diff options
author | Nivesh Rajbhandari | 2012-07-02 09:23:13 -0700 |
---|---|---|
committer | Nivesh Rajbhandari | 2012-07-02 09:23:13 -0700 |
commit | 2bae1b3148233288ec0bc50876935bdfea1f288c (patch) | |
tree | 686fa3b5b9615941bb7013f35c91e8f326b049db /js/panels/color/colorpanelbase.reel | |
parent | 2da05a4c71bfe9b136384d9e94fbfbef19f24550 (diff) | |
parent | 12de4e49a309e210c13eb40b2ffa158ef2eb54a7 (diff) | |
download | ninja-2bae1b3148233288ec0bc50876935bdfea1f288c.tar.gz |
Merge branch 'refs/heads/ninja-internal' into MaterialsUI
Diffstat (limited to 'js/panels/color/colorpanelbase.reel')
-rwxr-xr-x | js/panels/color/colorpanelbase.reel/colorpanelbase.js | 97 |
1 files changed, 47 insertions, 50 deletions
diff --git a/js/panels/color/colorpanelbase.reel/colorpanelbase.js b/js/panels/color/colorpanelbase.reel/colorpanelbase.js index 26d4932f..5ac93dbc 100755 --- a/js/panels/color/colorpanelbase.reel/colorpanelbase.js +++ b/js/panels/color/colorpanelbase.reel/colorpanelbase.js | |||
@@ -170,7 +170,7 @@ exports.ColorPanelBase = Montage.create(Component, { | |||
170 | this.addButton('current', this.btnCurrent); | 170 | this.addButton('current', this.btnCurrent); |
171 | this.addButton('previous', this.btnPrevious); | 171 | this.addButton('previous', this.btnPrevious); |
172 | // | 172 | // |
173 | this.addButton('hexinput', this.hextext); | 173 | this.addButton('hexinput', this.hextext, this.colorManager); |
174 | this.addButton('reset', this.btnDefault); | 174 | this.addButton('reset', this.btnDefault); |
175 | this.addButton('nocolor', this.btnNoColor); | 175 | this.addButton('nocolor', this.btnNoColor); |
176 | this.addButton('swap', this.btnSwap); | 176 | this.addButton('swap', this.btnSwap); |
@@ -260,7 +260,7 @@ exports.ColorPanelBase = Montage.create(Component, { | |||
260 | return; | 260 | return; |
261 | } | 261 | } |
262 | //Checking for event mode to be color change (NOT PANEL MODE RELATED) | 262 | //Checking for event mode to be color change (NOT PANEL MODE RELATED) |
263 | if (e._event.mode === 'hsv' || e._event.mode === 'hsl' || e._event.mode === 'rgb' || e._event.mode === 'hex' || e._event.mode === 'nocolor' || e._event.mode === 'gradient') { | 263 | if (e._event.mode === 'hsv' || e._event.mode === 'hsl' || e._event.mode === 'rgb' || e._event.mode === 'hex' || e._event.mode === 'nocolor' || e._event.mode === 'gradient' || e._event.mode === 'alpha') { |
264 | //Checking for panel color mode (RGB or HSL) to assign correct slider values | 264 | //Checking for panel color mode (RGB or HSL) to assign correct slider values |
265 | if (this.panelMode === 'rgb' && e._event.rgba) { | 265 | if (this.panelMode === 'rgb' && e._event.rgba) { |
266 | this._combo[0].slider.value = e._event.rgba.r; | 266 | this._combo[0].slider.value = e._event.rgba.r; |
@@ -461,7 +461,7 @@ exports.ColorPanelBase = Montage.create(Component, { | |||
461 | //////////////////////////////////////////////////////////////////// | 461 | //////////////////////////////////////////////////////////////////// |
462 | // | 462 | // |
463 | addButton: { | 463 | addButton: { |
464 | value: function (type, button) { | 464 | value: function (type, button, manager) { |
465 | // | 465 | // |
466 | switch (type.toLocaleLowerCase()) { | 466 | switch (type.toLocaleLowerCase()) { |
467 | case 'chip': | 467 | case 'chip': |
@@ -480,7 +480,13 @@ exports.ColorPanelBase = Montage.create(Component, { | |||
480 | } | 480 | } |
481 | if (c && c.css) { | 481 | if (c && c.css) { |
482 | this.ctx.clearRect(0, 0, this.cvs.width, this.cvs.height); | 482 | this.ctx.clearRect(0, 0, this.cvs.width, this.cvs.height); |
483 | this.style.backgroundColor = c.css; | 483 | if (m === 'gradient') { |
484 | this.style.backgroundImage = c.css; | ||
485 | this.style.backgroundColor = 'transparent'; | ||
486 | } else { | ||
487 | this.style.backgroundColor = c.css; | ||
488 | this.style.backgroundImage = 'none'; | ||
489 | } | ||
484 | } else { | 490 | } else { |
485 | this.drawNoColor(this, this.cvs); | 491 | this.drawNoColor(this, this.cvs); |
486 | } | 492 | } |
@@ -673,8 +679,8 @@ exports.ColorPanelBase = Montage.create(Component, { | |||
673 | case 'hexinput': | 679 | case 'hexinput': |
674 | var hexinp = HotText.create(); | 680 | var hexinp = HotText.create(); |
675 | hexinp.element = button; | 681 | hexinp.element = button; |
676 | hexinp.labelFunction = this._updateHexValue.bind(this); | 682 | hexinp.labelFunction = this._updateHexValue.bind(manager); |
677 | hexinp.inputFunction = this._hottextHexInput.bind(this); | 683 | hexinp.inputFunction = this._hottextHexInput.bind(manager); |
678 | hexinp.needsDraw = true; | 684 | hexinp.needsDraw = true; |
679 | this._buttons.hexinput.push(hexinp); | 685 | this._buttons.hexinput.push(hexinp); |
680 | return hexinp; | 686 | return hexinp; |
@@ -976,58 +982,45 @@ exports.ColorPanelBase = Montage.create(Component, { | |||
976 | _updateValueFromSH: { | 982 | _updateValueFromSH: { |
977 | value: function (e) { | 983 | value: function (e) { |
978 | // | 984 | // |
979 | var update; | 985 | var update, type; |
980 | // | 986 | // |
981 | if (!e._event.wasSetByCode) { | 987 | if (!e._event.wasSetByCode) { |
988 | // | ||
989 | if (!e.target.cInputType) { | ||
990 | type = 'hottext'; | ||
991 | } else { | ||
992 | type = 'slider' | ||
993 | } | ||
994 | // | ||
982 | if (e.target.changesColor) { | 995 | if (e.target.changesColor) { |
983 | // | 996 | // |
984 | //this.application.ninja.colorController.colorPopupManager.hideColorPopup(); | ||
985 | // | ||
986 | if (this.panelMode === 'rgb') { | 997 | if (this.panelMode === 'rgb') { |
987 | if (e.target.cInputType === 'slider') { | 998 | // |
988 | // | 999 | if (this.colorManager.rgb && Math.round(this._combo[0][type].value) === this.colorManager.rgb.r && Math.round(this._combo[1][type].value) === this.colorManager.rgb.g && Math.round(this._combo[2][type].value) === this.colorManager.rgb.b) { |
989 | if (this.colorManager.rgb && Math.round(this._combo[0].slider.value) === this.colorManager.rgb.r && Math.round(this._combo[1].slider.value) === this.colorManager.rgb.g && Math.round(this._combo[2].slider.value) === this.colorManager.rgb.b) { | 1000 | return; |
990 | return; | ||
991 | } | ||
992 | // | ||
993 | update = { r: Math.round(this._combo[0].slider.value), g: Math.round(this._combo[1].slider.value), b: Math.round(this._combo[2].slider.value) }; | ||
994 | } else { | ||
995 | // | ||
996 | if (this.colorManager.rgb && Math.round(this._combo[0].hottext.value) === this.colorManager.rgb.r && Math.round(this._combo[1].hottext.value) === this.colorManager.rgb.g && Math.round(this._combo[2].hottext.value) === this.colorManager.rgb.b) { | ||
997 | return; | ||
998 | } | ||
999 | // | ||
1000 | update = { r: Math.round(this._combo[0].hottext.value), g: Math.round(this._combo[1].hottext.value), b: Math.round(this._combo[2].hottext.value) }; | ||
1001 | } | 1001 | } |
1002 | // | ||
1003 | update = { r: Math.round(this._combo[0][type].value), g: Math.round(this._combo[1][type].value), b: Math.round(this._combo[2][type].value) }; | ||
1004 | // | ||
1002 | update.wasSetByCode = false; | 1005 | update.wasSetByCode = false; |
1003 | update.type = 'change'; | 1006 | update.type = 'change'; |
1004 | this.colorManager.rgb = update; | 1007 | this.colorManager.rgb = update; |
1005 | } else if (this.panelMode === 'hsl') { | 1008 | } else if (this.panelMode === 'hsl') { |
1006 | if (e.target.cInputType === 'slider') { | 1009 | // |
1007 | // | 1010 | if (this.colorManager.hsl && Math.round(this._combo[0][type].value) === this.colorManager.hsl.h && Math.round(this._combo[1][type].value) === this.colorManager.hsl.s && Math.round(this._combo[2][type].value) === this.colorManager.hsl.l) { |
1008 | if (this.colorManager.hsl && Math.round(this._combo[0].slider.value) === this.colorManager.hsl.h && Math.round(this._combo[1].slider.value) === this.colorManager.hsl.s && Math.round(this._combo[2].slider.value) === this.colorManager.hsl.l) { | 1011 | return; |
1009 | return; | ||
1010 | } | ||
1011 | // | ||
1012 | update = { h: Math.round(this._combo[0].slider.value), s: Math.round(this._combo[1].slider.value), l: Math.round(this._combo[2].slider.value) }; | ||
1013 | } else { | ||
1014 | // | ||
1015 | if (this.colorManager.hsl && Math.round(this._combo[0].hottext.value) === this.colorManager.hsl.h && Math.round(this._combo[1].hottext.value) === this.colorManager.hsl.s && Math.round(this._combo[2].hottext.value) === this.colorManager.hsl.l) { | ||
1016 | return; | ||
1017 | } | ||
1018 | // | ||
1019 | update = { h: Math.round(this._combo[0].hottext.value), s: Math.round(this._combo[1].hottext.value), l: Math.round(this._combo[2].hottext.value) }; | ||
1020 | } | 1012 | } |
1013 | // | ||
1014 | update = { h: Math.round(this._combo[0][type].value), s: Math.round(this._combo[1][type].value), l: Math.round(this._combo[2][type].value) }; | ||
1015 | // | ||
1021 | update.wasSetByCode = false; | 1016 | update.wasSetByCode = false; |
1022 | update.type = 'change'; | 1017 | update.type = 'change'; |
1023 | this.colorManager.hsl = update; | 1018 | this.colorManager.hsl = update; |
1024 | } | 1019 | } |
1025 | } else { | 1020 | } else { |
1026 | if (e.target.cInputType === 'slider') { | 1021 | // |
1027 | update = { value: this._combo[3].slider.value / 100, wasSetByCode: false, type: 'change' }; | 1022 | update = { value: this._combo[3][type].value/100, wasSetByCode: false, type: 'change' }; |
1028 | } else { | 1023 | // |
1029 | update = { value: this._combo[3].hottext.value / 100, wasSetByCode: false, type: 'change' }; | ||
1030 | } | ||
1031 | this.colorManager.alpha = update; | 1024 | this.colorManager.alpha = update; |
1032 | } | 1025 | } |
1033 | } | 1026 | } |
@@ -1244,23 +1237,23 @@ exports.ColorPanelBase = Montage.create(Component, { | |||
1244 | } | 1237 | } |
1245 | //Checking for panel mode and converting the color to the panel mode | 1238 | //Checking for panel mode and converting the color to the panel mode |
1246 | if (this._panelMode === 'hsl') { | 1239 | if (this._panelMode === 'hsl') { |
1247 | rgb = this.colorManager.hexToRgb(color); | 1240 | rgb = this.hexToRgb(color); |
1248 | if (rgb) { | 1241 | if (rgb) { |
1249 | update = this.colorManager.rgbToHsl(rgb.r, rgb.g, rgb.b); | 1242 | update = this.rgbToHsl(rgb.r, rgb.g, rgb.b); |
1250 | update.wasSetByCode = false; | 1243 | update.wasSetByCode = false; |
1251 | update.type = 'change'; | 1244 | update.type = 'change'; |
1252 | this.colorManager.hsl = update; | 1245 | this.hsl = update; |
1253 | } else { | 1246 | } else { |
1254 | this.colorManager.applyNoColor(false); | 1247 | this.applyNoColor(false); |
1255 | } | 1248 | } |
1256 | } else { | 1249 | } else { |
1257 | update = this.colorManager.hexToRgb(color); | 1250 | update = this.hexToRgb(color); |
1258 | if (update) { | 1251 | if (update) { |
1259 | update.wasSetByCode = false; | 1252 | update.wasSetByCode = false; |
1260 | update.type = 'change'; | 1253 | update.type = 'change'; |
1261 | this.colorManager.rgb = update; | 1254 | this.rgb = update; |
1262 | } else { | 1255 | } else { |
1263 | this.colorManager.applyNoColor(false); | 1256 | this.applyNoColor(false); |
1264 | } | 1257 | } |
1265 | } | 1258 | } |
1266 | } |