From 648ee61ae84216d0236e0dbc211addc13b2cfa3a Mon Sep 17 00:00:00 2001 From: Kris Kowal Date: Fri, 6 Jul 2012 11:52:06 -0700 Subject: Expand tabs --- js/controllers/document-controller.js | 160 +++++++++++++++++----------------- 1 file changed, 80 insertions(+), 80 deletions(-) (limited to 'js/controllers/document-controller.js') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 1a8fec98..1857dfd7 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -30,14 +30,14 @@ POSSIBILITY OF SUCH DAMAGE. //////////////////////////////////////////////////////////////////////// // -var Montage = require("montage/core/core").Montage, - Component = require("montage/ui/component").Component, +var Montage = require("montage/core/core").Montage, + Component = require("montage/ui/component").Component, HTMLDocument = require("js/document/document-html").HtmlDocument, TextDocument = require("js/document/document-text").TextDocument; //////////////////////////////////////////////////////////////////////// // exports.DocumentController = Montage.create(Component, { - // + // hasTemplate: { value: false }, @@ -110,45 +110,45 @@ exports.DocumentController = Montage.create(Component, { } }, - //TODO: Ensure these APIs are not needed - redirectRequests: { - value: false + //TODO: Ensure these APIs are not needed + redirectRequests: { + value: false }, - //////////////////////////////////////////////////////////////////// - // + //////////////////////////////////////////////////////////////////// + // handleWebRequest: { - value: function (request) { - //TODO: Check if frameId is proper - if (this.redirectRequests && request.parentFrameId !== -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.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.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split(chrome.extension.getURL('js/document/templates/html/'))[1]}; - } else if (request.url.indexOf('js/document/templates/app') !== -1) { - return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+this.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split(chrome.extension.getURL('js/document/templates/app/'))[1]}; - } else { - //Error, not a valid folder - } - } - } + value: function (request) { + //TODO: Check if frameId is proper + if (this.redirectRequests && request.parentFrameId !== -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.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.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split(chrome.extension.getURL('js/document/templates/html/'))[1]}; + } else if (request.url.indexOf('js/document/templates/app') !== -1) { + return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+this.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split(chrome.extension.getURL('js/document/templates/app/'))[1]}; + } else { + //Error, not a valid folder + } + } + } }, //////////////////////////////////////////////////////////////////// - // + // handleAppLoaded: { value: function() { //Checking for app to be loaded through extension var check; if (chrome && chrome.app) { - check = chrome.app.getDetails(); + check = chrome.app.getDetails(); } if (check !== null) { - //Adding an intercept to resources loaded to ensure user assets load from cloud simulator - chrome.webRequest.onBeforeRequest.addListener(this.handleWebRequest.bind(this), {urls: [""]}, ["blocking"]); + //Adding an intercept to resources loaded to ensure user assets load from cloud simulator + chrome.webRequest.onBeforeRequest.addListener(this.handleWebRequest.bind(this), {urls: [""]}, ["blocking"]); } } }, - //////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////// handleExecuteFileOpen: { @@ -172,39 +172,39 @@ exports.DocumentController = Montage.create(Component, { } } }, - //////////////////////////////////////////////////////////////////// - // + //////////////////////////////////////////////////////////////////// + // handleExecuteSave: { - value: function(event) { - // - if((typeof this.currentDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ - //Currently we don't need a callback handler - //this.activeDocument.model.save(this.saveExecuted.bind(this)); - this.currentDocument.model.save(); - } else { - //Error: cloud not available and/or no active document - } - } + value: function(event) { + // + if((typeof this.currentDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ + //Currently we don't need a callback handler + //this.activeDocument.model.save(this.saveExecuted.bind(this)); + this.currentDocument.model.save(); + } else { + //Error: cloud not available and/or no active document + } + } }, //////////////////////////////////////////////////////////////////// - // + // saveExecuted: { - value: function (value) { - //File saved, any callbacks or events should go here (must be added in handleExecuteSave passed as callback) - } + value: function (value) { + //File saved, any callbacks or events should go here (must be added in handleExecuteSave passed as callback) + } }, //////////////////////////////////////////////////////////////////// - //TODO: Check for appropiate structures + //TODO: Check for appropiate structures handleExecuteSaveAll: { - value: function(event) { + value: function(event) { // - if((typeof this.currentDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ - // - this.currentDocument.model.saveAll(); - } else { - //TODO: Add error handling - } - } + if((typeof this.currentDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ + // + this.currentDocument.model.saveAll(); + } else { + //TODO: Add error handling + } + } }, //////////////////////////////////////////////////////////////////// handleExecuteSaveAs: { @@ -227,16 +227,16 @@ exports.DocumentController = Montage.create(Component, { //////////////////////////////////////////////////////////////////// //TODO: Is this used, should be cleaned up handleExecuteFileCloseAll:{ - value: function(event) { - if(this.currentDocument && this.application.ninja.coreIoApi.cloudAvailable()){ - while(this.currentDocument.length > 0){ - this.closeDocument(this.currentDocument[this.currentDocument.length -1].uuid); - } - } - } - }, - //////////////////////////////////////////////////////////////////// - // + value: function(event) { + if(this.currentDocument && this.application.ninja.coreIoApi.cloudAvailable()){ + while(this.currentDocument.length > 0){ + this.closeDocument(this.currentDocument[this.currentDocument.length -1].uuid); + } + } + } + }, + //////////////////////////////////////////////////////////////////// + // createNewFile:{ value:function(newFileObj){ // @@ -245,8 +245,8 @@ exports.DocumentController = Montage.create(Component, { this.application.ninja.ioMediator.fileNew(newFileObj.newFilePath, newFileObj.fileTemplateUri, this.openNewFileCallback.bind(this), newFileObj.template); } }, - //////////////////////////////////////////////////////////////////// - + //////////////////////////////////////////////////////////////////// + /** * Public method * doc contains: @@ -296,7 +296,7 @@ exports.DocumentController = Montage.create(Component, { } this.isNewFilePath = false;//reset path identifier flag - //Sending full response object + //Sending full response object this.openDocument(response); } else if (!!response && (response.status === 404)){ @@ -309,8 +309,8 @@ exports.DocumentController = Montage.create(Component, { } }, - //////////////////////////////////////////////////////////////////// - // + //////////////////////////////////////////////////////////////////// + // saveAsCallback:{ value:function(saveAsDetails){ var fileUri = null, filename = saveAsDetails.filename, destination = saveAsDetails.destination; @@ -334,14 +334,14 @@ exports.DocumentController = Montage.create(Component, { //////////////////////////////////////////////////////////////////// openDocument: { value: function(file) { - var template, dimensions; + var template, dimensions; // TODO: HACKS to remove - this.documentHackReference = file; + this.documentHackReference = file; document.getElementById("iframeContainer").style.overflow = "hidden"; - // - switch (file.extension) { - case 'html': + // + 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'); @@ -349,20 +349,20 @@ exports.DocumentController = Montage.create(Component, { template = {type: 'banner', size: dimensions}; } - //Open in designer view + //Open in designer view this.redirectRequests = false; Montage.create(HTMLDocument).init(file, this.application.ninja, this.application.ninja.openDocument, 'design', template); - break; - default: + break; + default: //Open in code view Montage.create(TextDocument).init(file, this.application.ninja, this.application.ninja.openDocument, 'code'); break; - } + } } }, - //////////////////////////////////////////////////////////////////// - - openProjectWithURI: { + //////////////////////////////////////////////////////////////////// + + openProjectWithURI: { value: function(uri) { console.log("URI is: ", uri); } -- cgit v1.2.3 From 04343eda8c2f870b0da55cfdc8003c99fe1cc4de Mon Sep 17 00:00:00 2001 From: Kris Kowal Date: Fri, 6 Jul 2012 11:53:10 -0700 Subject: Remove trailing spaces --- 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 1857dfd7..bab2ed0e 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -246,7 +246,7 @@ exports.DocumentController = Montage.create(Component, { } }, //////////////////////////////////////////////////////////////////// - + /** * Public method * doc contains: @@ -361,7 +361,7 @@ exports.DocumentController = Montage.create(Component, { } }, //////////////////////////////////////////////////////////////////// - + openProjectWithURI: { value: function(uri) { console.log("URI is: ", uri); -- cgit v1.2.3 From fdbec324dad4ab33d97282ab021d2c1661bc097c Mon Sep 17 00:00:00 2001 From: Kris Kowal Date: Mon, 9 Jul 2012 16:27:52 -0700 Subject: BSD License --- js/controllers/document-controller.js | 23 ++++++++++++----------- 1 file changed, 12 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 bab2ed0e..588481bb 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -1,24 +1,25 @@ /* -Copyright (c) 2012, Motorola Mobility, Inc +Copyright (c) 2012, Motorola Mobility LLC. All Rights Reserved. -BSD License. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - Neither the name of Motorola Mobility nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. +* Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of Motorola Mobility LLC nor the names of its + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -- cgit v1.2.3