1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-21 21:55:43 +02:00

Move icons to CSS

This commit is contained in:
Jakub Vrana
2025-03-26 00:08:16 +01:00
parent 67fa4c2a6f
commit cd207238b7
12 changed files with 64 additions and 90 deletions

View File

@@ -3,7 +3,7 @@ namespace Adminer;
$row = $_POST;
if ($_POST && !$error && !isset($_POST["add_x"])) { // add is an image and PHP changes add.x to add_x
if ($_POST && !$error && !$_POST["add"]) {
$name = trim($row["name"]);
if ($_POST["drop"]) {
$_GET["db"] = ""; // to save in global history
@@ -60,7 +60,7 @@ if ($_POST) {
<form action="" method="post">
<p>
<?php
echo ($_POST["add_x"] || strpos($name, "\n")
echo ($_POST["add"] || strpos($name, "\n")
? '<textarea autofocus name="name" rows="10" cols="40">' . h($name) . '</textarea><br>'
: '<input name="name" autofocus value="' . h($name) . '" data-maxlength="64" autocapitalize="off">'
) . "\n" . ($collations ? html_select("collation", array("" => "(" . lang('collation') . ")") + $collations, $row["collation"]) . doc_link(array(
@@ -73,8 +73,8 @@ echo ($_POST["add_x"] || strpos($name, "\n")
<?php
if (DB != "") {
echo "<input type='submit' name='drop' value='" . lang('Drop') . "'>" . confirm(lang('Drop %s?', DB)) . "\n";
} elseif (!$_POST["add_x"] && $_GET["db"] == "") {
echo "<input type='image' class='icon' name='add' src='../adminer/static/plus.gif' alt='+' title='" . lang('Add next') . "'>\n";
} elseif (!$_POST["add"] && $_GET["db"] == "") {
echo icon("plus", "add[0]", "+", lang('Add next')) . "\n";
}
echo input_token();
?>

View File

@@ -35,21 +35,5 @@ if ($_GET["file"] == "favicon.ico") {
../externals/jush/modules/jush-mssql.js;
../externals/jush/modules/jush-oracle.js;
../externals/jush/modules/jush-simpledb.js', 'minify_js'));
} else {
header("Content-Type: image/gif");
switch ($_GET["file"]) {
case "plus.gif":
echo compile_file('../adminer/static/plus.gif');
break;
case "cross.gif":
echo compile_file('../adminer/static/cross.gif');
break;
case "up.gif":
echo compile_file('../adminer/static/up.gif');
break;
case "down.gif":
echo compile_file('../adminer/static/down.gif');
break;
}
}
exit;

View File

@@ -347,7 +347,7 @@ function edit_fields($fields, $collations, $type = "TABLE", $foreign_keys = arra
echo "<td id='label-default'$default_class>" . lang('Default value');
echo (support("comment") ? "<td id='label-comment'$comment_class>" . lang('Comment') : "");
}
echo "<td><input type='image' class='icon' name='add[" . (support("move_col") ? 0 : count($fields)) . "]' src='../adminer/static/plus.gif' alt='+' title='" . lang('Add next') . "'>" . script("row_count = " . count($fields) . ";");
echo "<td>" . icon("plus", "add[" . (support("move_col") ? 0 : count($fields)) . "]", "+", lang('Add next'));
echo "</thead>\n<tbody>\n";
echo script("mixin(qsl('tbody'), {onclick: editingClick, onkeydown: editingKeydown, oninput: editingInput});");
foreach ($fields as $i => $field) {
@@ -373,11 +373,11 @@ function edit_fields($fields, $collations, $type = "TABLE", $foreign_keys = arra
}
echo "<td>";
echo (support("move_col") ?
"<input type='image' class='icon' name='add[$i]' src='../adminer/static/plus.gif' alt='+' title='" . lang('Add next') . "'> "
. "<input type='image' class='icon' name='up[$i]' src='../adminer/static/up.gif' alt='↑' title='" . lang('Move up') . "'> "
. "<input type='image' class='icon' name='down[$i]' src='../adminer/static/down.gif' alt='↓' title='" . lang('Move down') . "'> "
icon("plus", "add[$i]", "+", lang('Add next')) . " "
. icon("up", "up[$i]", "", lang('Move up')) . " "
. icon("down", "down[$i]", "", lang('Move down')) . " "
: "");
echo ($orig == "" || support("drop_col") ? "<input type='image' class='icon' name='drop_col[$i]' src='../adminer/static/cross.gif' alt='x' title='" . lang('Remove') . "'>" : "");
echo ($orig == "" || support("drop_col") ? icon("cross", "drop_col[$i]", "x", lang('Remove')) : "");
}
}

View File

@@ -534,3 +534,14 @@ function edit_form($table, $fields, $row, $update) {
echo input_token();
echo "</form>\n";
}
/** Get button with icon
* @param string
* @param string
* @param string
* @param string
* @return string
*/
function icon($icon, $name, $html, $title) {
return "<button type='submit' name='$name' title='" . h($title) . "' class='icon icon-$icon'><span>$html</span></button>";
}

View File

@@ -112,7 +112,7 @@ if ($lengths || support("descidx")) {
}
?>
<th id="label-name"><?php echo lang('Name'); ?>
<th><noscript><?php echo "<input type='image' class='icon' name='add[0]' src='../adminer/static/plus.gif' alt='+' title='" . lang('Add next') . "'>"; ?></noscript>
<th><noscript><?php echo icon("plus", "add[0]", "+", lang('Add next')); ?></noscript>
</thead>
<?php
if ($primary) {
@@ -146,7 +146,7 @@ foreach ($row["indexes"] as $index) {
}
echo "<td><input name='indexes[$j][name]' value='" . h($index["name"]) . "' autocapitalize='off' aria-labelledby='label-name'>\n";
echo "<td><input type='image' class='icon' name='drop_col[$j]' src='../adminer/static/cross.gif' alt='x' title='" . lang('Remove') . "'>" . script("qsl('input').onclick = partial(editingRemoveRow, 'indexes\$1[type]');");
echo "<td>" . icon("cross", "drop_col[$j]", "x", lang('Remove')) . script("qsl('button').onclick = partial(editingRemoveRow, 'indexes\$1[type]');");
}
$j++;
}

View File

@@ -61,8 +61,13 @@ input.wayoff { left: -1000px; position: absolute; }
.sqlarea { width: 98%; }
.sql-footer { margin-bottom: 2.5em; }
.explain table { white-space: pre; }
.icon { width: 18px; height: 18px; background-color: navy; }
.icon { width: 18px; height: 18px; background-color: navy; border: 0; vertical-align: middle; }
.icon span { display: none; }
.icon:hover { background-color: red; }
.icon-up { background-image: url(up.gif); }
.icon-down { background-image: url(down.gif); }
.icon-plus { background-image: url(plus.gif); }
.icon-cross { background-image: url(cross.gif); }
.size { width: 7ex; }
.help { cursor: help; }
.footer { position: sticky; bottom: 0; margin-right: -20px; border-top: 20px solid rgba(255, 255, 255, .7); border-image: linear-gradient(rgba(255, 255, 255, .2), #fff) 100% 0; }

View File

@@ -249,11 +249,7 @@ function editFields() {
* @return boolean false to cancel action
*/
function editingClick(event) {
let el = event.target;
if (!isTag(el, 'input')) {
el = parentTag(el, 'label');
el = el && qs('input', el);
}
let el = parentTag(event.target, 'button');
if (el) {
const name = el.name;
if (/^add\[/.test(name)) {
@@ -264,18 +260,24 @@ function editingClick(event) {
editingMoveRow.call(el);
} else if (/^drop_col\[/.test(name)) {
editingRemoveRow.call(el, 'fields$1[field]');
} else {
if (name == 'auto_increment_col') {
const field = el.form['fields[' + el.value + '][field]'];
if (!field.value) {
field.value = 'id';
field.oninput();
}
}
return;
}
return false;
}
el = event.target;
if (!isTag(el, 'input')) {
el = parentTag(el, 'label');
el = el && qs('input', el);
}
if (el) {
const name = el.name;
if (name == 'auto_increment_col') {
const field = el.form['fields[' + el.value + '][field]'];
if (!field.value) {
field.value = 'id';
field.oninput();
}
}
}
}
/** Handle input on fields editing
@@ -334,11 +336,11 @@ function editingAddRow(focus) {
const x = match[0] + (match[2] ? added.substr(match[2].length) : added) + '1';
const row = parentTag(this, 'tr');
const row2 = cloneNode(row);
let tags = qsa('select', row);
let tags2 = qsa('select', row2);
let tags = qsa('select, input, button', row);
let tags2 = qsa('select, input, button', row2);
for (let i=0; i < tags.length; i++) {
tags2[i].name = tags[i].name.replace(/[0-9.]+/, x);
tags2[i].selectedIndex = tags[i].selectedIndex;
tags2[i].selectedIndex = (/\[(generated)/.test(tags[i].name) ? 0 : tags[i].selectedIndex);
}
tags = qsa('input', row);
tags2 = qsa('input', row2);
@@ -348,13 +350,11 @@ function editingAddRow(focus) {
tags2[i].value = x;
tags2[i].checked = false;
}
tags2[i].name = tags[i].name.replace(/([0-9.]+)/, x);
if (/\[(orig|field|comment|default)/.test(tags[i].name)) {
tags2[i].value = '';
}
if (/\[(generated)/.test(tags[i].name)) {
tags2[i].checked = false;
tags2[i].selectedIndex = 0;
}
}
tags[0].oninput = editingNameChange;