From 8f1385d4aa12173fb4d9af695b8e5036f675b621 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Fri, 4 May 2012 14:39:33 -0700 Subject: Fixing selection and layout code to exclude SCRIPT and STYLE tags. Signed-off-by: Nivesh Rajbhandari --- js/controllers/selection-controller.js | 11 +++++++++-- js/stage/layout.js | 2 +- js/tools/SelectionTool.js | 5 +++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js index 5665b09c..77c065ae 100755 --- a/js/controllers/selection-controller.js +++ b/js/controllers/selection-controller.js @@ -112,12 +112,12 @@ exports.SelectionController = Montage.create(Component, { handleSelectAll: { value: function(event) { - var selected = [], childNodes = []; + var selected = [], childNodes = [], self = this; childNodes = this.application.ninja.currentDocument.documentRoot.childNodes; childNodes = Array.prototype.slice.call(childNodes, 0); childNodes.forEach(function(item) { - if(item.nodeType == 1) { + if(self.isNodeTraversable(item)) { selected.push(item); } }); @@ -281,6 +281,13 @@ exports.SelectionController = Montage.create(Component, { return -1; } + }, + + isNodeTraversable: { + value: function( item ) { + if(item.nodeType !== 1) return false; + return ((item.nodeName !== "STYLE") && (item.nodeName !== "SCRIPT")); + } } }); diff --git a/js/stage/layout.js b/js/stage/layout.js index 0a76dbe5..9c5e2167 100755 --- a/js/stage/layout.js +++ b/js/stage/layout.js @@ -156,7 +156,7 @@ exports.Layout = Montage.create(Component, { drawTagOutline: { value: function (item) { - if(!item || (item.nodeType !== 1)) return; + if(!item || !this.application.ninja.selectionController.isNodeTraversable(item)) return; // TODO Bind the layoutview mode to the current document // var mode = this.application.ninja.currentDocument.layoutMode; diff --git a/js/tools/SelectionTool.js b/js/tools/SelectionTool.js index 855c7b8c..d3e4ebf9 100755 --- a/js/tools/SelectionTool.js +++ b/js/tools/SelectionTool.js @@ -165,10 +165,11 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { box[3] = point.y; //selectionManagerModule.selectionManager.marqueeSelection(box); - var childNodes = this.application.ninja.currentDocument.documentRoot.childNodes; + var childNodes = this.application.ninja.currentDocument.documentRoot.childNodes, + selectionController = this.application.ninja.selectionController; childNodes = Array.prototype.slice.call(childNodes, 0); childNodes.forEach(function(item) { - if(item.nodeType == 1 && SelectionTool._complicatedCollisionDetection(item, box)) { + if(selectionController.isNodeTraversable(item) && SelectionTool._complicatedCollisionDetection(item, box)) { selectedItems.push(item); } }); -- cgit v1.2.3