fancytree-rails 2.0.0.pre.6.pre.1 → 2.0.0.pre.11.pre.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Rakefile +6 -7
- data/lib/fancytree/rails/version.rb +2 -2
- data/vendor/assets/images/fancytree/skin-win8-xxl/icons.gif +0 -0
- data/vendor/assets/images/fancytree/skin-win8-xxl/loading.gif +0 -0
- data/vendor/assets/javascripts/fancytree.js +1 -1
- data/vendor/assets/javascripts/fancytree/MIT-LICENSE.txt +21 -0
- data/vendor/assets/javascripts/fancytree/jquery.fancytree-all.js +1267 -475
- data/vendor/assets/javascripts/fancytree/jquery.fancytree-custom.min.js +41 -0
- data/vendor/assets/javascripts/fancytree/jquery.fancytree.js +582 -310
- data/vendor/assets/javascripts/fancytree/jquery.fancytree.min.js +14 -7
- data/vendor/assets/javascripts/fancytree/src/jquery.fancytree.childcounter.js +185 -0
- data/vendor/assets/javascripts/fancytree/src/jquery.fancytree.clones.js +417 -0
- data/vendor/assets/javascripts/fancytree/src/jquery.fancytree.columnview.js +149 -0
- data/vendor/assets/javascripts/fancytree/src/jquery.fancytree.debug.js +142 -0
- data/vendor/assets/javascripts/fancytree/src/jquery.fancytree.dnd.js +539 -0
- data/vendor/assets/javascripts/fancytree/src/jquery.fancytree.edit.js +318 -0
- data/vendor/assets/javascripts/fancytree/src/jquery.fancytree.filter.js +173 -0
- data/vendor/assets/javascripts/fancytree/{jquery.fancytree.awesome.js → src/jquery.fancytree.glyph.js} +28 -26
- data/vendor/assets/javascripts/fancytree/{jquery.fancytree.gridnav.js → src/jquery.fancytree.gridnav.js} +77 -41
- data/vendor/assets/javascripts/fancytree/src/jquery.fancytree.js +4027 -0
- data/vendor/assets/javascripts/fancytree/src/jquery.fancytree.menu.js +155 -0
- data/vendor/assets/javascripts/fancytree/src/jquery.fancytree.persist.js +345 -0
- data/vendor/assets/javascripts/fancytree/src/jquery.fancytree.table.js +345 -0
- data/vendor/assets/javascripts/fancytree/src/jquery.fancytree.themeroller.js +82 -0
- data/vendor/assets/stylesheets/fancytree/skin-awesome/ui.fancytree.css +29 -15
- data/vendor/assets/stylesheets/fancytree/skin-awesome/ui.fancytree.min.css +1 -1
- data/vendor/assets/stylesheets/fancytree/skin-bootstrap/ui.fancytree.css +366 -0
- data/vendor/assets/stylesheets/fancytree/skin-bootstrap/ui.fancytree.min.css +6 -0
- data/vendor/assets/stylesheets/fancytree/skin-lion/ui.fancytree.css +34 -7
- data/vendor/assets/stylesheets/fancytree/skin-lion/ui.fancytree.min.css +1 -1
- data/vendor/assets/stylesheets/fancytree/skin-vista/ui.fancytree.css +34 -7
- data/vendor/assets/stylesheets/fancytree/skin-vista/ui.fancytree.min.css +1 -1
- data/vendor/assets/stylesheets/fancytree/skin-win7/ui.fancytree.css +34 -7
- data/vendor/assets/stylesheets/fancytree/skin-win7/ui.fancytree.min.css +1 -1
- data/vendor/assets/stylesheets/fancytree/skin-win8-xxl/ui.fancytree.css +507 -0
- data/vendor/assets/stylesheets/fancytree/skin-win8-xxl/ui.fancytree.min.css +11 -0
- data/vendor/assets/stylesheets/fancytree/skin-win8/ui.fancytree.css +34 -7
- data/vendor/assets/stylesheets/fancytree/skin-win8/ui.fancytree.min.css +1 -1
- data/vendor/assets/stylesheets/fancytree/skin-xp/ui.fancytree.css +34 -7
- data/vendor/assets/stylesheets/fancytree/skin-xp/ui.fancytree.min.css +1 -1
- metadata +24 -13
- data/vendor/assets/javascripts/fancytree/jquery.fancytree-all.min.js +0 -7
- data/vendor/assets/javascripts/fancytree/jquery.fancytree-all.min.js.map +0 -1
- data/vendor/assets/javascripts/fancytree/jquery.fancytree.min.js.map +0 -1
- data/vendor/assets/stylesheets/fancytree/skin-lion/ui.fancytree-org.css +0 -460
- data/vendor/assets/stylesheets/fancytree/skin-themeroller/ui.fancytree-org.css +0 -505
- data/vendor/assets/stylesheets/fancytree/skin-vista/ui.fancytree-org.css +0 -610
- data/vendor/assets/stylesheets/fancytree/skin-win7/ui.fancytree-org.css +0 -592
- data/vendor/assets/stylesheets/fancytree/skin-win8/ui.fancytree-org.css +0 -602
- data/vendor/assets/stylesheets/fancytree/skin-xp/ui.fancytree-org.css +0 -578
@@ -0,0 +1,318 @@
|
|
1
|
+
/*!
|
2
|
+
* jquery.fancytree.edit.js
|
3
|
+
*
|
4
|
+
* Make node titles editable.
|
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.0.0-11
|
13
|
+
* @date 2014-04-27T22:28
|
14
|
+
*/
|
15
|
+
|
16
|
+
;(function($, window, document, undefined) {
|
17
|
+
|
18
|
+
"use strict";
|
19
|
+
|
20
|
+
|
21
|
+
/*******************************************************************************
|
22
|
+
* Private functions and variables
|
23
|
+
*/
|
24
|
+
|
25
|
+
var isMac = /Mac/.test(navigator.platform),
|
26
|
+
escapeHtml = $.ui.fancytree.escapeHtml,
|
27
|
+
unescapeHtml = $.ui.fancytree.unescapeHtml;
|
28
|
+
// modifiers = {shift: "shiftKey", ctrl: "ctrlKey", alt: "altKey", meta: "metaKey"},
|
29
|
+
// specialKeys = {
|
30
|
+
// 8: "backspace", 9: "tab", 10: "return", 13: "return", 16: "shift", 17: "ctrl", 18: "alt", 19: "pause",
|
31
|
+
// 20: "capslock", 27: "esc", 32: "space", 33: "pageup", 34: "pagedown", 35: "end", 36: "home",
|
32
|
+
// 37: "left", 38: "up", 39: "right", 40: "down", 45: "insert", 46: "del",
|
33
|
+
// 96: "0", 97: "1", 98: "2", 99: "3", 100: "4", 101: "5", 102: "6", 103: "7",
|
34
|
+
// 104: "8", 105: "9", 106: "*", 107: "+", 109: "-", 110: ".", 111 : "/",
|
35
|
+
// 112: "f1", 113: "f2", 114: "f3", 115: "f4", 116: "f5", 117: "f6", 118: "f7", 119: "f8",
|
36
|
+
// 120: "f9", 121: "f10", 122: "f11", 123: "f12", 144: "numlock", 145: "scroll", 186: ";", 191: "/",
|
37
|
+
// 220: "\\", 222: "'", 224: "meta"
|
38
|
+
// },
|
39
|
+
// shiftNums = {
|
40
|
+
// "`": "~", "1": "!", "2": "@", "3": "#", "4": "$", "5": "%", "6": "^", "7": "&",
|
41
|
+
// "8": "*", "9": "(", "0": ")", "-": "_", "=": "+", ";": ": ", "'": "\"", ",": "<",
|
42
|
+
// ".": ">", "/": "?", "\\": "|"
|
43
|
+
// };
|
44
|
+
|
45
|
+
|
46
|
+
// $.ui.fancytree.isKeydownEvent = function(e, code){
|
47
|
+
// var i, part, partmap, partlist = code.split("+"), len = parts.length;
|
48
|
+
// var c = String.fromCharCode(e.which).toLowerCase();
|
49
|
+
// for( i = 0; i < len; i++ ) {
|
50
|
+
// }
|
51
|
+
// alert (parts.unshift());
|
52
|
+
// alert (parts.unshift());
|
53
|
+
// alert (parts.unshift());
|
54
|
+
// };
|
55
|
+
|
56
|
+
|
57
|
+
/**
|
58
|
+
* [ext-edit] Start inline editing of current node title.
|
59
|
+
*
|
60
|
+
* @alias FancytreeNode#editStart
|
61
|
+
* @requires Fancytree
|
62
|
+
*/
|
63
|
+
$.ui.fancytree._FancytreeNodeClass.prototype.editStart = function(){
|
64
|
+
var $input,
|
65
|
+
node = this,
|
66
|
+
tree = this.tree,
|
67
|
+
local = tree.ext.edit,
|
68
|
+
prevTitle = node.title,
|
69
|
+
instOpts = tree.options.edit,
|
70
|
+
$title = $(".fancytree-title", node.span),
|
71
|
+
eventData = {node: node, tree: tree, options: tree.options};
|
72
|
+
|
73
|
+
if( instOpts.beforeEdit.call(node, {type: "beforeEdit"}, eventData) === false){
|
74
|
+
return false;
|
75
|
+
}
|
76
|
+
// beforeEdit may want to modify the title before editing
|
77
|
+
prevTitle = node.title;
|
78
|
+
|
79
|
+
node.debug("editStart");
|
80
|
+
// Disable standard Fancytree mouse- and key handling
|
81
|
+
tree.widget._unbind();
|
82
|
+
// #116: ext-dnd prevents the blur event, so we have to catch outer clicks
|
83
|
+
$(document).on("mousedown.fancytree-edit", function(event){
|
84
|
+
if( ! $(event.target).hasClass("fancytree-edit-input") ){
|
85
|
+
node.editEnd(true, event);
|
86
|
+
}
|
87
|
+
});
|
88
|
+
|
89
|
+
// Replace node with <input>
|
90
|
+
$input = $("<input />", {
|
91
|
+
"class": "fancytree-edit-input",
|
92
|
+
value: unescapeHtml(prevTitle)
|
93
|
+
});
|
94
|
+
if ( instOpts.adjustWidthOfs != null ) {
|
95
|
+
$input.width($title.width() + instOpts.adjustWidthOfs);
|
96
|
+
}
|
97
|
+
if ( instOpts.inputCss != null ) {
|
98
|
+
$input.css(instOpts.inputCss);
|
99
|
+
}
|
100
|
+
eventData.input = $input;
|
101
|
+
|
102
|
+
$title.html($input);
|
103
|
+
|
104
|
+
$.ui.fancytree.assert(!local.currentNode, "recursive edit");
|
105
|
+
local.currentNode = this;
|
106
|
+
// Focus <input> and bind keyboard handler
|
107
|
+
$input
|
108
|
+
.focus()
|
109
|
+
.change(function(event){
|
110
|
+
$input.addClass("fancytree-edit-dirty");
|
111
|
+
}).keydown(function(event){
|
112
|
+
switch( event.which ) {
|
113
|
+
case $.ui.keyCode.ESCAPE:
|
114
|
+
node.editEnd(false, event);
|
115
|
+
break;
|
116
|
+
case $.ui.keyCode.ENTER:
|
117
|
+
node.editEnd(true, event);
|
118
|
+
return false; // so we don't start editmode on Mac
|
119
|
+
}
|
120
|
+
}).blur(function(event){
|
121
|
+
return node.editEnd(true, event);
|
122
|
+
});
|
123
|
+
|
124
|
+
instOpts.edit.call(node, {type: "edit"}, eventData);
|
125
|
+
};
|
126
|
+
|
127
|
+
|
128
|
+
/**
|
129
|
+
* [ext-edit] Stop inline editing.
|
130
|
+
* @param {Boolean} [applyChanges=false]
|
131
|
+
* @alias FancytreeNode#editEnd
|
132
|
+
* @requires jquery.fancytree.edit.js
|
133
|
+
*/
|
134
|
+
$.ui.fancytree._FancytreeNodeClass.prototype.editEnd = function(applyChanges, _event){
|
135
|
+
var node = this,
|
136
|
+
tree = this.tree,
|
137
|
+
local = tree.ext.edit,
|
138
|
+
instOpts = tree.options.edit,
|
139
|
+
$title = $(".fancytree-title", node.span),
|
140
|
+
$input = $title.find("input.fancytree-edit-input"),
|
141
|
+
newVal = $input.val(),
|
142
|
+
dirty = $input.hasClass("fancytree-edit-dirty"),
|
143
|
+
doSave = (applyChanges || (dirty && applyChanges !== false)) && (newVal !== node.title),
|
144
|
+
eventData = {
|
145
|
+
node: node, tree: tree, options: tree.options, originalEvent: _event,
|
146
|
+
dirty: dirty,
|
147
|
+
save: doSave,
|
148
|
+
input: $input,
|
149
|
+
value: newVal
|
150
|
+
};
|
151
|
+
|
152
|
+
if( instOpts.beforeClose.call(node, {type: "beforeClose"}, eventData) === false){
|
153
|
+
return false;
|
154
|
+
}
|
155
|
+
if( doSave && instOpts.save.call(node, {type: "save"}, eventData) === false){
|
156
|
+
return false;
|
157
|
+
}
|
158
|
+
$input
|
159
|
+
.removeClass("fancytree-edit-dirty")
|
160
|
+
.unbind();
|
161
|
+
// Unbind outer-click handler
|
162
|
+
$(document).off(".fancytree-edit");
|
163
|
+
|
164
|
+
if( doSave ) {
|
165
|
+
node.setTitle( escapeHtml(newVal) );
|
166
|
+
}else{
|
167
|
+
node.renderTitle();
|
168
|
+
}
|
169
|
+
// Re-enable mouse and keyboard handling
|
170
|
+
tree.widget._bind();
|
171
|
+
local.currentNode = null;
|
172
|
+
node.setFocus();
|
173
|
+
// Set keyboard focus, even if setFocus() claims 'nothing to do'
|
174
|
+
$(tree.$container).focus();
|
175
|
+
eventData.input = null;
|
176
|
+
instOpts.close.call(node, {type: "close"}, eventData);
|
177
|
+
return true;
|
178
|
+
};
|
179
|
+
|
180
|
+
|
181
|
+
$.ui.fancytree._FancytreeNodeClass.prototype.startEdit = function(){
|
182
|
+
this.warn("FancytreeNode.startEdit() is deprecated since 2014-01-04. Use .editStart() instead.");
|
183
|
+
return this.editStart.apply(this, arguments);
|
184
|
+
};
|
185
|
+
|
186
|
+
|
187
|
+
$.ui.fancytree._FancytreeNodeClass.prototype.endEdit = function(){
|
188
|
+
this.warn("FancytreeNode.endEdit() is deprecated since 2014-01-04. Use .editEnd() instead.");
|
189
|
+
return this.editEnd.apply(this, arguments);
|
190
|
+
};
|
191
|
+
|
192
|
+
|
193
|
+
///**
|
194
|
+
// * Create a new child or sibling node.
|
195
|
+
// *
|
196
|
+
// * @param {String} [mode] 'before', 'after', or 'child'
|
197
|
+
// * @lends FancytreeNode.prototype
|
198
|
+
// * @requires jquery.fancytree.edit.js
|
199
|
+
// */
|
200
|
+
//$.ui.fancytree._FancytreeNodeClass.prototype.editCreateNode = function(mode){
|
201
|
+
// var newNode,
|
202
|
+
// node = this,
|
203
|
+
// tree = this.tree,
|
204
|
+
// local = tree.ext.edit,
|
205
|
+
// instOpts = tree.options.edit,
|
206
|
+
// $title = $(".fancytree-title", node.span),
|
207
|
+
// $input = $title.find("input.fancytree-edit-input"),
|
208
|
+
// newVal = $input.val(),
|
209
|
+
// dirty = $input.hasClass("fancytree-edit-dirty"),
|
210
|
+
// doSave = (applyChanges || (dirty && applyChanges !== false)) && (newVal !== node.title),
|
211
|
+
// eventData = {
|
212
|
+
// node: node, tree: tree, options: tree.options, originalEvent: _event,
|
213
|
+
// dirty: dirty,
|
214
|
+
// save: doSave,
|
215
|
+
// input: $input,
|
216
|
+
// value: newVal
|
217
|
+
// };
|
218
|
+
//
|
219
|
+
// node.debug("editCreate");
|
220
|
+
//
|
221
|
+
// if( instOpts.beforeEdit.call(node, {type: "beforeCreateNode"}, eventData) === false){
|
222
|
+
// return false;
|
223
|
+
// }
|
224
|
+
// newNode = this.addNode({title: "Neuer Knoten"}, mode);
|
225
|
+
//
|
226
|
+
// newNode.editStart();
|
227
|
+
//};
|
228
|
+
|
229
|
+
|
230
|
+
/**
|
231
|
+
* [ext-edit] Check if any node in this tree in edit mode.
|
232
|
+
*
|
233
|
+
* @returns {FancytreeNode | null}
|
234
|
+
* @lends Fancytree.prototype
|
235
|
+
* @requires jquery.fancytree.edit.js
|
236
|
+
*/
|
237
|
+
$.ui.fancytree._FancytreeClass.prototype.isEditing = function(){
|
238
|
+
return this.ext.edit.currentNode;
|
239
|
+
};
|
240
|
+
|
241
|
+
|
242
|
+
/**
|
243
|
+
* [ext-edit] Check if this node is in edit mode.
|
244
|
+
* @returns {Boolean} true if node is currently beeing edited
|
245
|
+
* @lends FancytreeNode.prototype
|
246
|
+
* @requires jquery.fancytree.edit.js
|
247
|
+
*/
|
248
|
+
$.ui.fancytree._FancytreeNodeClass.prototype.isEditing = function(){
|
249
|
+
return this.tree.ext.edit.currentNode === this;
|
250
|
+
};
|
251
|
+
|
252
|
+
|
253
|
+
/*******************************************************************************
|
254
|
+
* Extension code
|
255
|
+
*/
|
256
|
+
$.ui.fancytree.registerExtension({
|
257
|
+
name: "edit",
|
258
|
+
version: "0.1.0",
|
259
|
+
// Default options for this extension.
|
260
|
+
options: {
|
261
|
+
adjustWidthOfs: 4, // null: don't adjust input size to content
|
262
|
+
inputCss: {minWidth: "3em"},
|
263
|
+
triggerCancel: ["esc", "tab", "click"],
|
264
|
+
// triggerStart: ["f2", "dblclick", "shift+click", "mac+enter"],
|
265
|
+
triggerStart: ["f2", "shift+click", "mac+enter"],
|
266
|
+
beforeClose: $.noop, // Return false to prevent cancel/save (data.input is available)
|
267
|
+
beforeEdit: $.noop, // Return false to prevent edit mode
|
268
|
+
close: $.noop, // Editor was removed
|
269
|
+
edit: $.noop, // Editor was opened (available as data.input)
|
270
|
+
// keypress: $.noop, // Not yet implemented
|
271
|
+
save: $.noop // Save data.input.val() or return false to keep editor open
|
272
|
+
},
|
273
|
+
// Local attributes
|
274
|
+
currentNode: null,
|
275
|
+
|
276
|
+
// Override virtual methods for this extension.
|
277
|
+
// `this` : the Fancytree instance
|
278
|
+
// `this._local`: the namespace that contains extension attributes and private methods (same as this.ext.EXTNAME)
|
279
|
+
// `this._super`: the virtual function that was overridden (member of previous extension or Fancytree)
|
280
|
+
treeInit: function(ctx){
|
281
|
+
this._super(ctx);
|
282
|
+
this.$container.addClass("fancytree-ext-edit");
|
283
|
+
},
|
284
|
+
nodeClick: function(ctx) {
|
285
|
+
if( $.inArray("shift+click", ctx.options.edit.triggerStart) >= 0 ){
|
286
|
+
if( ctx.originalEvent.shiftKey ){
|
287
|
+
ctx.node.editStart();
|
288
|
+
return false;
|
289
|
+
}
|
290
|
+
}
|
291
|
+
this._super(ctx);
|
292
|
+
},
|
293
|
+
nodeDblclick: function(ctx) {
|
294
|
+
if( $.inArray("dblclick", ctx.options.edit.triggerStart) >= 0 ){
|
295
|
+
ctx.node.editStart();
|
296
|
+
return false;
|
297
|
+
}
|
298
|
+
return this._super(ctx);
|
299
|
+
},
|
300
|
+
nodeKeydown: function(ctx) {
|
301
|
+
switch( ctx.originalEvent.which ) {
|
302
|
+
case 113: // [F2]
|
303
|
+
if( $.inArray("f2", ctx.options.edit.triggerStart) >= 0 ){
|
304
|
+
ctx.node.editStart();
|
305
|
+
return false;
|
306
|
+
}
|
307
|
+
break;
|
308
|
+
case $.ui.keyCode.ENTER:
|
309
|
+
if( $.inArray("mac+enter", ctx.options.edit.triggerStart) >= 0 && isMac ){
|
310
|
+
ctx.node.editStart();
|
311
|
+
return false;
|
312
|
+
}
|
313
|
+
break;
|
314
|
+
}
|
315
|
+
return this._super(ctx);
|
316
|
+
}
|
317
|
+
});
|
318
|
+
}(jQuery, window, document));
|
@@ -0,0 +1,173 @@
|
|
1
|
+
/*!
|
2
|
+
* jquery.fancytree.filter.js
|
3
|
+
*
|
4
|
+
* Remove or highlight tree nodes, based on a filter.
|
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.0.0-11
|
13
|
+
* @date 2014-04-27T22:28
|
14
|
+
*/
|
15
|
+
|
16
|
+
;(function($, window, document, undefined) {
|
17
|
+
|
18
|
+
"use strict";
|
19
|
+
|
20
|
+
|
21
|
+
/*******************************************************************************
|
22
|
+
* Private functions and variables
|
23
|
+
*/
|
24
|
+
|
25
|
+
function _escapeRegex(str){
|
26
|
+
/*jshint regexdash:true */
|
27
|
+
return (str + "").replace(/([.?*+\^\$\[\]\\(){}|-])/g, "\\$1");
|
28
|
+
}
|
29
|
+
|
30
|
+
/* EXT-TABLE: Show/hide all rows that are structural descendants of `parent`. */
|
31
|
+
// function setChildRowVisibility(parent, flag) {
|
32
|
+
// parent.visit(function(node){
|
33
|
+
// var tr = node.tr;
|
34
|
+
// if(tr){
|
35
|
+
// tr.style.display = flag ? "" : "none";
|
36
|
+
// }
|
37
|
+
// node.debug(flag ? "SHOW" : "HIDE");
|
38
|
+
// if(!node.expanded){
|
39
|
+
// return "skip";
|
40
|
+
// }
|
41
|
+
// });
|
42
|
+
// }
|
43
|
+
|
44
|
+
/**
|
45
|
+
* [ext-filter] Dimm or hide nodes.
|
46
|
+
*
|
47
|
+
* @param {function | string} filter
|
48
|
+
* @returns {integer} count
|
49
|
+
* @alias Fancytree#applyFilter
|
50
|
+
* @requires jquery.fancytree.filter.js
|
51
|
+
*/
|
52
|
+
$.ui.fancytree._FancytreeClass.prototype.applyFilter = function(filter){
|
53
|
+
var match, re,
|
54
|
+
count = 0,
|
55
|
+
hideMode = this.options.filter.mode === "hide",
|
56
|
+
leavesOnly = this.options.filter.leavesOnly;
|
57
|
+
|
58
|
+
// Default to 'match title substring (not case sensitive)'
|
59
|
+
if(typeof filter === "string"){
|
60
|
+
match = _escapeRegex(filter); // make sure a '.' is treated literally
|
61
|
+
re = new RegExp(".*" + match + ".*", "i");
|
62
|
+
filter = function(node){
|
63
|
+
return !!re.exec(node.title);
|
64
|
+
};
|
65
|
+
}
|
66
|
+
|
67
|
+
this.enableFilter = true;
|
68
|
+
this.$div.addClass("fancytree-ext-filter");
|
69
|
+
if( hideMode ){
|
70
|
+
this.$div.addClass("fancytree-ext-filter-hide");
|
71
|
+
} else {
|
72
|
+
this.$div.addClass("fancytree-ext-filter-dimm");
|
73
|
+
}
|
74
|
+
// Reset current filter
|
75
|
+
this.visit(function(node){
|
76
|
+
// node.hide = hideMode && true;
|
77
|
+
delete node.match;
|
78
|
+
delete node.subMatch;
|
79
|
+
});
|
80
|
+
// Adjust node.hide, .match, .subMatch flags
|
81
|
+
this.visit(function(node){
|
82
|
+
if ((!leavesOnly || node.children == null) && filter(node)) {
|
83
|
+
count++;
|
84
|
+
// node.hide = false;
|
85
|
+
node.match = true;
|
86
|
+
node.visitParents(function(p){
|
87
|
+
// p.hide = false;
|
88
|
+
p.subMatch = true;
|
89
|
+
});
|
90
|
+
}
|
91
|
+
});
|
92
|
+
// Redraw
|
93
|
+
this.render();
|
94
|
+
return count;
|
95
|
+
};
|
96
|
+
|
97
|
+
/**
|
98
|
+
* [ext-filter] Reset the filter.
|
99
|
+
*
|
100
|
+
* @alias Fancytree#applyFilter
|
101
|
+
* @requires jquery.fancytree.filter.js
|
102
|
+
*/
|
103
|
+
$.ui.fancytree._FancytreeClass.prototype.clearFilter = function(){
|
104
|
+
this.visit(function(node){
|
105
|
+
// delete node.hide;
|
106
|
+
delete node.match;
|
107
|
+
delete node.subMatch;
|
108
|
+
});
|
109
|
+
this.enableFilter = false;
|
110
|
+
this.$div.removeClass("fancytree-ext-filter fancytree-ext-filter-dimm fancytree-ext-filter-hide");
|
111
|
+
this.render();
|
112
|
+
};
|
113
|
+
|
114
|
+
|
115
|
+
/*******************************************************************************
|
116
|
+
* Extension code
|
117
|
+
*/
|
118
|
+
$.ui.fancytree.registerExtension({
|
119
|
+
name: "filter",
|
120
|
+
version: "0.0.2",
|
121
|
+
// Default options for this extension.
|
122
|
+
options: {
|
123
|
+
mode: "dimm",
|
124
|
+
leavesOnly: false
|
125
|
+
},
|
126
|
+
// Override virtual methods for this extension.
|
127
|
+
// `this` : is this extension object
|
128
|
+
// `this._base` : the Fancytree instance
|
129
|
+
// `this._super`: the virtual function that was overriden (member of prev. extension or Fancytree)
|
130
|
+
treeInit: function(ctx){
|
131
|
+
this._super(ctx);
|
132
|
+
// ctx.tree.filter = false;
|
133
|
+
},
|
134
|
+
treeDestroy: function(ctx){
|
135
|
+
this._super(ctx);
|
136
|
+
},
|
137
|
+
nodeRenderStatus: function(ctx) {
|
138
|
+
// Set classes for current status
|
139
|
+
var res,
|
140
|
+
node = ctx.node,
|
141
|
+
tree = ctx.tree,
|
142
|
+
$span = $(node[tree.statusClassPropName]);
|
143
|
+
|
144
|
+
res = this._super(ctx);
|
145
|
+
|
146
|
+
if(!$span.length){
|
147
|
+
return res; // nothing to do, if node was not yet rendered
|
148
|
+
}
|
149
|
+
if(!tree.enableFilter){
|
150
|
+
return res;
|
151
|
+
}
|
152
|
+
$span.toggleClass("fancytree-match", !!node.match);
|
153
|
+
$span.toggleClass("fancytree-submatch", !!node.subMatch);
|
154
|
+
$span.toggleClass("fancytree-hide", !(node.match || node.subMatch));
|
155
|
+
|
156
|
+
// if(opts.filter.mode === "hide"){
|
157
|
+
// // visible = !!(node.match || node.subMatch);
|
158
|
+
// visible = !node.hide;
|
159
|
+
// node.debug(node.title + ": visible=" + visible);
|
160
|
+
// if( node.li ) {
|
161
|
+
// $(node.li).toggle(visible);
|
162
|
+
// } else if( node.tr ) {
|
163
|
+
// // Show/hide all rows that are structural descendants of `parent`
|
164
|
+
// $(node.tr).toggle(visible);
|
165
|
+
// // if( !visible ) {
|
166
|
+
// // setChildRowVisibility(node, visible);
|
167
|
+
// // }
|
168
|
+
// }
|
169
|
+
// }
|
170
|
+
return res;
|
171
|
+
}
|
172
|
+
});
|
173
|
+
}(jQuery, window, document));
|