aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xjs/controllers/styles-controller.js19
-rw-r--r--js/panels/css-panel/style-sheet.reel/style-sheet.html3
-rw-r--r--js/panels/css-panel/style-sheet.reel/style-sheet.js20
-rw-r--r--js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js9
4 files changed, 45 insertions, 6 deletions
diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js
index 041794e0..11d53ac0 100755
--- a/js/controllers/styles-controller.js
+++ b/js/controllers/styles-controller.js
@@ -1477,7 +1477,8 @@ var stylesController = exports.StylesController = Montage.create(Component, {
1477 rel : 'stylesheet', 1477 rel : 'stylesheet',
1478 id : id || "", 1478 id : id || "",
1479 media : 'screen', 1479 media : 'screen',
1480 title : 'Temp' 1480 title : 'Temp',
1481 'data-ninja-node' : 'true'
1481 }); 1482 });
1482 1483
1483 doc.head.appendChild(sheetElement); 1484 doc.head.appendChild(sheetElement);
@@ -1504,6 +1505,9 @@ var stylesController = exports.StylesController = Montage.create(Component, {
1504 sheetEl.disabled = true; 1505 sheetEl.disabled = true;
1505 this.userStyleSheets.splice(this.userStyleSheets.indexOf(sheet), 1); 1506 this.userStyleSheets.splice(this.userStyleSheets.indexOf(sheet), 1);
1506 1507
1508 ///// Make sure cached rules from this stylesheet are not used
1509 this._clearCache();
1510
1507 ///// Check to see if we're removing the default style sheet 1511 ///// Check to see if we're removing the default style sheet
1508 if(sheet === this._defaultStylesheet) { 1512 if(sheet === this._defaultStylesheet) {
1509 sheetCount = this.userStyleSheets.length; 1513 sheetCount = this.userStyleSheets.length;
@@ -1541,6 +1545,18 @@ var stylesController = exports.StylesController = Montage.create(Component, {
1541 } 1545 }
1542 }, 1546 },
1543 1547
1548 setMediaAttribute : {
1549 value: function(sheet, mediaString) {
1550 if(sheet.media.mediaText === mediaString) { return false; }
1551
1552 sheet.ownerNode.setAttribute('media', mediaString);
1553
1554 this._clearCache();
1555
1556 this.styleSheetModified(sheet);
1557 }
1558 },
1559
1544 ///// Style Sheet Modified 1560 ///// Style Sheet Modified
1545 ///// Method to call whenever a stylesheet change is made 1561 ///// Method to call whenever a stylesheet change is made
1546 ///// Dispatches an event, and keeps list of dirty style sheets 1562 ///// Dispatches an event, and keeps list of dirty style sheets
@@ -1558,6 +1574,7 @@ var stylesController = exports.StylesController = Montage.create(Component, {
1558 ///// If the sheet doesn't already exist in the list of modified 1574 ///// If the sheet doesn't already exist in the list of modified
1559 ///// sheets, dispatch dirty event and add the sheet to the list 1575 ///// sheets, dispatch dirty event and add the sheet to the list
1560 if(sheetSearch.length === 0) { 1576 if(sheetSearch.length === 0) {
1577 NJevent('styleSheetDirty', eventData);
1561 this.dirtyStyleSheets.push({ 1578 this.dirtyStyleSheets.push({
1562 document : sheet.ownerNode.ownerDocument, 1579 document : sheet.ownerNode.ownerDocument,
1563 stylesheet : sheet 1580 stylesheet : sheet
diff --git a/js/panels/css-panel/style-sheet.reel/style-sheet.html b/js/panels/css-panel/style-sheet.reel/style-sheet.html
index 035bc760..01b5f20c 100644
--- a/js/panels/css-panel/style-sheet.reel/style-sheet.html
+++ b/js/panels/css-panel/style-sheet.reel/style-sheet.html
@@ -62,6 +62,9 @@ POSSIBILITY OF SUCH DAMAGE.
62 "prototype": "js/components/textfield.reel[TextField]", 62 "prototype": "js/components/textfield.reel[TextField]",
63 "properties": { 63 "properties": {
64 "element": {"#": "media-input"} 64 "element": {"#": "media-input"}
65 },
66 "bindings": {
67 "value": {"<->": "@owner.mediaText"}
65 } 68 }
66 }, 69 },
67 "editButton": { 70 "editButton": {
diff --git a/js/panels/css-panel/style-sheet.reel/style-sheet.js b/js/panels/css-panel/style-sheet.reel/style-sheet.js
index b7df05a7..3a0060b2 100644
--- a/js/panels/css-panel/style-sheet.reel/style-sheet.js
+++ b/js/panels/css-panel/style-sheet.reel/style-sheet.js
@@ -71,6 +71,9 @@ exports.StyleSheet = Montage.create(Component, {
71 prepareForDraw : { 71 prepareForDraw : {
72 value: function() { 72 value: function() {
73 this.nameText.element.addEventListener('click', this, false); 73 this.nameText.element.addEventListener('click', this, false);
74
75 //// Set the initial media text value
76 this.mediaText = this._source.media.mediaText;
74 } 77 }
75 }, 78 },
76 79
@@ -89,8 +92,6 @@ exports.StyleSheet = Montage.create(Component, {
89 value: function() { 92 value: function() {
90 var transStr = '-webkit-transform'; 93 var transStr = '-webkit-transform';
91 94
92 this.mediaInput.value = this._source.media.mediaText;
93
94 if(this.editing) { 95 if(this.editing) {
95 this.editView.classList.add('expanded'); 96 this.editView.classList.add('expanded');
96 this.editView.style.setProperty(transStr, 'translate3d(-'+ this._translateDistance + 'px,0,0)'); 97 this.editView.style.setProperty(transStr, 'translate3d(-'+ this._translateDistance + 'px,0,0)');
@@ -194,6 +195,21 @@ exports.StyleSheet = Montage.create(Component, {
194 this._name = text; 195 this._name = text;
195 } 196 }
196 }, 197 },
198
199 _mediaText : { value: null },
200 mediaText : {
201 get : function() { return this._mediaText; },
202 set : function(value) {
203 if(value === this._mediaText) { return; }
204
205 this.application.ninja.stylesController.setMediaAttribute(this._source, value);
206
207 this._mediaText = value;
208
209 this.needsDraw = true;
210 }
211 },
212
197 _dirty : { 213 _dirty : {
198 value: null 214 value: null
199 }, 215 },
diff --git a/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js b/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js
index 2effb429..fd559b24 100644
--- a/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js
+++ b/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js
@@ -96,13 +96,16 @@ exports.StyleSheetsView = Montage.create(Component, {
96 96
97 var sheetComponent, oldDefaultSheet; 97 var sheetComponent, oldDefaultSheet;
98 98
99 ///// Mark the appropriate component as the default, un-mark the previous default
99 if(this.styleSheetList) { 100 if(this.styleSheetList) {
100 sheetComponent = this.styleSheetList.childComponents[this.styleSheets.indexOf(sheet)]; 101 sheetComponent = this.styleSheetList.childComponents[this.styleSheets.indexOf(sheet)];
101 if(sheetComponent) { 102 if(sheetComponent) {
102 sheetComponent['default'] = true; 103 sheetComponent['default'] = true;
103 if(this._defaultStyleSheet) { 104 if(this._defaultStyleSheet) {
104 oldDefaultSheet = this.styleSheetList.childComponents[this.styleSheets.indexOf(this._defaultStyleSheet)]; 105 oldDefaultSheet = this.styleSheetList.childComponents[this.styleSheets.indexOf(this._defaultStyleSheet)];
105 oldDefaultSheet['default'] = false; 106 if(oldDefaultSheet) {
107 oldDefaultSheet['default'] = false;
108 }
106 } 109 }
107 } 110 }
108 } 111 }
@@ -175,7 +178,7 @@ exports.StyleSheetsView = Montage.create(Component, {
175 } 178 }
176 }, 179 },
177 180
178 handleStyleSheetModified : { 181 handleStyleSheetDirty : {
179 value: function(e) { 182 value: function(e) {
180 this.needsDraw = true; 183 this.needsDraw = true;
181 } 184 }
@@ -192,7 +195,7 @@ exports.StyleSheetsView = Montage.create(Component, {
192 prepareForDraw : { 195 prepareForDraw : {
193 value: function() { 196 value: function() {
194 this.eventManager.addEventListener("styleSheetsReady", this, false); 197 this.eventManager.addEventListener("styleSheetsReady", this, false);
195 this.eventManager.addEventListener("styleSheetModified", this, false); 198 this.eventManager.addEventListener("styleSheetDirty", this, false);
196 } 199 }
197 }, 200 },
198 draw : { 201 draw : {