aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorJohn Mayhew2012-02-08 14:39:16 -0800
committerJohn Mayhew2012-02-08 14:39:16 -0800
commitb6bc8b0bb91382991e6e43ad341304c813124882 (patch)
tree9ab504c981d2cf3be96a9f80ce638a85300489db /js
parentc7b5edf0351d678d26b17eb5e2f995a140e209bb (diff)
parentab12be4e9a0d9fee4450795077b0107983b5682e (diff)
downloadninja-b6bc8b0bb91382991e6e43ad341304c813124882.tar.gz
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal into WorkingBranch
Diffstat (limited to 'js')
-rw-r--r--js/components/tools-properties/tag-properties.reel/tag-properties.html6
-rw-r--r--js/controllers/styles-controller.js73
-rw-r--r--js/mediators/drag-drop-mediator.js2
-rw-r--r--js/tools/TagTool.js12
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 21024125..011caec5 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
@@ -283,6 +285,8 @@ var stylesController = exports.StylesController = Montage.create(Component, {
283 sheet.deleteRule(index); 285 sheet.deleteRule(index);
284 } 286 }
285 287
288 this.styleSheetModified(sheet);
289
286 return index; 290 return index;
287 } 291 }
288 }, 292 },
@@ -531,6 +535,9 @@ var stylesController = exports.StylesController = Montage.create(Component, {
531 value : function(rule, selector) { 535 value : function(rule, selector) {
532 rule.selectorText = selector; 536 rule.selectorText = selector;
533 rule[this.CONST.SPECIFICITY_KEY] = this.getSpecificity(selector); 537 rule[this.CONST.SPECIFICITY_KEY] = this.getSpecificity(selector);
538
539 this.styleSheetModified(rule.parentStyleSheet);
540
534 return rule; 541 return rule;
535 } 542 }
536 }, 543 },
@@ -780,6 +787,8 @@ var stylesController = exports.StylesController = Montage.create(Component, {
780 ///// method to apply/test the new value 787 ///// method to apply/test the new value
781 dec.setProperty(property, value, priority); 788 dec.setProperty(property, value, priority);
782 789
790 this.styleSheetModified(rule.parentStyleSheet);
791
783 ///// Return browser value for value we just set 792 ///// Return browser value for value we just set
784 return dec.getPropertyValue(property); 793 return dec.getPropertyValue(property);
785 } 794 }
@@ -838,7 +847,10 @@ var stylesController = exports.StylesController = Montage.create(Component, {
838 847
839 deleteStyle : { 848 deleteStyle : {
840 value : function(rule, property) { 849 value : function(rule, property) {
850 this.styleSheetModified(rule.parentStyleSheet);
851
841 rule.style.removeProperty(property); 852 rule.style.removeProperty(property);
853
842 return rule; 854 return rule;
843 } 855 }
844 }, 856 },
@@ -1070,9 +1082,10 @@ var stylesController = exports.StylesController = Montage.create(Component, {
1070 1082
1071 createStylesheet : { 1083 createStylesheet : {
1072 value: function(id, document) { 1084 value: function(id, document) {
1073 var doc = document || this._activeDocument; 1085 var doc = document || this._activeDocument._document,
1086 sheetElement, sheet;
1074 1087
1075 sheet = nj.make('style', { 1088 sheetElement = nj.make('style', {
1076 type : 'text/css', 1089 type : 'text/css',
1077 rel : 'stylesheet', 1090 rel : 'stylesheet',
1078 id : id || "", 1091 id : id || "",
@@ -1080,9 +1093,12 @@ var stylesController = exports.StylesController = Montage.create(Component, {
1080 title : 'Temp' 1093 title : 'Temp'
1081 }); 1094 });
1082 1095
1083 doc.head.appendChild(sheet); 1096 doc.head.appendChild(sheetElement);
1084 1097 sheet = this.getSheetFromElement(sheetElement, doc);
1085 return this.getSheetFromElement(sheet, doc); 1098
1099 this.styleSheetModified(sheet);
1100
1101 return sheet;
1086 } 1102 }
1087 }, 1103 },
1088 1104
@@ -1103,7 +1119,52 @@ var stylesController = exports.StylesController = Montage.create(Component, {
1103 1119
1104 } 1120 }
1105 }, 1121 },
1106 1122
1123 ///// Style Sheet Modified
1124 ///// Method to call whenever a stylesheet change is made
1125 ///// Dispatches an event, and keeps list of dirty style sheets
1126
1127 styleSheetModified : {
1128 value: function(sheet, eventData) {
1129 var sheetSearch = this.dirtyStyleSheets.filter(function(sheetObj) {
1130 return sheetObj.stylesheet === sheet;
1131 });
1132
1133 ///// If the sheet doesn't already exist in the list of modified
1134 ///// sheets, dispatch dirty event and add the sheet to the list
1135 if(sheetSearch.length === 0) {
1136 NJevent('styleSheetDirty', eventData);
1137 this.dirtyStyleSheets.push({
1138 document : sheet.ownerNode.ownerDocument,
1139 stylesheet : sheet
1140 });
1141 }
1142 }
1143 },
1144
1145 ///// Dirty Style Sheets
1146 ///// List of modified style sheets
1147
1148 dirtyStyleSheets : {
1149 value : []
1150 },
1151
1152 ///// Clear Dirty Style Sheets
1153 ///// Refreshes the list of dirty style sheets
1154 ///// If optional document object is supplied, only the styles sheets
1155 ///// of a particular document are cleared
1156 ///// Useful to call after a "Save" or "Save All" event
1157
1158 clearDirtyStyleSheets : {
1159 value: function(doc) {
1160 if(!doc) {
1161 this.dirtyStyleSheets = null;
1162 this.dirtyStyleSheets = [];
1163 }
1164
1165 }
1166 },
1167
1107 /* ----------------- Utils ------------------- */ 1168 /* ----------------- Utils ------------------- */
1108 1169
1109 _generateRandomAlphaNumeric : { 1170 _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") {