diff options
author | Valerio Virgillito | 2012-06-20 11:10:58 -0700 |
---|---|---|
committer | Valerio Virgillito | 2012-06-20 11:10:58 -0700 |
commit | 4fb904eb5660cac28e2085d4aedce8fa249339b5 (patch) | |
tree | 5dbae52e9961fa870c5ea15f97511572f209f9d2 /js/panels/color | |
parent | fcb6309915161d16a74a4385b905742f35b7d62d (diff) | |
parent | aad41becbc41882abf1558c6b5aa38db6a9e99c8 (diff) | |
download | ninja-4fb904eb5660cac28e2085d4aedce8fa249339b5.tar.gz |
Merge pull request #312 from joseeight/Color
Fixing logic to close color panel popup
Diffstat (limited to 'js/panels/color')
-rwxr-xr-x | js/panels/color/colorpopup-manager.js | 56 |
1 files changed, 17 insertions, 39 deletions
diff --git a/js/panels/color/colorpopup-manager.js b/js/panels/color/colorpopup-manager.js index 529ec1c8..4667f2b4 100755 --- a/js/panels/color/colorpopup-manager.js +++ b/js/panels/color/colorpopup-manager.js | |||
@@ -29,49 +29,27 @@ exports.ColorPopupManager = Montage.create(Component, { | |||
29 | enumerable: false, | 29 | enumerable: false, |
30 | value: function () { | 30 | value: function () { |
31 | //////////////////////////////////////////////////////////// | 31 | //////////////////////////////////////////////////////////// |
32 | //TODO: Improve logic on handling closing the popup | 32 | //Closing popups on resize |
33 | //////////////////////////////////////////////////////////// | ||
34 | //Hiding popup on any panel(s) actions | ||
35 | this.eventManager.addEventListener("panelOrderChanged", function (e) { | ||
36 | this.application.ninja.colorController.colorPopupManager.hideColorPopup(); | ||
37 | }.bind(this)); | ||
38 | // | ||
39 | this.eventManager.addEventListener("panelClose", function (e) { | ||
40 | this.application.ninja.colorController.colorPopupManager.hideColorPopup(); | ||
41 | }.bind(this)); | ||
42 | // | ||
43 | this.eventManager.addEventListener("panelCollapsed", function (e) { | ||
44 | this.application.ninja.colorController.colorPopupManager.hideColorPopup(); | ||
45 | }.bind(this)); | ||
46 | // | ||
47 | this.eventManager.addEventListener("panelSelected", function (e) { | ||
48 | this.application.ninja.colorController.colorPopupManager.hideColorPopup(); | ||
49 | }.bind(this)); | ||
50 | // | ||
51 | this.eventManager.addEventListener("togglePanel", function (e) { | ||
52 | this.application.ninja.colorController.colorPopupManager.hideColorPopup(); | ||
53 | }.bind(this)); | ||
54 | // | ||
55 | this.eventManager.addEventListener("panelResizing", function (e) { | ||
56 | this.application.ninja.colorController.colorPopupManager.hideColorPopup(); | ||
57 | }.bind(this)); | ||
58 | // | ||
59 | this.eventManager.addEventListener("panelResizedStart", function (e) { | ||
60 | this.application.ninja.colorController.colorPopupManager.hideColorPopup(); | ||
61 | }.bind(this)); | ||
62 | // | ||
63 | this.eventManager.addEventListener("panelResizedEnd", function (e) { | ||
64 | this.application.ninja.colorController.colorPopupManager.hideColorPopup(); | ||
65 | }.bind(this)); | ||
66 | // | ||
67 | window.addEventListener('resize', function (e) { | 33 | window.addEventListener('resize', function (e) { |
68 | this.application.ninja.colorController.colorPopupManager.hideColorPopup(); | 34 | this.application.ninja.colorController.colorPopupManager.hideColorPopup(); |
69 | }.bind(this)); | 35 | }.bind(this)); |
70 | // | 36 | //Storing limits of popup |
37 | var top, bottom, left, right; | ||
38 | //Closing popups if outside limits | ||
71 | document.addEventListener('mousedown', function (e) { | 39 | document.addEventListener('mousedown', function (e) { |
72 | // | 40 | //Checking for popup to be opened otherwise nothing happens |
73 | if (e._event.srcElement.getAttribute('data-montage-id') === 'stageCanvas' || e._event.srcElement.id === 'mainContainer' || e._event.srcElement.getAttribute('data-montage-id') === 'drawingCanvas') { | 41 | if (this._popupPanel.opened && this._popupPanel.popup && this._popupPanel.popup.element && !e._event.srcElement.inputType) { |
74 | this.application.ninja.colorController.colorPopupManager.hideColorPopup(); | 42 | //Getting horizontal limits |
43 | left = parseInt(this._popupPanel.popup.element.style.left) + parseInt(this._popupPanel.popup.element.style.marginLeft); | ||
44 | right = left + parseInt(this._popupPanel.popup.element.offsetWidth); | ||
45 | //Getting vertical limits | ||
46 | top = parseInt(this._popupPanel.popup.element.style.top) + parseInt(this._popupPanel.popup.element.style.marginTop); | ||
47 | bottom = left + parseInt(this._popupPanel.popup.element.offsetHeight); | ||
48 | //Checking click position in relation to limits | ||
49 | if ((e._event.clientX < left || e._event.clientX > right) || (e._event.clientY < top || e._event.clientY > bottom)) { | ||
50 | //Hides popups since click is outside limits | ||
51 | this.application.ninja.colorController.colorPopupManager.hideColorPopup(); | ||
52 | } | ||
75 | } | 53 | } |
76 | }.bind(this)); | 54 | }.bind(this)); |
77 | //////////////////////////////////////////////////////////// | 55 | //////////////////////////////////////////////////////////// |