Commit 410e4562 authored by Aran Dunkley's avatar Aran Dunkley

update fancytree lib to 2.1.0

parent 3e478132
......@@ -7,8 +7,8 @@
* Released under the MIT license
* https://github.com/mar10/fancytree/wiki/LicenseInfo
*
* @version @VERSION
* @date @DATE
* @version 2.10.0
* @date 2015-06-26T22:37
*/
/** Core Fancytree module.
......@@ -968,7 +968,7 @@ FancytreeNode.prototype = /** @lends FancytreeNode# */{
isLoading: function() {
return !!this._isLoading;
},
/**
/*
* @deprecated since v2.4.0: Use isRootNode() instead
*/
isRoot: function() {
......@@ -1369,7 +1369,7 @@ FancytreeNode.prototype = /** @lends FancytreeNode# */{
render: function(force, deep) {
return this.tree._callHook("nodeRender", this, force, deep);
},
/** Create HTML markup for the node's outer <span> (expander, checkbox, icon, and title).
/** Create HTML markup for the node's outer &lt;span> (expander, checkbox, icon, and title).
* @see Fancytree_Hooks#nodeRenderTitle
*/
renderTitle: function() {
......@@ -2579,7 +2579,7 @@ $.extend(Fancytree.prototype,
tree.nodeSetActive(ctx, true);
}
break;
case "enter":
case "return":
tree.nodeSetActive(ctx, true);
break;
case "backspace":
......@@ -2843,6 +2843,7 @@ $.extend(Fancytree.prototype,
} else{
node.children = null;
}
node.expanded = false; // #449
this.nodeRenderStatus(ctx);
},
/**Remove HTML markup for ctx.node and all its descendents.
......@@ -2870,20 +2871,20 @@ $.extend(Fancytree.prototype,
*
* Note: if a node was created/removed, nodeRender() must be called for the
* parent.
* <code>
* <li id='KEY' ftnode=NODE>
* <span class='fancytree-node fancytree-expanded fancytree-has-children fancytree-lastsib fancytree-exp-el fancytree-ico-e'>
* <span class="fancytree-expander"></span>
* <span class="fancytree-checkbox"></span> // only present in checkbox mode
* <span class="fancytree-icon"></span>
* <a href="#" class="fancytree-title"> Node 1 </a>
* </span>
* <ul> // only present if node has children
* <li id='KEY' ftnode=NODE> child1 ... </li>
* <li id='KEY' ftnode=NODE> child2 ... </li>
* </ul>
* </li>
* </code>
* &lt;code>
* &lt;li id='KEY' ftnode=NODE>
* &lt;span class='fancytree-node fancytree-expanded fancytree-has-children fancytree-lastsib fancytree-exp-el fancytree-ico-e'>
* &lt;span class="fancytree-expander">&lt;/span>
* &lt;span class="fancytree-checkbox">&lt;/span> // only present in checkbox mode
* &lt;span class="fancytree-icon">&lt;/span>
* &lt;a href="#" class="fancytree-title"> Node 1 &lt;/a>
* &lt;/span>
* &lt;ul> // only present if node has children
* &lt;li id='KEY' ftnode=NODE> child1 ... &lt;/li>
* &lt;li id='KEY' ftnode=NODE> child2 ... &lt;/li>
* &lt;/ul>
* &lt;/li>
* &lt;/code>
*
* @param {EventData} ctx
* @param {boolean} [force=false] re-render, even if html markup was already created
......@@ -3035,7 +3036,8 @@ $.extend(Fancytree.prototype,
}
}
},
/** Create HTML for the node's outer <span> (expander, checkbox, icon, and title).
/** Create HTML inside the node's outer &lt;span> (i.e. expander, checkbox,
* icon, and title).
*
* nodeRenderStatus() is implied.
* @param {EventData} ctx
......@@ -3304,6 +3306,7 @@ $.extend(Fancytree.prototype,
ctx.tree._triggerNodeEvent("deactivate", node, ctx.originalEvent);
}
}
return _getResolvedPromise(node);
},
/** Expand or collapse node, return Deferred.promise.
*
......@@ -3365,9 +3368,10 @@ $.extend(Fancytree.prototype,
}
// Trigger expand/collapse after expanding
dfd.done(function(){
if( flag && opts.autoScroll && !noAnimation ) {
var lastChild = node.getLastChild();
if( flag && opts.autoScroll && !noAnimation && lastChild ) {
// Scroll down to last child, but keep current node visible
node.getLastChild().scrollIntoView(true, {topNode: node}).always(function(){
lastChild.scrollIntoView(true, {topNode: node}).always(function(){
if( !noEvents ) {
ctx.tree._triggerNodeEvent(flag ? "expand" : "collapse", ctx);
}
......@@ -3661,6 +3665,8 @@ $.extend(Fancytree.prototype,
* @param {EventData} ctx
*/
treeDestroy: function(ctx) {
this.$div.find(">ul.fancytree-container").remove();
this.$source && this.$source.removeClass("ui-helper-hidden");
},
/** Widget was (re-)initialized.
* @param {EventData} ctx
......@@ -3920,9 +3926,6 @@ $.widget("ui.fancytree",
destroy: function() {
this._unbind();
this.tree._callHook("treeDestroy", this.tree);
// this.element.removeClass("ui-widget ui-widget-content ui-corner-all");
this.tree.$div.find(">ul.fancytree-container").remove();
this.$source && this.$source.removeClass("ui-helper-hidden");
// In jQuery UI 1.8, you must invoke the destroy method from the base widget
$.Widget.prototype.destroy.call(this);
// TODO: delete tree and nodes to make garbage collect easier?
......@@ -4074,11 +4077,11 @@ $.extend($.ui.fancytree,
/** @lends Fancytree_Static# */
{
/** @type {string} */
version: "@VERSION", // Set to semver by 'grunt release'
version: "2.10.0", // Set to semver by 'grunt release'
/** @type {string} */
buildType: "development", // Set to 'production' by 'grunt build'
buildType: "production", // Set to 'production' by 'grunt build'
/** @type {int} */
debugLevel: 2, // Set to 1 by 'grunt build'
debugLevel: 1, // Set to 1 by 'grunt build'
// Used by $.ui.fancytree.debug() and as default for tree.options.debugLevel
_nextId: 1,
......
......@@ -4,31 +4,42 @@
* Persist tree status in cookiesRemove or highlight tree nodes, based on a filter.
* (Extension module for jquery.fancytree.js: https://github.com/mar10/fancytree/)
*
* @depends: jquery.cookie.js
* @depends: js-cookie or jquery-cookie
*
* Copyright (c) 2008-2015, Martin Wendt (http://wwWendt.de)
*
* Released under the MIT license
* https://github.com/mar10/fancytree/wiki/LicenseInfo
*
* @version @VERSION
* @date @DATE
* @version 2.10.0
* @date 2015-06-26T22:37
*/
;(function($, window, document, undefined) {
"use strict";
/* global Cookies:false */
/*******************************************************************************
* Private functions and variables
*/
var _assert = $.ui.fancytree.assert,
var cookieGetter, cookieRemover, cookieSetter,
_assert = $.ui.fancytree.assert,
ACTIVE = "active",
EXPANDED = "expanded",
FOCUS = "focus",
SELECTED = "selected";
if( typeof Cookies === "function" ) {
// Assume https://github.com/js-cookie/js-cookie
cookieSetter = Cookies.set;
cookieGetter = Cookies.get;
cookieRemover = Cookies.remove;
} else {
// Fall back to https://github.com/carhartl/jquery-cookie
cookieSetter = cookieGetter = $.cookie;
cookieRemover = $.removeCookie;
}
/* Recursively load lazy nodes
* @param {string} mode 'load', 'expand', false
......@@ -163,18 +174,18 @@ $.ui.fancytree.registerExtension({
var ls = this._local.localStorage; // null, sessionStorage, or localStorage
if( value === undefined ) {
return ls ? ls.getItem(key) : $.cookie(key);
return ls ? ls.getItem(key) : cookieGetter(key);
} else if ( value === null ) {
if( ls ) {
ls.removeItem(key);
} else {
$.removeCookie(key);
cookieRemover(key);
}
} else {
if( ls ) {
ls.setItem(key, value);
} else {
$.cookie(key, value, this.options.persist.cookie);
cookieSetter(key, value, this.options.persist.cookie);
}
}
},
......@@ -207,7 +218,7 @@ $.ui.fancytree.registerExtension({
instOpts = this.options.persist;
// For 'auto' or 'cookie' mode, the cookie plugin must be available
_assert(instOpts.store === "localStore" || $.cookie, "Missing required plugin for 'persist' extension: jquery.cookie.js");
_assert(instOpts.store === "localStore" || cookieGetter, "Missing required plugin for 'persist' extension: js.cookie.js or jquery.cookie.js");
local.cookiePrefix = instOpts.cookiePrefix || ("fancytree-" + tree._id + "-");
local.storeActive = instOpts.types.indexOf(ACTIVE) >= 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment