aboutsummaryrefslogtreecommitdiff
path: root/js/controllers
diff options
context:
space:
mode:
authorJohn Mayhew2012-02-14 09:26:31 -0800
committerJohn Mayhew2012-02-14 09:26:31 -0800
commit65cb57d19c7ff0a8b143c40caa4a227b9e7fd87b (patch)
tree6113587f513fe191fb3538bdce1dc4874e583c93 /js/controllers
parentbe18a677863925963551ce3e88a4a4d254f3870c (diff)
parent1d82f1a041612f32bbf6c9f20d9fb14e2d11fcc7 (diff)
downloadninja-65cb57d19c7ff0a8b143c40caa4a227b9e7fd87b.tar.gz
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal into WorkingBranch
Diffstat (limited to 'js/controllers')
-rw-r--r--js/controllers/elements/stage-controller.js4
-rw-r--r--js/controllers/styles-controller.js78
2 files changed, 77 insertions, 5 deletions
diff --git a/js/controllers/elements/stage-controller.js b/js/controllers/elements/stage-controller.js
index b8170826..af7c4858 100644
--- 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 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 },
@@ -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