aboutsummaryrefslogtreecommitdiff
path: root/js/controllers/document-controller.js
diff options
context:
space:
mode:
authorValerio Virgillito2012-05-11 14:46:51 -0700
committerValerio Virgillito2012-05-11 14:46:51 -0700
commit1fb663b5f348fe2ff5ce86a80e8a61be289eba70 (patch)
tree7ccb54a07eb4adf793bae3f1a4ddd622bd4f9a0c /js/controllers/document-controller.js
parent647a7cf0697debe7b3d6fa0d68cd6b37996d6b59 (diff)
parentd2e1d4eeba4439ed26f2adf1c34991caf44a591f (diff)
downloadninja-1fb663b5f348fe2ff5ce86a80e8a61be289eba70.tar.gz
Merge pull request #222 from joseeight/Document
Adding partial support for templates
Diffstat (limited to 'js/controllers/document-controller.js')
-rwxr-xr-xjs/controllers/document-controller.js28
1 files changed, 17 insertions, 11 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js
index 0fd13be2..d88059ab 100755
--- a/js/controllers/document-controller.js
+++ b/js/controllers/document-controller.js
@@ -99,7 +99,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
99 //console.log(request); 99 //console.log(request);
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 //console.log(this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1], request.url);
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 //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]};
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-web/'))[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/'))[1]};
103 } 103 }
104 } 104 }
105 }, 105 },
@@ -244,20 +244,20 @@ if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){
244 } 244 }
245 }, 245 },
246 246
247
248
249 ////////////////////////////////////////////////////////////////////
250 //
247 createNewFile:{ 251 createNewFile:{
248 value:function(newFileObj){ 252 value:function(newFileObj){
249 //console.log(newFileObj);//contains the template uri and the new file uri 253 //
250 if(!newFileObj) return; 254 if(!newFileObj) return;
251 this.application.ninja.ioMediator.fileNew(newFileObj.newFilePath, newFileObj.fileTemplateUri, this.openNewFileCallback.bind(this)); 255 //
252 256 this.application.ninja.ioMediator.fileNew(newFileObj.newFilePath, newFileObj.fileTemplateUri, this.openNewFileCallback.bind(this), newFileObj.template);
253 if((newFileObj.fileExtension !== ".html") && (newFileObj.fileExtension !== ".htm")){//open code view
254
255 } else {
256 //open design view
257 }
258 } 257 }
259 }, 258 },
260 259 ////////////////////////////////////////////////////////////////////
260
261 /** 261 /**
262 * Public method 262 * Public method
263 * doc contains: 263 * doc contains:
@@ -374,6 +374,12 @@ if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){
374 }, 374 },
375 openWebDocument: { 375 openWebDocument: {
376 value: function(doc) { 376 value: function(doc) {
377 var template, dimensions;
378 if (doc.content.body.indexOf('Ninja-Banner Dimensions@@@') !== -1) {
379 dimensions = (doc.content.body.split('Ninja-Banner Dimensions@@@'))[1].split('-->')[0].split('x');
380 dimensions = {width: parseInt(dimensions[0]), height: parseInt(dimensions[1])};
381 template = {type: 'banner', size: dimensions};
382 }
377 // TODO: HACKS to remove 383 // TODO: HACKS to remove
378 this.documentHackReference = doc; 384 this.documentHackReference = doc;
379 document.getElementById("iframeContainer").style.overflow = "hidden"; 385 document.getElementById("iframeContainer").style.overflow = "hidden";
@@ -382,7 +388,7 @@ if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){
382 case 'html': 388 case 'html':
383 //Open in designer view 389 //Open in designer view
384 this._hackRootFlag = false; 390 this._hackRootFlag = false;
385 Montage.create(Document).init(doc, this, this._onOpenDocument, 'design'); 391 Montage.create(Document).init(doc, this, this._onOpenDocument, 'design', template);
386 break; 392 break;
387 default: 393 default:
388 //Open in code view 394 //Open in code view