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/document-controller.js | 2 +- js/controllers/selection-controller.js | 6 +++--- js/controllers/styles-controller.js | 36 +++++++++++++++++----------------- 3 files changed, 22 insertions(+), 22 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 4edcff48..f84e4da5 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -475,7 +475,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, this.activeDocument = doc; // Initialize the documentRoot styles - this.initializeRootStyles(doc.documentRoot); + this.initializeRootStyles(doc.model.documentRoot); // Flag to stop stylesheet dirty event this._hackInitialStyles = false; diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js index 1092615a..7bef0db8 100755 --- a/js/controllers/selection-controller.js +++ b/js/controllers/selection-controller.js @@ -114,7 +114,7 @@ exports.SelectionController = Montage.create(Component, { value: function(event) { var selected = [], childNodes = [], self = this; - childNodes = this.application.ninja.currentDocument.documentRoot.childNodes; + childNodes = this.application.ninja.currentDocument.model.documentRoot.childNodes; childNodes = Array.prototype.slice.call(childNodes, 0); childNodes.forEach(function(item) { if(self.isNodeTraversable(item)) { @@ -256,10 +256,10 @@ exports.SelectionController = Montage.create(Component, { for(var i=0, uuid; this.application.ninja.selectedElements[i];i++) { // Check for multiple selection and excluding inner elements - if(item.parentNode && item.parentNode !== this.application.ninja.currentDocument.documentRoot) { + if(item.parentNode && item.parentNode !== this.application.ninja.currentDocument.model.documentRoot) { var outerElement = item.parentNode; - while(outerElement.parentNode && outerElement.parentNode !== this.application.ninja.currentDocument.documentRoot) { + while(outerElement.parentNode && outerElement.parentNode !== this.application.ninja.currentDocument.model.documentRoot) { outerElement = outerElement.parentNode; } 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