From deb312310c4e031da62afa6e2520c192ad6e4990 Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Tue, 22 May 2012 15:58:02 -0700 Subject: CSS Panel - Merged Styles controller from DOM Architecture --- js/controllers/styles-controller.js | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js index 00d67b89..dcbe0eaf 100755 --- a/js/controllers/styles-controller.js +++ b/js/controllers/styles-controller.js @@ -128,21 +128,23 @@ var stylesController = exports.StylesController = Montage.create(Component, { this._defaultStylesheet = null; return false; } - ///// Use the last stylesheet in the document as the default - - var sheets = this._activeDocument._document.styleSheets, - lastIndex = sheets.length-1; - - ///// If the only sheet is the stage stylesheet, this will be true - ///// in which case, we want to create a stylesheet to hold the - ///// user's style rules - - if(sheets[lastIndex] === this._stageStyleSheet) { - this._defaultStylesheet = this.createStylesheet('nj-default'); - } else { - this._defaultStylesheet = sheets[lastIndex]; - } + //check that the document has a design view + 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, + lastIndex = sheets.length-1; + + ///// If the only sheet is the stage stylesheet, this will be true + ///// in which case, we want to create a stylesheet to hold the + ///// user's style rules + + if(sheets[lastIndex] === this._stageStyleSheet) { + this._defaultStylesheet = this.createStylesheet('nj-default'); + } else { + this._defaultStylesheet = sheets[lastIndex]; + } + } } } }, -- cgit v1.2.3