diff --git src/wp-admin/js/custom-background.js src/wp-admin/js/custom-background.js
index c3f4e294f1..9e96015e75 100644
|
|
|
|
| 1 | 1 | /* global ajaxurl */ |
| | 2 | |
| | 3 | /** |
| | 4 | * @summary Registers all events for customizing the background. |
| | 5 | * |
| | 6 | * @since 3.0.0 |
| | 7 | * |
| | 8 | * @requires jQuery |
| | 9 | */ |
| 2 | 10 | (function($) { |
| 3 | 11 | $(document).ready(function() { |
| 4 | 12 | var frame, |
| 5 | 13 | bgImage = $( '#custom-background-image' ); |
| 6 | 14 | |
| | 15 | /** |
| | 16 | * @summary Instantiates the WordPress color picker and binds the change and clear events. |
| | 17 | * |
| | 18 | * @since 3.5.0 |
| | 19 | * |
| | 20 | * @returns {void} |
| | 21 | */ |
| 7 | 22 | $('#background-color').wpColorPicker({ |
| 8 | 23 | change: function( event, ui ) { |
| 9 | 24 | bgImage.css('background-color', ui.color.toString()); |
| … |
… |
|
| 13 | 28 | } |
| 14 | 29 | }); |
| 15 | 30 | |
| | 31 | /** |
| | 32 | * @summary Alters the background size CSS property whenever the background size input has changed. |
| | 33 | * |
| | 34 | * @since 4.7.0 |
| | 35 | * |
| | 36 | * @returns {void} |
| | 37 | */ |
| 16 | 38 | $( 'select[name="background-size"]' ).change( function() { |
| 17 | 39 | bgImage.css( 'background-size', $( this ).val() ); |
| 18 | 40 | }); |
| 19 | 41 | |
| | 42 | /** |
| | 43 | * @summary Alters the background position CSS property whenever the background position input has changed. |
| | 44 | * |
| | 45 | * @since 4.7.0 |
| | 46 | * |
| | 47 | * @returns {void} |
| | 48 | */ |
| 20 | 49 | $( 'input[name="background-position"]' ).change( function() { |
| 21 | 50 | bgImage.css( 'background-position', $( this ).val() ); |
| 22 | 51 | }); |
| 23 | 52 | |
| | 53 | /** |
| | 54 | * @summary Alters the background repeat CSS property whenever the background repeat input has changed. |
| | 55 | * |
| | 56 | * @since 3.0.0 |
| | 57 | * |
| | 58 | * @returns {void} |
| | 59 | */ |
| 24 | 60 | $( 'input[name="background-repeat"]' ).change( function() { |
| 25 | 61 | bgImage.css( 'background-repeat', $( this ).is( ':checked' ) ? 'repeat' : 'no-repeat' ); |
| 26 | 62 | }); |
| 27 | 63 | |
| | 64 | /** |
| | 65 | * @summary Alters the background attachment CSS property whenever the background attachment input has changed. |
| | 66 | * |
| | 67 | * @since 4.7.0 |
| | 68 | * |
| | 69 | * @returns {void} |
| | 70 | */ |
| 28 | 71 | $( 'input[name="background-attachment"]' ).change( function() { |
| 29 | 72 | bgImage.css( 'background-attachment', $( this ).is( ':checked' ) ? 'scroll' : 'fixed' ); |
| 30 | 73 | }); |
| 31 | 74 | |
| | 75 | /** |
| | 76 | * @summary Binds the event for opening the WP Media dialog. |
| | 77 | * |
| | 78 | * @since 3.5.0 |
| | 79 | * |
| | 80 | * @returns {void} |
| | 81 | */ |
| 32 | 82 | $('#choose-from-library-link').click( function( event ) { |
| 33 | 83 | var $el = $(this); |
| 34 | 84 | |
| … |
… |
|
| 54 | 104 | button: { |
| 55 | 105 | // Set the text of the button. |
| 56 | 106 | text: $el.data('update'), |
| 57 | | // Tell the button not to close the modal, since we're |
| 58 | | // going to refresh the page when the image is selected. |
| | 107 | /* |
| | 108 | * Tell the button not to close the modal, since we're |
| | 109 | * going to refresh the page when the image is selected. |
| | 110 | */ |
| 59 | 111 | close: false |
| 60 | 112 | } |
| 61 | 113 | }); |
| 62 | 114 | |
| 63 | | // When an image is selected, run a callback. |
| | 115 | /** |
| | 116 | * @summary When an image is selected, run a callback. |
| | 117 | * |
| | 118 | * @since 3.5.0 |
| | 119 | * |
| | 120 | * @returns {void} |
| | 121 | */ |
| 64 | 122 | frame.on( 'select', function() { |
| 65 | 123 | // Grab the selected attachment. |
| 66 | 124 | var attachment = frame.state().get('selection').first(); |