diff options
Diffstat (limited to 'js/panels/color/colorpopup-manager.js')
-rwxr-xr-x | js/panels/color/colorpopup-manager.js | 51 |
1 files changed, 26 insertions, 25 deletions
diff --git a/js/panels/color/colorpopup-manager.js b/js/panels/color/colorpopup-manager.js index 7daf0e97..f243fad2 100755 --- a/js/panels/color/colorpopup-manager.js +++ b/js/panels/color/colorpopup-manager.js | |||
@@ -1,24 +1,25 @@ | |||
1 | /* <copyright> | 1 | /* <copyright> |
2 | Copyright (c) 2012, Motorola Mobility, Inc | 2 | Copyright (c) 2012, Motorola Mobility LLC. |
3 | All Rights Reserved. | 3 | All Rights Reserved. |
4 | BSD License. | ||
5 | 4 | ||
6 | Redistribution and use in source and binary forms, with or without | 5 | Redistribution and use in source and binary forms, with or without |
7 | modification, are permitted provided that the following conditions are met: | 6 | modification, are permitted provided that the following conditions are met: |
8 | 7 | ||
9 | - Redistributions of source code must retain the above copyright notice, | 8 | * Redistributions of source code must retain the above copyright notice, |
10 | this list of conditions and the following disclaimer. | 9 | this list of conditions and the following disclaimer. |
11 | - Redistributions in binary form must reproduce the above copyright | 10 | |
12 | notice, this list of conditions and the following disclaimer in the | 11 | * Redistributions in binary form must reproduce the above copyright notice, |
13 | documentation and/or other materials provided with the distribution. | 12 | this list of conditions and the following disclaimer in the documentation |
14 | - Neither the name of Motorola Mobility nor the names of its contributors | 13 | and/or other materials provided with the distribution. |
15 | may be used to endorse or promote products derived from this software | 14 | |
16 | without specific prior written permission. | 15 | * Neither the name of Motorola Mobility LLC nor the names of its |
16 | contributors may be used to endorse or promote products derived from this | ||
17 | software without specific prior written permission. | ||
17 | 18 | ||
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 20 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 21 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
21 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | 22 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
22 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 23 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
@@ -27,7 +28,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |||
27 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 28 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
28 | POSSIBILITY OF SUCH DAMAGE. | 29 | POSSIBILITY OF SUCH DAMAGE. |
29 | </copyright> */ | 30 | </copyright> */ |
30 | 31 | ||
31 | //////////////////////////////////////////////////////////////////////// | 32 | //////////////////////////////////////////////////////////////////////// |
32 | // | 33 | // |
33 | var Montage = require("montage/core/core").Montage, | 34 | var Montage = require("montage/core/core").Montage, |
@@ -45,7 +46,7 @@ exports.ColorPopupManager = Montage.create(Component, { | |||
45 | //////////////////////////////////////////////////////////////////// | 46 | //////////////////////////////////////////////////////////////////// |
46 | // | 47 | // |
47 | _hasCloseEvents: { | 48 | _hasCloseEvents: { |
48 | value: false | 49 | value: false |
49 | }, | 50 | }, |
50 | //////////////////////////////////////////////////////////////////// | 51 | //////////////////////////////////////////////////////////////////// |
51 | // | 52 | // |
@@ -81,7 +82,7 @@ exports.ColorPopupManager = Montage.create(Component, { | |||
81 | value: function (e) { | 82 | value: function (e) { |
82 | // | 83 | // |
83 | this.closeAllPopups(e); | 84 | this.closeAllPopups(e); |
84 | } | 85 | } |
85 | }, | 86 | }, |
86 | //////////////////////////////////////////////////////////////////// | 87 | //////////////////////////////////////////////////////////////////// |
87 | // | 88 | // |
@@ -89,7 +90,7 @@ exports.ColorPopupManager = Montage.create(Component, { | |||
89 | value: function (e) { | 90 | value: function (e) { |
90 | // | 91 | // |
91 | this.hideColorPopup(); | 92 | this.hideColorPopup(); |
92 | } | 93 | } |
93 | }, | 94 | }, |
94 | //////////////////////////////////////////////////////////////////// | 95 | //////////////////////////////////////////////////////////////////// |
95 | // | 96 | // |
@@ -121,7 +122,7 @@ exports.ColorPopupManager = Montage.create(Component, { | |||
121 | this.hideColorPopup(); | 122 | this.hideColorPopup(); |
122 | } | 123 | } |
123 | } | 124 | } |
124 | } | 125 | } |
125 | }, | 126 | }, |
126 | //////////////////////////////////////////////////////////////////// | 127 | //////////////////////////////////////////////////////////////////// |
127 | // | 128 | // |
@@ -129,11 +130,11 @@ exports.ColorPopupManager = Montage.create(Component, { | |||
129 | value: function (element, e) { | 130 | value: function (element, e) { |
130 | //Prevent any action for button to handle toggling | 131 | //Prevent any action for button to handle toggling |
131 | if (e._event.target.inputType || e._event.target.colorMode) return true; | 132 | if (e._event.target.inputType || e._event.target.colorMode) return true; |
132 | //Storing limits of popup | 133 | //Storing limits of popup |
133 | var top, bottom, left, right; | 134 | var top, bottom, left, right; |
134 | //Checking for popup to be opened otherwise nothing happens | 135 | //Checking for popup to be opened otherwise nothing happens |
135 | if (element && element.opened && element.popup && element.popup.element) { | 136 | if (element && element.opened && element.popup && element.popup.element) { |
136 | //Getting horizontal limits | 137 | //Getting horizontal limits |
137 | left = parseInt(element.popup.element.style.left) + parseInt(element.popup.element.style.marginLeft); | 138 | left = parseInt(element.popup.element.style.left) + parseInt(element.popup.element.style.marginLeft); |
138 | right = left + parseInt(element.popup.element.offsetWidth); | 139 | right = left + parseInt(element.popup.element.offsetWidth); |
139 | //Getting vertical limits | 140 | //Getting vertical limits |
@@ -151,7 +152,7 @@ exports.ColorPopupManager = Montage.create(Component, { | |||
151 | //Hides popups since element not detected | 152 | //Hides popups since element not detected |
152 | return false; | 153 | return false; |
153 | } | 154 | } |
154 | } | 155 | } |
155 | }, | 156 | }, |
156 | //////////////////////////////////////////////////////////////////// | 157 | //////////////////////////////////////////////////////////////////// |
157 | // | 158 | // |
@@ -239,7 +240,7 @@ exports.ColorPopupManager = Montage.create(Component, { | |||
239 | // | 240 | // |
240 | this._popupBase.needsDraw = true; | 241 | this._popupBase.needsDraw = true; |
241 | this._popupBase.addEventListener('firstDraw', this, false); | 242 | this._popupBase.addEventListener('firstDraw', this, false); |
242 | } | 243 | } |
243 | } | 244 | } |
244 | }, | 245 | }, |
245 | //////////////////////////////////////////////////////////////////// | 246 | //////////////////////////////////////////////////////////////////// |
@@ -648,11 +649,11 @@ exports.ColorPopupManager = Montage.create(Component, { | |||
648 | this._popupChipBase._components.hex.value = null; | 649 | this._popupChipBase._components.hex.value = null; |
649 | } else if (!isNaN(e._target._xStart) && !e._event.wasSetByCode) { | 650 | } else if (!isNaN(e._target._xStart) && !e._event.wasSetByCode) { |
650 | if (!isNaN(e._target._numValue)) { | 651 | if (!isNaN(e._target._numValue)) { |
651 | this._popupChipBase.colorManager.alpha = {value: e._target._numValue/100, type: 'change', wasSetByCode: false}; | 652 | this._popupChipBase.colorManager.alpha = {value: e._target._numValue/100, type: 'change', wasSetByCode: false}; |
652 | } | 653 | } |
653 | this.colorChipChange(e); | 654 | this.colorChipChange(e); |
654 | } else if (!e._event.wasSetByCode && (e._event.mode && e._event.mode === 'nocolor')) { | 655 | } else if (!e._event.wasSetByCode && (e._event.mode && e._event.mode === 'nocolor')) { |
655 | this.colorChipChange(e); | 656 | this.colorChipChange(e); |
656 | } else if (!e._event.wasSetByCode && (e._event.mode && e._event.mode === 'hex')) { | 657 | } else if (!e._event.wasSetByCode && (e._event.mode && e._event.mode === 'hex')) { |
657 | this.colorChipChange(e); | 658 | this.colorChipChange(e); |
658 | } | 659 | } |
@@ -668,7 +669,7 @@ exports.ColorPopupManager = Montage.create(Component, { | |||
668 | this._popupChipBase._components.hex.value = null; | 669 | this._popupChipBase._components.hex.value = null; |
669 | } else if (!isNaN(e._target._xStart) && !e._event.wasSetByCode) { | 670 | } else if (!isNaN(e._target._xStart) && !e._event.wasSetByCode) { |
670 | if (!isNaN(e._target._numValue)) { | 671 | if (!isNaN(e._target._numValue)) { |
671 | this._popupGradientChipBase.colorManager.alpha = {value: e._target._numValue/100, type: 'change', wasSetByCode: false}; | 672 | this._popupGradientChipBase.colorManager.alpha = {value: e._target._numValue/100, type: 'change', wasSetByCode: false}; |
672 | } | 673 | } |
673 | this.colorGradientChipChange(e); | 674 | this.colorGradientChipChange(e); |
674 | } else if (!e._event.wasSetByCode && (e._event.mode && e._event.mode === 'hex')) { | 675 | } else if (!e._event.wasSetByCode && (e._event.mode && e._event.mode === 'hex')) { |
@@ -677,7 +678,7 @@ exports.ColorPopupManager = Montage.create(Component, { | |||
677 | } else { | 678 | } else { |
678 | if (!isNaN(e._target._xStart) && !e._event.wasSetByCode) { | 679 | if (!isNaN(e._target._xStart) && !e._event.wasSetByCode) { |
679 | if (!isNaN(e._target._numValue)) { | 680 | if (!isNaN(e._target._numValue)) { |
680 | this._popupGradientChipBase.colorManager.alpha = {value: e._target._numValue/100, type: 'change', wasSetByCode: false}; | 681 | this._popupGradientChipBase.colorManager.alpha = {value: e._target._numValue/100, type: 'change', wasSetByCode: false}; |
681 | } | 682 | } |
682 | this.colorGradientChipChange(e); | 683 | this.colorGradientChipChange(e); |
683 | } else if (!e._event.wasSetByCode && (e._event.mode && e._event.mode === 'hex')) { | 684 | } else if (!e._event.wasSetByCode && (e._event.mode && e._event.mode === 'hex')) { |
@@ -716,7 +717,7 @@ exports.ColorPopupManager = Montage.create(Component, { | |||
716 | } | 717 | } |
717 | //Converting color to RGB to update buttons background colors (affecting only view) | 718 | //Converting color to RGB to update buttons background colors (affecting only view) |
718 | var color = this.colorManager.hsvToRgb(e._event.hsv.h/(Math.PI*2), e._event.hsv.s, e._event.hsv.v), i, input = this.colorManager.input; | 719 | var color = this.colorManager.hsvToRgb(e._event.hsv.h/(Math.PI*2), e._event.hsv.s, e._event.hsv.v), i, input = this.colorManager.input; |
719 | 720 | ||
720 | if (input === 'chip') { | 721 | if (input === 'chip') { |
721 | var ctx, cvs = this.application.ninja.colorController.colorView.currentChip.getElementsByTagName('canvas')[0]; | 722 | var ctx, cvs = this.application.ninja.colorController.colorView.currentChip.getElementsByTagName('canvas')[0]; |
722 | //if (cvs && color) { | 723 | //if (cvs && color) { |