aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNivesh Rajbhandari2012-05-04 14:39:33 -0700
committerNivesh Rajbhandari2012-05-04 14:39:33 -0700
commit8f1385d4aa12173fb4d9af695b8e5036f675b621 (patch)
tree5c25b7f37150265a3ccb3097c35ef5810759d942
parentfec9ccee11ea21ffc95edce6e89d0d302b63e3d8 (diff)
downloadninja-8f1385d4aa12173fb4d9af695b8e5036f675b621.tar.gz
Fixing selection and layout code to exclude SCRIPT and STYLE tags.
Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com>
-rwxr-xr-xjs/controllers/selection-controller.js11
-rwxr-xr-xjs/stage/layout.js2
-rwxr-xr-xjs/tools/SelectionTool.js5
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, {
112 112
113 handleSelectAll: { 113 handleSelectAll: {
114 value: function(event) { 114 value: function(event) {
115 var selected = [], childNodes = []; 115 var selected = [], childNodes = [], self = this;
116 116
117 childNodes = this.application.ninja.currentDocument.documentRoot.childNodes; 117 childNodes = this.application.ninja.currentDocument.documentRoot.childNodes;
118 childNodes = Array.prototype.slice.call(childNodes, 0); 118 childNodes = Array.prototype.slice.call(childNodes, 0);
119 childNodes.forEach(function(item) { 119 childNodes.forEach(function(item) {
120 if(item.nodeType == 1) { 120 if(self.isNodeTraversable(item)) {
121 selected.push(item); 121 selected.push(item);
122 } 122 }
123 }); 123 });
@@ -281,6 +281,13 @@ exports.SelectionController = Montage.create(Component, {
281 281
282 return -1; 282 return -1;
283 } 283 }
284 },
285
286 isNodeTraversable: {
287 value: function( item ) {
288 if(item.nodeType !== 1) return false;
289 return ((item.nodeName !== "STYLE") && (item.nodeName !== "SCRIPT"));
290 }
284 } 291 }
285 292
286}); 293});
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, {
156 drawTagOutline: { 156 drawTagOutline: {
157 value: function (item) { 157 value: function (item) {
158 158
159 if(!item || (item.nodeType !== 1)) return; 159 if(!item || !this.application.ninja.selectionController.isNodeTraversable(item)) return;
160 160
161 // TODO Bind the layoutview mode to the current document 161 // TODO Bind the layoutview mode to the current document
162 // var mode = this.application.ninja.currentDocument.layoutMode; 162 // 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, {
165 box[3] = point.y; 165 box[3] = point.y;
166 166
167 //selectionManagerModule.selectionManager.marqueeSelection(box); 167 //selectionManagerModule.selectionManager.marqueeSelection(box);
168 var childNodes = this.application.ninja.currentDocument.documentRoot.childNodes; 168 var childNodes = this.application.ninja.currentDocument.documentRoot.childNodes,
169 selectionController = this.application.ninja.selectionController;
169 childNodes = Array.prototype.slice.call(childNodes, 0); 170 childNodes = Array.prototype.slice.call(childNodes, 0);
170 childNodes.forEach(function(item) { 171 childNodes.forEach(function(item) {
171 if(item.nodeType == 1 && SelectionTool._complicatedCollisionDetection(item, box)) { 172 if(selectionController.isNodeTraversable(item) && SelectionTool._complicatedCollisionDetection(item, box)) {
172 selectedItems.push(item); 173 selectedItems.push(item);
173 } 174 }
174 }); 175 });