travis-web/assets/scripts/app/utils/limited-array.coffee
2015-01-30 09:10:48 +01:00

26 lines
565 B
CoffeeScript

LimitedArray = Ember.ArrayProxy.extend
limit: 10
isLoadedBinding: 'content.isLoaded'
arrangedContent: Ember.computed.limit('content', 'limit')
totalLength: (->
@get('content.length')
).property('content.length')
leftLength: (->
totalLength = @get('totalLength')
limit = @get('limit')
left = totalLength - limit
if left < 0 then 0 else left
).property('totalLength', 'limit')
isMore: (->
@get('leftLength') > 0
).property('leftLength')
showAll: ->
@set 'limit', Infinity
Travis.LimitedArray = LimitedArray