wp/wp-admin/js/media.js
changeset 18 be944660c56a
parent 16 a86126ab1dd4
child 19 3d72ae0968f4
equal deleted inserted replaced
17:34716fd837a4 18:be944660c56a
    44 			}
    44 			}
    45 
    45 
    46 			$( '#find-posts' ).show();
    46 			$( '#find-posts' ).show();
    47 
    47 
    48 			// Close the dialog when the escape key is pressed.
    48 			// Close the dialog when the escape key is pressed.
    49 			$('#find-posts-input').focus().keyup( function( event ){
    49 			$('#find-posts-input').trigger( 'focus' ).on( 'keyup', function( event ){
    50 				if ( event.which == 27 ) {
    50 				if ( event.which == 27 ) {
    51 					findPosts.close();
    51 					findPosts.close();
    52 				}
    52 				}
    53 			});
    53 			});
    54 
    54 
   138 	 * Initializes the file once the DOM is fully loaded and attaches events to the
   138 	 * Initializes the file once the DOM is fully loaded and attaches events to the
   139 	 * various form elements.
   139 	 * various form elements.
   140 	 *
   140 	 *
   141 	 * @return {void}
   141 	 * @return {void}
   142 	 */
   142 	 */
   143 	$( document ).ready( function() {
   143 	$( function() {
   144 		var settings, $mediaGridWrap = $( '#wp-media-grid' );
   144 		var settings, $mediaGridWrap = $( '#wp-media-grid' );
   145 
   145 
   146 		// Opens a manage media frame into the grid.
   146 		// Opens a manage media frame into the grid.
   147 		if ( $mediaGridWrap.length && window.wp && window.wp.media ) {
   147 		if ( $mediaGridWrap.length && window.wp && window.wp.media ) {
   148 			settings = _wpMediaGridSettings;
   148 			settings = _wpMediaGridSettings;
   156 			// Fire a global ready event.
   156 			// Fire a global ready event.
   157 			$mediaGridWrap.trigger( 'wp-media-grid-ready', frame );
   157 			$mediaGridWrap.trigger( 'wp-media-grid-ready', frame );
   158 		}
   158 		}
   159 
   159 
   160 		// Prevents form submission if no post has been selected.
   160 		// Prevents form submission if no post has been selected.
   161 		$( '#find-posts-submit' ).click( function( event ) {
   161 		$( '#find-posts-submit' ).on( 'click', function( event ) {
   162 			if ( ! $( '#find-posts-response input[type="radio"]:checked' ).length )
   162 			if ( ! $( '#find-posts-response input[type="radio"]:checked' ).length )
   163 				event.preventDefault();
   163 				event.preventDefault();
   164 		});
   164 		});
   165 
   165 
   166 		// Submits the search query when hitting the enter key in the search input.
   166 		// Submits the search query when hitting the enter key in the search input.
   167 		$( '#find-posts .find-box-search :input' ).keypress( function( event ) {
   167 		$( '#find-posts .find-box-search :input' ).on( 'keypress', function( event ) {
   168 			if ( 13 == event.which ) {
   168 			if ( 13 == event.which ) {
   169 				findPosts.send();
   169 				findPosts.send();
   170 				return false;
   170 				return false;
   171 			}
   171 			}
   172 		});
   172 		});
   173 
   173 
   174 		// Binds the click event to the search button.
   174 		// Binds the click event to the search button.
   175 		$( '#find-posts-search' ).click( findPosts.send );
   175 		$( '#find-posts-search' ).on( 'click', findPosts.send );
   176 
   176 
   177 		// Binds the close dialog click event.
   177 		// Binds the close dialog click event.
   178 		$( '#find-posts-close' ).click( findPosts.close );
   178 		$( '#find-posts-close' ).on( 'click', findPosts.close );
   179 
   179 
   180 		// Binds the bulk action events to the submit buttons.
   180 		// Binds the bulk action events to the submit buttons.
   181 		$( '#doaction, #doaction2' ).click( function( event ) {
   181 		$( '#doaction' ).on( 'click', function( event ) {
   182 
   182 
   183 			/*
   183 			/*
   184 			 * Retrieves all select elements for bulk actions that have a name starting with `action`
   184 			 * Handle the bulk action based on its value.
   185 			 * and handle its action based on its value.
       
   186 			 */
   185 			 */
   187 			$( 'select[name^="action"]' ).each( function() {
   186 			$( 'select[name="action"]' ).each( function() {
   188 				var optionValue = $( this ).val();
   187 				var optionValue = $( this ).val();
   189 
   188 
   190 				if ( 'attach' === optionValue ) {
   189 				if ( 'attach' === optionValue ) {
   191 					event.preventDefault();
   190 					event.preventDefault();
   192 					findPosts.open();
   191 					findPosts.open();