Wordpress/wp-admin/js/custom-background.dev.js
2010-05-15 19:47:03 +00:00

51 lines
1.4 KiB
JavaScript

var farbtastic;
function pickColor(color) {
farbtastic.setColor(color);
jQuery('#background-color').val(color);
jQuery('#custom-background-image').css('background-color', color);
}
jQuery(document).ready(function() {
jQuery('#pickcolor').click(function() {
jQuery('#colorPickerDiv').show();
});
jQuery('#background-color').keyup(function() {
var _hex = jQuery('#background-color').val();
var hex = _hex;
if ( hex[0] != '#' )
hex = '#' + hex;
hex = hex.replace(/[^#a-fA-F0-9]+/, '');
if ( hex != _hex )
jQuery('#background-color').val(hex);
if ( hex.length == 4 || hex.length == 7 )
pickColor( hex );
});
jQuery('input[name="background-position"]').change(function() {
jQuery('#custom-background-image').css('background-position', 'top ' + jQuery(this).val());
});
jQuery('select[name="background-repeat"]').change(function() {
jQuery('#custom-background-image').css('background-repeat', jQuery(this).val());
});
jQuery('input[name="background-attachment"]').change(function() {
jQuery('#custom-background-image').css('background-attachment', jQuery(this).val());
});
farbtastic = jQuery.farbtastic('#colorPickerDiv', function(color) {
pickColor(color);
});
pickColor(jQuery('#background-color').val());
jQuery(document).mousedown(function(){
jQuery('#colorPickerDiv').each(function(){
var display = jQuery(this).css('display');
if ( display == 'block' )
jQuery(this).fadeOut(2);
});
});
});