aboutsummaryrefslogtreecommitdiff
path: root/js/panels/color/colorpopup-manager.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/panels/color/colorpopup-manager.js')
-rwxr-xr-xjs/panels/color/colorpopup-manager.js1254
1 files changed, 627 insertions, 627 deletions
diff --git a/js/panels/color/colorpopup-manager.js b/js/panels/color/colorpopup-manager.js
index 7daf0e97..5667fbe7 100755
--- a/js/panels/color/colorpopup-manager.js
+++ b/js/panels/color/colorpopup-manager.js
@@ -27,156 +27,156 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28POSSIBILITY OF SUCH DAMAGE. 28POSSIBILITY OF SUCH DAMAGE.
29</copyright> */ 29</copyright> */
30 30
31//////////////////////////////////////////////////////////////////////// 31////////////////////////////////////////////////////////////////////////
32// 32//
33var Montage = require("montage/core/core").Montage, 33var Montage = require("montage/core/core").Montage,
34 Component = require("montage/ui/component").Component, 34 Component = require("montage/ui/component").Component,
35 ColorPanelPopup = require("js/panels/Color/colorpanelpopup.reel").ColorPanelPopup, 35 ColorPanelPopup = require("js/panels/Color/colorpanelpopup.reel").ColorPanelPopup,
36 ColorModel = require("js/models/color-model").ColorModel; 36 ColorModel = require("js/models/color-model").ColorModel;
37//////////////////////////////////////////////////////////////////////// 37////////////////////////////////////////////////////////////////////////
38//Exporting as ColorPopupManager 38//Exporting as ColorPopupManager
39exports.ColorPopupManager = Montage.create(Component, { 39exports.ColorPopupManager = Montage.create(Component, {
40 //////////////////////////////////////////////////////////////////// 40 ////////////////////////////////////////////////////////////////////
41 // 41 //
42 hasTemplate: { 42 hasTemplate: {
43 value: false 43 value: false
44 }, 44 },
45 //////////////////////////////////////////////////////////////////// 45 ////////////////////////////////////////////////////////////////////
46 // 46 //
47 _hasCloseEvents: { 47 _hasCloseEvents: {
48 value: false 48 value: false
49 }, 49 },
50 //////////////////////////////////////////////////////////////////// 50 ////////////////////////////////////////////////////////////////////
51 // 51 //
52 addCloseEvents: { 52 addCloseEvents: {
53 value: function () { 53 value: function () {
54 // 54 //
55 this._hasCloseEvents = true; 55 this._hasCloseEvents = true;
56 //////////////////////////////////////////////////////////// 56 ////////////////////////////////////////////////////////////
57 //Closing popups on resize 57 //Closing popups on resize
58 window.addEventListener('resize', this, false); 58 window.addEventListener('resize', this, false);
59 //Closing popups if outside limits 59 //Closing popups if outside limits
60 document.addEventListener('mousedown', this, false); 60 document.addEventListener('mousedown', this, false);
61 //////////////////////////////////////////////////////////// 61 ////////////////////////////////////////////////////////////
62 } 62 }
63 }, 63 },
64 //////////////////////////////////////////////////////////////////// 64 ////////////////////////////////////////////////////////////////////
65 // 65 //
66 removeCloseEvents: { 66 removeCloseEvents: {
67 value: function () { 67 value: function () {
68 // 68 //
69 this._hasCloseEvents = false; 69 this._hasCloseEvents = false;
70 //////////////////////////////////////////////////////////// 70 ////////////////////////////////////////////////////////////
71 //Closing popups on resize 71 //Closing popups on resize
72 window.removeEventListener('resize', this, false); 72 window.removeEventListener('resize', this, false);
73 //Closing popups if outside limits 73 //Closing popups if outside limits
74 document.removeEventListener('mousedown', this, false); 74 document.removeEventListener('mousedown', this, false);
75 //////////////////////////////////////////////////////////// 75 ////////////////////////////////////////////////////////////
76 } 76 }
77 }, 77 },
78 //////////////////////////////////////////////////////////////////// 78 ////////////////////////////////////////////////////////////////////
79 // 79 //
80 handleMousedown: { 80 handleMousedown: {
81 value: function (e) { 81 value: function (e) {
82 // 82 //
83 this.closeAllPopups(e); 83 this.closeAllPopups(e);
84 } 84 }
85 }, 85 },
86 //////////////////////////////////////////////////////////////////// 86 ////////////////////////////////////////////////////////////////////
87 // 87 //
88 handleResize: { 88 handleResize: {
89 value: function (e) { 89 value: function (e) {
90 // 90 //
91 this.hideColorPopup(); 91 this.hideColorPopup();
92 } 92 }
93 }, 93 },
94 //////////////////////////////////////////////////////////////////// 94 ////////////////////////////////////////////////////////////////////
95 // 95 //
96 closeAllPopups: { 96 closeAllPopups: {
97 value: function (e) { 97 value: function (e) {
98 // 98 //
99 if (this._popupBase && !this._popupChipBase && !this._popupGradientChipBase) { 99 if (this._popupBase && !this._popupChipBase && !this._popupGradientChipBase) {
100 if(!this.popupHitCheck(this._popupBase, e)) { 100 if(!this.popupHitCheck(this._popupBase, e)) {
101 this.hideColorPopup(); 101 this.hideColorPopup();
102 } 102 }
103 } else if (!this._popupBase && this._popupChipBase && !this._popupGradientChipBase) { 103 } else if (!this._popupBase && this._popupChipBase && !this._popupGradientChipBase) {
104 if(!this.popupHitCheck(this._popupChipBase, e)) { 104 if(!this.popupHitCheck(this._popupChipBase, e)) {
105 this.hideColorChipPopup(); 105 this.hideColorChipPopup();
106 } 106 }
107 } else if (this._popupBase && this._popupChipBase && !this._popupGradientChipBase) { 107 } else if (this._popupBase && this._popupChipBase && !this._popupGradientChipBase) {
108 if(!this.popupHitCheck(this._popupBase, e) && !this.popupHitCheck(this._popupChipBase, e)) { 108 if(!this.popupHitCheck(this._popupBase, e) && !this.popupHitCheck(this._popupChipBase, e)) {
109 this.hideColorPopup(); 109 this.hideColorPopup();
110 } 110 }
111 } else if (this._popupBase && this._popupChipBase && this._popupGradientChipBase) { 111 } else if (this._popupBase && this._popupChipBase && this._popupGradientChipBase) {
112 if(!this.popupHitCheck(this._popupBase, e) && !this.popupHitCheck(this._popupChipBase, e) && !this.popupHitCheck(this._popupGradientChipBase, e)) { 112 if(!this.popupHitCheck(this._popupBase, e) && !this.popupHitCheck(this._popupChipBase, e) && !this.popupHitCheck(this._popupGradientChipBase, e)) {
113 this.hideColorPopup(); 113 this.hideColorPopup();
114 } 114 }
115 } else if (!this._popupBase && this._popupChipBase && this._popupGradientChipBase) { 115 } else if (!this._popupBase && this._popupChipBase && this._popupGradientChipBase) {
116 if(!this.popupHitCheck(this._popupChipBase, e) && !this.popupHitCheck(this._popupGradientChipBase, e)) { 116 if(!this.popupHitCheck(this._popupChipBase, e) && !this.popupHitCheck(this._popupGradientChipBase, e)) {
117 this.hideColorChipPopup(); 117 this.hideColorChipPopup();
118 } 118 }
119 } else if (this._popupBase && !this._popupChipBase && this._popupGradientChipBase) { 119 } else if (this._popupBase && !this._popupChipBase && this._popupGradientChipBase) {
120 if(!this.popupHitCheck(this._popupBase, e) && !this.popupHitCheck(this._popupGradientChipBase, e)) { 120 if(!this.popupHitCheck(this._popupBase, e) && !this.popupHitCheck(this._popupGradientChipBase, e)) {
121 this.hideColorPopup(); 121 this.hideColorPopup();
122 } 122 }
123 } 123 }
124 } 124 }
125 }, 125 },
126 //////////////////////////////////////////////////////////////////// 126 ////////////////////////////////////////////////////////////////////
127 // 127 //
128 popupHitCheck: { 128 popupHitCheck: {
129 value: function (element, e) { 129 value: function (element, e) {
130 //Prevent any action for button to handle toggling 130 //Prevent any action for button to handle toggling
131 if (e._event.target.inputType || e._event.target.colorMode) return true; 131 if (e._event.target.inputType || e._event.target.colorMode) return true;
132 //Storing limits of popup 132 //Storing limits of popup
133 var top, bottom, left, right; 133 var top, bottom, left, right;
134 //Checking for popup to be opened otherwise nothing happens 134 //Checking for popup to be opened otherwise nothing happens
135 if (element && element.opened && element.popup && element.popup.element) { 135 if (element && element.opened && element.popup && element.popup.element) {
136 //Getting horizontal limits 136 //Getting horizontal limits
137 left = parseInt(element.popup.element.style.left) + parseInt(element.popup.element.style.marginLeft); 137 left = parseInt(element.popup.element.style.left) + parseInt(element.popup.element.style.marginLeft);
138 right = left + parseInt(element.popup.element.offsetWidth); 138 right = left + parseInt(element.popup.element.offsetWidth);
139 //Getting vertical limits 139 //Getting vertical limits
140 top = parseInt(element.popup.element.style.top) + parseInt(element.popup.element.style.marginTop); 140 top = parseInt(element.popup.element.style.top) + parseInt(element.popup.element.style.marginTop);
141 bottom = top + parseInt(element.popup.element.offsetHeight); 141 bottom = top + parseInt(element.popup.element.offsetHeight);
142 //Checking click position in relation to limits 142 //Checking click position in relation to limits
143 if ((e._event.clientX < left || e._event.clientX > right) || (e._event.clientY < top || e._event.clientY > bottom)) { 143 if ((e._event.clientX < left || e._event.clientX > right) || (e._event.clientY < top || e._event.clientY > bottom)) {
144 //Hides popups since click is outside limits 144 //Hides popups since click is outside limits
145 return false; 145 return false;
146 } else { 146 } else {
147 //Keeps popup open since click inside area 147 //Keeps popup open since click inside area
148 return true; 148 return true;
149 } 149 }
150 } else { 150 } else {
151 //Hides popups since element not detected 151 //Hides popups since element not detected
152 return false; 152 return false;
153 } 153 }
154 } 154 }
155 }, 155 },
156 //////////////////////////////////////////////////////////////////// 156 ////////////////////////////////////////////////////////////////////
157 // 157 //
158 _popupBase: { 158 _popupBase: {
159 value: null 159 value: null
160 }, 160 },
161 //////////////////////////////////////////////////////////////////// 161 ////////////////////////////////////////////