diff options
Diffstat (limited to 'js/panels/Timeline/Layer.reel/Layer.js')
-rw-r--r-- | js/panels/Timeline/Layer.reel/Layer.js | 264 |
1 files changed, 262 insertions, 2 deletions
diff --git a/js/panels/Timeline/Layer.reel/Layer.js b/js/panels/Timeline/Layer.reel/Layer.js index f81d8b09..4773489c 100644 --- a/js/panels/Timeline/Layer.reel/Layer.js +++ b/js/panels/Timeline/Layer.reel/Layer.js | |||
@@ -12,6 +12,7 @@ var LayerStyle = require("js/panels/Timeline/Style.reel").LayerStyle; | |||
12 | var DynamicText = require("montage/ui/dynamic-text.reel").DynamicText; | 12 | var DynamicText = require("montage/ui/dynamic-text.reel").DynamicText; |
13 | var defaultEventManager = require("montage/core/event/event-manager").defaultEventManager; | 13 | var defaultEventManager = require("montage/core/event/event-manager").defaultEventManager; |
14 | var nj = require("js/lib/NJUtils").NJUtils; | 14 | var nj = require("js/lib/NJUtils").NJUtils; |
15 | var ElementsMediator = require("js/mediators/element-mediator").ElementMediator; | ||
15 | 16 | ||
16 | var Layer = exports.Layer = Montage.create(Component, { | 17 | var Layer = exports.Layer = Montage.create(Component, { |
17 | 18 | ||
@@ -205,7 +206,6 @@ var Layer = exports.Layer = Montage.create(Component, { | |||
205 | this._dtextPositionX = value; | 206 | this._dtextPositionX = value; |
206 | this.layerData.dtextPositionX = value; | 207 | this.layerData.dtextPositionX = value; |
207 | } | 208 | } |
208 | |||
209 | } | 209 | } |
210 | }, | 210 | }, |
211 | 211 | ||
@@ -543,8 +543,33 @@ var Layer = exports.Layer = Montage.create(Component, { | |||
543 | this.element.addEventListener("dragleave", this.handleDragleave.bind(this), false); | 543 | this.element.addEventListener("dragleave", this.handleDragleave.bind(this), false); |
544 | this.element.addEventListener("dragstart", this.handleDragstart.bind(this), false); | 544 | this.element.addEventListener("dragstart", this.handleDragstart.bind(this), false); |
545 | this.element.addEventListener("drop", this.handleDrop.bind(this), false); | 545 | this.element.addEventListener("drop", this.handleDrop.bind(this), false); |
546 | |||
547 | this.eventManager.addEventListener("elementChange",this,false); | ||
548 | |||
549 | this.leftControl.identifier = "left"; | ||
550 | this.leftControl.addEventListener("changing",this,false); | ||
551 | this.leftControl.addEventListener("change",this,false); | ||
552 | |||
553 | this.topControl.identifier = "top"; | ||
554 | this.topControl.addEventListener("changing",this,false); | ||
555 | this.topControl.addEventListener("change",this,false); | ||
556 | |||
557 | this.widthControl.identifier = "width"; | ||
558 | this.widthControl.addEventListener("changing",this,false); | ||
559 | this.widthControl.addEventListener("change",this,false); | ||
560 | |||
561 | this.heightControl.identifier = "height"; | ||
562 | this.heightControl.addEventListener("changing",this,false); | ||
563 | this.heightControl.addEventListener("change",this,false); | ||
564 | |||
565 | el=this.layerData.stageElement; | ||
566 | this.dtextPositionX = parseFloat(ElementsMediator.getProperty(el, "left")); | ||
567 | this.dtextPositionY = parseFloat(ElementsMediator.getProperty(el, "top")); | ||
568 | this.dtextScaleY = parseFloat(ElementsMediator.getProperty(el, "height")); | ||
569 | this.dtextScaleX= parseFloat(ElementsMediator.getProperty(el, "width")); | ||
546 | } | 570 | } |
547 | }, | 571 | }, |
572 | |||
548 | draw: { | 573 | draw: { |
549 | value: function() { | 574 | value: function() { |
550 | var boolHasClass = this.element.classList.contains("layerSelected"); | 575 | var boolHasClass = this.element.classList.contains("layerSelected"); |
@@ -650,6 +675,7 @@ var Layer = exports.Layer = Montage.create(Component, { | |||
650 | newStyle.editorValue = ""; | 675 | newStyle.editorValue = ""; |
651 | newStyle.ruleTweener = false; | 676 | newStyle.ruleTweener = false; |
652 | newStyle.isSelected = false; | 677 | newStyle.isSelected = false; |
678 | newStyle.colorelement = ""; | ||
653 | this.arrLayerStyles.push(newStyle); | 679 | this.arrLayerStyles.push(newStyle); |
654 | this.selectStyle(this.arrLayerStyles.length -1); | 680 | this.selectStyle(this.arrLayerStyles.length -1); |
655 | 681 | ||
@@ -659,6 +685,7 @@ var Layer = exports.Layer = Montage.create(Component, { | |||
659 | defaultEventManager.dispatchEvent(newEvent); | 685 | defaultEventManager.dispatchEvent(newEvent); |
660 | } | 686 | } |
661 | }, | 687 | }, |
688 | |||
662 | deleteStyle : { | 689 | deleteStyle : { |
663 | value: function() { | 690 | value: function() { |
664 | 691 | ||
@@ -773,6 +800,7 @@ var Layer = exports.Layer = Montage.create(Component, { | |||
773 | this.triggerOutgoingBinding(); | 800 | this.triggerOutgoingBinding(); |
774 | 801 | ||
775 | this.addStyle(); | 802 | this.addStyle(); |
803 | |||
776 | } | 804 | } |
777 | }, | 805 | }, |
778 | handleDeleteStyleClick: { | 806 | handleDeleteStyleClick: { |
@@ -919,6 +947,238 @@ var Layer = exports.Layer = Montage.create(Component, { | |||
919 | return false; | 947 | return false; |
920 | } | 948 | } |
921 | }, | 949 | }, |
950 | |||
951 | handleLeftChange: { | ||
952 | value: function(event) { | ||
953 | var prevPosition; | ||
954 | if(this.application.ninja.timeline.selectedStyle==="left" ||this.application.ninja.timeline.selectedStyle==="master" ){ | ||
955 | if(!event.wasSetByCode) { | ||
956 | if(this.savedPosition) prevPosition = [this.savedPosition + "px"]; | ||
957 | this.application.ninja.elementMediator.setProperty([this.layerData.stageElement], "left", [this.leftControl.value + "px"] , "Change", "timeline", prevPosition); | ||
958 | this.savedPosition = null; | ||
959 | } | ||
960 | |||
961 | } | ||
962 | } | ||
963 | }, | ||
964 | |||
965 | handleTopChange: { | ||
966 | value: function(event) { | ||
967 | var prevPosition; | ||
968 | if(this.application.ninja.timeline.selectedStyle==="top" ||this.application.ninja.timeline.selectedStyle==="master" ){ | ||
969 | if(!event.wasSetByCode) { | ||
970 | if(this.savedPosition) prevPosition = [this.savedPosition + "px"]; | ||
971 | |||
972 | this.application.ninja.elementMediator.setProperty([this.layerData.stageElement], "top", [this.topControl.value + "px"] , "Change", "timeline", prevPosition); | ||
973 | this.savedPosition = null; | ||
974 | } | ||
975 | } | ||
976 | } | ||
977 | }, | ||
978 | |||
979 | handleWidthChange:{ | ||
980 | value: function(event) { | ||
981 | var prevPosition; | ||
982 | if(this.application.ninja.timeline.selectedStyle==="width" ||this.application.ninja.timeline.selectedStyle==="master" ){ | ||
983 | if(!event.wasSetByCode) { | ||
984 | if(this.savedPosition) prevPosition = [this.savedPosition + "px"]; | ||
985 | |||
986 | this.application.ninja.elementMediator.setProperty([this.layerData.stageElement], "width", [this.dtextScaleX + "px"] , "Change", "timeline", prevPosition); | ||
987 | this.savedPosition = null; | ||
988 | } | ||
989 | } | ||
990 | } | ||
991 | }, | ||
992 | |||
993 | handleHeightChange:{ | ||
994 | value: function(event) { | ||
995 | var prevPosition; | ||
996 | if(this.application.ninja.timeline.selectedStyle==="height" ||this.application.ninja.timeline.selectedStyle==="master" ){ | ||
997 | if(!event.wasSetByCode) { | ||
998 | if(this.savedPosition) prevPosition = [this.savedPosition + "px"]; | ||
999 | |||
1000 | this.application.ninja.elementMediator.setProperty([this.layerData.stageElement], "height", [this.dtextScaleY + "px"] , "Change", "timeline", prevPosition); | ||
1001 | this.savedPosition = null; | ||
1002 | } | ||
1003 | } | ||
1004 | } | ||
1005 | }, | ||
1006 | |||
1007 | handleLeftChanging: { | ||
1008 | value: function(event) { | ||
1009 | |||
1010 | if(this.application.ninja.timeline.selectedStyle==="left" ||this.application.ninja.timeline.selectedStyle==="master" ){ | ||
1011 | if(!event.wasSetByCode) { | ||
1012 | if(!this.savedPosition) this.savedPosition = this.leftPosition; | ||
1013 | this.application.ninja.elementMediator.setProperty([this.layerData.stageElement], "left", [this.leftControl.value + "px"] , "Changing", "timeline"); | ||
1014 | } | ||
1015 | } | ||
1016 | |||
1017 | } | ||
1018 | }, | ||
1019 | |||
1020 | handleTopChanging: { | ||
1021 | value: function(event) { | ||
1022 | if(this.application.ninja.timeline.selectedStyle==="top" ||this.application.ninja.timeline.selectedStyle==="master" ){ | ||
1023 | if(!event.wasSetByCode) { | ||
1024 | if(!this.savedPosition) this.savedPosition = this.topPosition; | ||
1025 | this.application.ninja.elementMediator.setProperty([this.layerData.stageElement], "top", [this.topControl.value + "px"] , "Changing", "timeline"); | ||
1026 | } | ||
1027 | } | ||
1028 | |||
1029 | } | ||
1030 | }, | ||
1031 | |||
1032 | handleWidthChanging:{ | ||
1033 | value: function(event) { | ||
1034 | if(this.application.ninja.timeline.selectedStyle==="width" ||this.application.ninja.timeline.selectedStyle==="master" ){ | ||
1035 | if(!event.wasSetByCode) { | ||
1036 | if(!this.savedPosition) this.savedPosition = this.dtextScaleX; | ||
1037 | this.application.ninja.elementMediator.setProperty([this.layerData.stageElement], "width", [this.dtextScaleX + "px"] , "Changing", "timeline"); | ||
1038 | } | ||
1039 | } | ||
1040 | |||
1041 | } | ||
1042 | }, | ||
1043 | |||
1044 | handleHeightChanging:{ | ||
1045 | value: function(event) { | ||
1046 | if(this.application.ninja.timeline.selectedStyle==="height" ||this.application.ninja.timeline.selectedStyle==="master" ){ | ||
1047 | if(!event.wasSetByCode) { | ||
1048 | if(!this.savedPosition) this.savedPosition = this.dtextScaleY; | ||
1049 | this.application.ninja.elementMediator.setProperty([this.layerData.stageElement], "height", [this.dtextScaleY + "px"] , "Changing", "timeline"); | ||
1050 | } | ||
1051 | } | ||
1052 | |||
1053 | } | ||
1054 | }, | ||
1055 | |||
1056 | |||
1057 | handleElementChange:{ | ||
1058 | value:function(event){ | ||
1059 | var el =this.layerData.stageElement; | ||
1060 | var length = this.arrLayerStyles.length , i , k=0; | ||
1061 | |||
1062 | this.dtextPositionX = parseFloat(ElementsMediator.getProperty(el, "left")); | ||
1063 | this.dtextPositionY = parseFloat(ElementsMediator.getProperty(el, "top")); | ||
1064 | this.dtextScaleY = parseFloat(ElementsMediator.getProperty(el, "height")); | ||
1065 | this.dtextScaleX= parseFloat(ElementsMediator.getProperty(el, "width")); | ||
1066 | |||
1067 | |||
1068 | for(i=0; i<length; i++){ | ||
1069 | if (event.detail.data.prop === "color"){ | ||
1070 | var currentValue1 = ElementsMediator.getColor(this.layerData.stageElement,event.detail.data.isFill,event.detail.data.borderSide); | ||
1071 | if(event.detail.data.isFill){ | ||
1072 | while(k <length){ | ||