fancytree-rails 2.0.0.pre.11.pre.1 → 2.1.0.pre.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/3th-party/jquery-ui.License.txt +2 -0
  3. data/README.md +7 -1
  4. data/Rakefile +21 -5
  5. data/{vendor → app}/assets/images/fancytree/icons.gif +0 -0
  6. data/{vendor → app}/assets/images/fancytree/loading.gif +0 -0
  7. data/app/assets/images/fancytree/skin-lion/icons.gif +0 -0
  8. data/{vendor → app}/assets/images/fancytree/skin-lion/loading.gif +0 -0
  9. data/app/assets/images/fancytree/skin-themeroller/icons.gif +0 -0
  10. data/{vendor → app}/assets/images/fancytree/skin-themeroller/loading.gif +0 -0
  11. data/app/assets/images/fancytree/skin-vista/icons.gif +0 -0
  12. data/{vendor → app}/assets/images/fancytree/skin-vista/loading.gif +0 -0
  13. data/app/assets/images/fancytree/skin-win7/icons.gif +0 -0
  14. data/{vendor → app}/assets/images/fancytree/skin-win7/loading.gif +0 -0
  15. data/{vendor → app}/assets/images/fancytree/skin-win8-xxl/icons.gif +0 -0
  16. data/{vendor → app}/assets/images/fancytree/skin-win8-xxl/loading.gif +0 -0
  17. data/app/assets/images/fancytree/skin-win8/icons.gif +0 -0
  18. data/{vendor → app}/assets/images/fancytree/skin-win8/loading.gif +0 -0
  19. data/{vendor → app}/assets/images/fancytree/skin-xp/icons-rtl.gif +0 -0
  20. data/{vendor → app}/assets/images/fancytree/skin-xp/icons.gif +0 -0
  21. data/{vendor → app}/assets/images/fancytree/skin-xp/loading.gif +0 -0
  22. data/{vendor → app}/assets/images/fancytree/skin-xp/vline-rtl.gif +0 -0
  23. data/{vendor → app}/assets/images/fancytree/skin-xp/vline.gif +0 -0
  24. data/{vendor → app}/assets/javascripts/fancytree.js +0 -0
  25. data/{vendor → app}/assets/javascripts/fancytree/MIT-LICENSE.txt +0 -0
  26. data/{vendor → app}/assets/javascripts/fancytree/jquery.fancytree-all.js +346 -333
  27. data/app/assets/javascripts/fancytree/jquery.fancytree-custom.min.js +41 -0
  28. data/{vendor → app}/assets/javascripts/fancytree/jquery.fancytree.js +109 -66
  29. data/app/assets/javascripts/fancytree/jquery.fancytree.min.js +14 -0
  30. data/{vendor → app}/assets/javascripts/fancytree/src/jquery.fancytree.childcounter.js +3 -3
  31. data/{vendor → app}/assets/javascripts/fancytree/src/jquery.fancytree.clones.js +36 -6
  32. data/{vendor → app}/assets/javascripts/fancytree/src/jquery.fancytree.columnview.js +2 -2
  33. data/{vendor → app}/assets/javascripts/fancytree/src/jquery.fancytree.debug.js +2 -2
  34. data/{vendor → app}/assets/javascripts/fancytree/src/jquery.fancytree.dnd.js +35 -51
  35. data/{vendor → app}/assets/javascripts/fancytree/src/jquery.fancytree.edit.js +5 -9
  36. data/{vendor → app}/assets/javascripts/fancytree/src/jquery.fancytree.filter.js +54 -66
  37. data/{vendor → app}/assets/javascripts/fancytree/src/jquery.fancytree.glyph.js +6 -9
  38. data/{vendor → app}/assets/javascripts/fancytree/src/jquery.fancytree.gridnav.js +2 -2
  39. data/{vendor → app}/assets/javascripts/fancytree/src/jquery.fancytree.js +109 -66
  40. data/{vendor → app}/assets/javascripts/fancytree/src/jquery.fancytree.menu.js +2 -2
  41. data/{vendor → app}/assets/javascripts/fancytree/src/jquery.fancytree.persist.js +106 -112
  42. data/{vendor → app}/assets/javascripts/fancytree/src/jquery.fancytree.table.js +23 -9
  43. data/{vendor → app}/assets/javascripts/fancytree/src/jquery.fancytree.themeroller.js +3 -6
  44. data/{vendor/assets/stylesheets/fancytree/skin-awesome/ui.fancytree.css → app/assets/stylesheets/fancytree/skin-awesome/ui.fancytree.css.erb} +30 -5
  45. data/app/assets/stylesheets/fancytree/skin-awesome/ui.fancytree.min.css.erb +6 -0
  46. data/{vendor/assets/stylesheets/fancytree/skin-bootstrap/ui.fancytree.css → app/assets/stylesheets/fancytree/skin-bootstrap/ui.fancytree.css.erb} +31 -6
  47. data/app/assets/stylesheets/fancytree/skin-bootstrap/ui.fancytree.min.css.erb +6 -0
  48. data/{vendor/assets/stylesheets/fancytree/skin-lion/ui.fancytree.css → app/assets/stylesheets/fancytree/skin-lion/ui.fancytree.css.erb} +35 -14
  49. data/app/assets/stylesheets/fancytree/skin-lion/ui.fancytree.min.css.erb +6 -0
  50. data/{vendor/assets/stylesheets/fancytree/skin-themeroller/ui.fancytree.css → app/assets/stylesheets/fancytree/skin-themeroller/ui.fancytree.css.erb} +1 -1
  51. data/{vendor/assets/stylesheets/fancytree/skin-themeroller/ui.fancytree.min.css → app/assets/stylesheets/fancytree/skin-themeroller/ui.fancytree.min.css.erb} +0 -0
  52. data/{vendor/assets/stylesheets/fancytree/skin-vista/ui.fancytree.css → app/assets/stylesheets/fancytree/skin-vista/ui.fancytree.css.erb} +35 -14
  53. data/app/assets/stylesheets/fancytree/skin-vista/ui.fancytree.min.css.erb +6 -0
  54. data/{vendor/assets/stylesheets/fancytree/skin-win7/ui.fancytree.css → app/assets/stylesheets/fancytree/skin-win7/ui.fancytree.css.erb} +35 -14
  55. data/app/assets/stylesheets/fancytree/skin-win7/ui.fancytree.min.css.erb +6 -0
  56. data/{vendor/assets/stylesheets/fancytree/skin-win8-xxl/ui.fancytree.css → app/assets/stylesheets/fancytree/skin-win8-xxl/ui.fancytree.css.erb} +37 -16
  57. data/app/assets/stylesheets/fancytree/skin-win8-xxl/ui.fancytree.min.css.erb +11 -0
  58. data/{vendor/assets/stylesheets/fancytree/skin-win8/ui.fancytree.css → app/assets/stylesheets/fancytree/skin-win8/ui.fancytree.css.erb} +37 -16
  59. data/app/assets/stylesheets/fancytree/skin-win8/ui.fancytree.min.css.erb +6 -0
  60. data/{vendor/assets/stylesheets/fancytree/skin-xp/ui.fancytree.css → app/assets/stylesheets/fancytree/skin-xp/ui.fancytree.css.erb} +35 -14
  61. data/app/assets/stylesheets/fancytree/skin-xp/ui.fancytree.min.css.erb +6 -0
  62. data/{vendor → app}/assets/stylesheets/ui.fancytree.css +0 -0
  63. data/lib/fancytree/rails/version.rb +2 -2
  64. metadata +77 -76
  65. data/vendor/assets/images/fancytree/skin-lion/icons.gif +0 -0
  66. data/vendor/assets/images/fancytree/skin-themeroller/icons.gif +0 -0
  67. data/vendor/assets/images/fancytree/skin-vista/icons.gif +0 -0
  68. data/vendor/assets/images/fancytree/skin-win7/icons.gif +0 -0
  69. data/vendor/assets/images/fancytree/skin-win8/icons.gif +0 -0
  70. data/vendor/assets/javascripts/fancytree/jquery.fancytree-custom.min.js +0 -41
  71. data/vendor/assets/javascripts/fancytree/jquery.fancytree.min.js +0 -14
  72. data/vendor/assets/stylesheets/fancytree/skin-awesome/ui.fancytree.min.css +0 -6
  73. data/vendor/assets/stylesheets/fancytree/skin-bootstrap/ui.fancytree.min.css +0 -6
  74. data/vendor/assets/stylesheets/fancytree/skin-lion/ui.fancytree.min.css +0 -6
  75. data/vendor/assets/stylesheets/fancytree/skin-vista/ui.fancytree.min.css +0 -6
  76. data/vendor/assets/stylesheets/fancytree/skin-win7/ui.fancytree.min.css +0 -6
  77. data/vendor/assets/stylesheets/fancytree/skin-win8-xxl/ui.fancytree.min.css +0 -11
  78. data/vendor/assets/stylesheets/fancytree/skin-win8/ui.fancytree.min.css +0 -6
  79. data/vendor/assets/stylesheets/fancytree/skin-xp/ui.fancytree.min.css +0 -6
