tinymce.PluginManager.add("colorpicker", function(a){function b(b, c){function d(a){var b = new tinymce.util.Color(a), c = b.toRgb(); f.fromJSON({r:c.r, g:c.g, b:c.b, hex:b.toHex().substr(1)}), e(b.toHex())}function e(a){f.find("#preview")[0].getEl().style.background = a}var f = a.windowManager.open({title:"Color", items:{type:"container", layout:"flex", direction:"row", align:"stretch", padding:5, spacing:10, items:[{type:"colorpicker", value:c, onchange:function(){var a = this.rgb(); f && (f.find("#r").value(a.r), f.find("#g").value(a.g), f.find("#b").value(a.b), f.find("#hex").value(this.value().substr(1)), e(this.value()))}}, {type:"form", padding:0, labelGap:5, defaults:{type:"textbox", size:7, value:"0", flex:1, spellcheck:!1, onchange:function(){var a, b, c = f.find("colorpicker")[0]; return a = this.name(), b = this.value(), "hex" == a?(b = "#" + b, d(b), void c.value(b)):(b = {r:f.find("#r").value(), g:f.find("#g").value(), b:f.find("#b").value()}, c.value(b), void d(b))}}, items:[{name:"r", label:"R", autofocus:1}, {name:"g", label:"G"}, {name:"b", label:"B"}, {name:"hex", label:"#", value:"000000"}, {name:"preview", type:"container", border:1}]}]}, onSubmit:function(){b("#" + this.toJSON().hex)}}); d(c)}a.settings.color_picker_callback || (a.settings.color_picker_callback = b)});
|