Sha256: c3985802f7dbe69c9d561bb7981a9defa5e696e1a29e21df0c9d14d601c055d5

Contents?: true

Size: 1.52 KB

Versions: 154

Compression:

Stored size: 1.52 KB

Contents

$(function() {
  var persistStore = new Persist.Store("Trusty CMS");
  var needToExpand = [];
  $("#pages").treetable({
    expandable: true,
    initialState: "collapsed",
    onNodeCollapse: function() {
      var node = this;
      persistStore.remove(node.id);
      $("#pages").treetable("unloadBranch", this);
    },
    onInitialized: function() {
      var length = needToExpand.length;
      for (var i = 0; i < length; i++)
        $("#pages").treetable("expandNode", needToExpand[i]);
    },
    onNodeInitialized: function() {
      var node = this;
      var state = persistStore.get(node.id);
      if (state) {
        needToExpand.push(node.id);
      }

    },
    onNodeExpand: function() {
      var node = this;
      var spinner = $($(node.row[0]).find(".busy")[0]);
      spinner.show();
      persistStore.set(node.id, 'expanded');
      // Render loader/spinner while loading
      $.ajax({
        async: true, // Must be false, otherwise loadBranch happens after showChildren?
        url: "/admin/pages/" + node.row.data('ttPageId') + "/children?index=" + node.id
      }).done(function(html) {
        var rows = $(html).filter("tr");

        $("#pages").treetable("loadBranch", node, rows);
        $.each(node.children, function() {
          var state = persistStore.get(this.id);
          if (state) {
            $("#pages").treetable("expandNode", this.id);
          }
        });
        $('a.dropdown').each(function(){
          Dropdown.setup(this);
        });
        spinner.hide();
      });
    }
  });
});

Version data entries

154 entries across 154 versions & 1 rubygems

Version Path
trusty-cms-6.3.1 app/assets/javascripts/admin/treetable.js
trusty-cms-7.0.2 app/assets/javascripts/admin/treetable.js
trusty-cms-7.0.1 app/assets/javascripts/admin/treetable.js
trusty-cms-7.0.0 app/assets/javascripts/admin/treetable.js
trusty-cms-6.3 app/assets/javascripts/admin/treetable.js
trusty-cms-6.2.1 app/assets/javascripts/admin/treetable.js
trusty-cms-6.2.2.1 app/assets/javascripts/admin/treetable.js
trusty-cms-6.2.0 app/assets/javascripts/admin/treetable.js
trusty-cms-6.1.2 app/assets/javascripts/admin/treetable.js
trusty-cms-6.1.1 app/assets/javascripts/admin/treetable.js
trusty-cms-6.0.5 app/assets/javascripts/admin/treetable.js
trusty-cms-6.0.4 app/assets/javascripts/admin/treetable.js
trusty-cms-6.0.3 app/assets/javascripts/admin/treetable.js
trusty-cms-6.0.2 app/assets/javascripts/admin/treetable.js
trusty-cms-6.0.1 app/assets/javascripts/admin/treetable.js
trusty-cms-5.6.1 app/assets/javascripts/admin/treetable.js
trusty-cms-6.0.0 app/assets/javascripts/admin/treetable.js
trusty-cms-5.6.0 app/assets/javascripts/admin/treetable.js
trusty-cms-5.5.9 app/assets/javascripts/admin/treetable.js
trusty-cms-5.5.8 app/assets/javascripts/admin/treetable.js