@@ -9,8 +9,8 @@
9
9
  * Released under the MIT license
10
10
  * https://github.com/mar10/fancytree/wiki/LicenseInfo
11
11
  *
12
- * @version 2.0.0-11
13
- * @date 2014-04-27T22:28
12
+ * @version 2.1.0
13
+ * @date 2014-05-29T16:44
14
14
  */
15
15
 
16
16
  ;(function($, window, document, undefined) {
@@ -9,8 +9,8 @@
9
9
  * Released under the MIT license
10
10
  * https://github.com/mar10/fancytree/wiki/LicenseInfo
11
11
  *
12
- * @version 2.0.0-11
13
- * @date 2014-04-27T22:28
12
+ * @version 2.1.0
13
+ * @date 2014-05-29T16:44
14
14
  */
15
15
 
16
16
  ;(function($, window, document, undefined) {
@@ -9,8 +9,8 @@
9
9
  * Released under the MIT license
10
10
  * https://github.com/mar10/fancytree/wiki/LicenseInfo
11
11
  *
12
- * @version 2.0.0-11
13
- * @date 2014-04-27T22:28
12
+ * @version 2.1.0
13
+ * @date 2014-05-29T16:44
14
14
  */
15
15
 
16
16
  ;(function($, window, document, undefined) {
@@ -73,8 +73,7 @@ function _initDragAndDrop(tree) {
73
73
  addClasses: false,
74
74
  tolerance: "intersect",
75
75
  greedy: false
76
- /*
77
- ,
76
+ /*
78
77
  activate: function(event, ui) {
79
78
  logMsg("droppable - activate", event, ui, this);
80
79
  },
@@ -112,32 +111,24 @@ function _registerDnd() {
112
111
  // 'draggable' was renamed to 'ui-draggable' since jQueryUI 1.10
113
112
  var draggable = $(this).data("ui-draggable") || $(this).data("draggable"),
114
113
  sourceNode = ui.helper.data("ftSourceNode") || null;
115
- // logMsg("draggable-connectToFancytree.start, %s", sourceNode);
116
- // logMsg(" this: %o", this);
117
- // logMsg(" event: %o", event);
118
- // logMsg(" draggable: %o", draggable);
119
- // logMsg(" ui: %o", ui);
120
114
 
121
115
  if(sourceNode) {
122
116
  // Adjust helper offset, so cursor is slightly outside top/left corner
123
117
  draggable.offset.click.top = -2;
124
118
  draggable.offset.click.left = + 16;
125
- // logMsg(" draggable2: %o", draggable);
126
- // logMsg(" draggable.offset.click FIXED: %s/%s", draggable.offset.click.left, draggable.offset.click.top);
127
119
  // Trigger dragStart event
128
120
  // TODO: when called as connectTo..., the return value is ignored(?)
129
121
  return sourceNode.tree.ext.dnd._onDragEvent("start", sourceNode, null, event, ui, draggable);
130
122
  }
131
123
  },
132
124
  drag: function(event, ui) {
133
- // 'draggable' was renamed to 'ui-draggable' since jQueryUI 1.10
134
125
  var isHelper,
126
+ // 'draggable' was renamed to 'ui-draggable' since jQueryUI 1.10
135
127
  draggable = $(this).data("ui-draggable") || $(this).data("draggable"),
136
128
  sourceNode = ui.helper.data("ftSourceNode") || null,
137
129
  prevTargetNode = ui.helper.data("ftTargetNode") || null,
138
130
  targetNode = $.ui.fancytree.getNode(event.target);
139
- // logMsg("$.ui.fancytree.getNode(%o): %s", event.target, targetNode);
140
- // logMsg("connectToFancytree.drag: helper: %o", ui.helper[0]);
131
+
141
132
  if(event.target && !targetNode){
142
133
  // We got a drag event, but the targetNode could not be found
143
134
  // at the event location. This may happen,
@@ -150,7 +141,6 @@ function _registerDnd() {
150
141
  return;
151
142
  }
152
143
  }
153
- // logMsg("draggable-connectToFancytree.drag: targetNode(from event): %s, ftTargetNode: %s", targetNode, ui.helper.data("ftTargetNode"));
154
144
  ui.helper.data("ftTargetNode", targetNode);
155
145
  // Leaving a tree node
156
146
  if(prevTargetNode && prevTargetNode !== targetNode ) {
@@ -177,10 +167,7 @@ function _registerDnd() {
177
167
  // mouseDownEvent = draggable._mouseDownEvent,
178
168
  eventType = event.type,
179
169
  dropped = (eventType === "mouseup" && event.which === 1);
180
- // logMsg("draggable-connectToFancytree.stop: targetNode(from event): %s, ftTargetNode: %s", targetNode, ui.helper.data("ftTargetNode"));
181
- // logMsg("draggable-connectToFancytree.stop, %s", sourceNode);
182
- // logMsg(" type: %o, downEvent: %o, upEvent: %o", eventType, mouseDownEvent, event);
183
- // logMsg(" targetNode: %o", targetNode);
170
+
184
171
  if(!dropped){
185
172
  logMsg("Drag was cancelled");
186
173
  }
@@ -204,8 +191,7 @@ function _registerDnd() {
204
191
  *
205
192
  */
206
193
 
207
- $.ui.fancytree.registerExtension(
208
- {
194
+ $.ui.fancytree.registerExtension({
209
195
  name: "dnd",
210
196
  version: "0.1.0",
211
197
  // Default options for this extension.
@@ -226,9 +212,7 @@ $.ui.fancytree.registerExtension(
226
212
  draggable: null, // Additional options passed to jQuery draggable
227
213
  droppable: null // Additional options passed to jQuery droppable
228
214
  },
229
- // Override virtual methods for this extension.
230
- // `this` : Fancytree instance
231
- // `this._super`: the virtual function that was overriden (member of prev. extension or Fancytree)
215
+
232
216
  treeInit: function(ctx){
233
217
  var tree = ctx.tree;
234
218
  this._super(ctx);
@@ -257,15 +241,7 @@ $.ui.fancytree.registerExtension(
257
241
  .css({"z-index": 1000})
258
242
  .prependTo($(this.$div).parent());
259
243
  // .prependTo("body");
260
- // logMsg("Creating marker: %o", this.$dropMarker);
261
- }
262
- /*
263
- if(hitMode === "start"){
264
- }
265
- if(hitMode === "stop"){
266
- // sourceNode.removeClass("fancytree-drop-target");
267
244
  }
268
- */
269
245
  // this.$dropMarker.attr("class", hitMode);
270
246
  if(hitMode === "after" || hitMode === "before" || hitMode === "over"){
271
247
  // $source && $source.addClass("fancytree-drag-source");
@@ -274,18 +250,19 @@ $.ui.fancytree.registerExtension(
274
250
 
275
251
  switch(hitMode){
276
252
  case "before":
277
- instData.$dropMarker.removeClass("fancytree-drop-after fancytree-drop-over");
278
- instData.$dropMarker.addClass("fancytree-drop-before");
253
+ instData
254
+ .$dropMarker.removeClass("fancytree-drop-after fancytree-drop-over")
255
+ .addClass("fancytree-drop-before");
279
256
  markerAt = "top";
280
257
  break;
281
258
  case "after":
282
- instData.$dropMarker.removeClass("fancytree-drop-before fancytree-drop-over");
283
- instData.$dropMarker.addClass("fancytree-drop-after");
259
+ instData.$dropMarker.removeClass("fancytree-drop-before fancytree-drop-over")
260
+ .addClass("fancytree-drop-after");
284
261
  markerAt = "bottom";
285
262
  break;
286
263
  default:
287
- instData.$dropMarker.removeClass("fancytree-drop-after fancytree-drop-before");
288
- instData.$dropMarker.addClass("fancytree-drop-over");
264
+ instData.$dropMarker.removeClass("fancytree-drop-after fancytree-drop-before")
265
+ .addClass("fancytree-drop-over");
289
266
  $target.addClass("fancytree-drop-target");
290
267
  markerOffsetX = 8;
291
268
  }
@@ -380,15 +357,15 @@ $.ui.fancytree.registerExtension(
380
357
  dnd = opts.dnd,
381
358
  ctx = this._makeHookContext(node, event, {otherNode: otherNode, ui: ui, draggable: draggable}),
382
359
  res = null,
383
- nodeTag = $(node.span);
360
+ $nodeTag = $(node.span);
384
361
 
385
362
  switch (eventName) {
386
363
  case "helper":
387
364
  // Only event and node argument is available
388
365
  $helper = $("<div class='fancytree-drag-helper'><span class='fancytree-drag-helper-img' /></div>")
389
- // .append($(event.target).closest("span.fancytree-node").find("span.fancytree-title").clone());
390
- .append(nodeTag.find("span.fancytree-title").clone());
391
- // issue 244: helper should be child of scrollParent
366
+ .css({zIndex: 3, position: "relative"}) // so it appears above ext-wide selection bar
367
+ .append($nodeTag.find("span.fancytree-title").clone());
368
+ // DT issue 244: helper should be child of scrollParent
392
369
  $("ul.fancytree-container", node.tree.$div).append($helper);
393
370
  // Attach node reference to helper object
394
371
  $helper.data("ftSourceNode", node);
@@ -396,6 +373,7 @@ $.ui.fancytree.registerExtension(
396
373
  // logMsg("helper.sourceNode=%o", $helper.data("ftSourceNode"));
397
374
  res = $helper;
398
375
  break;
376
+
399
377
  case "start":
400
378
  if( node.isStatusNode() ) {
401
379
  res = false;
@@ -407,12 +385,13 @@ $.ui.fancytree.registerExtension(
407
385
  //draggable._clear();
408
386
  // NOTE: the return value seems to be ignored (drag is not canceled, when false is returned)
409
387
  // TODO: call this._cancelDrag()?
410
- ui.helper.trigger("mouseup");
411
- ui.helper.hide();
388
+ ui.helper.trigger("mouseup")
389
+ .hide();
412
390
  } else {
413
- nodeTag.addClass("fancytree-drag-source");
391
+ $nodeTag.addClass("fancytree-drag-source");
414
392
  }
415
393
  break;
394
+
416
395
  case "enter":
417
396
  if(dnd.preventRecursiveMoves && node.isDescendantOf(otherNode)){
418
397
  r = false;
@@ -439,6 +418,7 @@ $.ui.fancytree.registerExtension(
439
418
  ui.helper.data("enterResponse", res);
440
419
  logMsg("helper.enterResponse: %o", res);
441
420
  break;
421
+
442
422
  case "over":
443
423
  enterResponse = ui.helper.data("enterResponse");
444
424
  hitMode = null;
@@ -450,11 +430,11 @@ $.ui.fancytree.registerExtension(
450
430
  hitMode = enterResponse;
451
431
  } else {
452
432
  // Calculate hitMode from relative cursor position.
453
- nodeOfs = nodeTag.offset();
433
+ nodeOfs = $nodeTag.offset();
454
434
  relPos = { x: event.pageX - nodeOfs.left,
455
435
  y: event.pageY - nodeOfs.top };
456
- relPos2 = { x: relPos.x / nodeTag.width(),
457
- y: relPos.y / nodeTag.height() };
436
+ relPos2 = { x: relPos.x / $nodeTag.width(),
437
+ y: relPos.y / $nodeTag.height() };
458
438
 
459
439
  if( enterResponse.after && relPos2.y > 0.75 ){
460
440
  hitMode = "after";
@@ -496,10 +476,11 @@ $.ui.fancytree.registerExtension(
496
476
  ctx.hitMode = hitMode;
497
477
  res = dnd.dragOver(node, ctx);
498
478
  }
499
- // issue 332
479
+ // DT issue 332
500
480
  // this._setDndStatus(otherNode, node, ui.helper, hitMode, res!==false);
501
481
  this._local._setDndStatus(otherNode, node, ui.helper, hitMode, res!==false && hitMode !== null);
502
482
  break;
483
+
503
484
  case "drop":
504
485
  hitMode = ui.helper.data("hitMode");
505
486
  if(hitMode && dnd.dragDrop){
@@ -507,6 +488,7 @@ $.ui.fancytree.registerExtension(
507
488
  dnd.dragDrop(node, ctx);
508
489
  }
509
490
  break;
491
+
510
492
  case "leave":
511
493
  // Cancel pending expand request
512
494
  node.scheduleAction("cancel");
@@ -517,14 +499,16 @@ $.ui.fancytree.registerExtension(
517
499
  dnd.dragLeave(node, ctx);
518
500
  }
519
501
  break;
502
+
520
503
  case "stop":
521
- nodeTag.removeClass("fancytree-drag-source");
504
+ $nodeTag.removeClass("fancytree-drag-source");
522
505
  if(dnd.dragStop){
523
506
  dnd.dragStop(node, ctx);
524
507
  }
525
508
  break;
509
+
526
510
  default:
527
- throw "Unsupported drag event: " + eventName;
511
+ $.error("Unsupported drag event: " + eventName);
528
512
  }
529
513
  return res;
530
514
  },
@@ -9,8 +9,8 @@
9
9
  * Released under the MIT license
10
10
  * https://github.com/mar10/fancytree/wiki/LicenseInfo
11
11
  *
12
- * @version 2.0.0-11
13
- * @date 2014-04-27T22:28
12
+ * @version 2.1.0
13
+ * @date 2014-05-29T16:44
14
14
  */
15
15
 
16
16
  ;(function($, window, document, undefined) {
@@ -231,7 +231,7 @@ $.ui.fancytree._FancytreeNodeClass.prototype.endEdit = function(){
231
231
  * [ext-edit] Check if any node in this tree in edit mode.
232
232
  *
233
233
  * @returns {FancytreeNode | null}
234
- * @lends Fancytree.prototype
234
+ * @alias Fancytree#isEditing
235
235
  * @requires jquery.fancytree.edit.js
236
236
  */
237
237
  $.ui.fancytree._FancytreeClass.prototype.isEditing = function(){
@@ -242,7 +242,7 @@ $.ui.fancytree._FancytreeClass.prototype.isEditing = function(){
242
242
  /**
243
243
  * [ext-edit] Check if this node is in edit mode.
244
244
  * @returns {Boolean} true if node is currently beeing edited
245
- * @lends FancytreeNode.prototype
245
+ * @alias FancytreeNode#isEditing
246
246
  * @requires jquery.fancytree.edit.js
247
247
  */
248
248
  $.ui.fancytree._FancytreeNodeClass.prototype.isEditing = function(){
@@ -273,10 +273,6 @@ $.ui.fancytree.registerExtension({
273
273
  // Local attributes
274
274
  currentNode: null,
275
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
276
  treeInit: function(ctx){
281
277
  this._super(ctx);
282
278
  this.$container.addClass("fancytree-ext-edit");
@@ -288,7 +284,7 @@ $.ui.fancytree.registerExtension({
288
284
  return false;
289
285
  }
290
286
  }
291
- this._super(ctx);
287
+ return this._super(ctx);
292
288
  },
293
289
  nodeDblclick: function(ctx) {
294
290
  if( $.inArray("dblclick", ctx.options.edit.triggerStart) >= 0 ){
@@ -9,8 +9,8 @@
9
9
  * Released under the MIT license
10
10
  * https://github.com/mar10/fancytree/wiki/LicenseInfo
11
11
  *
12
- * @version 2.0.0-11
13
- * @date 2014-04-27T22:28
12
+ * @version 2.1.0
13
+ * @date 2014-05-29T16:44
14
14
  */
15
15
 
16
16
  ;(function($, window, document, undefined) {
@@ -27,33 +27,12 @@ function _escapeRegex(str){
27
27
  return (str + "").replace(/([.?*+\^\$\[\]\\(){}|-])/g, "\\$1");
28
28
  }
29
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){
30
+ $.ui.fancytree._FancytreeClass.prototype._applyFilterImpl = function(filter, branchMode, leavesOnly){
53
31
  var match, re,
54
32
  count = 0,
55
- hideMode = this.options.filter.mode === "hide",
56
- leavesOnly = this.options.filter.leavesOnly;
33
+ hideMode = this.options.filter.mode === "hide";
34
+ // leavesOnly = !branchMode && this.options.filter.leavesOnly;
35
+ leavesOnly = !!leavesOnly && !branchMode;
57
36
 
58
37
  // Default to 'match title substring (not case sensitive)'
59
38
  if(typeof filter === "string"){
@@ -73,7 +52,6 @@ $.ui.fancytree._FancytreeClass.prototype.applyFilter = function(filter){
73
52
  }
74
53
  // Reset current filter
75
54
  this.visit(function(node){
76
- // node.hide = hideMode && true;
77
55
  delete node.match;
78
56
  delete node.subMatch;
79
57
  });
@@ -81,12 +59,16 @@ $.ui.fancytree._FancytreeClass.prototype.applyFilter = function(filter){
81
59
  this.visit(function(node){
82
60
  if ((!leavesOnly || node.children == null) && filter(node)) {
83
61
  count++;
84
- // node.hide = false;
85
62
  node.match = true;
86
63
  node.visitParents(function(p){
87
- // p.hide = false;
88
64
  p.subMatch = true;
89
65
  });
66
+ if( branchMode ) {
67
+ node.visit(function(p){
68
+ p.match = true;
69
+ });
70
+ return "skip";
71
+ }
90
72
  }
91
73
  });
92
74
  // Redraw
@@ -94,15 +76,45 @@ $.ui.fancytree._FancytreeClass.prototype.applyFilter = function(filter){
94
76
  return count;
95
77
  };
96
78
 
79
+ /**
80
+ * [ext-filter] Dimm or hide nodes.
81
+ *
82
+ * @param {function | string} filter
83
+ * @param {boolean} [leavesOnly=false]
84
+ * @returns {integer} count
85
+ * @alias Fancytree#filterNodes
86
+ * @requires jquery.fancytree.filter.js
87
+ */
88
+ $.ui.fancytree._FancytreeClass.prototype.filterNodes = function(filter, leavesOnly){
89
+ return this._applyFilterImpl(filter, false, leavesOnly);
90
+ };
91
+
92
+ $.ui.fancytree._FancytreeClass.prototype.applyFilter = function(filter){
93
+ this.warn("Fancytree.applyFilter() is deprecated since 2014-05-10. Use .filterNodes() instead.");
94
+ return this.filterNodes.apply(this, arguments);
95
+ };
96
+
97
+ /**
98
+ * [ext-filter] Dimm or hide whole branches.
99
+ *
100
+ * @param {function | string} filter
101
+ * @returns {integer} count
102
+ * @alias Fancytree#filterBranches
103
+ * @requires jquery.fancytree.filter.js
104
+ */
105
+ $.ui.fancytree._FancytreeClass.prototype.filterBranches = function(filter){
106
+ return this._applyFilterImpl(filter, true, null);
107
+ };
108
+
109
+
97
110
  /**
98
111
  * [ext-filter] Reset the filter.
99
112
  *
100
- * @alias Fancytree#applyFilter
113
+ * @alias Fancytree#clearFilter
101
114
  * @requires jquery.fancytree.filter.js
102
115
  */
103
116
  $.ui.fancytree._FancytreeClass.prototype.clearFilter = function(){
104
117
  this.visit(function(node){
105
- // delete node.hide;
106
118
  delete node.match;
107
119
  delete node.subMatch;
108
120
  });
@@ -117,22 +129,14 @@ $.ui.fancytree._FancytreeClass.prototype.clearFilter = function(){
117
129
  */
118
130
  $.ui.fancytree.registerExtension({
119
131
  name: "filter",
120
- version: "0.0.2",
132
+ version: "0.2.0",
121
133
  // Default options for this extension.
122
134
  options: {
123
- mode: "dimm",
124
- leavesOnly: false
135
+ mode: "dimm"
136
+ // leavesOnly: false
125
137
  },
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
138
  treeInit: function(ctx){
131
139
  this._super(ctx);
132
- // ctx.tree.filter = false;
133
- },
134
- treeDestroy: function(ctx){
135
- this._super(ctx);
136
140
  },
137
141
  nodeRenderStatus: function(ctx) {
138
142
  // Set classes for current status
@@ -142,31 +146,15 @@ $.ui.fancytree.registerExtension({
142
146
  $span = $(node[tree.statusClassPropName]);
143
147
 
144
148
  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){
149
+ // nothing to do, if node was not yet rendered
150
+ if( !$span.length || !tree.enableFilter ) {
150
151
  return res;
151
152
  }
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
- // }
153
+ $span
154
+ .toggleClass("fancytree-match", !!node.match)
155
+ .toggleClass("fancytree-submatch", !!node.subMatch)
156
+ .toggleClass("fancytree-hide", !(node.match || node.subMatch));
157
+
170
158
  return res;
171
159
  }
172
160
  });