aboutsummaryrefslogtreecommitdiff
path: root/js/panels/Timeline/PropertyTrack.reel/PropertyTrack.js
diff options
context:
space:
mode:
authorKruti Shah2012-07-09 10:53:35 -0700
committerKruti Shah2012-07-09 10:53:35 -0700
commit8a2a9cf8d43a1ba7e40c41619e7db9675f4cb195 (patch)
tree93e10a0895677c545591ae698b4f7d0b2180d0c9 /js/panels/Timeline/PropertyTrack.reel/PropertyTrack.js
parent028e0a2ccde5458303d90a9dd6c4fde09b1b6565 (diff)
downloadninja-8a2a9cf8d43a1ba7e40c41619e7db9675f4cb195.tar.gz
Refactoring Code
Signed-off-by: Kruti Shah <kruti.shah@motorola.com>
Diffstat (limited to 'js/panels/Timeline/PropertyTrack.reel/PropertyTrack.js')
-rw-r--r--js/panels/Timeline/PropertyTrack.reel/PropertyTrack.js73
1 files changed, 61 insertions, 12 deletions
diff --git a/js/panels/Timeline/PropertyTrack.reel/PropertyTrack.js b/js/panels/Timeline/PropertyTrack.reel/PropertyTrack.js
index 6463e396..b46a6242 100644
--- a/js/panels/Timeline/PropertyTrack.reel/PropertyTrack.js
+++ b/js/panels/Timeline/PropertyTrack.reel/PropertyTrack.js
@@ -9,6 +9,7 @@ var Component = require("montage/ui/component").Component;
9 9
10var PropertyTrack = exports.PropertyTrack = Montage.create(Component, { 10var PropertyTrack = exports.PropertyTrack = Montage.create(Component, {
11 11
12 /* Begin: Models */
12 hasTemplate:{ 13 hasTemplate:{
13 value: true 14 value: true
14 }, 15 },
@@ -155,6 +156,9 @@ var PropertyTrack = exports.PropertyTrack = Montage.create(Component, {
155 } 156 }
156 }, 157 },
157 158
159 /* End: Models */
160
161 /* Begin: Draw Cycle */
158 prepareForDraw:{ 162 prepareForDraw:{
159 value:function(){ 163 value:function(){
160 this.element.addEventListener("click", this, false); 164 this.element.addEventListener("click", this, false);
@@ -173,10 +177,16 @@ var PropertyTrack = exports.PropertyTrack = Montage.create(Component, {
173 } 177 }
174 }, 178 },
175 179
180 /* End: Draw Cycle */
181
182 /* Begin: Event Handlers */
183
176 handleClick:{ 184 handleClick:{
177 value:function (ev) { 185 value:function (ev) {
178 186
179 var selectIndex , currentSelectedStyleIndex; 187 var selectIndex ,
188 currentSelectedStyleIndex;
189
180 if (ev.shiftKey) { 190 if (ev.shiftKey) {
181 191
182 if (this.trackType == "position") { 192 if (this.trackType == "position") {
@@ -212,7 +222,10 @@ var PropertyTrack = exports.PropertyTrack = Montage.create(Component, {
212 222
213 handleNewPropTween:{ 223 handleNewPropTween:{
214 value:function (ev) { 224 value:function (ev) {
215 var findXOffset, targetElementOffset, position; 225 var findXOffset,
226 targetElementOffset,
227 position;
228
216 if (ev.offsetX > this.propTweens[this.propTweens.length - 1].tweenData.keyFramePosition) { 229 if (ev.offsetX > this.propTweens[this.propTweens.length - 1].tweenData.keyFramePosition) {
217 this.insertPropTween(ev.offsetX); 230 this.insertPropTween(ev.offsetX);
218 } else { 231 } else {
@@ -235,6 +248,10 @@ var PropertyTrack = exports.PropertyTrack = Montage.create(Component, {
235 } 248 }
236 }, 249 },
237 250
251 /* End: Event Handlers */
252
253 /* Begin: Controllers */
254
238 getCurrentSelectedStyleIndex: { 255 getCurrentSelectedStyleIndex: {
239 value: function(layerIndex) { 256 value: function(layerIndex) {
240 var returnVal = false, 257 var returnVal = false,
@@ -253,7 +270,12 @@ var PropertyTrack = exports.PropertyTrack = Montage.create(Component, {
253 270
254 insertPropTween:{ 271 insertPropTween:{
255 value:function(clickPos){ 272 value:function(clickPos){
256 var selectedIndex, currentMillisecPerPixel, currentMillisec, propVal 273 var selectedIndex,
274 currentMillisecPerPixel,
275 currentMillisec,
276 propVal,
277 newTween;
278
257 selectedIndex = this.application.ninja.timeline.getLayerIndexByID(this.trackID); 279 selectedIndex = this.application.ninja.timeline.getLayerIndexByID(this.trackID);
258 this.application.ninja.timeline.selectLayer(selectedIndex, true); 280 this.application.ninja.timeline.selectLayer(selectedIndex, true);
259 281
@@ -261,7 +283,7 @@ var PropertyTrack = exports.PropertyTrack = Montage.create(Component, {
261 currentMillisec = currentMillisecPerPixel * clickPos; 283 currentMillisec = currentMillisecPerPixel * clickPos;
262 this.trackDuration = currentMillisec; 284 this.trackDuration = currentMillisec;
263 285
264 var newTween = {}; 286 newTween = {};
265 newTween.tweenData = {}; 287 newTween.tweenData = {};
266 newTween.tweenData.tweenedProperties = []; 288 newTween.tweenData.tweenedProperties = [];
267 289
@@ -302,7 +324,8 @@ var PropertyTrack = exports.PropertyTrack = Montage.create(Component, {
302 tweensLength = this.propTweens.length - 1, 324 tweensLength = this.propTweens.length - 1,
303 prevTween, 325 prevTween,
304 nextTween, 326 nextTween,
305 splitTweenIndex; 327 splitTweenIndex,
328 newTweenToInsert;
306 329
307 for (i = 0; i < tweensLength; i++) { 330 for (i = 0; i < tweensLength; i++) {
308 prevTween = this.propTweens[i].tweenData.keyFramePosition; 331 prevTween = this.propTweens[i].tweenData.keyFramePosition;
@@ -323,7 +346,7 @@ var PropertyTrack = exports.PropertyTrack = Montage.create(Component, {
323 } 346 }
324 this.propTweenRepetition.childComponents[nextComponentIndex].setData(); 347 this.propTweenRepetition.childComponents[nextComponentIndex].setData();
325 348
326 var newTweenToInsert = {}; 349 newTweenToInsert = {};
327 newTweenToInsert.tweenData = {}; 350 newTweenToInsert.tweenData = {};
328 newTweenToInsert.tweenData.spanWidth = position - prevTween; 351 newTweenToInsert.tweenData.spanWidth = position - prevTween;
329 newTweenToInsert.tweenData.keyFramePosition = position; 352 newTweenToInsert.tweenData.keyFramePosition = position;
@@ -347,8 +370,21 @@ var PropertyTrack = exports.PropertyTrack = Montage.create(Component, {
347 370
348 retrieveStoredStyleTweens:{ 371 retrieveStoredStyleTweens:{
349 value:function(){ 372 value:function(){
350 var percentValue, fraction, splitValue, styleLength, firstChar, currProp, propVal ; 373 var j,k,i,percentValue,
351 var currentMilliSec, currentMilliSecPerPixel, clickPosition, tempTiming, tempTimingFloat, trackTiming, j, k, i = 0; 374 fraction,
375 splitValue,
376 styleLength,
377 firstChar,
378 currProp,
379 propVal ,
380 currentMilliSec,
381 currentMilliSecPerPixel,
382 clickPosition,
383 tempTiming,
384 tempTimingFloat,
385 trackTiming,
386 keyframeStyles,
387 newTween;
352 388
353 if (this.animatedElement !== undefined) { 389 if (this.animatedElement !== undefined) {
354 this.animationName = this.currentKeyframeRule.name; 390 this.animationName = this.currentKeyframeRule.name;
@@ -358,7 +394,7 @@ var PropertyTrack = exports.PropertyTrack = Montage.create(Component, {
358 this.nextKeyframe = 0; 394 this.nextKeyframe = 0;
359 395
360 for (i = 0; this.currentKeyframeRule[i]; i++) { 396 for (i = 0; this.currentKeyframeRule[i]; i++) {
361 var newTween = {}; 397 newTween = {};
362 newTween.tweenData = {}; 398 newTween.tweenData = {};
363 399
364 styleLength = this.currentKeyframeRule[i].style.length, keyframeStyles = []; 400 styleLength = this.currentKeyframeRule[i].style.length, keyframeStyles = [];
@@ -414,6 +450,13 @@ var PropertyTrack = exports.PropertyTrack = Montage.create(Component, {
414 450
415 updatePropKeyframeRule:{ 451 updatePropKeyframeRule:{
416 value:function(){ 452 value:function(){
453 var keyframeString,
454 keyMill,
455 trackDur,
456 keyframePercent,
457 keyframePropertyString,
458 prop;
459
417 this.ninjaStylesContoller.deleteRule(this.currentKeyframeRule); 460 this.ninjaStylesContoller.deleteRule(this.currentKeyframeRule);
418 461
419 // build the new keyframe string 462 // build the new keyframe string
@@ -438,8 +481,14 @@ var PropertyTrack = exports.PropertyTrack = Montage.create(Component, {
438 481
439 addPropAnimationRuleToElement:{ 482 addPropAnimationRuleToElement:{
440 value:function(tweenEvent){ 483 value:function(tweenEvent){
441 var currentStyleValue, currentAnimationNameString, newAnimationNames, currentAnimationDuration, newAnimationDuration, currentIterationCount; 484 var currentStyleValue,
442 var newIterationCount, initRule; 485 currentAnimationNameString,
486 newAnimationNames,
487 currentAnimationDuration,
488 newAnimationDuration,
489 currentIterationCount,
490 newIterationCount,
491 initRule;
443 492
444 currentStyleValue = this.ninjaStylesContoller.getElementStyle(this.animatedElement, this.trackEditorProperty); 493 currentStyleValue = this.ninjaStylesContoller.getElementStyle(this.animatedElement, this.trackEditorProperty);
445 if (currentStyleValue == null) { 494 if (currentStyleValue == null) {
@@ -471,5 +520,5 @@ var PropertyTrack = exports.PropertyTrack = Montage.create(Component, {
471 this.insertPropTween(tweenEvent.offsetX); 520 this.insertPropTween(tweenEvent.offsetX);
472 } 521 }
473 } 522 }
474 /* ===- End Controllers ==== */ 523 /* End: Controllers */
475}); 524});
<