author | ymh <ymh.work@gmail.com> |
Tue, 27 Sep 2022 16:37:53 +0200 | |
changeset 19 | 3d72ae0968f4 |
parent 18 | be944660c56a |
child 21 | 48c4eec2b7e6 |
permissions | -rw-r--r-- |
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 contains the functions needed for the inline editing of posts. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4 |
* @since 2.7.0 |
9 | 5 |
* @output wp-admin/js/inline-edit-post.js |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6 |
*/ |
5 | 7 |
|
16 | 8 |
/* global ajaxurl, typenow, inlineEditPost */ |
9 | 9 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
10 |
window.wp = window.wp || {}; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
11 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
12 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
13 |
* Manages the quick edit and bulk edit windows for editing posts or pages. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
14 |
* |
9 | 15 |
* @namespace inlineEditPost |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
16 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
17 |
* @since 2.7.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
18 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
19 |
* @type {Object} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
20 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
21 |
* @property {string} type The type of inline editor. |
16 | 22 |
* @property {string} what The prefix before the post ID. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
23 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
24 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
25 |
( function( $, wp ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
26 |
|
9 | 27 |
window.inlineEditPost = { |
0 | 28 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
29 |
/** |
9 | 30 |
* Initializes the inline and bulk post editor. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
31 |
* |
16 | 32 |
* Binds event handlers to the Escape key to close the inline editor |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
33 |
* and to the save and close buttons. Changes DOM to be ready for inline |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
34 |
* editing. Adds event handler to bulk edit. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
35 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
36 |
* @since 2.7.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
37 |
* |
16 | 38 |
* @memberof inlineEditPost |
39 |
* |
|
40 |
* @return {void} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
41 |
*/ |
0 | 42 |
init : function(){ |
43 |
var t = this, qeRow = $('#inline-edit'), bulkRow = $('#bulk-edit'); |
|
44 |
||
45 |
t.type = $('table.widefat').hasClass('pages') ? 'page' : 'post'; |
|
16 | 46 |
// Post ID prefix. |
0 | 47 |
t.what = '#post-'; |
48 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
49 |
/** |
16 | 50 |
* Binds the Escape key to revert the changes and close the quick editor. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
51 |
* |
16 | 52 |
* @return {boolean} The result of revert. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
53 |
*/ |
18 | 54 |
qeRow.on( 'keyup', function(e){ |
16 | 55 |
// Revert changes if Escape key is pressed. |
5 | 56 |
if ( e.which === 27 ) { |
0 | 57 |
return inlineEditPost.revert(); |
5 | 58 |
} |
0 | 59 |
}); |
60 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
61 |
/** |
16 | 62 |
* Binds the Escape key to revert the changes and close the bulk editor. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
63 |
* |
16 | 64 |
* @return {boolean} The result of revert. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
65 |
*/ |
18 | 66 |
bulkRow.on( 'keyup', function(e){ |
16 | 67 |
// Revert changes if Escape key is pressed. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
68 |
if ( e.which === 27 ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
69 |
return inlineEditPost.revert(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
70 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
71 |
}); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
72 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
73 |
/** |
9 | 74 |
* Reverts changes and close the quick editor if the cancel button is clicked. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
75 |
* |
16 | 76 |
* @return {boolean} The result of revert. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
77 |
*/ |
18 | 78 |
$( '.cancel', qeRow ).on( 'click', function() { |
0 | 79 |
return inlineEditPost.revert(); |
80 |
}); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
81 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
82 |
/** |
9 | 83 |
* Saves changes in the quick editor if the save(named: update) button is clicked. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
84 |
* |
16 | 85 |
* @return {boolean} The result of save. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
86 |
*/ |
18 | 87 |
$( '.save', qeRow ).on( 'click', function() { |
0 | 88 |
return inlineEditPost.save(this); |
89 |
}); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
90 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
91 |
/** |
16 | 92 |
* If Enter is pressed, and the target is not the cancel button, save the post. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
93 |
* |
16 | 94 |
* @return {boolean} The result of save. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
95 |
*/ |
18 | 96 |
$('td', qeRow).on( 'keydown', function(e){ |
5 | 97 |
if ( e.which === 13 && ! $( e.target ).hasClass( 'cancel' ) ) { |
0 | 98 |
return inlineEditPost.save(this); |
5 | 99 |
} |
0 | 100 |
}); |
101 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
102 |
/** |
9 | 103 |
* Reverts changes and close the bulk editor if the cancel button is clicked. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
104 |
* |
16 | 105 |
* @return {boolean} The result of revert. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
106 |
*/ |
18 | 107 |
$( '.cancel', bulkRow ).on( 'click', function() { |
0 | 108 |
return inlineEditPost.revert(); |
109 |
}); |
|
110 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
111 |
/** |
9 | 112 |
* Disables the password input field when the private post checkbox is checked. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
113 |
*/ |
18 | 114 |
$('#inline-edit .inline-edit-private input[value="private"]').on( 'click', function(){ |
0 | 115 |
var pw = $('input.inline-edit-password-input'); |
116 |
if ( $(this).prop('checked') ) { |
|
117 |
pw.val('').prop('disabled', true); |
|
118 |
} else { |
|
119 |
pw.prop('disabled', false); |
|
120 |
} |
|
121 |
}); |
|
122 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
123 |
/** |
9 | 124 |
* Binds click event to the .editinline button which opens the quick editor. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
125 |
*/ |
9 | 126 |
$( '#the-list' ).on( 'click', '.editinline', function() { |
127 |
$( this ).attr( 'aria-expanded', 'true' ); |
|
128 |
inlineEditPost.edit( this ); |
|
0 | 129 |
}); |
130 |
||
5 | 131 |
$('#bulk-edit').find('fieldset:first').after( |
0 | 132 |
$('#inline-edit fieldset.inline-edit-categories').clone() |
133 |
).siblings( 'fieldset:last' ).prepend( |
|
19 | 134 |
$( '#inline-edit .inline-edit-tags-wrap' ).clone() |
0 | 135 |
); |
136 |
||
137 |
$('select[name="_status"] option[value="future"]', bulkRow).remove(); |
|
138 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
139 |
/** |
9 | 140 |
* Adds onclick events to the apply buttons. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
141 |
*/ |
18 | 142 |
$('#doaction').on( 'click', function(e){ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
143 |
var n; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
144 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
145 |
t.whichBulkButtonId = $( this ).attr( 'id' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
146 |
n = t.whichBulkButtonId.substr( 2 ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
147 |
|
5 | 148 |
if ( 'edit' === $( 'select[name="' + n + '"]' ).val() ) { |
0 | 149 |
e.preventDefault(); |
150 |
t.setBulk(); |
|
151 |
} else if ( $('form#posts-filter tr.inline-editor').length > 0 ) { |
|
152 |
t.revert(); |
|
153 |
} |
|
154 |
}); |
|
155 |
}, |
|
156 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
157 |
/** |
9 | 158 |
* Toggles the quick edit window, hiding it when it's active and showing it when |
159 |
* inactive. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
160 |
* |
16 | 161 |
* @since 2.7.0 |
162 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
163 |
* @memberof inlineEditPost |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
164 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
165 |
* @param {Object} el Element within a post table row. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
166 |
*/ |
0 | 167 |
toggle : function(el){ |
168 |
var t = this; |
|
5 | 169 |
$( t.what + t.getId( el ) ).css( 'display' ) === 'none' ? t.revert() : t.edit( el ); |
0 | 170 |
}, |
171 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
172 |
/** |
9 | 173 |
* Creates the bulk editor row to edit multiple posts at once. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
174 |
* |
16 | 175 |
* @since 2.7.0 |
176 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
177 |
* @memberof inlineEditPost |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
178 |
*/ |
0 | 179 |
setBulk : function(){ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
180 |
var te = '', type = this.type, c = true; |
0 | 181 |
this.revert(); |
182 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
183 |
$( '#bulk-edit td' ).attr( 'colspan', $( 'th:visible, td:visible', '.widefat:first thead' ).length ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
184 |
|
5 | 185 |
// Insert the editor at the top of the table with an empty row above to maintain zebra striping. |
186 |
$('table.widefat tbody').prepend( $('#bulk-edit') ).prepend('<tr class="hidden"></tr>'); |
|
0 | 187 |
$('#bulk-edit').addClass('inline-editor').show(); |
188 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
189 |
/** |
9 | 190 |
* Create a HTML div with the title and a link(delete-icon) for each selected |
191 |
* post. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
192 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
193 |
* Get the selected posts based on the checked checkboxes in the post table. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
194 |
*/ |
5 | 195 |
$( 'tbody th.check-column input[type="checkbox"]' ).each( function() { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
196 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
197 |
// If the checkbox for a post is selected, add the post to the edit list. |
0 | 198 |
if ( $(this).prop('checked') ) { |
199 |
c = false; |
|
19 | 200 |
var id = $( this ).val(), |
201 |
theTitle = $( '#inline_' + id + ' .post_title' ).html() || wp.i18n.__( '(no title)' ), |
|
202 |
buttonVisuallyHiddenText = wp.i18n.sprintf( |
|
203 |
/* translators: %s: Post title. */ |
|
204 |
wp.i18n.__( 'Remove “%s” 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>'; |
|
0 | 209 |
} |
210 |
}); |
|
211 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
212 |
// If no checkboxes where checked, just hide the quick/bulk edit rows. |
5 | 213 |
if ( c ) { |
0 | 214 |
return this.revert(); |
5 | 215 |
} |
0 | 216 |
|
19 | 217 |
// Populate the list of items to bulk edit. |
218 |
$( '#bulk-titles' ).html( '<ul id="bulk-titles-list" role="list">' + te + '</ul>' ); |
|
219 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
220 |
/** |
19 | 221 |
* Binds on click events to handle the list of items to bulk edit. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
222 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
223 |
* @listens click |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
224 |
*/ |
19 | 225 |
$( '#bulk-titles .ntdelbutton' ).click( function() { |
226 |
var $this = $( this ), |
|
227 |
id = $this.attr( 'id' ).substr( 1 ), |
|
228 |
$prev = $this.parent().prev().children( '.ntdelbutton' ), |
|
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' ); |
|
0 | 234 |
|
19 | 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 |
} |
|
0 | 245 |
}); |
246 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
247 |
// Enable auto-complete for tags when editing posts. |
5 | 248 |
if ( 'post' === type ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
249 |
$( 'tr.inline-editor textarea[data-wp-taxonomy]' ).each( function ( i, element ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
250 |
/* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
251 |
* While Quick Edit clones the form each time, Bulk Edit always re-uses |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
252 |
* the same form. Let's check if an autocomplete instance already exists. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
253 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
254 |
if ( $( element ).autocomplete( 'instance' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
255 |
// jQuery equivalent of `continue` within an `each()` loop. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
256 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
257 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
258 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
259 |
$( element ).wpTagsSuggest(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
260 |
} ); |
0 | 261 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
262 |
|
19 | 263 |
// Set initial focus on the Bulk Edit region. |
264 |
$( '#bulk-edit .inline-edit-wrapper' ).attr( 'tabindex', '-1' ).focus(); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
265 |
// Scrolls to the top of the table where the editor is rendered. |
0 | 266 |
$('html, body').animate( { scrollTop: 0 }, 'fast' ); |
267 |
}, |
|
268 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
269 |
/** |
9 | 270 |
* Creates a quick edit window for the post that has been clicked. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
271 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
272 |
* @since 2.7.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
273 |
* |
16 | 274 |
* @memberof inlineEditPost |
275 |
* |
|
276 |
* @param {number|Object} id The ID of the clicked post or an element within a post |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
277 |
* table row. |
16 | 278 |
* @return {boolean} Always returns false at the end of execution. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
279 |
*/ |
0 | 280 |
edit : function(id) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
281 |
var t = this, fields, editRow, rowData, status, pageOpt, pageLevel, nextPage, pageLoop = true, nextLevel, f, val, pw; |
0 | 282 |
t.revert(); |
283 |
||
5 | 284 |
if ( typeof(id) === 'object' ) { |
0 | 285 |
id = t.getId(id); |
5 | 286 |
} |
0 | 287 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
288 |
fields = ['post_title', 'post_name', 'post_author', '_status', 'jj', 'mm', 'aa', 'hh', 'mn', 'ss', 'post_password', 'post_format', 'menu_order', 'page_template']; |
5 | 289 |
if ( t.type === 'page' ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
290 |
fields.push('post_parent'); |
5 | 291 |
} |
0 | 292 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
293 |
// Add the new edit row with an extra blank row underneath to maintain zebra striping. |
0 | 294 |
editRow = $('#inline-edit').clone(true); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
295 |
$( 'td', editRow ).attr( 'colspan', $( 'th:visible, td:visible', '.widefat:first thead' ).length ); |
0 | 296 |
|
19 | 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'); |
|
300 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
301 |
$(t.what+id).removeClass('is-expanded').hide().after(editRow).after('<tr class="hidden"></tr>'); |
0 | 302 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
303 |
// Populate fields in the quick edit window. |
0 | 304 |
rowData = $('#inline_'+id); |
305 |
if ( !$(':input[name="post_author"] option[value="' + $('.post_author', rowData).text() + '"]', editRow).val() ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
306 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
307 |
// The post author no longer has edit capabilities, so we need to add them to the list of authors. |
0 | 308 |
$(':input[name="post_author"]', editRow).prepend('<option value="' + $('.post_author', rowData).text() + '">' + $('#' + t.type + '-' + id + ' .author').text() + '</option>'); |
309 |
} |
|
5 | 310 |
if ( $( ':input[name="post_author"] option', editRow ).length === 1 ) { |
0 | 311 |
$('label.inline-edit-author', editRow).hide(); |
312 |
} |
|
313 |
||
314 |
for ( f = 0; f < fields.length; f++ ) { |
|
5 | 315 |
val = $('.'+fields[f], rowData); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
316 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
317 |
/** |
9 | 318 |
* Replaces the image for a Twemoji(Twitter emoji) with it's alternate text. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
319 |
* |
16 | 320 |
* @return {string} Alternate text from the image. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
321 |
*/ |
5 | 322 |
val.find( 'img' ).replaceWith( function() { return this.alt; } ); |
323 |
val = val.text(); |
|
324 |
$(':input[name="' + fields[f] + '"]', editRow).val( val ); |
|
0 | 325 |
} |
326 |
||
5 | 327 |
if ( $( '.comment_status', rowData ).text() === 'open' ) { |
328 |
$( 'input[name="comment_status"]', editRow ).prop( 'checked', true ); |
|
329 |
} |
|
330 |
if ( $( '.ping_status', rowData ).text() === 'open' ) { |
|
331 |
$( 'input[name="ping_status"]', editRow ).prop( 'checked', true ); |
|
332 |
} |
|
333 |
if ( $( '.sticky', rowData ).text() === 'sticky' ) { |
|
334 |
$( 'input[name="sticky"]', editRow ).prop( 'checked', true ); |
|
335 |
} |
|
0 | 336 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
337 |
/** |
9 | 338 |
* Creates the select boxes for the categories. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
339 |
*/ |
0 | 340 |
$('.post_category', rowData).each(function(){ |
5 | 341 |
var taxname, |
342 |
term_ids = $(this).text(); |
|
0 | 343 |
|
344 |
if ( term_ids ) { |
|
345 |
taxname = $(this).attr('id').replace('_'+id, ''); |
|
346 |
$('ul.'+taxname+'-checklist :checkbox', editRow).val(term_ids.split(',')); |
|
347 |
} |
|
348 |
}); |
|
349 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
350 |
/** |
9 | 351 |
* Gets all the taxonomies for live auto-fill suggestions when typing the name |
352 |
* of a tag. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
353 |
*/ |
0 | 354 |
$('.tags_input', rowData).each(function(){ |
5 | 355 |
var terms = $(this), |
0 | 356 |
taxname = $(this).attr('id').replace('_' + id, ''), |
357 |
textarea = $('textarea.tax_input_' + taxname, editRow), |
|
16 | 358 |
comma = wp.i18n._x( ',', 'tag delimiter' ).trim(); |
0 | 359 |
|
18 | 360 |
// Ensure the textarea exists. |
361 |
if ( ! textarea.length ) { |
|
362 |
return; |
|
363 |
} |
|
364 |
||
5 | 365 |
terms.find( 'img' ).replaceWith( function() { return this.alt; } ); |
366 |
terms = terms.text(); |
|
367 |
||
0 | 368 |
if ( terms ) { |
5 | 369 |
if ( ',' !== comma ) { |
0 | 370 |
terms = terms.replace(/,/g, comma); |
5 | 371 |
} |
0 | 372 |
textarea.val(terms); |
373 |
} |
|
374 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
375 |
textarea.wpTagsSuggest(); |
0 | 376 |
}); |
377 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
378 |
// Handle the post status. |
0 | 379 |
status = $('._status', rowData).text(); |
5 | 380 |
if ( 'future' !== status ) { |
0 | 381 |
$('select[name="_status"] option[value="future"]', editRow).remove(); |
5 | 382 |
} |
0 | 383 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
384 |
pw = $( '.inline-edit-password-input' ).prop( 'disabled', false ); |
5 | 385 |
if ( 'private' === status ) { |
386 |
$('input[name="keep_private"]', editRow).prop('checked', true); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
387 |
pw.val( '' ).prop( 'disabled', true ); |
0 | 388 |
} |
389 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
390 |
// Remove the current page and children from the parent dropdown. |
0 | 391 |
pageOpt = $('select[name="post_parent"] option[value="' + id + '"]', editRow); |
392 |
if ( pageOpt.length > 0 ) { |
|
393 |
pageLevel = pageOpt[0].className.split('-')[1]; |
|
394 |
nextPage = pageOpt; |
|
395 |
while ( pageLoop ) { |
|
396 |
nextPage = nextPage.next('option'); |
|
5 | 397 |
if ( nextPage.length === 0 ) { |
398 |
break; |
|
399 |
} |
|
400 |
||
0 | 401 |
nextLevel = nextPage[0].className.split('-')[1]; |
5 | 402 |
|
0 | 403 |
if ( nextLevel <= pageLevel ) { |
404 |
pageLoop = false; |
|
405 |
} else { |
|
406 |
nextPage.remove(); |
|
407 |
nextPage = pageOpt; |
|
408 |
} |
|
409 |
} |
|
410 |
pageOpt.remove(); |
|
411 |
} |
|
412 |
||
413 |
$(editRow).attr('id', 'edit-'+id).addClass('inline-editor').show(); |
|
18 | 414 |
$('.ptitle', editRow).trigger( 'focus' ); |
0 | 415 |
|
416 |
return false; |
|
417 |
}, |
|
418 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
419 |
/** |
9 | 420 |
* Saves the changes made in the quick edit window to the post. |
16 | 421 |
* Ajax saving is only for Quick Edit and not for bulk edit. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
422 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
423 |
* @since 2.7.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
424 |
* |
16 | 425 |
* @param {number} id The ID for the post that has been changed. |
426 |
* @return {boolean} False, so the form does not submit when pressing |
|
427 |
* Enter on a focused field. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
428 |
*/ |
0 | 429 |
save : function(id) { |
430 |
var params, fields, page = $('.post_status_page').val() || ''; |
|
431 |
||
5 | 432 |
if ( typeof(id) === 'object' ) { |
0 | 433 |
id = this.getId(id); |
5 | 434 |
} |
0 | 435 |
|
5 | 436 |
$( 'table.widefat .spinner' ).addClass( 'is-active' ); |
0 | 437 |
|
438 |
params = { |
|
439 |
action: 'inline-save', |
|
440 |
post_type: typenow, |
|
441 |
post_ID: id, |
|
442 |
edit_date: 'true', |
|
443 |
post_status: page |
|
444 |
}; |
|
445 |
||
5 | 446 |
fields = $('#edit-'+id).find(':input').serialize(); |
0 | 447 |
params = fields + '&' + $.param(params); |
448 |
||
16 | 449 |
// Make Ajax request. |
0 | 450 |
$.post( ajaxurl, params, |
451 |
function(r) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
452 |
var $errorNotice = $( '#edit-' + id + ' .inline-edit-save .notice-error' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
453 |
$error = $errorNotice.find( '.error' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
454 |
|
5 | 455 |
$( 'table.widefat .spinner' ).removeClass( 'is-active' ); |
0 | 456 |
|
457 |
if (r) { |
|
5 | 458 |
if ( -1 !== r.indexOf( '<tr' ) ) { |
459 |
$(inlineEditPost.what+id).siblings('tr.hidden').addBack().remove(); |
|
0 | 460 |
$('#edit-'+id).before(r).remove(); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
461 |
$( inlineEditPost.what + id ).hide().fadeIn( 400, function() { |
9 | 462 |
// Move focus back to the Quick Edit button. $( this ) is the row being animated. |
463 |
$( this ).find( '.editinline' ) |
|
464 |
.attr( 'aria-expanded', 'false' ) |
|
18 | 465 |
.trigger( 'focus' ); |
16 | 466 |
wp.a11y.speak( wp.i18n.__( 'Changes saved.' ) ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
467 |
}); |
0 | 468 |
} else { |
469 |
r = r.replace( /<.[^<>]*?>/g, '' ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
470 |
$errorNotice.removeClass( 'hidden' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
471 |
$error.html( r ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
472 |
wp.a11y.speak( $error.text() ); |
0 | 473 |
} |
474 |
} else { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
475 |
$errorNotice.removeClass( 'hidden' ); |
16 | 476 |
$error.text( wp.i18n.__( 'Error while saving the changes.' ) ); |
477 |
wp.a11y.speak( wp.i18n.__( 'Error while saving the changes.' ) ); |
|
0 | 478 |
} |
5 | 479 |
}, |
480 |
'html'); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
481 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
482 |
// Prevent submitting the form when pressing Enter on a focused field. |
0 | 483 |
return false; |
484 |
}, |
|
485 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
486 |
/** |
9 | 487 |
* Hides and empties the Quick Edit and/or Bulk Edit windows. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
488 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
489 |
* @since 2.7.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
490 |
* |
16 | 491 |
* @memberof inlineEditPost |
492 |
* |
|
493 |
* @return {boolean} Always returns false. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
494 |
*/ |
0 | 495 |
revert : function(){ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
496 |
var $tableWideFat = $( '.widefat' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
497 |
id = $( '.inline-editor', $tableWideFat ).attr( 'id' ); |
0 | 498 |
|
499 |
if ( id ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
500 |
$( '.spinner', $tableWideFat ).removeClass( 'is-active' ); |
0 | 501 |
|
5 | 502 |
if ( 'bulk-edit' === id ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
503 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
504 |
// Hide the bulk editor. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
505 |
$( '#bulk-edit', $tableWideFat ).removeClass( 'inline-editor' ).hide().siblings( '.hidden' ).remove(); |
5 | 506 |
$('#bulk-titles').empty(); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
507 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
508 |
// Store the empty bulk editor in a hidden element. |
0 | 509 |
$('#inlineedit').append( $('#bulk-edit') ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
510 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
511 |
// Move focus back to the Bulk Action button that was activated. |
18 | 512 |
$( '#' + inlineEditPost.whichBulkButtonId ).trigger( 'focus' ); |
0 | 513 |
} else { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
514 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
515 |
// Remove both the inline-editor and its hidden tr siblings. |
5 | 516 |
$('#'+id).siblings('tr.hidden').addBack().remove(); |
0 | 517 |
id = id.substr( id.lastIndexOf('-') + 1 ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
518 |
|
9 | 519 |
// Show the post row and move focus back to the Quick Edit button. |
520 |
$( this.what + id ).show().find( '.editinline' ) |
|
521 |
.attr( 'aria-expanded', 'false' ) |
|
18 | 522 |
.trigger( 'focus' ); |
0 | 523 |
} |
524 |
} |
|
525 |
||
526 |
return false; |
|
527 |
}, |
|
528 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
529 |
/** |
16 | 530 |
* Gets the ID for a the post that you want to quick edit from the row in the quick |
9 | 531 |
* edit table. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
532 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
533 |
* @since 2.7.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
534 |
* |
16 | 535 |
* @memberof inlineEditPost |
536 |
* |
|
537 |
* @param {Object} o DOM row object to get the ID for. |
|
538 |
* @return {string} The post ID extracted from the table row in the object. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
539 |
*/ |
0 | 540 |
getId : function(o) { |
541 |
var id = $(o).closest('tr').attr('id'), |
|
542 |
parts = id.split('-'); |
|
543 |
return parts[parts.length - 1]; |
|
544 |
} |
|
545 |
}; |
|
546 |
||
18 | 547 |
$( function() { inlineEditPost.init(); } ); |
0 | 548 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
549 |
// Show/hide locks on posts. |
18 | 550 |
$( function() { |
551 |
||
552 |
// Set the heartbeat interval to 15 seconds. |
|
553 |
if ( typeof wp !== 'undefined' && wp.heartbeat ) { |
|
554 |
wp.heartbeat.interval( 15 ); |
|
555 |
} |
|
556 |
}).on( 'heartbeat-tick.wp-check-locked-posts', function( e, data ) { |
|
0 | 557 |
var locked = data['wp-check-locked-posts'] || {}; |
558 |
||
559 |
$('#the-list tr').each( function(i, el) { |
|
560 |
var key = el.id, row = $(el), lock_data, avatar; |
|
561 |
||
562 |
if ( locked.hasOwnProperty( key ) ) { |
|
563 |
if ( ! row.hasClass('wp-locked') ) { |
|
564 |
lock_data = locked[key]; |
|
565 |
row.find('.column-title .locked-text').text( lock_data.text ); |
|
566 |
row.find('.check-column checkbox').prop('checked', false); |
|
567 |
||
568 |
if ( lock_data.avatar_src ) { |
|
16 | 569 |
avatar = $( '<img />', { |
570 |
'class': 'avatar avatar-18 photo', |
|
571 |
width: 18, |
|
572 |
height: 18, |
|
573 |
alt: '', |
|
574 |
src: lock_data.avatar_src, |
|
575 |
srcset: lock_data.avatar_src_2x ? lock_data.avatar_src_2x + ' 2x' : undefined |
|
576 |
} ); |
|
0 | 577 |
row.find('.column-title .locked-avatar').empty().append( avatar ); |
578 |
} |
|
579 |
row.addClass('wp-locked'); |
|
580 |
} |
|
581 |
} else if ( row.hasClass('wp-locked') ) { |
|
16 | 582 |
row.removeClass( 'wp-locked' ).find( '.locked-info span' ).empty(); |
0 | 583 |
} |
584 |
}); |
|
585 |
}).on( 'heartbeat-send.wp-check-locked-posts', function( e, data ) { |
|
586 |
var check = []; |
|
587 |
||
588 |
$('#the-list tr').each( function(i, el) { |
|
5 | 589 |
if ( el.id ) { |
0 | 590 |
check.push( el.id ); |
5 | 591 |
} |
0 | 592 |
}); |
593 |
||
5 | 594 |
if ( check.length ) { |
0 | 595 |
data['wp-check-locked-posts'] = check; |
5 | 596 |
} |
0 | 597 |
}); |
598 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
599 |
})( jQuery, window.wp ); |