From ef032412216d437ce1c7dfc9050ab41adf0594c0 Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Mon, 13 Feb 2012 10:28:44 -0800 Subject: Tree Components - Change the way delegate methods are called --- .../treeview/ninja-branch.reel/ninja-branch.html | 3 +- .../treeview/ninja-branch.reel/ninja-branch.js | 1 - .../treeview/ninja-leaf.reel/ninja-leaf.html | 2 +- .../treeview/ninja-leaf.reel/ninja-leaf.js | 43 ++++++++++++++++++---- 4 files changed, 39 insertions(+), 10 deletions(-) (limited to 'js/components/treeview') diff --git a/js/components/treeview/ninja-branch.reel/ninja-branch.html b/js/components/treeview/ninja-branch.reel/ninja-branch.html index 4d557a94..13f1c575 100644 --- a/js/components/treeview/ninja-branch.reel/ninja-branch.html +++ b/js/components/treeview/ninja-branch.reel/ninja-branch.html @@ -110,7 +110,8 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot "name": "Repetition", "properties": { "element": { "#": "branchList" }, - "contentController": {"@": "arrayController" } + "contentController": {"@": "arrayController" }, + "selectionEnabled": true } }, diff --git a/js/components/treeview/ninja-branch.reel/ninja-branch.js b/js/components/treeview/ninja-branch.reel/ninja-branch.js index 6b9ebb10..0d1a1d0e 100644 --- a/js/components/treeview/ninja-branch.reel/ninja-branch.js +++ b/js/components/treeview/ninja-branch.reel/ninja-branch.js @@ -5,7 +5,6 @@ */ var Montage = require("montage").Montage, - Component = require("montage/ui/component").Component, TreeNode = require("js/components/treeview/tree-node").TreeNode; var Branch = exports.Branch = Montage.create(TreeNode, { 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
-
+
\ 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..749df3cd 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 */ var Montage = require("montage/core/core").Montage, - Component = require("montage/ui/component").Component; TreeNode = require("js/components/treeview/tree-node").TreeNode; exports.Leaf = Montage.create(TreeNode, { @@ -14,19 +13,39 @@ exports.Leaf = Montage.create(TreeNode, { }, templateDidLoad : { value: function() { - this.needsDraw = true; + var event = this.treeView.activationEvent; + + ///// Re-set the activation event + if(event && event !== this.activationEvent) { + this.delegateEventMap[event] = this.delegateEventMap[this.activationEvent]; + delete this.delegateEventMap[this.activationEvent]; + this.activationEvent = this.treeView.activationEvent; + } } }, prepareForDraw: { value : function() { - this.activationEvent = this.activationEvent || 'click'; - this.label._element.addEventListener(this.activationEvent, this.handleNodeActivation.bind(this), false); + var el = this.label._element; + + Object.keys(this.delegateEventMap).forEach(function(event) { + el.addEventListener(event, this, false); + }, this); + } }, - handleNodeActivation: { + handleEvent : { value: function(e) { - console.log(this.sourceObject); - this.treeView.contentController.delegate.applyPresetSelection(this.sourceObject); + var delegateMethod = this.delegateEventMap[e._event.type]; + this.callDelegateMethod(delegateMethod); + } + }, + callDelegateMethod : { + value: function(methodName) { + console.log("Delegate method name: ", methodName); + var delegate = this.treeView.contentController.delegate; + if(delegate && typeof delegate[methodName] === 'function') { + delegate[methodName](this.sourceObject); + } } }, draw : { @@ -35,6 +54,16 @@ exports.Leaf = Montage.create(TreeNode, { this._labelText = this.sourceObject[this.labelKey]; } } + }, + activationEvent : { + value : 'click' + }, + delegateEventMap : { + value: { + 'click' : 'handleNodeActivation', + 'dragstart' : 'handleDragStart', + 'dragend' : 'handleDragEnd' + } } -- cgit v1.2.3 From 85afed8ed707ce20cd28c3139680dfef6fd4b23d Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Mon, 13 Feb 2012 11:42:09 -0800 Subject: Ninja leaf - remove console lot --- js/components/treeview/ninja-leaf.reel/ninja-leaf.js | 1 - 1 file changed, 1 deletion(-) (limited to 'js/components/treeview') diff --git a/js/components/treeview/ninja-leaf.reel/ninja-leaf.js b/js/components/treeview/ninja-leaf.reel/ninja-leaf.js index 749df3cd..0b7a171e 100644 --- a/js/components/treeview/ninja-leaf.reel/ninja-leaf.js +++ b/js/components/treeview/ninja-leaf.reel/ninja-leaf.js @@ -41,7 +41,6 @@ exports.Leaf = Montage.create(TreeNode, { }, callDelegateMethod : { value: function(methodName) { - console.log("Delegate method name: ", methodName); var delegate = this.treeView.contentController.delegate; if(delegate && typeof delegate[methodName] === 'function') { delegate[methodName](this.sourceObject); -- cgit v1.2.3 From df898049b2990f456a305eb18434b887468225cf Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 14 Feb 2012 11:13:32 -0800 Subject: small changes to the tree component to allow events to be passed and add a double click handler Signed-off-by: Valerio Virgillito --- js/components/treeview/ninja-leaf.reel/ninja-leaf.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'js/components/treeview') diff --git a/js/components/treeview/ninja-leaf.reel/ninja-leaf.js b/js/components/treeview/ninja-leaf.reel/ninja-leaf.js index 0b7a171e..c6416693 100644 --- a/js/components/treeview/ninja-leaf.reel/ninja-leaf.js +++ b/js/components/treeview/ninja-leaf.reel/ninja-leaf.js @@ -36,14 +36,14 @@ exports.Leaf = Montage.create(TreeNode, { handleEvent : { value: function(e) { var delegateMethod = this.delegateEventMap[e._event.type]; - this.callDelegateMethod(delegateMethod); + this.callDelegateMethod(delegateMethod, e); } }, callDelegateMethod : { - value: function(methodName) { + value: function(methodName, evt) { var delegate = this.treeView.contentController.delegate; if(delegate && typeof delegate[methodName] === 'function') { - delegate[methodName](this.sourceObject); + delegate[methodName](this.sourceObject, evt); } } }, @@ -60,6 +60,7 @@ exports.Leaf = Montage.create(TreeNode, { delegateEventMap : { value: { 'click' : 'handleNodeActivation', + 'dblclick' : 'handleDblclick', 'dragstart' : 'handleDragStart', 'dragend' : 'handleDragEnd' } -- cgit v1.2.3 From 23071f9cb32e1783d8c0aa960a8407e9024876c9 Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Wed, 15 Feb 2012 21:51:28 -0800 Subject: Tree Node - fix for applying tree child nodes array twice (and getting duplicates) --- js/components/treeview/tree-node.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'js/components/treeview') diff --git a/js/components/treeview/tree-node.js b/js/components/treeview/tree-node.js index 689fc233..d7b864b5 100644 --- a/js/components/treeview/tree-node.js +++ b/js/components/treeview/tree-node.js @@ -44,7 +44,9 @@ exports.TreeNode = Montage.create(Component, { if(!object) { return; } + if(object[this.branchKey]) { + this.childNodes.length = 0; object[this.branchKey].forEach(function(node) { this.childNodes.push(node); }, this); -- cgit v1.2.3 From e5654b593f0371ac218af2f542d4ab904dbca746 Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Wed, 15 Feb 2012 21:51:58 -0800 Subject: Ninja Leaf/Branch - Minor CSS fixes --- js/components/treeview/ninja-branch.reel/ninja-branch.css | 2 +- js/components/treeview/ninja-leaf.reel/ninja-leaf.css | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'js/components/treeview') diff --git a/js/components/treeview/ninja-branch.reel/ninja-branch.css b/js/components/treeview/ninja-branch.reel/ninja-branch.css index d8c212e8..a3a9350e 100644 --- a/js/components/treeview/ninja-branch.reel/ninja-branch.css +++ b/js/components/treeview/ninja-branch.reel/ninja-branch.css @@ -26,7 +26,7 @@ cursor: pointer; font-weight: bold; padding: 3px 0 4px; - text-shadow: 1px 1px 0 #000; + text-shadow: 1px 1px 1px #000; } /* First Level */ diff --git a/js/components/treeview/ninja-leaf.reel/ninja-leaf.css b/js/components/treeview/ninja-leaf.reel/ninja-leaf.css index 085b11e0..fedc1d9d 100644 --- a/js/components/treeview/ninja-leaf.reel/ninja-leaf.css +++ b/js/components/treeview/ninja-leaf.reel/ninja-leaf.css @@ -19,7 +19,6 @@ /* Second level */ .branch .branch .leaf-label { background-position: 25px center; - box-shadow: 0 3px 4px -4px rgba(0,0,0,0.2); color: #FFF; padding-left: 45px; } -- cgit v1.2.3 From 8195f0c948f145b5883dd7298649ef24b7e941ae Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Wed, 15 Feb 2012 21:52:57 -0800 Subject: Tree view event delegate map fix --- js/components/treeview/ninja-leaf.reel/ninja-leaf.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'js/components/treeview') diff --git a/js/components/treeview/ninja-leaf.reel/ninja-leaf.js b/js/components/treeview/ninja-leaf.reel/ninja-leaf.js index c6416693..1bfe66a4 100644 --- a/js/components/treeview/ninja-leaf.reel/ninja-leaf.js +++ b/js/components/treeview/ninja-leaf.reel/ninja-leaf.js @@ -63,7 +63,8 @@ exports.Leaf = Montage.create(TreeNode, { 'dblclick' : 'handleDblclick', 'dragstart' : 'handleDragStart', 'dragend' : 'handleDragEnd' - } + }, + distinct: true } -- cgit v1.2.3 From dcbacf63faa9caaea26883855e3adde37db9bd4f Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Thu, 16 Feb 2012 14:31:05 -0800 Subject: Presets - Minor CSS text-shadow work-around for Windows Chrome --- js/components/treeview/ninja-branch.reel/ninja-branch.css | 1 - 1 file changed, 1 deletion(-) (limited to 'js/components/treeview') diff --git a/js/components/treeview/ninja-branch.reel/ninja-branch.css b/js/components/treeview/ninja-branch.reel/ninja-branch.css index a3a9350e..340233c7 100644 --- a/js/components/treeview/ninja-branch.reel/ninja-branch.css +++ b/js/components/treeview/ninja-branch.reel/ninja-branch.css @@ -26,7 +26,6 @@ cursor: pointer; font-weight: bold; padding: 3px 0 4px; - text-shadow: 1px 1px 1px #000; } /* First Level */ -- cgit v1.2.3