From 4ba680a7e9168d0f505a81e42a287dfbc54b4d7d Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Tue, 1 May 2012 15:26:37 -0700 Subject: Preliminary IO to new DOM view --- js/controllers/document-controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/controllers/document-controller.js') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 7795a74d..bb0f542f 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -366,7 +366,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, case 'html': //Open in designer view this._hackRootFlag = false; - Montage.create(Document).init(doc, this, this._onOpenDocument); + Montage.create(Document).init(doc, this, this._onOpenDocument, 'design'); break; default: //Open in code view -- cgit v1.2.3 From 4504972c1f3b9bf1d02a4484a07a8a85cf9ccee2 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Tue, 8 May 2012 10:37:38 -0700 Subject: Adding Chrome Preview --- js/controllers/document-controller.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'js/controllers/document-controller.js') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 803519a7..6a25420a 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -88,7 +88,8 @@ var DocumentController = exports.DocumentController = Montage.create(Component, - + //TODO: Ensure these APIs are not needed + /* //////////////////////////////////////////////////////////////////// // handleWebRequest: { @@ -119,6 +120,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, } }, //////////////////////////////////////////////////////////////////// +*/ -- cgit v1.2.3 From a1e8540f5656e62db6a89f3af7829be6b259b7ed Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Tue, 8 May 2012 17:33:13 -0700 Subject: Adding SAVE for I/O Adding save functionality to new template. Need to implement user UI for prompts and also clean up... --- js/controllers/document-controller.js | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'js/controllers/document-controller.js') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 6a25420a..ed4d33eb 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -166,23 +166,34 @@ var DocumentController = exports.DocumentController = Montage.create(Component, } }, //////////////////////////////////////////////////////////////////// - //TODO: Check for appropiate structures + // handleExecuteSave: { value: function(event) { - if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ - //Text and HTML document classes should return the same save object for fileSave - this.application.ninja.ioMediator.fileSave(this.activeDocument.save(), this.fileSaveResult.bind(this)); - } + // + if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ + // + this.activeDocument.model.save(this.testCallback.bind(this)); //this.fileSaveResult.bind(this) + } else { + //Error: + } } }, + testCallback: { + value: function (value) { + console.log(value); + } + }, //////////////////////////////////////////////////////////////////// //TODO: Check for appropiate structures handleExecuteSaveAll: { value: function(event) { - if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ - //Text and HTML document classes should return the same save object for fileSave - this.application.ninja.ioMediator.fileSave(this.activeDocument.saveAll(), this.fileSaveResult.bind(this)); - } + // + if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ + // + this.activeDocument.model.saveAll(this.testCallback.bind(this)); //this.fileSaveResult.bind(this) + } else { + //Error: + } } }, //////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 9ff89d41048d056ddab4c15b4e9e74bc5417c883 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 9 May 2012 18:12:48 -0700 Subject: Adding support to save body's css styles on preview. Signed-off-by: Nivesh Rajbhandari --- js/controllers/document-controller.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'js/controllers/document-controller.js') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 17ae8cc3..682bd6a6 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -498,6 +498,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, this.webTemplate = false; + this._initializeBodyStyles(); NJevent("onOpenDocument", doc); this.application.ninja.stage.stageView.showCodeViewBar(false); @@ -645,5 +646,37 @@ var DocumentController = exports.DocumentController = Montage.create(Component, value:function(){ this.activeDocument.needsSave = true; } + }, + + _initializeBodyStyles: { + value: function() { + var sc = this.application.ninja.stylesController, + docRoot = this.application.ninja.currentDocument.documentRoot, + styles = {}, + needsRule = false, + rule; + + if(sc.getElementStyle(docRoot, "width", false, false) == null) { + styles['width'] = '100%'; + needsRule = true; + } + if(sc.getElementStyle(docRoot, "height", false, false) == null) { + styles['height'] = '100%'; + needsRule = true; + } + if(sc.getElementStyle(docRoot, "-webkit-transform", false, false) == null) { + styles['-webkit-transform'] = 'perspective(1400) matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'; + needsRule = true; + } + if(sc.getElementStyle(docRoot, "-webkit-transform-style", false, false) == null) { + styles['-webkit-transform-style'] = 'preserve-3d'; + needsRule = true; + } + + if(needsRule) { + rule = sc.addRule('body{}'); + sc.setStyles(rule, styles); + } + } } }); -- cgit v1.2.3 From fb7a3aa9ce0d9b99dca79cfb89951b5c51523250 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Thu, 10 May 2012 14:54:38 -0700 Subject: Adding partial close functionality --- js/controllers/document-controller.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'js/controllers/document-controller.js') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 682bd6a6..58fa4de7 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -211,9 +211,14 @@ var DocumentController = exports.DocumentController = Montage.create(Component, //////////////////////////////////////////////////////////////////// handleExecuteFileClose:{ value: function(event) { - if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){ + if (this.activeDocument) { + this.activeDocument.closeDocument(); + } + /* +if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){ this.closeDocument(this.activeDocument.uuid); } +*/ } }, //////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From d75aff9e251f84a13c326668a5271b5852dcde53 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Thu, 10 May 2012 15:36:24 -0700 Subject: Adding webRequest API Adding webRequest API to handle local URLs intercepting. Should be a temp fix. --- js/controllers/document-controller.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'js/controllers/document-controller.js') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 58fa4de7..84e9f4fc 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -89,8 +89,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, //TODO: Ensure these APIs are not needed - /* -//////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////// // handleWebRequest: { value: function (request) { @@ -100,7 +99,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, //console.log(request); //console.log(this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1], request.url); //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]}; - 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]}; + 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]}; } } }, @@ -120,7 +119,6 @@ var DocumentController = exports.DocumentController = Montage.create(Component, } }, //////////////////////////////////////////////////////////////////// -*/ -- cgit v1.2.3 From f6f722feecf88c8afe59327eaf8557ce4012abc7 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 10 May 2012 22:40:02 -0700 Subject: Fixing the dirty document flag. Disabling the stylesheets dirty flag because === true on document open. Signed-off-by: Valerio Virgillito --- js/controllers/document-controller.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/controllers/document-controller.js') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 84e9f4fc..0fd13be2 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -235,7 +235,7 @@ if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){ fileSaveResult: { value: function (result) { if((result.status === 204) || (result.status === 404)){//204=>existing file || 404=>new file... saved - this.activeDocument.needsSave = false; + this.activeDocument.model.needsSave = false; if(this.application.ninja.currentDocument !== null){ //clear Dirty StyleSheets for the saved document this.application.ninja.stylesController.clearDirtyStyleSheets(this.application.ninja.currentDocument); @@ -647,7 +647,7 @@ if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){ handleStyleSheetDirty:{ value:function(){ - this.activeDocument.needsSave = true; +// this.activeDocument.model.needsSave = true; } }, -- cgit v1.2.3 From c87e538fdc337639bc4d54bb087dbf2b4f20297f Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Fri, 11 May 2012 14:41:20 -0700 Subject: Adding support for new templates This is supported for NEW and OPEN, SAVE is not supported yet by I/O. Saving works, but it will not be a banner template. --- js/controllers/document-controller.js | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'js/controllers/document-controller.js') 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, //console.log(request); //console.log(this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1], request.url); //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]}; - 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]}; + 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]}; } } }, @@ -244,20 +244,20 @@ if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){ } }, + + + //////////////////////////////////////////////////////////////////// + // createNewFile:{ value:function(newFileObj){ - //console.log(newFileObj);//contains the template uri and the new file uri + // if(!newFileObj) return; - this.application.ninja.ioMediator.fileNew(newFileObj.newFilePath, newFileObj.fileTemplateUri, this.openNewFileCallback.bind(this)); - - if((newFileObj.fileExtension !== ".html") && (newFileObj.fileExtension !== ".htm")){//open code view - - } else { - //open design view - } + // + this.application.ninja.ioMediator.fileNew(newFileObj.newFilePath, newFileObj.fileTemplateUri, this.openNewFileCallback.bind(this), newFileObj.template); } }, - + //////////////////////////////////////////////////////////////////// + /** * Public method * doc contains: @@ -374,6 +374,12 @@ if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){ }, openWebDocument: { value: function(doc) { + var template, dimensions; + if (doc.content.body.indexOf('Ninja-Banner Dimensions@@@') !== -1) { + dimensions = (doc.content.body.split('Ninja-Banner Dimensions@@@'))[1].split('-->')[0].split('x'); + dimensions = {width: parseInt(dimensions[0]), height: parseInt(dimensions[1])}; + template = {type: 'banner', size: dimensions}; + } // TODO: HACKS to remove this.documentHackReference = doc; document.getElementById("iframeContainer").style.overflow = "hidden"; @@ -382,7 +388,7 @@ if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){ case 'html': //Open in designer view this._hackRootFlag = false; - Montage.create(Document).init(doc, this, this._onOpenDocument, 'design'); + Montage.create(Document).init(doc, this, this._onOpenDocument, 'design', template); break; default: //Open in code view -- cgit v1.2.3 From 1559abff592b976e6b983881fe208da4257e98f7 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Mon, 14 May 2012 10:44:42 -0700 Subject: Fixing webRequest URL parsing --- js/controllers/document-controller.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'js/controllers/document-controller.js') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index d88059ab..e6b543d7 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -95,11 +95,14 @@ var DocumentController = exports.DocumentController = Montage.create(Component, value: function (request) { //TODO: Check if frameId is proper if (this._hackRootFlag && request.parentFrameId !== -1) { - //TODO: Optimize creating string - //console.log(request); - //console.log(this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1], request.url); - //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]}; - 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]}; + //Checking for proper URL redirect (from different directories) + if (request.url.indexOf('js/document/templates/banner') !== -1) { + 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]}; + } else if (request.url.indexOf('js/document/templates/html') !== -1) { + 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]}; + } else { + //Error, not a valid folder + } } } }, -- cgit v1.2.3 From 734b6ad96d25bb67d0db4a0a75c331468e194809 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Mon, 14 May 2012 12:05:41 -0700 Subject: Fixing 3d to work in banner templates. Signed-off-by: Nivesh Rajbhandari --- js/controllers/document-controller.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'js/controllers/document-controller.js') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index d88059ab..3b6eb5bf 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -683,8 +683,11 @@ if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){ } if(needsRule) { - rule = sc.addRule('body{}'); +// rule = sc.addRule('body{}'); +// sc.setStyles(rule, styles); + rule = sc.addRule('.ninjaUserDoc{}'); sc.setStyles(rule, styles); + sc.addClass(docRoot, "ninjaUserDoc"); } } } -- cgit v1.2.3 From cfd3a44bb7aba54c15fab59eff39ecdffcb7ac11 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Mon, 14 May 2012 14:38:35 -0700 Subject: Viewport for banner templates so content doesn't push through "body". Signed-off-by: Nivesh Rajbhandari --- js/controllers/document-controller.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'js/controllers/document-controller.js') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 3b6eb5bf..3ce4ba81 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -683,11 +683,9 @@ if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){ } if(needsRule) { -// rule = sc.addRule('body{}'); -// sc.setStyles(rule, styles); - rule = sc.addRule('.ninjaUserDoc{}'); + rule = sc.addRule('.ninja-body{}'); sc.setStyles(rule, styles); - sc.addClass(docRoot, "ninjaUserDoc"); + sc.addClass(docRoot, "ninja-body"); } } } -- cgit v1.2.3 From 9b2cecc30a2e94ac247fddd8ec931b9aa768cb5c Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Mon, 14 May 2012 16:04:46 -0700 Subject: code cleanup Signed-off-by: Valerio Virgillito --- js/controllers/document-controller.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'js/controllers/document-controller.js') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index d88059ab..0a91ae29 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -155,13 +155,13 @@ var DocumentController = exports.DocumentController = Montage.create(Component, }, handleExecuteNewFile: { - value: function(event) { - var newFileSettings = event._event.settings || {}; - if (this.application.ninja.coreIoApi.cloudAvailable()) { - newFileSettings.callback = this.createNewFile.bind(this); - this.application.ninja.newFileController.showNewFileDialog(newFileSettings); - } + value: function(event) { + var newFileSettings = event._event.settings || {}; + if (this.application.ninja.coreIoApi.cloudAvailable()) { + newFileSettings.callback = this.createNewFile.bind(this); + this.application.ninja.newFileController.showNewFileDialog(newFileSettings); } + } }, //////////////////////////////////////////////////////////////////// // @@ -607,7 +607,7 @@ if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){ //hide the iframe when switching to code view document.getElementById("iframeContainer").style.display = "none"; } - } + } } }, -- cgit v1.2.3 From 919a0d0ed35c24b1047281723ddde2ac98fc9a3e Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 15 May 2012 22:36:44 -0700 Subject: document close handler. initial working draft Signed-off-by: Valerio Virgillito --- js/controllers/document-controller.js | 66 ++++++++++++++++++++++------------- 1 file changed, 42 insertions(+), 24 deletions(-) (limited to 'js/controllers/document-controller.js') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 48ceb21b..51791a11 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -33,6 +33,10 @@ var DocumentController = exports.DocumentController = Montage.create(Component, value: false }, + _hackInitialStyles: { + value: true + }, + _activeDocument: { value: null }, _iframeCounter: { value: 1, enumerable: false }, _iframeHolder: { value: null, enumerable: false }, @@ -44,8 +48,10 @@ var DocumentController = exports.DocumentController = Montage.create(Component, return this._activeDocument; }, set: function(doc) { - if(!!this._activeDocument){ this._activeDocument.isActive = false;} +// if(!!this._activeDocument){ this._activeDocument.isActive = false;} + this._activeDocument = doc; + if(!!this._activeDocument){ if(this._documents.indexOf(doc) === -1) this._documents.push(doc); this._activeDocument.isActive = true; @@ -213,13 +219,9 @@ var DocumentController = exports.DocumentController = Montage.create(Component, handleExecuteFileClose:{ value: function(event) { if (this.activeDocument) { - this.activeDocument.closeDocument(); +// this.activeDocument.closeDocument(); + this.closeFile(this.activeDocument); } - /* -if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){ - this.closeDocument(this.activeDocument.uuid); - } -*/ } }, //////////////////////////////////////////////////////////////////// @@ -448,7 +450,32 @@ if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){ */ } - }, + }, + + closeFile: { + value: function(document) { + document.closeDocument(this, this.onCloseFile); + } + }, + + onCloseFile: { + value: function(doc) { + + this._documents.splice(this._documents.indexOf(doc), 1); + + this.activeDocument = null; + + this.application.ninja.stage.stageView.hideRulers(); + +// document.getElementById("iframeContainer").style.display="block"; + + this.application.ninja.stage.hideCanvas(true); + + + NJevent("closeDocument", doc.model.file.uri); + //TODO: Delete object here + } + }, closeDocument: { value: function(id) { @@ -468,15 +495,7 @@ if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){ if(typeof doc.stopVideos !== "undefined"){doc.stopVideos();} this._removeDocumentView(doc.container); }else if(this._documents.length === 0){ - if(typeof this.activeDocument.pauseAndStopVideos !== "undefined"){ - this.activeDocument.pauseAndStopVideos(); - } - this.activeDocument = null; - this._removeDocumentView(doc.container); - this.application.ninja.stage.stageView.hideRulers(); - document.getElementById("iframeContainer").style.display="block"; - - this.application.ninja.stage.hideCanvas(true); + // See above }else{//closing inactive document tab - just clear DOM if(typeof doc.pauseAndStopVideos !== "undefined"){ doc.pauseAndStopVideos(); @@ -515,6 +534,9 @@ if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){ this.application.ninja.stage.stageView.showCodeViewBar(false); this.application.ninja.stage.stageView.restoreAllPanels(); + + // Flag to stop stylesheet dirty event + this._hackInitialStyles = false; } }, @@ -552,12 +574,6 @@ if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){ /** * VIEW Related Methods */ - // PUBLIC - ShowActiveDocument: { - value: function() { - this.activeDocument.iframe.style.opacity = 1.0; - } - }, // PRIVATE _findDocumentByUUID: { @@ -656,7 +672,9 @@ if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){ handleStyleSheetDirty:{ value:function(){ -// this.activeDocument.model.needsSave = true; + if(!this._hackInitialStyles) { + this.activeDocument.model.needsSave = true; + } } }, -- cgit v1.2.3 From 0eaa0be8e030a6bac5ab70af3c1044682d973366 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 15 May 2012 23:33:44 -0700 Subject: fixed some binding warnings Signed-off-by: Valerio Virgillito --- js/controllers/document-controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/controllers/document-controller.js') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 51791a11..fba9fad5 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -463,7 +463,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, this._documents.splice(this._documents.indexOf(doc), 1); - this.activeDocument = null; + this._activeDocument = null; this.application.ninja.stage.stageView.hideRulers(); -- cgit v1.2.3 From 99f16ae08fbb0a6dfe6008c9833f2253b18c19e5 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 16 May 2012 14:13:28 -0700 Subject: removing first draw on the component event Signed-off-by: Valerio Virgillito --- js/controllers/document-controller.js | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'js/controllers/document-controller.js') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index fba9fad5..1e894f02 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -76,24 +76,13 @@ var DocumentController = exports.DocumentController = Montage.create(Component, this.eventManager.addEventListener("styleSheetDirty", this, false); - this.eventManager.addEventListener("addComponentFirstDraw", this, false); - // Temporary add listeners for the new stage templates this.eventManager.addEventListener("executeWebpageOpen", this, false); this.eventManager.addEventListener("executeNewWebpage", this, false); } }, - handleAddComponentFirstDraw: { - value: function (e) { - //TODO: Add logic to reparse the document for dynamically added styles - //console.log(e); - } - }, - - - - + //TODO: Ensure these APIs are not needed //////////////////////////////////////////////////////////////////// // -- cgit v1.2.3 From b1e5ef1949eeddc39a1e9570a65612879cbdadef Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 16 May 2012 20:49:40 -0700 Subject: clearing the needs save flag on save. Signed-off-by: Valerio Virgillito --- js/controllers/document-controller.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'js/controllers/document-controller.js') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 1e894f02..ecb988ff 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -177,6 +177,8 @@ var DocumentController = exports.DocumentController = Montage.create(Component, testCallback: { value: function (value) { console.log(value); + //TODO: Move this to the model.save() + this.activeDocument.model.needsSave = false; } }, //////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From c26de5fa7b909a53b103b72027b5cbe7c3e1c49f Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 16 May 2012 22:48:39 -0700 Subject: code cleanup and refactoring of the document controller and stage view Signed-off-by: Valerio Virgillito --- js/controllers/document-controller.js | 194 ++++++++++------------------------ 1 file changed, 56 insertions(+), 138 deletions(-) (limited to 'js/controllers/document-controller.js') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index ecb988ff..1796f9b5 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -21,10 +21,6 @@ var DocumentController = exports.DocumentController = Montage.create(Component, value: false }, - webTemplate: { - value: false - }, - _documents: { value: [] }, @@ -75,10 +71,6 @@ var DocumentController = exports.DocumentController = Montage.create(Component, this.eventManager.addEventListener("executeFileCloseAll", this, false); this.eventManager.addEventListener("styleSheetDirty", this, false); - - // Temporary add listeners for the new stage templates - this.eventManager.addEventListener("executeWebpageOpen", this, false); - this.eventManager.addEventListener("executeNewWebpage", this, false); } }, @@ -138,20 +130,6 @@ var DocumentController = exports.DocumentController = Montage.create(Component, } }, - handleExecuteWebpageOpen: { - value: function(event) { - this.webTemplate = true; - this.handleExecuteFileOpen(event); - } - }, - - handleExecuteNewWebpage: { - value: function(event) { - this.webTemplate = true; - this.handleExecuteNewFile(event); - } - }, - handleExecuteNewFile: { value: function(event) { var newFileSettings = event._event.settings || {}; @@ -304,12 +282,8 @@ var DocumentController = exports.DocumentController = Montage.create(Component, this.isNewFilePath = false;//reset path identifier flag //Sending full response object - // TODO: Unify those 2 methods. Using if/else for the new template - if(this.webTemplate) { - this.openWebDocument(response); - } else { - this.openDocument(response); - } + this.openDocument(response); + } else if (!!response && (response.status === 404)){ alert("Unable to open file.\n [Error: File does not exist]"); } else if (!!response && (response.status === 500)){ @@ -345,30 +319,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, }, //////////////////////////////////////////////////////////////////// - openDocument: { - value: function(doc) { - - // - this.documentHackReference = doc; - // - switch (doc.extension) { - case 'html': - //Open in designer view - Montage.create(HTMLDocument).initialize(doc, Uuid.generate(), this._createIframeElement(), this._onOpenDocument.bind(this)); - break; - default: - //Open in code view - var code = Montage.create(TextDocument, {"source": {value: doc.content}}), docuuid = Uuid.generate(), textArea; - textArea = this.application.ninja.stage.stageView.createTextAreaElement(docuuid); - code.initialize(doc, docuuid, textArea, textArea.parentNode); - //code.init(doc.name, doc.uri, doc.extension, null, docuuid); - code.textArea.value = doc.content; - this.application.ninja.stage.stageView.createTextView(code); - break; - } - } - }, - openWebDocument: { + openDocument: { value: function(doc) { var template, dimensions; if (doc.content.body.indexOf('Ninja-Banner Dimensions@@@') !== -1) { @@ -484,14 +435,14 @@ var DocumentController = exports.DocumentController = Montage.create(Component, } this.application.ninja.stage.stageView.switchDocument(this._documents[nextDocumentIndex]); if(typeof doc.stopVideos !== "undefined"){doc.stopVideos();} - this._removeDocumentView(doc.container); + doc.container.parentNode.removeChild(doc.container); }else if(this._documents.length === 0){ // See above }else{//closing inactive document tab - just clear DOM if(typeof doc.pauseAndStopVideos !== "undefined"){ doc.pauseAndStopVideos(); } - this._removeDocumentView(doc.container); + doc.container.parentNode.removeChild(doc.container); } NJevent("closeDocument", doc.uri); @@ -500,41 +451,65 @@ var DocumentController = exports.DocumentController = Montage.create(Component, } }, - // Document has been loaded into the Iframe. Dispatch the event. - // Event Detail: Contains the current ActiveDocument + // Open document callback _onOpenDocument: { value: function(doc){ - this.application.ninja.currentDocument = doc; - this._hideCurrentDocument(); - this.application.ninja.stage.stageView.hideOtherDocuments(doc.uuid); - this.application.ninja.stage.hideCanvas(false); + if(this.activeDocument) { + // There is a document currently opened - this.activeDocument = doc; +// this.application.ninja.stage.stageView.showCodeViewBar(false); +// this.application.ninja.stage.stageView.restoreAllPanels(); - if(!this.webTemplate) { - this._showCurrentDocument(); + // + /* + if(this.activeDocument.currentView === "design"){ + this.activeDocument.saveAppState(); + this.activeDocument.container.parentNode.style["display"] = "none"; + this.application.ninja.stage.hideCanvas(true); + this.application.ninja.stage.stageView.hideRulers(); + } + + this.activeDocument.container.style["display"] = "none"; + */ + // hide current document } else { - this.application.ninja.stage.stageView.showRulers(); - } + // There is no document opened - this.webTemplate = false; + // Set the active document + this.activeDocument = doc; - this._initializeBodyStyles(); - NJevent("onOpenDocument", doc); + // Show the canvas + this.application.ninja.stage.hideCanvas(false); + + // Show the rulers + // TODO: Move this indo design view + this.application.ninja.stage.stageView.showRulers(); - this.application.ninja.stage.stageView.showCodeViewBar(false); - this.application.ninja.stage.stageView.restoreAllPanels(); + // Initialize the documentRoot styles + this.initializeRootStyles(doc.documentRoot); + // Flag to stop stylesheet dirty event + this._hackInitialStyles = false; - // Flag to stop stylesheet dirty event - this._hackInitialStyles = false; + NJevent("onOpenDocument", doc); + } } }, _onOpenTextDocument: { value: function(doc) { - this._hideCurrentDocument(); + if(this.activeDocument) { + if(this.activeDocument.currentView === "design"){ + this.activeDocument.saveAppState(); + this.activeDocument.container.parentNode.style["display"] = "none"; + this.application.ninja.stage.hideCanvas(true); + this.application.ninja.stage.stageView.hideRulers(); + } + + this.activeDocument.container.style["display"] = "none"; + } + this.application.ninja.stage._scrollFlag = false; // TODO HACK to prevent type error on Hide/Show Iframe this.activeDocument = doc; @@ -589,21 +564,6 @@ var DocumentController = exports.DocumentController = Montage.create(Component, } }, - _hideCurrentDocument: { - value: function() { - if(this.activeDocument) { - if(this.activeDocument.currentView === "design"){ - this.activeDocument.saveAppState(); - this.activeDocument.container.parentNode.style["display"] = "none"; - this.application.ninja.stage.hideCanvas(true); - this.application.ninja.stage.stageView.hideRulers(); - } - - this.activeDocument.container.style["display"] = "none"; - } - } - }, - _showCurrentDocument: { value: function() { if(this.activeDocument) { @@ -611,8 +571,6 @@ var DocumentController = exports.DocumentController = Montage.create(Component, if(this.activeDocument.currentView === "design"){ this.activeDocument.container.parentNode.style["display"] = "block"; this.activeDocument.restoreAppState(); - this.application.ninja.stage.hideCanvas(false); - this.application.ninja.stage.stageView.showRulers(); }else{ //hide the iframe when switching to code view document.getElementById("iframeContainer").style.display = "none"; @@ -621,46 +579,6 @@ var DocumentController = exports.DocumentController = Montage.create(Component, } }, - _removeDocumentView: { - value: function(node) { - node.parentNode.removeChild(node); - } - }, - - reloadDocumentContent: { - value: function() { - this.activeDocument._window.location.reload(); - } - }, - - /** - * Creates a new iFrame element using a new unique ID for it. Returns the iframe ID. - */ - _createIframeElement: { - value: function() { - var e = document.createElement("iframe"); - e.id = this._createIframeID(); - e.style.border = "none"; - e.style.opacity = 0; - e.height = 1000; - e.width = 2000; - e.src = ""; - - if(!this._iframeHolder) this._iframeHolder = document.getElementById("iframeContainer"); - - this._iframeHolder.appendChild(e); - - return e; - } - }, - - - _createIframeID: { - value: function() { - return "userDocument_" + (this._iframeCounter++); - } - }, - handleStyleSheetDirty:{ value:function(){ if(!this._hackInitialStyles) { @@ -669,27 +587,27 @@ var DocumentController = exports.DocumentController = Montage.create(Component, } }, - _initializeBodyStyles: { - value: function() { + // TODO: Move this into the design views + initializeRootStyles: { + value: function(documentRoot) { var sc = this.application.ninja.stylesController, - docRoot = this.application.ninja.currentDocument.documentRoot, styles = {}, needsRule = false, rule; - if(sc.getElementStyle(docRoot, "width", false, false) == null) { + if(sc.getElementStyle(documentRoot, "width", false, false) == null) { styles['width'] = '100%'; needsRule = true; } - if(sc.getElementStyle(docRoot, "height", false, false) == null) { + if(sc.getElementStyle(documentRoot, "height", false, false) == null) { styles['height'] = '100%'; needsRule = true; } - if(sc.getElementStyle(docRoot, "-webkit-transform", false, false) == null) { + if(sc.getElementStyle(documentRoot, "-webkit-transform", false, false) == null) { styles['-webkit-transform'] = 'perspective(1400) matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'; needsRule = true; } - if(sc.getElementStyle(docRoot, "-webkit-transform-style", false, false) == null) { + if(sc.getElementStyle(documentRoot, "-webkit-transform-style", false, false) == null) { styles['-webkit-transform-style'] = 'preserve-3d'; needsRule = true; } @@ -697,7 +615,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, if(needsRule) { rule = sc.addRule('.ninja-body{}'); sc.setStyles(rule, styles); - sc.addClass(docRoot, "ninja-body"); + sc.addClass(documentRoot, "ninja-body"); } } } -- cgit v1.2.3 From 402a369c7bf164c3c6686be3a33f5e36f25e4130 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 16 May 2012 23:19:32 -0700 Subject: document controller and stage view code cleanup Signed-off-by: Valerio Virgillito --- js/controllers/document-controller.js | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) (limited to 'js/controllers/document-controller.js') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 1796f9b5..cf46e73e 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -458,8 +458,10 @@ var DocumentController = exports.DocumentController = Montage.create(Component, if(this.activeDocument) { // There is a document currently opened -// this.application.ninja.stage.stageView.showCodeViewBar(false); -// this.application.ninja.stage.stageView.restoreAllPanels(); + + + //this.application.ninja.stage.stageView.showCodeViewBar(false); + //this.application.ninja.stage.stageView.restoreAllPanels(); // /* @@ -472,6 +474,18 @@ var DocumentController = exports.DocumentController = Montage.create(Component, this.activeDocument.container.style["display"] = "none"; */ + + /* + this.activeDocument.container.style["display"] = "block"; + if(this.activeDocument.currentView === "design"){ + this.activeDocument.container.parentNode.style["display"] = "block"; + this.activeDocument.restoreAppState(); + }else{ + //hide the iframe when switching to code view + document.getElementById("iframeContainer").style.display = "none"; + } + + */ // hide current document } else { // There is no document opened @@ -564,21 +578,6 @@ var DocumentController = exports.DocumentController = Montage.create(Component, } }, - _showCurrentDocument: { - value: function() { - if(this.activeDocument) { - this.activeDocument.container.style["display"] = "block"; - if(this.activeDocument.currentView === "design"){ - this.activeDocument.container.parentNode.style["display"] = "block"; - this.activeDocument.restoreAppState(); - }else{ - //hide the iframe when switching to code view - document.getElementById("iframeContainer").style.display = "none"; - } - } - } - }, - handleStyleSheetDirty:{ value:function(){ if(!this._hackInitialStyles) { -- cgit v1.2.3 From eff40602cac6821f8272177c24b6bf3de399f8b1 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 17 May 2012 21:11:33 -0700 Subject: multiple documents - enable opening multiple documents and initial switching Signed-off-by: Valerio Virgillito --- js/controllers/document-controller.js | 71 +++++++++++++++++------------------ 1 file changed, 35 insertions(+), 36 deletions(-) (limited to 'js/controllers/document-controller.js') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index cf46e73e..50874725 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -454,58 +454,57 @@ var DocumentController = exports.DocumentController = Montage.create(Component, // Open document callback _onOpenDocument: { value: function(doc){ - + var currentDocument; if(this.activeDocument) { // There is a document currently opened - - + currentDocument = this.activeDocument; //this.application.ninja.stage.stageView.showCodeViewBar(false); //this.application.ninja.stage.stageView.restoreAllPanels(); - // - /* - if(this.activeDocument.currentView === "design"){ - this.activeDocument.saveAppState(); - this.activeDocument.container.parentNode.style["display"] = "none"; - this.application.ninja.stage.hideCanvas(true); - this.application.ninja.stage.stageView.hideRulers(); - } + //this.activeDocument.saveAppState(); - this.activeDocument.container.style["display"] = "none"; - */ - - /* - this.activeDocument.container.style["display"] = "block"; - if(this.activeDocument.currentView === "design"){ - this.activeDocument.container.parentNode.style["display"] = "block"; - this.activeDocument.restoreAppState(); - }else{ - //hide the iframe when switching to code view - document.getElementById("iframeContainer").style.display = "none"; - } - - */ - // hide current document + // TODO: Do we need this? + //this.application.ninja.stage.hideCanvas(true); + //this.application.ninja.stage.stageView.hideRulers(); + + //this.activeDocument.restoreAppState(); } else { // There is no document opened - // Set the active document - this.activeDocument = doc; + // Show the rulers + // TODO: Move this indo design view + this.application.ninja.stage.stageView.showRulers(); // Show the canvas this.application.ninja.stage.hideCanvas(false); + } - // Show the rulers - // TODO: Move this indo design view - this.application.ninja.stage.stageView.showRulers(); - // Initialize the documentRoot styles - this.initializeRootStyles(doc.documentRoot); - // Flag to stop stylesheet dirty event - this._hackInitialStyles = false; + // Set the active document + this.activeDocument = doc; + + // Initialize the documentRoot styles + this.initializeRootStyles(doc.documentRoot); + // Flag to stop stylesheet dirty event + this._hackInitialStyles = false; + + this.switchDocuments(currentDocument, doc); + + NJevent("onOpenDocument", doc); + + //Setting opacity to be viewable after load + //doc.model.views.design.iframe.style.opacity = 1; + + } + }, + + switchDocuments: { + value: function(current, newDocument) { + newDocument.model.views.design.iframe.style.opacity = 1; - NJevent("onOpenDocument", doc); + if(current) { + current.model.views.design.hide(); } } }, -- cgit v1.2.3 From 7a94696e19b14e15261df516e2ba75e693b1313d Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 18 May 2012 00:21:56 -0700 Subject: enabling basic document switching Signed-off-by: Valerio Virgillito --- js/controllers/document-controller.js | 37 +++++++++++++++-------------------- 1 file changed, 16 insertions(+), 21 deletions(-) (limited to 'js/controllers/document-controller.js') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 50874725..fc1f2c0f 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -459,16 +459,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, // There is a document currently opened currentDocument = this.activeDocument; - //this.application.ninja.stage.stageView.showCodeViewBar(false); //this.application.ninja.stage.stageView.restoreAllPanels(); - - //this.activeDocument.saveAppState(); - - // TODO: Do we need this? - //this.application.ninja.stage.hideCanvas(true); - //this.application.ninja.stage.stageView.hideRulers(); - - //this.activeDocument.restoreAppState(); } else { // There is no document opened @@ -480,7 +471,6 @@ var DocumentController = exports.DocumentController = Montage.create(Component, this.application.ninja.stage.hideCanvas(false); } - // Set the active document this.activeDocument = doc; @@ -489,22 +479,27 @@ var DocumentController = exports.DocumentController = Montage.create(Component, // Flag to stop stylesheet dirty event this._hackInitialStyles = false; - this.switchDocuments(currentDocument, doc); - - NJevent("onOpenDocument", doc); - - //Setting opacity to be viewable after load - //doc.model.views.design.iframe.style.opacity = 1; - + this.switchDocuments(currentDocument, doc, true); } }, switchDocuments: { - value: function(current, newDocument) { - newDocument.model.views.design.iframe.style.opacity = 1; + value: function(currentDocument, newDocument, didCreate) { + + if(currentDocument) { + currentDocument.serializeDocument(); - if(current) { - current.model.views.design.hide(); + currentDocument.model.views.design.hide(); + } + + if(didCreate) { + newDocument.model.views.design.iframe.style.opacity = 1; + NJevent("onOpenDocument", newDocument); + } else { + this.activeDocument = newDocument; + newDocument.model.views.design.show(); + newDocument.deserializeDocument(); + NJevent("switchDocument"); } } }, -- cgit v1.2.3 From e9dddef38507cafcf5702ce6a512b4005609acef Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 18 May 2012 01:14:41 -0700 Subject: Fixing the save as paths Signed-off-by: Valerio Virgillito --- js/controllers/document-controller.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/controllers/document-controller.js') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index fc1f2c0f..ea4022b8 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -177,8 +177,8 @@ var DocumentController = exports.DocumentController = Montage.create(Component, value: function(event) { var saveAsSettings = event._event.settings || {}; if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ - saveAsSettings.fileName = this.activeDocument.name; - saveAsSettings.folderUri = this.activeDocument.uri.substring(0, this.activeDocument.uri.lastIndexOf("/")); + saveAsSettings.fileName = this.activeDocument.model.file.name; + saveAsSettings.folderUri = this.activeDocument.model.file.uri.substring(0, this.activeDocument.model.file.uri.lastIndexOf("/")); saveAsSettings.callback = this.saveAsCallback.bind(this); this.application.ninja.newFileController.showSaveAsDialog(saveAsSettings); } -- cgit v1.2.3 From 24d1873302b2fffc25d254e15e8aa36f59eedb88 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 18 May 2012 01:36:05 -0700 Subject: fixed a switch documents bug where the layout was getting called before setting the container. Signed-off-by: Valerio Virgillito --- js/controllers/document-controller.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'js/controllers/document-controller.js') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index ea4022b8..f1523d87 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -492,6 +492,8 @@ var DocumentController = exports.DocumentController = Montage.create(Component, currentDocument.model.views.design.hide(); } + this.application.ninja.stage.clearAllCanvas(); + if(didCreate) { newDocument.model.views.design.iframe.style.opacity = 1; NJevent("onOpenDocument", newDocument); @@ -499,7 +501,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, this.activeDocument = newDocument; newDocument.model.views.design.show(); newDocument.deserializeDocument(); - NJevent("switchDocument"); + NJevent("onSwitchDocument"); } } }, -- cgit v1.2.3 From d878aa470074d5698a316512b513949fa22073f2 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Fri, 18 May 2012 15:23:15 -0700 Subject: Fixing save logic Moved dirty marker clearing code to model. --- js/controllers/document-controller.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'js/controllers/document-controller.js') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index f1523d87..cf618360 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -145,18 +145,19 @@ var DocumentController = exports.DocumentController = Montage.create(Component, value: function(event) { // if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ - // - this.activeDocument.model.save(this.testCallback.bind(this)); //this.fileSaveResult.bind(this) + //Currently we don't need a callback handler + //this.activeDocument.model.save(this.saveExecuted.bind(this)); + this.activeDocument.model.save(); } else { - //Error: + //Error: cloud not available and/or no active document } } }, - testCallback: { + //////////////////////////////////////////////////////////////////// + // + saveExecuted: { value: function (value) { - console.log(value); - //TODO: Move this to the model.save() - this.activeDocument.model.needsSave = false; + //File saved, any callbacks or events should go here } }, //////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From fdfba499f0b84360b96096fa866a981e96e8756c Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 18 May 2012 16:35:56 -0700 Subject: fixing the color chip for the document root Signed-off-by: Valerio Virgillito --- js/controllers/document-controller.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'js/controllers/document-controller.js') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index f1523d87..7721d32d 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -489,6 +489,8 @@ var DocumentController = exports.DocumentController = Montage.create(Component, if(currentDocument) { currentDocument.serializeDocument(); + this.application.ninja.selectionController._selectionContainer = null; + currentDocument.model.views.design.propertiesPanel.clear(); currentDocument.model.views.design.hide(); } -- cgit v1.2.3 From 7a22f7b368ef549a5b30c58a0f3900685b764bdb Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Fri, 18 May 2012 16:56:16 -0700 Subject: integrated open code view document in new dom architecture Signed-off-by: Ananya Sen --- js/controllers/document-controller.js | 65 +++++++++++++---------------------- 1 file changed, 24 insertions(+), 41 deletions(-) (limited to 'js/controllers/document-controller.js') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index cf46e73e..a795d652 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -13,7 +13,8 @@ var Montage = require("montage/core/core").Montage, TextDocument = require("js/document/text-document").TextDocument; // New Document Objects -var Document = require("js/document/document-html").HtmlDocument; +var Document_HTML = require("js/document/document-html").HtmlDocument; +var Document_Text = require("js/document/document-text").TextDocument; //////////////////////////////////////////////////////////////////////// // var DocumentController = exports.DocumentController = Montage.create(Component, { @@ -320,32 +321,30 @@ var DocumentController = exports.DocumentController = Montage.create(Component, //////////////////////////////////////////////////////////////////// openDocument: { - value: function(doc) { + value: function(file) { var template, dimensions; - if (doc.content.body.indexOf('Ninja-Banner Dimensions@@@') !== -1) { - dimensions = (doc.content.body.split('Ninja-Banner Dimensions@@@'))[1].split('-->')[0].split('x'); - dimensions = {width: parseInt(dimensions[0]), height: parseInt(dimensions[1])}; - template = {type: 'banner', size: dimensions}; - } + // TODO: HACKS to remove - this.documentHackReference = doc; + this.documentHackReference = file; document.getElementById("iframeContainer").style.overflow = "hidden"; // - switch (doc.extension) { + switch (file.extension) { case 'html': + + if (file.content.body.indexOf('Ninja-Banner Dimensions@@@') !== -1) { + dimensions = (file.content.body.split('Ninja-Banner Dimensions@@@'))[1].split('-->')[0].split('x'); + dimensions = {width: parseInt(dimensions[0]), height: parseInt(dimensions[1])}; + template = {type: 'banner', size: dimensions}; + } + //Open in designer view this._hackRootFlag = false; - Montage.create(Document).init(doc, this, this._onOpenDocument, 'design', template); + Montage.create(Document_HTML).init(file, this, this._onOpenDocument, 'design', template); break; default: - //Open in code view - var code = Montage.create(TextDocument, {"source": {value: doc.content}}), docuuid = Uuid.generate(), textArea; - textArea = this.application.ninja.stage.stageView.createTextAreaElement(docuuid); - code.initialize(doc, docuuid, textArea, textArea.parentNode); - //code.init(doc.name, doc.uri, doc.extension, null, docuuid); - code.textArea.value = doc.content; - this.application.ninja.stage.stageView.createTextView(code); - break; + //Open in code view + Montage.create(Document_Text).init(file, this, this._onOpenTextDocument, 'code'); + break; } } }, @@ -514,9 +513,10 @@ var DocumentController = exports.DocumentController = Montage.create(Component, _onOpenTextDocument: { value: function(doc) { if(this.activeDocument) { + if(this.activeDocument.currentView === "design"){ this.activeDocument.saveAppState(); - this.activeDocument.container.parentNode.style["display"] = "none"; + this.activeDocument.parentContainer.style["display"] = "none"; this.application.ninja.stage.hideCanvas(true); this.application.ninja.stage.stageView.hideRulers(); } @@ -526