Sha256: 33d174308aae593c16d59380e2c4698f68fbac0822b15080c3f271dc9fd9f744

Contents?: true

Size: 1.75 KB

Versions: 13

Compression:

Stored size: 1.75 KB

Contents

(function() {

  define(['view_model'], function(ViewModel) {
    var ViewCollection, ViewHeirModel, flatten;
    ViewCollection = Backbone.Collection;
    flatten = function(rootViewModel) {
      var childViewModel, flattenedViewModels, _i, _len, _ref;
      flattenedViewModels = [rootViewModel];
      _ref = rootViewModel.get('children');
      for (_i = 0, _len = _ref.length; _i < _len; _i++) {
        childViewModel = _ref[_i];
        flattenedViewModels = flattenedViewModels.concat(flatten(childViewModel));
      }
      return flattenedViewModels;
    };
    ViewHeirModel = Backbone.Model.extend({
      getAccessibleViews: function() {
        return this.get('allViews').filter(function(viewModel) {
          return viewModel.has('accessibilityLabel');
        });
      },
      resetViewHeir: function(rawRootView) {
        var allViews, rootViewModel,
          _this = this;
        rootViewModel = new ViewModel(rawRootView);
        allViews = new ViewCollection(flatten(rootViewModel));
        allViews.on('change:active', function(viewModel) {
          if (viewModel.get('active')) {
            return _this.trigger('active-view-changed', viewModel);
          }
        });
        allViews.on('selected', function(selectedViewModel) {
          allViews.each(function(viewModel) {
            return viewModel.set('selected', viewModel === selectedViewModel);
          });
          return _this.trigger('selected-view-changed', selectedViewModel);
        });
        allViews.on('accessible-selected', function(viewModel) {
          return _this.trigger('accessible-view-selected', viewModel);
        });
        this.set('root', rootViewModel);
        return this.set('allViews', allViews);
      }
    });
    return ViewHeirModel;
  });

}).call(this);

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.js
frank-cucumber-1.1.6 frank-skeleton/frank_static_resources.bundle/js/view_heir_model.js
frank-cucumber-1.1.5 frank-skeleton/frank_static_resources.bundle/js/view_heir_model.js
frank-cucumber-1.1.4.pre1 frank-skeleton/frank_static_resources.bundle/js/view_heir_model.js
frank-cucumber-1.1.3 frank-skeleton/frank_static_resources.bundle/js/view_heir_model.js
frank-cucumber-1.1.3.pre1 frank-skeleton/frank_static_resources.bundle/js/view_heir_model.js
frank-cucumber-1.1.2 frank-skeleton/frank_static_resources.bundle/js/view_heir_model.js
frank-cucumber-1.1.1 frank-skeleton/frank_static_resources.bundle/js/view_heir_model.js
frank-cucumber-1.1.0 frank-skeleton/frank_static_resources.bundle/js/view_heir_model.js
frank-cucumber-1.0.0 frank-skeleton/frank_static_resources.bundle/js/view_heir_model.js
frank-cucumber-0.9.8 frank-skeleton/frank_static_resources.bundle/js/view_heir_model.js
frank-cucumber-0.9.7 frank-skeleton/frank_static_resources.bundle/js/view_heir_model.js
frank-cucumber-1.0.0.pre2 frank-skeleton/frank_static_resources.bundle/js/view_heir_model.js