diff options
author | Pushkar Joshi | 2012-02-24 12:08:49 -0800 |
---|---|---|
committer | Pushkar Joshi | 2012-02-24 12:08:49 -0800 |
commit | 03ca7a5ed13c25faaa9100bb666e062fd15335e6 (patch) | |
tree | c51112223ceb9121cd595a60335eb2795215590f /js/controllers/styles-controller.js | |
parent | fcb12cc09eb3cd3b42bd215877ba18f449275b75 (diff) | |
parent | 053fc63a2950c7a5ee4ebf98033b64d474a3c46e (diff) | |
download | ninja-03ca7a5ed13c25faaa9100bb666e062fd15335e6.tar.gz |
Merge branch 'pentool' into brushtool
Conflicts:
imports/codemirror/mode/scheme/scheme.js
js/tools/BrushTool.js
Diffstat (limited to 'js/controllers/styles-controller.js')
-rwxr-xr-x[-rw-r--r--] | js/controllers/styles-controller.js | 87 |
1 files changed, 83 insertions, 4 deletions
diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js index 011caec5..885d710f 100644..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,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 | } |
@@ -567,6 +571,10 @@ var stylesController = exports.StylesController = Montage.create(Component, { | |||
567 | rules = [], | 571 | rules = [], |
568 | win = element.ownerDocument.defaultView, | 572 | win = element.ownerDocument.defaultView, |
569 | self = this; | 573 | self = this; |
574 | |||
575 | if(!win) { | ||
576 | return null; | ||
577 | } | ||
570 | 578 | ||
571 | if(!omitPseudos) { | 579 | if(!omitPseudos) { |
572 | pseudos.concat(['link', 'visited', 'active', 'hover', 'focus', 'first-letter', | 580 | pseudos.concat(['link', 'visited', 'active', 'hover', 'focus', 'first-letter', |
@@ -670,8 +678,9 @@ var stylesController = exports.StylesController = Montage.create(Component, { | |||
670 | } | 678 | } |
671 | 679 | ||
672 | var matchingElements, i; | 680 | var matchingElements, i; |
681 | |||
673 | for(i = 0; i < specArr.length; i++) { | 682 | for(i = 0; i < specArr.length; i++) { |
674 | matchingElements = win.document.querySelectorAll(specArr[i].selector); | 683 | matchingElements = element.ownerDocument.querySelectorAll(specArr[i].selector); |
675 | if(nj.toArray(matchingElements).indexOf(element) !== -1) { | 684 | if(nj.toArray(matchingElements).indexOf(element) !== -1) { |
676 | return specArr[i]; | 685 | return specArr[i]; |
677 | } | 686 | } |
@@ -840,6 +849,61 @@ var stylesController = exports.StylesController = Montage.create(Component, { | |||
840 | } | 849 | } |
841 | }, | 850 | }, |
842 | 851 | ||
852 | ///// Get Animation Rule With Name | ||
853 | ///// Returns the CSSKeyframesRule with given name | ||
854 | |||
855 | getAnimationRuleWithName : { | ||
856 | value: function(name, document) { | ||
857 | var doc = document || this._activeDocument._document, | ||
858 | animRules = this.getDocumentAnimationRules(doc), | ||
859 | rule, i; | ||
860 | |||
861 | for(i = 0; i < animRules.length; i++) { | ||
862 | rule = animRules[i]; | ||
863 | if(rule.name === name) { | ||
864 | return rule; | ||
865 | } | ||
866 | } | ||
867 | |||
868 | return; | ||
869 | } | ||
870 | }, | ||
871 | |||
872 | ///// Get Document Animation Rules | ||
873 | ///// Returns all CSSKeyframesRules in active document, or in | ||
874 | ///// optionally passed-in document | ||
875 | ///// If none are found, returns an empty array | ||
876 | |||
877 | getDocumentAnimationRules : { | ||
878 | value: function(document) { | ||
879 | var sheets = (document) ? document.styleSheets : this._activeDocument._document.styleSheets, | ||
880 | rules = []; | ||
881 | |||
882 | nj.toArray(sheets).forEach(function(sheet) { | ||
883 | rules = rules.concat(this.getStyleSheetAnimationRules(sheet)); | ||
884 | }, this); | ||
885 | |||
886 | return rules; | ||
887 | } | ||
888 | }, | ||
889 | |||
890 | ///// Get Style Sheet Animation Rules | ||
891 | ///// Returns all CSSKeyframesRules from the given stylesheet | ||
892 | ///// If none are found, returns an empty array | ||
893 | |||
894 | getStyleSheetAnimationRules : { | ||
895 | value: function(sheet) { | ||
896 | var rules = []; | ||
897 | |||
898 | if(sheet.rules) { | ||
899 | rules = rules.concat(nj.toArray(sheet.rules).filter(function(rule) { | ||
900 | return rule instanceof WebKitCSSKeyframesRule; | ||
901 | })); | ||
902 | } | ||
903 | |||
904 | return rules; | ||
905 | } | ||
906 | }, | ||
843 | 907 | ||
844 | ///// Delete style | 908 | ///// Delete style |
845 | ///// Removes the property from the style declaration/rule | 909 | ///// Removes the property from the style declaration/rule |
@@ -1045,6 +1109,21 @@ var stylesController = exports.StylesController = Montage.create(Component, { | |||
1045 | } | 1109 | } |
1046 | }, | 1110 | }, |
1047 | 1111 | ||
1112 | ///// Get Element Animation Rule | ||
1113 | ///// Returns the CSSKeyframesRule applied to an element | ||
1114 | |||
1115 | getElementAnimationRule : { | ||
1116 | value: function(element) { | ||
1117 | var animationName = this.getElementStyle(element, '-webkit-animation-name'); | ||
1118 | |||
1119 | if(!animationName) { | ||
1120 | return null; | ||
1121 | } | ||
1122 | |||
1123 | return this.getAnimationRuleWithName(animationName); | ||
1124 | } | ||
1125 | }, | ||
1126 | |||
1048 | ///// Create Rule From Inline Style | 1127 | ///// Create Rule From Inline Style |
1049 | ///// Creates a rule for an inline style with a specified, or partially random selector. | 1128 | ///// Creates a rule for an inline style with a specified, or partially random selector. |
1050 | 1129 | ||