From fbd9d2492aeaef392ad59792825b8757d6c363fc Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Fri, 15 Jun 2012 15:14:34 -0700 Subject: Fixing apply 'no color' This should fix canvas and standard DOM elements including the root (body or template wrapper). --- js/controllers/color-controller.js | 2 +- js/models/color-model.js | 14 +++++++------- js/panels/color/colorchippopup.reel/colorchippopup.js | 4 ++-- js/panels/color/colorpanelbase.reel/colorpanelbase.js | 18 +++++++++--------- .../color/colorpanelpopup.reel/colorpanelpopup.js | 8 ++++---- js/panels/color/colortoolbar.reel/colortoolbar.js | 4 ++-- js/panels/properties.reel/properties.js | 4 ++-- .../properties.reel/sections/custom.reel/custom.js | 6 +++++- js/tools/EyedropperTool.js | 2 +- 9 files changed, 33 insertions(+), 29 deletions(-) diff --git a/js/controllers/color-controller.js b/js/controllers/color-controller.js index d4737aad..3edaff86 100755 --- a/js/controllers/color-controller.js +++ b/js/controllers/color-controller.js @@ -198,7 +198,7 @@ exports.ColorController = Montage.create(Component, { enumerable: true, value: function (e) { // - var actionEvent, color, input = e._event.input, panelMode, mode = e._event.mode; + var color, input = e._event.input, panelMode, mode = e._event.mode; if (this.colorView) { panelMode = this.colorView.panelMode; } diff --git a/js/models/color-model.js b/js/models/color-model.js index 764feeb5..a2eab2e1 100755 --- a/js/models/color-model.js +++ b/js/models/color-model.js @@ -231,10 +231,10 @@ exports.ColorModel = Montage.create(Component, { // applyNoColor: { enumerable: true, - value: function () { + value: function (code) { // var nocolor = {}; - nocolor.wasSetByCode = true; + nocolor.wasSetByCode = code; nocolor.type = 'change'; this.updateColorSelected('nocolor', nocolor); } @@ -310,29 +310,29 @@ exports.ColorModel = Montage.create(Component, { case 'hex': switch (color.length) { case 1: - this.applyNoColor(); + this.applyNoColor(false); return; break; case 2: - this.applyNoColor(); + this.applyNoColor(false); return; break; case 3: color = color[0]+color[0]+color[1]+color[1]+color[2]+color[2]; break; case 4: - this.applyNoColor(); + this.applyNoColor(false); return; break; case 5: - this.applyNoColor(); + this.applyNoColor(false); return; break; case 6: //Nothing break; default: - this.applyNoColor(); + this.applyNoColor(false); return; break; } diff --git a/js/panels/color/colorchippopup.reel/colorchippopup.js b/js/panels/color/colorchippopup.reel/colorchippopup.js index 414be8b7..923beca9 100755 --- a/js/panels/color/colorchippopup.reel/colorchippopup.js +++ b/js/panels/color/colorchippopup.reel/colorchippopup.js @@ -43,8 +43,8 @@ exports.ColorChipPopup = Montage.create(Component, { // setNoColor: { enumerable: true, - value: function (e) { - this.colorManager.applyNoColor(); + value: function (code) { + this.colorManager.applyNoColor(code); } }, //////////////////////////////////////////////////////////////////// diff --git a/js/panels/color/colorpanelbase.reel/colorpanelbase.js b/js/panels/color/colorpanelbase.reel/colorpanelbase.js index 7a28c55d..7071f590 100755 --- a/js/panels/color/colorpanelbase.reel/colorpanelbase.js +++ b/js/panels/color/colorpanelbase.reel/colorpanelbase.js @@ -694,7 +694,7 @@ exports.ColorPanelBase = Montage.create(Component, { case 'nocolor': this._buttons.nocolor.push(button); button.title = 'No Color'; - button.addEventListener('click', this.setNoColor.bind(this)); + button.addEventListener('click', function () {this.setNoColor(false)}.bind(this)); break; //////////////////////////////////////////////////////// case 'swap': @@ -746,7 +746,7 @@ exports.ColorPanelBase = Montage.create(Component, { color.wasSetByCode = false; // if (prev.m === 'nocolor') { - this.setNoColor(); + this.setNoColor(false); } else { this.colorManager.alpha = { value: alpha, wasSetByCode: true, type: 'change' }; this.colorManager[prev.m] = color; @@ -832,11 +832,11 @@ exports.ColorPanelBase = Montage.create(Component, { //TODO: Add set by code property setNoColor: { enumerable: true, - value: function (e) { + value: function (wasSetByCode) { // this.application.ninja.colorController.colorPopupManager.hideColorPopup(); // - this.colorManager.applyNoColor(); + this.colorManager.applyNoColor(wasSetByCode); } }, //////////////////////////////////////////////////////////////////// @@ -879,7 +879,7 @@ exports.ColorPanelBase = Montage.create(Component, { break; //////////////////////////////////////////////////////// default: - this.setNoColor(); + this.setNoColor(false); break; //////////////////////////////////////////////////////// } @@ -911,7 +911,7 @@ exports.ColorPanelBase = Montage.create(Component, { break; //////////////////////////////////////////////////////// default: - this.setNoColor(); + this.setNoColor(false); break; //////////////////////////////////////////////////////// } @@ -1300,7 +1300,7 @@ exports.ColorPanelBase = Montage.create(Component, { update.type = 'change'; this.colorManager.hsl = update; } else { - this.colorManager.applyNoColor(); + this.colorManager.applyNoColor(false); } } else { update = this.colorManager.hexToRgb(color); @@ -1309,7 +1309,7 @@ exports.ColorPanelBase = Montage.create(Component, { update.type = 'change'; this.colorManager.rgb = update; } else { - this.colorManager.applyNoColor(); + this.colorManager.applyNoColor(false); } } } @@ -1553,7 +1553,7 @@ exports.ColorPanelBase = Montage.create(Component, { this.colorManager.hsv = color.c; break; default: - this.colorManager.applyNoColor(); + this.colorManager.applyNoColor(true); break; } // diff --git a/js/panels/color/colorpanelpopup.reel/colorpanelpopup.js b/js/panels/color/colorpanelpopup.reel/colorpanelpopup.js index 4161cb50..ded06797 100755 --- a/js/panels/color/colorpanelpopup.reel/colorpanelpopup.js +++ b/js/panels/color/colorpanelpopup.reel/colorpanelpopup.js @@ -50,8 +50,8 @@ exports.ColorPanelPopup = Montage.create(Component, { //////////////////////////////////////////////////////////////////// // setNoColor: { - value: function (e) { - if (this.colorManager) this.colorManager.applyNoColor(); + value: function (code) { + if (this.colorManager) this.colorManager.applyNoColor(code); } }, //////////////////////////////////////////////////////////////////// @@ -308,7 +308,7 @@ exports.ColorPanelPopup = Montage.create(Component, { color.type = 'change'; this.colorManager.hsl = color; } else { - this.colorManager.applyNoColor(); + this.colorManager.applyNoColor(false); } } else { color = this.colorManager.hexToRgb(b._event.srcElement.colorValue); @@ -317,7 +317,7 @@ exports.ColorPanelPopup = Montage.create(Component, { color.type = 'change'; this.colorManager.rgb = color; } else { - this.colorManager.applyNoColor(); + this.colorManager.applyNoColor(false); } } } diff --git a/js/panels/color/colortoolbar.reel/colortoolbar.js b/js/panels/color/colortoolbar.reel/colortoolbar.js index 6b8e476b..bf4d307f 100755 --- a/js/panels/color/colortoolbar.reel/colortoolbar.js +++ b/js/panels/color/colortoolbar.reel/colortoolbar.js @@ -108,7 +108,7 @@ exports.ColorToolbar = Montage.create(Component, { color.mode = e._event.colorMode; this.application.ninja.colorController.colorModel[e._event.colorMode] = color; } else { - this.application.ninja.colorController.colorModel.applyNoColor(); + this.application.ninja.colorController.colorModel.applyNoColor(false); } this.application.ninja.colorController.colorModel.input = 'chip'; }.bind(this)); @@ -125,7 +125,7 @@ exports.ColorToolbar = Montage.create(Component, { color.mode = e._event.colorMode; this.application.ninja.colorController.colorModel[e._event.colorMode] = color; } else { - this.application.ninja.colorController.colorModel.applyNoColor(); + this.application.ninja.colorController.colorModel.applyNoColor(false); } this.application.ninja.colorController.colorModel.input = 'chip'; }.bind(this)); diff --git a/js/panels/properties.reel/properties.js b/js/panels/properties.reel/properties.js index 43c92b74..fcd0ab01 100755 --- a/js/panels/properties.reel/properties.js +++ b/js/panels/properties.reel/properties.js @@ -367,7 +367,7 @@ exports.Properties = Montage.create(Component, { } } else { this.application.ninja.colorController.colorModel.alpha = {value: 1, wasSetByCode: true, type: 'change'}; - this.application.ninja.colorController.colorModel.applyNoColor(); + this.application.ninja.colorController.colorModel.applyNoColor(true); } } } @@ -397,7 +397,7 @@ exports.Properties = Montage.create(Component, { this.application.ninja.colorController.colorModel.hsv = color.c; break; default: - this.application.ninja.colorController.colorModel.applyNoColor(); + this.application.ninja.colorController.colorModel.applyNoColor(true); break; } } diff --git a/js/panels/properties.reel/sections/custom.reel/custom.js b/js/panels/properties.reel/sections/custom.reel/custom.js index c599dcb0..08434b01 100755 --- a/js/panels/properties.reel/sections/custom.reel/custom.js +++ b/js/panels/properties.reel/sections/custom.reel/custom.js @@ -116,7 +116,11 @@ exports.CustomSection = Montage.create(Component, { value: function(event) { // Change the stage color for now //console.log(this, event); - ElementsMediator.setProperty([this.application.ninja.currentDocument.model.documentRoot], this.id, [event._event.color.css], "Change", "pi", ''); + if (event._event.color && event._event.color.css) { + ElementsMediator.setProperty([this.application.ninja.currentDocument.model.documentRoot], this.id, [event._event.color.css], "Change", "pi", ''); + } else { + ElementsMediator.setProperty([this.application.ninja.currentDocument.model.documentRoot], this.id, ['none'], "Change", "pi", ''); + } /* var propEvent = document.createEvent("CustomEvent"); propEvent.initEvent("propertyChange", true, true); diff --git a/js/tools/EyedropperTool.js b/js/tools/EyedropperTool.js index 6a56004d..30a6a48b 100755 --- a/js/tools/EyedropperTool.js +++ b/js/tools/EyedropperTool.js @@ -240,7 +240,7 @@ exports.EyedropperTool = Montage.create(toolBase, { else { this.application.ninja.colorController.colorModel.alpha = {value: 1, wasSetByCode: true, type: eventType}; - this.application.ninja.colorController.colorModel.applyNoColor(); + this.application.ninja.colorController.colorModel.applyNoColor(true); if(updateColorToolBar) { this._previousColor = "none"; -- cgit v1.2.3