diff options
| author | Jules Laplace <jules@okfoc.us> | 2014-11-13 13:34:00 -0500 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2014-11-13 13:34:00 -0500 |
| commit | d4774d78b0b9a52b5fff4c4b782df6b2d534a167 (patch) | |
| tree | 66f2789990e34e5e7f43427f8298a5d3b124d7ef /public/assets/javascripts | |
| parent | 0f8be5bc39ca5049d3f29fe74eb423da4dcb055a (diff) | |
toggle color picker, swatches, done button, etc
Diffstat (limited to 'public/assets/javascripts')
| -rw-r--r-- | public/assets/javascripts/ui/editor/TextEditor.js | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/public/assets/javascripts/ui/editor/TextEditor.js b/public/assets/javascripts/ui/editor/TextEditor.js index c5902b2..5013408 100644 --- a/public/assets/javascripts/ui/editor/TextEditor.js +++ b/public/assets/javascripts/ui/editor/TextEditor.js @@ -13,8 +13,10 @@ var TextEditor = FormView.extend({ "change [name=text-align]": 'changeTextAlign', "click .swatch": 'showColorPicker', "click [data-role=hide-color-picker]": 'hideColorPicker', + "click [data-role=hide-text-editor]": 'hide', "input [name=text-body]": 'changeText', "click [data-role=destroy-text]": "destroy", + "click .colors span": "setHue", }, initialize: function(opt){ @@ -34,13 +36,22 @@ var TextEditor = FormView.extend({ this.$(".color-picker").append( this.colorPicker.canvas ) this.$(".color-picker").append( this.colorPicker.cursor ) this.$(".slider").append( this.colorPicker.brightness ) - + + this.$colors = this.$(".colors") + this.parent.colorControl.colors.forEach(function(color){ + var $swatch = $("<span>") + $swatch.css("background-color","rgb(" + color + ")") + $swatch.data('color', color) + this.$colors.append($swatch) + }.bind(this)) + this.$(".setting").hide() app.on("cancel-scenery", function(){ this.createMode(true) $("body").toggleClass("addText", false) }.bind(this)) + }, toggle: function(state){ @@ -100,7 +111,7 @@ var TextEditor = FormView.extend({ }, createMode: function(state){ - this.$colorSettings.hide() + this.hideColorPicker() this.$textSettings.toggle(! state) this.$noTextMessage.toggle(!! state) $("body").toggleClass("addText", !! state) @@ -169,24 +180,36 @@ var TextEditor = FormView.extend({ this.$textSettings.hide() this.$colorSettings.show() - this.labColor = this.colorPicker.load(this.scenery.media.font.color) + var color = this.scenery.media.font.color + this.labColor = this.colorPicker.load(color) this.pickColor(color, this.labColor) + + this.$el.addClass("color-mode") }, + hideColorPicker: function(e){ e && e.preventDefault() this.$textSettings.show() this.$colorSettings.hide() + this.$el.removeClass("color-mode") }, pickColor: function(rgb, Lab){ this.labColor = Lab this.setSwatchColor(rgb) this.scenery.setFont({ color: rgb }) + this.tainted = true + }, + + setHue: function(e){ + var color = $(e.currentTarget).data('color') + this.labColor = this.colorPicker.load(color) + this.pickColor(color, this.labColor) }, initialState: null, - begin: function(){ + begin: function(){ // this.initialState = this.serialize() }, |
