Sha256: ec6b999b2ec174137ff889bf9c41509f01c2b64e819321d95a63987ca7d28de2
Contents?: true
Size: 1.16 KB
Versions: 13
Compression:
Stored size: 1.16 KB
Contents
define ['view_model'], (ViewModel)-> ViewCollection = Backbone.Collection flatten = (rootViewModel)-> flattenedViewModels = [rootViewModel] for childViewModel in rootViewModel.get('children') flattenedViewModels = flattenedViewModels.concat( flatten(childViewModel) ) flattenedViewModels ViewHeirModel = Backbone.Model.extend getAccessibleViews: -> @get( 'allViews' ).filter (viewModel)-> viewModel.has('accessibilityLabel') resetViewHeir: (rawRootView)-> rootViewModel = new ViewModel(rawRootView) allViews = new ViewCollection( flatten( rootViewModel ) ) allViews.on 'change:active', (viewModel)=> if viewModel.get('active') @trigger( 'active-view-changed', viewModel ) allViews.on 'selected', (selectedViewModel)=> allViews.each (viewModel)-> viewModel.set('selected',viewModel == selectedViewModel) @trigger( 'selected-view-changed', selectedViewModel ) allViews.on 'accessible-selected', (viewModel)=> @trigger( 'accessible-view-selected', viewModel ) @set( 'root', rootViewModel ) @set( 'allViews', allViews ) ViewHeirModel
Version data entries
13 entries across 13 versions & 1 rubygems