wp/wp-admin/js/media-gallery.js
author ymh <ymh.work@gmail.com>
Tue, 27 Sep 2022 16:37:53 +0200
changeset 19 3d72ae0968f4
parent 18 be944660c56a
permissions -rw-r--r--
upgrade wordpress to 6.0.2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
     1
/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
     2
 * This file is used on media-upload.php which has been replaced by media-new.php and upload.php
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
     3
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
     4
 * @deprecated 3.5.0
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
     5
 * @output wp-admin/js/media-gallery.js
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
     6
 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
     7
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
     8
 /* global ajaxurl */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
     9
jQuery(function($) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    10
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    11
	 * Adds a click event handler to the element with a 'wp-gallery' class.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    12
	 */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    13
	$( 'body' ).on( 'click.wp-gallery', function(e) {
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    14
		var target = $( e.target ), id, img_size, nonceValue;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
		if ( target.hasClass( 'wp-set-header' ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    17
			// Opens the image to preview it full size.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
			( window.dialogArguments || opener || parent || top ).location.href = target.data( 'location' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
			e.preventDefault();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
		} else if ( target.hasClass( 'wp-set-background' ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    21
			// Sets the image as background of the theme.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
			id = target.data( 'attachment-id' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
			img_size = $( 'input[name="attachments[' + id + '][image-size]"]:checked').val();
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    24
			nonceValue = $( '#_wpnonce' ).val() && '';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    26
			/**
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    27
			 * This Ajax action has been deprecated since 3.5.0, see custom-background.php
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    28
			 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    29
			jQuery.post(ajaxurl, {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    30
				action: 'set-background-image',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    31
				attachment_id: id,
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    32
				_ajax_nonce: nonceValue,
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    33
				size: img_size
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    34
			}, function() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    35
				var win = window.dialogArguments || opener || parent || top;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    36
				win.tb_remove();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    37
				win.location.reload();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    38
			});
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    39
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    40
			e.preventDefault();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    41
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    42
	});
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    43
});