Sha256: d086088c9801137a8470c7be84ee30f41464ef3f574aaef3872c4c26fbcfc708

Contents?: true

Size: 1.95 KB

Versions: 13

Compression:

Stored size: 1.95 KB

Contents

(function() {

  define(['view_heir_model'], function(ViewHeirModel) {
    var TreeNodeView, TreeView;
    TreeNodeView = Backbone.View.extend({
      tagName: 'li',
      initialize: function() {
        return this.model.on('change:selected', _.bind(this.refreshSelectedness, this));
      },
      $a: function() {
        return this.$('> a');
      },
      render: function() {
        var $childList, child, childView, _i, _len, _ref,
          _this = this;
        $childList = $("<ul/>");
        _ref = this.model.get('children');
        for (_i = 0, _len = _ref.length; _i < _len; _i++) {
          child = _ref[_i];
          childView = new TreeNodeView({
            model: child
          });
          $childList.append(childView.render().el);
        }
        this.$el.append("<a>" + (this.model.getDesc()) + "</a>").append($childList);
        this.$a().on('mouseenter', function() {
          return _this.model.setActive();
        }).on('mouseleave', function() {
          return _this.model.unsetActive();
        }).on('click', function() {
          return _this.model.trigger('selected', _this.model);
        });
        this.refreshSelectedness();
        return this;
      },
      refreshSelectedness: function() {
        if (this.model.get('selected')) {
          return this.$a().addClass('selected');
        } else {
          return this.$a().removeClass('selected');
        }
      }
    });
    return TreeView = Backbone.View.extend({
      el: $('#dom-dump > ul'),
      initialize: function() {
        this.model = new ViewHeirModel();
        return this.model.on('change', _.bind(this.refresh, this));
      },
      refresh: function() {
        var rootNodeView;
        this.$el.empty();
        rootNodeView = new TreeNodeView({
          model: this.model.get('root')
        });
        this.$el.append(rootNodeView.render().el);
        return this.$el.treeview({
          collapsed: false
        });
      }
    });
  });

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