Skip to content
Snippets Groups Projects
Select Git revision
  • ed80d28b52a2d0a5bfd1a946ed3b679d0587c632
  • master default
  • renovate/golang.org-x-crypto-0.x
  • renovate/go-1.x
  • renovate/golang.org-x-sync-0.x
  • renovate/opentelemetry-go-monorepo
  • renovate/github.com-go-webauthn-webauthn-0.x
  • renovate/github.com-mattn-go-sqlite3-1.x
  • renovate/github.com-go-ldap-ldap-v3-3.x
  • renovate/github.com-prometheus-client_golang-1.x
  • renovate/github.com-google-go-cmp-0.x
  • renovate/github.com-lunixbochs-struc-digest
  • renovate/github.com-duo-labs-webauthn-digest
13 results

main.go

Blame
  • 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();
    			}
    		});