From 2e308be9bec5e06d81b2905b65005a232f0a190d Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Wed, 15 Feb 2012 09:50:20 -0800 Subject: Revert "Creating NinjaTemplate to HTML function" This reverts commit e327eccb93e2bc513fcbb7ab302783d6bce83884. Signed-off-by: Ananya Sen --- js/mediators/io-mediator.js | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'js/mediators') diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index 2008e40f..599b7d84 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js @@ -142,7 +142,12 @@ exports.IoMediator = Montage.create(Component, { // switch (file.mode) { case 'html': - contents = this.parseNinjaTemplateToHtml(file); + file.document.content.document.body.innerHTML = file.body; + file.document.content.document.head.innerHTML = file.head; + if (file.style) { + file.document.content.document.head.getElementsByTagName('style')[0].innerHTML = this.getCssFromRules(file.style.cssRules); + } + contents = file.document.content.document.documentElement.outerHTML; break; default: contents = file.content; @@ -184,21 +189,6 @@ exports.IoMediator = Montage.create(Component, { } }, //////////////////////////////////////////////////////////////////// - //TODO: Expand to allow more templates - parseNinjaTemplateToHtml: { - enumerable: false, - value: function (template) { - // - template.document.content.document.body.innerHTML = template.body; - template.document.content.document.head.innerHTML = template.head; - //TODO: Remove temp fix for styles - if (template.style) { - template.document.content.document.head.getElementsByTagName('style')[0].innerHTML = this.getCssFromRules(template.style.cssRules); - } - return template.document.content.document.documentElement.outerHTML; - } - }, - //////////////////////////////////////////////////////////////////// //Method to return a string from CSS rules (to be saved to a file) getCssFromRules: { enumerable: false, -- cgit v1.2.3 From 56d2a8d11a73cd04c7f1bc20d1ded52b9c1242f2 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Wed, 15 Feb 2012 10:54:38 -0800 Subject: Revert "Revert "Creating NinjaTemplate to HTML function"" This reverts commit 2e308be9bec5e06d81b2905b65005a232f0a190d. Signed-off-by: Ananya Sen --- js/mediators/io-mediator.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'js/mediators') diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index 599b7d84..2008e40f 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js @@ -142,12 +142,7 @@ exports.IoMediator = Montage.create(Component, { // switch (file.mode) { case 'html': - file.document.content.document.body.innerHTML = file.body; - file.document.content.document.head.innerHTML = file.head; - if (file.style) { - file.document.content.document.head.getElementsByTagName('style')[0].innerHTML = this.getCssFromRules(file.style.cssRules); - } - contents = file.document.content.document.documentElement.outerHTML; + contents = this.parseNinjaTemplateToHtml(file); break; default: contents = file.content; @@ -189,6 +184,21 @@ exports.IoMediator = Montage.create(Component, { } }, //////////////////////////////////////////////////////////////////// + //TODO: Expand to allow more templates + parseNinjaTemplateToHtml: { + enumerable: false, + value: function (template) { + // + template.document.content.document.body.innerHTML = template.body; + template.document.content.document.head.innerHTML = template.head; + //TODO: Remove temp fix for styles + if (template.style) { + template.document.content.document.head.getElementsByTagName('style')[0].innerHTML = this.getCssFromRules(template.style.cssRules); + } + return template.document.content.document.documentElement.outerHTML; + } + }, + //////////////////////////////////////////////////////////////////// //Method to return a string from CSS rules (to be saved to a file) getCssFromRules: { enumerable: false, -- cgit v1.2.3 From f3b6a62f110be31a9438a6172694b111ffd4d507 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Fri, 17 Feb 2012 11:07:42 -0800 Subject: -added keyboard control for saving documents -mark html design view when element is added or deleted Signed-off-by: Ananya Sen --- js/mediators/keyboard-mediator.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'js/mediators') diff --git a/js/mediators/keyboard-mediator.js b/js/mediators/keyboard-mediator.js index a1fdead3..e348a09b 100755 --- a/js/mediators/keyboard-mediator.js +++ b/js/mediators/keyboard-mediator.js @@ -85,7 +85,7 @@ exports.KeyboardMediator = Montage.create(Component, { handleKeydown: { value: function(evt) { - if(document.activeElement.nodeName !== "BODY") { + if((document.activeElement.nodeName !== "BODY") && (this.application.ninja.documentController.activeDocument.currentView === "design")) { // Don't do anything if an input or other control is focused return; } @@ -110,6 +110,13 @@ exports.KeyboardMediator = Montage.create(Component, { return; } + // Check if cmd+s/ctrl+s for Save (Windows/Mac) + if ((evt.keyCode == Keyboard.S) && (evt.ctrlKey || evt.metaKey) && !evt.shiftKey) { + NJevent("executeSave"); + evt.preventDefault(); + return; + } + // Check if cmd+shift+z for Redo (Mac) if ((evt.keyCode == Keyboard.Z) && evt.metaKey && evt.shiftKey) { NJevent("executeRedo"); -- cgit v1.2.3 From 3b862fe489a3320882f91ab56781fc5dc400c3d1 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Fri, 17 Feb 2012 11:26:02 -0800 Subject: changed the document dirtying logic to be done in the feature that edits the document. Signed-off-by: Ananya Sen --- js/mediators/element-mediator.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'js/mediators') diff --git a/js/mediators/element-mediator.js b/js/mediators/element-mediator.js index 95aec2a3..e1eadda9 100755 --- a/js/mediators/element-mediator.js +++ b/js/mediators/element-mediator.js @@ -101,7 +101,10 @@ exports.ElementMediator = Montage.create(NJComponent, { { el.elementModel.controller["set3DProperties"](el, [p3d], 0, true); } - if(!noEvent) NJevent("elementAdded", el); + if(!noEvent) { + this.application.ninja.documentController.activeDocument.dirtyFlag = true; + NJevent("elementAdded", el); + } } }, @@ -127,6 +130,7 @@ exports.ElementMediator = Montage.create(NJComponent, { _removeElement: { value: function(el, rules) { ElementController.removeElement(el, rules); + this.application.ninja.documentController.activeDocument.dirtyFlag = true; NJevent("elementDeleted", el); } }, -- cgit v1.2.3 From 2ef2ad33ff3f6ee1afd1e2a5c3189278f8fd46f4 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Fri, 17 Feb 2012 11:35:49 -0800 Subject: mark document on setting color, properties and stroke. Signed-off-by: Ananya Sen --- js/mediators/element-mediator.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'js/mediators') diff --git a/js/mediators/element-mediator.js b/js/mediators/element-mediator.js index e1eadda9..ad01fe2d 100755 --- a/js/mediators/element-mediator.js +++ b/js/mediators/element-mediator.js @@ -189,6 +189,8 @@ exports.ElementMediator = Montage.create(NJComponent, { NJUtils.makeElementModel(el, "Canvas", "block", true); } + this.application.ninja.documentController.activeDocument.dirtyFlag = true; + return el.elementModel.controller["setShapeProperty"](el, prop, value); } }, @@ -256,6 +258,8 @@ exports.ElementMediator = Montage.create(NJComponent, { item.elementModel.controller["setAttribute"](item, att, value); + this.application.ninja.documentController.activeDocument.dirtyFlag = true; + NJevent("attribute" + eventType, {type : "setAttribute", source: source, data: {"els": el, "prop": att, "value": value}, redraw: null}); } }, @@ -328,6 +332,8 @@ exports.ElementMediator = Montage.create(NJComponent, { el.elementModel.controller["setProperty"](el, p, value[i]); } + this.application.ninja.documentController.activeDocument.dirtyFlag = true; + NJevent("element" + eventType, {type : "setProperty", source: source, data: {"els": els, "prop": p, "value": value}, redraw: null}); } }, @@ -387,6 +393,8 @@ exports.ElementMediator = Montage.create(NJComponent, { el.elementModel.controller["setProperties"](el, props, i); } + this.application.ninja.documentController.activeDocument.dirtyFlag = true; + NJevent("element" + eventType, {type : "setProperties", source: source, data: {"els": els, "prop": props, "value": props}, redraw: null}); } }, @@ -459,6 +467,8 @@ exports.ElementMediator = Montage.create(NJComponent, { el.elementModel.controller["set3DProperties"](el, props, i, update3DModel); } + this.application.ninja.documentController.activeDocument.dirtyFlag = true; + NJevent("element" + eventType, {type : "set3DProperties", source: source, data: {"els": els, "prop": "matrix", "value": props}, redraw: null}); } }, @@ -543,6 +553,8 @@ exports.ElementMediator = Montage.create(NJComponent, { el.elementModel.controller["setColor"](el, value, isFill); } + this.application.ninja.documentController.activeDocument.dirtyFlag = true; + NJevent("element" + eventType, {type : "setColor", source: source, data: {"els": els, "prop": "color", "value": value, "isFill": isFill}, redraw: null}); } }, @@ -624,6 +636,8 @@ exports.ElementMediator = Montage.create(NJComponent, { el.elementModel.controller["setStroke"](el, value); } + this.application.ninja.documentController.activeDocument.dirtyFlag = true; + NJevent("element" + eventType, {type : "setStroke", source: source, data: {"els": els, "prop": "stroke", "value": value}, redraw: null}); } }, @@ -698,6 +712,8 @@ exports.ElementMediator = Montage.create(NJComponent, { } else { + this.application.ninja.documentController.activeDocument.dirtyFlag = true; + NJevent("elementChange", {type : "setMatrix", source: null, data: {"els": [el], "prop": "matrix", "value": mat}, redraw: null}); } } -- cgit v1.2.3 From a7e3ef9f80d5e29515c9f8dd5374c89b9d2496de Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Fri, 17 Feb 2012 12:39:12 -0800 Subject: use method to update dirtyFlag Signed-off-by: Ananya Sen --- js/mediators/element-mediator.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'js/mediators') diff --git a/js/mediators/element-mediator.js b/js/mediators/element-mediator.js index ad01fe2d..559cb44c 100755 --- a/js/mediators/element-mediator.js +++ b/js/mediators/element-mediator.js @@ -102,7 +102,7 @@ exports.ElementMediator = Montage.create(NJComponent, { el.elementModel.controller["set3DProperties"](el, [p3d], 0, true); } if(!noEvent) { - this.application.ninja.documentController.activeDocument.dirtyFlag = true; + this.application.ninja.documentController.activeDocument.markDocumentEditted(); NJevent("elementAdded", el); } } @@ -130,7 +130,7 @@ exports.ElementMediator = Montage.create(NJComponent, { _removeElement: { value: function(el, rules) { ElementController.removeElement(el, rules); - this.application.ninja.documentController.activeDocument.dirtyFlag = true; + this.application.ninja.documentController.activeDocument.markDocumentEditted(); NJevent("elementDeleted", el); } }, @@ -189,7 +189,7 @@ exports.ElementMediator = Montage.create(NJComponent, { NJUtils.makeElementModel(el, "Canvas", "block", true); } - this.application.ninja.documentController.activeDocument.dirtyFlag = true; + this.application.ninja.documentController.activeDocument.markDocumentEditted(); return el.elementModel.controller["setShapeProperty"](el, prop, value); } @@ -258,7 +258,7 @@ exports.ElementMediator = Montage.create(NJComponent, { item.elementModel.controller["setAttribute"](item, att, value); - this.application.ninja.documentController.activeDocument.dirtyFlag = true; + this.application.ninja.documentController.activeDocument.markDocumentEditted(); NJevent("attribute" + eventType, {type : "setAttribute", source: source, data: {"els": el, "prop": att, "value": value}, redraw: null}); } @@ -332,7 +332,7 @@ exports.ElementMediator = Montage.create(NJComponent, { el.elementModel.controller["setProperty"](el, p, value[i]); } - this.application.ninja.documentController.activeDocument.dirtyFlag = true; + this.application.ninja.documentController.activeDocument.markDocumentEditted(); NJevent("element" + eventType, {type : "setProperty", source: source, data: {"els": els, "prop": p, "value": value}, redraw: null}); } @@ -393,7 +393,7 @@ exports.ElementMediator = Montage.create(NJComponent, { el.elementModel.controller["setProperties"](el, props, i); } - this.application.ninja.documentController.activeDocument.dirtyFlag = true; + this.application.ninja.documentController.activeDocument.markDocumentEditted(); NJevent("element" + eventType, {type : "setProperties", source: source, data: {"els": els, "prop": props, "value": props}, redraw: null}); } @@ -467,7 +467,7 @@ exports.ElementMediator = Montage.create(NJComponent, { el.elementModel.controller["set3DProperties"](el, props, i, update3DModel); } - this.application.ninja.documentController.activeDocument.dirtyFlag = true; + this.application.ninja.documentController.activeDocument.markDocumentEditted(); NJevent("element" + eventType, {type : "set3DProperties", source: source, data: {"els": els, "prop": "matrix", "value": props}, redraw: null}); } @@ -553,7 +553,7 @@ exports.ElementMediator = Montage.create(NJComponent, { el.elementModel.controller["setColor"](el, value, isFill); } - this.application.ninja.documentController.activeDocument.dirtyFlag = true; + this.application.ninja.documentController.activeDocument.markDocumentEditted(); NJevent("element" + eventType, {type : "setColor", source: source, data: {"els": els, "prop": "color", "value": value, "isFill": isFill}, redraw: null}); } @@ -636,7 +636,7 @@ exports.ElementMediator = Montage.create(NJComponent, { el.elementModel.controller["setStroke"](el, value); } - this.application.ninja.documentController.activeDocument.dirtyFlag = true; + this.application.ninja.documentController.activeDocument.markDocumentEditted(); NJevent("element" + eventType, {type : "setStroke", source: source, data: {"els": els, "prop": "stroke", "value": value}, redraw: null}); } @@ -712,7 +712,7 @@ exports.ElementMediator = Montage.create(NJComponent, { } else { - this.application.ninja.documentController.activeDocument.dirtyFlag = true; + this.application.ninja.documentController.activeDocument.markDocumentEditted(); NJevent("elementChange", {type : "setMatrix", source: null, data: {"els": [el], "prop": "matrix", "value": mat}, redraw: null}); } -- cgit v1.2.3 From 96178309ddcdb54c0c451b69ea6fb8cdf76fcf62 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Fri, 17 Feb 2012 12:54:07 -0800 Subject: renamed methods to use better words Signed-off-by: Ananya Sen --- js/mediators/element-mediator.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'js/mediators') diff --git a/js/mediators/element-mediator.js b/js/mediators/element-mediator.js index 559cb44c..7dad7aca 100755 --- a/js/mediators/element-mediator.js +++ b/js/mediators/element-mediator.js @@ -102,7 +102,7 @@ exports.ElementMediator = Montage.create(NJComponent, { el.elementModel.controller["set3DProperties"](el, [p3d], 0, true); } if(!noEvent) { - this.application.ninja.documentController.activeDocument.markDocumentEditted(); + this.application.ninja.documentController.activeDocument.markEdited(); NJevent("elementAdded", el); } } @@ -130,7 +130,7 @@ exports.ElementMediator = Montage.create(NJComponent, { _removeElement: { value: function(el, rules) { ElementController.removeElement(el, rules); - this.application.ninja.documentController.activeDocument.markDocumentEditted(); + this.application.ninja.documentController.activeDocument.markEdited(); NJevent("elementDeleted", el); } }, @@ -189,7 +189,7 @@ exports.ElementMediator = Montage.create(NJComponent, { NJUtils.makeElementModel(el, "Canvas", "block", true); } - this.application.ninja.documentController.activeDocument.markDocumentEditted(); + this.application.ninja.documentController.activeDocument.markEdited(); return el.elementModel.controller["setShapeProperty"](el, prop, value); } @@ -258,7 +258,7 @@ exports.ElementMediator = Montage.create(NJComponent, { item.elementModel.controller["setAttribute"](item, att, value); - this.application.ninja.documentController.activeDocument.markDocumentEditted(); + this.application.ninja.documentController.activeDocument.markEdited(); NJevent("attribute" + eventType, {type : "setAttribute", source: source, data: {"els": el, "prop": att, "value": value}, redraw: null}); } @@ -332,7 +332,7 @@ exports.ElementMediator = Montage.create(NJComponent, { el.elementModel.controller["setProperty"](el, p, value[i]); } - this.application.ninja.documentController.activeDocument.markDocumentEditted(); + this.application.ninja.documentController.activeDocument.markEdited(); NJevent("element" + eventType, {type : "setProperty", source: source, data: {"els": els, "prop": p, "value": value}, redraw: null}); } @@ -393,7 +393,7 @@ exports.ElementMediator = Montage.create(NJComponent, { el.elementModel.controller["setProperties"](el, props, i); } - this.application.ninja.documentController.activeDocument.markDocumentEditted(); + this.application.ninja.documentController.activeDocument.markEdited(); NJevent("element" + eventType, {type : "setProperties", source: source, data: {"els": els, "prop": props, "value": props}, redraw: null}); } @@ -467,7 +467,7 @@ exports.ElementMediator = Montage.create(NJComponent, { el.elementModel.controller["set3DProperties"](el, props, i, update3DModel); } - this.application.ninja.documentController.activeDocument.markDocumentEditted(); + this.application.ninja.documentController.activeDocument.markEdited(); NJevent("element" + eventType, {type : "set3DProperties", source: source, data: {"els": els, "prop": "matrix", "value": props}, redraw: null}); } @@ -553,7 +553,7 @@ exports.ElementMediator = Montage.create(NJComponent, { el.elementModel.controller["setColor"](el, value, isFill); } - this.application.ninja.documentController.activeDocument.markDocumentEditted(); + this.application.ninja.documentController.activeDocument.markEdited(); NJevent("element" + eventType, {type : "setColor", source: source, data: {"els": els, "prop": "color", "value": value, "isFill": isFill}, redraw: null}); } @@ -636,7 +636,7 @@ exports.ElementMediator = Montage.create(NJComponent, { el.elementModel.controller["setStroke"](el, value); } - this.application.ninja.documentController.activeDocument.markDocumentEditted(); + this.application.ninja.documentController.activeDocument.markEdited(); NJevent("element" + eventType, {type : "setStroke", source: source, data: {"els": els, "prop": "stroke", "value": value}, redraw: null}); } @@ -712,7 +712,7 @@ exports.ElementMediator = Montage.create(NJComponent, { } else { - this.application.ninja.documentController.activeDocument.markDocumentEditted(); + this.application.ninja.documentController.activeDocument.markEdited(); NJevent("elementChange", {type : "setMatrix", source: null, data: {"els": [el], "prop": "matrix", "value": mat}, redraw: null}); } -- cgit v1.2.3 From c2a5918480adae0124e1dc2531c019562f1e3e60 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Sat, 18 Feb 2012 18:42:43 -0800 Subject: doc.markEdited() removed from element-mediator, for style changes, as per teams suggestion Signed-off-by: Ananya Sen --- js/mediators/element-mediator.js | 16 ---------------- js/mediators/keyboard-mediator.js | 3 ++- 2 files changed, 2 insertions(+), 17 deletions(-) (limited to 'js/mediators') diff --git a/js/mediators/element-mediator.js b/js/mediators/element-mediator.js index 7dad7aca..6088aeab 100755 --- a/js/mediators/element-mediator.js +++ b/js/mediators/element-mediator.js @@ -189,8 +189,6 @@ exports.ElementMediator = Montage.create(NJComponent, { NJUtils.makeElementModel(el, "Canvas", "block", true); } - this.application.ninja.documentController.activeDocument.markEdited(); - return el.elementModel.controller["setShapeProperty"](el, prop, value); } }, @@ -258,8 +256,6 @@ exports.ElementMediator = Montage.create(NJComponent, { item.elementModel.controller["setAttribute"](item, att, value); - this.application.ninja.documentController.activeDocument.markEdited(); - NJevent("attribute" + eventType, {type : "setAttribute", source: source, data: {"els": el, "prop": att, "value": value}, redraw: null}); } }, @@ -332,8 +328,6 @@ exports.ElementMediator = Montage.create(NJComponent, { el.elementModel.controller["setProperty"](el, p, value[i]); } - this.application.ninja.documentController.activeDocument.markEdited(); - NJevent("element" + eventType, {type : "setProperty", source: source, data: {"els": els, "prop": p, "value": value}, redraw: null}); } }, @@ -393,8 +387,6 @@ exports.ElementMediator = Montage.create(NJComponent, { el.elementModel.controller["setProperties"](el, props, i); } - this.application.ninja.documentController.activeDocument.markEdited(); - NJevent("element" + eventType, {type : "setProperties", source: source, data: {"els": els, "prop": props, "value": props}, redraw: null}); } }, @@ -467,8 +459,6 @@ exports.ElementMediator = Montage.create(NJComponent, { el.elementModel.controller["set3DProperties"](el, props, i, update3DModel); } - this.application.ninja.documentController.activeDocument.markEdited(); - NJevent("element" + eventType, {type : "set3DProperties", source: source, data: {"els": els, "prop": "matrix", "value": props}, redraw: null}); } }, @@ -553,8 +543,6 @@ exports.ElementMediator = Montage.create(NJComponent, { el.elementModel.controller["setColor"](el, value, isFill); } - this.application.ninja.documentController.activeDocument.markEdited(); - NJevent("element" + eventType, {type : "setColor", source: source, data: {"els": els, "prop": "color", "value": value, "isFill": isFill}, redraw: null}); } }, @@ -636,8 +624,6 @@ exports.ElementMediator = Montage.create(NJComponent, { el.elementModel.controller["setStroke"](el, value); } - this.application.ninja.documentController.activeDocument.markEdited(); - NJevent("element" + eventType, {type : "setStroke", source: source, data: {"els": els, "prop": "stroke", "value": value}, redraw: null}); } }, @@ -712,8 +698,6 @@ exports.ElementMediator = Montage.create(NJComponent, { } else { - this.application.ninja.documentController.activeDocument.markEdited(); - NJevent("elementChange", {type : "setMatrix", source: null, data: {"els": [el], "prop": "matrix", "value": mat}, redraw: null}); } } diff --git a/js/mediators/keyboard-mediator.js b/js/mediators/keyboard-mediator.js index e348a09b..4011db69 100755 --- a/js/mediators/keyboard-mediator.js +++ b/js/mediators/keyboard-mediator.js @@ -85,7 +85,8 @@ exports.KeyboardMediator = Montage.create(Component, { handleKeydown: { value: function(evt) { - if((document.activeElement.nodeName !== "BODY") && (this.application.ninja.documentController.activeDocument.currentView === "design")) { + if((document.activeElement.nodeName !== "BODY") && (!!this.application.ninja.documentController.activeDocument) + && (this.application.ninja.documentController.activeDocument.currentView === "design")) { // Don't do anything if an input or other control is focused return; } -- cgit v1.2.3 From 50e555587d3a97dbfc75c33f3589cfccee392180 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Mon, 20 Feb 2012 12:04:57 -0800 Subject: - moved tools specific keyboard controls for desing view only - stopped snapping when all documents are closed Signed-off-by: Ananya Sen --- js/mediators/keyboard-mediator.js | 220 ++++++++++++++++++++------------------ 1 file changed, 115 insertions(+), 105 deletions(-) (limited to 'js/mediators') diff --git a/js/mediators/keyboard-mediator.js b/js/mediators/keyboard-mediator.js index 40b26582..0282060f 100755 --- a/js/mediators/keyboard-mediator.js +++ b/js/mediators/keyboard-mediator.js @@ -85,23 +85,115 @@ exports.KeyboardMediator = Montage.create(Component, { handleKeydown: { value: function(evt) { - if((document.activeElement.nodeName !== "BODY") && (!!this.application.ninja.documentController.activeDocument) - && (this.application.ninja.documentController.activeDocument.currentView === "design")) { - // Don't do anything if an input or other control is focused - return; - } - // Disable defaults for the Arrow Keys - if((evt.keyCode == Keyboard.LEFT) || (evt.keyCode == Keyboard.RIGHT) || (evt.keyCode == Keyboard.UP) || (evt.keyCode == Keyboard.DOWN)) { - evt.preventDefault(); - } + //keyboard controls for html design view + if((!!this.application.ninja.documentController.activeDocument) && (this.application.ninja.documentController.activeDocument.currentView === "design")){ + + // Don't do anything if an input or other control is focused + if(document.activeElement.nodeName !== "BODY") { + return; + } + + // Disable defaults for the Arrow Keys + if((evt.keyCode == Keyboard.LEFT) || (evt.keyCode == Keyboard.RIGHT) || (evt.keyCode == Keyboard.UP) || (evt.keyCode == Keyboard.DOWN)) { + evt.preventDefault(); + } + + // Check DELETE OR BACKSPACE + if((evt.keyCode == Keyboard.BACKSPACE) || (evt.keyCode == Keyboard.DELETE)) { + evt.stopImmediatePropagation(); + evt.preventDefault(); + NJevent("deleting"); + return; + } + + + // Shortcut for Selection Tool is V + if(evt.keyCode === Keyboard.V) { + evt.preventDefault(); + this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[0]}); + return; + } + + // Shortcut for Tag Tool is D + if(evt.keyCode === Keyboard.D){ + evt.preventDefault(); + this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[4]}); + return; + } + + // Shortcut for Rotate Tool is W + if(evt.keyCode === Keyboard.W){ + evt.preventDefault(); + this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[2]}); + return; + } + + // Shortcut for Translate Tool is G + if(evt.keyCode === Keyboard.G){ + evt.preventDefault(); + this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[3]}); + return; + } + + // Shortcut for Rectangle Tool is R + // unless the user is pressing the command key. + // If the user is pressing the command key, they want to refresh the browser. + if((evt.keyCode === Keyboard.R) && !evt.metaKey) { + evt.preventDefault(); + this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[7]}); + this.application.ninja.handleSelectSubTool({"detail": this.application.ninja.toolsData.defaultToolsData[7].subtools[1]}); + return; + } + + // Shortcut for Oval Tool is O + if(evt.keyCode === Keyboard.O) { + evt.preventDefault(); + this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[7]}); + this.application.ninja.handleSelectSubTool({"detail": this.application.ninja.toolsData.defaultToolsData[7].subtools[0]}); + return; + } + + // Shortcut for Line Tool is L + if(evt.keyCode === Keyboard.L ) { + evt.preventDefault(); + this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[7]}); + this.application.ninja.handleSelectSubTool({"detail": this.application.ninja.toolsData.defaultToolsData[7].subtools[2]}); + return; + } + + if(evt.keyCode === Keyboard.H ) { + evt.preventDefault(); + this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[15]}); + return; + } + + if(evt.keyCode === Keyboard.Z ) { + evt.preventDefault(); + this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[16]}); + return; + } + + // Check if cmd+a/ctrl+a for Select All + if((evt.keyCode == Keyboard.A) && (evt.ctrlKey || evt.metaKey)) { + NJevent("selectAll"); + return; + } + + if(evt.keyCode === Keyboard.ESCAPE){//ESC key + //console.log("ESC key pressed"); + if(this.application.ninja.toolsData) this.application.ninja.toolsData.selectedToolInstance.HandleEscape(evt); + //menuViewManagerModule.MenuViewManager.closeMenu("mainMenuBar"); + } + + + if((evt.keyCode == Keyboard.ENTER) && (evt.ctrlKey || evt.metaKey)) { + this.application.ninja.executeChromePreview(); + return; + } + + if(this.application.ninja.toolsData) this.application.ninja.toolsData.selectedToolInstance.HandleKeyPress(evt); - // Check DELETE OR BACKSPACE - if((evt.keyCode == Keyboard.BACKSPACE) || (evt.keyCode == Keyboard.DELETE)) { - evt.stopImmediatePropagation(); - evt.preventDefault(); - NJevent("deleting"); - return; } // Check if cmd+z/ctrl+z for Undo (Windows/Mac) @@ -132,103 +224,21 @@ exports.KeyboardMediator = Montage.create(Component, { return; } - // Shortcut for Selection Tool is V - if(evt.keyCode === Keyboard.V) { - evt.preventDefault(); - this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[0]}); - return; - } - - // Shortcut for Tag Tool is D - if(evt.keyCode === Keyboard.D){ - evt.preventDefault(); - this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[4]}); - return; - } - - // Shortcut for Rotate Tool is W - if(evt.keyCode === Keyboard.W){ - evt.preventDefault(); - this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[2]}); - return; - } - - // Shortcut for Translate Tool is G - if(evt.keyCode === Keyboard.G){ - evt.preventDefault(); - this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[3]}); - return; - } - - // Shortcut for Rectangle Tool is R - // unless the user is pressing the command key. - // If the user is pressing the command key, they want to refresh the browser. - if((evt.keyCode === Keyboard.R) && !evt.metaKey) { - evt.preventDefault(); - this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[7]}); - this.application.ninja.handleSelectSubTool({"detail": this.application.ninja.toolsData.defaultToolsData[7].subtools[1]}); - return; - } - - // Shortcut for Oval Tool is O - if(evt.keyCode === Keyboard.O) { - evt.preventDefault(); - this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[7]}); - this.application.ninja.handleSelectSubTool({"detail": this.application.ninja.toolsData.defaultToolsData[7].subtools[0]}); - return; - } - - // Shortcut for Line Tool is L - if(evt.keyCode === Keyboard.L ) { - evt.preventDefault(); - this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[7]}); - this.application.ninja.handleSelectSubTool({"detail": this.application.ninja.toolsData.defaultToolsData[7].subtools[2]}); - return; - } - - if(evt.keyCode === Keyboard.H ) { - evt.preventDefault(); - this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[15]}); - return; - } - - if(evt.keyCode === Keyboard.Z ) { - evt.preventDefault(); - this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[16]}); - return; - } - - // Check if cmd+a/ctrl+a for Select All - if((evt.keyCode == Keyboard.A) && (evt.ctrlKey || evt.metaKey)) { - NJevent("selectAll"); - return; - } - - if(evt.keyCode === Keyboard.ESCAPE){//ESC key - //console.log("ESC key pressed"); - if(this.application.ninja.toolsData) this.application.ninja.toolsData.selectedToolInstance.HandleEscape(evt); - //menuViewManagerModule.MenuViewManager.closeMenu("mainMenuBar"); - } - - // Check if cmd+a/ctrl+a for Select All - if((evt.keyCode == Keyboard.ENTER) && (evt.ctrlKey || evt.metaKey)) { - this.application.ninja.executeChromePreview(); - return; - } - - if(this.application.ninja.toolsData) this.application.ninja.toolsData.selectedToolInstance.HandleKeyPress(evt); } }, handleKeyup: { value: function(evt) { - if(document.activeElement.nodeName !== "BODY") { - // Don't do anything if an input or other control is focused - return; + //keyboard controls for html design view + if((!!this.application.ninja.documentController.activeDocument) && (this.application.ninja.documentController.activeDocument.currentView === "design")){ + if(document.activeElement.nodeName !== "BODY") { + // Don't do anything if an input or other control is focused + return; + } + + if(this.application.ninja.toolsData) this.application.ninja.toolsData.selectedToolInstance.HandleKeyUp(evt); } - - if(this.application.ninja.toolsData) this.application.ninja.toolsData.selectedToolInstance.HandleKeyUp(evt); } }, -- cgit v1.2.3 From 1b1a51370feffc1abbd1ad558cbf4d5d8163ef6f Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Mon, 20 Feb 2012 22:23:28 -0800 Subject: cleanup Signed-off-by: Valerio Virgillito --- js/mediators/element-mediator.js | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'js/mediators') diff --git a/js/mediators/element-mediator.js b/js/mediators/element-mediator.js index 95aec2a3..8481f557 100755 --- a/js/mediators/element-mediator.js +++ b/js/mediators/element-mediator.js @@ -28,13 +28,7 @@ exports.ElementMediator = Montage.create(NJComponent, { // TODO use the specific controller to be able to subclass the functionality handleElementAdding: { value: function(event) { - /* - var cmd = ElementControllerCommands.addElementCommand(event.detail.el, event.detail.data); - NJevent("sendToUndo", cmd); - cmd.execute(); - */ this.addElement(event.detail.el, event.detail.data); - } }, @@ -97,8 +91,7 @@ exports.ElementMediator = Montage.create(NJComponent, { value: function(el, rules, noEvent) { ElementController.addElement(el, rules); var p3d = this.get3DProperties(el); - if(p3d) - { + if(p3d) { el.elementModel.controller["set3DProperties"](el, [p3d], 0, true); } if(!noEvent) NJevent("elementAdded", el); -- cgit v1.2.3 From b1daf0b285a4a96bfd0086709c20e3682d75551a Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 21 Feb 2012 14:32:17 -0800 Subject: fixing the dirty flag and removing sass changes Signed-off-by: Valerio Virgillito --- js/mediators/element-mediator.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/mediators') diff --git a/js/mediators/element-mediator.js b/js/mediators/element-mediator.js index 6088aeab..95a72c89 100755 --- a/js/mediators/element-mediator.js +++ b/js/mediators/element-mediator.js @@ -102,7 +102,7 @@ exports.ElementMediator = Montage.create(NJComponent, { el.elementModel.controller["set3DProperties"](el, [p3d], 0, true); } if(!noEvent) { - this.application.ninja.documentController.activeDocument.markEdited(); + this.application.ninja.documentController.activeDocument.needsSave = true; NJevent("elementAdded", el); } } @@ -130,7 +130,7 @@ exports.ElementMediator = Montage.create(NJComponent, { _removeElement: { value: function(el, rules) { ElementController.removeElement(el, rules); - this.application.ninja.documentController.activeDocument.markEdited(); + this.application.ninja.documentController.activeDocument.needsSave = true; NJevent("elementDeleted", el); } }, -- cgit v1.2.3