angular_ui_tree_rails 0.1.0 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/angular_ui_tree_rails/version.rb +1 -1
- data/vendor/assets/javascripts/angular-ui-tree.js +37 -119
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb384e9399313e761e3f338f16f85a795d406724
|
4
|
+
data.tar.gz: da0f0f3d4690b8ff2a0a4549b61879d0513421a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc1352f893c058a7c6b045bb723d1ef8bb4a90726bef010b163227185ba99268ca00c16a3961f8aa9dcbf362807a8be6baaef6ef810f3ed291a8b898de87dc6f
|
7
|
+
data.tar.gz: 4a2cddb7dbd78a5f533772662ce432f52a973dd2ff85beae58abdcef2767ad5fe26350bc6fdf2c85c9e0c6cd4b47c1d65b8d62b417b3b4eb676f27cbc9c1a1f3
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/**
|
2
|
-
* @license Angular UI Tree v2.
|
2
|
+
* @license Angular UI Tree v2.0.13
|
3
3
|
* (c) 2010-2014. https://github.com/JimLiu/angular-ui-tree
|
4
4
|
* License: MIT
|
5
5
|
*/
|
@@ -48,7 +48,6 @@
|
|
48
48
|
},
|
49
49
|
|
50
50
|
setNodeAttribute: function(scope, attrName, val) {
|
51
|
-
if (!scope.$modelValue) return null;
|
52
51
|
var data = this.nodesData[scope.$modelValue.$$hashKey];
|
53
52
|
if (!data) {
|
54
53
|
data = {};
|
@@ -58,7 +57,6 @@
|
|
58
57
|
},
|
59
58
|
|
60
59
|
getNodeAttribute: function(scope, attrName) {
|
61
|
-
if (!scope.$modelValue) return null;
|
62
60
|
var data = this.nodesData[scope.$modelValue.$$hashKey];
|
63
61
|
if (data) {
|
64
62
|
return data[attrName];
|
@@ -305,7 +303,6 @@
|
|
305
303
|
$scope.$callbacks = null;
|
306
304
|
|
307
305
|
$scope.dragEnabled = true;
|
308
|
-
$scope.emptyPlaceHolderEnabled = true;
|
309
306
|
$scope.maxDepth = 0;
|
310
307
|
$scope.dragDelay = 0;
|
311
308
|
|
@@ -322,8 +319,7 @@
|
|
322
319
|
};
|
323
320
|
|
324
321
|
$scope.resetEmptyElement = function() {
|
325
|
-
if ($scope.$nodesScope.$modelValue.length === 0
|
326
|
-
$scope.emptyPlaceHolderEnabled) {
|
322
|
+
if ($scope.$nodesScope.$modelValue.length === 0) {
|
327
323
|
$element.append($scope.$emptyElm);
|
328
324
|
} else {
|
329
325
|
$scope.$emptyElm.remove();
|
@@ -358,8 +354,8 @@
|
|
358
354
|
|
359
355
|
angular.module('ui.tree')
|
360
356
|
|
361
|
-
.controller('TreeNodesController', ['$scope', '$element', 'treeConfig',
|
362
|
-
function ($scope, $element, treeConfig) {
|
357
|
+
.controller('TreeNodesController', ['$scope', '$element', '$timeout', 'treeConfig',
|
358
|
+
function ($scope, $element, $timeout, treeConfig) {
|
363
359
|
this.scope = $scope;
|
364
360
|
|
365
361
|
$scope.$element = $element;
|
@@ -373,12 +369,12 @@
|
|
373
369
|
$scope.maxDepth = 0;
|
374
370
|
|
375
371
|
$scope.initSubNode = function(subNode) {
|
376
|
-
|
377
|
-
|
372
|
+
$timeout(function() {
|
373
|
+
$scope.$nodesMap[subNode.$modelValue.$$hashKey] = subNode;
|
374
|
+
});
|
378
375
|
};
|
379
376
|
|
380
377
|
$scope.destroySubNode = function(subNode) {
|
381
|
-
if(!subNode.$modelValue) return null;
|
382
378
|
$scope.$nodesMap[subNode.$modelValue.$$hashKey] = null;
|
383
379
|
};
|
384
380
|
|
@@ -386,10 +382,6 @@
|
|
386
382
|
return $scope.$treeScope.$callbacks.accept(sourceNode, $scope, destIndex);
|
387
383
|
};
|
388
384
|
|
389
|
-
$scope.beforeDrag = function(sourceNode) {
|
390
|
-
return $scope.$treeScope.$callbacks.beforeDrag(sourceNode);
|
391
|
-
};
|
392
|
-
|
393
385
|
$scope.isParent = function(node) {
|
394
386
|
return node.$parentNodesScope == $scope;
|
395
387
|
};
|
@@ -536,15 +528,7 @@
|
|
536
528
|
};
|
537
529
|
|
538
530
|
$scope.accept = function(sourceNode, destIndex) {
|
539
|
-
return $scope.$childNodesScope &&
|
540
|
-
$scope.$childNodesScope.$modelValue &&
|
541
|
-
$scope.$childNodesScope.accept(sourceNode, destIndex);
|
542
|
-
};
|
543
|
-
|
544
|
-
$scope.removeNode = function(){
|
545
|
-
var node = $scope.remove();
|
546
|
-
$scope.$callbacks.removed(node);
|
547
|
-
return node;
|
531
|
+
return $scope.$childNodesScope && $scope.$childNodesScope.accept(sourceNode, destIndex);
|
548
532
|
};
|
549
533
|
|
550
534
|
$scope.remove = function() {
|
@@ -626,8 +610,7 @@
|
|
626
610
|
controller: 'TreeController',
|
627
611
|
link: function(scope, element, attrs) {
|
628
612
|
var callbacks = {
|
629
|
-
accept: null
|
630
|
-
beforeDrag: null
|
613
|
+
accept: null
|
631
614
|
};
|
632
615
|
|
633
616
|
var config = {};
|
@@ -647,27 +630,24 @@
|
|
647
630
|
}
|
648
631
|
}, true);
|
649
632
|
|
650
|
-
|
651
|
-
|
652
|
-
|
633
|
+
attrs.$observe('dragEnabled', function(val) {
|
634
|
+
var de = scope.$eval(val);
|
635
|
+
if((typeof de) == "boolean") {
|
636
|
+
scope.dragEnabled = de;
|
653
637
|
}
|
654
638
|
});
|
655
639
|
|
656
|
-
|
657
|
-
|
658
|
-
|
640
|
+
attrs.$observe('maxDepth', function(val) {
|
641
|
+
var md = scope.$eval(val);
|
642
|
+
if((typeof md) == "number") {
|
643
|
+
scope.maxDepth = md;
|
659
644
|
}
|
660
645
|
});
|
661
646
|
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
});
|
667
|
-
|
668
|
-
scope.$watch(attrs.dragDelay, function(val) {
|
669
|
-
if((typeof val) == "number") {
|
670
|
-
scope.dragDelay = val;
|
647
|
+
attrs.$observe('dragDelay', function(val) {
|
648
|
+
var dd = scope.$eval(val);
|
649
|
+
if((typeof dd) == "number") {
|
650
|
+
scope.dragDelay = dd;
|
671
651
|
}
|
672
652
|
});
|
673
653
|
|
@@ -682,14 +662,6 @@
|
|
682
662
|
return true;
|
683
663
|
};
|
684
664
|
|
685
|
-
callbacks.beforeDrag = function(sourceNodeScope) {
|
686
|
-
return true;
|
687
|
-
};
|
688
|
-
|
689
|
-
callbacks.removed = function(node){
|
690
|
-
|
691
|
-
};
|
692
|
-
|
693
665
|
callbacks.dropped = function(event) {
|
694
666
|
|
695
667
|
};
|
@@ -707,10 +679,6 @@
|
|
707
679
|
|
708
680
|
};
|
709
681
|
|
710
|
-
callbacks.beforeDrop = function(event) {
|
711
|
-
|
712
|
-
};
|
713
|
-
|
714
682
|
scope.$watch(attrs.uiTree, function(newVal, oldVal){
|
715
683
|
angular.forEach(newVal, function(value, key){
|
716
684
|
if (callbacks[key]) {
|
@@ -770,9 +738,10 @@
|
|
770
738
|
};
|
771
739
|
}
|
772
740
|
|
773
|
-
|
774
|
-
|
775
|
-
|
741
|
+
attrs.$observe('maxDepth', function(val) {
|
742
|
+
var md = scope.$eval(val);
|
743
|
+
if((typeof md) == "number") {
|
744
|
+
scope.maxDepth = md;
|
776
745
|
}
|
777
746
|
});
|
778
747
|
|
@@ -810,10 +779,10 @@
|
|
810
779
|
scope.init(controllersArr);
|
811
780
|
|
812
781
|
scope.collapsed = !!$uiTreeHelper.getNodeAttribute(scope, 'collapsed');
|
813
|
-
|
814
|
-
|
815
|
-
if((typeof
|
816
|
-
scope.collapsed =
|
782
|
+
attrs.$observe('collapsed', function(val) {
|
783
|
+
var collapsed = scope.$eval(val);
|
784
|
+
if((typeof collapsed) == "boolean") {
|
785
|
+
scope.collapsed = collapsed;
|
817
786
|
}
|
818
787
|
});
|
819
788
|
|
@@ -828,8 +797,6 @@
|
|
828
797
|
var placeElm, hiddenPlaceElm, dragElm;
|
829
798
|
var treeScope = null;
|
830
799
|
var elements; // As a parameter for callbacks
|
831
|
-
var dragDelaying = true;
|
832
|
-
var dragStarted = false;
|
833
800
|
var dragTimer = null;
|
834
801
|
var body = document.body,
|
835
802
|
html = document.documentElement,
|
@@ -860,14 +827,6 @@
|
|
860
827
|
return;
|
861
828
|
}
|
862
829
|
|
863
|
-
var eventElmTagName = eventElm.prop('tagName').toLowerCase();
|
864
|
-
if (eventElmTagName == 'input' ||
|
865
|
-
eventElmTagName == 'textarea' ||
|
866
|
-
eventElmTagName == 'button' ||
|
867
|
-
eventElmTagName == 'select') { // if it's a input or button, ignore it
|
868
|
-
return;
|
869
|
-
}
|
870
|
-
|
871
830
|
// check if it or it's parents has a 'data-nodrag' attribute
|
872
831
|
while (eventElm && eventElm[0] && eventElm[0] != element) {
|
873
832
|
if ($uiTreeHelper.nodrag(eventElm)) { // if the node mark as `nodrag`, DONOT drag it.
|
@@ -876,10 +835,6 @@
|
|
876
835
|
eventElm = eventElm.parent();
|
877
836
|
}
|
878
837
|
|
879
|
-
if (!scope.beforeDrag(scope)){
|
880
|
-
return;
|
881
|
-
}
|
882
|
-
|
883
838
|
e.uiTreeDragging = true; // stop event bubbling
|
884
839
|
if (e.originalEvent) {
|
885
840
|
e.originalEvent.uiTreeDragging = true;
|
@@ -912,13 +867,6 @@
|
|
912
867
|
dragElm.css('width', $uiTreeHelper.width(scope.$element) + 'px');
|
913
868
|
dragElm.css('z-index', 9999);
|
914
869
|
|
915
|
-
// Prevents cursor to change rapidly in Opera 12.16 and IE when dragging an element
|
916
|
-
var hStyle = (scope.$element[0].querySelector('.angular-ui-tree-handle') || scope.$element[0]).currentStyle;
|
917
|
-
if (hStyle) {
|
918
|
-
document.body.setAttribute('ui-tree-cursor', $document.find('body').css('cursor') || '');
|
919
|
-
$document.find('body').css({'cursor': hStyle.cursor + '!important'});
|
920
|
-
}
|
921
|
-
|
922
870
|
scope.$element.after(placeElm);
|
923
871
|
scope.$element.after(hiddenPlaceElm);
|
924
872
|
dragElm.append(scope.$element);
|
@@ -931,6 +879,9 @@
|
|
931
879
|
placeholder: placeElm,
|
932
880
|
dragging: dragElm
|
933
881
|
};
|
882
|
+
scope.$apply(function() {
|
883
|
+
scope.$callbacks.dragStart(dragInfo.eventArgs(elements, pos));
|
884
|
+
});
|
934
885
|
|
935
886
|
angular.element($document).bind('touchend', dragEndEvent);
|
936
887
|
angular.element($document).bind('touchcancel', dragEndEvent);
|
@@ -938,33 +889,17 @@
|
|
938
889
|
angular.element($document).bind('mouseup', dragEndEvent);
|
939
890
|
angular.element($document).bind('mousemove', dragMoveEvent);
|
940
891
|
angular.element($document).bind('mouseleave', dragCancelEvent);
|
941
|
-
|
942
892
|
document_height = Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight);
|
943
893
|
document_width = Math.max(body.scrollWidth, body.offsetWidth, html.clientWidth, html.scrollWidth, html.offsetWidth);
|
944
894
|
};
|
945
895
|
|
946
896
|
var dragMove = function(e) {
|
947
|
-
if (!dragStarted) {
|
948
|
-
if (!dragDelaying) {
|
949
|
-
dragStarted = true;
|
950
|
-
scope.$apply(function() {
|
951
|
-
scope.$callbacks.dragStart(dragInfo.eventArgs(elements, pos));
|
952
|
-
});
|
953
|
-
}
|
954
|
-
return;
|
955
|
-
}
|
956
|
-
|
957
897
|
var eventObj = $uiTreeHelper.eventObj(e);
|
958
898
|
var prev, leftElmPos, topElmPos;
|
959
899
|
|
960
900
|
if (dragElm) {
|
961
901
|
e.preventDefault();
|
962
|
-
|
963
|
-
if ($window.getSelection) {
|
964
|
-
$window.getSelection().removeAllRanges();
|
965
|
-
} else if ($window.document.selection) {
|
966
|
-
$window.document.selection.empty();
|
967
|
-
}
|
902
|
+
$window.getSelection().removeAllRanges();
|
968
903
|
|
969
904
|
leftElmPos = eventObj.pageX - pos.offsetX;
|
970
905
|
topElmPos = eventObj.pageY - pos.offsetY;
|
@@ -1051,12 +986,8 @@
|
|
1051
986
|
// Select the drag target. Because IE does not support CSS 'pointer-events: none', it will always
|
1052
987
|
// pick the drag element itself as the target. To prevent this, we hide the drag element while
|
1053
988
|
// selecting the target.
|
1054
|
-
var displayElm;
|
1055
989
|
if (angular.isFunction(dragElm.hide)) {
|
1056
990
|
dragElm.hide();
|
1057
|
-
}else{
|
1058
|
-
displayElm = dragElm[0].style.display;
|
1059
|
-
dragElm[0].style.display = "none";
|
1060
991
|
}
|
1061
992
|
|
1062
993
|
// when using elementFromPoint() inside an iframe, you have to call
|
@@ -1066,8 +997,6 @@
|
|
1066
997
|
var targetElm = angular.element($window.document.elementFromPoint(targetX, targetY));
|
1067
998
|
if (angular.isFunction(dragElm.show)) {
|
1068
999
|
dragElm.show();
|
1069
|
-
}else{
|
1070
|
-
dragElm[0].style.display = displayElm;
|
1071
1000
|
}
|
1072
1001
|
|
1073
1002
|
// move vertical
|
@@ -1135,9 +1064,6 @@
|
|
1135
1064
|
e.preventDefault();
|
1136
1065
|
|
1137
1066
|
if (dragElm) {
|
1138
|
-
scope.$treeScope.$apply(function() {
|
1139
|
-
scope.$callbacks.beforeDrop(dragInfo.eventArgs(elements, pos));
|
1140
|
-
});
|
1141
1067
|
// roll back elements changed
|
1142
1068
|
hiddenPlaceElm.replaceWith(scope.$element);
|
1143
1069
|
placeElm.remove();
|
@@ -1160,12 +1086,6 @@
|
|
1160
1086
|
|
1161
1087
|
}
|
1162
1088
|
|
1163
|
-
// Restore cursor in Opera 12.16 and IE
|
1164
|
-
var oldCur = document.body.getAttribute('ui-tree-cursor');
|
1165
|
-
if (oldCur !== null) {
|
1166
|
-
$document.find('body').css({'cursor': oldCur});
|
1167
|
-
document.body.removeAttribute('ui-tree-cursor');
|
1168
|
-
}
|
1169
1089
|
|
1170
1090
|
angular.element($document).unbind('touchend', dragEndEvent); // Mobile
|
1171
1091
|
angular.element($document).unbind('touchcancel', dragEndEvent); // Mobile
|
@@ -1195,13 +1115,11 @@
|
|
1195
1115
|
};
|
1196
1116
|
|
1197
1117
|
var bindDrag = function() {
|
1198
|
-
element.bind('touchstart
|
1199
|
-
|
1200
|
-
|
1201
|
-
dragStartEvent(e);
|
1202
|
-
dragTimer = $timeout(function(){dragDelaying = false;}, scope.dragDelay);
|
1118
|
+
element.bind('touchstart', dragStartEvent);
|
1119
|
+
element.bind('mousedown', function (e) {
|
1120
|
+
dragTimer = $timeout(function(){dragStartEvent(e);}, scope.dragDelay);
|
1203
1121
|
});
|
1204
|
-
element.bind('
|
1122
|
+
element.bind('mouseup',function(){$timeout.cancel(dragTimer);});
|
1205
1123
|
};
|
1206
1124
|
bindDrag();
|
1207
1125
|
|