From ccbee25538065c47594c2874485394e3cae35711 Mon Sep 17 00:00:00 2001 From: Roy Orbitson Date: Tue, 21 Nov 2023 11:24:02 +1030 Subject: [PATCH] Consistent filter remove buttons Match row removal buttons on alter table screens. --- adminer/include/adminer.inc.php | 16 ++++++++-------- adminer/select.inc.php | 1 + adminer/static/default.css | 4 ++-- adminer/static/functions.js | 11 ++++++++--- editor/include/adminer.inc.php | 6 +++--- 5 files changed, 22 insertions(+), 16 deletions(-) diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php index c76a2cd6..0dee1711 100644 --- a/adminer/include/adminer.inc.php +++ b/adminer/include/adminer.inc.php @@ -372,8 +372,8 @@ class Adminer { . on_help("getTarget(event).value && getTarget(event).value.replace(/ |\$/, '(') + ')'", 1) . script("qsl('select').onchange = function () { helpClose();" . ($key !== "" ? "" : " qsl('select, input', this.parentNode).onchange();") . " };", "") . "($column)" : $column) - . ' ' - . script('qsl("button").onclick = selectRemoveRow;', "") + . " " + . script('qsl(".icon").onclick = selectRemoveRow;', "") . "\n"; $i++; } @@ -410,8 +410,8 @@ class Adminer { echo html_select("where[$i][op]", $this->operators, $val["op"], $change_next); echo ""; echo script("mixin(qsl('input'), {oninput: function () { $change_next }, onkeydown: selectSearchKeydown, onsearch: selectSearchSearch});", ""); - echo ''; - echo script('qsl("button").onclick = selectRemoveRow;', ""); + echo ""; + echo script('qsl(".icon").onclick = selectRemoveRow;', ""); echo "\n"; } } @@ -431,16 +431,16 @@ class Adminer { if ($val != "") { echo "
" . select_input(" name='order[$i]'", $columns, $val, "selectFieldChange"); echo checkbox("desc[$i]", 1, isset($_GET["desc"][$key]), lang('descending')); - echo ' '; - echo script('qsl("button").onclick = selectRemoveRow;', ""); + echo " "; + echo script('qsl(".icon").onclick = selectRemoveRow;', ""); echo "
\n"; $i++; } } echo "
" . select_input(" name='order[$i]'", $columns, "", "selectAddRow"); echo checkbox("desc[$i]", 1, false, lang('descending')); - echo ' '; - echo script('qsl("button").onclick = selectRemoveRow;', ""); + echo " "; + echo script('qsl(".icon").onclick = selectRemoveRow;', ""); echo "
\n"; echo "\n"; } diff --git a/adminer/select.inc.php b/adminer/select.inc.php index 9c6e9426..956f948f 100644 --- a/adminer/select.inc.php +++ b/adminer/select.inc.php @@ -243,6 +243,7 @@ if (!$columns && support("table")) { hidden_fields_get(); echo (DB != "" ? '' . (isset($_GET["ns"]) ? '' : "") : ""); // not used in Editor echo ''; + echo ''; # hidden default submit so filter remove buttons aren't "clicked" on submission from enter key echo "\n"; $adminer->selectColumnsPrint($select, $columns); $adminer->selectSearchPrint($where, $columns, $indexes); diff --git a/adminer/static/default.css b/adminer/static/default.css index efe22d1a..56e5ae1f 100644 --- a/adminer/static/default.css +++ b/adminer/static/default.css @@ -33,8 +33,8 @@ input[type='submit'] { padding-left: 10px; padding-right: 10px; } select { border-radius: 5px; padding: 2px; vertical-align: middle;; } fieldset label input[type='checkbox'] { margin-bottom: 6px; } fieldset a { line-height: 20px; } -#fieldset-select div:last-child > button, #fieldset-search div:last-child > button, #fieldset-sort div:last-child > button { display: none; } -#fieldset-select button, #fieldset-search button, #fieldset-sort button { width: 16px; height: 16px; margin-bottom: 8px; line-height: 8px; border: 0px; } +#fieldset-select .icon, #fieldset-search .icon, #fieldset-sort .icon { cursor: pointer; } +#fieldset-select div:last-child > .icon, #fieldset-search div:last-child > .icon, #fieldset-sort div:last-child > .icon { display: none; } span.separator { margin-left: 5px; margin-right: 5px; } .block { display: block; } .version { color: #777; font-size: 50%; } diff --git a/adminer/static/functions.js b/adminer/static/functions.js index 274a72b7..ec856119 100644 --- a/adminer/static/functions.js +++ b/adminer/static/functions.js @@ -386,6 +386,10 @@ function selectAddRow() { } var inputs = qsa('input', row); for (var i=0; i < inputs.length; i++) { + if (inputs[i].type === 'image') { + // button + continue; + } inputs[i].name = inputs[i].name.replace(/[a-z]\[\d+/, '$&1'); inputs[i].className = ''; if (inputs[i].type == 'checkbox') { @@ -394,7 +398,7 @@ function selectAddRow() { inputs[i].value = ''; } } - var buttons = qsa('button', row); + var buttons = qsa('.icon', row); for (var i=0; i < buttons.length; i++) { buttons[i].onclick = selectRemoveRow; } @@ -402,7 +406,7 @@ function selectAddRow() { } /** Remove a row in select fieldset -* @this HTMLButtonElement +* @this HTMLInputElement */ function selectRemoveRow() { var button = this; @@ -411,9 +415,10 @@ function selectRemoveRow() { while (nextRow = nextRow.nextSibling) { if (nextRow.tagName === row.tagName) { row.parentNode.removeChild(row); - return; + break; } } + return false; } /** Prevent onsearch handler on Enter diff --git a/editor/include/adminer.inc.php b/editor/include/adminer.inc.php index b35d834e..01b636c1 100644 --- a/editor/include/adminer.inc.php +++ b/editor/include/adminer.inc.php @@ -260,7 +260,7 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5 echo "
"; echo html_select("where[$i][op]", array(-1 => "") + $this->operators, $val["op"]); echo "" . script("mixin(qsl('input'), {onkeydown: selectSearchKeydown, onsearch: selectSearchSearch});", ""); - echo '' . script('qsl("button").onclick = selectRemoveRow;', ""); + echo "" . script('qsl(".icon").onclick = selectRemoveRow;', ""); echo "
\n"; $i++; } @@ -270,8 +270,8 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5 echo html_select("where[$i][op]", array(-1 => "") + $this->operators); echo ""; echo script("mixin(qsl('input'), {onchange: function () { this.parentNode.firstChild.onchange(); }, onsearch: selectSearchSearch});"); - echo ''; - echo script('qsl("button").onclick = selectRemoveRow;', ""); + echo ""; + echo script('qsl(".icon").onclick = selectRemoveRow;', ""); echo ""; echo "\n"; }