2011-04-27 00:52:18 +02:00
|
|
|
var farbtastic;
|
2011-04-28 11:32:34 +02:00
|
|
|
|
|
|
|
(function($){
|
|
|
|
var pickColor = function(a) {
|
|
|
|
farbtastic.setColor(a);
|
|
|
|
$('#link-color').val(a);
|
|
|
|
$('#link-color-example').css('background-color', a);
|
2011-04-28 21:01:51 +02:00
|
|
|
};
|
2011-04-28 11:32:34 +02:00
|
|
|
|
|
|
|
$(document).ready( function() {
|
2011-06-08 19:39:12 +02:00
|
|
|
$('#default-color').wrapInner('<a href="#" />');
|
|
|
|
|
2011-04-28 11:32:34 +02:00
|
|
|
farbtastic = $.farbtastic('#colorPickerDiv', pickColor);
|
|
|
|
|
|
|
|
pickColor( $('#link-color').val() );
|
|
|
|
|
2011-04-28 21:01:51 +02:00
|
|
|
$('.pickcolor').click( function(e) {
|
2011-04-28 11:32:34 +02:00
|
|
|
$('#colorPickerDiv').show();
|
|
|
|
e.preventDefault();
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#link-color').keyup( function() {
|
|
|
|
var a = $('#link-color').val(),
|
|
|
|
b = a;
|
|
|
|
|
|
|
|
a = a.replace(/[^a-fA-F0-9]/, '');
|
|
|
|
if ( '#' + a !== b )
|
|
|
|
$('#link-color').val(a);
|
|
|
|
if ( a.length === 3 || a.length === 6 )
|
|
|
|
pickColor( '#' + a );
|
|
|
|
});
|
|
|
|
|
|
|
|
$(document).mousedown( function() {
|
|
|
|
$('#colorPickerDiv').hide();
|
2011-04-27 00:52:18 +02:00
|
|
|
});
|
2011-06-08 19:39:12 +02:00
|
|
|
|
|
|
|
$('#default-color a').click( function(e) {
|
|
|
|
pickColor( '#' + this.innerHTML.replace(/[^a-fA-F0-9]/, '') );
|
|
|
|
e.preventDefault();
|
|
|
|
});
|
|
|
|
|
|
|
|
$('.image-radio-option input:radio').change( function() {
|
|
|
|
var currentDefault = $('#default-color a'),
|
|
|
|
newDefault;
|
|
|
|
if ( $('#link-color').val() !== currentDefault.text() )
|
|
|
|
return;
|
|
|
|
newDefault = $(this).next().val();
|
|
|
|
currentDefault.text( newDefault );
|
|
|
|
pickColor( newDefault );
|
|
|
|
});
|
2011-04-27 00:52:18 +02:00
|
|
|
});
|
2011-04-28 11:32:34 +02:00
|
|
|
})(jQuery);
|