diff options
Diffstat (limited to 'js/controllers')
-rwxr-xr-x | js/controllers/document-controller.js | 2 | ||||
-rwxr-xr-x | js/controllers/elements/stage-controller.js | 4 | ||||
-rwxr-xr-x | js/controllers/styles-controller.js | 78 |
3 files changed, 78 insertions, 6 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index b80dfe56..b066a9c2 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js | |||
@@ -187,7 +187,7 @@ DocumentController = exports.DocumentController = Montage.create(Component, { | |||
187 | var code = Montage.create(TextDocument, {"source": {value: doc.content}}), docuuid = Uuid.generate(), textArea; | 187 | var code = Montage.create(TextDocument, {"source": {value: doc.content}}), docuuid = Uuid.generate(), textArea; |
188 | textArea = this.application.ninja.stage.stageView.createTextAreaElement(docuuid); | 188 | textArea = this.application.ninja.stage.stageView.createTextAreaElement(docuuid); |
189 | code.initialize(doc, docuuid, textArea, textArea.parentNode); | 189 | code.initialize(doc, docuuid, textArea, textArea.parentNode); |
190 | code.init(doc.name, doc.uri, doc.extension, null, docuuid); | 190 | //code.init(doc.name, doc.uri, doc.extension, null, docuuid); |
191 | code.textArea.value = doc.content; | 191 | code.textArea.value = doc.content; |
192 | this.application.ninja.stage.stageView.createTextView(code); | 192 | this.application.ninja.stage.stageView.createTextView(code); |
193 | break; | 193 | break; |
diff --git a/js/controllers/elements/stage-controller.js b/js/controllers/elements/stage-controller.js index b8170826..af7c4858 100755 --- a/js/controllers/elements/stage-controller.js +++ b/js/controllers/elements/stage-controller.js | |||
@@ -75,6 +75,8 @@ exports.StageController = Montage.create(ElementController, { | |||
75 | getProperty: { | 75 | getProperty: { |
76 | value: function(el, p) { | 76 | value: function(el, p) { |
77 | switch(p) { | 77 | switch(p) { |
78 | case "background" : | ||
79 | return el.elementModel.stageBackground.style.getProperty(p); | ||
78 | case "border": | 80 | case "border": |
79 | return el.elementModel.stageView.style.getProperty(p); | 81 | return el.elementModel.stageView.style.getProperty(p); |
80 | case "height": | 82 | case "height": |
@@ -92,7 +94,7 @@ exports.StageController = Montage.create(ElementController, { | |||
92 | value: function(el, p, value) { | 94 | value: function(el, p, value) { |
93 | switch(p) { | 95 | switch(p) { |
94 | case "background": | 96 | case "background": |
95 | el.elementModel.body.style.setProperty(p, value); | 97 | el.elementModel.stageBackground.style.setProperty(p, value); |
96 | break; | 98 | break; |
97 | case "overflow": | 99 | case "overflow": |
98 | el.elementModel.viewPort.style.setProperty(p, value); | 100 | el.elementModel.viewPort.style.setProperty(p, value); |
diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js index 44e0e798..44ca50e1 100755 --- a/js/controllers/styles-controller.js +++ b/js/controllers/styles-controller.js | |||
@@ -128,7 +128,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { | |||
128 | } else { | 128 | } else { |
129 | this._defaultStylesheet = sheets[lastIndex]; | 129 | this._defaultStylesheet = sheets[lastIndex]; |
130 | } | 130 | } |
131 | 131 | ||
132 | } | 132 | } |
133 | } | 133 | } |
134 | }, | 134 | }, |
@@ -179,14 +179,14 @@ var stylesController = exports.StylesController = Montage.create(Component, { | |||
179 | this.styleSheetModified(stylesheet); | 179 | this.styleSheetModified(stylesheet); |
180 | 180 | ||
181 | rule = stylesheet.rules[index]; | 181 | rule = stylesheet.rules[index]; |
182 | 182 | ||
183 | ///// attach specificity to rule object | 183 | ///// attach specificity to rule object |
184 | // if rule is css keyframes, return rule and don't attach specificity | 184 | ///// if rule is css keyframes, return rule and don't attach specificity |
185 | if (rule instanceof WebKitCSSKeyframesRule) { | 185 | if (rule instanceof WebKitCSSKeyframesRule) { |
186 | return rule; | 186 | return rule; |
187 | } | 187 | } |
188 | rule[this.CONST.SPECIFICITY_KEY] = this.getSpecificity(rule.selectorText); | 188 | rule[this.CONST.SPECIFICITY_KEY] = this.getSpecificity(rule.selectorText); |
189 | 189 | ||
190 | ///// return the rule we just inserted | 190 | ///// return the rule we just inserted |
191 | return rule; | 191 | return rule; |
192 | } | 192 | } |
@@ -844,6 +844,61 @@ var stylesController = exports.StylesController = Montage.create(Component, { | |||
844 | } | 844 | } |
845 | }, | 845 | }, |
846 | 846 | ||
847 | ///// Get Animation Rule With Name | ||
848 | ///// Returns the CSSKeyframesRule with given name | ||
849 | |||
850 | getAnimationRuleWithName : { | ||
851 | value: function(name, document) { | ||
852 | var doc = document || this._activeDocument._document, | ||
853 | animRules = this.getDocumentAnimationRules(doc), | ||
854 | rule, i; | ||
855 | |||
856 | for(i = 0; i < animRules.length; i++) { | ||
857 | rule = animRules[i]; | ||
858 | if(rule.name === name) { | ||
859 | return rule; | ||
860 | } | ||
861 | } | ||
862 | |||
863 | return; | ||
864 | } | ||
865 | }, | ||
866 | |||
867 | ///// Get Document Animation Rules | ||
868 | ///// Returns all CSSKeyframesRules in active document, or in | ||
869 | ///// optionally passed-in document | ||
870 | ///// If none are found, returns an empty array | ||
871 | |||
872 | getDocumentAnimationRules : { | ||
873 | value: function(document) { | ||
874 | var sheets = (document) ? document.styleSheets : this._activeDocument._document.styleSheets, | ||
875 | rules = []; | ||
876 | |||
877 | nj.toArray(sheets).forEach(function(sheet) { | ||
878 | rules = rules.concat(this.getStyleSheetAnimationRules(sheet)); | ||
879 | }, this); | ||
880 | |||
881 | return rules; | ||
882 | } | ||
883 | }, | ||
884 | |||
885 | ///// Get Style Sheet Animation Rules | ||
886 | ///// Returns all CSSKeyframesRules from the given stylesheet | ||
887 | ///// If none are found, returns an empty array | ||
888 | |||
889 | getStyleSheetAnimationRules : { | ||
890 | value: function(sheet) { | ||
891 | var rules = []; | ||
892 | |||
893 | if(sheet.rules) { | ||
894 | rules = rules.concat(nj.toArray(sheet.rules).filter(function(rule) { | ||
895 | return rule instanceof WebKitCSSKeyframesRule; | ||
896 | })); | ||
897 | } | ||
898 | |||
899 | return rules; | ||
900 | } | ||
901 | }, | ||
847 | 902 | ||
848 | ///// Delete style | 903 | ///// Delete style |
849 | ///// Removes the property from the style declaration/rule | 904 | ///// Removes the property from the style declaration/rule |
@@ -1049,6 +1104,21 @@ var stylesController = exports.StylesController = Montage.create(Component, { | |||
1049 | } | 1104 | } |
1050 | }, | 1105 | }, |
1051 | 1106 | ||
1107 | ///// Get Element Animation Rule | ||
1108 | ///// Returns the CSSKeyframesRule applied to an element | ||
1109 | |||
1110 | getElementAnimationRule : { | ||
1111 | value: function(element) { | ||
1112 | var animationName = this.getElementStyle(element, '-webkit-animation-name'); | ||
1113 | |||
1114 | if(!animationName) { | ||
1115 | return null; | ||
1116 | } | ||
1117 | |||
1118 | return this.getAnimationRuleWithName(animationName); | ||
1119 | } | ||
1120 | }, | ||
1121 | |||
1052 | ///// Create Rule From Inline Style | 1122 | ///// Create Rule From Inline Style |
1053 | ///// Creates a rule for an inline style with a specified, or partially random selector. | 1123 | ///// Creates a rule for an inline style with a specified, or partially random selector. |
1054 | 1124 | ||