aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/controllers/styles-controller.js44
1 files changed, 42 insertions, 2 deletions
diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js
index 011caec5..ff59c8f8 100644
--- a/js/controllers/styles-controller.js
+++ b/js/controllers/styles-controller.js
@@ -179,10 +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
185 if (rule instanceof WebKitCSSKeyframesRule) {
186 return rule;
187 }
184 rule[this.CONST.SPECIFICITY_KEY] = this.getSpecificity(rule.selectorText); 188 rule[this.CONST.SPECIFICITY_KEY] = this.getSpecificity(rule.selectorText);
185 189
186 ///// return the rule we just inserted 190 ///// return the rule we just inserted
187 return rule; 191 return rule;
188 } 192 }
@@ -840,6 +844,27 @@ var stylesController = exports.StylesController = Montage.create(Component, {
840 } 844 }
841 }, 845 },
842 846
847 ///// Get Animation Rule With Name
848 ///// Returns the CSSKeyframesRule with given name
849
850 getAnimationRuleWithName : {
851 value: function(name) {
852 var sheets = this._activeDocument._document.styleSheets,
853 rules, i, j, rule;
854
855 for(i = 0; i < sheets.length; i++) {
856 rules = sheets[i].rules;
857 for(j = 0; j < rules.length; j++) {
858 rule = rules[j];
859 if(rule instanceof WebKitCSSKeyframesRule && rule.name === name) {
860 return rule;
861 }
862 }
863 }
864
865 return;
866 }
867 },
843 868
844 ///// Delete style 869 ///// Delete style
845 ///// Removes the property from the style declaration/rule 870 ///// Removes the property from the style declaration/rule
@@ -1045,6 +1070,21 @@ var stylesController = exports.StylesController = Montage.create(Component, {
1045 } 1070 }
1046 }, 1071 },
1047 1072
1073 ///// Get Element Animation Rule
1074 ///// Returns the CSSKeyframesRule applied to an element
1075
1076 getElementAnimationRule : {
1077 value: function(element) {
1078 var animationName = this.getElementStyle(element, '-webkit-animation-name');
1079
1080 if(!animationName) {
1081 return null;
1082 }
1083
1084 return this.getAnimationRuleWithName(animationName);
1085 }
1086 },
1087
1048 ///// Create Rule From Inline Style 1088 ///// Create Rule From Inline Style
1049 ///// Creates a rule for an inline style with a specified, or partially random selector. 1089 ///// Creates a rule for an inline style with a specified, or partially random selector.
1050 1090