2013-12-06 20:36:11 +01:00
|
|
|
/* global isRtl */
|
2013-10-25 00:55:12 +02:00
|
|
|
(function($){
|
|
|
|
|
2013-12-06 20:36:11 +01:00
|
|
|
$(document).ready( function() {
|
|
|
|
var $colorpicker, $stylesheet;
|
|
|
|
|
|
|
|
$('.color-palette').click( function() {
|
|
|
|
$(this).siblings('input[name="admin_color"]').prop('checked', true);
|
|
|
|
});
|
|
|
|
|
|
|
|
$colorpicker = $( '#color-picker' );
|
|
|
|
$stylesheet = $( '#colors-css' );
|
|
|
|
if ( isRtl ){
|
|
|
|
$stylesheet = $( '#colors-rtl-css' );
|
2013-10-25 04:29:52 +02:00
|
|
|
}
|
2013-12-06 20:36:11 +01:00
|
|
|
|
|
|
|
$colorpicker.on( 'click.colorpicker', '.color-option', function() {
|
|
|
|
var colors, css_url,
|
|
|
|
$this = $(this);
|
|
|
|
|
|
|
|
if ( $this.hasClass( 'selected' ) ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$this.siblings( '.selected' ).removeClass( 'selected' );
|
|
|
|
$this.addClass( 'selected' ).find( 'input[type="radio"]' ).prop( 'checked', true );
|
|
|
|
|
|
|
|
// Set color scheme
|
|
|
|
// Load the colors stylesheet
|
|
|
|
css_url = $this.children( '.css_url' ).val();
|
|
|
|
if ( isRtl ){
|
|
|
|
css_url = css_url.replace('.min', '-rtl.min');
|
|
|
|
}
|
|
|
|
|
|
|
|
$stylesheet.attr( 'href', css_url );
|
|
|
|
|
|
|
|
// repaint icons
|
|
|
|
if ( typeof wp !== 'undefined' && wp.svgPainter ) {
|
|
|
|
try {
|
|
|
|
colors = $.parseJSON( $this.children( '.icon_colors' ).val() );
|
|
|
|
} catch ( error ) {}
|
|
|
|
|
|
|
|
if ( colors ) {
|
|
|
|
wp.svgPainter.setColors( colors );
|
|
|
|
wp.svgPainter.paint();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2013-10-25 04:29:52 +02:00
|
|
|
});
|
|
|
|
|
2013-10-25 00:56:29 +02:00
|
|
|
})(jQuery);
|