From 9c725732b7ae64f284a33875621ee41979e6422c Mon Sep 17 00:00:00 2001 From: Richa Ferry Setyawan Date: Tue, 30 Jul 2024 19:14:21 +0700 Subject: [PATCH] revert global-checklists.js --- .../checklists/assets/js/global-checklists.js | 151 +++++++++--------- 1 file changed, 79 insertions(+), 72 deletions(-) diff --git a/modules/checklists/assets/js/global-checklists.js b/modules/checklists/assets/js/global-checklists.js index c84a0b9b..f2f2fbbc 100644 --- a/modules/checklists/assets/js/global-checklists.js +++ b/modules/checklists/assets/js/global-checklists.js @@ -33,7 +33,9 @@ $(function () { show_post_type_requirements(objectL10n_checklists_global_checklist.first_post_type); - $('#pp-checklists-requirements tbody').sortable({ items: ' > tr' }); + $('#pp-checklists-requirements tbody').sortable({ + items : ' > tr' + }); // Set the event for the post type filter $('#pp-checklists-post-type-filter a').on('click', function (event) { @@ -52,12 +54,9 @@ $('.pp-checklists-number').on('keypress', function (event) { var key = event.keyCode || event.which; var allowed_keys = [ - // arrows - 35, 36, 37, 38, 39, 40, - // backspace, tab, delete, esc, enter - 8, 9, 46, 27, 13, - // 0-9 - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 35, 36, 37, 38, 39, 40, // arrows + 8, 9, 46, 27, 13, // backspace, tab, delete, esc, enter + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57 // 0-9 ]; // Ignore any key different than number @@ -73,14 +72,10 @@ $('.pp-checklists-float').on('keypress', function (event) { var key = event.keyCode || event.which; var allowed_keys = [ - // arrows - 35, 36, 37, 38, 39, 40, - // decimal separators - 44, 46, - // backspace, tab, delete, esc, enter - 8, 9, 46, 27, 13, - // 0-9 - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 35, 36, 37, 38, 39, 40, // arrows + 44, 46, // decimal separators + 8, 9, 46, 27, 13, // backspace, tab, delete, esc, enter + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57 // 0-9 ]; // Ignore any key different than number @@ -99,7 +94,7 @@ * * @param {string} post_type */ - function show_post_type_requirements(post_type) { + function show_post_type_requirements (post_type) { // Hide the requirements which are not for the current post type $('#pp-checklists-requirements tr.pp-checklists-requirement-row').hide(); // Display the correct requirements @@ -110,7 +105,7 @@ //add active class to title tab $('.pp-checklists-tabs a[data-tab="title"]').addClass('active'); - + // Mark the filter as selected $('#pp-checklists-post-type-filter li.nav-tab-active').removeClass('nav-tab-active'); $('#pp-checklists-post-type-filter li.post-type-' + post_type).addClass('nav-tab-active'); @@ -121,7 +116,7 @@ * * @return string */ - function get_current_post_type() { + function get_current_post_type () { var post_type = $('#pp-checklists-post-type-filter li.nav-tab-active a').attr('href').substring(1); if (post_type === '' || post_type === false || post_type === null || typeof post_type === undefined) { @@ -138,7 +133,7 @@ * @param {string} id * @param {string} type */ - function remove_row(id, type) { + function remove_row (id, type) { // Add a special hidden input to flag the delete action var $input = $('') .attr('name', 'publishpress_checklists_checklists_options[' + type + '_items_remove][]') @@ -154,7 +149,7 @@ * * @param {Event} event */ - function callback_remove_row(event) { + function callback_remove_row (event) { var $target = $(event.target); remove_row($target.data('id'), $target.data('type')); @@ -168,7 +163,7 @@ * * @return {Element} */ - function create_row(id, title, action, post_type, type) { + function create_row (id, title, action, post_type, type) { var $table = $('#pp-checklists-requirements'), $tr = $(''), $td = null, @@ -195,13 +190,19 @@ // ID field $idField - .attr('name', 'publishpress_checklists_checklists_options[' + type + '_items][]') + .attr( + 'name', + 'publishpress_checklists_checklists_options[' + type + '_items][]' + ) .val(id) .appendTo($td); // Title cell $titleField - .attr('name', 'publishpress_checklists_checklists_options[' + id + '_title][' + post_type + ']') + .attr( + 'name', + 'publishpress_checklists_checklists_options[' + id + '_title][' + post_type + ']' + ) .val(title) .addClass('pp-checklists-custom-item-title') .focus() @@ -211,22 +212,10 @@ // Suggestion if (typeof $suggestionsObject !== 'undefined') { - $suggestionItem.append( - '' + - objectL10n_checklists_global_checklist.suggestion_title + - ': ', - ); + $suggestionItem.append('' + objectL10n_checklists_global_checklist.suggestion_title + ': '); for (var key in $suggestionsObject) { if ($suggestionsObject.hasOwnProperty(key)) { - $suggestionItem.append( - '' + - $suggestionsObject[key].label + - ' ', - ); + $suggestionItem.append('' + $suggestionsObject[key].label + ' '); } } $suggestionItem.appendTo($td); @@ -235,48 +224,68 @@ // Action cell $td = $('').appendTo($tr); $actionField - .attr('name', 'publishpress_checklists_checklists_options[' + id + '_rule][' + post_type + ']') + .attr( + 'name', + 'publishpress_checklists_checklists_options[' + id + '_rule][' + post_type + ']' + ) .attr('data-id', id) .appendTo($td); $.each(objectL10n_checklists_global_checklist.rules, function (value, label) { - $option = $('').appendTo($canIgnoreField); $.each(objectL10n_checklists_global_checklist.roles, function (value, label) { - $option = $('').appendTo($optionsField); $.each(objectL10n_checklists_global_checklist.roles, function (value, label) { - $option = $('