diff --git a/modules/admin/tpl/js/jquery.jstree.js b/modules/admin/tpl/js/jquery.jstree.js index 35cb97856..b9a5611ae 100644 --- a/modules/admin/tpl/js/jquery.jstree.js +++ b/modules/admin/tpl/js/jquery.jstree.js @@ -13,7 +13,7 @@ */ /*jslint browser: true, onevar: true, undef: true, bitwise: true, strict: true */ -/*global window : false, clearInterval: false, clearTimeout: false, document: false, setInterval: false, setTimeout: false, jQuery: false, navigator: false, XSLTProcessor: false, DOMParser: false, XMLSerializer: false*/ +/*global window : false, clearInterval: false, clearTimeout: false, document: false, setInterval: false, setTimeout: false, jQuery: false, navigator: false, XSLTProcessor: false, DOMParser: false, XMLSerializer: false, ActiveXObject: false */ "use strict"; @@ -114,7 +114,7 @@ if(isMethodCall) { if(settings.substring(0, 1) == '_') { return returnValue; } this.each(function() { - var instance = instances[$.data(this, "jstree-instance-id")], + var instance = instances[$.data(this, "jstree_instance_id")], methodValue = (instance && $.isFunction(instance[settings])) ? instance[settings].apply(instance, args) : instance; if(typeof methodValue !== "undefined" && (settings.indexOf("is_") === 0 || (methodValue !== true && methodValue !== false))) { returnValue = methodValue; return false; } }); @@ -122,7 +122,7 @@ else { this.each(function() { // extend settings and allow for multiple hashes and $.data - var instance_id = $.data(this, "jstree-instance-id"), + var instance_id = $.data(this, "jstree_instance_id"), a = [], b = settings ? $.extend({}, true, settings) : {}, c = $(this), @@ -137,7 +137,7 @@ // push a new empty object to the instances array instance_id = parseInt(instances.push({}),10) - 1; // store the jstree instance id to the container element - $.data(this, "jstree-instance-id", instance_id); + $.data(this, "jstree_instance_id", instance_id); // clean up all plugins b.plugins = $.isArray(b.plugins) ? b.plugins : $.jstree.defaults.plugins.slice(); b.plugins.unshift("core"); @@ -159,7 +159,7 @@ $.each(instances[instance_id]._get_settings().plugins, function (i, val) { instances[instance_id].data[val] = {}; }); $.each(instances[instance_id]._get_settings().plugins, function (i, val) { if(plugins[val]) { plugins[val].__init.apply(instances[instance_id]); } }); // initialize the instance - setTimeout(function() { instances[instance_id].init(); }, 0); + setTimeout(function() { if(instances[instance_id]) { instances[instance_id].init(); } }, 0); }); } // return the jquery selection (or if it was a method call that returned a value - the returned value) @@ -178,7 +178,7 @@ var o = $(needle); if(!o.length && typeof needle === "string") { o = $("#" + needle); } if(!o.length) { return null; } - return instances[o.closest(".jstree").data("jstree-instance-id")] || null; + return instances[o.closest(".jstree").data("jstree_instance_id")] || null; }, _instance : function (index, container, settings) { // for plugins to store data in @@ -276,7 +276,7 @@ '.jstree-rtl li { margin-left:0; margin-right:18px; } ' + '.jstree > ul > li { margin-left:0px; } ' + '.jstree-rtl > ul > li { margin-right:0px; } ' + - '.jstree ins { display:inline-block; text-decoration:none; width:18px; height:18px; margin:0 0 0 0; padding:0; vertical-align:top; } ' + + '.jstree ins { display:inline-block; text-decoration:none; width:18px; height:18px; margin:0 0 0 0; padding:0; } ' + '.jstree a { display:inline-block; line-height:16px; height:16px; color:black; white-space:nowrap; text-decoration:none; padding:1px 2px; margin:0; } ' + '.jstree a:focus { outline: none; } ' + '.jstree a > ins { height:16px; width:16px; } ' + @@ -356,7 +356,8 @@ this.get_container() .delegate("li > ins", "click.jstree", $.proxy(function (event) { var trgt = $(event.target); - if(trgt.is("ins") && event.pageY - trgt.offset().top < this.data.core.li_height) { this.toggle_node(trgt); } + // if(trgt.is("ins") && event.pageY - trgt.offset().top < this.data.core.li_height) { this.toggle_node(trgt); } + this.toggle_node(trgt); }, this)) .bind("mousedown.jstree", $.proxy(function () { this.set_focus(); // This used to be setTimeout(set_focus,0) - why? @@ -433,7 +434,7 @@ this.get_container() .unbind(".jstree") .undelegate(".jstree") - .removeData("jstree-instance-id") + .removeData("jstree_instance_id") .find("[class^='jstree']") .addBack() .attr("class", function () { return this.className.replace(/jstree[^ ]*|$/ig,''); }); @@ -752,6 +753,7 @@ if(m.language) { tmp.addClass(m.language); } } tmp.prepend(" "); + if(!m.icon && js.icon) { m.icon = js.icon; } if(m.icon) { if(m.icon.indexOf("/") === -1) { tmp.children("ins").addClass(m.icon); } else { tmp.children("ins").css("background","url('" + m.icon + "') center center no-repeat"); } @@ -920,10 +922,12 @@ check_move : function () { var obj = prepared_move, ret = true, r = obj.r === -1 ? this.get_container() : obj.r; if(!obj || !obj.o || obj.or[0] === obj.o[0]) { return false; } - if(obj.op && obj.np && obj.op[0] === obj.np[0] && obj.cp - 1 === obj.o.index()) { return false; } - obj.o.each(function () { - if(r.parentsUntil(".jstree", "li").addBack().index(this) !== -1) { ret = false; return false; } - }); + if(!obj.cy) { + if(obj.op && obj.np && obj.op[0] === obj.np[0] && obj.cp - 1 === obj.o.index()) { return false; } + obj.o.each(function () { + if(r.parentsUntil(".jstree", "li").addBack().index(this) !== -1) { ret = false; return false; } + }); + } return ret; }, move_node : function (obj, ref, position, is_copy, is_prepared, skip_check) { @@ -1272,16 +1276,15 @@ "class" : "jstree-rename-input", // "size" : t.length, "css" : { - "padding" : "0 4px", + "padding" : "0", "border" : "1px solid silver", - "borderRadius" : "3px", "position" : "absolute", - "left" : (rtl ? "auto" : (w1 + w2) + "px"), + "left" : (rtl ? "auto" : (w1 + w2 + 4) + "px"), "right" : (rtl ? (w1 + w2 + 4) + "px" : "auto"), - "top" : "0", + "top" : "0px", "height" : (this.data.core.li_height - 2) + "px", "lineHeight" : (this.data.core.li_height - 2) + "px", - "width" : "200px" // will be set a bit further down + "width" : "150px" // will be set a bit further down }, "blur" : $.proxy(function () { var i = obj.children(".jstree-rename-input"), @@ -1659,7 +1662,7 @@ obj = this._get_node(obj); var s = this._get_settings().json_data; if(obj && obj !== -1 && s.progressive_unload && ($.isFunction(s.data) || !!s.ajax)) { - obj.removeData("jstree-children"); + obj.removeData("jstree_children"); } return this.__call_old(); }, @@ -1669,11 +1672,11 @@ success_func = function () {}; obj = this._get_node(obj); - if(obj && obj !== -1 && (s.progressive_render || s.progressive_unload) && !obj.is(".jstree-open, .jstree-leaf") && obj.children("ul").children("li").length === 0 && obj.data("jstree-children")) { - d = this._parse_json(obj.data("jstree-children"), obj); + if(obj && obj !== -1 && (s.progressive_render || s.progressive_unload) && !obj.is(".jstree-open, .jstree-leaf") && obj.children("ul").children("li").length === 0 && obj.data("jstree_children")) { + d = this._parse_json(obj.data("jstree_children"), obj); if(d) { obj.append(d); - if(!s.progressive_unload) { obj.removeData("jstree-children"); } + if(!s.progressive_unload) { obj.removeData("jstree_children"); } } this.clean_node(obj); if(s_call) { s_call.call(this); } @@ -1681,8 +1684,8 @@ } if(obj && obj !== -1) { - if(obj.data("jstree-is-loading")) { return; } - else { obj.data("jstree-is-loading",true); } + if(obj.data("jstree_is_loading")) { return; } + else { obj.data("jstree_is_loading",true); } } switch(!0) { case (!s.data && !s.ajax): throw "Neither data nor ajax settings supplied."; @@ -1696,14 +1699,14 @@ } else { obj.children("a.jstree-loading").removeClass("jstree-loading"); - obj.removeData("jstree-is-loading"); + obj.removeData("jstree_is_loading"); if(s.correct_state) { this.correct_state(obj); } } if(e_call) { e_call.call(this); } } else { if(obj === -1 || !obj) { this.get_container().children("ul").empty().append(d.children()); } - else { obj.append(d).children("a.jstree-loading").removeClass("jstree-loading"); obj.removeData("jstree-is-loading"); } + else { obj.append(d).children("a.jstree-loading").removeClass("jstree-loading"); obj.removeData("jstree_is_loading"); } this.clean_node(obj); if(s_call) { s_call.call(this); } } @@ -1728,7 +1731,7 @@ if(ef) { ef.call(this, x, t, e); } if(obj != -1 && obj.length) { obj.children("a.jstree-loading").removeClass("jstree-loading"); - obj.removeData("jstree-is-loading"); + obj.removeData("jstree_is_loading"); if(t === "success" && s.correct_state) { this.correct_state(obj); } } else { @@ -1745,7 +1748,7 @@ d = this._parse_json(d, obj); if(d) { if(obj === -1 || !obj) { this.get_container().children("ul").empty().append(d.children()); } - else { obj.append(d).children("a.jstree-loading").removeClass("jstree-loading"); obj.removeData("jstree-is-loading"); } + else { obj.append(d).children("a.jstree-loading").removeClass("jstree-loading"); obj.removeData("jstree_is_loading"); } this.clean_node(obj); if(s_call) { s_call.call(this); } } @@ -1758,7 +1761,7 @@ } else { obj.children("a.jstree-loading").removeClass("jstree-loading"); - obj.removeData("jstree-is-loading"); + obj.removeData("jstree_is_loading"); if(s.correct_state) { this.correct_state(obj); if(s_call) { s_call.call(this); } @@ -1785,15 +1788,18 @@ if(!js) { return d; } if(s.progressive_unload && obj && obj !== -1) { - obj.data("jstree-children", d); + obj.data("jstree_children", d); } if($.isArray(js)) { - d = $(); + d = $('