diff options
Diffstat (limited to 'js/controllers/document-controller.js')
-rwxr-xr-x | js/controllers/document-controller.js | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index b1a22c1b..5e2a6461 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 | // |
17 | DocumentController = exports.DocumentController = Montage.create(Component, { | 17 | var 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 }, |
@@ -56,12 +60,39 @@ DocumentController = exports.DocumentController = Montage.create(Component, { | |||
56 | this.eventManager.addEventListener("executeSave", this, false); | 60 | this.eventManager.addEventListener("executeSave", this, false); |
57 | 61 | ||
58 | this.eventManager.addEventListener("recordStyleChanged", this, false); | 62 | this.eventManager.addEventListener("recordStyleChanged", this, false); |
63 | |||
64 | |||
65 | |||
59 | } | 66 | } |
60 | }, | 67 | }, |
68 | |||
69 | |||
70 | handleWebRequest: { | ||
71 | value: function (request) { | ||
72 | if (request.url.indexOf('js/document/templates/montage-html') !== -1) { | ||
73 | |||
74 | console.log(request); | ||
75 | |||
76 | //TODO: Figure out why active document is not available here | ||
77 | |||
78 | if (this._hackRootFlag) { | ||
79 | |||
80 | //console.log(request.url.split('/')[request.url.split('/').length-1]); | ||
81 | //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]); | ||
82 | |||
83 | 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]}; | ||
84 | } | ||
85 | } | ||
86 | } | ||
87 | }, | ||
88 | |||
61 | 89 | ||
62 | handleAppLoaded: { | 90 | handleAppLoaded: { |
63 | value: function() { | 91 | value: function() { |
64 | // | 92 | // |
93 | |||
94 | chrome.webRequest.onBeforeRequest.addListener(this.handleWebRequest.bind(this), {urls: ["<all_urls>"]}, ["blocking"]); | ||
95 | |||
65 | } | 96 | } |
66 | }, | 97 | }, |
67 | 98 | ||
@@ -180,6 +211,9 @@ DocumentController = exports.DocumentController = Montage.create(Component, { | |||
180 | // | 211 | // |
181 | openDocument: { | 212 | openDocument: { |
182 | value: function(doc) { | 213 | value: function(doc) { |
214 | |||
215 | // | ||
216 | this.documentHackReference = doc; | ||
183 | // | 217 | // |
184 | switch (doc.extension) { | 218 | switch (doc.extension) { |
185 | case 'html': case 'html': | 219 | case 'html': case 'html': |
@@ -277,7 +311,6 @@ DocumentController = exports.DocumentController = Montage.create(Component, { | |||
277 | _onOpenDocument: { | 311 | _onOpenDocument: { |
278 | value: function(doc){ | 312 | value: function(doc){ |
279 | //var data = DocumentManager.activeDocument; | 313 | //var data = DocumentManager.activeDocument; |
280 | |||
281 | this._hideCurrentDocument(); | 314 | this._hideCurrentDocument(); |
282 | this.application.ninja.stage.stageView.hideOtherDocuments(doc.uuid); | 315 | this.application.ninja.stage.stageView.hideOtherDocuments(doc.uuid); |
283 | 316 | ||