wp/wp-admin/js/inline-edit-post.js
author ymh <ymh.work@gmail.com>
Tue, 15 Dec 2020 13:49:49 +0100
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 18 be944660c56a
permissions -rw-r--r--
update enmi-conf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
     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
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
     7
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
     8
/* global ajaxurl, typenow, inlineEditPost */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
     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
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    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
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    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
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    27
	window.inlineEditPost = {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    28
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    29
	/**
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    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
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    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
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    38
	 * @memberof inlineEditPost
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    39
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    40
	 * @return {void}
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    41
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    42
	init : function(){
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    43
		var t = this, qeRow = $('#inline-edit'), bulkRow = $('#bulk-edit');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    44
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    45
		t.type = $('table.widefat').hasClass('pages') ? 'page' : 'post';
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    46
		// Post ID prefix.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    47
		t.what = '#post-';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    48
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    49
		/**
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    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
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    52
		 * @return {boolean} The result of revert.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    53
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    54
		qeRow.keyup(function(e){
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    55
			// Revert changes if Escape key is pressed.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    56
			if ( e.which === 27 ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    57
				return inlineEditPost.revert();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    58
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    59
		});
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    60
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    61
		/**
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    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
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    64
		 * @return {boolean} The result of revert.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    65
		 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    66
		bulkRow.keyup(function(e){
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    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
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    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
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    76
		 * @return {boolean} The result of revert.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    77
		 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    78
		$( '.cancel', qeRow ).click( function() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    79
			return inlineEditPost.revert();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    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
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    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
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    85
		 * @return {boolean} The result of save.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    86
		 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    87
		$( '.save', qeRow ).click( function() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    88
			return inlineEditPost.save(this);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    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
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    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
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    94
		 * @return {boolean} The result of save.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    95
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    96
		$('td', qeRow).keydown(function(e){
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    97
			if ( e.which === 13 && ! $( e.target ).hasClass( 'cancel' ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    98
				return inlineEditPost.save(this);
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    99
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   100
		});
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   101
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   102
		/**
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   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
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   105
		 * @return {boolean} The result of revert.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   106
		 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   107
		$( '.cancel', bulkRow ).click( function() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   108
			return inlineEditPost.revert();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   109
		});
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   110
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   111
		/**
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   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
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   114
		$('#inline-edit .inline-edit-private input[value="private"]').click( function(){
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   115
			var pw = $('input.inline-edit-password-input');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   116
			if ( $(this).prop('checked') ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   117
				pw.val('').prop('disabled', true);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   118
			} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   119
				pw.prop('disabled', false);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   120
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   121
		});
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   122
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   123
		/**
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   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
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   126
		$( '#the-list' ).on( 'click', '.editinline', function() {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   127
			$( this ).attr( 'aria-expanded', 'true' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   128
			inlineEditPost.edit( this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   129
		});
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   130
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   131
		$('#bulk-edit').find('fieldset:first').after(
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   132
			$('#inline-edit fieldset.inline-edit-categories').clone()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   133
		).siblings( 'fieldset:last' ).prepend(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   134
			$('#inline-edit label.inline-edit-tags').clone()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   135
		);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   136
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   137
		$('select[name="_status"] option[value="future"]', bulkRow).remove();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   138
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   139
		/**
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   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
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   142
		$('#doaction, #doaction2').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
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   148
			if ( 'edit' === $( 'select[name="' + n + '"]' ).val() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   149
				e.preventDefault();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   150
				t.setBulk();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   151
			} else if ( $('form#posts-filter tr.inline-editor').length > 0 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   152
				t.revert();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   153
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   154
		});
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   155
	},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   156
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   157
	/**
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   158
	 * Toggles the quick edit window, hiding it when it's active and showing it when
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   159
	 * inactive.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   160
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   161
	 * @since 2.7.0
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   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
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   167
	toggle : function(el){
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   168
		var t = this;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   169
		$( t.what + t.getId( el ) ).css( 'display' ) === 'none' ? t.revert() : t.edit( el );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   170
	},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   171
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   172
	/**
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   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
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   175
	 * @since 2.7.0
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   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
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   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
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   181
		this.revert();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   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
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   185
		// Insert the editor at the top of the table with an empty row above to maintain zebra striping.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   186
		$('table.widefat tbody').prepend( $('#bulk-edit') ).prepend('<tr class="hidden"></tr>');
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   187
		$('#bulk-edit').addClass('inline-editor').show();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   188
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   189
		/**
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   190
		 * Create a HTML div with the title and a link(delete-icon) for each selected
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   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
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   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
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   198
			if ( $(this).prop('checked') ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   199
				c = false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   200
				var id = $(this).val(), theTitle;
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   201
				theTitle = $('#inline_'+id+' .post_title').html() || wp.i18n.__( '(no title)' );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   202
				te += '<div id="ttle'+id+'"><a id="_'+id+'" class="ntdelbutton" title="'+ wp.i18n.__( 'Remove From Bulk Edit' ) +'">X</a>'+theTitle+'</div>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   203
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   204
		});
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   205
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   206
		// If no checkboxes where checked, just hide the quick/bulk edit rows.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   207
		if ( c ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   208
			return this.revert();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   209
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   210
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   211
		// Add onclick events to the delete-icons in the bulk editors the post title list.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   212
		$('#bulk-titles').html(te);
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   213
		/**
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   214
		 * Binds on click events to the checkboxes before the posts in the table.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   215
		 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   216
		 * @listens click
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   217
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   218
		$('#bulk-titles a').click(function(){
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   219
			var id = $(this).attr('id').substr(1);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   220
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   221
			$('table.widefat input[value="' + id + '"]').prop('checked', false);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   222
			$('#ttle'+id).remove();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   223
		});
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   224
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   225
		// Enable auto-complete for tags when editing posts.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   226
		if ( 'post' === type ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   227
			$( '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
   228
				/*
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   229
				 * 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
   230
				 * 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
   231
				 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   232
				if ( $( element ).autocomplete( 'instance' ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   233
					// jQuery equivalent of `continue` within an `each()` loop.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   234
					return;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   235
				}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   236
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   237
				$( element ).wpTagsSuggest();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   238
			} );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   239
		}
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   240
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   241
		// Scrolls to the top of the table where the editor is rendered.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   242
		$('html, body').animate( { scrollTop: 0 }, 'fast' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   243
	},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   244
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   245
	/**
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   246
	 * 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
   247
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   248
	 * @since 2.7.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   249
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   250
	 * @memberof inlineEditPost
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   251
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   252
	 * @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
   253
	 *                           table row.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   254
	 * @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
   255
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   256
	edit : function(id) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   257
		var t = this, fields, editRow, rowData, status, pageOpt, pageLevel, nextPage, pageLoop = true, nextLevel, f, val, pw;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   258
		t.revert();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   259
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   260
		if ( typeof(id) === 'object' ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   261
			id = t.getId(id);
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   262
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   263
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   264
		fields = ['post_title', 'post_name', 'post_author', '_status', 'jj', 'mm', 'aa', 'hh', 'mn', 'ss', 'post_password', 'post_format', 'menu_order', 'page_template'];
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   265
		if ( t.type === 'page' ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   266
			fields.push('post_parent');
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   267
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   268
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   269
		// Add the new edit row with an extra blank row underneath to maintain zebra striping.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   270
		editRow = $('#inline-edit').clone(true);
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   271
		$( 'td', editRow ).attr( 'colspan', $( 'th:visible, td:visible', '.widefat:first thead' ).length );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   272
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   273
		$(t.what+id).removeClass('is-expanded').hide().after(editRow).after('<tr class="hidden"></tr>');
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   274
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   275
		// Populate fields in the quick edit window.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   276
		rowData = $('#inline_'+id);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   277
		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
   278
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   279
			// The post author no longer has edit capabilities, so we need to add them to the list of authors.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   280
			$(':input[name="post_author"]', editRow).prepend('<option value="' + $('.post_author', rowData).text() + '">' + $('#' + t.type + '-' + id + ' .author').text() + '</option>');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   281
		}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   282
		if ( $( ':input[name="post_author"] option', editRow ).length === 1 ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   283
			$('label.inline-edit-author', editRow).hide();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   284
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   285
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   286
		for ( f = 0; f < fields.length; f++ ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   287
			val = $('.'+fields[f], rowData);
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   288
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   289
			/**
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   290
			 * 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
   291
			 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   292
			 * @return {string} Alternate text from the image.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   293
			 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   294
			val.find( 'img' ).replaceWith( function() { return this.alt; } );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   295
			val = val.text();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   296
			$(':input[name="' + fields[f] + '"]', editRow).val( val );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   297
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   298
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   299
		if ( $( '.comment_status', rowData ).text() === 'open' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   300
			$( 'input[name="comment_status"]', editRow ).prop( 'checked', true );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   301
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   302
		if ( $( '.ping_status', rowData ).text() === 'open' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   303
			$( 'input[name="ping_status"]', editRow ).prop( 'checked', true );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   304
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   305
		if ( $( '.sticky', rowData ).text() === 'sticky' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   306
			$( 'input[name="sticky"]', editRow ).prop( 'checked', true );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   307
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   308
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   309
		/**
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   310
		 * Creates the select boxes for the categories.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   311
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   312
		$('.post_category', rowData).each(function(){
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   313
			var taxname,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   314
				term_ids = $(this).text();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   315
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   316
			if ( term_ids ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   317
				taxname = $(this).attr('id').replace('_'+id, '');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   318
				$('ul.'+taxname+'-checklist :checkbox', editRow).val(term_ids.split(','));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   319
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   320
		});
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   321
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   322
		/**
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   323
		 * Gets all the taxonomies for live auto-fill suggestions when typing the name
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   324
		 * of a tag.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   325
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   326
		$('.tags_input', rowData).each(function(){
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   327
			var terms = $(this),
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   328
				taxname = $(this).attr('id').replace('_' + id, ''),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   329
				textarea = $('textarea.tax_input_' + taxname, editRow),
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   330
				comma = wp.i18n._x( ',', 'tag delimiter' ).trim();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   331
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   332
			terms.find( 'img' ).replaceWith( function() { return this.alt; } );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   333
			terms = terms.text();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   334
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   335
			if ( terms ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   336
				if ( ',' !== comma ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   337
					terms = terms.replace(/,/g, comma);
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   338
				}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   339
				textarea.val(terms);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   340
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   341
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   342
			textarea.wpTagsSuggest();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   343
		});
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   344
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   345
		// Handle the post status.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   346
		status = $('._status', rowData).text();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   347
		if ( 'future' !== status ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   348
			$('select[name="_status"] option[value="future"]', editRow).remove();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   349
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   350
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   351
		pw = $( '.inline-edit-password-input' ).prop( 'disabled', false );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   352
		if ( 'private' === status ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   353
			$('input[name="keep_private"]', editRow).prop('checked', true);
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   354
			pw.val( '' ).prop( 'disabled', true );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   355
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   356
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   357
		// Remove the current page and children from the parent dropdown.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   358
		pageOpt = $('select[name="post_parent"] option[value="' + id + '"]', editRow);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   359
		if ( pageOpt.length > 0 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   360
			pageLevel = pageOpt[0].className.split('-')[1];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   361
			nextPage = pageOpt;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   362
			while ( pageLoop ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   363
				nextPage = nextPage.next('option');
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   364
				if ( nextPage.length === 0 ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   365
					break;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   366
				}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   367
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   368
				nextLevel = nextPage[0].className.split('-')[1];
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   369
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   370
				if ( nextLevel <= pageLevel ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   371
					pageLoop = false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   372
				} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   373
					nextPage.remove();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   374
					nextPage = pageOpt;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   375
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   376
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   377
			pageOpt.remove();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   378
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   379
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   380
		$(editRow).attr('id', 'edit-'+id).addClass('inline-editor').show();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   381
		$('.ptitle', editRow).focus();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   382
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   383
		return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   384
	},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   385
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   386
	/**
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   387
	 * Saves the changes made in the quick edit window to the post.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   388
	 * 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
   389
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   390
	 * @since 2.7.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   391
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   392
	 * @param {number} id The ID for the post that has been changed.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   393
	 * @return {boolean} False, so the form does not submit when pressing
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   394
	 *                   Enter on a focused field.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   395
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   396
	save : function(id) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   397
		var params, fields, page = $('.post_status_page').val() || '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   398
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   399
		if ( typeof(id) === 'object' ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   400
			id = this.getId(id);
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   401
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   402
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   403
		$( 'table.widefat .spinner' ).addClass( 'is-active' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   404
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   405
		params = {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   406
			action: 'inline-save',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   407
			post_type: typenow,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   408
			post_ID: id,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   409
			edit_date: 'true',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   410
			post_status: page
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   411
		};
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   412
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   413
		fields = $('#edit-'+id).find(':input').serialize();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   414
		params = fields + '&' + $.param(params);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   415
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   416
		// Make Ajax request.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   417
		$.post( ajaxurl, params,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   418
			function(r) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   419
				var $errorNotice = $( '#edit-' + id + ' .inline-edit-save .notice-error' ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   420
					$error = $errorNotice.find( '.error' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   421
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   422
				$( 'table.widefat .spinner' ).removeClass( 'is-active' );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   423
				$( '.ac_results' ).hide();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   424
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   425
				if (r) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   426
					if ( -1 !== r.indexOf( '<tr' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   427
						$(inlineEditPost.what+id).siblings('tr.hidden').addBack().remove();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   428
						$('#edit-'+id).before(r).remove();
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   429
						$( inlineEditPost.what + id ).hide().fadeIn( 400, function() {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   430
							// Move focus back to the Quick Edit button. $( this ) is the row being animated.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   431
							$( this ).find( '.editinline' )
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   432
								.attr( 'aria-expanded', 'false' )
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   433
								.focus();
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   434
							wp.a11y.speak( wp.i18n.__( 'Changes saved.' ) );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   435
						});
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   436
					} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   437
						r = r.replace( /<.[^<>]*?>/g, '' );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   438
						$errorNotice.removeClass( 'hidden' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   439
						$error.html( r );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   440
						wp.a11y.speak( $error.text() );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   441
					}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   442
				} else {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   443
					$errorNotice.removeClass( 'hidden' );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   444
					$error.text( wp.i18n.__( 'Error while saving the changes.' ) );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   445
					wp.a11y.speak( wp.i18n.__( 'Error while saving the changes.' ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   446
				}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   447
			},
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   448
		'html');
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   449
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   450
		// Prevent submitting the form when pressing Enter on a focused field.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   451
		return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   452
	},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   453
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   454
	/**
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   455
	 * 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
   456
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   457
	 * @since 2.7.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   458
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   459
	 * @memberof inlineEditPost
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   460
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   461
	 * @return {boolean} Always returns false.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   462
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   463
	revert : function(){
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   464
		var $tableWideFat = $( '.widefat' ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   465
			id = $( '.inline-editor', $tableWideFat ).attr( 'id' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   466
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   467
		if ( id ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   468
			$( '.spinner', $tableWideFat ).removeClass( 'is-active' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   469
			$( '.ac_results' ).hide();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   470
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   471
			if ( 'bulk-edit' === id ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   472
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   473
				// Hide the bulk editor.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   474
				$( '#bulk-edit', $tableWideFat ).removeClass( 'inline-editor' ).hide().siblings( '.hidden' ).remove();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   475
				$('#bulk-titles').empty();
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   476
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   477
				// Store the empty bulk editor in a hidden element.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   478
				$('#inlineedit').append( $('#bulk-edit') );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   479
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   480
				// Move focus back to the Bulk Action button that was activated.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   481
				$( '#' + inlineEditPost.whichBulkButtonId ).focus();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   482
			} else {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   483
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   484
				// Remove both the inline-editor and its hidden tr siblings.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   485
				$('#'+id).siblings('tr.hidden').addBack().remove();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   486
				id = id.substr( id.lastIndexOf('-') + 1 );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   487
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   488
				// Show the post row and move focus back to the Quick Edit button.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   489
				$( this.what + id ).show().find( '.editinline' )
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   490
					.attr( 'aria-expanded', 'false' )
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   491
					.focus();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   492
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   493
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   494
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   495
		return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   496
	},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   497
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   498
	/**
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   499
	 * Gets the ID for a the post that you want to quick edit from the row in the quick
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   500
	 * edit table.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   501
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   502
	 * @since 2.7.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   503
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   504
	 * @memberof inlineEditPost
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   505
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   506
	 * @param {Object} o DOM row object to get the ID for.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   507
	 * @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
   508
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   509
	getId : function(o) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   510
		var id = $(o).closest('tr').attr('id'),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   511
			parts = id.split('-');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   512
		return parts[parts.length - 1];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   513
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   514
};
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   515
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   516
$( document ).ready( function(){ inlineEditPost.init(); } );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   517
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   518
// Show/hide locks on posts.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   519
$( document ).on( 'heartbeat-tick.wp-check-locked-posts', function( e, data ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   520
	var locked = data['wp-check-locked-posts'] || {};
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   521
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   522
	$('#the-list tr').each( function(i, el) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   523
		var key = el.id, row = $(el), lock_data, avatar;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   524
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   525
		if ( locked.hasOwnProperty( key ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   526
			if ( ! row.hasClass('wp-locked') ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   527
				lock_data = locked[key];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   528
				row.find('.column-title .locked-text').text( lock_data.text );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   529
				row.find('.check-column checkbox').prop('checked', false);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   530
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   531
				if ( lock_data.avatar_src ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   532
					avatar = $( '<img />', {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   533
						'class': 'avatar avatar-18 photo',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   534
						width: 18,
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   535
						height: 18,
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   536
						alt: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   537
						src: lock_data.avatar_src,
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   538
						srcset: lock_data.avatar_src_2x ? lock_data.avatar_src_2x + ' 2x' : undefined
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   539
					} );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   540
					row.find('.column-title .locked-avatar').empty().append( avatar );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   541
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   542
				row.addClass('wp-locked');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   543
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   544
		} else if ( row.hasClass('wp-locked') ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   545
			row.removeClass( 'wp-locked' ).find( '.locked-info span' ).empty();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   546
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   547
	});
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   548
}).on( 'heartbeat-send.wp-check-locked-posts', function( e, data ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   549
	var check = [];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   550
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   551
	$('#the-list tr').each( function(i, el) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   552
		if ( el.id ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   553
			check.push( el.id );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   554
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   555
	});
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   556
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   557
	if ( check.length ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   558
		data['wp-check-locked-posts'] = check;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   559
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   560
}).ready( function() {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   561
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   562
	// Set the heartbeat interval to 15 seconds.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   563
	if ( typeof wp !== 'undefined' && wp.heartbeat ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   564
		wp.heartbeat.interval( 15 );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   565
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   566
});
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   567
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   568
})( jQuery, window.wp );