aboutsummaryrefslogtreecommitdiff
path: root/js/panels/Timeline/Layer.reel/Layer.js
diff options
context:
space:
mode:
authorKruti Shah2012-06-12 13:09:11 -0700
committerKruti Shah2012-06-12 13:09:11 -0700
commitd648c842905c7c53e0f89b943982493d2b79f56e (patch)
treeeb5585f92061975215f6d19305a8d1b76262e2fc /js/panels/Timeline/Layer.reel/Layer.js
parentbedb38e14887b29eae3cdf1c8d435259c920257c (diff)
parentcf3b96822665751dae7a64644db3cb3960733c3d (diff)
downloadninja-d648c842905c7c53e0f89b943982493d2b79f56e.tar.gz
Merge branch 'refs/heads/TimelineUberjd' into TimelineUber
Conflicts: js/controllers/elements/element-controller.js js/document/_toDelete/html-document.js js/panels/Timeline/Layer.reel/Layer.js Signed-off-by: Kruti Shah <kruti.shah@motorola.com>
Diffstat (limited to 'js/panels/Timeline/Layer.reel/Layer.js')
-rw-r--r--js/panels/Timeline/Layer.reel/Layer.js132
1 files changed, 83 insertions, 49 deletions
diff --git a/js/panels/Timeline/Layer.reel/Layer.js b/js/panels/Timeline/Layer.reel/Layer.js
index 629b118c..4773489c 100644
--- a/js/panels/Timeline/Layer.reel/Layer.js
+++ b/js/panels/Timeline/Layer.reel/Layer.js
@@ -86,10 +86,12 @@ var Layer = exports.Layer = Montage.create(Component, {
86 if (newVal !== this._selectedStyleIndex) { 86 if (newVal !== this._selectedStyleIndex) {
87 this._selectedStyleIndex = newVal; 87 this._selectedStyleIndex = newVal;
88 this.layerData.selectedStyleIndex = newVal; 88 this.layerData.selectedStyleIndex = newVal;
89 this.needsDraw = true;
90 } 89 }
91 } 90 }
92 }, 91 },
92 _storedStyleIndex : {
93 value: false
94 },
93 95
94 /* Layer models: the name, ID, and selected and animation booleans for the layer */ 96 /* Layer models: the name, ID, and selected and animation booleans for the layer */
95 _layerName:{ 97 _layerName:{
@@ -276,6 +278,10 @@ var Layer = exports.Layer = Montage.create(Component, {
276 if (value === false) { 278 if (value === false) {
277 // If changing from true to false, we need to deselect any associated styles 279 // If changing from true to false, we need to deselect any associated styles
278 this.selectStyle(false); 280 this.selectStyle(false);
281 } else {
282 if (this._storedStyleIndex !== false) {
283 this.selectStyle(this._storedStyleIndex);
284 }
279 } 285 }
280 this._isSelected = value; 286 this._isSelected = value;
281 this.layerData.isSelected = value; 287 this.layerData.isSelected = value;
@@ -342,6 +348,19 @@ var Layer = exports.Layer = Montage.create(Component, {
342 _layerEditable : { 348 _layerEditable : {
343 value: false 349 value: false
344 }, 350 },
351
352 _dynamicLayerName:{
353 value:true
354 },
355 dynamicLayerName:{
356 serializable:true,
357 get:function () {
358 return this._dynamicLayerName;
359 },
360 set:function (newVal) {
361 this._dynamicLayerName = newVal;
362 }
363 },
345 364
346 // Are the various collapsers collapsed or not 365 // Are the various collapsers collapsed or not
347 _isMainCollapsed : { 366 _isMainCollapsed : {
@@ -565,7 +584,7 @@ var Layer = exports.Layer = Montage.create(Component, {
565 } 584 }
566 // Enable or disable the delete style button as appropriate 585 // Enable or disable the delete style button as appropriate
567 if (this.isSelected) { 586 if (this.isSelected) {
568 if (this.selectedStyleIndex !== "false") { 587 if (this.selectedStyleIndex !== false) {
569 this.selectStyle(this.selectedStyleIndex); 588 this.selectStyle(this.selectedStyleIndex);
570 this.buttonDeleteStyle.classList.remove("disabled"); 589 this.buttonDeleteStyle.classList.remove("disabled");
571 } 590 }
@@ -620,7 +639,7 @@ var Layer = exports.Layer = Montage.create(Component, {
620 } 639 }
621 }, 640 },
622 addStyle : { 641 addStyle : {
623 value: function(styleProperty) { 642 value: function(styleProperty, existingRule) {
624 // Add a new style rule. It should be added above the currently selected rule, 643 // Add a new style rule. It should be added above the currently selected rule,
625 // Or at the end, if no rule is selected. 644 // Or at the end, if no rule is selected.
626 645
@@ -649,13 +668,16 @@ var Layer = exports.Layer = Montage.create(Component, {
649 newStyle.editorProperty = styleProperty; 668 newStyle.editorProperty = styleProperty;
650 newEvent.layerEventType = "restoreStyle"; 669 newEvent.layerEventType = "restoreStyle";
651 newEvent.trackEditorProperty = styleProperty; 670 newEvent.trackEditorProperty = styleProperty;
652 newEvent.trackEditorProperty = styleProperty; 671 if(existingRule){
672 newEvent.existingRule = existingRule;
673 }
653 } 674 }
654 newStyle.editorValue = ""; 675 newStyle.editorValue = "";
655 newStyle.ruleTweener = false; 676 newStyle.ruleTweener = false;
656 newStyle.isSelected = false; 677 newStyle.isSelected = false;
657 newStyle.colorelement = ""; 678 newStyle.colorelement = "";
658 this.arrLayerStyles.push(newStyle); 679 this.arrLayerStyles.push(newStyle);
680 this.selectStyle(this.arrLayerStyles.length -1);
659 681
660 // Set up the event info and dispatch the event 682 // Set up the event info and dispatch the event
661 this.styleCounter += 1; 683 this.styleCounter += 1;
@@ -666,56 +688,64 @@ var Layer = exports.Layer = Montage.create(Component, {
666 688
667 deleteStyle : { 689 deleteStyle : {
668 value: function() { 690 value: function() {
669 var newEvent = document.createEvent("CustomEvent"), 691
670 selectedIndex = 0; 692 // Only delete a style if we have one or more styles, and one of them is selected
671 if (this.arrLayerStyles.length > 0) { 693 if ((this.arrLayerStyles.length > 0) && (this.selectedStyleIndex !== false)) {
672 if (!!this.styleRepetition.selectedIndexes) { 694 var newEvent = document.createEvent("CustomEvent");
673 695
674 selectedIndex = this.styleRepetition.selectedIndexes[0]; 696 // Set up the event info and dispatch the event
675 697 newEvent.initCustomEvent("layerEvent", false, true);
676 // Set up the event info and dispatch the event 698 newEvent.layerEventLocale = "styles";
677 newEvent.initCustomEvent("layerEvent", false, true); 699 newEvent.layerEventType = "deleteStyle";
678 newEvent.layerEventLocale = "styles"; 700 newEvent.layerID = this.layerID;
679 newEvent.layerEventType = "deleteStyle"; 701 newEvent.styleID = this.selectedStyleIndex;
680 newEvent.layerID = this.layerID; 702 newEvent.selectedStyleIndex = this.selectedStyleIndex;
681 newEvent.styleID = this.arrLayerStyles[selectedIndex].styleID; 703 defaultEventManager.dispatchEvent(newEvent);
682 newEvent.styleSelection = selectedIndex; 704
683 defaultEventManager.dispatchEvent(newEvent); 705 // Delete the style from the view
684 706 this.arrLayerStyles.splice(this.selectedStyleIndex, 1);
685 // Delete the style from the view 707
686 this.arrLayerStyles.splice(selectedIndex, 1); 708 // Set selection to none
687 709 this.selectedStyleIndex = false;
688 // Was that the last style? 710
689 if (this.arrLayerStyles.length === 0) { 711 // Disable the delete style button, because now nothing is selected
690 this.buttonDeleteStyle.classList.add("disabled"); 712 this.buttonDeleteStyle.classList.add("disabled");
691 } 713 }
692
693 }
694 }
695 } 714 }
696 }, 715 },
697 selectStyle : { 716 selectStyle : {
698 value: function(styleIndex) { 717 value: function(styleIndex) {
699 //console.log("Layer.selectStyle ", styleIndex);
700
701 // Select a style based on its index. 718 // Select a style based on its index.
702 // use layerIndex = false to deselect all styles. 719 // use layerIndex = false to deselect all styles.
703 var i = 0, 720 var i = 0,
704 arrLayerStylesLength = this.arrLayerStyles.length; 721 arrLayerStylesLength = this.arrLayerStyles.length;
705 722
706 723 if (styleIndex === false) {
707 // First, update this.arrStyles[].isSelected 724 if (arrLayerStylesLength === 0) {
708 for (i = 0; i < arrLayerStylesLength; i++) { 725 // No styles selected, so do nothing.
709 if (i === styleIndex) { 726 return;
710 this.arrLayerStyles[i].isSelected = true; 727 }
711 } else { 728 for (i = 0; i < arrLayerStylesLength; i++) {
712 if (this.arrLayerStyles[i].isSelected === true) { 729 if (this.arrLayerStyles[i].isSelected === true) {
713 this.arrLayerStyles[i].isSelected = false; 730 this.arrLayerStyles[i].isSelected = false;
714 } 731 }
715 } 732 }
716 } 733 } else {
717 734 for (i = 0; i < arrLayerStylesLength; i++) {
718 735 if (i === styleIndex) {
736 this.arrLayerStyles[i].isSelected = true;
737 } else {
738 if (this.arrLayerStyles[i].isSelected === true) {
739 this.arrLayerStyles[i].isSelected = false;
740 }
741 }
742 }
743 this.selectedStyleIndex = styleIndex;
744 this._storedStyleIndex = styleIndex;
745 }
746
747
748
719 /* 749 /*
720 // Next, update this.styleRepetition.selectedIndexes. 750 // Next, update this.styleRepetition.selectedIndexes.
721 if (styleIndex !== false) { 751 if (styleIndex !== false) {
@@ -757,7 +787,7 @@ var Layer = exports.Layer = Montage.create(Component, {
757 787
758 if (this._layerEditable.value !== this.layerName) { 788 if (this._layerEditable.value !== this.layerName) {
759 this.layerName = this._layerEditable.value; 789 this.layerName = this._layerEditable.value;
760 this.application.ninja.documentController.activeDocument.needsSave = true; 790 this.application.ninja.currentDocument.model.needsSave = true;
761 this.layerData.stageElement.setAttribute("id",this._layerEditable.value); 791 this.layerData.stageElement.setAttribute("id",this._layerEditable.value);
762 } 792 }