aboutsummaryrefslogtreecommitdiff
path: root/js/controllers/selection-controller.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/controllers/selection-controller.js')
-rwxr-xr-xjs/controllers/selection-controller.js29
1 files changed, 15 insertions, 14 deletions
diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js
index 5665b09c..6e40abb5 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 });
@@ -152,7 +152,6 @@ exports.SelectionController = Montage.create(Component, {
152 152
153 selectElement: { 153 selectElement: {
154 value: function(element) { 154 value: function(element) {
155
156 if(this.findSelectedElement(element) === -1) { 155 if(this.findSelectedElement(element) === -1) {
157 156
158 if(this.application.ninja.currentDocument.inExclusion(element) !== -1){ 157 if(this.application.ninja.currentDocument.inExclusion(element) !== -1){
@@ -166,7 +165,7 @@ exports.SelectionController = Montage.create(Component, {
166 165
167 while(outerElement.parentNode && outerElement.parentNode.uuid !== this.selectionContainer.uuid) { 166 while(outerElement.parentNode && outerElement.parentNode.uuid !== this.selectionContainer.uuid) {
168 // If element is higher up than current container then return 167 // If element is higher up than current container then return
169 if(outerElement.id === "UserContent") return; 168 if(outerElement.nodeName === "BODY") return;
170 // else keep going up the chain 169 // else keep going up the chain
171 outerElement = outerElement.parentNode; 170 outerElement = outerElement.parentNode;
172 } 171 }
@@ -247,25 +246,20 @@ exports.SelectionController = Montage.create(Component, {
247 } 246 }
248 }, 247 },
249 248
250 /**
251 * Looks into the selectionObject for the item to be found using it's id
252 *
253 * @return: Item index in the selectionObject if found
254 * -1 if not found
255 */
256 findSelectedElement: { 249 findSelectedElement: {
257 value: function(item) { 250 value: function(item) {
258 // TODO do the loop check in the select element and only use the index here 251 // TODO: Remove this function and use the stage selectable. Then only return a match in the array
259 // return this.application.ninja.selectedElements.indexOf(item); 252 //return this.application.ninja.selectedElements.indexOf(item);
260 253
254 //TODO: Make sure we don't need to loop back to the container element.
261 var itemUUID; 255 var itemUUID;
262 256
263 for(var i=0, uuid; this.application.ninja.selectedElements[i];i++) { 257 for(var i=0, uuid; this.application.ninja.selectedElements[i];i++) {
264 // Check for multiple selection and excluding inner elements 258 // Check for multiple selection and excluding inner elements
265 if(item.parentNode && item.parentNode.id !== "UserContent") { 259 if(item.parentNode && item.parentNode !== this.application.ninja.currentDocument.documentRoot) {
266 var outerElement = item.parentNode; 260 var outerElement = item.parentNode;
267 261
268 while(outerElement.parentNode && outerElement.parentNode.id !== "UserContent") { 262 while(outerElement.parentNode && outerElement.parentNode !== this.application.ninja.currentDocument.documentRoot) {
269 outerElement = outerElement.parentNode; 263 outerElement = outerElement.parentNode;
270 } 264 }
271 265
@@ -281,6 +275,13 @@ exports.SelectionController = Montage.create(Component, {
281 275
282 return -1; 276 return -1;
283 } 277 }
278 },
279
280 isNodeTraversable: {
281 value: function( item ) {
282 if(item.nodeType !== 1) return false;
283 return ((item.nodeName !== "STYLE") && (item.nodeName !== "SCRIPT"));
284 }
284 } 285 }
285 286
286}); 287});