aboutsummaryrefslogtreecommitdiff
path: root/js/controllers/styles-controller.js
diff options
context:
space:
mode:
authorJose Antonio Marquez2012-04-10 11:24:21 -0700
committerJose Antonio Marquez2012-04-10 11:24:21 -0700
commitd14f78b06d37aa469885f2ecf84419bcb7e3e613 (patch)
tree91b95c6c9aef779a743b710105546a8ae74bff12 /js/controllers/styles-controller.js
parenta9bcc403df76ad2cb7c31ff7fdd42a85c35cf424 (diff)
parentbd43ce383b050d03b0f92cc923c517febc66ca28 (diff)
downloadninja-d14f78b06d37aa469885f2ecf84419bcb7e3e613.tar.gz
Merge branch 'refs/heads/Ninja-Internal' into FileIO
Diffstat (limited to 'js/controllers/styles-controller.js')
-rwxr-xr-xjs/controllers/styles-controller.js66
1 files changed, 65 insertions, 1 deletions
diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js
index addfc24e..5d5f27ba 100755
--- a/js/controllers/styles-controller.js
+++ b/js/controllers/styles-controller.js
@@ -836,7 +836,7 @@ var stylesController = exports.StylesController = Montage.create(Component, {
836 ///// For a given CSSKeyframesRule, we may add styles to the keyframe at 836 ///// For a given CSSKeyframesRule, we may add styles to the keyframe at
837 ///// given index. 837 ///// given index.
838 838
839 setKeyframeStyle : { 839 setKeyframeStyles : {
840 value : function(rule, keyframeIndex, property, value, useImportant) { 840 value : function(rule, keyframeIndex, property, value, useImportant) {
841 return this.setStyles(rule.cssRules[keyframeIndex], property, value, useImportant); 841 return this.setStyles(rule.cssRules[keyframeIndex], property, value, useImportant);
842 } 842 }
@@ -1124,6 +1124,70 @@ var stylesController = exports.StylesController = Montage.create(Component, {
1124 } 1124 }
1125 }, 1125 },
1126 1126
1127 ///// Get Matrix From Element
1128 ///// Returns the matrix from an element's -webkit-transform
1129 //// TODO - This routine should eventually check for other transform styles, i.e., rotateX, translateZ, etc.
1130
1131 getMatrixFromElement : {
1132 value: function(element, isStage) {
1133 var xformStr = this.getElementStyle(element, "-webkit-transform", false, isStage),
1134 mat;
1135
1136 if (xformStr) {
1137 var index1 = xformStr.indexOf( "matrix3d(");
1138 if (index1 >= 0) {
1139 index1 += 9; // do not include 'matrix3d('
1140 var index2 = xformStr.indexOf( ")", index1 );
1141 if (index2 >= 0) {
1142 var substr = xformStr.substr( index1, (index2-index1));
1143 if (substr && (substr.length > 0)) {
1144 var numArray = substr.split(',');
1145 var nNums = numArray.length;
1146 if (nNums == 16) {
1147 // gl-matrix wants row order
1148 mat = numArray;
1149 for (var i=0; i<16; i++) {
1150 mat[i] = Number( mat[i] );
1151 }
1152 }
1153 }
1154 }
1155 }
1156 }
1157 return mat;
1158 }
1159 },
1160
1161 ///// Get Perspective Distance From Element
1162 ///// Returns the perspective from an element's -webkit-transform
1163
1164 getPerspectiveDistFromElement : {
1165 value: function(element, isStage) {
1166 var xformStr = this.getElementStyle(element, "-webkit-transform", false, isStage),
1167 dist;
1168
1169 if (xformStr) {
1170 var index1 = xformStr.indexOf( "perspective(");
1171 if (index1 >= 0) {
1172 index1 += 12; // do not include 'perspective('
1173 var index2 = xformStr.indexOf( ")", index1 );
1174 if (index2 >= 0) {
1175 var substr = xformStr.substr( index1, (index2-index1));
1176 if (substr && (substr.length > 0)) {
1177 dist = parseInt( substr );
1178 }
1179 }
1180 }
1181 } else {
1182 xformStr = this.getElementStyle(element, "-webkit-perspective", false, isStage);
1183 if(xformStr) {
1184 dist = parseInt(xformStr);
1185 }
1186 }
1187 return dist;
1188 }
1189 },
1190
1127 ///// Create Rule From Inline Style 1191 ///// Create Rule From Inline Style
1128 ///// Creates a rule for an inline style with a specified, or partially random selector. 1192 ///// Creates a rule for an inline style with a specified, or partially random selector.
1129 1193