aboutsummaryrefslogtreecommitdiff
path: root/js/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'js/controllers')
-rw-r--r--js/controllers/elements/shapes-controller.js29
-rw-r--r--js/controllers/elements/stage-controller.js4
-rw-r--r--js/controllers/main-menu-controller.js43
-rw-r--r--js/controllers/styles-controller.js80
4 files changed, 142 insertions, 14 deletions
diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js
index b9c033aa..640119c4 100644
--- a/js/controllers/elements/shapes-controller.js
+++ b/js/controllers/elements/shapes-controller.js
@@ -346,19 +346,24 @@ exports.ShapesController = Montage.create(CanvasController, {
346 { 346 {
347 world = new GLWorld(el, true); 347 world = new GLWorld(el, true);
348 el.elementModel.shapeModel.GLWorld = world; 348 el.elementModel.shapeModel.GLWorld = world;
349 el.elementModel.shapeModel.GLGeomObj.setWorld(world);
350 el.elementModel.shapeModel.useWebGl = true; 349 el.elementModel.shapeModel.useWebGl = true;
350 world.import(worldData);
351 el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot();
352
351 sm = Object.create(MaterialsLibrary.getMaterial("FlatMaterial")); 353 sm = Object.create(MaterialsLibrary.getMaterial("FlatMaterial"));
352 fm = Object.create(MaterialsLibrary.getMaterial("FlatMaterial")); 354 if(sm)
353 if(sm && fm)
354 { 355 {
355 el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(sm); 356 el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(sm);
356 el.elementModel.shapeModel.GLGeomObj.setFillMaterial(fm);
357 el.elementModel.shapeModel.strokeMaterial = sm; 357 el.elementModel.shapeModel.strokeMaterial = sm;
358 }
359 fm = Object.create(MaterialsLibrary.getMaterial("FlatMaterial"));
360 // TODO - Use consts after GL code is converted to object literal notation
361// if( fm && (el.elementModel.shapeModel.GLGeomObj.geomType() !== GLGeomObj.GEOM_TYPE_LINE) )
362 if( fm && (el.elementModel.shapeModel.GLGeomObj.geomType() !== 3) )
363 {
364 el.elementModel.shapeModel.GLGeomObj.setFillMaterial(fm);
358 el.elementModel.shapeModel.fillMaterial = fm; 365 el.elementModel.shapeModel.fillMaterial = fm;
359 el.elementModel.shapeModel.GLGeomObj.buildBuffers();
360 } 366 }
361 world.import(worldData);
362 } 367 }
363 368
364 } 369 }
@@ -378,13 +383,17 @@ exports.ShapesController = Montage.create(CanvasController, {
378 world = new GLWorld(el, false); 383 world = new GLWorld(el, false);
379 el.elementModel.shapeModel.GLWorld = world; 384 el.elementModel.shapeModel.GLWorld = world;
380 el.elementModel.shapeModel.useWebGl = false; 385 el.elementModel.shapeModel.useWebGl = false;
386 world.import(worldData);
387 el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot();
381 el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(null); 388 el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(null);
382 el.elementModel.shapeModel.GLGeomObj.setFillMaterial(null);
383 el.elementModel.shapeModel.strokeMaterial = null; 389 el.elementModel.shapeModel.strokeMaterial = null;
384 el.elementModel.shapeModel.fillMaterial = null; 390 // TODO - Use consts after GL code is converted to object literal notation
385 world.import(worldData); 391 if(el.elementModel.shapeModel.GLGeomObj.geomType() !== 3)
392 {
393 el.elementModel.shapeModel.GLGeomObj.setFillMaterial(null);
394 el.elementModel.shapeModel.fillMaterial = null;
395 }
386 } 396 }
387
388 } 397 }
389 } 398 }
390 399
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/main-menu-controller.js b/js/controllers/main-menu-controller.js
new file mode 100644
index 00000000..5e126617
--- /dev/null
+++ b/js/controllers/main-menu-controller.js
@@ -0,0 +1,43 @@
1/* <copyright>
2This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
4(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5</copyright> */
6
7
8var Montage = require("montage/core/core").Montage,
9 Component = require("montage/ui/component").Component;
10
11exports.MainMenuController = Montage.create(Component, {
12 deserializedFromTemplate:{
13 value:function () {
14 this.eventManager.addEventListener("executeHelpFAQ", this, false);
15 this.eventManager.addEventListener("executeHelpForums", this, false);
16 this.eventManager.addEventListener("executeHelpTopics", this, false);
17 this.eventManager.addEventListener("executeHelpAbout", this, false);
18 }
19 },
20
21 // Basic help menu handling methods
22 handleExecuteHelpFAQ:{
23 value:function () {
24 window.open('http://www.tetsubo.org/go/ninjafaq');
25 }
26 },
27 handleExecuteHelpForums:{
28 value:function () {
29 window.open('http://www.tetsubo.org/go/ninjaforums');
30 }
31 },
32 handleExecuteHelpTopics:{
33 value:function () {
34 window.open('http://www.tetsubo.org/go/ninjadocs');
35 }
36 },
37 handleExecuteHelpAbout:{
38 value:function () {
39 // TODO
40 console.log("Pull up the about popup");
41 }
42 }
43});
diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js
index 011caec5..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,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 }
@@ -840,6 +844,61 @@ var stylesController = exports.StylesController = Montage.create(Component, {
840 } 844 }
841 }, 845 },
842 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 }));