mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-04 17:20:07 +00:00
Cleanup of Custom Background. Move JS to external file, Add @since, Remove redundant steps functionality, Preview of Image alignment. See #12186
git-svn-id: https://develop.svn.wordpress.org/trunk@13788 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
49
wp-admin/js/custom-background.dev.js
Normal file
49
wp-admin/js/custom-background.dev.js
Normal file
@@ -0,0 +1,49 @@
|
||||
var buttons = ['#pickcolor'], farbtastic;
|
||||
|
||||
function pickColor(color) {
|
||||
jQuery('#background-color').val(color);
|
||||
farbtastic.setColor(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 img').attr('align', jQuery(this).val() );
|
||||
});
|
||||
|
||||
farbtastic = jQuery.farbtastic('#colorPickerDiv', function(color) {
|
||||
pickColor(color);
|
||||
});
|
||||
pickColor(customBackgroundL10n.backgroundcolor);
|
||||
});
|
||||
|
||||
jQuery(document).mousedown(function(){
|
||||
hide_picker(); // Make the picker disappear if you click outside its div element
|
||||
});
|
||||
|
||||
function hide_picker(what) {
|
||||
var update = false;
|
||||
jQuery('#colorPickerDiv').each(function(){
|
||||
var id = jQuery(this).attr('id');
|
||||
if ( id == what )
|
||||
return;
|
||||
|
||||
var display = jQuery(this).css('display');
|
||||
if ( display == 'block' )
|
||||
jQuery(this).fadeOut(2);
|
||||
});
|
||||
}
|
||||
1
wp-admin/js/custom-background.js
Normal file
1
wp-admin/js/custom-background.js
Normal file
@@ -0,0 +1 @@
|
||||
var buttons=["#pickcolor"],farbtastic;function pickColor(color){jQuery("#background-color").val(color);farbtastic.setColor(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 img").attr("align",jQuery(this).val())});farbtastic=jQuery.farbtastic("#colorPickerDiv",function(color){pickColor(color)});pickColor(customBackgroundL10n.backgroundcolor)});jQuery(document).mousedown(function(){hide_picker()});function hide_picker(what){var update=false;jQuery("#colorPickerDiv").each(function(){var id=jQuery(this).attr("id");if(id==what){return}var display=jQuery(this).css("display");if(display=="block"){jQuery(this).fadeOut(2)}})};
|
||||
Reference in New Issue
Block a user