<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[40796] trunk/src/wp-admin/js/inline-edit-post.js: </title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/40796">40796</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/40796","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>obenland</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2017-05-19 15:44:10 +0000 (Fri, 19 May 2017)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>
Docs: Improve inline docs for inlineEditPost.
Props jjcomack, rensw90.
Fixes <a href="https://core.trac.wordpress.org/ticket/39823">#39823</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadminjsinlineeditpostjs">trunk/src/wp-admin/js/inline-edit-post.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadminjsinlineeditpostjs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/js/inline-edit-post.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/js/inline-edit-post.js 2017-05-19 15:18:06 UTC (rev 40795)
+++ trunk/src/wp-admin/js/inline-edit-post.js 2017-05-19 15:44:10 UTC (rev 40796)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,44 +1,115 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /* global inlineEditL10n, ajaxurl, typenow */
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * This file contains the functions needed for the inline editing of posts.
+ *
+ * @since 2.7.0
+ */
+
</ins><span class="cx" style="display: block; padding: 0 10px"> window.wp = window.wp || {};
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * Manages the quick edit and bulk edit windows for editing posts or pages.
+ *
+ * @namespace
+ *
+ * @since 2.7.0
+ * @access public
+ *
+ * @type {Object}
+ *
+ * @property {string} type The type of inline editor.
+ * @property {string} what The prefix before the post id.
+ *
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> var inlineEditPost;
</span><span class="cx" style="display: block; padding: 0 10px"> ( function( $, wp ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-inlineEditPost = {
</del><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ inlineEditPost = {
+
+ /**
+ * @summary Initializes the inline and bulk post editor.
+ *
+ * Binds event handlers to the escape key to close the inline editor
+ * and to the save and close buttons. Changes DOM to be ready for inline
+ * editing. Adds event handler to bulk edit.
+ *
+ * @memberof inlineEditPost
+ * @since 2.7.0
+ *
+ * @returns {void}
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> init : function(){
</span><span class="cx" style="display: block; padding: 0 10px"> var t = this, qeRow = $('#inline-edit'), bulkRow = $('#bulk-edit');
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> t.type = $('table.widefat').hasClass('pages') ? 'page' : 'post';
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Post id prefix.
</ins><span class="cx" style="display: block; padding: 0 10px"> t.what = '#post-';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // prepare the edit rows
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @summary Bind escape key to revert the changes and close the quick editor.
+ *
+ * @returns {boolean} The result of revert.
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> qeRow.keyup(function(e){
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Revert changes if escape key is pressed.
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( e.which === 27 ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return inlineEditPost.revert();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> });
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ /**
+ * @summary Bind escape key to revert the changes and close the bulk editor.
+ *
+ * @returns {boolean} The result of revert.
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> bulkRow.keyup(function(e){
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Revert changes if escape key is pressed.
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( e.which === 27 ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return inlineEditPost.revert();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> });
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @summary Revert changes and close the quick editor if the cancel button is clicked.
+ *
+ * @returns {boolean} The result of revert.
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> $( '.cancel', qeRow ).click( function() {
</span><span class="cx" style="display: block; padding: 0 10px"> return inlineEditPost.revert();
</span><span class="cx" style="display: block; padding: 0 10px"> });
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ /**
+ * @summary Save changes in the quick editor if the save(named: update) button is clicked.
+ *
+ * @returns {boolean} The result of save.
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> $( '.save', qeRow ).click( function() {
</span><span class="cx" style="display: block; padding: 0 10px"> return inlineEditPost.save(this);
</span><span class="cx" style="display: block; padding: 0 10px"> });
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ /**
+ * @summary If enter is pressed, and the target is not the cancel button, save the post.
+ *
+ * @returns {boolean} The result of save.
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> $('td', qeRow).keydown(function(e){
</span><span class="cx" style="display: block; padding: 0 10px"> if ( e.which === 13 && ! $( e.target ).hasClass( 'cancel' ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return inlineEditPost.save(this);
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> });
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @summary Revert changes and close the bulk editor if the cancel button is clicked.
+ *
+ * @returns {boolean} The result of revert.
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> $( '.cancel', bulkRow ).click( function() {
</span><span class="cx" style="display: block; padding: 0 10px"> return inlineEditPost.revert();
</span><span class="cx" style="display: block; padding: 0 10px"> });
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @summary Disables the password input field when the private post checkbox is checked.
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> $('#inline-edit .inline-edit-private input[value="private"]').click( function(){
</span><span class="cx" style="display: block; padding: 0 10px"> var pw = $('input.inline-edit-password-input');
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $(this).prop('checked') ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -48,7 +119,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> });
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // add events
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @summary Bind click event to the .editinline link which opens the quick editor.
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> $('#the-list').on( 'click', 'a.editinline', function( e ) {
</span><span class="cx" style="display: block; padding: 0 10px"> e.preventDefault();
</span><span class="cx" style="display: block; padding: 0 10px"> inlineEditPost.edit(this);
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -62,6 +135,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $('select[name="_status"] option[value="future"]', bulkRow).remove();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @summary Adds onclick events to the apply buttons.
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> $('#doaction, #doaction2').click(function(e){
</span><span class="cx" style="display: block; padding: 0 10px"> var n;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -77,21 +153,46 @@
</span><span class="cx" style="display: block; padding: 0 10px"> });
</span><span class="cx" style="display: block; padding: 0 10px"> },
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @summary Toggles the quick edit window.
+ *
+ * Hides the window when it's active and shows the window when inactive.
+ *
+ * @memberof inlineEditPost
+ * @since 2.7.0
+ *
+ * @param {Object} el Element within a post table row.
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> toggle : function(el){
</span><span class="cx" style="display: block; padding: 0 10px"> var t = this;
</span><span class="cx" style="display: block; padding: 0 10px"> $( t.what + t.getId( el ) ).css( 'display' ) === 'none' ? t.revert() : t.edit( el );
</span><span class="cx" style="display: block; padding: 0 10px"> },
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @summary Creates the bulk editor row to edit multiple posts at once.
+ *
+ * @memberof inlineEditPost
+ * @since 2.7.0
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> setBulk : function(){
</span><span class="cx" style="display: block; padding: 0 10px"> var te = '', type = this.type, c = true;
</span><span class="cx" style="display: block; padding: 0 10px"> this.revert();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $( '#bulk-edit td' ).attr( 'colspan', $( 'th:visible, td:visible', '.widefat:first thead' ).length );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> // Insert the editor at the top of the table with an empty row above to maintain zebra striping.
</span><span class="cx" style="display: block; padding: 0 10px"> $('table.widefat tbody').prepend( $('#bulk-edit') ).prepend('<tr class="hidden"></tr>');
</span><span class="cx" style="display: block; padding: 0 10px"> $('#bulk-edit').addClass('inline-editor').show();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @summary Create a HTML div with the title and a delete link(cross-icon) for each selected post.
+ *
+ * Get the selected posts based on the checked checkboxes in the post table.
+ * Create a HTML div with the title and a link(delete-icon) for each selected post.
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> $( 'tbody th.check-column input[type="checkbox"]' ).each( function() {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ // If the checkbox for a post is selected, add the post to the edit list.
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $(this).prop('checked') ) {
</span><span class="cx" style="display: block; padding: 0 10px"> c = false;
</span><span class="cx" style="display: block; padding: 0 10px"> var id = $(this).val(), theTitle;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -100,11 +201,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> });
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // If no checkboxes where checked, just hide the quick/bulk edit rows.
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( c ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return this.revert();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Add onclick events to the delete-icons in the bulk editors the post title list.
</ins><span class="cx" style="display: block; padding: 0 10px"> $('#bulk-titles').html(te);
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @summary Binds on click events to the checkboxes before the posts in the table.
+ *
+ * @listens click
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> $('#bulk-titles a').click(function(){
</span><span class="cx" style="display: block; padding: 0 10px"> var id = $(this).attr('id').substr(1);
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -112,7 +220,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $('#ttle'+id).remove();
</span><span class="cx" style="display: block; padding: 0 10px"> });
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // enable autocomplete for tags
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Enable auto-complete for tags when editing posts.
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( 'post' === type ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $( 'tr.inline-editor textarea[data-wp-taxonomy]' ).each( function ( i, element ) {
</span><span class="cx" style="display: block; padding: 0 10px"> /*
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -127,9 +235,21 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $( element ).wpTagsSuggest();
</span><span class="cx" style="display: block; padding: 0 10px"> } );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ // Scrolls to the top of the table where the editor is rendered.
</ins><span class="cx" style="display: block; padding: 0 10px"> $('html, body').animate( { scrollTop: 0 }, 'fast' );
</span><span class="cx" style="display: block; padding: 0 10px"> },
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @summary Creates a quick edit window for the post that has been clicked.
+ *
+ * @memberof inlineEditPost
+ * @since 2.7.0
+ *
+ * @param {number|Object} id The id of the clicked post or an element within a post
+ * table row.
+ * @returns {boolean} Always returns false at the end of execution.
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> edit : function(id) {
</span><span class="cx" style="display: block; padding: 0 10px"> var t = this, fields, editRow, rowData, status, pageOpt, pageLevel, nextPage, pageLoop = true, nextLevel, f, val, pw;
</span><span class="cx" style="display: block; padding: 0 10px"> t.revert();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -143,16 +263,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> fields.push('post_parent');
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // add the new edit row with an extra blank row underneath to maintain zebra striping.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Add the new edit row with an extra blank row underneath to maintain zebra striping.
</ins><span class="cx" style="display: block; padding: 0 10px"> editRow = $('#inline-edit').clone(true);
</span><span class="cx" style="display: block; padding: 0 10px"> $( 'td', editRow ).attr( 'colspan', $( 'th:visible, td:visible', '.widefat:first thead' ).length );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $(t.what+id).removeClass('is-expanded').hide().after(editRow).after('<tr class="hidden"></tr>');
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // populate the data
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Populate fields in the quick edit window.
</ins><span class="cx" style="display: block; padding: 0 10px"> rowData = $('#inline_'+id);
</span><span class="cx" style="display: block; padding: 0 10px"> if ( !$(':input[name="post_author"] option[value="' + $('.post_author', rowData).text() + '"]', editRow).val() ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // author no longer has edit caps, so we need to add them to the list of authors
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ // The post author no longer has edit capabilities, so we need to add them to the list of authors.
</ins><span class="cx" style="display: block; padding: 0 10px"> $(':input[name="post_author"]', editRow).prepend('<option value="' + $('.post_author', rowData).text() + '">' + $('#' + t.type + '-' + id + ' .author').text() + '</option>');
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $( ':input[name="post_author"] option', editRow ).length === 1 ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -161,7 +282,12 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> for ( f = 0; f < fields.length; f++ ) {
</span><span class="cx" style="display: block; padding: 0 10px"> val = $('.'+fields[f], rowData);
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Deal with Twemoji
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ /**
+ * @summary Replaces the image for a Twemoji(Twitter emoji) with it's alternate text.
+ *
+ * @returns Alternate text from the image.
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> val.find( 'img' ).replaceWith( function() { return this.alt; } );
</span><span class="cx" style="display: block; padding: 0 10px"> val = val.text();
</span><span class="cx" style="display: block; padding: 0 10px"> $(':input[name="' + fields[f] + '"]', editRow).val( val );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -177,7 +303,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $( 'input[name="sticky"]', editRow ).prop( 'checked', true );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // hierarchical taxonomies
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @summary Creates the select boxes for the categories.
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> $('.post_category', rowData).each(function(){
</span><span class="cx" style="display: block; padding: 0 10px"> var taxname,
</span><span class="cx" style="display: block; padding: 0 10px"> term_ids = $(this).text();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -188,7 +316,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> });
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- //flat taxonomies
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @summary Gets all the taxonomies for live auto-fill suggestions.
+ * When typing the name of a tag.
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> $('.tags_input', rowData).each(function(){
</span><span class="cx" style="display: block; padding: 0 10px"> var terms = $(this),
</span><span class="cx" style="display: block; padding: 0 10px"> taxname = $(this).attr('id').replace('_' + id, ''),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -208,7 +339,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> textarea.wpTagsSuggest();
</span><span class="cx" style="display: block; padding: 0 10px"> });
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // handle the post status
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Handle the post status.
</ins><span class="cx" style="display: block; padding: 0 10px"> status = $('._status', rowData).text();
</span><span class="cx" style="display: block; padding: 0 10px"> if ( 'future' !== status ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $('select[name="_status"] option[value="future"]', editRow).remove();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -220,7 +351,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> pw.val( '' ).prop( 'disabled', true );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // remove the current page and children from the parent dropdown
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Remove the current page and children from the parent dropdown.
</ins><span class="cx" style="display: block; padding: 0 10px"> pageOpt = $('select[name="post_parent"] option[value="' + id + '"]', editRow);
</span><span class="cx" style="display: block; padding: 0 10px"> if ( pageOpt.length > 0 ) {
</span><span class="cx" style="display: block; padding: 0 10px"> pageLevel = pageOpt[0].className.split('-')[1];
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -249,7 +380,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> },
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Ajax saving is only for Quick Edit.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @summary Saves the changes made in the quick edit window to the post.
+ * AJAX saving is only for Quick Edit and not for bulk edit.
+ *
+ * @since 2.7.0
+ *
+ * @param {int} id The id for the post that has been changed.
+ * @returns {boolean} false, so the form does not submit when pressing
+ * Enter on a focused field.
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> save : function(id) {
</span><span class="cx" style="display: block; padding: 0 10px"> var params, fields, page = $('.post_status_page').val() || '';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -270,7 +410,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> fields = $('#edit-'+id).find(':input').serialize();
</span><span class="cx" style="display: block; padding: 0 10px"> params = fields + '&' + $.param(params);
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // make ajax request
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Make ajax request.
</ins><span class="cx" style="display: block; padding: 0 10px"> $.post( ajaxurl, params,
</span><span class="cx" style="display: block; padding: 0 10px"> function(r) {
</span><span class="cx" style="display: block; padding: 0 10px"> var $errorSpan = $( '#edit-' + id + ' .inline-edit-save .error' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -298,11 +438,19 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> },
</span><span class="cx" style="display: block; padding: 0 10px"> 'html');
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> // Prevent submitting the form when pressing Enter on a focused field.
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> },
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Revert is for both Quick Edit and Bulk Edit.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @summary Hides and empties the Quick Edit and/or Bulk Edit windows.
+ *
+ * @memberof inlineEditPost
+ * @since 2.7.0
+ *
+ * @returns {boolean} Always returns false.
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> revert : function(){
</span><span class="cx" style="display: block; padding: 0 10px"> var $tableWideFat = $( '.widefat' ),
</span><span class="cx" style="display: block; padding: 0 10px"> id = $( '.inline-editor', $tableWideFat ).attr( 'id' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -312,14 +460,22 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $( '.ac_results' ).hide();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( 'bulk-edit' === id ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ // Hide the bulk editor.
</ins><span class="cx" style="display: block; padding: 0 10px"> $( '#bulk-edit', $tableWideFat ).removeClass( 'inline-editor' ).hide().siblings( '.hidden' ).remove();
</span><span class="cx" style="display: block; padding: 0 10px"> $('#bulk-titles').empty();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ // Store the empty bulk editor in a hidden element.
</ins><span class="cx" style="display: block; padding: 0 10px"> $('#inlineedit').append( $('#bulk-edit') );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> // Move focus back to the Bulk Action button that was activated.
</span><span class="cx" style="display: block; padding: 0 10px"> $( '#' + inlineEditPost.whichBulkButtonId ).focus();
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ // Remove both the inline-editor and its hidden tr siblings.
</ins><span class="cx" style="display: block; padding: 0 10px"> $('#'+id).siblings('tr.hidden').addBack().remove();
</span><span class="cx" style="display: block; padding: 0 10px"> id = id.substr( id.lastIndexOf('-') + 1 );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> // Show the post row and move focus back to the Quick Edit link.
</span><span class="cx" style="display: block; padding: 0 10px"> $( this.what + id ).show().find( '.editinline' ).focus();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -328,6 +484,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> },
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @summary Gets the id for a the post that you want to quick edit from the row
+ * in the quick edit table.
+ *
+ * @memberof inlineEditPost
+ * @since 2.7.0
+ *
+ * @param {Object} o DOM row object to get the id for.
+ * @returns {string} The post id extracted from the table row in the object.
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> getId : function(o) {
</span><span class="cx" style="display: block; padding: 0 10px"> var id = $(o).closest('tr').attr('id'),
</span><span class="cx" style="display: block; padding: 0 10px"> parts = id.split('-');
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -337,7 +503,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $( document ).ready( function(){ inlineEditPost.init(); } );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-// Show/hide locks on posts
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+// Show/hide locks on posts.
</ins><span class="cx" style="display: block; padding: 0 10px"> $( document ).on( 'heartbeat-tick.wp-check-locked-posts', function( e, data ) {
</span><span class="cx" style="display: block; padding: 0 10px"> var locked = data['wp-check-locked-posts'] || {};
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -374,6 +540,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> data['wp-check-locked-posts'] = check;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }).ready( function() {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> // Set the heartbeat interval to 15 sec.
</span><span class="cx" style="display: block; padding: 0 10px"> if ( typeof wp !== 'undefined' && wp.heartbeat ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp.heartbeat.interval( 15 );
</span></span></pre>
</div>
</div>
</body>
</html>