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-3.9.3 app/assets/javascripts/admin/treetable.js
trusty-cms-3.9.2 app/assets/javascripts/admin/treetable.js
trusty-cms-4.0.0 app/assets/javascripts/admin/treetable.js
trusty-cms-3.9.1 app/assets/javascripts/admin/treetable.js
trusty-cms-3.9.0 app/assets/javascripts/admin/treetable.js
trusty-cms-3.8.4 app/assets/javascripts/admin/treetable.js
trusty-cms-3.8.3 app/assets/javascripts/admin/treetable.js
trusty-cms-3.8.2 app/assets/javascripts/admin/treetable.js
trusty-cms-3.8.1 app/assets/javascripts/admin/treetable.js
trusty-cms-3.8.0 app/assets/javascripts/admin/treetable.js
trusty-cms-3.7.1 app/assets/javascripts/admin/treetable.js
trusty-cms-3.7.0 app/assets/javascripts/admin/treetable.js
trusty-cms-3.6.2 app/assets/javascripts/admin/treetable.js
trusty-cms-3.6.1 app/assets/javascripts/admin/treetable.js
trusty-cms-3.6.0 app/assets/javascripts/admin/treetable.js
trusty-cms-3.5.5 app/assets/javascripts/admin/treetable.js
trusty-cms-3.5.4 app/assets/javascripts/admin/treetable.js
trusty-cms-3.5.3 app/assets/javascripts/admin/treetable.js
trusty-cms-3.5.2 app/assets/javascripts/admin/treetable.js
trusty-cms-3.5.1 app/assets/javascripts/admin/treetable.js