Created
August 20, 2014 14:23
-
-
Save alej0varas/ef0479e4998cff08779f to your computer and use it in GitHub Desktop.
hallo.js color picker plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// hallo colorpicker plugin | |
// (c) 2014 Alejandro Varas | |
// Based on https://github.com/25th-floor/hallo-simplecolorpicker-plugin | |
// hallocolorpicker may be freely distributed under the MIT license | |
(function(jQuery) { | |
return jQuery.widget("IKS.hallocolorpicker", { | |
colorElement : null, | |
options: { | |
uuid: '', | |
colors: { | |
"#7bd148": "Green", | |
"#5484ed": "Bold blue", | |
"#a4bdfc": "Blue", | |
"#46d6db": "Turquoise", | |
"#7ae7bf": "Light green", | |
"#51b749": "Bold green", | |
"#fbd75b": "Yellow", | |
"#ffb878": "Orange", | |
"#ff887c": "Red", | |
"#dc2127": "Bold red", | |
"#dbadff": "Purple", | |
"#e1e1e1": "Gray", | |
"#000000": "Black" | |
}, | |
}, | |
populateToolbar: function(toolbar) { | |
var buttonset, widget, | |
_this = this; | |
widget = this; | |
buttonset = jQuery("<span class=\"" + widget.widgetName + "\"></span>"); | |
this.createbuttons(buttonset); | |
buttonset.hallobuttonset(); | |
toolbar.append(buttonset); | |
}, | |
createbuttons: function (buttonset) { | |
var _this = this | |
jQuery.each(this.options.colors, function(color, label) { | |
var buttonElement; | |
buttonElement = jQuery('<span></span>'); | |
buttonElement.hallobutton({ | |
uuid: _this.options.uuid, | |
editable: _this.options.editable, | |
label: label, | |
command: 'backColor', | |
commandValue: color, | |
cssClass: _this.options.buttonCssClass, | |
icon: 'fa fa-font' | |
}); | |
buttonElement.find('.ui-button-text').css('background', color); | |
buttonElement.find('.ui-button-text').text('C'); | |
buttonset.append(buttonElement); | |
}); | |
}, | |
}); | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment