mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-10-04 14:47:02 +00:00
git-svn-id: https://develop.svn.wordpress.org/trunk@22502 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
(function($) {
|
||||
|
||||
$(document).ready(function() {
|
||||
var bgImage = $("#custom-background-image");
|
||||
var bgImage = $("#custom-background-image"),
|
||||
frame;
|
||||
|
||||
$('#background-color').wpColorPicker({
|
||||
change: function( event, ui ) {
|
||||
@@ -19,6 +19,45 @@
|
||||
$('input[name="background-repeat"]').change(function() {
|
||||
bgImage.css('background-repeat', $(this).val());
|
||||
});
|
||||
});
|
||||
|
||||
$('#choose-from-library-link').click( function( event ) {
|
||||
var $el = $(this);
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
if ( frame ) {
|
||||
frame.open();
|
||||
return;
|
||||
}
|
||||
|
||||
frame = wp.media({
|
||||
title: $el.data('choose'),
|
||||
library: {
|
||||
type: 'image'
|
||||
}
|
||||
});
|
||||
|
||||
frame.toolbar.on( 'activate:select', function() {
|
||||
frame.toolbar.view().add({
|
||||
select: {
|
||||
style: 'primary',
|
||||
text: $el.data('update'),
|
||||
|
||||
click: function() {
|
||||
var attachment = frame.state().get('selection').first();
|
||||
$.post( ajaxurl, {
|
||||
action: 'set-background-image',
|
||||
attachment_id: attachment.id,
|
||||
size: 'full'
|
||||
}, function() {
|
||||
window.location.reload();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
frame.state('library');
|
||||
});
|
||||
});
|
||||
})(jQuery);
|
||||
Reference in New Issue
Block a user