fancytree-rails 2.1.0.pre.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +1 -1
- data/Rakefile +3 -4
- data/app/assets/javascripts/fancytree/jquery.fancytree-all.js +568 -51
- data/app/assets/javascripts/fancytree/jquery.fancytree-custom.min.js +9 -6
- data/app/assets/javascripts/fancytree/jquery.fancytree.js +63 -27
- data/app/assets/javascripts/fancytree/jquery.fancytree.min.js +4 -4
- data/app/assets/javascripts/fancytree/src/jquery.fancytree.childcounter.js +2 -2
- data/app/assets/javascripts/fancytree/src/jquery.fancytree.clones.js +7 -3
- data/app/assets/javascripts/fancytree/src/jquery.fancytree.columnview.js +2 -2
- data/app/assets/javascripts/fancytree/src/jquery.fancytree.debug.js +2 -2
- data/app/assets/javascripts/fancytree/src/jquery.fancytree.dnd.js +24 -4
- data/app/assets/javascripts/fancytree/src/jquery.fancytree.edit.js +3 -2
- data/app/assets/javascripts/fancytree/src/jquery.fancytree.filter.js +2 -2
- data/app/assets/javascripts/fancytree/src/jquery.fancytree.glyph.js +14 -6
- data/app/assets/javascripts/fancytree/src/jquery.fancytree.gridnav.js +2 -2
- data/app/assets/javascripts/fancytree/src/jquery.fancytree.js +63 -27
- data/app/assets/javascripts/fancytree/src/jquery.fancytree.menu.js +2 -2
- data/app/assets/javascripts/fancytree/src/jquery.fancytree.persist.js +2 -2
- data/app/assets/javascripts/fancytree/src/jquery.fancytree.table.js +2 -2
- data/app/assets/javascripts/fancytree/src/jquery.fancytree.themeroller.js +2 -2
- data/app/assets/javascripts/fancytree/src/jquery.fancytree.wide.js +124 -0
- data/app/assets/stylesheets/fancytree/skin-lion/ui.fancytree.css.erb +5 -0
- data/app/assets/stylesheets/fancytree/skin-vista/ui.fancytree.css.erb +5 -0
- data/app/assets/stylesheets/fancytree/skin-win7/ui.fancytree.css.erb +5 -0
- data/app/assets/stylesheets/fancytree/skin-win8-xxl/ui.fancytree.css.erb +5 -0
- data/app/assets/stylesheets/fancytree/skin-win8/ui.fancytree.css.erb +5 -0
- data/app/assets/stylesheets/fancytree/skin-xp/ui.fancytree.css.erb +5 -0
- data/lib/fancytree/rails/version.rb +2 -2
- metadata +5 -4
@@ -7,8 +7,8 @@
|
|
7
7
|
* Released under the MIT license
|
8
8
|
* https://github.com/mar10/fancytree/wiki/LicenseInfo
|
9
9
|
*
|
10
|
-
* @version 2.
|
11
|
-
* @date 2014-
|
10
|
+
* @version 2.3.0
|
11
|
+
* @date 2014-08-17T10:39
|
12
12
|
*/
|
13
13
|
|
14
14
|
/** Core Fancytree module.
|
@@ -614,7 +614,7 @@ FancytreeNode.prototype = /** @lends FancytreeNode# */{
|
|
614
614
|
var i, l, child, s, state, allSelected,someSelected,
|
615
615
|
children = node.children;
|
616
616
|
|
617
|
-
if( children ){
|
617
|
+
if( children && children.length ){
|
618
618
|
// check all children recursively
|
619
619
|
allSelected = true;
|
620
620
|
someSelected = false;
|
@@ -852,6 +852,16 @@ FancytreeNode.prototype = /** @lends FancytreeNode# */{
|
|
852
852
|
hasFocus: function() {
|
853
853
|
return (this.tree.hasFocus() && this.tree.focusNode === this);
|
854
854
|
},
|
855
|
+
/** Write to browser console if debugLevel >= 1 (prepending node info)
|
856
|
+
*
|
857
|
+
* @param {*} msg string or object or array of such
|
858
|
+
*/
|
859
|
+
info: function(msg){
|
860
|
+
if( this.tree.options.debugLevel >= 1 ) {
|
861
|
+
Array.prototype.unshift.call(arguments, this.toString());
|
862
|
+
consoleApply("info", arguments);
|
863
|
+
}
|
864
|
+
},
|
855
865
|
/** Return true if node is active (see also FancytreeNode#isSelected).
|
856
866
|
* @returns {boolean}
|
857
867
|
*/
|
@@ -1063,6 +1073,9 @@ FancytreeNode.prototype = /** @lends FancytreeNode# */{
|
|
1063
1073
|
}
|
1064
1074
|
// Unlink this node from current parent
|
1065
1075
|
if( this.parent.children.length === 1 ) {
|
1076
|
+
if( this.parent === targetParent ){
|
1077
|
+
return; // #258
|
1078
|
+
}
|
1066
1079
|
this.parent.children = this.parent.lazy ? [] : null;
|
1067
1080
|
this.parent.expanded = false;
|
1068
1081
|
} else {
|
@@ -1196,7 +1209,7 @@ FancytreeNode.prototype = /** @lends FancytreeNode# */{
|
|
1196
1209
|
// Navigate to node
|
1197
1210
|
function _goto(n){
|
1198
1211
|
if( n ){
|
1199
|
-
n.makeVisible();
|
1212
|
+
try { n.makeVisible(); } catch(e) {} // #272
|
1200
1213
|
// Node may still be hidden by a filter
|
1201
1214
|
if( ! $(n.span).is(":visible") ) {
|
1202
1215
|
n.debug("Navigate: skipping hidden node");
|
@@ -1467,13 +1480,20 @@ FancytreeNode.prototype = /** @lends FancytreeNode# */{
|
|
1467
1480
|
setFocus: function(flag){
|
1468
1481
|
return this.tree._callHook("nodeSetFocus", this, flag);
|
1469
1482
|
},
|
1470
|
-
// TODO: setLazyNodeStatus
|
1471
1483
|
/**Select this node, i.e. check the checkbox.
|
1472
1484
|
* @param {boolean} [flag=true] pass false to deselect
|
1473
1485
|
*/
|
1474
1486
|
setSelected: function(flag){
|
1475
1487
|
return this.tree._callHook("nodeSetSelected", this, flag);
|
1476
1488
|
},
|
1489
|
+
/**Mark a lazy node as 'error', 'loading', or 'ok'.
|
1490
|
+
* @param {string} status 'error', 'ok'
|
1491
|
+
* @param {string} [message]
|
1492
|
+
* @param {string} [details]
|
1493
|
+
*/
|
1494
|
+
setStatus: function(status, message, details){
|
1495
|
+
return this.tree._callHook("nodeSetStatus", this, status, message, details);
|
1496
|
+
},
|
1477
1497
|
/**Rename this node.
|
1478
1498
|
* @param {string} title
|
1479
1499
|
*/
|
@@ -1666,6 +1686,9 @@ function Fancytree(widget) {
|
|
1666
1686
|
};
|
1667
1687
|
}
|
1668
1688
|
}
|
1689
|
+
if( this.options && $.isFunction(this.options.loaderror) ) {
|
1690
|
+
$.error("The 'loaderror' event was renamed since 2014-07-03. Use 'loadError' (with uppercase E) instead.");
|
1691
|
+
}
|
1669
1692
|
this.ext = {}; // Active extension instances
|
1670
1693
|
// allow to init tree.data.foo from <div data-foo=''>
|
1671
1694
|
this.data = _getElementDataAsDict(this.$div);
|
@@ -1883,17 +1906,17 @@ Fancytree.prototype = /** @lends Fancytree# */{
|
|
1883
1906
|
generateFormElements: function(selected, active) {
|
1884
1907
|
// TODO: test case
|
1885
1908
|
var nodeList,
|
1886
|
-
selectedName = (selected !== false) ? "ft_" + this._id : selected,
|
1909
|
+
selectedName = (selected !== false) ? "ft_" + this._id + "[]" : selected,
|
1887
1910
|
activeName = (active !== false) ? "ft_" + this._id + "_active" : active,
|
1888
1911
|
id = "fancytree_result_" + this._id,
|
1889
|
-
$result =
|
1912
|
+
$result = $("#" + id);
|
1890
1913
|
|
1891
1914
|
if($result.length){
|
1892
1915
|
$result.empty();
|
1893
1916
|
}else{
|
1894
1917
|
$result = $("<div>", {
|
1895
1918
|
id: id
|
1896
|
-
}).hide().
|
1919
|
+
}).hide().insertAfter(this.$container);
|
1897
1920
|
}
|
1898
1921
|
if(selectedName){
|
1899
1922
|
nodeList = this.getSelectedNodes( this.options.selectMode === 3 );
|
@@ -1967,7 +1990,12 @@ Fancytree.prototype = /** @lends Fancytree# */{
|
|
1967
1990
|
}, true);
|
1968
1991
|
return match;
|
1969
1992
|
},
|
1970
|
-
|
1993
|
+
/** Return the invisible system root node.
|
1994
|
+
* @returns {FancytreeNode}
|
1995
|
+
*/
|
1996
|
+
getRootNode: function() {
|
1997
|
+
return this.rootNode;
|
1998
|
+
},
|
1971
1999
|
/**
|
1972
2000
|
* Return an array of selected nodes.
|
1973
2001
|
* @param {boolean} [stopOnParents=false] only return the topmost selected
|
@@ -2373,7 +2401,7 @@ $.extend(Fancytree.prototype,
|
|
2373
2401
|
* data was rendered.
|
2374
2402
|
*/
|
2375
2403
|
nodeLoadChildren: function(ctx, source) {
|
2376
|
-
var ajax, delay,
|
2404
|
+
var ajax, delay, dfd,
|
2377
2405
|
tree = ctx.tree,
|
2378
2406
|
node = ctx.node;
|
2379
2407
|
|
@@ -2393,7 +2421,7 @@ $.extend(Fancytree.prototype,
|
|
2393
2421
|
|
2394
2422
|
node.debug("nodeLoadChildren waiting debug delay " + Math.round(delay) + "ms");
|
2395
2423
|
ajax.debugDelay = false;
|
2396
|
-
|
2424
|
+
dfd = $.Deferred(function (dfd) {
|
2397
2425
|
setTimeout(function () {
|
2398
2426
|
$.ajax(ajax)
|
2399
2427
|
.done(function () { dfd.resolveWith(this, arguments); })
|
@@ -2401,33 +2429,42 @@ $.extend(Fancytree.prototype,
|
|
2401
2429
|
}, delay);
|
2402
2430
|
});
|
2403
2431
|
}else{
|
2404
|
-
|
2432
|
+
dfd = $.ajax(ajax);
|
2405
2433
|
}
|
2406
2434
|
|
2407
|
-
//
|
2408
|
-
//
|
2409
|
-
source =
|
2410
|
-
|
2435
|
+
// Defer the deferred: we want to be able to reject, even if ajax
|
2436
|
+
// resolved ok.
|
2437
|
+
source = new $.Deferred();
|
2438
|
+
dfd.done(function (data, textStatus, jqXHR) {
|
2439
|
+
var errorObj, res;
|
2411
2440
|
if(typeof data === "string"){
|
2412
2441
|
$.error("Ajax request returned a string (did you get the JSON dataType wrong?).");
|
2413
2442
|
}
|
2414
|
-
// postProcess is similar to the standard dataFilter hook,
|
2443
|
+
// postProcess is similar to the standard ajax dataFilter hook,
|
2415
2444
|
// but it is also called for JSONP
|
2416
2445
|
if( ctx.options.postProcess ){
|
2417
|
-
res = tree._triggerNodeEvent("postProcess", ctx, ctx.originalEvent, {response: data, dataType: this.dataType});
|
2446
|
+
res = tree._triggerNodeEvent("postProcess", ctx, ctx.originalEvent, {response: data, error: null, dataType: this.dataType});
|
2447
|
+
if( res.error ) {
|
2448
|
+
errorObj = $.isPlainObject(res.error) ? res.error : {message: res.error};
|
2449
|
+
errorObj = tree._makeHookContext(node, null, errorObj);
|
2450
|
+
source.rejectWith(this, [errorObj]);
|
2451
|
+
return;
|
2452
|
+
}
|
2418
2453
|
data = $.isArray(res) ? res : data;
|
2454
|
+
|
2419
2455
|
} else if (data && data.hasOwnProperty("d") && ctx.options.enableAspx ) {
|
2420
2456
|
// Process ASPX WebMethod JSON object inside "d" property
|
2421
2457
|
data = (typeof data.d === "string") ? $.parseJSON(data.d) : data.d;
|
2422
2458
|
}
|
2423
|
-
|
2424
|
-
}
|
2425
|
-
|
2459
|
+
source.resolveWith(this, [data]);
|
2460
|
+
}).fail(function (jqXHR, textStatus, errorThrown) {
|
2461
|
+
var errorObj = tree._makeHookContext(node, null, {
|
2426
2462
|
error: jqXHR,
|
2427
2463
|
args: Array.prototype.slice.call(arguments),
|
2428
2464
|
message: errorThrown,
|
2429
2465
|
details: jqXHR.status + ": " + errorThrown
|
2430
2466
|
});
|
2467
|
+
source.rejectWith(this, [errorObj]);
|
2431
2468
|
});
|
2432
2469
|
}
|
2433
2470
|
|
@@ -2437,7 +2474,7 @@ $.extend(Fancytree.prototype,
|
|
2437
2474
|
// node._isLoading = true;
|
2438
2475
|
tree.nodeSetStatus(ctx, "loading");
|
2439
2476
|
|
2440
|
-
source.done(function () {
|
2477
|
+
source.done(function (children) {
|
2441
2478
|
tree.nodeSetStatus(ctx, "ok");
|
2442
2479
|
}).fail(function(error){
|
2443
2480
|
var ctxErr;
|
@@ -2451,8 +2488,9 @@ $.extend(Fancytree.prototype,
|
|
2451
2488
|
message: error ? (error.message || error.toString()) : ""
|
2452
2489
|
});
|
2453
2490
|
}
|
2454
|
-
tree._triggerNodeEvent("
|
2455
|
-
|
2491
|
+
if( tree._triggerNodeEvent("loadError", ctxErr, null) !== false ) {
|
2492
|
+
tree.nodeSetStatus(ctx, "error", ctxErr.message, ctxErr.details);
|
2493
|
+
}
|
2456
2494
|
});
|
2457
2495
|
}
|
2458
2496
|
// $.when(source) resolves also for non-deferreds
|
@@ -2472,9 +2510,7 @@ $.extend(Fancytree.prototype,
|
|
2472
2510
|
_assert($.isArray(children), "expected array of children");
|
2473
2511
|
node._setChildren(children);
|
2474
2512
|
// trigger fancytreeloadchildren
|
2475
|
-
// if( node.parent ) {
|
2476
2513
|
tree._triggerNodeEvent("loadChildren", node);
|
2477
|
-
// }
|
2478
2514
|
// }).always(function(){
|
2479
2515
|
// node._isLoading = false;
|
2480
2516
|
});
|
@@ -3791,7 +3827,7 @@ $.extend($.ui.fancytree,
|
|
3791
3827
|
/** @lends Fancytree_Static# */
|
3792
3828
|
{
|
3793
3829
|
/** @type {string} */
|
3794
|
-
version: "2.
|
3830
|
+
version: "2.3.0", // Set to semver by 'grunt release'
|
3795
3831
|
/** @type {string} */
|
3796
3832
|
buildType: "production", // Set to 'production' by 'grunt build'
|
3797
3833
|
/** @type {int} */
|
@@ -0,0 +1,124 @@
|
|
1
|
+
/*!
|
2
|
+
*
|
3
|
+
* jquery.fancytree.wide.js
|
4
|
+
* Support for 100% wide selection bars.
|
5
|
+
* (Extension module for jquery.fancytree.js: https://github.com/mar10/fancytree/)
|
6
|
+
*
|
7
|
+
* Copyright (c) 2014, Martin Wendt (http://wwWendt.de)
|
8
|
+
*
|
9
|
+
* Released under the MIT license
|
10
|
+
* https://github.com/mar10/fancytree/wiki/LicenseInfo
|
11
|
+
*
|
12
|
+
* @version 2.3.0
|
13
|
+
* @date 2014-08-17T10:39
|
14
|
+
*/
|
15
|
+
|
16
|
+
;(function($, window, document, undefined) {
|
17
|
+
|
18
|
+
"use strict";
|
19
|
+
|
20
|
+
/*******************************************************************************
|
21
|
+
* Private functions and variables
|
22
|
+
*/
|
23
|
+
// function _assert(cond, msg){
|
24
|
+
// // TODO: see qunit.js extractStacktrace()
|
25
|
+
// if(!cond){
|
26
|
+
// msg = msg ? ": " + msg : "";
|
27
|
+
// $.error("Assertion failed" + msg);
|
28
|
+
// }
|
29
|
+
// }
|
30
|
+
|
31
|
+
/* Calculate inner width without scrollbar */
|
32
|
+
function realInnerWidth($el) {
|
33
|
+
// http://blog.jquery.com/2012/08/16/jquery-1-8-box-sizing-width-csswidth-and-outerwidth/
|
34
|
+
// inst.contWidth = parseFloat(this.$container.css("width"), 10);
|
35
|
+
// 'Client width without scrollbar' - 'padding'
|
36
|
+
return $el[0].clientWidth - ($el.innerWidth() - parseFloat($el.css("width"), 10));
|
37
|
+
}
|
38
|
+
|
39
|
+
|
40
|
+
/**
|
41
|
+
* [ext-wide] Recalculate the width of the selection bar after the tree container
|
42
|
+
* was resized.<br>
|
43
|
+
* May be called explicitly on container resize, since there is no resize event
|
44
|
+
* for DIV tags.
|
45
|
+
*
|
46
|
+
* @alias Fancytree#wideUpdate
|
47
|
+
* @requires jquery.fancytree.wide.js
|
48
|
+
*/
|
49
|
+
$.ui.fancytree._FancytreeClass.prototype.wideUpdate = function(){
|
50
|
+
var inst = this.ext.wide,
|
51
|
+
prevCw = inst.contWidth,
|
52
|
+
prevLo = inst.lineOfs;
|
53
|
+
// http://blog.jquery.com/2012/08/16/jquery-1-8-box-sizing-width-csswidth-and-outerwidth/
|
54
|
+
// inst.contWidth = parseFloat(this.$container.css("width"), 10);
|
55
|
+
inst.contWidth = realInnerWidth(this.$container);
|
56
|
+
// Each title is precceeded by 2 or 3 icons (16px + 3 margin)
|
57
|
+
// + 1px title border and 3px title padding
|
58
|
+
inst.lineOfs = (this.options.checkbox ? 3 : 2) * 19;
|
59
|
+
if( prevCw !== inst.contWidth || prevLo !== inst.lineOfs ) {
|
60
|
+
this.debug("wideUpdate: " + inst.contWidth);
|
61
|
+
this.visit(function(node){
|
62
|
+
node.tree._callHook("nodeRenderTitle", node);
|
63
|
+
});
|
64
|
+
}
|
65
|
+
};
|
66
|
+
|
67
|
+
/*******************************************************************************
|
68
|
+
* Extension code
|
69
|
+
*/
|
70
|
+
$.ui.fancytree.registerExtension({
|
71
|
+
name: "wide",
|
72
|
+
version: "0.0.2",
|
73
|
+
// Default options for this extension.
|
74
|
+
options: {
|
75
|
+
autoResize: true, // call wideUpdate() on window.resize events
|
76
|
+
cheap: false, // true: use static css only
|
77
|
+
margin: {left: 3, right: 3} // free margins near the selection bar
|
78
|
+
},
|
79
|
+
|
80
|
+
treeCreate: function(ctx){
|
81
|
+
this.$container.addClass("fancytree-ext-wide");
|
82
|
+
this._super(ctx);
|
83
|
+
// http://blog.jquery.com/2012/08/16/jquery-1-8-box-sizing-width-csswidth-and-outerwidth/
|
84
|
+
// this._local.contWidth = parseFloat(ctx.tree.$container.css("width"), 10);
|
85
|
+
this._local.contWidth = realInnerWidth(ctx.tree.$container);
|
86
|
+
// Every nested UL is indented by 16px
|
87
|
+
// Each title is precceeded by 2 or 3 icons (16px + 3 margin)
|
88
|
+
// + 1px title border and 3px title padding
|
89
|
+
this._local.lineOfs = (ctx.options.checkbox ? 3 : 2) * 19;
|
90
|
+
this._local.levelOfs = 16;
|
91
|
+
this._local.titlePadding = 3;
|
92
|
+
$(window).on("resize" + ctx.widget.eventNamespace, $.ui.fancytree.debounce(200, function(event){
|
93
|
+
if( ctx.options.wide.autoResize && !ctx.options.wide.cheap ) {
|
94
|
+
ctx.tree.wideUpdate();
|
95
|
+
}
|
96
|
+
}));
|
97
|
+
},
|
98
|
+
treeDestroy: function(ctx){
|
99
|
+
$(window).off("resize" + ctx.widget.eventNamespace);
|
100
|
+
this._super(ctx);
|
101
|
+
},
|
102
|
+
nodeRenderTitle: function(ctx) {
|
103
|
+
var ofs, res, margin,
|
104
|
+
instOpts = ctx.options.wide,
|
105
|
+
inst = this._local,
|
106
|
+
cw = inst.contWidth,
|
107
|
+
node = ctx.node;
|
108
|
+
|
109
|
+
res = this._super(ctx);
|
110
|
+
|
111
|
+
if( !instOpts.cheap ) {
|
112
|
+
margin = instOpts.margin;
|
113
|
+
ofs = (node.getLevel() - 1) * inst.levelOfs + inst.lineOfs;
|
114
|
+
$(node.span).find(".fancytree-title").css({
|
115
|
+
width: cw - margin.left - margin.right - ofs,
|
116
|
+
marginLeft: -ofs + margin.left,
|
117
|
+
paddingLeft: +ofs - margin.left + inst.titlePadding,
|
118
|
+
paddingRight: inst.titlePadding
|
119
|
+
});
|
120
|
+
}
|
121
|
+
return res;
|
122
|
+
}
|
123
|
+
});
|
124
|
+
}(jQuery, window, document));
|
@@ -4,6 +4,11 @@
|
|
4
4
|
* DON'T EDIT THE CSS FILE DIRECTLY, since it is automatically generated from
|
5
5
|
* the LESS templates.
|
6
6
|
*/
|
7
|
+
|
8
|
+
/*
|
9
|
+
*= depend_on_asset "fancytree/icons.gif"
|
10
|
+
*/
|
11
|
+
|
7
12
|
/*******************************************************************************
|
8
13
|
* Common Styles for Fancytree Skins.
|
9
14
|
*
|
@@ -4,6 +4,11 @@
|
|
4
4
|
* DON'T EDIT THE CSS FILE DIRECTLY, since it is automatically generated from
|
5
5
|
* the LESS templates.
|
6
6
|
*/
|
7
|
+
|
8
|
+
/*
|
9
|
+
*= depend_on_asset "fancytree/icons.gif"
|
10
|
+
*/
|
11
|
+
|
7
12
|
/*******************************************************************************
|
8
13
|
* Common Styles for Fancytree Skins.
|
9
14
|
*
|