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 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/color-controller.js | 8 +- js/controllers/document-controller.js | 4 +- js/controllers/elements/element-controller.js | 8 +- js/controllers/elements/shapes-controller.js | 2 +- js/controllers/objects-controller.js | 6 +- js/controllers/styles-controller.js | 276 +++++++++++++------------- js/controllers/undo-controller.js | 2 +- 7 files changed, 153 insertions(+), 153 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/color-controller.js b/js/controllers/color-controller.js index 194b7153..8be2421f 100755 --- a/js/controllers/color-controller.js +++ b/js/controllers/color-controller.js @@ -27,7 +27,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 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, @@ -163,7 +163,7 @@ exports.ColorController = Montage.create(Component, { // getBorder: { value: function (element) { - + } }, //////////////////////////////////////////////////////////////////// @@ -262,14 +262,14 @@ exports.ColorController = Montage.create(Component, { 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 = []; 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); diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js index 646fa455..59ac238c 100755 --- a/js/controllers/elements/element-controller.js +++ b/js/controllers/elements/element-controller.js @@ -36,9 +36,9 @@ 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) { @@ -51,7 +51,7 @@ exports.ElementController = Montage.create(Component, { element.parentNode.insertBefore(el, element.nextSibling); } } - + if(styles) { this.application.ninja.stylesController.setElementStyles(el, styles); } @@ -67,7 +67,7 @@ exports.ElementController = Montage.create(Component, { el.parentNode.removeChild(el); } }, - + getProperty: { value: function(el, prop, fallbackOnComputed, isStageElement) { if(el.nodeType !== 3){ diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js index bef315ba..e6774858 100755 --- a/js/controllers/elements/shapes-controller.js +++ b/js/controllers/elements/shapes-controller.js @@ -300,7 +300,7 @@ exports.ShapesController = Montage.create(CanvasController, { return null; } break; - + case "strokeMaterial": var sm = el.elementModel.shapeModel.GLGeomObj.getStrokeMaterial(); diff --git a/js/controllers/objects-controller.js b/js/controllers/objects-controller.js index 0462df98..32eecf20 100644 --- a/js/controllers/objects-controller.js +++ b/js/controllers/objects-controller.js @@ -73,11 +73,11 @@ var objectsController = exports.ObjectsController = Montage.create(Montage, { } } }, - + /* -------------------------- Binding Methods ----------------------------- */ - + addBinding : { value: function(bindingArgs) { if(!bindingArgs.sourceObject || !bindingArgs.sourceObjectPropertyPath || !bindingArgs) { return; } @@ -122,7 +122,7 @@ var objectsController = exports.ObjectsController = Montage.create(Montage, { } }, - + getObjectBindings : { value: function(object) { var descriptors = object._bindingDescriptors, diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js index 1030acb4..973c3aa1 100755 --- a/js/controllers/styles-controller.js +++ b/js/controllers/styles-controller.js @@ -59,26 +59,26 @@ Methods: - Delete stylesheets - Enable stylesheets - Disable stylesheets - + use case : set background color - needs to know most specific rule WITH that property - - + - */ var stylesController = exports.StylesController = Montage.create(Component, { - + ///// Initialize after the active document has been set, and ///// bind the document to prop w/ setter. The setter calls to find ///// the stage and default css files. - ///// Active document gets automatically set when the + ///// Active document gets automatically set when the ///// document controller changes it _currentDocument : { value : null, enumerable : false }, - + currentDocument : { get : function() { return this._currentDocument; @@ -97,7 +97,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { ///// setting document via binding this._currentDocument = document; - + ///// Stage stylesheet should always be found this._stageStylesheet = this.getSheetFromElement(this.CONST.STAGE_SHEET_ID); // Returns null if sheet not found (as in non-ninja projects) @@ -191,29 +191,29 @@ var stylesController = exports.StylesController = Montage.create(Component, { } }, /* ----------------- Rule methods ----------------- */ - + ///// Add Rule ///// Passed in rule will be appended to the default stylesheet ///// The rule can be in the form of a string (one argument), or ///// the selector string and declaration string (two arguments), or ///// the selector string and a declaration object. ///// Optionally pass in the rule index (defaults to end of sheet) - + /* - Signature 1 : + Signature 1 : addRule( "#div1", "color:blue; width:100px;", 3) [str] [str] [num] - - Signature 2 (w/ styles object literal): + + Signature 2 (w/ styles object literal): addRule( "#div1", { color:"blue", width:"100px" }, 3) [str] [obj] [num] - - Signature 3 (w/ full rule as one string) : + + Signature 3 (w/ full rule as one string) : addRule( "#div1 { color:blue; width:100px; }", 3) [str] [num] - + */ - + addRule : { value : function(selector, declaration, stylesheet, index) { stylesheet = stylesheet || this._defaultStylesheet; @@ -228,20 +228,20 @@ var stylesController = exports.StylesController = Montage.create(Component, { rule; index = index || (argType === 'number') ? declaration : rulesLength; - + if(argType === 'string') { ruleText += '{' + declaration + '}'; } else if(argType === 'object') { ruleText += '{' + this.cssFromObject(declaration) + '}'; } - + stylesheet.insertRule(ruleText, index); ///// Invalidate cache because rule dominance is affected this._clearCache(); this.styleSheetModified(stylesheet); - + rule = stylesheet.rules[index]; ///// attach specificity to rule object @@ -256,7 +256,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { return rule; } }, - + ///// Create Override Rule ///// Takes a given rule and creates a rule with a selector of equal ///// or greater specificity, and inserts it after the original rule @@ -264,10 +264,10 @@ var stylesController = exports.StylesController = Montage.create(Component, { ///// and the class will have to be applied to the element in order for ///// the rule to stick ///// Returns an object containing this classname and the rule itself - + createOverrideRule : { value : function(ruleToOverride, element) { - + ///// Locally-scoped function to de-clutter variable declarations function getSelector(el, rule) { return this._getMostSpecificSelectorForElement(el, rule[this.CONST.SPECIFICITY_KEY]).selector; @@ -283,12 +283,12 @@ var stylesController = exports.StylesController = Montage.create(Component, { ///// Create new rule with selector and insert it after the rule we're overriding rule = this.addRule(overrideData.selector + ' { }', this.getRuleIndex(ruleToOverride)+1); - + return { className : overrideData.className, rule : rule }; - + } }, @@ -341,18 +341,18 @@ var stylesController = exports.StylesController = Montage.create(Component, { }; } }, - + ///// Delete Rule ///// Deletes the passed-in rule from its stylesheet ///// Argument can be the index of the rule, or the rule itself ///// If the index is passed, the sheet must be passed in - + deleteRule : { value : function(rule, sheet) { var index; - + if(typeof rule === 'number') { - ///// 1st arg is the index + ///// 1st arg is the index index = rule; } else { ///// derive the index of the rule @@ -360,7 +360,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { ///// the sheet is a property of the rule sheet = rule.parentStyleSheet; } - + if(index > -1) { sheet.deleteRule(index); } @@ -370,22 +370,22 @@ var stylesController = exports.StylesController = Montage.create(Component, { return index; } }, - + ///// Get Dominant Rule For Style - ///// Given an element, this method returns the dominant rule + ///// Given an element, this method returns the dominant rule ///// for the particular style property. ///// Optionally, it returns an override object if no single-target ///// rule is found. ///// An override object consists of a rule to override, and a ///// flag for using !important or not - + getDominantRuleForElement : { value : function(element, property, returnOverrideObject, useStageStyleSheet) { var matchedRules = this.getMatchingRules(element, true, useStageStyleSheet), doc = element.ownerDocument, useImportant = false, inLineStyleRule, rulesWithProperty, importantRules, dominantRule; - + ///// First, since an element's style attribute is a CSSStyleDeclaration ///// and not a CSSStyleRule, we want to create an imitation rule object ///// to act like any returned by getMatchedCSSRules @@ -417,7 +417,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { - Get 2) No rules with the property (i.e., no chance of property collision) - use the original rule list to find the most specific, single-target rule - - start with the highest specificity to minimize calls to querySelectorAll() + - start with the highest specificity to minimize calls to querySelectorAll() - if there is no single-target rule, create a new rule to apply this style */ @@ -439,7 +439,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { //dominantRule = this._getFirstSingleTargetRule(rulesWithProperty, doc); dominantRule = rulesWithProperty[0]; } - + } else { // no rules with property ///// In this case, we don't want to use the inline style ///// Important flag is irrelevant because the style property isn't defined @@ -457,7 +457,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { singleTargetBackup : this._getFirstSingleTargetRule(matchedRules.slice(1), doc) }; } - + return dominantRule; } }, @@ -525,58 +525,58 @@ var stylesController = exports.StylesController = Montage.create(Component, { ///// Disable Rule ///// Disables a rule by giving it a known garbage selector - + disableRule : { value : function(rule, sheet) { rule = (typeof rule === 'number') ? sheet.rules[rule] : rule; - + rule.selectorText += this.CONST.GARBAGE_SELECTOR; - + return rule; } }, - + ///// Enable Rule ///// Enables a rule by removing the known garbage selector - + enableRule : { value : function(rule, sheet) { rule = (typeof rule === 'number') ? sheet.rules[rule] : rule; - + ///// remove any occurances of the garbage selector rule.selectorText.replace(this.CONST.GARBAGE_SELECTOR, ''); - + return rule; } }, - + ///// Has Property ///// Checks to see if a rule has the property defined in ///// its declaration. ///// Optionally checks for shortand property - + hasProperty : { value: function(rule, property, checkForShorthand) { var properties = [property], shorthands = cssShorthandMap[property]; - + ///// If shorthand properties are defined, add to the array ///// of which properties to check for if(shorthands) { properties.concat(shorthands); } - + ///// return true if any property exists in rule return properties.some(function(prop) { return !!rule.style.getPropertyValue(prop); }, this); - + } }, - + ///// Matches Multiple Elements ///// Checks to see if the rule affects multiple elements - + matchesMultipleElements : { value: function(rule, document) { if(rule.isInlineStyle) { @@ -606,12 +606,12 @@ var stylesController = exports.StylesController = Montage.create(Component, { } }, - - + + ///// Set Rule Selector ///// Allows user to change the selector of given rule ///// while attaching new specificity value to rule object - + setRuleSelector : { value : function(rule, selector) { rule.selectorText = selector; @@ -622,13 +622,13 @@ var stylesController = exports.StylesController = Montage.create(Component, { return rule; } }, - + ///// Get Rule Index ///// Returns the index of the passed-in rule. ///// Returns -1 if not found. ///// A rule's index is useful to know for deleting, inserting ///// and determining rule precedence - + getRuleIndex : { value : function(rule) { var rules = nj.toArray(rule.parentStyleSheet.rules); @@ -666,7 +666,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { ///// Get All Matching Rules ///// Returns an array of css rules for an element ///// Optionally sorted by specificity, and can omit pseudo elements - + getMatchingRules : { //TODO: Remove omitPseudos from here and usages value: function(element, omitPseudos, useStageStyleSheet) { var rules, @@ -748,17 +748,17 @@ var stylesController = exports.StylesController = Montage.create(Component, { return order; } - + rules.sort(sorter.bind(this)); - + return rules; } }, - + ///// Get Common Rules ///// Returns an array of rules that are common to all the elements ///// in passed-in element array. - + getCommonRules : { value : function(elements) { var itemIndex = -1, @@ -783,17 +783,17 @@ var stylesController = exports.StylesController = Montage.create(Component, { return commonRules; } }, - + ///// Get Most Specific Selector For Element ///// Given a selector+specificity array, find the most specific ///// selector for the passed-in element - + _getMostSpecificSelectorForElement : { value : function(element, specArr) { - if(specArr.length === 1) { + if(specArr.length === 1) { return specArr[0]; } - + var matchingElements, i; for(i = 0; i < specArr.length; i++) { @@ -840,12 +840,12 @@ var stylesController = exports.StylesController = Montage.create(Component, { } }, - + ///// Get First Single Target Rule ///// Loops through the array of rules sequentially, returning the first ///// single-target rule (i.e. first rule which affects only one element) ///// Returns null if no single target rule is found - + _getFirstSingleTargetRule : { value : function(rules, document) { var i; @@ -857,32 +857,32 @@ var stylesController = exports.StylesController = Montage.create(Component, { return null; } }, - + ///// Compare Specificity ///// Takes two specificity objects and returns: ///// -1 if first is more specific than second ///// +1 if second is more speficic than first ///// 0 if equal in specificity - + compareSpecificity : { value : function(a, b) { var specA = a, specB = b, order; - + [this.CONST.SPEC_ID_KEY,this.CONST.SPEC_CLASS_KEY,this.CONST.SPEC_TYPE_KEY].some(function(t) { order = specA[t] < specB[t] ? 1 : (specA[t] > specB[t]) ? -1 : 0; return order !== 0; }, this); - + return order; } }, - + ///// Get specificity - ///// Creates array of objects, ordered by specificity for each + ///// Creates array of objects, ordered by specificity for each ///// selector in the passed-in selectorText. - + getSpecificity : { value : function(selector) { var arr = selector.split(',').map(function(sel) { @@ -891,14 +891,14 @@ var stylesController = exports.StylesController = Montage.create(Component, { specificity : this.calculateSpecificity(sel) }; }, this); - + ///// now sort by specificity return arr.sort(function(a, b) { return this.compareSpecificity(a.specificity, b.specificity); }.bind(this)); } }, - + ///// Calculate specificity ///// Returns the specificity value of passed-in selector ///// WARNING: Do not pass in grouped selectors! @@ -911,36 +911,36 @@ var stylesController = exports.StylesController = Montage.create(Component, { value : function(selector) { var s = selector.replace(/\([^\)]+\)/,''), obj = {}; - + ///// function for counting matches for different ///// selector patterns function m(reg) { var matches = s.match(reg); return matches ? matches.length : 0; } - + obj[this.CONST.SPEC_ID_KEY] = m(/#[\d\w-_]+/g); /// match id selector obj[this.CONST.SPEC_CLASS_KEY] = m(/[\.:\[][^\.:\[+>]+/g); /// match class selector obj[this.CONST.SPEC_TYPE_KEY] = m(/(^|[\s\+>])\w+/g); /// match tag selector - + return obj; } }, - + /* ----------------- Style methods ----------------- */ - + ///// Add style ///// Set style property and value on provided rule ///// with optional priority (!important) ///// Returns the browser's value of passed-in property - + setStyle : { value: function(rule, property, value, useImportant) { var dec = rule.style, priority; - + ///// Remove property for passive validation (sets it to null) dec.removeProperty(property); - + priority = (useImportant) ? this.IMPORTANT_FLAG : null; ///// Use CSS declaration's setProperty() @@ -955,23 +955,23 @@ var stylesController = exports.StylesController = Montage.create(Component, { return dec.getPropertyValue(property); } }, - + ///// Add styles ///// Set multiple styles on provided rule ///// Returns a collection of browser values for the ///// passed-in properties - + setStyles : { value: function(rule, styles, useImportant) { var browserValues = {}, property, value; - + for(property in styles) { if(styles.hasOwnProperty(property)) { value = styles[property]; browserValues[property] = this.setStyle(rule, property, value, useImportant); } } - + return browserValues; } }, @@ -1061,7 +1061,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { ///// Delete style ///// Removes the property from the style declaration/rule ///// Returns the rule - + deleteStyle : { value : function(rule, property) { this.styleSheetModified(rule.parentStyleSheet); @@ -1071,34 +1071,34 @@ var stylesController = exports.StylesController = Montage.create(Component, { return rule; } }, - + ///// Delete styles ///// Removes all style properties in passed-in array or object ///// Returns the rule - + deleteStyles : { value : function(rule, properties) { if(properties.constructor !== Array && typeof properties === 'object') { properties = Object.keys(properties); } - + properties.forEach(function(prop) { this.deleteStyle(rule, prop); }, this); - + return rule; } }, - + /* ----------------- Element methods ----------------- */ - + ///// Set Element Style ///// Applies style to element via dominant rule logic: - + ///// We find the most specific rule that has the style property (or it's shorthand) ///// and does not affect multiple elements (we don't want to change that style on ///// all elements sharing a class, for example). - + ///// Here there are a few possibilities: ///// 1) We find the most specific, single-target matching rule with the property defined ///// - Great! Set the style on it. @@ -1113,11 +1113,11 @@ var stylesController = exports.StylesController = Montage.create(Component, { ///// - use most specific, single-target rule ///// - else (this means no single-target rule matches element), create a class ///// - for this element - - + + ///// For Undo/Redo: should return object detailing what actually happened ///// during the application of the style (created rule or amended rule) - + setElementStyle : { value : function(element, property, value, isStageElement) { var doc = element.ownerDocument, @@ -1151,7 +1151,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { className = this.generateClassName(element.nodeName); dominantRule = this.addRule('.'+className + '{}'); this.addClass(element, className); - + } else if(dominantRule.ruleToOverride) { ///// Do we have to override a rule? ///// Well, let's first see if a higher-specificity, single-target @@ -1198,7 +1198,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { ///// Set Element Styles ///// Applies passed-in styles to the element via dominant rule logic ///// Styles must be in object format with the property as the key - + setElementStyles : { value : function(element, styles, isStageElement) { for(var property in styles) { @@ -1245,13 +1245,13 @@ var stylesController = exports.StylesController = Montage.create(Component, { this.addRule(selectors.join(', '), styles); } }, - + ///// Get Element Style ///// Gets the style value that is currently applied to the element ///// Uses Dominant Rule logic to determine the rule that has the property ///// and if not found, can optionally return the computed style instead of ///// null. - + getElementStyle : { value : function(element, property, fallbackOnComputed, isStageElement) { var cache = this._getCachedRuleForProperty(element, property), @@ -1379,26 +1379,26 @@ var stylesController = exports.StylesController = Montage.create(Component, { return rule; } }, - + ///// Add Class ///// Adds class to element - + addClass : { value : function(element, className) { element.classList.add(className); } }, - + /* ----------------- Stylesheet methods ----------------- */ - + ///// Create a stylesheet via style tag in active document, or ///// optionally passed-in document - + createStylesheet : { value: function(id, document) { var doc = document || this._currentDocument.model.views.design.document, sheetElement, sheet; - + sheetElement = nj.make('style', { type : 'text/css', rel : 'stylesheet', @@ -1446,16 +1446,16 @@ var stylesController = exports.StylesController = Montage.create(Component, { } }, - + ///// Gets the stylesheet object associated with passed-in ///// element or element id, with option context (document) ///// (For and