diff --git a/css/qsm-admin-question.css b/css/qsm-admin-question.css index 3d596f342..76ba60d12 100644 --- a/css/qsm-admin-question.css +++ b/css/qsm-admin-question.css @@ -136,13 +136,14 @@ .page-header-buttons { text-align: right; } -.question, .question-bank-question { +.qsm-question-container, .question-bank-question { box-sizing: border-box; background: #ffffff; border: 1px solid #dfd4d4; border-radius: 3px; padding: 6px 5px; - margin: 10px 20px 0; + margin: 10px 20px 0 35px; + position: relative; } .question a { text-decoration: none; @@ -175,7 +176,7 @@ color: #1f8cbe; font-size: 16px; font-weight: 500; - margin: 2px 0 2px 30px; + margin: 2px 0; } .question-content .form-actions { display: inline-flex; @@ -192,11 +193,12 @@ color: #939697; font-weight: normal; font-style: italic; - margin: 3px 0 3px 30px; + margin: 3px 0; } .qsm-admin-select-question-input { position: absolute; top: calc(50% - 3px); + left: -25px; visibility: hidden; } .question:hover .qsm-admin-select-question-input, @@ -481,7 +483,7 @@ a.import-button.button.disable_import::before { padding: 15px 10px; background-color: #fafafa; border: 1px solid #cbcbcb; - margin: 0 20px 0; + margin: 0 20px 0 35px; box-sizing: border-box; border-top: medium none; } @@ -631,11 +633,19 @@ a#qsm-category-add-toggle { } .qsm-admin-bulk-actions{ margin-top: 10px; + text-align: right; + display: none; } input.qsm-admin-select-page-question { - margin-left: 74px; + margin-left: 10px; + margin-right: 10px; display: inline-block; } +.qsm-admin-select-page-question-label{ + color: #a6abaf; + font-size: 16px; + display: none; +} @media (min-width: 783px) and (max-width: 1199px) { #poststuff #post-body.columns-2 #side-sortables { min-width: unset; diff --git a/css/qsm-admin-rtl.css b/css/qsm-admin-rtl.css index cbd205e26..9710e2c33 100644 --- a/css/qsm-admin-rtl.css +++ b/css/qsm-admin-rtl.css @@ -19,4 +19,6 @@ .overview-main-wrapper .overview-inner-wrap {margin-left: 2%;margin-right: 0;} div.qsm_icon_wrap{left:0;right:auto;} .text-right{text-align: left !important;} -.text-left{text-align: right !important;} \ No newline at end of file +.text-left{text-align: right !important;} +.wp-core-ui .button-danger { color: #DC3232; border-color: #DC3232; } +.wp-core-ui .button-danger:hover { color: #ca1010; border-color: #ca1010; } \ No newline at end of file diff --git a/css/qsm-admin.css b/css/qsm-admin.css index f4e771587..ece1d7b72 100644 --- a/css/qsm-admin.css +++ b/css/qsm-admin.css @@ -3301,4 +3301,11 @@ input#preferred-date-format-custom { .qsm-date-time-text { min-width: 110px; display: inline-block; +} +.wp-core-ui .button-danger { + color: #DC3232; + border-color: #DC3232; +} +.wp-core-ui .button-danger:hover { + color: #ca1010; border-color: #ca1010; } \ No newline at end of file diff --git a/js/qsm-admin.js b/js/qsm-admin.js index 927aa98a0..c0969ff2b 100644 --- a/js/qsm-admin.js +++ b/js/qsm-admin.js @@ -2739,51 +2739,33 @@ var import_button; $('#delete-question-button').attr('data-question-iid', $(this).data('question-iid')); }); // removes question from database - $('#delete-question-button').click(function (event) { - event.preventDefault(); - var question_id = $(this).data('question-iid'); - $.ajax({ - url: ajaxurl, - method: 'POST', - data: { - 'action': 'qsm_delete_question_from_database', - 'question_id': question_id, - 'nonce': qsmQuestionSettings.single_question_nonce - }, - success: function (response) { - if (response.success) { - remove.parents('.question').remove(); - QSMQuestion.countTotal(); - $('.save-page-button').trigger('click'); - } else { - QSMAdmin.displayAlert(response.data, 'error'); - } + $(document).on('click', '.qsm-delete-question-button-btn', function () { + let question_id = $(this).attr('data-question-iid'); + let checkedValues = ""; + if ("selected-questions" == question_id || "all-questions" == question_id) { + if ("all-questions" == question_id) { + checkedValues = $('.qsm-admin-select-question-input') + .map(function () { + return $(this).val(); + }) + .get(); + } else { + checkedValues = $('.qsm-admin-select-question-input:checked') + .map(function () { + return $(this).val(); + }) + .get(); + } + let question_ids = checkedValues.join(','); + if (question_ids == undefined || question_ids == null || question_ids == '') { + return; } - }); - MicroModal.close('modal-7'); - }); - // removes bulk question from database - $(document).on('click', '#qsm-bulk-delete-question-submit', function (event) { - event.preventDefault(); - jQuery('#qsm-bulk-delete-question-submit').attr('disabled', true); - let bulk_action = $("#bulk-delete-question-selector").val(); - let checkedValues = $('.qsm-admin-select-question-input:checked') - .map(function () { - return $(this).val(); - }) - .get() - let question_id = checkedValues.join(','); - if (question_id == undefined || question_id == null || question_id == '') { - jQuery('#qsm-bulk-delete-question-submit').attr('disabled', false); - return; - } - if ('delete' === bulk_action) { $.ajax({ url: ajaxurl, method: 'POST', data: { 'action': 'qsm_bulk_delete_question_from_database', - 'question_id': question_id, + 'question_id': question_ids, 'nonce': qsmQuestionSettings.single_question_nonce }, success: function (response) { @@ -2797,17 +2779,44 @@ var import_button; } else { QSMAdmin.displayAlert(response.data, 'error'); } - jQuery('#qsm-bulk-delete-question-submit').attr('disabled', false); + jQuery('.qsm-admin-bulk-actions').fadeOut(); } }); - }else if ('unlink' === bulk_action) { - checkedValues.forEach(function (questionId) { - $('.question[data-question-id="' + questionId + '"]').remove(); + } else { + $.ajax({ + url: ajaxurl, + method: 'POST', + data: { + 'action': 'qsm_delete_question_from_database', + 'question_id': question_id, + 'nonce': qsmQuestionSettings.single_question_nonce + }, + success: function (response) { + if (response.success) { + remove.parents('.question').remove(); + QSMQuestion.countTotal(); + $('.save-page-button').trigger('click'); + } else { + QSMAdmin.displayAlert(response.data, 'error'); + } + } }); - jQuery('.qsm-admin-select-page-question').prop('checked',false); - QSMQuestion.countTotal(); - $('.save-page-button').trigger('click'); } + MicroModal.close('modal-7'); + }); + // delete bulk question from database + $(document).on('click', '#qsm-bulk-delete-question', function (event) { + event.preventDefault(); + MicroModal.show('modal-7'); + $('#unlink-question-button').attr('data-question-iid', 'selected-questions'); + $('#delete-question-button').attr('data-question-iid', 'selected-questions'); + }); + // remove bulk question from quiz + $(document).on('click', '#qsm-bulk-delete-all-question', function (event) { + event.preventDefault(); + MicroModal.show('modal-7'); + $('#unlink-question-button').attr('data-question-iid', 'all-questions'); + $('#delete-question-button').attr('data-question-iid', 'all-questions'); }); $(document).on('click', '.qsm-admin-select-page-question', function () { @@ -2820,6 +2829,13 @@ var import_button; let allCheckboxesChecked = checkboxesToToggle.length === checkboxesToToggle.filter(':checked').length; $('.qsm-admin-select-page-question').prop('checked', allCheckboxesChecked); } + let count = jQuery('.qsm-admin-select-question-input:checked').length; + jQuery('.qsm-selected-question-count').html(count); + if (count) { + jQuery('.qsm-admin-bulk-actions').fadeIn(); + } else { + jQuery('.qsm-admin-bulk-actions').fadeOut(); + } }); $(document).on('click', '.qsm-admin-select-question-input', function () { @@ -2829,15 +2845,54 @@ var import_button; let allCheckboxesChecked = $(this).closest('.page').find('.qsm-admin-select-question-input:checked').length === $(this).closest('.page').find('.qsm-admin-select-question-input').length; $(this).closest('.page').find('.qsm-admin-select-page-question').prop('checked', allCheckboxesChecked); } + if ( $(this).closest('.page').find('.qsm-admin-select-question-input:checked').length ) { + $(this).closest('.page').find('.qsm-admin-select-page-question-label').fadeIn(); + } else { + $(this).closest('.page').find('.qsm-admin-select-page-question-label').fadeOut(); + } + let count = jQuery('.qsm-admin-select-question-input:checked').length; + jQuery('.qsm-selected-question-count').html(count); + if (count) { + jQuery('.qsm-admin-bulk-actions').fadeIn(); + } else { + jQuery('.qsm-admin-bulk-actions').fadeOut(); + } }); // unlink question from a particular quiz. - $('#unlink-question-button').click(function (event) { + $(document).on('click', '.qsm-unlink-question-button-btn', function (event) { event.preventDefault(); - var question_id = $(this).data('question-iid'); - remove.parents('.question').remove(); - QSMQuestion.countTotal(); - $('.save-page-button').trigger('click'); + let question_id = $(this).attr('data-question-iid'); + let checkedValues = ""; + if ("selected-questions" == question_id || "all-questions" == question_id) { + if ("all-questions" == question_id) { + checkedValues = $('.qsm-admin-select-question-input') + .map(function () { + return $(this).val(); + }) + .get(); + } else { + checkedValues = $('.qsm-admin-select-question-input:checked') + .map(function () { + return $(this).val(); + }) + .get(); + } + let question_ids = checkedValues.join(','); + if (undefined != question_ids && null != question_ids && '' != question_ids) { + checkedValues.forEach(function (questionId) { + $('.question[data-question-id="' + questionId + '"]').remove(); + }); + QSMQuestion.countTotal(); + $('.save-page-button').trigger('click'); + jQuery('.qsm-admin-bulk-actions').fadeOut(); + jQuery('.qsm-admin-select-page-question').prop('checked',false); + } + } else { + remove.parents('.question').remove(); + QSMQuestion.countTotal(); + $('.save-page-button').trigger('click'); + } MicroModal.close('modal-7'); }); diff --git a/php/admin/options-page-questions-tab.php b/php/admin/options-page-questions-tab.php index 9cdd5f2d3..6785008dd 100644 --- a/php/admin/options-page-questions-tab.php +++ b/php/admin/options-page-questions-tab.php @@ -200,20 +200,15 @@ function qsm_options_questions_tab_content() { ?>