fancytree 2.34.0

This commit is contained in:
zadam 2020-01-01 23:13:49 +01:00
parent 82420fe5f6
commit 547a5714ae
4 changed files with 175 additions and 77 deletions

View File

@ -1,4 +1,4 @@
/*! jQuery Fancytree Plugin - 2.33.0 - 2019-10-29T08:00:07Z
/*! jQuery Fancytree Plugin - 2.34.0 - 2019-12-26T14:16:19Z
* https://github.com/mar10/fancytree
* Copyright (c) 2019 Martin Wendt; Licensed MIT
*/
@ -1365,8 +1365,8 @@ var uniqueId = $.fn.extend( {
* Released under the MIT license
* https://github.com/mar10/fancytree/wiki/LicenseInfo
*
* @version 2.33.0
* @date 2019-10-29T08:00:07Z
* @version 2.34.0
* @date 2019-12-26T14:16:19Z
*/
/** Core Fancytree module.
@ -4156,11 +4156,18 @@ var uniqueId = $.fn.extend( {
delete this._tempCache[key];
return null;
},
/* Check if this tree has extension `name` enabled.
*
* @param {string} name name of the required extension
*/
_usesExtension: function(name) {
return $.inArray(name, this.options.extensions) >= 0;
},
/* Check if current extensions dependencies are met and throw an error if not.
*
* This method may be called inside the `treeInit` hook for custom extensions.
*
* @param {string} extension name of the required extension
* @param {string} name name of the required extension
* @param {boolean} [required=true] pass `false` if the extension is optional, but we want to check for order if it is present
* @param {boolean} [before] `true` if `name` must be included before this, `false` otherwise (use `null` if order doesn't matter)
* @param {string} [message] optional error message (defaults to a descriptve error message)
@ -4417,6 +4424,13 @@ var uniqueId = $.fn.extend( {
consoleApply("log", arguments);
}
},
/** Destroy this widget, restore previous markup and cleanup resources.
*
* @since 2.34
*/
destroy: function() {
this.widget.destroy();
},
/** Enable (or disable) the tree control.
*
* @param {boolean} [flag=true] pass false to disable
@ -4795,6 +4809,20 @@ var uniqueId = $.fn.extend( {
* @returns {boolean}
*/
hasFocus: function() {
// var ae = document.activeElement,
// hasFocus = !!(
// ae && $(ae).closest(".fancytree-container").length
// );
// if (hasFocus !== !!this._hasFocus) {
// this.warn(
// "hasFocus(): fix inconsistent container state, now: " +
// hasFocus
// );
// this._hasFocus = hasFocus;
// this.$container.toggleClass("fancytree-treefocus", hasFocus);
// }
// return hasFocus;
return !!this._hasFocus;
},
/** Write to browser console if debugLevel >= 3 (prepending tree name)
@ -5120,6 +5148,26 @@ var uniqueId = $.fn.extend( {
setOption: function(optionName, value) {
return this.widget.option(optionName, value);
},
/**
* Call console.time() when in debug mode (verbose >= 4).
*
* @param {string} label
*/
debugTime: function(label) {
if (this.options.debugLevel >= 4) {
window.console.time(this + " - " + label);
}
},
/**
* Call console.timeEnd() when in debug mode (verbose >= 4).
*
* @param {string} label
*/
debugTimeEnd: function(label) {
if (this.options.debugLevel >= 4) {
window.console.timeEnd(this + " - " + label);
}
},
/**
* Return all nodes as nested list of {@link NodeData}.
*
@ -5185,7 +5233,7 @@ var uniqueId = $.fn.extend( {
* @since 2.28
*/
visitRows: function(fn, opts) {
if (!this.rootNode.children) {
if (!this.rootNode.hasChildren()) {
return false;
}
if (opts && opts.reverse) {
@ -5314,7 +5362,8 @@ var uniqueId = $.fn.extend( {
/**
* These additional methods of the {@link Fancytree} class are 'hook functions'
* that can be used and overloaded by extensions.
* (See <a href="https://github.com/mar10/fancytree/wiki/TutorialExtensions">writing extensions</a>.)
*
* @see [writing extensions](https://github.com/mar10/fancytree/wiki/TutorialExtensions)
* @mixin Fancytree_Hooks
*/
$.extend(
@ -6005,6 +6054,7 @@ var uniqueId = $.fn.extend( {
* Call this method to create new nodes, or after the strucuture
* was changed (e.g. after moving this node or adding/removing children)
* nodeRenderTitle() and nodeRenderStatus() are implied.
*
* ```html
* <li id='KEY' ftnode=NODE>
* <span class='fancytree-node fancytree-expanded fancytree-has-children fancytree-lastsib fancytree-exp-el fancytree-ico-e'>
@ -7493,14 +7543,28 @@ var uniqueId = $.fn.extend( {
*/
/**
* The plugin (derrived from <a href=" http://api.jqueryui.com/jQuery.widget/">jQuery.Widget</a>).<br>
* This constructor is not called directly. Use `$(selector).fancytree({})`
* to initialize the plugin instead.<br>
* <pre class="sh_javascript sunlight-highlight-javascript">// Access widget methods and members:
* var tree = $("#tree").fancytree("getTree");
* var node = $("#tree").fancytree("getActiveNode", "1234");
* </pre>
* The plugin (derrived from [jQuery.Widget](http://api.jqueryui.com/jQuery.widget/)).
*
* **Note:**
* These methods implement the standard jQuery UI widget API.
* It is recommended to use methods of the {Fancytree} instance instead
*
* @example
* // DEPRECATED: Access jQuery UI widget methods and members:
* var tree = $("#tree").fancytree("getTree", "#myTree");
* var node = $.ui.fancytree.getTree("#tree").getActiveNode();
*
* // RECOMMENDED: Use the Fancytree object API
* var tree = $.ui.fancytree.getTree("#myTree");
* var node = tree.getActiveNode();
*
* // or you may already have stored the tree instance upon creation:
* import {createTree, version} from 'jquery.fancytree'
* const tree = createTree('#tree', { ... });
* var node = tree.getActiveNode();
*
* @see {Fancytree_Static#getTree}
* @deprecated Use methods of the {Fancytree} instance instead
* @mixin Fancytree_Widget
*/
@ -7584,6 +7648,17 @@ var uniqueId = $.fn.extend( {
lazyLoad: null,
postProcess: null,
},
_deprecationWarning: function(name) {
var tree = this.tree;
if (tree && tree.options.debugLevel >= 3) {
tree.warn(
"$().fancytree('" +
name +
"') is deprecated (see https://wwwendt.de/tech/fancytree/doc/jsdoc/Fancytree_Widget.html"
);
}
},
/* Set up the widget, Called on first $().fancytree() */
_create: function() {
this.tree = new Fancytree(this);
@ -7701,11 +7776,11 @@ var uniqueId = $.fn.extend( {
},
/** Use the destroy method to clean up any modifications your widget has made to the DOM */
destroy: function() {
_destroy: function() {
this._unbind();
this.tree._callHook("treeDestroy", this.tree);
// In jQuery UI 1.8, you must invoke the destroy method from the base widget
$.Widget.prototype.destroy.call(this);
// $.Widget.prototype.destroy.call(this);
// TODO: delete tree and nodes to make garbage collect easier?
// TODO: In jQuery UI 1.9 and above, you would define _destroy instead of destroy and not call the base method
},
@ -7898,27 +7973,35 @@ var uniqueId = $.fn.extend( {
},
/** Return the active node or null.
* @returns {FancytreeNode}
* @deprecated Use methods of the Fancytree instance instead (<a href="Fancytree_Widget.html">example above</a>).
*/
getActiveNode: function() {
this._deprecationWarning("getActiveNode");
return this.tree.activeNode;
},
/** Return the matching node or null.
* @param {string} key
* @returns {FancytreeNode}
* @deprecated Use methods of the Fancytree instance instead (<a href="Fancytree_Widget.html">example above</a>).
*/
getNodeByKey: function(key) {
this._deprecationWarning("getNodeByKey");
return this.tree.getNodeByKey(key);
},
/** Return the invisible system root node.
* @returns {FancytreeNode}
* @deprecated Use methods of the Fancytree instance instead (<a href="Fancytree_Widget.html">example above</a>).
*/
getRootNode: function() {
this._deprecationWarning("getRootNode");
return this.tree.rootNode;
},
/** Return the current tree instance.
* @returns {Fancytree}
* @deprecated Use `$.ui.fancytree.getTree()` instead (<a href="Fancytree_Widget.html">example above</a>).
*/
getTree: function() {
this._deprecationWarning("getTree");
return this.tree;
},
}
@ -7928,12 +8011,14 @@ var uniqueId = $.fn.extend( {
FT = $.ui.fancytree;
/**
* Static members in the `$.ui.fancytree` namespace.<br>
* <br>
* <pre class="sh_javascript sunlight-highlight-javascript">// Access static members:
* Static members in the `$.ui.fancytree` namespace.
* This properties and methods can be accessed without instantiating a concrete
* Fancytree instance.
*
* @example
* // Access static members:
* var node = $.ui.fancytree.getNode(element);
* alert($.ui.fancytree.version);
* </pre>
*
* @mixin Fancytree_Static
*/
@ -7941,11 +8026,14 @@ var uniqueId = $.fn.extend( {
$.ui.fancytree,
/** @lends Fancytree_Static# */
{
/** @type {string} */
version: "2.33.0", // Set to semver by 'grunt release'
/** @type {string} */
/** Version number `"MAJOR.MINOR.PATCH"`
* @type {string} */
version: "2.34.0", // Set to semver by 'grunt release'
/** @type {string}
* @description `"production" for release builds` */
buildType: "production", // Set to 'production' by 'grunt build'
/** @type {int} */
/** @type {int}
* @description 0: silent .. 5: verbose (default: 3 for release builds). */
debugLevel: 3, // Set to 3 by 'grunt build'
// Used by $.ui.fancytree.debug() and as default for tree.options.debugLevel
@ -7954,9 +8042,15 @@ var uniqueId = $.fn.extend( {
_extensions: {},
// focusTree: null,
/** Expose class object as $.ui.fancytree._FancytreeClass */
/** Expose class object as `$.ui.fancytree._FancytreeClass`.
* Useful to extend `$.ui.fancytree._FancytreeClass.prototype`.
* @type {Fancytree}
*/
_FancytreeClass: Fancytree,
/** Expose class object as $.ui.fancytree._FancytreeNodeClass */
/** Expose class object as $.ui.fancytree._FancytreeNodeClass
* Useful to extend `$.ui.fancytree._FancytreeNodeClass.prototype`.
* @type {FancytreeNode}
*/
_FancytreeNodeClass: FancytreeNode,
/* Feature checks to provide backwards compatibility */
jquerySupports: {
@ -7983,10 +8077,8 @@ var uniqueId = $.fn.extend( {
* @since 2.25
*/
createTree: function(el, opts) {
var tree = $(el)
.fancytree(opts)
.fancytree("getTree");
return tree;
var $tree = $(el).fancytree(opts);
return FT.getTree($tree);
},
/** Return a function that executes *fn* at most every *timeout* ms.
* @param {integer} timeout
@ -8191,11 +8283,17 @@ var uniqueId = $.fn.extend( {
if (!el.length) {
el = $(orgEl).eq(0); // el was a selector: use first match
}
} else if (
el instanceof Element ||
el instanceof HTMLDocument
) {
el = $(el);
} else if (el instanceof $) {
el = el.eq(0); // el was a jQuery object: use the first DOM element
el = el.eq(0); // el was a jQuery object: use the first
} else if (el.originalEvent !== undefined) {
el = $(el.target); // el was an Event
}
// el is a jQuery object wit one element here
el = el.closest(":ui-fancytree");
widget = el.data("ui-fancytree") || el.data("fancytree"); // the latter is required by jQuery <= 1.8
return widget ? widget.tree : null;
@ -8203,11 +8301,11 @@ var uniqueId = $.fn.extend( {
/** Return an option value that has a default, but may be overridden by a
* callback or a node instance attribute.
*
* Evaluation sequence:<br>
* Evaluation sequence:
*
* If tree.options.<optionName> is a callback that returns something, use that.<br>
* Else if node.<optionName> is defined, use that.<br>
* Else if tree.options.<optionName> is a value, use that.<br>
* If `tree.options.<optionName>` is a callback that returns something, use that.
* Else if `node.<optionName>` is defined, use that.
* Else if `tree.options.<optionName>` is a value, use that.
* Else use `defaultValue`.
*
* @param {string} optionName name of the option property (on node and tree)
@ -8565,8 +8663,8 @@ var uniqueId = $.fn.extend( {
* Released under the MIT license
* https://github.com/mar10/fancytree/wiki/LicenseInfo
*
* @version 2.33.0
* @date 2019-10-29T08:00:07Z
* @version 2.34.0
* @date 2019-12-26T14:16:19Z
*/
// To keep the global namespace clean, we wrap everything in a closure.
@ -8602,7 +8700,7 @@ var uniqueId = $.fn.extend( {
// New member functions can be added to the `Fancytree` class.
// This function will be available for every tree instance:
//
// var tree = $("#tree").fancytree("getTree");
// var tree = $.ui.fancytree.getTree("#tree");
// tree.countSelected(false);
$.ui.fancytree._FancytreeClass.prototype.countSelected = function(topOnly) {
@ -8685,7 +8783,7 @@ var uniqueId = $.fn.extend( {
// Every extension must be registered by a unique name.
name: "childcounter",
// Version information should be compliant with [semver](http://semver.org)
version: "2.33.0",
version: "2.34.0",
// Extension specific options and their defaults.
// This options will be available as `tree.options.childcounter.hideExpanded`
@ -8796,8 +8894,8 @@ var uniqueId = $.fn.extend( {
* Released under the MIT license
* https://github.com/mar10/fancytree/wiki/LicenseInfo
*
* @version 2.33.0
* @date 2019-10-29T08:00:07Z
* @version 2.34.0
* @date 2019-12-26T14:16:19Z
*/
(function(factory) {
@ -9155,7 +9253,7 @@ var uniqueId = $.fn.extend( {
*/
$.ui.fancytree.registerExtension({
name: "clones",
version: "2.33.0",
version: "2.34.0",
// Default options for this extension.
options: {
highlightActiveClones: true, // set 'fancytree-active-clone' on active clones and all peers
@ -9317,8 +9415,8 @@ var uniqueId = $.fn.extend( {
* Released under the MIT license
* https://github.com/mar10/fancytree/wiki/LicenseInfo
*
* @version 2.33.0
* @date 2019-10-29T08:00:07Z
* @version 2.34.0
* @date 2019-12-26T14:16:19Z
*/
/*
@ -10322,7 +10420,7 @@ var uniqueId = $.fn.extend( {
$.ui.fancytree.registerExtension({
name: "dnd5",
version: "2.33.0",
version: "2.34.0",
// Default options for this extension.
options: {
autoExpandMS: 1500, // Expand nodes after n milliseconds of hovering
@ -10455,8 +10553,8 @@ var uniqueId = $.fn.extend( {
* Released under the MIT license
* https://github.com/mar10/fancytree/wiki/LicenseInfo
*
* @version 2.33.0
* @date 2019-10-29T08:00:07Z
* @version 2.34.0
* @date 2019-12-26T14:16:19Z
*/
(function(factory) {
@ -10748,7 +10846,7 @@ var uniqueId = $.fn.extend( {
*/
$.ui.fancytree.registerExtension({
name: "edit",
version: "2.33.0",
version: "2.34.0",
// Default options for this extension.
options: {
adjustWidthOfs: 4, // null: don't adjust input size to content
@ -10859,8 +10957,8 @@ var uniqueId = $.fn.extend( {
* Released under the MIT license
* https://github.com/mar10/fancytree/wiki/LicenseInfo
*
* @version 2.33.0
* @date 2019-10-29T08:00:07Z
* @version 2.34.0
* @date 2019-12-26T14:16:19Z
*/
(function(factory) {
@ -11198,7 +11296,7 @@ var uniqueId = $.fn.extend( {
*/
$.ui.fancytree.registerExtension({
name: "filter",
version: "2.33.0",
version: "2.34.0",
// Default options for this extension.
options: {
autoApply: true, // Re-apply last filter if lazy data is loaded
@ -11318,8 +11416,8 @@ var uniqueId = $.fn.extend( {
* Released under the MIT license
* https://github.com/mar10/fancytree/wiki/LicenseInfo
*
* @version 2.33.0
* @date 2019-10-29T08:00:07Z
* @version 2.34.0
* @date 2019-12-26T14:16:19Z
*/
(function(factory) {
@ -11502,7 +11600,7 @@ var uniqueId = $.fn.extend( {
$.ui.fancytree.registerExtension({
name: "glyph",
version: "2.33.0",
version: "2.34.0",
// Default options for this extension.
options: {
preset: null, // 'awesome3', 'awesome4', 'bootstrap3', 'material'
@ -11656,8 +11754,8 @@ var uniqueId = $.fn.extend( {
* Released under the MIT license
* https://github.com/mar10/fancytree/wiki/LicenseInfo
*
* @version 2.33.0
* @date 2019-10-29T08:00:07Z
* @version 2.34.0
* @date 2019-12-26T14:16:19Z
*/
(function(factory) {
@ -11774,7 +11872,7 @@ var uniqueId = $.fn.extend( {
*/
$.ui.fancytree.registerExtension({
name: "gridnav",
version: "2.33.0",
version: "2.34.0",
// Default options for this extension.
options: {
autofocusInput: false, // Focus first embedded input if node gets activated
@ -11881,8 +11979,8 @@ var uniqueId = $.fn.extend( {
* Released under the MIT license
* https://github.com/mar10/fancytree/wiki/LicenseInfo
*
* @version 2.33.0
* @date 2019-10-29T08:00:07Z
* @version 2.34.0
* @date 2019-12-26T14:16:19Z
*/
(function(factory) {
@ -11911,7 +12009,7 @@ var uniqueId = $.fn.extend( {
*/
$.ui.fancytree.registerExtension({
name: "multi",
version: "2.33.0",
version: "2.34.0",
// Default options for this extension.
options: {
allowNoSelect: false, //
@ -12013,8 +12111,8 @@ var uniqueId = $.fn.extend( {
* Released under the MIT license
* https://github.com/mar10/fancytree/wiki/LicenseInfo
*
* @version 2.33.0
* @date 2019-10-29T08:00:07Z
* @version 2.34.0
* @date 2019-12-26T14:16:19Z
*/
(function(factory) {
@ -12154,7 +12252,7 @@ var uniqueId = $.fn.extend( {
/**
* [ext-persist] Remove persistence data of the given type(s).
* Called like
* $("#tree").fancytree("getTree").clearCookies("active expanded focus selected");
* $.ui.fancytree.getTree("#tree").clearCookies("active expanded focus selected");
*
* @alias Fancytree#clearPersistData
* @requires jquery.fancytree.persist.js
@ -12191,7 +12289,7 @@ var uniqueId = $.fn.extend( {
* [ext-persist] Return persistence information from cookies
*
* Called like
* $("#tree").fancytree("getTree").getPersistData();
* $.ui.fancytree.getTree("#tree").getPersistData();
*
* @alias Fancytree#getPersistData
* @requires jquery.fancytree.persist.js
@ -12214,7 +12312,7 @@ var uniqueId = $.fn.extend( {
*/
$.ui.fancytree.registerExtension({
name: "persist",
version: "2.33.0",
version: "2.34.0",
// Default options for this extension.
options: {
cookieDelimiter: "~",
@ -12507,8 +12605,8 @@ var uniqueId = $.fn.extend( {
* Released under the MIT license
* https://github.com/mar10/fancytree/wiki/LicenseInfo
*
* @version 2.33.0
* @date 2019-10-29T08:00:07Z
* @version 2.34.0
* @date 2019-12-26T14:16:19Z
*/
(function(factory) {
@ -12591,7 +12689,7 @@ var uniqueId = $.fn.extend( {
$.ui.fancytree.registerExtension({
name: "table",
version: "2.33.0",
version: "2.34.0",
// Default options for this extension.
options: {
checkboxColumnIdx: null, // render the checkboxes into the this column index (default: nodeColumnIdx)
@ -13057,8 +13155,8 @@ var uniqueId = $.fn.extend( {
* Released under the MIT license
* https://github.com/mar10/fancytree/wiki/LicenseInfo
*
* @version 2.33.0
* @date 2019-10-29T08:00:07Z
* @version 2.34.0
* @date 2019-12-26T14:16:19Z
*/
(function(factory) {
@ -13081,7 +13179,7 @@ var uniqueId = $.fn.extend( {
*/
$.ui.fancytree.registerExtension({
name: "themeroller",
version: "2.33.0",
version: "2.34.0",
// Default options for this extension.
options: {
activeClass: "ui-state-active", // Class added to active node
@ -13177,8 +13275,8 @@ var uniqueId = $.fn.extend( {
* Released under the MIT license
* https://github.com/mar10/fancytree/wiki/LicenseInfo
*
* @version 2.33.0
* @date 2019-10-29T08:00:07Z
* @version 2.34.0
* @date 2019-12-26T14:16:19Z
*/
(function(factory) {
@ -13308,7 +13406,7 @@ var uniqueId = $.fn.extend( {
*/
$.ui.fancytree.registerExtension({
name: "wide",
version: "2.33.0",
version: "2.34.0",
// Default options for this extension.
options: {
iconWidth: null, // Adjust this if @fancy-icon-width != "16px"

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -13,8 +13,8 @@
* Released under the MIT license
* https://github.com/mar10/fancytree/wiki/LicenseInfo
*
* @version 2.33.0
* @date 2019-10-29T08:00:07Z
* @version 2.34.0
* @date 2019-12-26T14:16:19Z
******************************************************************************/
/*------------------------------------------------------------------------------
* Helpers