aboutsummaryrefslogtreecommitdiff
path: root/js/mediators
diff options
context:
space:
mode:
Diffstat (limited to 'js/mediators')
-rw-r--r--js/mediators/io-mediator.js44
-rwxr-xr-xjs/mediators/keyboard-mediator.js14
2 files changed, 51 insertions, 7 deletions
diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js
index 733e44b2..e763c67c 100644
--- a/js/mediators/io-mediator.js
+++ b/js/mediators/io-mediator.js
@@ -39,6 +39,12 @@ exports.IoMediator = Montage.create(Component, {
39 enumerable: false, 39 enumerable: false,
40 value: ProjectIo 40 value: ProjectIo
41 }, 41 },
42 ////////////////////////////////////////////////////////////////////
43 //
44 appTemplatesUrl: {
45 enumerable: false,
46 value: new RegExp(chrome.extension.getURL('js/document/templates/montage-html/'), 'gi')
47 },
42 //////////////////////////////////////////////////////////////////// 48 ////////////////////////////////////////////////////////////////////
43 // 49 //
44 fileNew: { 50 fileNew: {
@@ -209,8 +215,7 @@ exports.IoMediator = Montage.create(Component, {
209 template.document.content.document.head.innerHTML = template.head; 215 template.document.content.document.head.innerHTML = template.head;
210 //Getting all CSS (style or link) tags 216 //Getting all CSS (style or link) tags
211 var styletags = template.document.content.document.getElementsByTagName('style'), 217 var styletags = template.document.content.document.getElementsByTagName('style'),
212 linktags = template.document.content.document.getElementsByTagName('link'), 218 linktags = template.document.content.document.getElementsByTagName('link');
213 url = new RegExp(chrome.extension.getURL('js/document/templates/montage-html/'), 'gi'); //TODO: Make public into var
214 //Looping through link tags and removing file recreated elements 219 //Looping through link tags and removing file recreated elements
215 for (var j in styletags) { 220 for (var j in styletags) {
216 if (styletags[j].getAttribute) { 221 if (styletags[j].getAttribute) {
@@ -260,6 +265,17 @@ exports.IoMediator = Montage.create(Component, {
260 var styleCounter = 0, 265 var styleCounter = 0,
261 docStyles = template.document.content.document.getElementsByTagName('style'), 266 docStyles = template.document.content.document.getElementsByTagName('style'),
262 docLinks = template.document.content.document.getElementsByTagName('link'); 267 docLinks = template.document.content.document.getElementsByTagName('link');
268 //Removing Ninja Data Attributes
269 for (var n in docLinks) {
270 if (docLinks[n].attributes) {
271 for (var m in docLinks[n].attributes) {
272 if (docLinks[n].attributes[m].name && docLinks[n].attributes[m].name.indexOf('data-ninja')!=-1) {
273 docLinks[n].removeAttribute(docLinks[n].attributes[m].name);
274 }
275 }
276 }
277 }
278 //
263 for(var i in template.css) { 279 for(var i in template.css) {
264 if (template.css[i].ownerNode) { 280 if (template.css[i].ownerNode) {
265 if (template.css[i].ownerNode.getAttribute) { 281 if (template.css[i].ownerNode.getAttribute) {
@@ -268,6 +284,22 @@ exports.IoMediator = Montage.create(Component, {
268 docStyles[styleCounter].innerHTML = this.getCssFromRules(template.css[i].cssRules); 284 docStyles[styleCounter].innerHTML = this.getCssFromRules(template.css[i].cssRules);
269 styleCounter++; 285 styleCounter++;
270 } else { 286 } else {
287 //Checking for attributes to be added to tag upon saving
288 for (var k in docLinks) {
289 if (docLinks[k].getAttribute) {
290 if (docLinks[k].getAttribute('href') && ('/'+docLinks[k].getAttribute('href')) === template.css[i].ownerNode.getAttribute('data-ninja-file-url')) {
291 for (var l in template.css[i].ownerNode.attributes) {
292 if (template.css[i].ownerNode.attributes[l].value) {
293 if (template.css[i].ownerNode.attributes[l].name.indexOf('data-ninja')!=-1) {
294 //Ninja attribute...
295 } else {
296 docLinks[k].setAttribute(template.css[i].ownerNode.attributes[l].name, template.css[i].ownerNode.attributes[l].value);
297 }
298 }
299 }
300 }
301 }
302 }
271 //Saving data from rules array converted to string into <link> file 303 //Saving data from rules array converted to string into <link> file
272 var save = this.fio.saveFile({uri: template.css[i].ownerNode.getAttribute('data-ninja-uri'), contents: this.getCssFromRules(template.css[i].cssRules)}); 304 var save = this.fio.saveFile({uri: template.css[i].ownerNode.getAttribute('data-ninja-uri'), contents: this.getCssFromRules(template.css[i].cssRules)});
273 } 305 }
@@ -318,7 +350,7 @@ exports.IoMediator = Montage.create(Component, {
318 webgltag.innerHTML = json; 350 webgltag.innerHTML = json;
319 } 351 }
320 // 352 //
321 return this.getPrettyHtml(template.document.content.document.documentElement.outerHTML.replace(url, '')); 353 return this.getPrettyHtml(template.document.content.document.documentElement.outerHTML.replace(this.appTemplatesUrl, ''));
322 } 354 }
323 }, 355 },
324 //////////////////////////////////////////////////////////////////// 356 ////////////////////////////////////////////////////////////////////
@@ -327,7 +359,7 @@ exports.IoMediator = Montage.create(Component, {
327 enumerable: false, 359 enumerable: false,
328 value: function (list) { 360 value: function (list) {
329 //Variable to store CSS definitions 361 //Variable to store CSS definitions
330 var i, str, url, css = ''; 362 var i, str, css = '';
331 //Looping through list 363 //Looping through list
332 if (list && list.length > 0) { 364 if (list && list.length > 0) {
333 //Adding each list item to string and also adding breaks 365 //Adding each list item to string and also adding breaks
@@ -335,10 +367,8 @@ exports.IoMediator = Montage.create(Component, {
335 css += list[i].cssText; 367 css += list[i].cssText;
336 } 368 }
337 } 369 }
338 //TODO: Add better logic for creating this string
339 url = new RegExp(chrome.extension.getURL('js/document/templates/montage-html/'), 'gi');
340 //Returning the CSS string 370 //Returning the CSS string
341 return this.getPrettyCss(css.replace(url, '')); 371 return this.getPrettyCss(css.replace(this.appTemplatesUrl, ''));
342 } 372 }
343 }, 373 },
344 //////////////////////////////////////////////////////////////////// 374 ////////////////////////////////////////////////////////////////////
diff --git a/js/mediators/keyboard-mediator.js b/js/mediators/keyboard-mediator.js
index 62b514ee..65dd34cd 100755
--- a/js/mediators/keyboard-mediator.js
+++ b/js/mediators/keyboard-mediator.js
@@ -136,6 +136,13 @@ exports.KeyboardMediator = Montage.create(Component, {
136 return; 136 return;
137 } 137 }
138 138
139 // shortcut for Pen tool is P
140 if (evt.keyCode === Keyboard.P){
141 evt.preventDefault();
142 this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[5]});
143 return;
144 }
145
139 // Shortcut for Rectangle Tool is R 146 // Shortcut for Rectangle Tool is R
140 // unless the user is pressing the command key. 147 // unless the user is pressing the command key.
141 // If the user is pressing the command key, they want to refresh the browser. 148 // If the user is pressing the command key, they want to refresh the browser.
@@ -162,6 +169,13 @@ exports.KeyboardMediator = Montage.create(Component, {
162 return; 169 return;
163 } 170 }
164 171
172 // Rotate Stage Tool is M
173 if(evt.keyCode === Keyboard.M ) {
174 evt.preventDefault();
175 this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[13]});
176 return;
177 }
178
165 // Hand tool 179 // Hand tool
166 if(evt.keyCode === Keyboard.H ) { 180 if(evt.keyCode === Keyboard.H ) {
167 evt.preventDefault(); 181 evt.preventDefault();