diff options
Diffstat (limited to 'js/controllers')
-rwxr-xr-x | js/controllers/document-controller.js | 131 | ||||
-rwxr-xr-x | js/controllers/elements/body-controller.js | 6 | ||||
-rwxr-xr-x | js/controllers/elements/component-controller.js | 4 | ||||
-rwxr-xr-x | js/controllers/elements/shapes-controller.js | 4 | ||||
-rwxr-xr-x | js/controllers/selection-controller.js | 17 | ||||
-rwxr-xr-x | js/controllers/styles-controller.js | 2 |
6 files changed, 110 insertions, 54 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 2be2e214..48ceb21b 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js | |||
@@ -88,18 +88,21 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
88 | 88 | ||
89 | 89 | ||
90 | 90 | ||
91 | 91 | //TODO: Ensure these APIs are not needed | |
92 | //////////////////////////////////////////////////////////////////// | 92 | //////////////////////////////////////////////////////////////////// |
93 | // | 93 | // |
94 | handleWebRequest: { | 94 | handleWebRequest: { |
95 | value: function (request) { | 95 | value: function (request) { |
96 | //TODO: Check if frameId is proper | 96 | //TODO: Check if frameId is proper |
97 | if (this._hackRootFlag && request.parentFrameId !== -1) { | 97 | if (this._hackRootFlag && request.parentFrameId !== -1) { |
98 | //TODO: Optimize creating string | 98 | //Checking for proper URL redirect (from different directories) |
99 | //console.log(request); | 99 | if (request.url.indexOf('js/document/templates/banner') !== -1) { |
100 | //console.log(this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1], request.url); | 100 | return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split(chrome.extension.getURL('js/document/templates/banner/'))[1]}; |
101 | //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]}; | 101 | } else if (request.url.indexOf('js/document/templates/html') !== -1) { |
102 | return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split(chrome.extension.getURL('js/document/templates/montage-html/'))[1]}; | 102 | return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split(chrome.extension.getURL('js/document/templates/html/'))[1]}; |
103 | } else { | ||
104 | //Error, not a valid folder | ||
105 | } | ||
103 | } | 106 | } |
104 | } | 107 | } |
105 | }, | 108 | }, |
@@ -155,32 +158,43 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
155 | }, | 158 | }, |
156 | 159 | ||
157 | handleExecuteNewFile: { | 160 | handleExecuteNewFile: { |
158 | value: function(event) { | 161 | value: function(event) { |
159 | var newFileSettings = event._event.settings || {}; | 162 | var newFileSettings = event._event.settings || {}; |
160 | if (this.application.ninja.coreIoApi.cloudAvailable()) { | 163 | if (this.application.ninja.coreIoApi.cloudAvailable()) { |
161 | newFileSettings.callback = this.createNewFile.bind(this); | 164 | newFileSettings.callback = this.createNewFile.bind(this); |
162 | this.application.ninja.newFileController.showNewFileDialog(newFileSettings); | 165 | this.application.ninja.newFileController.showNewFileDialog(newFileSettings); |
163 | } | ||
164 | } | 166 | } |
167 | } | ||
165 | }, | 168 | }, |
166 | //////////////////////////////////////////////////////////////////// | 169 | //////////////////////////////////////////////////////////////////// |
167 | //TODO: Check for appropiate structures | 170 | // |
168 | handleExecuteSave: { | 171 | handleExecuteSave: { |
169 | value: function(event) { | 172 | value: function(event) { |
170 | if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ | 173 | // |
171 | //Text and HTML document classes should return the same save object for fileSave | 174 | if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ |
172 | this.application.ninja.ioMediator.fileSave(this.activeDocument.save(), this.fileSaveResult.bind(this)); | 175 | // |
173 | } | 176 | this.activeDocument.model.save(this.testCallback.bind(this)); //this.fileSaveResult.bind(this) |
177 | } else { | ||
178 | //Error: | ||
179 | } | ||
174 | } | 180 | } |
175 | }, | 181 | }, |
182 | testCallback: { | ||
183 | value: function (value) { | ||
184 | console.log(value); | ||
185 | } | ||
186 | }, | ||
176 | //////////////////////////////////////////////////////////////////// | 187 | //////////////////////////////////////////////////////////////////// |
177 | //TODO: Check for appropiate structures | 188 | //TODO: Check for appropiate structures |
178 | handleExecuteSaveAll: { | 189 | handleExecuteSaveAll: { |
179 | value: function(event) { | 190 | value: function(event) { |
180 | if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ | 191 | // |
181 | //Text and HTML document classes should return the same save object for fileSave | 192 | if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ |
182 | this.application.ninja.ioMediator.fileSave(this.activeDocument.saveAll(), this.fileSaveResult.bind(this)); | 193 | // |
183 | } | 194 | this.activeDocument.model.saveAll(this.testCallback.bind(this)); //this.fileSaveResult.bind(this) |
195 | } else { | ||
196 | //Error: | ||
197 | } | ||
184 | } | 198 | } |
185 | }, | 199 | }, |
186 | //////////////////////////////////////////////////////////////////// | 200 | //////////////////////////////////////////////////////////////////// |
@@ -198,9 +212,14 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
198 | //////////////////////////////////////////////////////////////////// | 212 | //////////////////////////////////////////////////////////////////// |
199 | handleExecuteFileClose:{ | 213 | handleExecuteFileClose:{ |
200 | value: function(event) { | 214 | value: function(event) { |
201 | if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){ | 215 | if (this.activeDocument) { |
216 | this.activeDocument.closeDocument(); | ||
217 | } | ||
218 | /* | ||
219 | if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){ | ||
202 | this.closeDocument(this.activeDocument.uuid); | 220 | this.closeDocument(this.activeDocument.uuid); |
203 | } | 221 | } |
222 | */ | ||
204 | } | 223 | } |
205 | }, | 224 | }, |
206 | //////////////////////////////////////////////////////////////////// | 225 | //////////////////////////////////////////////////////////////////// |
@@ -219,7 +238,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
219 | fileSaveResult: { | 238 | fileSaveResult: { |
220 | value: function (result) { | 239 | value: function (result) { |
221 | if((result.status === 204) || (result.status === 404)){//204=>existing file || 404=>new file... saved | 240 | if((result.status === 204) || (result.status === 404)){//204=>existing file || 404=>new file... saved |
222 | this.activeDocument.needsSave = false; | 241 | this.activeDocument.model.needsSave = false; |
223 | if(this.application.ninja.currentDocument !== null){ | 242 | if(this.application.ninja.currentDocument !== null){ |
224 | //clear Dirty StyleSheets for the saved document | 243 | //clear Dirty StyleSheets for the saved document |
225 | this.application.ninja.stylesController.clearDirtyStyleSheets(this.application.ninja.currentDocument); | 244 | this.application.ninja.stylesController.clearDirtyStyleSheets(this.application.ninja.currentDocument); |
@@ -228,20 +247,20 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
228 | } | 247 | } |
229 | }, | 248 | }, |
230 | 249 | ||
250 | |||
251 | |||
252 | //////////////////////////////////////////////////////////////////// | ||
253 | // | ||
231 | createNewFile:{ | 254 | createNewFile:{ |
232 | value:function(newFileObj){ | 255 | value:function(newFileObj){ |
233 | //console.log(newFileObj);//contains the template uri and the new file uri | 256 | // |
234 | if(!newFileObj) return; | 257 | if(!newFileObj) return; |
235 | this.application.ninja.ioMediator.fileNew(newFileObj.newFilePath, newFileObj.fileTemplateUri, this.openNewFileCallback.bind(this)); | 258 | // |
236 | 259 | this.application.ninja.ioMediator.fileNew(newFileObj.newFilePath, newFileObj.fileTemplateUri, this.openNewFileCallback.bind(this), newFileObj.template); | |
237 | if((newFileObj.fileExtension !== ".html") && (newFileObj.fileExtension !== ".htm")){//open code view | ||
238 | |||
239 | } else { | ||
240 | //open design view | ||
241 | } | ||
242 | } | 260 | } |
243 | }, | 261 | }, |
244 | 262 | //////////////////////////////////////////////////////////////////// | |
263 | |||
245 | /** | 264 | /** |
246 | * Public method | 265 | * Public method |
247 | * doc contains: | 266 | * doc contains: |
@@ -358,6 +377,12 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
358 | }, | 377 | }, |
359 | openWebDocument: { | 378 | openWebDocument: { |
360 | value: function(doc) { | 379 | value: function(doc) { |
380 | var template, dimensions; | ||
381 | if (doc.content.body.indexOf('Ninja-Banner Dimensions@@@') !== -1) { | ||
382 | dimensions = (doc.content.body.split('Ninja-Banner Dimensions@@@'))[1].split('-->')[0].split('x'); | ||
383 | dimensions = {width: parseInt(dimensions[0]), height: parseInt(dimensions[1])}; | ||
384 | template = {type: 'banner', size: dimensions}; | ||
385 | } | ||
361 | // TODO: HACKS to remove | 386 | // TODO: HACKS to remove |
362 | this.documentHackReference = doc; | 387 | this.documentHackReference = doc; |
363 | document.getElementById("iframeContainer").style.overflow = "hidden"; | 388 | document.getElementById("iframeContainer").style.overflow = "hidden"; |
@@ -366,7 +391,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
366 | case 'html': | 391 | case 'html': |
367 | //Open in designer view | 392 | //Open in designer view |
368 | this._hackRootFlag = false; | 393 | this._hackRootFlag = false; |
369 | Montage.create(Document).init(doc, this, this._onOpenDocument, 'design'); | 394 | Montage.create(Document).init(doc, this, this._onOpenDocument, 'design', template); |
370 | break; | 395 | break; |
371 | default: | 396 | default: |
372 | //Open in code view | 397 | //Open in code view |
@@ -485,6 +510,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
485 | 510 | ||
486 | this.webTemplate = false; | 511 | this.webTemplate = false; |
487 | 512 | ||
513 | this._initializeBodyStyles(); | ||
488 | NJevent("onOpenDocument", doc); | 514 | NJevent("onOpenDocument", doc); |
489 | 515 | ||
490 | this.application.ninja.stage.stageView.showCodeViewBar(false); | 516 | this.application.ninja.stage.stageView.showCodeViewBar(false); |
@@ -584,7 +610,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
584 | //hide the iframe when switching to code view | 610 | //hide the iframe when switching to code view |
585 | document.getElementById("iframeContainer").style.display = "none"; | 611 | document.getElementById("iframeContainer").style.display = "none"; |
586 | } | 612 | } |
587 | } | 613 | } |
588 | } | 614 | } |
589 | }, | 615 | }, |
590 | 616 | ||
@@ -630,7 +656,40 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
630 | 656 | ||
631 |