You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
localStorage is made to store Client code information, Cookie is better use to store information that need to be shared with the server. So i think that to store Open/Selected node the default should be localStorage instead.
/* * jsTree storage plugin * Stores the currently opened/selected nodes in a localStorage and then restores them */(function($){$.jstree.plugin("localStorage",{__init : function(){if(typeoflocalStorage==="undefined"){throw"jsTree localStorage: localStorage is not supported by your browser.";}vars=this._get_settings().localStorage;vartmp;if(!!s.save_loaded){tmp=localStorage.getItem(s.save_loaded);if(tmp&&tmp.length){this.data.core.to_load=tmp.split(",");}}if(!!s.save_opened){tmp=localStorage.getItem(s.save_opened);if(tmp&&tmp.length){this.data.core.to_open=tmp.split(",");}}if(!!s.save_selected){tmp=localStorage.getItem(s.save_selected);if(tmp&&tmp.length&&this.data.ui){this.data.ui.to_select=tmp.split(",");}}this.get_container().one((this.data.ui ? "reselect" : "reopen")+".jstree",$.proxy(function(){this.get_container().bind("open_node.jstree close_node.jstree select_node.jstree deselect_node.jstree",$.proxy(function(e){if(this._get_settings().localStorage.auto_save){this.save_node((e.handleObj.namespace+e.handleObj.type).replace("jstree",""));}},this));},this));},defaults : {save_loaded : "jstree_load",save_opened : "jstree_open",save_selected : "jstree_select",auto_save : true,localStorage_options : {}},_fn : {save_node : function(c){if(this.data.core.refreshing){return;}vars=this._get_settings().localStorage;if(!c){// if called manually and not by eventif(s.save_loaded){this.save_loaded();localStorage.setItem(s.save_loaded,this.data.core.to_load.join(","));}if(s.save_opened){this.save_opened();localStorage.setItem(s.save_opened,this.data.core.to_open.join(","));}if(s.save_selected&&this.data.ui){this.save_selected();localStorage.setItem(s.save_selected,this.data.ui.to_select.join(","));}return;}switch(c){case"open_node":
case"close_node":
if(!!s.save_opened){this.save_opened();localStorage.setItem(s.save_opened,this.data.core.to_open.join(","));}if(!!s.save_loaded){this.save_loaded();localStorage.setItem(s.save_loaded,this.data.core.to_load.join(","));}break;case"select_node":
case"deselect_node":
if(!!s.save_selected&&this.data.ui){this.save_selected();localStorage.setItem(s.save_selected,this.data.ui.to_select.join(","));}break;}}}});// include localStorage by default$.jstree.defaults.plugins.push("localStorage");})(jQuery);
edit: tried to fix code formating issue.
edit2: found how to properly use "GitHub Flavored Markdown"
The text was updated successfully, but these errors were encountered:
Thank you for the contribution! I will update the 1.0 branch very soon. I was also thinking about localStorage, but at the time of releasing the cookie plugin browser support was minimal, now things are different. Thank you for the great work. I was thinking of maybe using a minimal library that will support all major browser + a cookie fallback maybe (sorry if this is non-sense - I haven't looked at localStorage for some time now. Once again - thanks! I will release the 1.0 state plugin soon.
I added a helper for local storage (used jstorage), which tries to work with localstorage, globalstorage, userdata (for IE), and finally falls back to cookies.
I also just commited a small state plugin that seems to work, not thoroughly tested though.
localStorage is made to store Client code information, Cookie is better use to store information that need to be shared with the server. So i think that to store Open/Selected node the default should be localStorage instead.
edit: tried to fix code formating issue.
edit2: found how to properly use "GitHub Flavored Markdown"
The text was updated successfully, but these errors were encountered: