aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--js/controllers/styles-controller.js58
1 files changed, 46 insertions, 12 deletions
diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js
index ff59c8f8..44ca50e1 100644
--- 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 },
@@ -848,17 +848,15 @@ var stylesController = exports.StylesController = Montage.create(Component, {
848 ///// Returns the CSSKeyframesRule with given name 848 ///// Returns the CSSKeyframesRule with given name
849 849
850 getAnimationRuleWithName : { 850 getAnimationRuleWithName : {
851 value: function(name) { 851 value: function(name, document) {
852 var sheets = this._activeDocument._document.styleSheets, 852 var doc = document || this._activeDocument._document,
853 rules, i, j, rule; 853 animRules = this.getDocumentAnimationRules(doc),
854 854 rule, i;
855 for(i = 0; i < sheets.length; i++) { 855
856 rules = sheets[i].rules; 856 for(i = 0; i < animRules.length; i++) {
857 for(j = 0; j < rules.length; j++) { 857 rule = animRules[i];
858 rule = rules[j]; 858 if(rule.name === name) {
859 if(rule instanceof WebKitCSSKeyframesRule && rule.name === name) { 859 return rule;
860 return rule;
861 }
862 } 860 }
863 } 861 }
864 862
@@ -866,6 +864,42 @@ var stylesController = exports.StylesController = Montage.create(Component, {
866 } 864 }
867 }, 865 },
868 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 },
902
869 ///// Delete style 903 ///// Delete style
870 ///// Removes the property from the style declaration/rule 904 ///// Removes the property from the style declaration/rule
871 ///// Returns the rule 905 ///// Returns the rule