aboutsummaryrefslogtreecommitdiff
path: root/js/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'js/controllers')
-rw-r--r--js/controllers/styles-controller.js73
1 files changed, 67 insertions, 6 deletions
diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js
index a38984e7..44e0e798 100644
--- a/js/controllers/styles-controller.js
+++ b/js/controllers/styles-controller.js
@@ -175,6 +175,8 @@ var stylesController = exports.StylesController = Montage.create(Component, {
175 } 175 }
176 176
177 stylesheet.insertRule(ruleText, index); 177 stylesheet.insertRule(ruleText, index);
178
179 this.styleSheetModified(stylesheet);
178 180
179 rule = stylesheet.rules[index]; 181 rule = stylesheet.rules[index];
180 182
@@ -287,6 +289,8 @@ var stylesController = exports.StylesController = Montage.create(Component, {
287 sheet.deleteRule(index); 289 sheet.deleteRule(index);
288 } 290 }
289 291
292 this.styleSheetModified(sheet);
293
290 return index; 294 return index;
291 } 295 }
292 }, 296 },
@@ -535,6 +539,9 @@ var stylesController = exports.StylesController = Montage.create(Component, {
535 value : function(rule, selector) { 539 value : function(rule, selector) {
536 rule.selectorText = selector; 540 rule.selectorText = selector;
537 rule[this.CONST.SPECIFICITY_KEY] = this.getSpecificity(selector); 541 rule[this.CONST.SPECIFICITY_KEY] = this.getSpecificity(selector);
542
543 this.styleSheetModified(rule.parentStyleSheet);
544
538 return rule; 545 return rule;
539 } 546 }
540 }, 547 },
@@ -784,6 +791,8 @@ var stylesController = exports.StylesController = Montage.create(Component, {
784 ///// method to apply/test the new value 791 ///// method to apply/test the new value
785 dec.setProperty(property, value, priority); 792 dec.setProperty(property, value, priority);
786 793
794 this.styleSheetModified(rule.parentStyleSheet);
795
787 ///// Return browser value for value we just set 796 ///// Return browser value for value we just set
788 return dec.getPropertyValue(property); 797 return dec.getPropertyValue(property);
789 } 798 }
@@ -842,7 +851,10 @@ var stylesController = exports.StylesController = Montage.create(Component, {
842 851
843 deleteStyle : { 852 deleteStyle : {
844 value : function(rule, property) { 853 value : function(rule, property) {
854 this.styleSheetModified(rule.parentStyleSheet);
855
845 rule.style.removeProperty(property); 856 rule.style.removeProperty(property);
857
846 return rule; 858 return rule;
847 } 859 }
848 }, 860 },
@@ -1074,9 +1086,10 @@ var stylesController = exports.StylesController = Montage.create(Component, {
1074 1086
1075 createStylesheet : { 1087 createStylesheet : {
1076 value: function(id, document) { 1088 value: function(id, document) {
1077 var doc = document || this._activeDocument; 1089 var doc = document || this._activeDocument._document,
1090 sheetElement, sheet;
1078 1091
1079 sheet = nj.make('style', { 1092 sheetElement = nj.make('style', {
1080 type : 'text/css', 1093 type : 'text/css',
1081 rel : 'stylesheet', 1094 rel : 'stylesheet',
1082 id : id || "", 1095 id : id || "",
@@ -1084,9 +1097,12 @@ var stylesController = exports.StylesController = Montage.create(Component, {
1084 title : 'Temp' 1097 title : 'Temp'
1085 }); 1098 });
1086 1099
1087 doc.head.appendChild(sheet); 1100 doc.head.appendChild(sheetElement);
1088 1101 sheet = this.getSheetFromElement(sheetElement, doc);
1089 return this.getSheetFromElement(sheet, doc); 1102
1103 this.styleSheetModified(sheet);
1104
1105 return sheet;
1090 } 1106 }
1091 }, 1107 },
1092 1108
@@ -1107,7 +1123,52 @@ var stylesController = exports.StylesController = Montage.create(Component, {
1107 1123
1108 } 1124 }
1109 }, 1125 },
1110 1126
1127 ///// Style Sheet Modified
1128 ///// Method to call whenever a stylesheet change is made
1129 ///// Dispatches an event, and keeps list of dirty style sheets
1130
1131 styleSheetModified : {
1132 value: function(sheet, eventData) {
1133 var sheetSearch = this.dirtyStyleSheets.filter(function(sheetObj) {
1134 return sheetObj.stylesheet === sheet;
1135 });
1136
1137 ///// If the sheet doesn't already exist in the list of modified
1138 ///// sheets, dispatch dirty event and add the sheet to the list
1139 if(sheetSearch.length === 0) {
1140 NJevent('styleSheetDirty', eventData);
1141 this.dirtyStyleSheets.push({
1142 document : sheet.ownerNode.ownerDocument,
1143 stylesheet : sheet
1144 });
1145 }
1146 }
1147 },
1148
1149 ///// Dirty Style Sheets
1150 ///// List of modified style sheets
1151
1152 dirtyStyleSheets : {
1153 value : []
1154 },
1155
1156 ///// Clear Dirty Style Sheets
1157 ///// Refreshes the list of dirty style sheets
1158 ///// If optional document object is supplied, only the styles sheets
1159 ///// of a particular document are cleared
1160 ///// Useful to call after a "Save" or "Save All" event
1161
1162 clearDirtyStyleSheets : {
1163 value: function(doc) {
1164 if(!doc) {
1165 this.dirtyStyleSheets = null;
1166 this.dirtyStyleSheets = [];
1167 }
1168
1169 }
1170 },
1171
1111 /* ----------------- Utils ------------------- */ 1172 /* ----------------- Utils ------------------- */
1112 1173
1113 _generateRandomAlphaNumeric : { 1174 _generateRandomAlphaNumeric : {