2 if(typeof $.
cookie ==
"undefined")
throw "jsTree cookie: jQuery cookie plugin not included.";
4 $.extend($.tree.plugins, {
18 keep_selected :
false,
21 set_cookie :
function (type) {
22 var opts = $.extend(
true, {}, $.tree.plugins.cookie.defaults, this.settings.plugins.cookie);
23 if(opts.types[type] !==
true)
return false;
26 if(this.settings.rules.multiple !=
false &&
this.selected_arr.length > 1) {
28 $.each(this.selected_arr,
function () {
29 if(this.attr(
"id")) { val.push(this.attr(
"id")); }
33 else var val = this.selected ? this.selected.attr(
"id") :
false;
34 $.cookie(opts.prefix +
'selected', val, opts.options);
38 this.container.find(
"li.open").each(
function (i) {
if(this.
id) { str += this.
id +
","; } });
39 $.cookie(opts.prefix +
'open', str.replace(/,$/ig,
""), opts.options);
44 oninit :
function (t) {
45 var opts = $.extend(
true, {}, $.tree.plugins.cookie.defaults, this.settings.plugins.cookie);
47 tmp = $.cookie(opts.prefix +
'open');
50 if(opts.keep_opened) this.settings.opened = $.unique($.merge(tmp, this.settings.opened));
51 else this.settings.opened = tmp;
53 tmp = $.cookie(opts.prefix +
'selected');
56 if(opts.keep_selected) this.settings.selected = $.unique($.merge(tmp, this.settings.opened));
57 else this.settings.selected = tmp;
60 onchange :
function() { $.tree.plugins.cookie.set_cookie.apply(
this, [
"selected"]); },
61 onopen :
function() { $.tree.plugins.cookie.set_cookie.apply(
this, [
"open"]); },
62 onclose :
function() { $.tree.plugins.cookie.set_cookie.apply(
this, [
"open"]); },
63 ondelete :
function() { $.tree.plugins.cookie.set_cookie.apply(
this, [
"open"]); },
64 oncopy :
function() { $.tree.plugins.cookie.set_cookie.apply(
this, [
"open"]); },
65 oncreate :
function() { $.tree.plugins.cookie.set_cookie.apply(
this, [
"open"]); },
66 onmoved :
function() { $.tree.plugins.cookie.set_cookie.apply(
this, [
"open"]); }