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

Version Path
frank-cucumber-1.1.7 frank-skeleton/frank_static_resources.bundle/js/view_heir_model.coffee
frank-cucumber-1.1.6 frank-skeleton/frank_static_resources.bundle/js/view_heir_model.coffee
frank-cucumber-1.1.5 frank-skeleton/frank_static_resources.bundle/js/view_heir_model.coffee
frank-cucumber-1.1.4.pre1 frank-skeleton/frank_static_resources.bundle/js/view_heir_model.coffee
frank-cucumber-1.1.3 frank-skeleton/frank_static_resources.bundle/js/view_heir_model.coffee
frank-cucumber-1.1.3.pre1 frank-skeleton/frank_static_resources.bundle/js/view_heir_model.coffee
frank-cucumber-1.1.2 frank-skeleton/frank_static_resources.bundle/js/view_heir_model.coffee
frank-cucumber-1.1.1 frank-skeleton/frank_static_resources.bundle/js/view_heir_model.coffee
frank-cucumber-1.1.0 frank-skeleton/frank_static_resources.bundle/js/view_heir_model.coffee
frank-cucumber-1.0.0 frank-skeleton/frank_static_resources.bundle/js/view_heir_model.coffee
frank-cucumber-0.9.8 frank-skeleton/frank_static_resources.bundle/js/view_heir_model.coffee
frank-cucumber-0.9.7 frank-skeleton/frank_static_resources.bundle/js/view_heir_model.coffee
frank-cucumber-1.0.0.pre2 frank-skeleton/frank_static_resources.bundle/js/view_heir_model.coffee