aboutsummaryrefslogtreecommitdiff
path: root/js/controllers/styles-controller.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/controllers/styles-controller.js')
-rwxr-xr-xjs/controllers/styles-controller.js36
1 files changed, 18 insertions, 18 deletions
diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js
index 8ceb9774..534f77c7 100755
--- a/js/controllers/styles-controller.js
+++ b/js/controllers/styles-controller.js
@@ -99,7 +99,7 @@ var stylesController = exports.StylesController = Montage.create(Component, {
99 // Setter will handle null case 99 // Setter will handle null case
100 this.defaultStylesheet = this.getSheetFromElement(this.CONST.DEFAULT_SHEET_ID); 100 this.defaultStylesheet = this.getSheetFromElement(this.CONST.DEFAULT_SHEET_ID);
101 101
102 this.userStyleSheets = nj.toArray(document._document.styleSheets).filter(function(sheet) { 102 this.userStyleSheets = nj.toArray(document.model.views.design.document.styleSheets).filter(function(sheet) {
103 return sheet !== this._stageStylesheet; 103 return sheet !== this._stageStylesheet;
104 }, this); 104 }, this);
105 105
@@ -132,7 +132,7 @@ var stylesController = exports.StylesController = Montage.create(Component, {
132 else if(this._activeDocument.model && this._activeDocument.model.views && this._activeDocument.model.views.design){ 132 else if(this._activeDocument.model && this._activeDocument.model.views && this._activeDocument.model.views.design){
133 ///// Use the last stylesheet in the document as the default 133 ///// Use the last stylesheet in the document as the default
134 134
135 var sheets = this._activeDocument._document.styleSheets, 135 var sheets = this._activeDocument.model.views.design.document.styleSheets,
136 lastIndex = sheets.length-1; 136 lastIndex = sheets.length-1;
137 137
138 ///// If the only sheet is the stage stylesheet, this will be true 138 ///// If the only sheet is the stage stylesheet, this will be true
@@ -887,7 +887,7 @@ var stylesController = exports.StylesController = Montage.create(Component, {
887 887
888 getAnimationRuleWithName : { 888 getAnimationRuleWithName : {
889 value: function(name, document) { 889 value: function(name, document) {
890 var doc = document || this._activeDocument._document, 890 var doc = document || this._activeDocument.model.views.design.document,
891 animRules = this.getDocumentAnimationRules(doc), 891 animRules = this.getDocumentAnimationRules(doc),
892 rule, i; 892 rule, i;
893 893
@@ -909,7 +909,7 @@ var stylesController = exports.StylesController = Montage.create(Component, {
909 909
910 getDocumentAnimationRules : { 910 getDocumentAnimationRules : {
911 value: function(document) { 911 value: function(document) {
912 var sheets = (document) ? document.styleSheets : this._activeDocument._document.styleSheets, 912 var sheets = (document) ? document.styleSheets : this._activeDocument.model.views.design.document.styleSheets,
913 rules = []; 913 rules = [];
914 914
915 nj.toArray(sheets).forEach(function(sheet) { 915 nj.toArray(sheets).forEach(function(sheet) {
@@ -1272,7 +1272,7 @@ var stylesController = exports.StylesController = Montage.create(Component, {
1272 1272
1273 createStylesheet : { 1273 createStylesheet : {
1274 value: function(id, document) { 1274 value: function(id, document) {
1275 var doc = document || this._activeDocument._document, 1275 var doc = document || this._activeDocument.model.views.design.document,
1276 sheetElement, sheet; 1276 sheetElement, sheet;
1277 1277
1278 sheetElement = nj.make('style', { 1278 sheetElement = nj.make('style', {
@@ -1329,7 +1329,7 @@ var stylesController = exports.StylesController = Montage.create(Component, {
1329 1329
1330 getSheetFromElement : { 1330 getSheetFromElement : {
1331 value : function(element, context) { 1331 value : function(element, context) {
1332 var doc = context || this._activeDocument._document, 1332 var doc = context || this._activeDocument.model.views.design.document,
1333 el = (typeof element === 'string') ? nj.$(element, doc) : element; 1333 el = (typeof element === 'string') ? nj.$(element, doc) : element;
1334 1334
1335 if(el && el.sheet) { 1335 if(el && el.sheet) {
@@ -1572,7 +1572,7 @@ var stylesController = exports.StylesController = Montage.create(Component, {
1572 getStyleTest : function() { 1572 getStyleTest : function() {
1573 var properties = ['background-position', 'width', 'height']; 1573 var properties = ['background-position', 'width', 'height'];
1574 1574
1575 var el = stylesController.activeDocument._document.getElementById('Div_1'); 1575 var el = stylesController.activeDocument.model.views.design.document.getElementById('Div_1');
1576 1576
1577 properties.forEach(function(prop) { 1577 properties.forEach(function(prop) {
1578 console.log('Getting value for "' + prop + '": ' + stylesController.getElementStyle(el, prop, true)); 1578 console.log('Getting value for "' + prop + '": ' + stylesController.getElementStyle(el, prop, true));
@@ -1591,7 +1591,7 @@ var stylesController = exports.StylesController = Montage.create(Component, {
1591 }); 1591 });
1592 }, 1592 },
1593 getMatchingRulesTest : function() { 1593 getMatchingRulesTest : function() {
1594 var el = stylesController.activeDocument._document.getElementById('Div_1'), 1594 var el = stylesController.activeDocument.model.views.design.document.getElementById('Div_1'),
1595 mRules; 1595 mRules;
1596 1596
1597 this.addRulesTest(); 1597 this.addRulesTest();
@@ -1606,7 +1606,7 @@ var stylesController = exports.StylesController = Montage.create(Component, {
1606 ///// apply a new style using setElementStyle, and print out the new 1606 ///// apply a new style using setElementStyle, and print out the new
1607 ///// value. 1607 ///// value.
1608 1608
1609 var el = stylesController.activeDocument._document.getElementById('Div_1'), 1609 var el = stylesController.activeDocument.model.views.design.document.getElementById('Div_1'),
1610 bg; 1610 bg;
1611 1611
1612 console.log('----- Set Element Style Test -----'); 1612 console.log('----- Set Element Style Test -----');
@@ -1631,14 +1631,14 @@ var stylesController = exports.StylesController = Montage.create(Component, {
1631 var rules = ['#UserContent div { background-color: blue }']; 1631 var rules = ['#UserContent div { background-color: blue }'];
1632 rules.forEach(function(rule) { stylesController.addRule(rule); }); 1632 rules.forEach(function(rule) { stylesController.addRule(rule); });
1633 1633
1634 var el = stylesController.activeDocument._document.getElementById('Div_1'); 1634 var el = stylesController.activeDocument.model.views.design.document.getElementById('Div_1');
1635 stylesController.setElementStyle(el, 'color', 'red'); 1635 stylesController.setElementStyle(el, 'color', 'red');
1636 1636
1637 ///// the #Div_1 rule created by tag tool should have the color style 1637 ///// the #Div_1 rule created by tag tool should have the color style
1638 }, 1638 },
1639 setElementStyle3Test : function() { 1639 setElementStyle3Test : function() {
1640 ///// First, draw a div onto the stage 1640 ///// First, draw a div onto the stage
1641 var el = stylesController.activeDocument._document.getElementById('Div_1'); 1641 var el = stylesController.activeDocument.model.views.design.document.getElementById('Div_1');
1642 1642
1643 //// now add a multi-target rule overriding the bg color 1643 //// now add a multi-target rule overriding the bg color
1644 var rules = [ 1644 var rules = [
@@ -1655,14 +1655,14 @@ var stylesController = exports.StylesController = Montage.create(Component, {
1655 }, 1655 },
1656 setGroupStyleTest : function() { 1656 setGroupStyleTest : function() {
1657 ///// draw 2 divs on stage 1657 ///// draw 2 divs on stage
1658 var el1 = stylesController.activeDocument._document.getElementById('Div_1'); 1658 var el1 = stylesController.activeDocument.model.views.design.document.getElementById('Div_1');
1659 var el2 = stylesController.activeDocument._document.getElementById('Div_2'); 1659 var el2 = stylesController.activeDocument.model.views.design.document.getElementById('Div_2');
1660 1660
1661 var dominantRule = stylesController.getDominantRuleForGroup([el1, el2], 'color'); 1661 var dominantRule = stylesController.getDominantRuleForGroup([el1, el2], 'color');
1662 }, 1662 },
1663 setElementStylesTest : function() { 1663 setElementStylesTest : function() {
1664 ///// draw a div on stage 1664 ///// draw a div on stage
1665 var el = stylesController.activeDocument._document.getElementById('Div_1'); 1665 var el = stylesController.activeDocument.model.views.design.document.getElementById('Div_1');
1666 1666
1667 mRules = stylesController.getMatchingRules(el, true); 1667 mRules = stylesController.getMatchingRules(el, true);
1668 mRules.forEach(function(rule) { 1668 mRules.forEach(function(rule) {
@@ -1681,7 +1681,7 @@ var stylesController = exports.StylesController = Montage.create(Component, {
1681 1681
1682 console.log('----- Create Override Rule Test -----'); 1682 console.log('----- Create Override Rule Test -----');
1683 1683
1684 var el = stylesController.activeDocument._document.getElementById('Div_1'), 1684 var el = stylesController.activeDocument.model.views.design.document.getElementById('Div_1'),
1685 rule = stylesController.addRule('#UserContent div { background-color: blue }'), 1685 rule = stylesController.addRule('#UserContent div { background-color: blue }'),
1686 override; 1686 override;
1687 1687
@@ -1693,7 +1693,7 @@ var stylesController = exports.StylesController = Montage.create(Component, {
1693 }, 1693 },
1694 deleteRulesTest : function() { 1694 deleteRulesTest : function() {
1695 // drag one div on stage 1695 // drag one div on stage
1696 var el = stylesController.activeDocument._document.getElementById('Div_1'); 1696 var el = stylesController.activeDocument.model.views.design.document.getElementById('Div_1');
1697 this.addRulesTest(); 1697 this.addRulesTest();
1698 1698
1699 mRules = stylesController.getMatchingRules(el, true); 1699 mRules = stylesController.getMatchingRules(el, true);
@@ -1705,8 +1705,8 @@ var stylesController = exports.StylesController = Montage.create(Component, {
1705 matchesElementsExclusivelyTest : function() { 1705 matchesElementsExclusivelyTest : function() {
1706 /// drag two divs on stage 1706 /// drag two divs on stage
1707 var rule = stylesController.addRule('#Div_1, #Div_3 { color:black; }'); 1707 var rule = stylesController.addRule('#Div_1, #Div_3 { color:black; }');
1708 var el1 = stylesController.activeDocument._document.getElementById('Div_1'); 1708 var el1 = stylesController.activeDocument.model.views.design.document.getElementById('Div_1');
1709 var el2 = stylesController.activeDocument._document.getElementById('Div_2'); 1709 var el2 = stylesController.activeDocument.model.views.design.document.getElementById('Div_2');
1710 1710
1711 console.log('Does rule match elements exclusively? ' + stylesController.matchesElementsExclusively(rule, [el1, el2])); 1711 console.log('Does rule match elements exclusively? ' + stylesController.matchesElementsExclusively(rule, [el1, el2]));
1712 } 1712 }