From d5b36812ba84e49aa8b597eea9f75bf36ddcb571 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 23 May 2012 15:24:25 -0700 Subject: fixing the styles manager to open code view files and closing the last document. Signed-off-by: Valerio Virgillito --- js/controllers/styles-controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/controllers/styles-controller.js') diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js index dcbe0eaf..8ceb9774 100755 --- a/js/controllers/styles-controller.js +++ b/js/controllers/styles-controller.js @@ -81,7 +81,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { set : function(document) { ///// If the document is null set default stylesheets to null - if(!document) { + if(!document || document.currentView === "code") { this._activeDocument = null; this._stageStylesheet = null; this.defaultStylesheet = null; -- cgit v1.2.3 From 5914c5b2209c4b8daac4249bb76cda5c9314c4e6 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Thu, 24 May 2012 00:07:23 -0700 Subject: Cleaning up referencing to 'documentRoot' and '_document' Moved to reference new model in DOM architecture rework. This should not affect anything, just moving the references, and also the setting to the render methods in the design view. --- js/controllers/styles-controller.js | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'js/controllers/styles-controller.js') diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js index dcbe0eaf..04e87ba7 100755 --- a/js/controllers/styles-controller.js +++ b/js/controllers/styles-controller.js @@ -99,7 +99,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { // Setter will handle null case this.defaultStylesheet = this.getSheetFromElement(this.CONST.DEFAULT_SHEET_ID); - this.userStyleSheets = nj.toArray(document._document.styleSheets).filter(function(sheet) { + this.userStyleSheets = nj.toArray(document.model.views.design.document.styleSheets).filter(function(sheet) { return sheet !== this._stageStylesheet; }, this); @@ -132,7 +132,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { else if(this._activeDocument.model && this._activeDocument.model.views && this._activeDocument.model.views.design){ ///// Use the last stylesheet in the document as the default - var sheets = this._activeDocument._document.styleSheets, + var sheets = this._activeDocument.model.views.design.document.styleSheets, lastIndex = sheets.length-1; ///// If the only sheet is the stage stylesheet, this will be true @@ -887,7 +887,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { getAnimationRuleWithName : { value: function(name, document) { - var doc = document || this._activeDocument._document, + var doc = document || this._activeDocument.model.views.design.document, animRules = this.getDocumentAnimationRules(doc), rule, i; @@ -909,7 +909,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { getDocumentAnimationRules : { value: function(document) { - var sheets = (document) ? document.styleSheets : this._activeDocument._document.styleSheets, + var sheets = (document) ? document.styleSheets : this._activeDocument.model.views.design.document.styleSheets, rules = []; nj.toArray(sheets).forEach(function(sheet) { @@ -1272,7 +1272,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { createStylesheet : { value: function(id, document) { - var doc = document || this._activeDocument._document, + var doc = document || this._activeDocument.model.views.design.document, sheetElement, sheet; sheetElement = nj.make('style', { @@ -1329,7 +1329,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { getSheetFromElement : { value : function(element, context) { - var doc = context || this._activeDocument._document, + var doc = context || this._activeDocument.model.views.design.document, el = (typeof element === 'string') ? nj.$(element, doc) : element; if(el && el.sheet) { @@ -1572,7 +1572,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { getStyleTest : function() { var properties = ['background-position', 'width', 'height']; - var el = stylesController.activeDocument._document.getElementById('Div_1'); + var el = stylesController.activeDocument.model.views.design.document.getElementById('Div_1'); properties.forEach(function(prop) { console.log('Getting value for "' + prop + '": ' + stylesController.getElementStyle(el, prop, true)); @@ -1591,7 +1591,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { }); }, getMatchingRulesTest : function() { - var el = stylesController.activeDocument._document.getElementById('Div_1'), + var el = stylesController.activeDocument.model.views.design.document.getElementById('Div_1'), mRules; this.addRulesTest(); @@ -1606,7 +1606,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { ///// apply a new style using setElementStyle, and print out the new ///// value. - var el = stylesController.activeDocument._document.getElementById('Div_1'), + var el = stylesController.activeDocument.model.views.design.document.getElementById('Div_1'), bg; console.log('----- Set Element Style Test -----'); @@ -1631,14 +1631,14 @@ var stylesController = exports.StylesController = Montage.create(Component, { var rules = ['#UserContent div { background-color: blue }']; rules.forEach(function(rule) { stylesController.addRule(rule); }); - var el = stylesController.activeDocument._document.getElementById('Div_1'); + var el = stylesController.activeDocument.model.views.design.document.getElementById('Div_1'); stylesController.setElementStyle(el, 'color', 'red'); ///// the #Div_1 rule created by tag tool should have the color style }, setElementStyle3Test : function() { ///// First, draw a div onto the stage - var el = stylesController.activeDocument._document.getElementById('Div_1'); + var el = stylesController.activeDocument.model.views.design.document.getElementById('Div_1'); //// now add a multi-target rule overriding the bg color var rules = [ @@ -1655,14 +1655,14 @@ var stylesController = exports.StylesController = Montage.create(Component, { }, setGroupStyleTest : function() { ///// draw 2 divs on stage - var el1 = stylesController.activeDocument._document.getElementById('Div_1'); - var el2 = stylesController.activeDocument._document.getElementById('Div_2'); + var el1 = stylesController.activeDocument.model.views.design.document.getElementById('Div_1'); + var el2 = stylesController.activeDocument.model.views.design.document.getElementById('Div_2'); var dominantRule = stylesController.getDominantRuleForGroup([el1, el2], 'color'); }, setElementStylesTest : function() { ///// draw a div on stage - var el = stylesController.activeDocument._document.getElementById('Div_1'); + var el = stylesController.activeDocument.model.views.design.document.getElementById('Div_1'); mRules = stylesController.getMatchingRules(el, true); mRules.forEach(function(rule) { @@ -1681,7 +1681,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { console.log('----- Create Override Rule Test -----'); - var el = stylesController.activeDocument._document.getElementById('Div_1'), + var el = stylesController.activeDocument.model.views.design.document.getElementById('Div_1'), rule = stylesController.addRule('#UserContent div { background-color: blue }'), override; @@ -1693,7 +1693,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { }, deleteRulesTest : function() { // drag one div on stage - var el = stylesController.activeDocument._document.getElementById('Div_1'); + var el = stylesController.activeDocument.model.views.design.document.getElementById('Div_1'); this.addRulesTest(); mRules = stylesController.getMatchingRules(el, true); @@ -1705,8 +1705,8 @@ var stylesController = exports.StylesController = Montage.create(Component, { matchesElementsExclusivelyTest : function() { /// drag two divs on stage var rule = stylesController.addRule('#Div_1, #Div_3 { color:black; }'); - var el1 = stylesController.activeDocument._document.getElementById('Div_1'); - var el2 = stylesController.activeDocument._document.getElementById('Div_2'); + var el1 = stylesController.activeDocument.model.views.design.document.getElementById('Div_1'); + var el2 = stylesController.activeDocument.model.views.design.document.getElementById('Div_2'); console.log('Does rule match elements exclusively? ' + stylesController.matchesElementsExclusively(rule, [el1, el2])); } -- cgit v1.2.3