Select Git revision
inline-edit-post.js 16.03 KiB
/* global inlineEditL10n, ajaxurl, typenow */
/**
* This file contains the functions needed for the inline editing of posts.
*
* @since 2.7.0
*/
window.wp = window.wp || {};
/**
* 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.
*
*/
var inlineEditPost;
( function( $, wp ) {
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}
*/
init : function(){
var t = this, qeRow = $('#inline-edit'), bulkRow = $('#bulk-edit');
t.type = $('table.widefat').hasClass('pages') ? 'page' : 'post';
// Post id prefix.
t.what = '#post-';
/**
* @summary Bind escape key to revert the changes and close the quick editor.
*
* @returns {boolean} The result of revert.
*/
qeRow.keyup(function(e){
// Revert changes if escape key is pressed.
if ( e.which === 27 ) {
return inlineEditPost.revert();
}
});
/**
* @summary Bind escape key to revert the changes and close the bulk editor.
*
* @returns {boolean} The result of revert.
*/
bulkRow.keyup(function(e){
// Revert changes if escape key is pressed.
if ( e.which === 27 ) {
return inlineEditPost.revert();
}
});