aboutsummaryrefslogtreecommitdiff
path: root/js/panels
diff options
context:
space:
mode:
Diffstat (limited to 'js/panels')
-rwxr-xr-xjs/panels/color/colorpopup-manager.js71
1 files changed, 68 insertions, 3 deletions
diff --git a/js/panels/color/colorpopup-manager.js b/js/panels/color/colorpopup-manager.js
index fba196e4..bccfcebc 100755
--- a/js/panels/color/colorpopup-manager.js
+++ b/js/panels/color/colorpopup-manager.js
@@ -33,7 +33,6 @@ exports.ColorPopupManager = Montage.create(Component, {
33 window.addEventListener('resize', function (e) { 33 window.addEventListener('resize', function (e) {
34 this.application.ninja.colorController.colorPopupManager.hideColorPopup(); 34 this.application.ninja.colorController.colorPopupManager.hideColorPopup();
35 }.bind(this)); 35 }.bind(this));
36
37 //Closing popups if outside limits 36 //Closing popups if outside limits
38 document.addEventListener('mousedown', function (e) { 37 document.addEventListener('mousedown', function (e) {
39 // 38 //
@@ -58,6 +57,8 @@ exports.ColorPopupManager = Montage.create(Component, {
58 // 57 //
59 popupHitCheck: { 58 popupHitCheck: {
60 value: function (element, e) { 59 value: function (element, e) {
60 //Prevent any action for button to handle toggling
61 if (e._event.target.inputType || e._event.target.colorMode) return true;
61 //Storing limits of popup 62 //Storing limits of popup
62 var top, bottom, left, right; 63 var top, bottom, left, right;
63 //Checking for popup to be opened otherwise nothing happens 64 //Checking for popup to be opened otherwise nothing happens
@@ -263,6 +264,9 @@ exports.ColorPopupManager = Montage.create(Component, {
263 this._popupChipBase.props.x = (e._event.clientX - e._event.offsetX)+'px'; 264 this._popupChipBase.props.x = (e._event.clientX - e._event.offsetX)+'px';
264 this._popupChipBase.props.y = (e._event.target.clientHeight/2+e._event.clientY - e._event.offsetY)+'px'; 265 this._popupChipBase.props.y = (e._event.target.clientHeight/2+e._event.clientY - e._event.offsetY)+'px';
265 } 266 }
267 //
268 this._popupChipBase.props.source = e._event.srcElement;
269 //
266 this._popupChipBase.colorManager = ColorModel.create(); 270 this._popupChipBase.colorManager = ColorModel.create();
267 // 271 //
268 this._popupChipBase.addEventListener('change', this, false); 272 this._popupChipBase.addEventListener('change', this, false);
@@ -361,7 +365,68 @@ exports.ColorPopupManager = Montage.create(Component, {
361 e._target.base.popup.element.style.opacity = 1; 365 e._target.base.popup.element.style.opacity = 1;
362 //Popup was added, so it's opened 366 //Popup was added, so it's opened
363 e._target.base.opened = true; 367 e._target.base.opened = true;
364 }/* 368 //
369 if (e._target.base.props && e._target.base.props.source) {
370 //
371 var cbtn = e._target.base.props.source, color, hsv;
372 //
373 if (cbtn.colorMode === 'rgb') {
374 //
375 if (cbtn.colorValue && !isNaN(cbtn.colorValue.r)) {
376 color = cbtn.colorValue;
377 } else if (cbtn.colorValue && cbtn.colorValue.color){
378 color = cbtn.colorValue.color;
379 } else {
380 return;
381 }
382 //
383 hsv = this.colorManager.rgbToHsv(color.r, color.g, color.b);
384 } else if (cbtn.colorMode === 'hsl') {
385 //
386 if (cbtn.colorValue && !isNaN(cbtn.colorValue.h)) {
387 color = cbtn.colorValue;
388 } else if (cbtn.colorValue && cbtn.colorValue.color){
389 color = cbtn.colorValue.color;
390 } else {
391 return;
392 }
393 //
394 color = this.colorManager.hslToRgb(color.h/360, color.s/100, color.l/100);
395 //
396 hsv = this.colorManager.rgbToHsv(color.r, color.g, color.b);
397 }
398 //
399 if (hsv) {
400 hsv.wasSetByCode = false;
401 hsv.type = 'change';
402 e._target.base._components.wheel.value = hsv;
403 }
404 }
405 }
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429 /*
365 else if (e._target._element.className === 'cc_popup') { 430 else if (e._target._element.className === 'cc_popup') {
366 this._popupChipBase.removeEventListener('firstDraw', this, false); 431 this._popupChipBase.removeEventListener('firstDraw', this, false);
367 //Creating an instance of the popup and sending in created color popup content 432 //Creating an instance of the popup and sending in created color popup content
@@ -429,7 +494,7 @@ exports.ColorPopupManager = Montage.create(Component, {
429 this._popupChipBase.colorManager.hsv = {h: e._event.hsv.h, s: e._event.hsv.s, v: e._event.hsv.v, type: e._event.type, wasSetByCode: e._event.wasSetByCode}; 494 this._popupChipBase.colorManager.hsv = {h: e._event.hsv.h, s: e._event.hsv.s, v: e._event.hsv.v, type: e._event.type, wasSetByCode: e._event.wasSetByCode};
430 this.colorChipChange(e); 495 this.colorChipChange(e);
431 } else { 496 } else {
432 console.log(e._event); 497 //console.log(e._event);
433 } 498 }
434 return; 499 return;
435 } 500 }