Skip to content

Commit

Permalink
Reset jquery.tree to the previous version
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathias Helin committed Aug 31, 2017
1 parent 47f39f6 commit 8a11911
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 98 deletions.
135 changes: 68 additions & 67 deletions src/Backend/Modules/Pages/Js/jstree/plugins/jquery.tree.cookie.js
@@ -1,69 +1,70 @@
(function ($) {
if (typeof $.cookie === 'undefined') throw 'jsTree cookie: jQuery cookie plugin not included.'
if(typeof $.cookie == "undefined") throw "jsTree cookie: jQuery cookie plugin not included.";

$.extend($.tree.plugins, {
'cookie': {
defaults: {
prefix: '', // a prefix that will be used for all cookies for this tree
options: {
expires: false,
path: false,
domain: false,
secure: false
},
types: {
selected: true, // should we set the selected cookie
open: true // should we set the open cookie
},
keep_selected: false, // should we merge with the selected option or overwrite it
keep_opened: false // should we merge with the opened option or overwrite it
},
set_cookie: function (type) {
var opts = $.extend(true, {}, $.tree.plugins.cookie.defaults, this.settings.plugins.cookie)
if (opts.types[type] !== true) return false
switch (type) {
case 'selected':
if (this.settings.rules.multiple != false && this.selected_arr.length > 1) {
var val = Array()
$.each(this.selected_arr, function () {
if (this.attr('id')) { val.push(this.attr('id')) }
})
val = val.join(',')
} else var val = this.selected ? this.selected.attr('id') : false
$.cookie(opts.prefix + 'selected', val, opts.options)
break
case 'open':
var str = ''
this.container.find('li.open').each(function (i) { if (this.id) { str += this.id + ',' } })
$.cookie(opts.prefix + 'open', str.replace(/,$/ig, ''), opts.options)
break
}
},
callbacks: {
oninit: function (t) {
var opts = $.extend(true, {}, $.tree.plugins.cookie.defaults, this.settings.plugins.cookie)
var tmp = false
tmp = $.cookie(opts.prefix + 'open')
if (tmp) {
tmp = tmp.split(',')
if (opts.keep_opened) this.settings.opened = $.unique($.merge(tmp, this.settings.opened))
else this.settings.opened = tmp
}
tmp = $.cookie(opts.prefix + 'selected')
if (tmp) {
tmp = tmp.split(',')
if (opts.keep_selected) this.settings.selected = $.unique($.merge(tmp, this.settings.opened))
else this.settings.selected = tmp
}
},
onchange: function () { $.tree.plugins.cookie.set_cookie.apply(this, ['selected']) },
onopen: function () { $.tree.plugins.cookie.set_cookie.apply(this, ['open']) },
onclose: function () { $.tree.plugins.cookie.set_cookie.apply(this, ['open']) },
ondelete: function () { $.tree.plugins.cookie.set_cookie.apply(this, ['open']) },
oncopy: function () { $.tree.plugins.cookie.set_cookie.apply(this, ['open']) },
oncreate: function () { $.tree.plugins.cookie.set_cookie.apply(this, ['open']) },
onmoved: function () { $.tree.plugins.cookie.set_cookie.apply(this, ['open']) }
}
}
})
})(jQuery)
$.extend($.tree.plugins, {
"cookie" : {
defaults : {
prefix : "", // a prefix that will be used for all cookies for this tree
options : {
expires: false,
path: false,
domain: false,
secure: false
},
types : {
selected : true, // should we set the selected cookie
open : true // should we set the open cookie
},
keep_selected : false, // should we merge with the selected option or overwrite it
keep_opened : false // should we merge with the opened option or overwrite it
},
set_cookie : function (type) {
var opts = $.extend(true, {}, $.tree.plugins.cookie.defaults, this.settings.plugins.cookie);
if(opts.types[type] !== true) return false;
switch(type) {
case "selected":
if(this.settings.rules.multiple != false && this.selected_arr.length > 1) {
var val = Array();
$.each(this.selected_arr, function () {
if(this.attr("id")) { val.push(this.attr("id")); }
});
val = val.join(",");
}
else var val = this.selected ? this.selected.attr("id") : false;
$.cookie(opts.prefix + 'selected', val, opts.options);
break;
case "open":
var str = "";
this.container.find("li.open").each(function (i) { if(this.id) { str += this.id + ","; } });
$.cookie(opts.prefix + 'open', str.replace(/,$/ig,""), opts.options);
break;
}
},
callbacks : {
oninit : function (t) {
var opts = $.extend(true, {}, $.tree.plugins.cookie.defaults, this.settings.plugins.cookie);
var tmp = false;
tmp = $.cookie(opts.prefix + 'open');
if(tmp) {
tmp = tmp.split(",");
if(opts.keep_opened) this.settings.opened = $.unique($.merge(tmp, this.settings.opened));
else this.settings.opened = tmp;
}
tmp = $.cookie(opts.prefix + 'selected');
if(tmp) {
tmp = tmp.split(",");
if(opts.keep_selected) this.settings.selected = $.unique($.merge(tmp, this.settings.opened));
else this.settings.selected = tmp;
}
},
onchange : function() { $.tree.plugins.cookie.set_cookie.apply(this, ["selected"]); },
onopen : function() { $.tree.plugins.cookie.set_cookie.apply(this, ["open"]); },
onclose : function() { $.tree.plugins.cookie.set_cookie.apply(this, ["open"]); },
ondelete : function() { $.tree.plugins.cookie.set_cookie.apply(this, ["open"]); },
oncopy : function() { $.tree.plugins.cookie.set_cookie.apply(this, ["open"]); },
oncreate : function() { $.tree.plugins.cookie.set_cookie.apply(this, ["open"]); },
onmoved : function() { $.tree.plugins.cookie.set_cookie.apply(this, ["open"]); }
}
}
});
})(jQuery);
@@ -1,33 +1,33 @@
(function ($) {
$.extend($.tree.plugins, {
'themeroller': {
defaults: {
$.extend($.tree.plugins, {
"themeroller" : {
defaults : {

},
callbacks: {
oninit: function (t) {
if (this.settings.ui.theme_name != 'themeroller') return
var opts = $.extend(true, {}, $.tree.plugins.themeroller.defaults, this.settings.plugins.themeroller)
this.container.addClass('ui-widget ui-widget-content')
$('#' + this.container.attr('id') + ' li a').live('mouseover', function () { $(this).addClass('ui-state-hover') })
$('#' + this.container.attr('id') + ' li a').live('mouseout', function () { $(this).removeClass('ui-state-hover') })
},
onparse: function (s, t) {
if (this.settings.ui.theme_name != 'themeroller') return
var opts = $.extend(true, {}, $.tree.plugins.themeroller.defaults, this.settings.plugins.themeroller)
return $(s).find('a').not('.ui-state-default').addClass('ui-state-default').children('ins').addClass('ui-icon').end().end().end()
},
onselect: function (n, t) {
if (this.settings.ui.theme_name != 'themeroller') return
var opts = $.extend(true, {}, $.tree.plugins.themeroller.defaults, this.settings.plugins.themeroller)
$(n).children('a').addClass('ui-state-active')
},
ondeselect: function (n, t) {
if (this.settings.ui.theme_name != 'themeroller') return
var opts = $.extend(true, {}, $.tree.plugins.themeroller.defaults, this.settings.plugins.themeroller)
$(n).children('a').removeClass('ui-state-active')
}
}
}
})
})(jQuery)
},
callbacks : {
oninit : function (t) {
if(this.settings.ui.theme_name != "themeroller") return;
var opts = $.extend(true, {}, $.tree.plugins.themeroller.defaults, this.settings.plugins.themeroller);
this.container.addClass("ui-widget ui-widget-content");
$("#" + this.container.attr("id") + " li a").live("mouseover", function () { $(this).addClass("ui-state-hover"); });
$("#" + this.container.attr("id") + " li a").live("mouseout", function () { $(this).removeClass("ui-state-hover"); });
},
onparse : function (s, t) {
if(this.settings.ui.theme_name != "themeroller") return;
var opts = $.extend(true, {}, $.tree.plugins.themeroller.defaults, this.settings.plugins.themeroller);
return $(s).find("a").not(".ui-state-default").addClass("ui-state-default").children("ins").addClass("ui-icon").end().end().end();
},
onselect : function(n, t) {
if(this.settings.ui.theme_name != "themeroller") return;
var opts = $.extend(true, {}, $.tree.plugins.themeroller.defaults, this.settings.plugins.themeroller);
$(n).children("a").addClass("ui-state-active");
},
ondeselect : function(n, t) {
if(this.settings.ui.theme_name != "themeroller") return;
var opts = $.extend(true, {}, $.tree.plugins.themeroller.defaults, this.settings.plugins.themeroller);
$(n).children("a").removeClass("ui-state-active");
}
}
}
});
})(jQuery);

0 comments on commit 8a11911

Please sign in to comment.