diff options
Diffstat (limited to 'js')
-rwxr-xr-x | js/panels/color/colorpopup-manager.js | 199 |
1 files changed, 77 insertions, 122 deletions
diff --git a/js/panels/color/colorpopup-manager.js b/js/panels/color/colorpopup-manager.js index 15d55787..cf6fd7ac 100755 --- a/js/panels/color/colorpopup-manager.js +++ b/js/panels/color/colorpopup-manager.js | |||
@@ -20,52 +20,87 @@ exports.ColorPopupManager = Montage.create(Component, { | |||
20 | }, | 20 | }, |
21 | //////////////////////////////////////////////////////////////////// | 21 | //////////////////////////////////////////////////////////////////// |
22 | // | 22 | // |
23 | _hasInit: { | 23 | _hasCloseEvents: { |
24 | value: false | 24 | value: false |
25 | }, | 25 | }, |
26 | //////////////////////////////////////////////////////////////////// | 26 | //////////////////////////////////////////////////////////////////// |
27 | // | 27 | // |
28 | init: { | 28 | addCloseEvents: { |
29 | value: function () { | 29 | value: function () { |
30 | // | ||
31 | this._hasCloseEvents = true; | ||
30 | //////////////////////////////////////////////////////////// | 32 | //////////////////////////////////////////////////////////// |
31 | //Closing popups on resize | 33 | //Closing popups on resize |
32 | window.addEventListener('resize', function (e) { | 34 | window.addEventListener('resize', this, false); |
33 | this.application.ninja.colorController.colorPopupManager.hideColorPopup(); | ||
34 | }.bind(this)); | ||
35 | //Closing popups if outside limits | 35 | //Closing popups if outside limits |
36 | document.addEventListener('mousedown', function (e) { | 36 | document.addEventListener('mousedown', this, false); |
37 | // | ||
38 | if (this._popupBase && !this._popupChipBase && !this._popupGradientChipBase) { | ||
39 | if(!this.popupHitCheck(this._popupBase, e)) { | ||
40 | this.hideColorPopup(); | ||
41 | } | ||
42 | } else if (!this._popupBase && this._popupChipBase && !this._popupGradientChipBase) { | ||
43 | if(!this.popupHitCheck(this._popupChipBase, e)) { | ||
44 | this.hideColorChipPopup(); | ||
45 | } | ||
46 | } else if (this._popupBase && this._popupChipBase && !this._popupGradientChipBase) { | ||
47 | if(!this.popupHitCheck(this._popupBase, e) && !this.popupHitCheck(this._popupChipBase, e)) { | ||
48 | this.hideColorPopup(); | ||
49 | } | ||
50 | } else if (this._popupBase && this._popupChipBase && this._popupGradientChipBase) { | ||
51 | if(!this.popupHitCheck(this._popupBase, e) && !this.popupHitCheck(this._popupChipBase, e) && !this.popupHitCheck(this._popupGradientChipBase, e)) { | ||
52 | this.hideColorPopup(); | ||
53 | } | ||
54 | } else if (!this._popupBase && this._popupChipBase && this._popupGradientChipBase) { | ||
55 | if(!this.popupHitCheck(this._popupChipBase, e) && !this.popupHitCheck(this._popupGradientChipBase, e)) { | ||
56 | this.hideColorChipPopup(); | ||
57 | } | ||
58 | } else if (this._popupBase && !this._popupChipBase && this._popupGradientChipBase) { | ||
59 | if(!this.popupHitCheck(this._popupBase, e) && !this.popupHitCheck(this._popupGradientChipBase, e)) { | ||
60 | this.hideColorPopup(); | ||
61 | } | ||
62 | } | ||
63 | }.bind(this)); | ||
64 | //////////////////////////////////////////////////////////// | 37 | //////////////////////////////////////////////////////////// |
65 | } | 38 | } |
66 | }, | 39 | }, |
67 | //////////////////////////////////////////////////////////////////// | 40 | //////////////////////////////////////////////////////////////////// |
68 | // | 41 | // |
42 | removeCloseEvents: { | ||
43 | value: function () { | ||
44 | // | ||
45 | this._hasCloseEvents = false; | ||
46 | //////////////////////////////////////////////////////////// | ||
47 | //Closing popups on resize | ||
48 | window.removeEventListener('resize', this, false); | ||
49 | //Closing popups if outside limits | ||
50 | document.removeEventListener('mousedown', this, false); | ||
51 | //////////////////////////////////////////////////////////// | ||
52 | } | ||
53 | }, | ||
54 | //////////////////////////////////////////////////////////////////// | ||
55 | // | ||
56 | handleMousedown: { | ||
57 | value: function (e) { | ||
58 | // | ||
59 | this.closeAllPopups(e); | ||
60 | } | ||
61 | }, | ||
62 | //////////////////////////////////////////////////////////////////// | ||
63 | // | ||
64 | handleResize: { | ||
65 | value: function (e) { | ||
66 | // | ||
67 | this.hideColorPopup(); | ||
68 | } | ||
69 | }, | ||
70 | //////////////////////////////////////////////////////////////////// | ||
71 | // | ||
72 | closeAllPopups: { | ||
73 | value: function (e) { | ||
74 | // | ||
75 | if (this._popupBase && !this._popupChipBase && !this._popupGradientChipBase) { | ||
76 | if(!this.popupHitCheck(this._popupBase, e)) { | ||
77 | this.hideColorPopup(); | ||
78 | } | ||
79 | } else if (!this._popupBase && this._popupChipBase && !this._popupGradientChipBase) { | ||
80 | if(!this.popupHitCheck(this._popupChipBase, e)) { | ||
81 | this.hideColorChipPopup(); | ||
82 | } | ||
83 | } else if (this._popupBase && this._popupChipBase && !this._popupGradientChipBase) { | ||
84 | if(!this.popupHitCheck(this._popupBase, e) && !this.popupHitCheck(this._popupChipBase, e)) { | ||
85 | this.hideColorPopup(); | ||
86 | } | ||
87 | } else if (this._popupBase && this._popupChipBase && this._popupGradientChipBase) { | ||
88 | if(!this.popupHitCheck(this._popupBase, e) && !this.popupHitCheck(this._popupChipBase, e) && !this.popupHitCheck(this._popupGradientChipBase, e)) { | ||
89 | this.hideColorPopup(); | ||
90 | } | ||
91 | } else if (!this._popupBase && this._popupChipBase && this._popupGradientChipBase) { | ||
92 | if(!this.popupHitCheck(this._popupChipBase, e) && !this.popupHitCheck(this._popupGradientChipBase, e)) { | ||
93 | this.hideColorChipPopup(); | ||
94 | } | ||
95 | } else if (this._popupBase && !this._popupChipBase && this._popupGradientChipBase) { | ||
96 | if(!this.popupHitCheck(this._popupBase, e) && !this.popupHitCheck(this._popupGradientChipBase, e)) { | ||
97 | this.hideColorPopup(); | ||
98 | } | ||
99 | } | ||
100 | } | ||
101 | }, | ||
102 | //////////////////////////////////////////////////////////////////// | ||
103 | // | ||
69 | popupHitCheck: { | 104 | popupHitCheck: { |
70 | value: function (element, e) { | 105 | value: function (element, e) { |
71 | //Prevent any action for button to handle toggling | 106 | //Prevent any action for button to handle toggling |
@@ -161,9 +196,8 @@ exports.ColorPopupManager = Montage.create(Component, { | |||
161 | this._colorPopupDrawing = true; | 196 | this._colorPopupDrawing = true; |
162 | //////////////////////////////////////////////////// | 197 | //////////////////////////////////////////////////// |
163 | //Initializing events | 198 | //Initializing events |
164 | if (!this._hasinit) { | 199 | if (!this._hasCloseEvents) { |
165 | this.init(); | 200 | this.addCloseEvents(); |
166 | this._hasinit = true; | ||
167 | } | 201 | } |
168 | //////////////////////////////////////////////////// | 202 | //////////////////////////////////////////////////// |
169 | //Creating popup | 203 | //Creating popup |
@@ -191,6 +225,7 @@ exports.ColorPopupManager = Montage.create(Component, { | |||
191 | // | 225 | // |
192 | this._popupBase.popup.removeEventListener('didDraw', this, false); | 226 | this._popupBase.popup.removeEventListener('didDraw', this, false); |
193 | // | 227 | // |
228 | this.removeCloseEvents(); | ||
194 | this.hideColorChipPopup(); | 229 | this.hideColorChipPopup(); |
195 | this.hideGradientChipPopup(); | 230 | this.hideGradientChipPopup(); |
196 | //Making sure to return color manager to either stroke or fill (might be a Hack for now) | 231 | //Making sure to return color manager to either stroke or fill (might be a Hack for now) |
@@ -313,9 +348,8 @@ exports.ColorPopupManager = Montage.create(Component, { | |||
313 | this._colorChipPopupDrawing = true; | 348 | this._colorChipPopupDrawing = true; |
314 | //////////////////////////////////////////////////// | 349 | //////////////////////////////////////////////////// |
315 | //Initializing events | 350 | //Initializing events |
316 | if (!this._hasinit) { | 351 | if (!this._hasCloseEvents) { |
317 | this.init(); | 352 | this.addCloseEvents(); |
318 | this._hasinit = true; | ||
319 | } | 353 | } |
320 | //////////////////////////////////////////////////// | 354 | //////////////////////////////////////////////////// |
321 | //Creating popup | 355 | //Creating popup |
@@ -358,6 +392,7 @@ exports.ColorPopupManager = Montage.create(Component, { | |||
358 | // | 392 | // |
359 | if (this._popupChipBase && this._popupChipBase.opened) { | 393 | if (this._popupChipBase && this._popupChipBase.opened) { |
360 | // | 394 | // |
395 | this.removeCloseEvents(); | ||
361 | this.hideGradientChipPopup(); | 396 | this.hideGradientChipPopup(); |
362 | // | 397 | // |
363 | this._popupChipBase.popup.removeEventListener('didDraw', this, false); | 398 | this._popupChipBase.popup.removeEventListener('didDraw', this, false); |
@@ -392,9 +427,8 @@ exports.ColorPopupManager = Montage.create(Component, { | |||
392 | this._colorGradientPopupDrawing = true; | 427 | this._colorGradientPopupDrawing = true; |
393 | //////////////////////////////////////////////////// | 428 | //////////////////////////////////////////////////// |
394 | //Initializing events | 429 | //Initializing events |
395 | if (!this._hasinit) { | 430 | if (!this._hasCloseEvents) { |
396 | this.init(); | 431 | this.addCloseEvents(); |
397 | this._hasinit = true; | ||
398 | } | 432 | } |
399 | //////////////////////////////////////////////////// | 433 | //////////////////////////////////////////////////// |
400 | //Creating popup | 434 | //Creating popup |
@@ -519,85 +553,6 @@ exports.ColorPopupManager = Montage.create(Component, { | |||
519 | } | 553 | } |
520 | } | 554 | } |
521 | } | 555 | } |
522 | |||
523 | |||
524 | |||
525 | |||
526 | |||
527 | |||
528 | |||
529 | |||
530 | |||
531 | |||
532 | |||
533 | |||
534 | |||
535 | |||
536 | |||
537 | |||
538 | |||
539 | |||
540 | |||
541 | |||
542 | |||
543 | |||
544 | |||
545 | /* |