diff options
Diffstat (limited to 'js')
-rw-r--r-- | js/components/tools-properties/tag-properties.reel/tag-properties.html | 6 | ||||
-rw-r--r-- | js/controllers/styles-controller.js | 73 | ||||
-rw-r--r-- | js/mediators/drag-drop-mediator.js | 2 | ||||
-rw-r--r-- | js/tools/TagTool.js | 12 |
4 files changed, 76 insertions, 17 deletions
diff --git a/js/components/tools-properties/tag-properties.reel/tag-properties.html b/js/components/tools-properties/tag-properties.reel/tag-properties.html index c7588b9e..2b81bb71 100644 --- a/js/components/tools-properties/tag-properties.reel/tag-properties.html +++ b/js/components/tools-properties/tag-properties.reel/tag-properties.html | |||
@@ -56,9 +56,9 @@ | |||
56 | <label class="label"> Tag Name:</label> | 56 | <label class="label"> Tag Name:</label> |
57 | 57 | ||
58 | <select id="customTagCB" class="nj-skinned"> | 58 | <select id="customTagCB" class="nj-skinned"> |
59 | <option>Article</option> | 59 | <option>article</option> |
60 | <option>Aside</option> | 60 | <option>aside</option> |
61 | <option>Section</option> | 61 | <option>section</option> |
62 | </select> | 62 | </select> |
63 | </div> | 63 | </div> |
64 | 64 | ||
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 : { |
diff --git a/js/mediators/drag-drop-mediator.js b/js/mediators/drag-drop-mediator.js index aacb228c..ede71383 100644 --- a/js/mediators/drag-drop-mediator.js +++ b/js/mediators/drag-drop-mediator.js | |||
@@ -122,7 +122,7 @@ exports.DragDropMediator = Montage.create(Component, { | |||
122 | 122 | ||
123 | NJUtils.makeElementModel(domElem, "SVG", "block"); | 123 | NJUtils.makeElementModel(domElem, "SVG", "block"); |
124 | } else { // treat as a regular image | 124 | } else { // treat as a regular image |
125 | domElem = NJUtils.makeNJElement("image", "Image", "block"); | 125 | domElem = NJUtils.makeNJElement("image", "image", "image"); |
126 | domElem.src = evt2.currentTarget.result; | 126 | domElem.src = evt2.currentTarget.result; |
127 | } | 127 | } |
128 | 128 | ||
diff --git a/js/tools/TagTool.js b/js/tools/TagTool.js index c527edf3..e3f49bbe 100644 --- a/js/tools/TagTool.js +++ b/js/tools/TagTool.js | |||
@@ -158,19 +158,17 @@ exports.TagTool = Montage.create(DrawingTool, { | |||
158 | selectedTag = this.options.selectedElement; | 158 | selectedTag = this.options.selectedElement; |
159 | 159 | ||
160 | if(selectedTag === "divTool") { | 160 | if(selectedTag === "divTool") { |
161 | newTag = NJUtils.makeNJElement("div", "Div", "block"); | 161 | newTag = NJUtils.makeNJElement("div", "div", "block"); |
162 | } else if(selectedTag === "imageTool") { | 162 | } else if(selectedTag === "imageTool") { |
163 | newTag = NJUtils.makeNJElement("image", "Image", "image"); | 163 | newTag = NJUtils.makeNJElement("image", "image", "image"); |
164 | } else if(selectedTag === "videoTool") { | 164 | } else if(selectedTag === "videoTool") { |
165 | newTag = NJUtils.makeNJElement("video", "Video", "video", { | 165 | newTag = NJUtils.makeNJElement("video", "video", "video", { |
166 | innerHTML: "Your browser does not support the VIDEO element." | 166 | innerHTML: "Your browser does not support the VIDEO element." |
167 | }); | 167 | }); |
168 | } else if(selectedTag === "canvasTool") { | 168 | } else if(selectedTag === "canvasTool") { |
169 | newTag = NJUtils.makeNJElement("canvas", "Canvas", "canvas"); | 169 | newTag = NJUtils.makeNJElement("canvas", "canvas", "canvas"); |
170 | } else if(selectedTag === "customTool") { | 170 | } else if(selectedTag === "customTool") { |
171 | newTag = document.createElement(this.options.customName.value); | 171 | newTag = NJUtils.makeNJElement(this.options.customName.value, this.options.customName.value, "block"); |
172 | newTag.Ninja = {}; | ||
173 | newTag.Ninja.selectionType = this.options.customName.value; | ||
174 | } | 172 | } |
175 | /* SWF Tag tool - Not used for now. Will revisit this at a later time. | 173 | /* SWF Tag tool - Not used for now. Will revisit this at a later time. |
176 | else if(selectedTag === "flashTool") { | 174 | else if(selectedTag === "flashTool") { |