aboutsummaryrefslogtreecommitdiff
path: root/js/panels/Timeline/Layer.reel/Layer.js
diff options
context:
space:
mode:
authorJon Reid2012-05-31 17:09:45 -0700
committerJon Reid2012-05-31 17:09:45 -0700
commit66007a04da84cae1d81af5340b11706d5f25c89d (patch)
treed73469edef0aae13c40075c9d426f893d264d49a /js/panels/Timeline/Layer.reel/Layer.js
parent121d0e616f48aa7cd048763554089c20a1883d7a (diff)
downloadninja-66007a04da84cae1d81af5340b11706d5f25c89d.tar.gz
Timeline: Bug fixes for deleting styles and their associated tracks
correctly.
Diffstat (limited to 'js/panels/Timeline/Layer.reel/Layer.js')
-rw-r--r--js/panels/Timeline/Layer.reel/Layer.js55
1 files changed, 27 insertions, 28 deletions
diff --git a/js/panels/Timeline/Layer.reel/Layer.js b/js/panels/Timeline/Layer.reel/Layer.js
index db4ad712..9576d66f 100644
--- a/js/panels/Timeline/Layer.reel/Layer.js
+++ b/js/panels/Timeline/Layer.reel/Layer.js
@@ -83,6 +83,7 @@ var Layer = exports.Layer = Montage.create(Component, {
83 return; 83 return;
84 } 84 }
85 if (newVal !== this._selectedStyleIndex) { 85 if (newVal !== this._selectedStyleIndex) {
86 console.log("Layer.selectedStyleIndex.set ", newVal);
86 this._selectedStyleIndex = newVal; 87 this._selectedStyleIndex = newVal;
87 this.layerData.selectedStyleIndex = newVal; 88 this.layerData.selectedStyleIndex = newVal;
88 this.needsDraw = true; 89 this.needsDraw = true;
@@ -638,37 +639,34 @@ var Layer = exports.Layer = Montage.create(Component, {
638 }, 639 },
639 deleteStyle : { 640 deleteStyle : {
640 value: function() { 641 value: function() {
641 var newEvent = document.createEvent("CustomEvent"), 642
642 selectedIndex = 0; 643 // Only delete a style if we have one or more styles, and one of them is selected
643 if (this.arrLayerStyles.length > 0) { 644 if ((this.arrLayerStyles.length > 0) && (this.selectedStyleIndex !== false)) {
644 if (!!this.styleRepetition.selectedIndexes) { 645 var newEvent = document.createEvent("CustomEvent");
645
646 selectedIndex = this.styleRepetition.selectedIndexes[0];
647 646
648 // Set up the event info and dispatch the event 647 // Set up the event info and dispatch the event
649 newEvent.initCustomEvent("layerEvent", false, true); 648 newEvent.initCustomEvent("layerEvent", false, true);
650 newEvent.layerEventLocale = "styles"; 649 newEvent.layerEventLocale = "styles";
651 newEvent.layerEventType = "deleteStyle"; 650 newEvent.layerEventType = "deleteStyle";
652 newEvent.layerID = this.layerID; 651 newEvent.layerID = this.layerID;
653 newEvent.styleID = this.arrLayerStyles[selectedIndex].styleID; 652 newEvent.styleID = this.selectedStyleIndex;
654 newEvent.styleSelection = selectedIndex; 653 newEvent.selectedStyleIndex = this.selectedStyleIndex;
655 defaultEventManager.dispatchEvent(newEvent); 654 defaultEventManager.dispatchEvent(newEvent);
656 655
657 // Delete the style from the view 656 // Delete the style from the view
658 this.arrLayerStyles.splice(selectedIndex, 1); 657 this.arrLayerStyles.splice(this.selectedStyleIndex, 1);
659 658
660 // Was that the last style? 659 // Set selection to none
661 if (this.arrLayerStyles.length === 0) { 660 this.selectedStyleIndex = false;
662 this.buttonDeleteStyle.classList.add("disabled"); 661
663 } 662 // Disable the delete style button, because now nothing is selected
664 663 this.buttonDeleteStyle.classList.add("disabled");
665 } 664 }
666 }
667 } 665 }
668 }, 666 },
669 selectStyle : { 667 selectStyle : {
670 value: function(styleIndex) { 668 value: function(styleIndex) {
671 //console.log("Layer.selectStyle ", styleIndex); 669 console.log("Layer.selectStyle ", styleIndex);
672 670
673 // Select a style based on its index. 671 // Select a style based on its index.
674 // use layerIndex = false to deselect all styles. 672 // use layerIndex = false to deselect all styles.
@@ -771,7 +769,9 @@ var Layer = exports.Layer = Montage.create(Component, {
771 }, 769 },
772 handleMousedown: { 770 handleMousedown: {
773 value: function(event) { 771 value: function(event) {
774 //console.log("Layer.handleMousedown") 772 if (event.target.classList.contains("button-delete")) {
773 return;
774 }
775 this.layerData.isActive = true; 775 this.layerData.isActive = true;
776 var ptrParent = nj.queryParentSelector(event.target, ".content-style"), 776 var ptrParent = nj.queryParentSelector(event.target, ".content-style"),
777 activeStyleIndex = this.getActiveStyleIndex(); 777 activeStyleIndex = this.getActiveStyleIndex();
@@ -783,7 +783,6 @@ var Layer = exports.Layer = Montage.create(Component, {
783 }, 783 },
784 handleLayerClick : { 784 handleLayerClick : {
785 value: function(event) { 785 value: function(event) {
786 //console.log("Layer.handleLayerClick")
787 var ptrParent = nj.queryParentSelector(event.target, ".content-style"); 786 var ptrParent = nj.queryParentSelector(event.target, ".content-style");
788 if (ptrParent !== false) { 787 if (ptrParent !== false) {
789 var myIndex = this.getActiveStyleIndex(); 788 var myIndex = this.getActiveStyleIndex();