aboutsummaryrefslogtreecommitdiff
path: root/js/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'js/controllers')
-rw-r--r--js/controllers/clipboard-controller.js14
-rwxr-xr-xjs/controllers/elements/shapes-controller.js8
-rwxr-xr-xjs/controllers/styles-controller.js110
3 files changed, 114 insertions, 18 deletions
diff --git a/js/controllers/clipboard-controller.js b/js/controllers/clipboard-controller.js
index d2173e31..3eba1bec 100644
--- a/js/controllers/clipboard-controller.js
+++ b/js/controllers/clipboard-controller.js
@@ -80,9 +80,11 @@ var ClipboardController = exports.ClipboardController = Montage.create(Component
80 return; 80 return;
81 }//for design view only 81 }//for design view only
82 82
83 // Don't do anything if an input or other control is focused 83 // Don't do anything if an input or other control is focused except the copy menu button
84 if(document.activeElement.nodeName !== "BODY") { 84 if(document.activeElement.nodeName !== "BODY") {
85 return; 85 if(!(document.activeElement.getAttribute("data-montage-id") === "menuItemButton")) {
86 return;
87 }
86 } 88 }
87 89
88 if(this.clipboardContext === "stage"){ 90 if(this.clipboardContext === "stage"){
@@ -99,7 +101,9 @@ var ClipboardController = exports.ClipboardController = Montage.create(Component
99 101
100 // Don't do anything if an input or other control is focused 102 // Don't do anything if an input or other control is focused
101 if(document.activeElement.nodeName !== "BODY") { 103 if(document.activeElement.nodeName !== "BODY") {
102 return; 104 if(!(document.activeElement.getAttribute("data-montage-id") === "menuItemButton")) {
105 return;
106 }
103 } 107 }
104 108
105 if(this.clipboardContext === "stage"){ 109 if(this.clipboardContext === "stage"){
@@ -123,7 +127,9 @@ var ClipboardController = exports.ClipboardController = Montage.create(Component
123 127
124 // Don't do anything if an input or other control is focused 128 // Don't do anything if an input or other control is focused
125 if(document.activeElement.nodeName !== "BODY") { 129 if(document.activeElement.nodeName !== "BODY") {
126 return; 130 if(!(document.activeElement.getAttribute("data-montage-id") === "menuItemButton")) {
131 return;
132 }
127 } 133 }
128 134
129 //TODO: return if stage is not focussed 135 //TODO: return if stage is not focussed
diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js
index 1d945066..6dabff47 100755
--- a/js/controllers/elements/shapes-controller.js
+++ b/js/controllers/elements/shapes-controller.js
@@ -841,10 +841,10 @@ exports.ShapesController = Montage.create(CanvasController, {
841 child.strokeMat = "Linear Gradient"; 841 child.strokeMat = "Linear Gradient";
842 } 842 }
843 } 843 }
844 else if( (child.strokeMat === "Radial Gradient") || 844 else if( !child.strokeMat || (child.strokeMat === "Radial Gradient") ||
845 (child.strokeMat === "Linear Gradient") ) 845 (child.strokeMat === "Linear Gradient") )
846 { 846 {
847 // Set Flat Material for children geometry if color has been changed to solid 847 // Set Flat Material for children geometry if no material defined or color has been changed to solid
848 child.strokeMat = "Flat"; 848 child.strokeMat = "Flat";
849 } 849 }
850 } 850 }
@@ -863,10 +863,10 @@ exports.ShapesController = Montage.create(CanvasController, {
863 child.fillMat = "Linear Gradient"; 863 child.fillMat = "Linear Gradient";
864 } 864 }
865 } 865 }
866 else if( (child.fillMat === "Radial Gradient") || 866 else if( !child.fillMat || (child.fillMat === "Radial Gradient") ||
867 (child.fillMat === "Linear Gradient") ) 867 (child.fillMat === "Linear Gradient") )
868 { 868 {
869 // Set Flat Material for children geometry if color has been changed to solid 869 // Set Flat Material for children geometry if no material defined or color has been changed to solid
870 child.fillMat = "Flat"; 870 child.fillMat = "Flat";
871 } 871 }
872 } 872 }
diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js
index 89a389a4..21321f6d 100755
--- a/js/controllers/styles-controller.js
+++ b/js/controllers/styles-controller.js
@@ -106,7 +106,17 @@ var stylesController = exports.StylesController = Montage.create(Component, {
106 this.defaultStylesheet = this.getSheetFromElement(this.CONST.DEFAULT_SHEET_ID); 106 this.defaultStylesheet = this.getSheetFromElement(this.CONST.DEFAULT_SHEET_ID);
107 107
108 this.userStyleSheets = nj.toArray(document.model.views.design.document.styleSheets).filter(function(sheet) { 108 this.userStyleSheets = nj.toArray(document.model.views.design.document.styleSheets).filter(function(sheet) {
109 return sheet !== this._stageStylesheet; 109 if(sheet === this._stageStylesheet) { return false; }
110
111 var media = sheet.ownerNode.getAttribute('media');
112
113 ///// If the media attribute contains a query, we'll watch for changes in media
114 if(/\([0-9A-Za-z-: ]+\)/.test(media)) {
115 this.watchMedia(media);
116 }
117
118 return true;
119
110 }, this); 120 }, this);
111 121
112 this.initializeRootStyles(); 122 this.initializeRootStyles();
@@ -115,6 +125,33 @@ var stylesController = exports.StylesController = Montage.create(Component, {
115 }, 125 },
116 enumerable : false 126 enumerable : false
117 }, 127 },
128
129 _mediaList : {
130 value: []
131 },
132
133 watchMedia : {
134 value: function(mediaQuery, doc) {
135 var _doc = doc || this._currentDocument.model.views.design.document;
136
137 ///// Set a listener for media changes
138 _doc.defaultView.matchMedia(mediaQuery).addListener(function(e) {
139 this.handleMediaChange(e);
140 }.bind(this));
141 }
142 },
143
144 handleMediaChange : {
145 value: function(query) {
146 this._clearCache();
147
148 NJevent('mediaChange', {
149 query: query,
150 source: "stylesController"
151 });
152 }
153 },
154
118 userStyleSheets : { 155 userStyleSheets : {
119 value : null 156 value : null
120 }, 157 },
@@ -1292,33 +1329,68 @@ var stylesController = exports.StylesController = Montage.create(Component, {
1292 1329
1293 ///// Get Matrix From Element 1330 ///// Get Matrix From Element
1294 ///// Returns the matrix from an element's -webkit-transform 1331 ///// Returns the matrix from an element's -webkit-transform
1295 //// TODO - This routine should eventually check for other transform styles, i.e., rotateX, translateZ, etc.
1296 1332
1297 getMatrixFromElement : { 1333 getMatrixFromElement : {
1298 value: function(element, isStage) { 1334 value: function(element, isStage) {
1299 isStage = false; 1335 isStage = false;
1300 var xformStr = this.getElementStyle(element, "-webkit-transform", true, isStage), 1336 var xformStr = this.getElementStyle(element, "-webkit-transform", true, isStage),
1301 mat; 1337 mat,
1338 index1,
1339 index2,
1340 substr,
1341 numArray,
1342 nNums,
1343 i;
1302 1344
1303 if (xformStr) { 1345 if (xformStr) {
1304 var index1 = xformStr.indexOf( "matrix3d("); 1346 // Check for 3d matrix
1347 index1 = xformStr.indexOf( "matrix3d(");
1348 // If style does not contain 'matrix3d', try computed matrix/matrix3d from rotateY, translateZ, etc.
1349 if((index1 === -1) && element.ownerDocument.defaultView) {
1350 xformStr = element.ownerDocument.defaultView.getComputedStyle(element).getPropertyValue("-webkit-transform");
1351 index1 = xformStr.indexOf( "matrix3d(");
1352 }
1305 if (index1 >= 0) { 1353 if (index1 >= 0) {
1306 index1 += 9; // do not include 'matrix3d(' 1354 index1 += 9; // do not include 'matrix3d('
1307 var index2 = xformStr.indexOf( ")", index1 ); 1355 index2 = xformStr.indexOf( ")", index1 );
1308 if (index2 >= 0) { 1356 if (index2 >= 0) {
1309 var substr = xformStr.substr( index1, (index2-index1)); 1357 substr = xformStr.substr( index1, (index2-index1));
1310 if (substr && (substr.length > 0)) { 1358 if (substr && (substr.length > 0)) {
1311 var numArray = substr.split(','); 1359 numArray = substr.split(',');
1312 var nNums = numArray.length; 1360 nNums = numArray.length;
1313 if (nNums == 16) { 1361 if (nNums == 16) {
1314 // gl-matrix wants row order 1362 // gl-matrix wants row order
1315 mat = numArray; 1363 mat = numArray;
1316 for (var i=0; i<16; i++) { 1364 for (i=0; i<16; i++) {
1317 mat[i] = Number( mat[i] ); 1365 mat[i] = Number( mat[i] );
1318 } 1366 }
1319 } 1367 }
1320 } 1368 }
1321 } 1369 }
1370 } else {
1371 // Check for 2d matrix
1372 index1 = xformStr.indexOf( "matrix(");
1373 if (index1 >= 0) {
1374 index1 += 7; // do not include 'matrix('
1375 index2 = xformStr.indexOf( ")", index1 );
1376 if (index2 >= 0) {
1377 substr = xformStr.substr( index1, (index2-index1));
1378 if (substr && (substr.length > 0)) {
1379 numArray = substr.split(',');
1380 nNums = numArray.length;
1381 if (nNums === 6) {
1382 // gl-matrix wants row order
1383 mat = Matrix.I(4);
1384 mat[0] = Number(numArray[0]);
1385 mat[1] = Number(numArray[1]);
1386 mat[4] = Number(numArray[2]);
1387 mat[5] = Number(numArray[3]);
1388 mat[12] = Number(numArray[4]);
1389 mat[13] = Number(numArray[5]);
1390 }