Built motion from commit 1020cd7.|0.0.107
[motion.git] / public / bower_components / ng-js-tree / ngJsTree.js
index 0a74df0..9ecd56c 100644 (file)
@@ -5,15 +5,16 @@
     function jsTreeCtrl() {
         /*jshint validthis:true */
         var nodeSerialId = 1;
+        var vm = this;
 
-        this.nodesFingerprint = function (e) {
+        vm.nodesFingerprint = function (e) {
             if (!e.__uiNodeId) {
                 e.__uiNodeId = nodeSerialId++;
             }
             return '' + e.__uiNodeId + (e.id || '') + (e.text || '') + (e.type || '');
         };
 
-        this.changeWatcher = function (arraySource, tokenFn) {
+        vm.changeWatcher = function (arraySource, tokenFn) {
             var self;
             var getTokens = function () {
                 var result = [], token, el;
@@ -95,6 +96,7 @@
             restrict: 'A',
             scope: {
                 treeData: '=ngModel',
+                treeEventsObj: '=?treeEventsObj',
                 shouldApply : '&'
             },
             controller: 'jsTreeCtrl',
                                 s.tree.on(evt, s.$parent.$eval(cb));
                             }
                         }
+                    } else if (angular.isObject(s.treeEventsObj)) {
+                        angular.forEach(s.treeEventsObj, function(cb, name) {
+                            var evt = name + '.jstree';
+                            s.tree.on(evt, cb);
+                        });
                     }
                 }
 
                     if (attrs.tree) {
                         if (attrs.tree.indexOf('.') !== -1) {
                             var split = attrs.tree.split('.');
-                            scope.tree = scope.$parent[split[0]][split[1]] = elm;
+                            var tree = split.pop();
+                            var context = scope.$parent;
+                            for (var i = 0; i < split.length; i++) {
+                                context = context[split[i]];
+                            }
+                            scope.tree = context[tree] = elm;
                         }
                         else {
                             scope.tree = scope.$parent[attrs.tree] = elm;