wp/wp-admin/js/inline-edit-tax.js
changeset 18 be944660c56a
parent 16 a86126ab1dd4
equal deleted inserted replaced
17:34716fd837a4 18:be944660c56a
    45 		/**
    45 		/**
    46 		 * Cancels inline editing when pressing Escape inside the inline editor.
    46 		 * Cancels inline editing when pressing Escape inside the inline editor.
    47 		 *
    47 		 *
    48 		 * @param {Object} e The keyup event that has been triggered.
    48 		 * @param {Object} e The keyup event that has been triggered.
    49 		 */
    49 		 */
    50 		row.keyup( function( e ) {
    50 		row.on( 'keyup', function( e ) {
    51 			// 27 = [Escape].
    51 			// 27 = [Escape].
    52 			if ( e.which === 27 ) {
    52 			if ( e.which === 27 ) {
    53 				return inlineEditTax.revert();
    53 				return inlineEditTax.revert();
    54 			}
    54 			}
    55 		});
    55 		});
    56 
    56 
    57 		/**
    57 		/**
    58 		 * Cancels inline editing when clicking the cancel button.
    58 		 * Cancels inline editing when clicking the cancel button.
    59 		 */
    59 		 */
    60 		$( '.cancel', row ).click( function() {
    60 		$( '.cancel', row ).on( 'click', function() {
    61 			return inlineEditTax.revert();
    61 			return inlineEditTax.revert();
    62 		});
    62 		});
    63 
    63 
    64 		/**
    64 		/**
    65 		 * Saves the inline edits when clicking the save button.
    65 		 * Saves the inline edits when clicking the save button.
    66 		 */
    66 		 */
    67 		$( '.save', row ).click( function() {
    67 		$( '.save', row ).on( 'click', function() {
    68 			return inlineEditTax.save(this);
    68 			return inlineEditTax.save(this);
    69 		});
    69 		});
    70 
    70 
    71 		/**
    71 		/**
    72 		 * Saves the inline edits when pressing Enter inside the inline editor.
    72 		 * Saves the inline edits when pressing Enter inside the inline editor.
    73 		 */
    73 		 */
    74 		$( 'input, select', row ).keydown( function( e ) {
    74 		$( 'input, select', row ).on( 'keydown', function( e ) {
    75 			// 13 = [Enter].
    75 			// 13 = [Enter].
    76 			if ( e.which === 13 ) {
    76 			if ( e.which === 13 ) {
    77 				return inlineEditTax.save( this );
    77 				return inlineEditTax.save( this );
    78 			}
    78 			}
    79 		});
    79 		});
    80 
    80 
    81 		/**
    81 		/**
    82 		 * Saves the inline edits on submitting the inline edit form.
    82 		 * Saves the inline edits on submitting the inline edit form.
    83 		 */
    83 		 */
    84 		$( '#posts-filter input[type="submit"]' ).mousedown( function() {
    84 		$( '#posts-filter input[type="submit"]' ).on( 'mousedown', function() {
    85 			t.revert();
    85 			t.revert();
    86 		});
    86 		});
    87 	},
    87 	},
    88 
    88 
    89 	/**
    89 	/**
   141 		val.find( 'img' ).replaceWith( function() { return this.alt; } );
   141 		val.find( 'img' ).replaceWith( function() { return this.alt; } );
   142 		val = val.text();
   142 		val = val.text();
   143 		$(':input[name="slug"]', editRow).val( val );
   143 		$(':input[name="slug"]', editRow).val( val );
   144 
   144 
   145 		$(editRow).attr('id', 'edit-'+id).addClass('inline-editor').show();
   145 		$(editRow).attr('id', 'edit-'+id).addClass('inline-editor').show();
   146 		$('.ptitle', editRow).eq(0).focus();
   146 		$('.ptitle', editRow).eq(0).trigger( 'focus' );
   147 
   147 
   148 		return false;
   148 		return false;
   149 	},
   149 	},
   150 
   150 
   151 	/**
   151 	/**
   221 
   221 
   222 						row.hide().fadeIn( 400, function() {
   222 						row.hide().fadeIn( 400, function() {
   223 							// Move focus back to the Quick Edit button.
   223 							// Move focus back to the Quick Edit button.
   224 							row.find( '.editinline' )
   224 							row.find( '.editinline' )
   225 								.attr( 'aria-expanded', 'false' )
   225 								.attr( 'aria-expanded', 'false' )
   226 								.focus();
   226 								.trigger( 'focus' );
   227 							wp.a11y.speak( wp.i18n.__( 'Changes saved.' ) );
   227 							wp.a11y.speak( wp.i18n.__( 'Changes saved.' ) );
   228 						});
   228 						});
   229 
   229 
   230 					} else {
   230 					} else {
   231 						$errorNotice.removeClass( 'hidden' );
   231 						$errorNotice.removeClass( 'hidden' );
   266 			id = id.substr( id.lastIndexOf('-') + 1 );
   266 			id = id.substr( id.lastIndexOf('-') + 1 );
   267 
   267 
   268 			// Show the taxonomy row and move focus back to the Quick Edit button.
   268 			// Show the taxonomy row and move focus back to the Quick Edit button.
   269 			$( this.what + id ).show().find( '.editinline' )
   269 			$( this.what + id ).show().find( '.editinline' )
   270 				.attr( 'aria-expanded', 'false' )
   270 				.attr( 'aria-expanded', 'false' )
   271 				.focus();
   271 				.trigger( 'focus' );
   272 		}
   272 		}
   273 	},
   273 	},
   274 
   274 
   275 	/**
   275 	/**
   276 	 * Retrieves the ID of the term of the element inside the table row.
   276 	 * Retrieves the ID of the term of the element inside the table row.
   287 
   287 
   288 		return parts[parts.length - 1];
   288 		return parts[parts.length - 1];
   289 	}
   289 	}
   290 };
   290 };
   291 
   291 
   292 $(document).ready(function(){inlineEditTax.init();});
   292 $( function() { inlineEditTax.init(); } );
   293 
   293 
   294 })( jQuery, window.wp );
   294 })( jQuery, window.wp );