wp/wp-admin/js/inline-edit-post.js
changeset 19 3d72ae0968f4
parent 18 be944660c56a
child 21 48c4eec2b7e6
equal deleted inserted replaced
18:be944660c56a 19:3d72ae0968f4
   129 		});
   129 		});
   130 
   130 
   131 		$('#bulk-edit').find('fieldset:first').after(
   131 		$('#bulk-edit').find('fieldset:first').after(
   132 			$('#inline-edit fieldset.inline-edit-categories').clone()
   132 			$('#inline-edit fieldset.inline-edit-categories').clone()
   133 		).siblings( 'fieldset:last' ).prepend(
   133 		).siblings( 'fieldset:last' ).prepend(
   134 			$('#inline-edit label.inline-edit-tags').clone()
   134 			$( '#inline-edit .inline-edit-tags-wrap' ).clone()
   135 		);
   135 		);
   136 
   136 
   137 		$('select[name="_status"] option[value="future"]', bulkRow).remove();
   137 		$('select[name="_status"] option[value="future"]', bulkRow).remove();
   138 
   138 
   139 		/**
   139 		/**
   195 		$( 'tbody th.check-column input[type="checkbox"]' ).each( function() {
   195 		$( 'tbody th.check-column input[type="checkbox"]' ).each( function() {
   196 
   196 
   197 			// If the checkbox for a post is selected, add the post to the edit list.
   197 			// If the checkbox for a post is selected, add the post to the edit list.
   198 			if ( $(this).prop('checked') ) {
   198 			if ( $(this).prop('checked') ) {
   199 				c = false;
   199 				c = false;
   200 				var id = $(this).val(), theTitle;
   200 				var id = $( this ).val(),
   201 				theTitle = $('#inline_'+id+' .post_title').html() || wp.i18n.__( '(no title)' );
   201 					theTitle = $( '#inline_' + id + ' .post_title' ).html() || wp.i18n.__( '(no title)' ),
   202 				te += '<div id="ttle'+id+'"><a id="_'+id+'" class="ntdelbutton" title="'+ wp.i18n.__( 'Remove From Bulk Edit' ) +'">X</a>'+theTitle+'</div>';
   202 					buttonVisuallyHiddenText = wp.i18n.sprintf(
       
   203 						/* translators: %s: Post title. */
       
   204 						wp.i18n.__( 'Remove &#8220;%s&#8221; from Bulk Edit' ),
       
   205 						theTitle
       
   206 					);
       
   207 
       
   208 				te += '<li class="ntdelitem"><button type="button" id="_' + id + '" class="button-link ntdelbutton"><span class="screen-reader-text">' + buttonVisuallyHiddenText + '</span></button><span class="ntdeltitle" aria-hidden="true">' + theTitle + '</span></li>';
   203 			}
   209 			}
   204 		});
   210 		});
   205 
   211 
   206 		// If no checkboxes where checked, just hide the quick/bulk edit rows.
   212 		// If no checkboxes where checked, just hide the quick/bulk edit rows.
   207 		if ( c ) {
   213 		if ( c ) {
   208 			return this.revert();
   214 			return this.revert();
   209 		}
   215 		}
   210 
   216 
   211 		// Add onclick events to the delete-icons in the bulk editors the post title list.
   217 		// Populate the list of items to bulk edit.
   212 		$('#bulk-titles').html(te);
   218 		$( '#bulk-titles' ).html( '<ul id="bulk-titles-list" role="list">' + te + '</ul>' );
   213 		/**
   219 
   214 		 * Binds on click events to the checkboxes before the posts in the table.
   220 		/**
       
   221 		 * Binds on click events to handle the list of items to bulk edit.
   215 		 *
   222 		 *
   216 		 * @listens click
   223 		 * @listens click
   217 		 */
   224 		 */
   218 		$('#bulk-titles a').on( 'click', function(){
   225 		$( '#bulk-titles .ntdelbutton' ).click( function() {
   219 			var id = $(this).attr('id').substr(1);
   226 			var $this = $( this ),
   220 
   227 				id = $this.attr( 'id' ).substr( 1 ),
   221 			$('table.widefat input[value="' + id + '"]').prop('checked', false);
   228 				$prev = $this.parent().prev().children( '.ntdelbutton' ),
   222 			$('#ttle'+id).remove();
   229 				$next = $this.parent().next().children( '.ntdelbutton' );
       
   230 
       
   231 			$( 'table.widefat input[value="' + id + '"]' ).prop( 'checked', false );
       
   232 			$( '#_' + id ).parent().remove();
       
   233 			wp.a11y.speak( wp.i18n.__( 'Item removed.' ), 'assertive' );
       
   234 
       
   235 			// Move focus to a proper place when items are removed.
       
   236 			if ( $next.length ) {
       
   237 				$next.focus();
       
   238 			} else if ( $prev.length ) {
       
   239 				$prev.focus();
       
   240 			} else {
       
   241 				$( '#bulk-titles-list' ).remove();
       
   242 				inlineEditPost.revert();
       
   243 				wp.a11y.speak( wp.i18n.__( 'All selected items have been removed. Select new items to use Bulk Actions.' ) );
       
   244 			}
   223 		});
   245 		});
   224 
   246 
   225 		// Enable auto-complete for tags when editing posts.
   247 		// Enable auto-complete for tags when editing posts.
   226 		if ( 'post' === type ) {
   248 		if ( 'post' === type ) {
   227 			$( 'tr.inline-editor textarea[data-wp-taxonomy]' ).each( function ( i, element ) {
   249 			$( 'tr.inline-editor textarea[data-wp-taxonomy]' ).each( function ( i, element ) {
   236 
   258 
   237 				$( element ).wpTagsSuggest();
   259 				$( element ).wpTagsSuggest();
   238 			} );
   260 			} );
   239 		}
   261 		}
   240 
   262 
       
   263 		// Set initial focus on the Bulk Edit region.
       
   264 		$( '#bulk-edit .inline-edit-wrapper' ).attr( 'tabindex', '-1' ).focus();
   241 		// Scrolls to the top of the table where the editor is rendered.
   265 		// Scrolls to the top of the table where the editor is rendered.
   242 		$('html, body').animate( { scrollTop: 0 }, 'fast' );
   266 		$('html, body').animate( { scrollTop: 0 }, 'fast' );
   243 	},
   267 	},
   244 
   268 
   245 	/**
   269 	/**
   267 		}
   291 		}
   268 
   292 
   269 		// Add the new edit row with an extra blank row underneath to maintain zebra striping.
   293 		// Add the new edit row with an extra blank row underneath to maintain zebra striping.
   270 		editRow = $('#inline-edit').clone(true);
   294 		editRow = $('#inline-edit').clone(true);
   271 		$( 'td', editRow ).attr( 'colspan', $( 'th:visible, td:visible', '.widefat:first thead' ).length );
   295 		$( 'td', editRow ).attr( 'colspan', $( 'th:visible, td:visible', '.widefat:first thead' ).length );
       
   296 
       
   297 		// Remove the ID from the copied row and let the `for` attribute reference the hidden ID.
       
   298 		$( 'td', editRow ).find('#quick-edit-legend').removeAttr('id');
       
   299 		$( 'td', editRow ).find('p[id^="quick-edit-"]').removeAttr('id');
   272 
   300 
   273 		$(t.what+id).removeClass('is-expanded').hide().after(editRow).after('<tr class="hidden"></tr>');
   301 		$(t.what+id).removeClass('is-expanded').hide().after(editRow).after('<tr class="hidden"></tr>');
   274 
   302 
   275 		// Populate fields in the quick edit window.
   303 		// Populate fields in the quick edit window.
   276 		rowData = $('#inline_'+id);
   304 		rowData = $('#inline_'+id);