2012-05-25 13:58:57 -04:00
|
|
|
var farbtastic, pickColor;
|
|
|
|
|
|
|
|
(function($) {
|
|
|
|
|
2012-06-05 14:57:49 -04:00
|
|
|
var defaultColor = '';
|
|
|
|
|
|
|
|
pickColor = function(color) {
|
2012-05-25 13:58:57 -04:00
|
|
|
farbtastic.setColor(color);
|
|
|
|
$('#background-color').val(color);
|
|
|
|
$('#custom-background-image').css('background-color', color);
|
2012-06-05 14:57:49 -04:00
|
|
|
// If we have a default color, and they match, then we need to hide the 'Default' link.
|
|
|
|
// Otherwise, we hide the 'Clear' link when it is empty.
|
|
|
|
if ( ( defaultColor && color === defaultColor ) || ( ! defaultColor && ( '' === color || '#' === color ) ) )
|
2012-05-25 13:58:57 -04:00
|
|
|
$('#clearcolor').hide();
|
|
|
|
else
|
|
|
|
$('#clearcolor').show();
|
|
|
|
}
|
|
|
|
|
|
|
|
$(document).ready(function() {
|
2012-05-27 12:25:43 -04:00
|
|
|
|
2012-06-05 14:57:49 -04:00
|
|
|
defaultColor = $('#defaultcolor').val();
|
|
|
|
|
2012-05-25 13:58:57 -04:00
|
|
|
$('#pickcolor').click(function() {
|
|
|
|
$('#colorPickerDiv').show();
|
|
|
|
return false;
|
|
|
|
});
|
2012-05-27 12:25:43 -04:00
|
|
|
|
2012-05-25 13:58:57 -04:00
|
|
|
$('#clearcolor a').click( function(e) {
|
2012-06-05 14:57:49 -04:00
|
|
|
pickColor( defaultColor );
|
2012-05-25 13:58:57 -04:00
|
|
|
e.preventDefault();
|
|
|
|
});
|
2012-05-27 12:25:43 -04:00
|
|
|
|
2012-05-25 13:58:57 -04:00
|
|
|
$('#background-color').keyup(function() {
|
|
|
|
var _hex = $('#background-color').val(), hex = _hex;
|
|
|
|
if ( hex.charAt(0) != '#' )
|
|
|
|
hex = '#' + hex;
|
|
|
|
hex = hex.replace(/[^#a-fA-F0-9]+/, '');
|
|
|
|
if ( hex != _hex )
|
|
|
|
$('#background-color').val(hex);
|
|
|
|
if ( hex.length == 4 || hex.length == 7 )
|
|
|
|
pickColor( hex );
|
|
|
|
});
|
2012-05-27 12:25:43 -04:00
|
|
|
|
2012-05-25 13:58:57 -04:00
|
|
|
$('input[name="background-position-x"]').change(function() {
|
|
|
|
$('#custom-background-image').css('background-position', $(this).val() + ' top');
|
|
|
|
});
|
2012-05-27 12:25:43 -04:00
|
|
|
|
2012-05-25 13:58:57 -04:00
|
|
|
$('input[name="background-repeat"]').change(function() {
|
|
|
|
$('#custom-background-image').css('background-repeat', $(this).val());
|
|
|
|
});
|
2012-05-27 12:25:43 -04:00
|
|
|
|
2012-05-25 13:58:57 -04:00
|
|
|
farbtastic = $.farbtastic('#colorPickerDiv', function(color) {
|
|
|
|
pickColor(color);
|
|
|
|
});
|
|
|
|
pickColor($('#background-color').val());
|
2012-05-27 12:25:43 -04:00
|
|
|
|
2012-05-25 13:58:57 -04:00
|
|
|
$(document).mousedown(function(){
|
|
|
|
$('#colorPickerDiv').each(function(){
|
|
|
|
var display = $(this).css('display');
|
|
|
|
if ( display == 'block' )
|
|
|
|
$(this).fadeOut(2);
|
|
|
|
});
|
2010-05-15 15:47:03 -04:00
|
|
|
});
|
2010-03-21 02:06:18 -04:00
|
|
|
});
|
2012-05-25 13:58:57 -04:00
|
|
|
|
|
|
|
})(jQuery);
|