Sha256: 1b5b4bfea7a4fe430a8e14d00ac29c435f06d8d8e5e0f5908701480e055b6fd7
Contents?: true
Size: 1.39 KB
Versions: 1
Compression:
Stored size: 1.39 KB
Contents
unless typeof define is 'function' and define.amd module = @GooglePlus ||= {} @define = (name, deps, callback) -> module.Reader = callback(jQuery) define 'googleplus.reader', ['jquery'], ($) -> class constructor: (options) -> @id = options.id @key = options.key @token = null @collection = [] @position = 0 next: (count) -> deferred = $.Deferred() nextPosition = @position + count if nextPosition <= @collection.length elements = @collection.slice(@position, nextPosition) @position = nextPosition deferred.resolve(elements) else @load() .done => nextPosition = Math.min(nextPosition, @collection.length) elements = @collection.slice(@position, nextPosition) @position = nextPosition deferred.resolve(elements) return .fail (details...) => deferred.reject(details...) return deferred.promise() load: -> url = "https://www.googleapis.com/plus/v1/people/#{@id}/activities/public?key=#{@key}" url = "#{url}&pageToken=#{@token}" if @token $.ajax(url: url, crossDomain: true, dataType: 'jsonp').done (result) => @append(result.items) @token = result.nextPageToken return append: (items) -> @collection.push(item) for item in items return
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
googleplus-reader-0.0.5 | lib/assets/javascripts/googleplus.reader.js.coffee |