aboutsummaryrefslogtreecommitdiff
path: root/js/panels/Timeline/EasingMenu.reel/EasingMenu.js
diff options
context:
space:
mode:
authorJon Reid2012-06-13 16:00:32 -0700
committerJon Reid2012-06-13 16:00:32 -0700
commit80d1074a5e4a10da8d36c14b8d4f4e9fae47a5ec (patch)
tree56e68ec0dd0b43c13327f6ee7ba258b22dbd02c2 /js/panels/Timeline/EasingMenu.reel/EasingMenu.js
parentf97e4b6ab1db9fb7de18b2e44c1b0edcf2ba072d (diff)
downloadninja-80d1074a5e4a10da8d36c14b8d4f4e9fae47a5ec.tar.gz
Timeline: More work on new easing menu.
Diffstat (limited to 'js/panels/Timeline/EasingMenu.reel/EasingMenu.js')
-rw-r--r--js/panels/Timeline/EasingMenu.reel/EasingMenu.js141
1 files changed, 132 insertions, 9 deletions
diff --git a/js/panels/Timeline/EasingMenu.reel/EasingMenu.js b/js/panels/Timeline/EasingMenu.reel/EasingMenu.js
index b736ea59..006efd69 100644
--- a/js/panels/Timeline/EasingMenu.reel/EasingMenu.js
+++ b/js/panels/Timeline/EasingMenu.reel/EasingMenu.js
@@ -13,26 +13,149 @@ var EasingMenu = exports.EasingMenu = Montage.create(Component, {
13 hasTemplate:{ 13 hasTemplate:{
14 value: true 14 value: true
15 }, 15 },
16
17 /* Begin: Models */
18
19 // popup: the initialized component.
20 _popup: {
21 value: null
22 },
23 popup: {
24 get: function() {
25 return this._popup;
26 },
27 set: function(newVal) {
28 this._popup = newVal
29 }
30 },
31
32 // callingComponent: pointer to the span that called for the menu
33 _callingComponent: {
34 value: null
35 },
36 callingComponent: {
37 get: function() {
38 return this._callingComponent;
39 },
40 set: function(newVal) {
41 this._callingComponent = newVal;
42 }
43 },
44
45 // anchor: pointer to the anchoring element
46 _anchor: {
47 value: null
48 },
49 anchor: {
50 get: function() {
51 return this._anchor;
52 },
53 set: function(newVal) {
54 this._anchor = newVal;
55 }
56 },
57
58
59 _top: {
60 value: null
61 },
62 top: {
63 get: function() {
64 return this._top;
65 },
66 set: function(newVal) {
67 this._top = newVal;
68 }
69 },
70 _left: {
71 value: null
72 },
73 left: {
74 get: function() {
75 return this._left;
76 },
77 set: function(newVal) {
78 this._left = newVal;
79 }
80 },
81
82 // currentChoice: The data attribute of the current choice
83 _currentChoice: {
84 value: null
85 },
86 currentChoice: {
87 get: function() {
88 return this._currentChoice;
89 },
90 set: function(newVal) {
91 this._currentChoice = newVal;
92 }
93 },
94
95 /* End: Models */
96
97 /* Begin: Draw Cycle */
98 willDraw: {
99 value: function() {
100 this.element.addEventListener("click", this.handleEasingChoicesClick.bind(this), false);
101 }
102 },
16 103
17 draw: { 104 draw: {
18 value: function() { 105 value: function() {
19 console.log("EasingMenu.draw") 106 // Update the selection classes.
107 this.element.querySelector(".easing-selected").classList.remove("easing-selected");
108 this.element.querySelector('[data-ninja-ease="'+this.currentChoice+'"]').classList.add("easing-selected");
109 }
110 },
111 didDraw: {
112 value: function() {
20 } 113 }
21 }, 114 },
115 /* End Draw Cycle */
22 116
117 /* Begin: Controllers */
23 show: { 118 show: {
24 value: function() { 119 value: function() {
25 var popup, easingMenu; 120 // Initialize the popup if it hasn't already been done
26 popup = Popup.create(); 121 if (this.popup == null) {
27 this._popup = popup; 122 this.popup = Popup.create();
123 this.popup.modal = false;
124 this.popup.content = EasingMenu.create();
125 }
126
127 // Show the popup
128 this.popup.anchor = this.anchor;
129 var position = {};
130 position.top = this.top;
131 position.left = this.left;
132 this.popup.position = position;
133 this.popup.show();
28 134
29 popup.modal = false;
30 135
31 easingMenu = EasingMenu.create(); 136
32 popup.content = easingMenu; 137
33 138
34 popup.show(); 139 // Redraw the content (needed to reflect probable changes in selection from the last time we showed it)
140 this.popup.content.needsDraw = true;
35 } 141 }
142 },
143 handleEasingChoicesClick: {
144 value: function(event) {
145 event.stopPropagation();
146
147 // Un-highlight the old choice and highlight the new choice
148 this.element.querySelector(".easing-selected").classList.remove("easing-selected");
149 event.target.classList.add("easing-selected");
150
151 // Set the easing in the span that called us
152 this.callingComponent.easing = event.target.dataset.ninjaEase;
153
154 // Hide the menu.
155 this.popup.hide();
156 }
36 } 157 }
37 158
159 /* End: Controllers */
160
38}); 161});