WordPress/wp-admin/js/custom-background.min.js

1 line
914 B
JavaScript

!function(c){c(document).ready(function(){var a,t=c("#custom-background-image");c("#background-color").wpColorPicker({change:function(o,n){t.css("background-color",n.color.toString())},clear:function(){t.css("background-color","")}}),c('input[name="background-position-x"]').change(function(){t.css("background-position",c(this).val()+" top")}),c('input[name="background-repeat"]').change(function(){t.css("background-repeat",c(this).val())}),c("#choose-from-library-link").click(function(o){var n=c(this);o.preventDefault(),a||(a=wp.media.frames.customBackground=wp.media({title:n.data("choose"),library:{type:"image"},button:{text:n.data("update"),close:!1}})).on("select",function(){var o=a.state().get("selection").first(),n=c("#_wpnonce").val()||"";c.post(ajaxurl,{action:"set-background-image",attachment_id:o.id,_ajax_nonce:n,size:"full"}).done(function(){window.location.reload()})}),a.open()})})}(jQuery);