diff --git a/js/src/ajax.js b/js/src/ajax.js index 97c2289c91..61b6c8f0d7 100644 --- a/js/src/ajax.js +++ b/js/src/ajax.js @@ -378,7 +378,7 @@ var AJAX = { msg = data.errSubmitMsg; } if (data.errors) { - $('
', { id : 'pma_errors', class : 'clearfloat' }) + $('', { id : 'pma_errors', class : 'clearfloat d-print-none' }) .insertAfter('#selflink') .append(data.errors); // bind for php error reporting forms (bottom) @@ -553,7 +553,7 @@ var AJAX = { msg = data.errSubmitMsg; } if (data.errors) { - $('', { id : 'pma_errors', class : 'clearfloat' }) + $('', { id : 'pma_errors', class : 'clearfloat d-print-none' }) .insertAfter('#selflink') .append(data.errors); // bind for php error reporting forms (bottom) diff --git a/js/src/database/structure.js b/js/src/database/structure.js index c0c0566ce9..6c27120998 100644 --- a/js/src/database/structure.js +++ b/js/src/database/structure.js @@ -27,7 +27,6 @@ AJAX.registerTeardown('database/structure.js', function () { $(document).off('click', 'a.drop_table_anchor.ajax'); $(document).off('click', '#real_end_input'); $(document).off('click', 'a.favorite_table_anchor.ajax'); - $(document).off('click', '#printView'); $('a.real_row_count').off('click'); $('a.row_count_sum').off('click'); $('select[name=submit_mult]').off('change'); @@ -399,16 +398,6 @@ AJAX.registerOnload('database/structure.js', function () { }, Functions.loadForeignKeyCheckbox); }); // end of Drop Table Ajax action - /** - * Attach Event Handler for 'Print' link - */ - $(document).on('click', '#printView', function (event) { - event.preventDefault(); - - // Take to preview mode - Functions.printPreview(); - }); // end of Print View action - // Calculate Real End for InnoDB /** * Ajax Event handler for calculating the real end for a InnoDB table diff --git a/js/src/functions.js b/js/src/functions.js index 24f68ea2d8..2e43954291 100644 --- a/js/src/functions.js +++ b/js/src/functions.js @@ -3924,11 +3924,6 @@ Functions.getCellValue = function (td) { } }; -$(window).on('popstate', function () { - $('#printcss').attr('media','print'); - return true; -}); - /** * Unbind all event handlers before tearing down a page */ @@ -3946,49 +3941,10 @@ AJAX.registerOnload('functions.js', function () { }); /** - * Produce print preview + * @implements EventListener */ -Functions.printPreview = function () { - $('#printcss').attr('media','all'); - Functions.createPrintAndBackButtons(); -}; - -/** - * Create print and back buttons in preview page - */ -Functions.createPrintAndBackButtons = function () { - var backButton = $('',{ - type: 'button', - value: Messages.back, - class: 'btn btn-secondary', - id: 'back_button_print_view' - }); - backButton.on('click', Functions.removePrintAndBackButton); - backButton.appendTo('#page_content'); - var printButton = $('',{ - type: 'button', - value: Messages.print, - class: 'btn btn-primary', - id: 'print_button_print_view' - }); - printButton.on('click', Functions.printPage); - printButton.appendTo('#page_content'); -}; - -/** - * Remove print and back buttons and revert to normal view - */ -Functions.removePrintAndBackButton = function () { - $('#printcss').attr('media','print'); - $('#back_button_print_view').remove(); - $('#print_button_print_view').remove(); -}; - -/** - * Print page - */ -Functions.printPage = function () { - if (typeof(window.print) !== 'undefined') { +const PrintPage = { + handleEvent: () => { window.print(); } }; @@ -3997,14 +3953,20 @@ Functions.printPage = function () { * Unbind all event handlers before tearing down a page */ AJAX.registerTeardown('functions.js', function () { - $('input#print').off('click'); + document.querySelectorAll('.jsPrintButton').forEach(item => { + item.removeEventListener('click', PrintPage); + }); + $(document).off('click', 'a.create_view.ajax'); $(document).off('keydown', '#createViewModal input, #createViewModal select'); $(document).off('change', '#fkc_checkbox'); }); AJAX.registerOnload('functions.js', function () { - $('input#print').on('click', Functions.printPage); + document.querySelectorAll('.jsPrintButton').forEach(item => { + item.addEventListener('click', PrintPage); + }); + $('.logout').on('click', function () { var form = $( '