travis-web/app/utils/limited-array.coffee
2015-02-03 09:48:22 +01:00

29 lines
624 B
CoffeeScript

`import Ember from 'ember'`
`import limit from 'travis/utils/computed-limit'`
LimitedArray = Ember.ArrayProxy.extend
limit: 10
isLoadedBinding: 'content.isLoaded'
arrangedContent: 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
`export default LimitedArray`