diff options
author | Armen Kesablyan | 2012-02-14 10:09:48 -0800 |
---|---|---|
committer | Armen Kesablyan | 2012-02-14 10:09:48 -0800 |
commit | ace16ef22b3ff32663504df7720af481d76987d6 (patch) | |
tree | b223da744577290b00fb454177738369b3a3894a /js/components/treeview/ninja-leaf.reel | |
parent | 90d0c8c0e98d062c628c061fe5765ce991fda409 (diff) | |
parent | 1d82f1a041612f32bbf6c9f20d9fb14e2d11fcc7 (diff) | |
download | ninja-ace16ef22b3ff32663504df7720af481d76987d6.tar.gz |
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal
Diffstat (limited to 'js/components/treeview/ninja-leaf.reel')
-rw-r--r-- | js/components/treeview/ninja-leaf.reel/ninja-leaf.html | 2 | ||||
-rw-r--r-- | js/components/treeview/ninja-leaf.reel/ninja-leaf.js | 42 |
2 files changed, 36 insertions, 8 deletions
diff --git a/js/components/treeview/ninja-leaf.reel/ninja-leaf.html b/js/components/treeview/ninja-leaf.reel/ninja-leaf.html index bd8e8acd..310274bc 100644 --- a/js/components/treeview/ninja-leaf.reel/ninja-leaf.html +++ b/js/components/treeview/ninja-leaf.reel/ninja-leaf.html | |||
@@ -37,7 +37,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
37 | </head> | 37 | </head> |
38 | <body> | 38 | <body> |
39 | <div id="leaf" class="leaf"> | 39 | <div id="leaf" class="leaf"> |
40 | <div id="label" class="leaf-label"></div> | 40 | <div id="label" class="leaf-label" draggable="true"></div> |
41 | </div> | 41 | </div> |
42 | </body> | 42 | </body> |
43 | </html> \ No newline at end of file | 43 | </html> \ No newline at end of file |
diff --git a/js/components/treeview/ninja-leaf.reel/ninja-leaf.js b/js/components/treeview/ninja-leaf.reel/ninja-leaf.js index bd566b26..0b7a171e 100644 --- a/js/components/treeview/ninja-leaf.reel/ninja-leaf.js +++ b/js/components/treeview/ninja-leaf.reel/ninja-leaf.js | |||
@@ -5,7 +5,6 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
5 | </copyright> */ | 5 | </copyright> */ |
6 | 6 | ||
7 | var Montage = require("montage/core/core").Montage, | 7 | var Montage = require("montage/core/core").Montage, |
8 | Component = require("montage/ui/component").Component; | ||
9 | TreeNode = require("js/components/treeview/tree-node").TreeNode; | 8 | TreeNode = require("js/components/treeview/tree-node").TreeNode; |
10 | 9 | ||
11 | exports.Leaf = Montage.create(TreeNode, { | 10 | exports.Leaf = Montage.create(TreeNode, { |
@@ -14,19 +13,38 @@ exports.Leaf = Montage.create(TreeNode, { | |||
14 | }, | 13 | }, |
15 | templateDidLoad : { | 14 | templateDidLoad : { |
16 | value: function() { | 15 | value: function() { |
17 | this.needsDraw = true; | 16 | var event = this.treeView.activationEvent; |
17 | |||
18 | ///// Re-set the activation event | ||
19 | if(event && event !== this.activationEvent) { | ||
20 | this.delegateEventMap[event] = this.delegateEventMap[this.activationEvent]; | ||
21 | delete this.delegateEventMap[this.activationEvent]; | ||
22 | this.activationEvent = this.treeView.activationEvent; | ||
23 | } | ||
18 | } | 24 | } |
19 | }, | 25 | }, |
20 | prepareForDraw: { | 26 | prepareForDraw: { |
21 | value : function() { | 27 | value : function() { |
22 | this.activationEvent = this.activationEvent || 'click'; | 28 | var el = this.label._element; |
23 | this.label._element.addEventListener(this.activationEvent, this.handleNodeActivation.bind(this), false); | 29 | |
30 | Object.keys(this.delegateEventMap).forEach(function(event) { | ||
31 | el.addEventListener(event, this, false); | ||
32 | }, this); | ||
33 | |||
24 | } | 34 | } |
25 | }, | 35 | }, |
26 | handleNodeActivation: { | 36 | handleEvent : { |
27 | value: function(e) { | 37 | value: function(e) { |
28 | console.log(this.sourceObject); | 38 | var delegateMethod = this.delegateEventMap[e._event.type]; |
29 | this.treeView.contentController.delegate.applyPresetSelection(this.sourceObject); | 39 | this.callDelegateMethod(delegateMethod); |
40 | } | ||
41 | }, | ||
42 | callDelegateMethod : { | ||
43 | value: function(methodName) { | ||
44 | var delegate = this.treeView.contentController.delegate; | ||
45 | if(delegate && typeof delegate[methodName] === 'function') { | ||
46 | delegate[methodName](this.sourceObject); | ||
47 | } | ||
30 | } | 48 | } |
31 | }, | 49 | }, |
32 | draw : { | 50 | draw : { |
@@ -35,6 +53,16 @@ exports.Leaf = Montage.create(TreeNode, { | |||
35 | this._labelText = this.sourceObject[this.labelKey]; | 53 | this._labelText = this.sourceObject[this.labelKey]; |
36 | } | 54 | } |
37 | } | 55 | } |
56 | }, | ||
57 | activationEvent : { | ||
58 | value : 'click' | ||
59 | }, | ||
60 | delegateEventMap : { | ||
61 | value: { | ||
62 | 'click' : 'handleNodeActivation', | ||
63 | 'dragstart' : 'handleDragStart', | ||
64 | 'dragend' : 'handleDragEnd' | ||
65 | } | ||
38 | } | 66 | } |
39 | 67 | ||
40 | 68 | ||