| 1 |
/* global metasyncQuickEditData, inlineEditPost, jQuery */ |
| 2 |
/** |
| 3 |
* MetaSync Quick Edit Badge |
| 4 |
* |
| 5 |
* Extracted for Phase 5, #887. |
| 6 |
* Copies the MetaSync HTML badge from the posts list into the |
| 7 |
* WordPress quick-edit panel. |
| 8 |
* |
| 9 |
* Localized object: metasyncQuickEditData |
| 10 |
* - standardPageLabel (string) Translated "Standard page" label |
| 11 |
* |
| 12 |
* @since Phase 5 |
| 13 |
*/ |
| 14 |
(function ($) { |
| 15 |
// Only runs on post/page list screens where inlineEditPost exists |
| 16 |
if (typeof inlineEditPost === 'undefined') return; |
| 17 |
|
| 18 |
// Copy badge from posts list to quick edit panel |
| 19 |
var wp_inline_edit = inlineEditPost.edit; |
| 20 |
inlineEditPost.edit = function (id) { |
| 21 |
wp_inline_edit.apply(this, arguments); |
| 22 |
|
| 23 |
var post_id = 0; |
| 24 |
if (typeof (id) === 'object') { |
| 25 |
post_id = parseInt(this.getId(id)); |
| 26 |
} |
| 27 |
|
| 28 |
if (post_id > 0) { |
| 29 |
var $row = $('#post-' + post_id); |
| 30 |
var $badge = $row.find('.metasync-html-badge').clone(); |
| 31 |
|
| 32 |
if ($badge.length) { |
| 33 |
$('.metasync-quick-edit-badge-container').html($badge); |
| 34 |
} else { |
| 35 |
$('.metasync-quick-edit-badge-container').html('<em>' + metasyncQuickEditData.standardPageLabel + '</em>'); |
| 36 |
} |
| 37 |
} |
| 38 |
}; |
| 39 |
})(jQuery); |
| 40 |
|