Skip to content

Commit

Permalink
update jstree to v3.30
Browse files Browse the repository at this point in the history
  • Loading branch information
dleffler committed Nov 4, 2016
1 parent 559792b commit 1ed5596
Show file tree
Hide file tree
Showing 3 changed files with 216 additions and 37 deletions.
185 changes: 148 additions & 37 deletions external/jquery/addons/js/jstree.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
}(function ($, undefined) {
"use strict";
/*!
* jsTree 3.3.2
* jsTree 3.3.3
* http://jstree.com/
*
* Copyright (c) 2014 Ivan Bozhanov (http://vakata.com)
Expand Down Expand Up @@ -43,25 +43,7 @@
ccp_inst = false,
themes_loaded = [],
src = $('script:last').attr('src'),
document = window.document, // local variable is always faster to access then a global
_node = document.createElement('LI'), _temp1, _temp2;

_node.setAttribute('role', 'treeitem');
_temp1 = document.createElement('I');
_temp1.className = 'jstree-icon jstree-ocl';
_temp1.setAttribute('role', 'presentation');
_node.appendChild(_temp1);
_temp1 = document.createElement('A');
_temp1.className = 'jstree-anchor';
_temp1.setAttribute('href','#');
_temp1.setAttribute('tabindex','-1');
_temp2 = document.createElement('I');
_temp2.className = 'jstree-icon jstree-themeicon';
_temp2.setAttribute('role', 'presentation');
_temp1.appendChild(_temp2);
_node.appendChild(_temp1);
_temp1 = _temp2 = null;

document = window.document; // local variable is always faster to access then a global

/**
* holds all jstree related functions and variables, including the actual class and methods to create, access and manipulate instances.
Expand All @@ -72,7 +54,7 @@
* specifies the jstree version in use
* @name $.jstree.version
*/
version : '3.3.2',
version : '3.3.3',
/**
* holds all the default options used when creating new instances
* @name $.jstree.defaults
Expand All @@ -93,6 +75,7 @@
idregex : /[\\:&!^|()\[\]<>@*'+~#";.,=\- \/${}%?`]/g,
root : '#'
};

/**
* creates a jstree instance
* @name $.jstree.create(el [, options])
Expand Down Expand Up @@ -139,7 +122,8 @@
themes : {
name : false,
dots : false,
icons : false
icons : false,
ellipsis : false
},
selected : [],
last_error : {},
Expand Down Expand Up @@ -409,6 +393,11 @@
* @name $.jstree.defaults.core.themes.icons
*/
icons : true,
/**
* a boolean indicating if node ellipsis should be shown - this only works with a fixed with on the container
* @name $.jstree.defaults.core.themes.ellipsis
*/
ellipsis : false,
/**
* a boolean indicating if the tree background is striped
* @name $.jstree.defaults.core.themes.stripes
Expand Down Expand Up @@ -527,6 +516,7 @@
this.element.html("<"+"ul class='jstree-container-ul jstree-children' role='group'><"+"li id='j"+this._id+"_loading' class='jstree-initial-node jstree-loading jstree-leaf jstree-last' role='tree-item'><i class='jstree-icon jstree-ocl'></i><"+"a class='jstree-anchor' href='#'><i class='jstree-icon jstree-themeicon-hidden'></i>" + this.get_string("Loading ...") + "</a></li></ul>");
this.element.attr('aria-activedescendant','j' + this._id + '_loading');
this._data.core.li_height = this.get_container_ul().children("li").first().height() || 24;
this._data.core.node = this._create_prototype_node();
/**
* triggered after the loading text is shown and before loading starts
* @event
Expand All @@ -551,6 +541,29 @@
if(!keep_html) { this.element.empty(); }
this.teardown();
},
/**
* Create prototype node
*/
_create_prototype_node : function () {
var _node = document.createElement('LI'), _temp1, _temp2;
_node.setAttribute('role', 'treeitem');
_temp1 = document.createElement('I');
_temp1.className = 'jstree-icon jstree-ocl';
_temp1.setAttribute('role', 'presentation');
_node.appendChild(_temp1);
_temp1 = document.createElement('A');
_temp1.className = 'jstree-anchor';
_temp1.setAttribute('href','#');
_temp1.setAttribute('tabindex','-1');
_temp2 = document.createElement('I');
_temp2.className = 'jstree-icon jstree-themeicon';
_temp2.setAttribute('role', 'presentation');
_temp1.appendChild(_temp2);
_node.appendChild(_temp1);
_temp1 = _temp2 = null;

return _node;
},
/**
* part of the destroying of an instance. Used internally.
* @private
Expand Down Expand Up @@ -801,13 +814,15 @@
this._data.core.themes.dots = s.dots;
this._data.core.themes.stripes = s.stripes;
this._data.core.themes.icons = s.icons;
this._data.core.themes.ellipsis = s.ellipsis;
this.set_theme(s.name || "default", s.url);
this.set_theme_variant(s.variant);
}, this))
.on("loading.jstree", $.proxy(function () {
this[ this._data.core.themes.dots ? "show_dots" : "hide_dots" ]();
this[ this._data.core.themes.icons ? "show_icons" : "hide_icons" ]();
this[ this._data.core.themes.stripes ? "show_stripes" : "hide_stripes" ]();
this[ this._data.core.themes.ellipsis ? "show_ellipsis" : "hide_ellipsis" ]();
}, this))
.on('blur.jstree', '.jstree-anchor', $.proxy(function (e) {
this._data.core.focused = null;
Expand Down Expand Up @@ -2358,7 +2373,7 @@
//node = d.createElement('LI');
//node = node[0];
}
node = _node.cloneNode(true);
node = this._data.core.node.cloneNode(true);
// node is DOM, deep is boolean

c = 'jstree-node ';
Expand Down Expand Up @@ -2865,7 +2880,7 @@
* hides a node - it is still in the structure but will not be visible
* @name hide_node(obj)
* @param {mixed} obj the node to hide
* @param {Boolean} redraw internal parameter controlling if redraw is called
* @param {Boolean} skip_redraw internal parameter controlling if redraw is called
* @trigger hide_node.jstree
*/
hide_node : function (obj, skip_redraw) {
Expand Down Expand Up @@ -4518,12 +4533,30 @@
* shows a striped background on the container (if the theme supports it)
* @name show_stripes()
*/
show_stripes : function () { this._data.core.themes.stripes = true; this.get_container_ul().addClass("jstree-striped"); },
show_stripes : function () {
this._data.core.themes.stripes = true;
this.get_container_ul().addClass("jstree-striped");
/**
* triggered when stripes are shown
* @event
* @name show_stripes.jstree
*/
this.trigger('show_stripes');
},
/**
* hides the striped background on the container
* @name hide_stripes()
*/
hide_stripes : function () { this._data.core.themes.stripes = false; this.get_container_ul().removeClass("jstree-striped"); },
hide_stripes : function () {
this._data.core.themes.stripes = false;
this.get_container_ul().removeClass("jstree-striped");
/**
* triggered when stripes are hidden
* @event
* @name hide_stripes.jstree
*/
this.trigger('hide_stripes');
},
/**
* toggles the striped background on the container
* @name toggle_stripes()
Expand All @@ -4533,12 +4566,30 @@
* shows the connecting dots (if the theme supports it)
* @name show_dots()
*/
show_dots : function () { this._data.core.themes.dots = true; this.get_container_ul().removeClass("jstree-no-dots"); },
show_dots : function () {
this._data.core.themes.dots = true;
this.get_container_ul().removeClass("jstree-no-dots");
/**
* triggered when dots are shown
* @event
* @name show_dots.jstree
*/
this.trigger('show_dots');
},
/**
* hides the connecting dots
* @name hide_dots()
*/
hide_dots : function () { this._data.core.themes.dots = false; this.get_container_ul().addClass("jstree-no-dots"); },
hide_dots : function () {
this._data.core.themes.dots = false;
this.get_container_ul().addClass("jstree-no-dots");
/**
* triggered when dots are hidden
* @event
* @name hide_dots.jstree
*/
this.trigger('hide_dots');
},
/**
* toggles the connecting dots
* @name toggle_dots()
Expand All @@ -4548,17 +4599,68 @@
* show the node icons
* @name show_icons()
*/
show_icons : function () { this._data.core.themes.icons = true; this.get_container_ul().removeClass("jstree-no-icons"); },
show_icons : function () {
this._data.core.themes.icons = true;
this.get_container_ul().removeClass("jstree-no-icons");
/**
* triggered when icons are shown
* @event
* @name show_icons.jstree
*/
this.trigger('show_icons');
},
/**
* hide the node icons
* @name hide_icons()
*/
hide_icons : function () { this._data.core.themes.icons = false; this.get_container_ul().addClass("jstree-no-icons"); },
hide_icons : function () {
this._data.core.themes.icons = false;
this.get_container_ul().addClass("jstree-no-icons");
/**
* triggered when icons are hidden
* @event
* @name hide_icons.jstree
*/
this.trigger('hide_icons');
},
/**
* toggle the node icons
* @name toggle_icons()
*/
toggle_icons : function () { if(this._data.core.themes.icons) { this.hide_icons(); } else { this.show_icons(); } },
/**
* show the node ellipsis
* @name show_icons()
*/
show_ellipsis : function () {
this._data.core.themes.ellipsis = true;
this.get_container_ul().addClass("jstree-ellipsis");
/**
* triggered when ellisis is shown
* @event
* @name show_ellipsis.jstree
*/
this.trigger('show_ellipsis');
},
/**
* hide the node ellipsis
* @name hide_ellipsis()
*/
hide_ellipsis : function () {
this._data.core.themes.ellipsis = false;
this.get_container_ul().removeClass("jstree-ellipsis");
/**
* triggered when ellisis is hidden
* @event
* @name hide_ellipsis.jstree
*/
this.trigger('hide_ellipsis');
},
/**
* toggle the node ellipsis
* @name toggle_icons()
*/
toggle_ellipsis : function () { if(this._data.core.themes.ellipsis) { this.hide_ellipsis(); } else { this.show_ellipsis(); } },
/**
* set the node icon for a node
* @name set_icon(obj, icon)
Expand Down Expand Up @@ -6203,7 +6305,7 @@
switch(e.which) {
case 13:
case 32:
e.type = "mouseup";
e.type = "click";
e.preventDefault();
$(e.currentTarget).trigger(e);
break;
Expand Down Expand Up @@ -7182,7 +7284,7 @@
return a.call(this, str, $.proxy(function (d) {
if(d && d.d) { d = d.d; }
this._load_nodes(!$.isArray(d) ? [] : $.vakata.array_unique(d), function () {
this.search(str, true, show_only_matches, inside, append);
this.search(str, true, show_only_matches, inside, append, show_only_matches_children);
});
}, this), inside);
}
Expand All @@ -7193,17 +7295,21 @@
if(inside) {
a.data.inside = inside;
}
return $.ajax(a)
if (this._data.search.lastRequest) {
this._data.search.lastRequest.abort();
}
this._data.search.lastRequest = $.ajax(a)
.fail($.proxy(function () {
this._data.core.last_error = { 'error' : 'ajax', 'plugin' : 'search', 'id' : 'search_01', 'reason' : 'Could not load search parents', 'data' : JSON.stringify(a) };
this.settings.core.error.call(this, this._data.core.last_error);
}, this))
.done($.proxy(function (d) {
if(d && d.d) { d = d.d; }
this._load_nodes(!$.isArray(d) ? [] : $.vakata.array_unique(d), function () {
this.search(str, true, show_only_matches, inside, append);
this.search(str, true, show_only_matches, inside, append, show_only_matches_children);
});
}, this));
return this._data.search.lastRequest;
}
}
if(!append) {
Expand Down Expand Up @@ -7853,12 +7959,12 @@
old_type = obj.type;
old_icon = this.get_icon(obj);
obj.type = type;
if(old_icon === true || (t[old_type] && t[old_type].icon !== undefined && old_icon === t[old_type].icon)) {
if(old_icon === true || !t[old_type] || (t[old_type].icon !== undefined && old_icon === t[old_type].icon)) {
this.set_icon(obj, t[type].icon !== undefined ? t[type].icon : true);
}

// remove old type props
if(t[old_type].li_attr !== undefined && typeof t[old_type].li_attr === 'object') {
if(t[old_type] && t[old_type].li_attr !== undefined && typeof t[old_type].li_attr === 'object') {
for (k in t[old_type].li_attr) {
if (t[old_type].li_attr.hasOwnProperty(k)) {
if (k === 'id') {
Expand All @@ -7875,7 +7981,7 @@
}
}
}
if(t[old_type].a_attr !== undefined && typeof t[old_type].a_attr === 'object') {
if(t[old_type] && t[old_type].a_attr !== undefined && typeof t[old_type].a_attr === 'object') {
for (k in t[old_type].a_attr) {
if (t[old_type].a_attr.hasOwnProperty(k)) {
if (k === 'id') {
Expand Down Expand Up @@ -8130,6 +8236,11 @@
var tmp = $.Event('click', { metaKey : e.metaKey, ctrlKey : e.ctrlKey, altKey : e.altKey, shiftKey : e.shiftKey });
$(e.currentTarget).closest(".jstree-node").children(".jstree-anchor").first().trigger(tmp).focus();
})
.on("dblclick.jstree", ".jstree-wholerow", function (e) {
e.stopImmediatePropagation();
var tmp = $.Event('dblclick', { metaKey : e.metaKey, ctrlKey : e.ctrlKey, altKey : e.altKey, shiftKey : e.shiftKey });
$(e.currentTarget).closest(".jstree-node").children(".jstree-anchor").first().trigger(tmp).focus();
})
.on("click.jstree", ".jstree-leaf > .jstree-ocl", $.proxy(function (e) {
e.stopImmediatePropagation();
var tmp = $.Event('click', { metaKey : e.metaKey, ctrlKey : e.ctrlKey, altKey : e.altKey, shiftKey : e.shiftKey });
Expand Down

0 comments on commit 1ed5596

Please sign in to comment.