-
-
Save raulillana/1878051 to your computer and use it in GitHub Desktop.
WordPress Farbtastic Color Picker for Multiple Instances
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
<!-- WordPress Farbtastic Color Picker for Multiple Instances --> | |
<div style="position:relative;"> | |
<input type="text" name="my-theme-options[color]" id="color" /> | |
<input type="button" class="pickcolor button-secondary" value="<?php _e('Select Color') ?>"> | |
<div class="colorpicker" style="z-index:100; position:absolute; display:none;"></div> | |
</div> | |
<script> | |
// Include this script in your JS related file | |
$('.pickcolor').click(function(e) { | |
colorPicker = jQuery(this).next('div'); | |
input = jQuery(this).prev('input'); | |
$.farbtastic($(colorPicker), function(a) { $(input).val(a).css('background', a); }); | |
colorPicker.show(); | |
e.preventDefault(); | |
$(document).mousedown( function() { $(colorPicker).hide(); }); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment