travis-web/assets/scripts/lib/travis/limited_array.coffee
Piotr Sarnacki 36db80d45f Add Ember.computed.limit and use it in LimitedArray
arrayComputed was added recently in order to make array computations
easier. Using arrayComputed we can improve LimitedArray which now uses
an isolated multipurpose Ember.computed.limit.
2014-02-18 10:00:33 +01:00

24 lines
533 B
CoffeeScript

Travis.LimitedArray = Em.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