1/* File: jstree.state.js 2This plugin enables state saving between reloads. 3*/ 4/* Group: jstree state plugin */ 5(function ($) { 6 $.jstree.plugin("state", { 7 __construct : function () { 8 if(typeof $.vakata.storage === "undefined") { throw "jsTree state plugin: vakata storage helper not included."; } 9 10 this.get_container() 11 .bind("__loaded.jstree", $.proxy(function (e, data) { 12 this.restore_state(); 13 }, this)) 14 .bind("__ready.jstree", $.proxy(function (e, data) { 15 this.get_container() 16 .bind(this.get_settings(true).state.events, $.proxy(function () { 17 this.save_state(); 18 }, this)); 19 }, this)); 20 }, 21 defaults : { 22 key : 'jstree', // pass unique name to work with many trees 23 events : 'select_node.jstree open_node.jstree close_node.jstree deselect_node.jstree deselect_all.jstree' 24 }, 25 _fn : { 26 save_state : function () { 27 var s = this.get_settings(true).state; 28 $.vakata.storage.set(s.key, this.get_state()); 29 }, 30 restore_state : function () { 31 var s = this.get_settings(true).state, 32 k = $.vakata.storage.get(s.key); 33 if(!!k) { this.set_state(k); } 34 } 35 } 36 }); 37 // include the state plugin by default 38 // $.jstree.defaults.plugins.push("state"); 39})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.