jqtree-rails 0.1.4.3 → 0.1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/build +3 -0
- data/lib/jqtree/rails/version.rb +2 -2
- data/vendor/assets/javascripts/tree.jquery.js +251 -168
- data/vendor/assets/stylesheets/jqtree.css +6 -5
- metadata +8 -7
data/build
ADDED
data/lib/jqtree/rails/version.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
// Generated by CoffeeScript 1.
|
1
|
+
// Generated by CoffeeScript 1.6.1
|
2
2
|
|
3
3
|
/*
|
4
|
-
Copyright
|
4
|
+
Copyright 2013 Marco Braak
|
5
5
|
|
6
6
|
Licensed under the Apache License, Version 2.0 (the "License");
|
7
7
|
you may not use this file except in compliance with the License.
|
@@ -18,7 +18,7 @@ limitations under the License.
|
|
18
18
|
|
19
19
|
|
20
20
|
(function() {
|
21
|
-
var $, BorderDropHint, DragAndDropHandler, DragElement, FolderElement, GhostDropHint, JqTreeWidget, MouseWidget, Node, NodeElement, Position, SaveStateHandler, ScrollHandler, SelectNodeHandler, SimpleWidget, TRIANGLE_DOWN, TRIANGLE_RIGHT,
|
21
|
+
var $, BorderDropHint, DragAndDropHandler, DragElement, FolderElement, GhostDropHint, JqTreeWidget, MouseWidget, Node, NodeElement, Position, SaveStateHandler, ScrollHandler, SelectNodeHandler, SimpleWidget, TRIANGLE_DOWN, TRIANGLE_RIGHT, html_escape, indexOf, json_escapable, json_meta, json_quote, json_str, _indexOf,
|
22
22
|
__slice = [].slice,
|
23
23
|
__hasProp = {}.hasOwnProperty,
|
24
24
|
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
@@ -230,12 +230,16 @@ limitations under the License.
|
|
230
230
|
return null;
|
231
231
|
};
|
232
232
|
|
233
|
+
MouseWidget.prototype.setMouseDelay = function(mouse_delay) {
|
234
|
+
return this.mouse_delay = mouse_delay;
|
235
|
+
};
|
236
|
+
|
233
237
|
return MouseWidget;
|
234
238
|
|
235
239
|
})(SimpleWidget);
|
236
240
|
|
237
241
|
/*
|
238
|
-
Copyright
|
242
|
+
Copyright 2013 Marco Braak
|
239
243
|
|
240
244
|
Licensed under the Apache License, Version 2.0 (the "License");
|
241
245
|
you may not use this file except in compliance with the License.
|
@@ -255,23 +259,29 @@ limitations under the License.
|
|
255
259
|
|
256
260
|
$ = this.jQuery;
|
257
261
|
|
258
|
-
|
262
|
+
_indexOf = function(array, item) {
|
259
263
|
var i, value, _i, _len;
|
264
|
+
for (i = _i = 0, _len = array.length; _i < _len; i = ++_i) {
|
265
|
+
value = array[i];
|
266
|
+
if (value === item) {
|
267
|
+
return i;
|
268
|
+
}
|
269
|
+
}
|
270
|
+
return -1;
|
271
|
+
};
|
272
|
+
|
273
|
+
indexOf = function(array, item) {
|
260
274
|
if (array.indexOf) {
|
261
275
|
return array.indexOf(item);
|
262
276
|
} else {
|
263
|
-
|
264
|
-
value = array[i];
|
265
|
-
if (value === item) {
|
266
|
-
return i;
|
267
|
-
}
|
268
|
-
}
|
269
|
-
return -1;
|
277
|
+
return _indexOf(array, item);
|
270
278
|
}
|
271
279
|
};
|
272
280
|
|
273
281
|
this.Tree.indexOf = indexOf;
|
274
282
|
|
283
|
+
this.Tree._indexOf = _indexOf;
|
284
|
+
|
275
285
|
if (!((this.JSON != null) && (this.JSON.stringify != null) && typeof this.JSON.stringify === 'function')) {
|
276
286
|
json_escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
|
277
287
|
json_meta = {
|
@@ -333,7 +343,7 @@ limitations under the License.
|
|
333
343
|
return (partial.length === 0 ? '{}' : '{' + partial.join(',') + '}');
|
334
344
|
}
|
335
345
|
};
|
336
|
-
if (
|
346
|
+
if (this.JSON == null) {
|
337
347
|
this.JSON = {};
|
338
348
|
}
|
339
349
|
this.JSON.stringify = function(value) {
|
@@ -376,10 +386,21 @@ limitations under the License.
|
|
376
386
|
|
377
387
|
Node = (function() {
|
378
388
|
|
379
|
-
function Node(o) {
|
389
|
+
function Node(o, is_root, node_class) {
|
390
|
+
if (is_root == null) {
|
391
|
+
is_root = false;
|
392
|
+
}
|
393
|
+
if (node_class == null) {
|
394
|
+
node_class = Node;
|
395
|
+
}
|
380
396
|
this.setData(o);
|
381
397
|
this.children = [];
|
382
398
|
this.parent = null;
|
399
|
+
if (is_root) {
|
400
|
+
this.id_mapping = {};
|
401
|
+
this.tree = this;
|
402
|
+
this.node_class = node_class;
|
403
|
+
}
|
383
404
|
}
|
384
405
|
|
385
406
|
Node.prototype.setData = function(o) {
|
@@ -413,7 +434,7 @@ limitations under the License.
|
|
413
434
|
var child, node, _i, _len;
|
414
435
|
for (_i = 0, _len = children_data.length; _i < _len; _i++) {
|
415
436
|
child = children_data[_i];
|
416
|
-
node = new
|
437
|
+
node = new _this.tree.node_class('');
|
417
438
|
node.initFromData(child);
|
418
439
|
_this.addChild(node);
|
419
440
|
}
|
@@ -424,30 +445,30 @@ limitations under the License.
|
|
424
445
|
};
|
425
446
|
|
426
447
|
/*
|
427
|
-
|
448
|
+
Create tree from data.
|
428
449
|
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
450
|
+
Structure of data is:
|
451
|
+
[
|
452
|
+
{
|
453
|
+
label: 'node1',
|
454
|
+
children: [
|
455
|
+
{ label: 'child1' },
|
456
|
+
{ label: 'child2' }
|
457
|
+
]
|
458
|
+
},
|
459
|
+
{
|
460
|
+
label: 'node2'
|
461
|
+
}
|
462
|
+
]
|
442
463
|
*/
|
443
464
|
|
444
465
|
|
445
466
|
Node.prototype.loadFromData = function(data) {
|
446
467
|
var node, o, _i, _len;
|
447
|
-
this.
|
468
|
+
this.removeChildren();
|
448
469
|
for (_i = 0, _len = data.length; _i < _len; _i++) {
|
449
470
|
o = data[_i];
|
450
|
-
node = new
|
471
|
+
node = new this.tree.node_class(o);
|
451
472
|
this.addChild(node);
|
452
473
|
if (typeof o === 'object' && o.children) {
|
453
474
|
node.loadFromData(o.children);
|
@@ -457,11 +478,11 @@ limitations under the License.
|
|
457
478
|
};
|
458
479
|
|
459
480
|
/*
|
460
|
-
|
481
|
+
Add child.
|
461
482
|
|
462
|
-
|
463
|
-
|
464
|
-
|
483
|
+
tree.addChild(
|
484
|
+
new Node('child1')
|
485
|
+
);
|
465
486
|
*/
|
466
487
|
|
467
488
|
|
@@ -471,12 +492,12 @@ limitations under the License.
|
|
471
492
|
};
|
472
493
|
|
473
494
|
/*
|
474
|
-
|
495
|
+
Add child at position. Index starts at 0.
|
475
496
|
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
497
|
+
tree.addChildAtPosition(
|
498
|
+
new Node('abc'),
|
499
|
+
1
|
500
|
+
);
|
480
501
|
*/
|
481
502
|
|
482
503
|
|
@@ -492,26 +513,26 @@ limitations under the License.
|
|
492
513
|
};
|
493
514
|
|
494
515
|
/*
|
495
|
-
|
516
|
+
Remove child. This also removes the children of the node.
|
496
517
|
|
497
|
-
|
518
|
+
tree.removeChild(tree.children[0]);
|
498
519
|
*/
|
499
520
|
|
500
521
|
|
501
522
|
Node.prototype.removeChild = function(node) {
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
523
|
+
node.removeChildren();
|
524
|
+
return this._removeChild(node);
|
525
|
+
};
|
526
|
+
|
527
|
+
Node.prototype._removeChild = function(node) {
|
507
528
|
this.children.splice(this.getChildIndex(node), 1);
|
508
529
|
return this.tree.removeNodeFromIndex(node);
|
509
530
|
};
|
510
531
|
|
511
532
|
/*
|
512
|
-
|
533
|
+
Get child index.
|
513
534
|
|
514
|
-
|
535
|
+
var index = getChildIndex(node);
|
515
536
|
*/
|
516
537
|
|
517
538
|
|
@@ -520,11 +541,11 @@ limitations under the License.
|
|
520
541
|
};
|
521
542
|
|
522
543
|
/*
|
523
|
-
|
544
|
+
Does the tree have children?
|
524
545
|
|
525
|
-
|
526
|
-
|
527
|
-
|
546
|
+
if (tree.hasChildren()) {
|
547
|
+
//
|
548
|
+
}
|
528
549
|
*/
|
529
550
|
|
530
551
|
|
@@ -537,20 +558,20 @@ limitations under the License.
|
|
537
558
|
};
|
538
559
|
|
539
560
|
/*
|
540
|
-
|
561
|
+
Iterate over all the nodes in the tree.
|
541
562
|
|
542
|
-
|
563
|
+
Calls callback with (node, level).
|
543
564
|
|
544
|
-
|
565
|
+
The callback must return true to continue the iteration on current node.
|
545
566
|
|
546
|
-
|
547
|
-
|
548
|
-
|
567
|
+
tree.iterate(
|
568
|
+
function(node, level) {
|
569
|
+
console.log(node.name);
|
549
570
|
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
571
|
+
// stop iteration after level 2
|
572
|
+
return (level <= 2);
|
573
|
+
}
|
574
|
+
);
|
554
575
|
*/
|
555
576
|
|
556
577
|
|
@@ -576,12 +597,12 @@ limitations under the License.
|
|
576
597
|
};
|
577
598
|
|
578
599
|
/*
|
579
|
-
|
600
|
+
Move node relative to another node.
|
580
601
|
|
581
|
-
|
602
|
+
Argument position: Position.BEFORE, Position.AFTER or Position.Inside
|
582
603
|
|
583
|
-
|
584
|
-
|
604
|
+
// move node1 after node2
|
605
|
+
tree.moveNode(node1, node2, Position.AFTER);
|
585
606
|
*/
|
586
607
|
|
587
608
|
|
@@ -589,7 +610,7 @@ limitations under the License.
|
|
589
610
|
if (moved_node.isParentOf(target_node)) {
|
590
611
|
return;
|
591
612
|
}
|
592
|
-
moved_node.parent.
|
613
|
+
moved_node.parent._removeChild(moved_node);
|
593
614
|
if (position === Position.AFTER) {
|
594
615
|
return target_node.parent.addChildAtPosition(moved_node, target_node.parent.getChildIndex(target_node) + 1);
|
595
616
|
} else if (position === Position.BEFORE) {
|
@@ -600,7 +621,7 @@ limitations under the License.
|
|
600
621
|
};
|
601
622
|
|
602
623
|
/*
|
603
|
-
|
624
|
+
Get the tree as data.
|
604
625
|
*/
|
605
626
|
|
606
627
|
|
@@ -648,7 +669,7 @@ limitations under the License.
|
|
648
669
|
if (!this.parent) {
|
649
670
|
return null;
|
650
671
|
} else {
|
651
|
-
node = new
|
672
|
+
node = new this.tree.node_class(node_info);
|
652
673
|
child_index = this.parent.getChildIndex(this);
|
653
674
|
this.parent.addChildAtPosition(node, child_index + 1);
|
654
675
|
return node;
|
@@ -660,9 +681,10 @@ limitations under the License.
|
|
660
681
|
if (!this.parent) {
|
661
682
|
return null;
|
662
683
|
} else {
|
663
|
-
node = new
|
684
|
+
node = new this.tree.node_class(node_info);
|
664
685
|
child_index = this.parent.getChildIndex(this);
|
665
|
-
|
686
|
+
this.parent.addChildAtPosition(node, child_index);
|
687
|
+
return node;
|
666
688
|
}
|
667
689
|
};
|
668
690
|
|
@@ -671,7 +693,7 @@ limitations under the License.
|
|
671
693
|
if (!this.parent) {
|
672
694
|
return null;
|
673
695
|
} else {
|
674
|
-
new_parent = new
|
696
|
+
new_parent = new this.tree.node_class(node_info);
|
675
697
|
new_parent._setParent(this.tree);
|
676
698
|
original_parent = this.parent;
|
677
699
|
_ref = original_parent.children;
|
@@ -694,14 +716,14 @@ limitations under the License.
|
|
694
716
|
|
695
717
|
Node.prototype.append = function(node_info) {
|
696
718
|
var node;
|
697
|
-
node = new
|
719
|
+
node = new this.tree.node_class(node_info);
|
698
720
|
this.addChild(node);
|
699
721
|
return node;
|
700
722
|
};
|
701
723
|
|
702
724
|
Node.prototype.prepend = function(node_info) {
|
703
725
|
var node;
|
704
|
-
node = new
|
726
|
+
node = new this.tree.node_class(node_info);
|
705
727
|
this.addChildAtPosition(node, 0);
|
706
728
|
return node;
|
707
729
|
};
|
@@ -718,41 +740,45 @@ limitations under the License.
|
|
718
740
|
return false;
|
719
741
|
};
|
720
742
|
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
this.id_mapping = {};
|
732
|
-
this.tree = this;
|
733
|
-
}
|
743
|
+
Node.prototype.getLevel = function() {
|
744
|
+
var level, node;
|
745
|
+
level = 0;
|
746
|
+
node = this;
|
747
|
+
while (node.parent) {
|
748
|
+
level += 1;
|
749
|
+
node = node.parent;
|
750
|
+
}
|
751
|
+
return level;
|
752
|
+
};
|
734
753
|
|
735
|
-
|
754
|
+
Node.prototype.getNodeById = function(node_id) {
|
736
755
|
return this.id_mapping[node_id];
|
737
756
|
};
|
738
757
|
|
739
|
-
|
758
|
+
Node.prototype.addNodeToIndex = function(node) {
|
740
759
|
if (node.id) {
|
741
760
|
return this.id_mapping[node.id] = node;
|
742
761
|
}
|
743
762
|
};
|
744
763
|
|
745
|
-
|
764
|
+
Node.prototype.removeNodeFromIndex = function(node) {
|
746
765
|
if (node.id) {
|
747
766
|
return delete this.id_mapping[node.id];
|
748
767
|
}
|
749
768
|
};
|
750
769
|
|
751
|
-
|
770
|
+
Node.prototype.removeChildren = function() {
|
771
|
+
var _this = this;
|
772
|
+
this.iterate(function(child) {
|
773
|
+
_this.tree.removeNodeFromIndex(child);
|
774
|
+
return true;
|
775
|
+
});
|
776
|
+
return this.children = [];
|
777
|
+
};
|
752
778
|
|
753
|
-
|
779
|
+
return Node;
|
754
780
|
|
755
|
-
|
781
|
+
})();
|
756
782
|
|
757
783
|
this.Tree.Node = Node;
|
758
784
|
|
@@ -780,9 +806,11 @@ limitations under the License.
|
|
780
806
|
onIsMoveHandle: null,
|
781
807
|
onCanMove: null,
|
782
808
|
onCanMoveTo: null,
|
809
|
+
onLoadFailed: null,
|
783
810
|
autoEscape: true,
|
784
811
|
dataUrl: null,
|
785
|
-
slide: true
|
812
|
+
slide: true,
|
813
|
+
nodeClass: Node
|
786
814
|
};
|
787
815
|
|
788
816
|
JqTreeWidget.prototype.toggle = function(node, slide) {
|
@@ -813,24 +841,42 @@ limitations under the License.
|
|
813
841
|
};
|
814
842
|
|
815
843
|
JqTreeWidget.prototype.loadData = function(data, parent_node) {
|
816
|
-
|
844
|
+
this._loadData(data, parent_node);
|
845
|
+
if (!parent_node) {
|
846
|
+
return this.selected_node = null;
|
847
|
+
}
|
848
|
+
};
|
849
|
+
|
850
|
+
JqTreeWidget.prototype.loadDataFromUrl = function(url, parent_node, on_finished) {
|
851
|
+
if ($.type(url) !== 'string') {
|
852
|
+
parent_node = url;
|
853
|
+
on_finished = parent_node;
|
854
|
+
url = null;
|
855
|
+
on_finished = null;
|
856
|
+
}
|
857
|
+
this._loadDataFromUrl(url, parent_node, on_finished);
|
858
|
+
if (!parent_node) {
|
859
|
+
return this.selected_node = null;
|
860
|
+
}
|
817
861
|
};
|
818
862
|
|
819
|
-
JqTreeWidget.prototype.
|
820
|
-
var $
|
863
|
+
JqTreeWidget.prototype._loadDataFromUrl = function(url_info, parent_node, on_finished) {
|
864
|
+
var $el, addLoadingClass, parseUrlInfo, removeLoadingClass,
|
821
865
|
_this = this;
|
822
|
-
$
|
866
|
+
$el = null;
|
823
867
|
addLoadingClass = function() {
|
824
868
|
var folder_element;
|
825
|
-
if (parent_node) {
|
869
|
+
if (!parent_node) {
|
870
|
+
$el = _this.element;
|
871
|
+
} else {
|
826
872
|
folder_element = new FolderElement(parent_node, _this);
|
827
|
-
$
|
828
|
-
return $li.addClass('jqtree-loading');
|
873
|
+
$el = folder_element.getLi();
|
829
874
|
}
|
875
|
+
return $el.addClass('jqtree-loading');
|
830
876
|
};
|
831
877
|
removeLoadingClass = function() {
|
832
|
-
if ($
|
833
|
-
return $
|
878
|
+
if ($el) {
|
879
|
+
return $el.removeClass('jqtree-loading');
|
834
880
|
}
|
835
881
|
};
|
836
882
|
parseUrlInfo = function() {
|
@@ -844,6 +890,9 @@ limitations under the License.
|
|
844
890
|
}
|
845
891
|
};
|
846
892
|
addLoadingClass();
|
893
|
+
if (!url_info) {
|
894
|
+
url_info = this._getDataUrlInfo(parent_node);
|
895
|
+
}
|
847
896
|
parseUrlInfo();
|
848
897
|
return $.ajax({
|
849
898
|
url: url_info.url,
|
@@ -860,29 +909,31 @@ limitations under the License.
|
|
860
909
|
}
|
861
910
|
removeLoadingClass();
|
862
911
|
_this._loadData(data, parent_node);
|
863
|
-
if (on_finished) {
|
912
|
+
if (on_finished && $.isFunction(on_finished)) {
|
864
913
|
return on_finished();
|
865
914
|
}
|
915
|
+
},
|
916
|
+
error: function(response) {
|
917
|
+
removeLoadingClass();
|
918
|
+
if (_this.options.onLoadFailed) {
|
919
|
+
return _this.options.onLoadFailed(response);
|
920
|
+
}
|
866
921
|
}
|
867
922
|
});
|
868
923
|
};
|
869
924
|
|
870
925
|
JqTreeWidget.prototype._loadData = function(data, parent_node) {
|
871
|
-
var child, subtree, _i, _len, _ref;
|
872
926
|
this._triggerEvent('tree.load_data', {
|
873
927
|
tree_data: data
|
874
928
|
});
|
875
929
|
if (!parent_node) {
|
876
|
-
this._initTree(data);
|
930
|
+
this._initTree(data, false, this.options.nodeClass);
|
877
931
|
} else {
|
878
|
-
|
879
|
-
|
880
|
-
subtree.loadFromData(data);
|
881
|
-
_ref = subtree.children;
|
882
|
-
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
883
|
-
child = _ref[_i];
|
884
|
-
parent_node.addChild(child);
|
932
|
+
if (this.selected_node && parent_node.isParentOf(this.selected_node)) {
|
933
|
+
this.selected_node = null;
|
885
934
|
}
|
935
|
+
parent_node.loadFromData(data);
|
936
|
+
parent_node.load_on_demand = false;
|
886
937
|
this._refreshElements(parent_node.parent);
|
887
938
|
}
|
888
939
|
if (this.is_dragging) {
|
@@ -938,8 +989,7 @@ limitations under the License.
|
|
938
989
|
if (slide == null) {
|
939
990
|
slide = true;
|
940
991
|
}
|
941
|
-
|
942
|
-
return this.loadDataFromUrl(this._getDataUrlInfo(node), node, function() {
|
992
|
+
return this._loadDataFromUrl(null, node, function() {
|
943
993
|
return _this._openNode(node, slide, on_finished);
|
944
994
|
});
|
945
995
|
};
|
@@ -994,7 +1044,7 @@ limitations under the License.
|
|
994
1044
|
return true;
|
995
1045
|
} else {
|
996
1046
|
result = true;
|
997
|
-
iterate(function(child) {
|
1047
|
+
_this.tree.iterate(function(child) {
|
998
1048
|
if (node === child) {
|
999
1049
|
result = true;
|
1000
1050
|
return false;
|
@@ -1080,9 +1130,9 @@ limitations under the License.
|
|
1080
1130
|
|
1081
1131
|
JqTreeWidget.prototype._initData = function() {
|
1082
1132
|
if (this.options.data) {
|
1083
|
-
return this.
|
1133
|
+
return this._loadData(this.options.data);
|
1084
1134
|
} else {
|
1085
|
-
return this.
|
1135
|
+
return this._loadDataFromUrl(this._getDataUrlInfo());
|
1086
1136
|
}
|
1087
1137
|
};
|
1088
1138
|
|
@@ -1108,11 +1158,10 @@ limitations under the License.
|
|
1108
1158
|
};
|
1109
1159
|
|
1110
1160
|
JqTreeWidget.prototype._initTree = function(data) {
|
1111
|
-
this.tree = new
|
1161
|
+
this.tree = new this.options.nodeClass(null, true, this.options.nodeClass);
|
1112
1162
|
this.tree.loadFromData(data);
|
1113
1163
|
this._openNodes();
|
1114
1164
|
this._refreshElements();
|
1115
|
-
this.select_node_handler.selectCurrentNode();
|
1116
1165
|
return this._triggerEvent('tree.init');
|
1117
1166
|
};
|
1118
1167
|
|
@@ -1131,7 +1180,9 @@ limitations under the License.
|
|
1131
1180
|
max_level = parseInt(this.options.autoOpen);
|
1132
1181
|
}
|
1133
1182
|
return this.tree.iterate(function(node, level) {
|
1134
|
-
node.
|
1183
|
+
if (node.hasChildren()) {
|
1184
|
+
node.is_open = true;
|
1185
|
+
}
|
1135
1186
|
return level !== max_level;
|
1136
1187
|
});
|
1137
1188
|
};
|
@@ -1171,9 +1222,14 @@ limitations under the License.
|
|
1171
1222
|
return $li;
|
1172
1223
|
};
|
1173
1224
|
createNodeLi = function(node) {
|
1174
|
-
var escaped_name;
|
1225
|
+
var class_string, escaped_name, li_classes;
|
1226
|
+
li_classes = ['jqtree_common'];
|
1227
|
+
if (node === _this.selected_node) {
|
1228
|
+
li_classes.push('jqtree-selected');
|
1229
|
+
}
|
1230
|
+
class_string = li_classes.join(' ');
|
1175
1231
|
escaped_name = escapeIfNecessary(node.name);
|
1176
|
-
return $("<li class=\"
|
1232
|
+
return $("<li class=\"" + class_string + "\"><div class=\"jqtree-element jqtree_common\"><span class=\"jqtree-title jqtree_common\">" + escaped_name + "</span></div></li>");
|
1177
1233
|
};
|
1178
1234
|
createFolderLi = function(node) {
|
1179
1235
|
var button_char, button_classes, escaped_name, folder_classes, getButtonClasses, getFolderClasses;
|
@@ -1191,6 +1247,9 @@ limitations under the License.
|
|
1191
1247
|
if (!node.is_open) {
|
1192
1248
|
classes.push('jqtree-closed');
|
1193
1249
|
}
|
1250
|
+
if (node === _this.selected_node) {
|
1251
|
+
classes.push('jqtree-selected');
|
1252
|
+
}
|
1194
1253
|
return classes.join(' ');
|
1195
1254
|
};
|
1196
1255
|
button_classes = getButtonClasses();
|
@@ -1201,7 +1260,7 @@ limitations under the License.
|
|
1201
1260
|
} else {
|
1202
1261
|
button_char = TRIANGLE_RIGHT;
|
1203
1262
|
}
|
1204
|
-
return $("<li class=\"jqtree_common " + folder_classes + "\"><div><a class=\"jqtree_common " + button_classes + "\">" + button_char + "</a><span class=\"jqtree_common jqtree-title\">" + escaped_name + "</span></div></li>");
|
1263
|
+
return $("<li class=\"jqtree_common " + folder_classes + "\"><div class=\"jqtree-element jqtree_common\"><a class=\"jqtree_common " + button_classes + "\">" + button_char + "</a><span class=\"jqtree_common jqtree-title\">" + escaped_name + "</span></div></li>");
|
1205
1264
|
};
|
1206
1265
|
doCreateDomElements = function($element, children, is_root_node, is_open) {
|
1207
1266
|
var $li, $ul, child, _i, _len;
|
@@ -1235,28 +1294,28 @@ limitations under the License.
|
|
1235
1294
|
};
|
1236
1295
|
|
1237
1296
|
JqTreeWidget.prototype._click = function(e) {
|
1238
|
-
var $button, $
|
1297
|
+
var $button, $el, $target, node;
|
1239
1298
|
if (e.ctrlKey) {
|
1240
1299
|
return;
|
1241
1300
|
}
|
1242
1301
|
$target = $(e.target);
|
1243
|
-
$
|
1244
|
-
if ($
|
1245
|
-
node = this._getNode($
|
1302
|
+
$button = $target.closest('.jqtree-toggler');
|
1303
|
+
if ($button.length) {
|
1304
|
+
node = this._getNode($button);
|
1246
1305
|
if (node) {
|
1247
|
-
this.
|
1248
|
-
|
1249
|
-
|
1250
|
-
return this.selectNode(node);
|
1306
|
+
this.toggle(node, this.options.slide);
|
1307
|
+
e.preventDefault();
|
1308
|
+
return e.stopPropagation();
|
1251
1309
|
}
|
1252
1310
|
} else {
|
1253
|
-
$
|
1254
|
-
if ($
|
1255
|
-
node = this._getNode($
|
1311
|
+
$el = $target.closest('.jqtree-element');
|
1312
|
+
if ($el.length) {
|
1313
|
+
node = this._getNode($el);
|
1256
1314
|
if (node) {
|
1257
|
-
this.
|
1258
|
-
|
1259
|
-
|
1315
|
+
this._triggerEvent('tree.click', {
|
1316
|
+
node: node
|
1317
|
+
});
|
1318
|
+
return this.select_node_handler.selectNode(node, true);
|
1260
1319
|
}
|
1261
1320
|
}
|
1262
1321
|
}
|
@@ -1292,7 +1351,7 @@ limitations under the License.
|
|
1292
1351
|
|
1293
1352
|
JqTreeWidget.prototype._contextmenu = function(e) {
|
1294
1353
|
var $div, node;
|
1295
|
-
$div = $(e.target).closest('ul.jqtree-tree
|
1354
|
+
$div = $(e.target).closest('ul.jqtree-tree .jqtree-element');
|
1296
1355
|
if ($div.length) {
|
1297
1356
|
node = this._getNode($div);
|
1298
1357
|
if (node) {
|
@@ -1340,9 +1399,9 @@ limitations under the License.
|
|
1340
1399
|
}
|
1341
1400
|
};
|
1342
1401
|
|
1343
|
-
JqTreeWidget.prototype._mouseStop = function() {
|
1402
|
+
JqTreeWidget.prototype._mouseStop = function(e) {
|
1344
1403
|
if (this.options.dragAndDrop) {
|
1345
|
-
return this.dnd_handler.mouseStop();
|
1404
|
+
return this.dnd_handler.mouseStop(e);
|
1346
1405
|
} else {
|
1347
1406
|
return false;
|
1348
1407
|
}
|
@@ -1416,7 +1475,7 @@ limitations under the License.
|
|
1416
1475
|
|
1417
1476
|
function BorderDropHint($element) {
|
1418
1477
|
var $div, width;
|
1419
|
-
$div = $element.children('
|
1478
|
+
$div = $element.children('.jqtree-element');
|
1420
1479
|
width = $element.width() - 4;
|
1421
1480
|
this.$hint = $('<span class="jqtree-border"></span>');
|
1422
1481
|
$div.append(this.$hint);
|
@@ -1451,7 +1510,7 @@ limitations under the License.
|
|
1451
1510
|
};
|
1452
1511
|
|
1453
1512
|
NodeElement.prototype.getSpan = function() {
|
1454
|
-
return this.$element.children('
|
1513
|
+
return this.$element.children('.jqtree-element').find('span.jqtree-title');
|
1455
1514
|
};
|
1456
1515
|
|
1457
1516
|
NodeElement.prototype.getLi = function() {
|
@@ -1542,7 +1601,7 @@ limitations under the License.
|
|
1542
1601
|
};
|
1543
1602
|
|
1544
1603
|
FolderElement.prototype.getButton = function() {
|
1545
|
-
return this.$element.children('
|
1604
|
+
return this.$element.children('.jqtree-element').find('a.jqtree-toggler');
|
1546
1605
|
};
|
1547
1606
|
|
1548
1607
|
FolderElement.prototype.addDropHint = function(position) {
|
@@ -1594,6 +1653,7 @@ limitations under the License.
|
|
1594
1653
|
} else if (typeof localStorage !== "undefined" && localStorage !== null) {
|
1595
1654
|
return localStorage.setItem(this.getCookieName(), this.getState());
|
1596
1655
|
} else if ($.cookie) {
|
1656
|
+
$.cookie.raw = true;
|
1597
1657
|
return $.cookie(this.getCookieName(), this.getState(), {
|
1598
1658
|
path: '/'
|
1599
1659
|
});
|
@@ -1617,9 +1677,8 @@ limitations under the License.
|
|
1617
1677
|
} else if (typeof localStorage !== "undefined" && localStorage !== null) {
|
1618
1678
|
return localStorage.getItem(this.getCookieName());
|
1619
1679
|
} else if ($.cookie) {
|
1620
|
-
|
1621
|
-
|
1622
|
-
});
|
1680
|
+
$.cookie.raw = true;
|
1681
|
+
return $.cookie(this.getCookieName());
|
1623
1682
|
} else {
|
1624
1683
|
return null;
|
1625
1684
|
}
|
@@ -1682,29 +1741,54 @@ limitations under the License.
|
|
1682
1741
|
this.tree_widget = tree_widget;
|
1683
1742
|
}
|
1684
1743
|
|
1685
|
-
SelectNodeHandler.prototype.selectNode = function(node) {
|
1686
|
-
var canSelect, parent,
|
1744
|
+
SelectNodeHandler.prototype.selectNode = function(node, must_toggle) {
|
1745
|
+
var canSelect, mustToggle, node_element, parent, previous_node,
|
1687
1746
|
_this = this;
|
1747
|
+
if (must_toggle == null) {
|
1748
|
+
must_toggle = false;
|
1749
|
+
}
|
1688
1750
|
canSelect = function() {
|
1689
1751
|
if (!_this.tree_widget.options.onCanSelectNode) {
|
1690
1752
|
return true;
|
1691
1753
|
}
|
1692
1754
|
return _this.tree_widget.options.onCanSelectNode(node);
|
1693
1755
|
};
|
1756
|
+
mustToggle = function(previous_node, node) {
|
1757
|
+
if (must_toggle && previous_node && node) {
|
1758
|
+
if (node.id) {
|
1759
|
+
return node.id === previous_node.id;
|
1760
|
+
} else {
|
1761
|
+
return node.element === previous_node.element;
|
1762
|
+
}
|
1763
|
+
} else {
|
1764
|
+
return false;
|
1765
|
+
}
|
1766
|
+
};
|
1694
1767
|
if (canSelect()) {
|
1695
1768
|
if (this.tree_widget.selected_node) {
|
1696
|
-
this.tree_widget.
|
1769
|
+
previous_node = this.tree_widget.selected_node;
|
1770
|
+
this.tree_widget._getNodeElementForNode(previous_node).deselect();
|
1697
1771
|
this.tree_widget.selected_node = null;
|
1772
|
+
} else {
|
1773
|
+
previous_node = null;
|
1698
1774
|
}
|
1699
1775
|
if (node) {
|
1700
|
-
this.tree_widget._getNodeElementForNode(node)
|
1701
|
-
|
1702
|
-
|
1703
|
-
|
1704
|
-
|
1705
|
-
|
1706
|
-
|
1707
|
-
|
1776
|
+
node_element = this.tree_widget._getNodeElementForNode(node);
|
1777
|
+
if (mustToggle(previous_node, node)) {
|
1778
|
+
node_element.deselect();
|
1779
|
+
this.tree_widget._triggerEvent('tree.select', {
|
1780
|
+
node: null
|
1781
|
+
});
|
1782
|
+
} else {
|
1783
|
+
node_element.select();
|
1784
|
+
this.tree_widget.selected_node = node;
|
1785
|
+
this.tree_widget._triggerEvent('tree.select', {
|
1786
|
+
node: node
|
1787
|
+
});
|
1788
|
+
parent = this.tree_widget.selected_node.parent;
|
1789
|
+
if (!parent.is_open) {
|
1790
|
+
this.tree_widget.openNode(parent, false);
|
1791
|
+
}
|
1708
1792
|
}
|
1709
1793
|
}
|
1710
1794
|
if (this.tree_widget.options.saveState) {
|
@@ -1777,17 +1861,15 @@ limitations under the License.
|
|
1777
1861
|
this.removeDropHint();
|
1778
1862
|
this.removeHover();
|
1779
1863
|
this.stopOpenFolderTimer();
|
1780
|
-
} else {
|
1781
|
-
|
1782
|
-
|
1783
|
-
this.updateDropHint();
|
1784
|
-
}
|
1864
|
+
} else if (this.hovered_area !== area) {
|
1865
|
+
this.hovered_area = area;
|
1866
|
+
this.updateDropHint();
|
1785
1867
|
}
|
1786
1868
|
return true;
|
1787
1869
|
};
|
1788
1870
|
|
1789
|
-
DragAndDropHandler.prototype.mouseStop = function() {
|
1790
|
-
this.moveItem();
|
1871
|
+
DragAndDropHandler.prototype.mouseStop = function(e) {
|
1872
|
+
this.moveItem(e);
|
1791
1873
|
this.clear();
|
1792
1874
|
this.removeHover();
|
1793
1875
|
this.removeDropHint();
|
@@ -2029,7 +2111,7 @@ limitations under the License.
|
|
2029
2111
|
}
|
2030
2112
|
};
|
2031
2113
|
|
2032
|
-
DragAndDropHandler.prototype.moveItem = function() {
|
2114
|
+
DragAndDropHandler.prototype.moveItem = function(original_event) {
|
2033
2115
|
var doMove, event, moved_node, position, previous_parent, target_node,
|
2034
2116
|
_this = this;
|
2035
2117
|
if (this.hovered_area && this.hovered_area.position !== Position.NONE) {
|
@@ -2051,7 +2133,8 @@ limitations under the License.
|
|
2051
2133
|
target_node: target_node,
|
2052
2134
|
position: Position.getName(position),
|
2053
2135
|
previous_parent: previous_parent,
|
2054
|
-
do_move: doMove
|
2136
|
+
do_move: doMove,
|
2137
|
+
original_event: original_event
|
2055
2138
|
}
|
2056
2139
|
});
|
2057
2140
|
if (!event.isDefaultPrevented()) {
|
@@ -20,6 +20,7 @@ ul.jqtree-tree li.jqtree-closed > ul.jqtree_common {
|
|
20
20
|
|
21
21
|
ul.jqtree-tree li.jqtree_common {
|
22
22
|
clear: both;
|
23
|
+
list-style-type: none;
|
23
24
|
}
|
24
25
|
ul.jqtree-tree .jqtree-toggler {
|
25
26
|
display: block;
|
@@ -38,7 +39,7 @@ ul.jqtree-tree .jqtree-toggler:hover {
|
|
38
39
|
color: #000;
|
39
40
|
}
|
40
41
|
|
41
|
-
ul.jqtree-tree
|
42
|
+
ul.jqtree-tree .jqtree-element {
|
42
43
|
cursor: pointer;
|
43
44
|
}
|
44
45
|
|
@@ -117,14 +118,14 @@ ul.jqtree-tree span.jqtree-border {
|
|
117
118
|
margin: 0;
|
118
119
|
}
|
119
120
|
|
120
|
-
ul.jqtree-tree
|
121
|
+
ul.jqtree-tree .jqtree-element {
|
121
122
|
width: 100%; /* todo: why is this in here? */
|
122
123
|
*width: auto; /* ie7 fix; issue 41 */
|
123
124
|
position: relative;
|
124
125
|
}
|
125
126
|
|
126
|
-
ul.jqtree-tree li.jqtree-selected >
|
127
|
-
ul.jqtree-tree li.jqtree-selected >
|
127
|
+
ul.jqtree-tree li.jqtree-selected > .jqtree-element,
|
128
|
+
ul.jqtree-tree li.jqtree-selected > .jqtree-element:hover {
|
128
129
|
background-color: #97BDD6;
|
129
130
|
background: -webkit-gradient(linear, left top, left bottom, from(#BEE0F5), to(#89AFCA));
|
130
131
|
background: -moz-linear-gradient(top, #BEE0F5, #89AFCA);
|
@@ -133,6 +134,6 @@ ul.jqtree-tree li.jqtree-selected > div:hover {
|
|
133
134
|
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.7);
|
134
135
|
}
|
135
136
|
|
136
|
-
ul.jqtree-tree .jqtree-moving >
|
137
|
+
ul.jqtree-tree .jqtree-moving > .jqtree-element .jqtree-title {
|
137
138
|
outline: dashed 1px #0000ff;
|
138
139
|
}
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: jqtree-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.5.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Ryan Scott Lewis
|
@@ -10,9 +10,10 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2013-03-25 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
|
+
prerelease: false
|
16
17
|
version_requirements: !ruby/object:Gem::Requirement
|
17
18
|
requirements:
|
18
19
|
- - ! '>='
|
@@ -22,9 +23,8 @@ dependencies:
|
|
22
23
|
- !ruby/object:Gem::Version
|
23
24
|
version: '5.0'
|
24
25
|
none: false
|
25
|
-
name: railties
|
26
26
|
type: :runtime
|
27
|
-
|
27
|
+
name: railties
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -35,15 +35,15 @@ dependencies:
|
|
35
35
|
version: '5.0'
|
36
36
|
none: false
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
|
+
prerelease: false
|
38
39
|
version_requirements: !ruby/object:Gem::Requirement
|
39
40
|
requirements:
|
40
41
|
- - ~>
|
41
42
|
- !ruby/object:Gem::Version
|
42
43
|
version: '0.14'
|
43
44
|
none: false
|
44
|
-
name: thor
|
45
45
|
type: :runtime
|
46
|
-
|
46
|
+
name: thor
|
47
47
|
requirement: !ruby/object:Gem::Requirement
|
48
48
|
requirements:
|
49
49
|
- - ~>
|
@@ -65,6 +65,7 @@ files:
|
|
65
65
|
- LICENSE
|
66
66
|
- README.md
|
67
67
|
- Rakefile
|
68
|
+
- build
|
68
69
|
- jqtree-rails.gemspec
|
69
70
|
- lib/generators/jqtree/install/install_generator.rb
|
70
71
|
- lib/jqtree-rails.rb
|
@@ -94,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
95
|
none: false
|
95
96
|
requirements: []
|
96
97
|
rubyforge_project:
|
97
|
-
rubygems_version: 1.8.
|
98
|
+
rubygems_version: 1.8.25
|
98
99
|
signing_key:
|
99
100
|
specification_version: 3
|
100
101
|
summary: Use jqTree with Rails 3
|