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/clipboard-controller.js | 4 +- js/controllers/color-controller.js | 282 +++++++++++++------------- js/controllers/document-controller.js | 160 +++++++-------- js/controllers/elements/controller-factory.js | 2 +- js/controllers/elements/element-controller.js | 26 +-- js/controllers/elements/shapes-controller.js | 2 +- js/controllers/selection-controller.js | 10 +- 7 files changed, 243 insertions(+), 243 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/clipboard-controller.js b/js/controllers/clipboard-controller.js index 74aef060..e3aa76df 100644 --- a/js/controllers/clipboard-controller.js +++ b/js/controllers/clipboard-controller.js @@ -30,8 +30,8 @@ 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, ElementsClipboardAgent = require("js/clipboard/internal-ops/elements-clipboard-agent").ElementsClipboardAgent, ExternalAppsClipboardAgent= require("js/clipboard/external-apps-clipboard-agent").ExternalAppsClipboardAgent; diff --git a/js/controllers/color-controller.js b/js/controllers/color-controller.js index c5c614ea..194b7153 100755 --- a/js/controllers/color-controller.js +++ b/js/controllers/color-controller.js @@ -30,13 +30,13 @@ POSSIBILITY OF SUCH DAMAGE. //////////////////////////////////////////////////////////////////////// // -var Montage = require("montage/core/core").Montage, - Component = require("montage/ui/component").Component, - ColorModel = require("js/models/color-model").ColorModel, - ColorPanelBase = require("js/panels/Color/colorpanelbase.reel").ColorPanelBase, - ElementsMediator = require("js/mediators/element-mediator").ElementMediator, - ColorPopupManager = require("js/panels/Color/colorpopup-manager").ColorPopupManager, - ColorButtonManager = require("js/panels/Color/colorbutton-manager").ColorButtonManager; +var Montage = require("montage/core/core").Montage, + Component = require("montage/ui/component").Component, + ColorModel = require("js/models/color-model").ColorModel, + ColorPanelBase = require("js/panels/Color/colorpanelbase.reel").ColorPanelBase, + ElementsMediator = require("js/mediators/element-mediator").ElementMediator, + ColorPopupManager = require("js/panels/Color/colorpopup-manager").ColorPopupManager, + ColorButtonManager = require("js/panels/Color/colorbutton-manager").ColorButtonManager; //////////////////////////////////////////////////////////////////////// //Exporting as ColorController exports.ColorController = Montage.create(Component, { @@ -48,14 +48,14 @@ exports.ColorController = Montage.create(Component, { //////////////////////////////////////////////////////////////////// // deserializedFromTemplate: { - value: function () { - //Setting up colorManager in other classes - this.colorPanelBase.colorManager = this.colorModel; - this.colorPopupManager.colorManager = this.colorModel; - this.colorButtonManager.colorManager = this.colorModel; - //Listening for color changes - this.colorModel.addEventListener('change', this, false); - } + value: function () { + //Setting up colorManager in other classes + this.colorPanelBase.colorManager = this.colorModel; + this.colorPopupManager.colorManager = this.colorModel; + this.colorButtonManager.colorManager = this.colorModel; + //Listening for color changes + this.colorModel.addEventListener('change', this, false); + } }, //////////////////////////////////////////////////////////////////// // @@ -90,7 +90,7 @@ exports.ColorController = Montage.create(Component, { //////////////////////////////////////////////////////////////////// // _popupTab: { - value: 'wheel' + value: 'wheel' }, //////////////////////////////////////////////////////////////////// // @@ -131,7 +131,7 @@ exports.ColorController = Montage.create(Component, { //////////////////////////////////////////////////////////////////// // _fill: { - value: null + value: null }, //////////////////////////////////////////////////////////////////// // @@ -142,7 +142,7 @@ exports.ColorController = Montage.create(Component, { //////////////////////////////////////////////////////////////////// // _stroke: { - value: null + value: null }, //////////////////////////////////////////////////////////////////// // @@ -154,16 +154,16 @@ exports.ColorController = Montage.create(Component, { // getBackground: { value: function (element) { - //TODO: Return object with all background properties - console.log(ElementsMediator.getProperty(element, 'background-color')); - console.log(ElementsMediator.getProperty(element, 'background-image')); + //TODO: Return object with all background properties + console.log(ElementsMediator.getProperty(element, 'background-color')); + console.log(ElementsMediator.getProperty(element, 'background-image')); } }, //////////////////////////////////////////////////////////////////// // getBorder: { value: function (element) { - + } }, //////////////////////////////////////////////////////////////////// @@ -189,14 +189,14 @@ exports.ColorController = Montage.create(Component, { // handleChange: { value: function (e) { - // + // var color, input = e._event.input, panelMode, mode = e._event.mode; if (this.colorView) { - panelMode = this.colorView.panelMode; + panelMode = this.colorView.panelMode; } // if (mode === 'nocolor') { - color = {value: null, css: 'none'}; + color = {value: null, css: 'none'}; } else if (panelMode === 'rgb' && e._event.rgba && mode !== 'gradient') { color = e._event.rgba; color.webGlColor = e._event.webGlColor; @@ -206,7 +206,7 @@ exports.ColorController = Montage.create(Component, { } else if (mode !== 'gradient'){ color = {value: e._event.hex, css: '#'+e._event.hex}; } else if (mode === 'gradient'){ - color = e._event.value.value; + color = e._event.value.value; } color.mode = panelMode; color.wasSetByCode = true; @@ -215,15 +215,15 @@ exports.ColorController = Montage.create(Component, { //////////////////////////////////////////////////////////// // if (input === 'fill') { - // - this.fill = color; + // + this.fill = color; // if(e._event.wasSetByCode) return; - // + // this.setColor(mode, color, true); } else if (input === 'stroke') { - // - this.stroke = color; + // + this.stroke = color; // if(e._event.wasSetByCode) return; @@ -237,93 +237,93 @@ exports.ColorController = Montage.create(Component, { //Converts CSS to a color object to be used by the color model getColorObjFromCss: { value: function (css) { - // - var color, arr, i, j, temp, c, gradient; - //console.log(css.indexOf('-webkit'), css); - if (css && css.indexOf('-webkit') >= 0) { - // - gradient = {mode: null, stops: null}; - //Checking for gradient type - if (css.indexOf('-webkit-radial-gradient') >= 0) { - //Radial gradient - gradient.stops = []; - gradient.mode = 'radial'; - gradient.gradientMode = 'radial'; - gradient.css = css; - // - arr = css.split('%,'); - // - for (j=1; arr[j]; j++) { - //TODO: Add HSL support - if (arr[j].indexOf('rgb') >= 0 && arr[j].indexOf('rgba') < 0) { - temp = arr[j].split('rgb'); - temp = temp[1].replace(/\(/i, ""); - temp = temp.split(')'); - c = this.parseCssToColor('rgb('+temp[0]+')'); - gradient.stops.push({css: c.css, value: c.value, mode: c.mode, position: parseInt(temp[1].replace(/\%/i, ""))}); - } else if (css.indexOf('rgba') >= 0) { - - temp = arr[j].split('rgba'); - temp = temp[1].replace(/\(/i, ""); - temp = temp.split(')'); - c = this.parseCssToColor('rgba('+temp[0]+')'); - gradient.stops.push({css: c.css, value: c.value, mode: c.mode, position: parseInt(temp[1].replace(/\%/i, ""))}); - } - } - } else if (css.indexOf('-webkit-gradient') >= 0) { - //Linear gradient - gradient.stops = []; - gradient.mode = 'linear'; - gradient.gradientMode = 'linear'; - gradient.css = css; - // - arr = css.split('from('); - // - if (arr.length > 1) { - arr = arr[1].split('),'); - } else { - arr = (css.split(css.split('color-stop(')[0])[1]).split('),'); - } - // - for (i=0; arr[i]; i++) { - arr[i] = arr[i].replace(/ color-stop\(/i, ""); - // - if (arr[i].indexOf('to(') >= 0) { - arr[i] = arr[i].replace(/ to\(/i, ""); - arr[i] = arr[i].replace(/\)\)/i, ""); - } - // - if (i === 0 && arr[i].indexOf('color-stop') === -1) { - arr[i] = {css: arr[i], percent: 0}; - } else if (i === arr.length-1) { - temp = arr[i].split(', rgb'); - if (temp.length > 1) { - arr[i] = {css: 'rgb'+temp[1].replace(/\)\)/i, ""), percent: Math.round(parseFloat(temp[0])*100)}; - } else { - arr[i] = {css: arr[i], percent: 100}; - } - } else { - // - if (arr[i].indexOf('rgb') >= 0 && arr[i].indexOf('rgba') < 0) { - temp = arr[i].split(', rgb'); - temp[0] = temp[0].replace(/color\-stop\(/gi, ''); - arr[i] = {css: 'rgb'+temp[1], percent: Math.round(parseFloat(temp[0])*100)}; - } else if (arr[i].indexOf('rgba') >= 0) { - temp = arr[i].split(', rgba'); - arr[i] = {css: 'rgba'+temp[1], percent: Math.round(parseFloat(temp[0])*100)}; - } - } - // - c = this.parseCssToColor(arr[i].css); - gradient.stops.push({css: c.css, value: c.value, mode: c.mode, position: arr[i].percent}); - } - } - //Creating gradient object - color = {mode: 'gradient', value: {stops: gradient.stops, mode: gradient.mode, gradientMode: gradient.gradientMode, css: css}}; - } else if (css){ - //Simple solid color - color = this.parseCssToColor(css); - } + // + var color, arr, i, j, temp, c, gradient; + //console.log(css.indexOf('-webkit'), css); + if (css && css.indexOf('-webkit') >= 0) { + // + gradient = {mode: null, stops: null}; + //Checking for gradient type + if (css.indexOf('-webkit-radial-gradient') >= 0) { + //Radial gradient + gradient.stops = []; + gradient.mode = 'radial'; + gradient.gradientMode = 'radial'; + gradient.css = css; + // + arr = css.split('%,'); + // + for (j=1; arr[j]; j++) { + //TODO: Add HSL support + if (arr[j].indexOf('rgb') >= 0 && arr[j].indexOf('rgba') < 0) { + temp = arr[j].split('rgb'); + temp = temp[1].replace(/\(/i, ""); + temp = temp.split(')'); + c = this.parseCssToColor('rgb('+temp[0]+')'); + gradient.stops.push({css: c.css, value: c.value, mode: c.mode, position: parseInt(temp[1].replace(/\%/i, ""))}); + } else if (css.indexOf('rgba') >= 0) { + + temp = arr[j].split('rgba'); + temp = temp[1].replace(/\(/i, ""); + temp = temp.split(')'); + c = this.parseCssToColor('rgba('+temp[0]+')'); + gradient.stops.push({css: c.css, value: c.value, mode: c.mode, position: parseInt(temp[1].replace(/\%/i, ""))}); + } + } + } else if (css.indexOf('-webkit-gradient') >= 0) { + //Linear gradient + gradient.stops = []; + gradient.mode = 'linear'; + gradient.gradientMode = 'linear'; + gradient.css = css; + // + arr = css.split('from('); + // + if (arr.length > 1) { + arr = arr[1].split('),'); + } else { + arr = (css.split(css.split('color-stop(')[0])[1]).split('),'); + } + // + for (i=0; arr[i]; i++) { + arr[i] = arr[i].replace(/ color-stop\(/i, ""); + // + if (arr[i].indexOf('to(') >= 0) { + arr[i] = arr[i].replace(/ to\(/i, ""); + arr[i] = arr[i].replace(/\)\)/i, ""); + } + // + if (i === 0 && arr[i].indexOf('color-stop') === -1) { + arr[i] = {css: arr[i], percent: 0}; + } else if (i === arr.length-1) { + temp = arr[i].split(', rgb'); + if (temp.length > 1) { + arr[i] = {css: 'rgb'+temp[1].replace(/\)\)/i, ""), percent: Math.round(parseFloat(temp[0])*100)}; + } else { + arr[i] = {css: arr[i], percent: 100}; + } + } else { + // + if (arr[i].indexOf('rgb') >= 0 && arr[i].indexOf('rgba') < 0) { + temp = arr[i].split(', rgb'); + temp[0] = temp[0].replace(/color\-stop\(/gi, ''); + arr[i] = {css: 'rgb'+temp[1], percent: Math.round(parseFloat(temp[0])*100)}; + } else if (arr[i].indexOf('rgba') >= 0) { + temp = arr[i].split(', rgba'); + arr[i] = {css: 'rgba'+temp[1], percent: Math.round(parseFloat(temp[0])*100)}; + } + } + // + c = this.parseCssToColor(arr[i].css); + gradient.stops.push({css: c.css, value: c.value, mode: c.mode, position: arr[i].percent}); + } + } + //Creating gradient object + color = {mode: 'gradient', value: {stops: gradient.stops, mode: gradient.mode, gradientMode: gradient.gradientMode, css: css}}; + } else if (css){ + //Simple solid color + color = this.parseCssToColor(css); + } // TODO - Hack for inconsistent color object -- some workflows set color.color and some color.value if(color) { @@ -337,36 +337,36 @@ exports.ColorController = Montage.create(Component, { } } //Returning color object (or null if none) - return color; + return color; } }, //////////////////////////////////////////////////////////////////// //Parses simple solid CSS string into color object parseCssToColor: { value: function (css) { - var color, r, p; - //Parsing string and converting into color object - if (css.indexOf('#') >= 0) { - color = {mode: 'hex', css: css, value: css.split('#')[1]}; - } else if (css.indexOf('rgb') >= 0 && css.indexOf('rgba') < 0) { - r = /^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/; - p = css.match(r); + var color, r, p; + //Parsing string and converting into color object + if (css.indexOf('#') >= 0) { + color = {mode: 'hex', css: css, value: css.split('#')[1]}; + } else if (css.indexOf('rgb') >= 0 && css.indexOf('rgba') < 0) { + r = /^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/; + p = css.match(r); color = {mode: 'rgb', css: css, value: {css: css, r: parseInt(p[1]), g: parseInt(p[2]), b: parseInt(p[3]), a: 1}}; - } else if (css.indexOf('rgba') >= 0) { - r = /^rgba\((\d+),\s*(\d+),\s*(\d+),\s*(\d*\.?\d+)\)$/; - p = css.match(r); - color = {mode: 'rgb', css: css, value: {css: css, r: parseInt(p[1]), g: parseInt(p[2]), b: parseInt(p[3]), a: parseFloat(p[4])}}; - } else if (css.indexOf('hsl') >= 0 && css.indexOf('hsla') < 0) { - r = /^hsl\((\d+),\s*(\d+),\s*(\d+)\)$/; - p = css.match(r); - color = {mode: 'hsl', css: css, value: {css: css, h: parseInt(p[1]), s: parseInt(p[2]), l: parseInt(p[3]), a: 1}}; - } if (css.indexOf('hsla') >= 0) { - r = /^hsla\((\d+),\s*(\d+),\s*(\d+),\s*(\d*\.?\d+)\)$/; - p = css.match(r); - color = {mode: 'hsl', css: css, value: {css: css, h: parseInt(p[1]), s: parseInt(p[2]), l: parseInt(p[3]), a: parseFloat(p[4])}}; - } - //Must be a valid CSS or null will be returned - return color; + } else if (css.indexOf('rgba') >= 0) { + r = /^rgba\((\d+),\s*(\d+),\s*(\d+),\s*(\d*\.?\d+)\)$/; + p = css.match(r); + color = {mode: 'rgb', css: css, value: {css: css, r: parseInt(p[1]), g: parseInt(p[2]), b: parseInt(p[3]), a: parseFloat(p[4])}}; + } else if (css.indexOf('hsl') >= 0 && css.indexOf('hsla') < 0) { + r = /^hsl\((\d+),\s*(\d+),\s*(\d+)\)$/; + p = css.match(r); + color = {mode: 'hsl', css: css, value: {css: css, h: parseInt(p[1]), s: parseInt(p[2]), l: parseInt(p[3]), a: 1}}; + } if (css.indexOf('hsla') >= 0) { + r = /^hsla\((\d+),\s*(\d+),\s*(\d+),\s*(\d*\.?\d+)\)$/; + p = css.match(r); + color = {mode: 'hsl', css: css, value: {css: css, h: parseInt(p[1]), s: parseInt(p[2]), l: parseInt(p[3]), a: parseFloat(p[4])}}; + } + //Must be a valid CSS or null will be returned + return color; } } //////////////////////////////////////////////////////////////////// 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); } diff --git a/js/controllers/elements/controller-factory.js b/js/controllers/elements/controller-factory.js index 2bf3eae0..eb8e977c 100755 --- a/js/controllers/elements/controller-factory.js +++ b/js/controllers/elements/controller-factory.js @@ -33,7 +33,7 @@ var Montage = require("montage/core/core").Montage; var BodyController = require("js/controllers/elements/body-controller").BodyController, BlockController = require("js/controllers/elements/block-controller").BlockController, ShapesController = require("js/controllers/elements/shapes-controller").ShapesController, - ImageController = require("js/controllers/elements/image-controller").ImageController, + ImageController = require("js/controllers/elements/image-controller").ImageController, VideoController = require("js/controllers/elements/video-controller").VideoController, ComponentController = require("js/controllers/elements/component-controller").ComponentController, CanvasController = require("js/controllers/elements/canvas-controller").CanvasController; diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js index 39efcf0c..646fa455 100755 --- a/js/controllers/elements/element-controller.js +++ b/js/controllers/elements/element-controller.js @@ -37,21 +37,21 @@ exports.ElementController = Montage.create(Component, { addElement: { value: function(el, styles) { - if (el.getAttribute) el.setAttribute('data-ninja-node', 'true'); - - // Updated to use new methods in TimelinePanel. JR. - var insertionIndex = this.application.ninja.timeline.getInsertionIndex(); - if (insertionIndex === false) { - this.application.ninja.currentDocument.model.domContainer.appendChild(el); - } else { - if (insertionIndex === 0) { - this.application.ninja.currentDocument.model.domContainer.appendChild(el); - } else { + if (el.getAttribute) el.setAttribute('data-ninja-node', 'true'); + + // Updated to use new methods in TimelinePanel. JR. + var insertionIndex = this.application.ninja.timeline.getInsertionIndex(); + if (insertionIndex === false) { + this.application.ninja.currentDocument.model.domContainer.appendChild(el); + } else { + if (insertionIndex === 0) { + this.application.ninja.currentDocument.model.domContainer.appendChild(el); + } else { var element = this.application.ninja.timeline.arrLayers[insertionIndex].layerData.stageElement; element.parentNode.insertBefore(el, element.nextSibling); - } - } - + } + } + if(styles) { this.application.ninja.stylesController.setElementStyles(el, styles); } diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js index a0d3c0d6..bef315ba 100755 --- a/js/controllers/elements/shapes-controller.js +++ b/js/controllers/elements/shapes-controller.js @@ -28,7 +28,7 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -var Montage = require("montage/core/core").Montage, +var Montage = require("montage/core/core").Montage, CanvasController = require("js/controllers/elements/canvas-controller").CanvasController, njModule = require("js/lib/NJUtils"), World = require("js/lib/drawing/world").World, diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js index d0e239b6..ad3e2464 100755 --- a/js/controllers/selection-controller.js +++ b/js/controllers/selection-controller.js @@ -261,11 +261,11 @@ exports.SelectionController = Montage.create(Component, { } }, - isObjectSelected: { - value: function( elt ) { - return this.findSelectedElement(elt) > -1; - } - }, + isObjectSelected: { + value: function( elt ) { + return this.findSelectedElement(elt) > -1; + } + }, findSelectedElement: { value: function(item) { -- cgit v1.2.3