aboutsummaryrefslogtreecommitdiff
path: root/js/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'js/controllers')
-rwxr-xr-xjs/controllers/document-controller.js39
-rwxr-xr-xjs/controllers/elements/component-controller.js44
-rwxr-xr-xjs/controllers/elements/shapes-controller.js1
3 files changed, 78 insertions, 6 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js
index 232af4c9..df3c74f8 100755
--- a/js/controllers/document-controller.js
+++ b/js/controllers/document-controller.js
@@ -14,7 +14,7 @@ var Montage = require("montage/core/core").Montage,
14 DocumentController; 14 DocumentController;
15//////////////////////////////////////////////////////////////////////// 15////////////////////////////////////////////////////////////////////////
16// 16//
17DocumentController = exports.DocumentController = Montage.create(Component, { 17var DocumentController = exports.DocumentController = Montage.create(Component, {
18 hasTemplate: { 18 hasTemplate: {
19 value: false 19 value: false
20 }, 20 },
@@ -22,6 +22,10 @@ DocumentController = exports.DocumentController = Montage.create(Component, {
22 _documents: { 22 _documents: {
23 value: [] 23 value: []
24 }, 24 },
25
26 _hackRootFlag: {
27 value: false
28 },
25 29
26 _activeDocument: { value: null }, 30 _activeDocument: { value: null },
27 _iframeCounter: { value: 1, enumerable: false }, 31 _iframeCounter: { value: 1, enumerable: false },
@@ -50,21 +54,42 @@ DocumentController = exports.DocumentController = Montage.create(Component, {
50 54
51 deserializedFromTemplate: { 55 deserializedFromTemplate: {
52 value: function() { 56 value: function() {
53 var self = this;
54
55 this.eventManager.addEventListener("appLoaded", this, false); 57 this.eventManager.addEventListener("appLoaded", this, false);
56 this.eventManager.addEventListener("executeFileOpen", this, false); 58 this.eventManager.addEventListener("executeFileOpen", this, false);
57 this.eventManager.addEventListener("executeNewFile", this, false); 59 this.eventManager.addEventListener("executeNewFile", this, false);
58 this.eventManager.addEventListener("executeSave", this, false); 60 this.eventManager.addEventListener("executeSave", this, false);
59 61
60 this.eventManager.addEventListener("recordStyleChanged", this, false); 62 this.eventManager.addEventListener("recordStyleChanged", this, false);
61
62 } 63 }
63 }, 64 },
65
66
67 handleWebRequest: {
68 value: function (request) {
69 if (request.url.indexOf('js/document/templates/montage-html') !== -1) {
70
71 console.log(request);
72
73 //TODO: Figure out why active document is not available here
74
75 if (this._hackRootFlag) {
76
77 //console.log(request.url.split('/')[request.url.split('/').length-1]);
78 //console.log(this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController._activeDocument.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split('/')[request.url.split('/').length-1]);
79
80 return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split('/')[request.url.split('/').length-1]};
81 }
82 }
83 }
84 },
85
64 86
65 handleAppLoaded: { 87 handleAppLoaded: {
66 value: function() { 88 value: function() {
67 // 89 //
90
91 chrome.webRequest.onBeforeRequest.addListener(this.handleWebRequest.bind(this), {urls: ["<all_urls>"]}, ["blocking"]);
92
68 } 93 }
69 }, 94 },
70 95
@@ -185,6 +210,9 @@ DocumentController = exports.DocumentController = Montage.create(Component, {
185 // 210 //
186 openDocument: { 211 openDocument: {
187 value: function(doc) { 212 value: function(doc) {
213
214 //
215 this.documentHackReference = doc;
188 // 216 //
189 switch (doc.extension) { 217 switch (doc.extension) {
190 case 'html': case 'html': 218 case 'html': case 'html':
@@ -282,7 +310,6 @@ DocumentController = exports.DocumentController = Montage.create(Component, {
282 _onOpenDocument: { 310 _onOpenDocument: {
283 value: function(doc){ 311 value: function(doc){
284 //var data = DocumentManager.activeDocument; 312 //var data = DocumentManager.activeDocument;
285
286 this._hideCurrentDocument(); 313 this._hideCurrentDocument();
287 this.application.ninja.stage.stageView.hideOtherDocuments(doc.uuid); 314 this.application.ninja.stage.stageView.hideOtherDocuments(doc.uuid);
288 315
diff --git a/js/controllers/elements/component-controller.js b/js/controllers/elements/component-controller.js
index 458e6b46..83450d0f 100755
--- a/js/controllers/elements/component-controller.js
+++ b/js/controllers/elements/component-controller.js
@@ -9,4 +9,48 @@ var Montage = require("montage/core/core").Montage,
9 9
10exports.ComponentController = Montage.create(ElementController, { 10exports.ComponentController = Montage.create(ElementController, {
11 11
12 getProperty: {
13 value: function(el, prop) {
14 switch(prop) {
15 case "id":
16 case "class":
17 case "left":
18 case "top":
19 case "width":
20 case "height":
21 if(el.nodeName === "IMG" && (prop === "width" || prop === "height")) {
22 return this.application.ninja.currentDocument.getComponentFromElement(el)[prop];
23 } else {
24 return ElementController.getProperty(el, prop, true);
25 }
26 default:
27 return this.application.ninja.currentDocument.getComponentFromElement(el)[prop];
28 }
29 }
30 },
31
32 setProperty: {
33 value: function(el, p, value) {
34 switch(p) {
35 case "id":
36 case "class":
37 case "left":
38 case "top":
39 case "width":
40 case "height":
41 if(el.nodeName === "IMG" && (p === "width" || p === "height")) {
42 this.application.ninja.currentDocument.getComponentFromElement(el)[p] = value;
43 } else {
44 ElementController.setProperty(el, p, value);
45 }
46 break;
47 default:
48 if(p === "min" || p === "max") value = parseFloat(value);
49
50 this.application.ninja.currentDocument.getComponentFromElement(el)[p] = value;
51 break;
52
53 }
54 }
55 }
12}); 56});
diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js
index 640119c4..15a18a51 100755
--- a/js/controllers/elements/shapes-controller.js
+++ b/js/controllers/elements/shapes-controller.js
@@ -59,6 +59,7 @@ exports.ShapesController = Montage.create(CanvasController, {
59 break; 59 break;
60 case "useWebGl": 60 case "useWebGl":
61 var canvas = njModule.NJUtils.makeNJElement("canvas", "Canvas", "shape", el.className, true); 61 var canvas = njModule.NJUtils.makeNJElement("canvas", "Canvas", "shape", el.className, true);
62 canvas.setAttribute("data-RDGE-id", njModule.NJUtils.generateRandom());
62 canvas.width = el.width; 63 canvas.width = el.width;
63 canvas.height = el.height; 64 canvas.height = el.height;
64 this.application.ninja.elementMediator.replaceElement(el, canvas); 65 this.application.ninja.elementMediator.replaceElement(el, canvas);