Highlight default submit button
This commit is contained in:
parent
94a0cc8de8
commit
b7021c9c7f
|
@ -157,7 +157,7 @@ foreach ($engines as $engine) {
|
||||||
<form action="" method="post" id="form">
|
<form action="" method="post" id="form">
|
||||||
<p>
|
<p>
|
||||||
<?php echo lang('Table name'); ?>: <input name="name" maxlength="64" value="<?php echo h($row["name"]); ?>" autocapitalize="off">
|
<?php echo lang('Table name'); ?>: <input name="name" maxlength="64" value="<?php echo h($row["name"]); ?>" autocapitalize="off">
|
||||||
<?php if ($TABLE == "" && !$_POST) { ?><script type='text/javascript'>document.getElementById('form')['name'].focus();</script><?php } ?>
|
<?php if ($TABLE == "" && !$_POST) { ?><script type='text/javascript'>focus(document.getElementById('form')['name']);</script><?php } ?>
|
||||||
<?php echo ($engines ? html_select("Engine", array("" => "(" . lang('engine') . ")") + $engines, $row["Engine"]) : ""); ?>
|
<?php echo ($engines ? html_select("Engine", array("" => "(" . lang('engine') . ")") + $engines, $row["Engine"]) : ""); ?>
|
||||||
<?php echo ($collations && !ereg("sqlite|mssql", $jush) ? html_select("Collation", array("" => "(" . lang('collation') . ")") + $collations, $row["Collation"]) : ""); ?>
|
<?php echo ($collations && !ereg("sqlite|mssql", $jush) ? html_select("Collation", array("" => "(" . lang('collation') . ")") + $collations, $row["Collation"]) : ""); ?>
|
||||||
<input type="submit" value="<?php echo lang('Save'); ?>">
|
<input type="submit" value="<?php echo lang('Save'); ?>">
|
||||||
|
|
|
@ -62,7 +62,7 @@ echo ($_POST["add_x"] || strpos($name, "\n")
|
||||||
: '<input name="name" id="name" value="' . h($name) . '" maxlength="64" autocapitalize="off">'
|
: '<input name="name" id="name" value="' . h($name) . '" maxlength="64" autocapitalize="off">'
|
||||||
) . "\n" . ($collations ? html_select("collation", array("" => "(" . lang('collation') . ")") + $collations, $collate) : "");
|
) . "\n" . ($collations ? html_select("collation", array("" => "(" . lang('collation') . ")") + $collations, $collate) : "");
|
||||||
?>
|
?>
|
||||||
<script type='text/javascript'>document.getElementById('name').focus();</script>
|
<script type='text/javascript'>focus(document.getElementById('name'));</script>
|
||||||
<input type="submit" value="<?php echo lang('Save'); ?>">
|
<input type="submit" value="<?php echo lang('Save'); ?>">
|
||||||
<?php
|
<?php
|
||||||
if (DB != "") {
|
if (DB != "") {
|
||||||
|
|
|
@ -122,7 +122,7 @@ if ($fields) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
echo ($update ? "<input type='submit' name='delete' value='" . lang('Delete') . "' onclick=\"return confirm('" . lang('Are you sure?') . "');\">\n"
|
echo ($update ? "<input type='submit' name='delete' value='" . lang('Delete') . "' onclick=\"return confirm('" . lang('Are you sure?') . "');\">\n"
|
||||||
: ($_POST || !$fields ? "" : "<script type='text/javascript'>document.getElementById('form').getElementsByTagName('td')[1].firstChild.focus();</script>\n")
|
: ($_POST || !$fields ? "" : "<script type='text/javascript'>focus(document.getElementById('form').getElementsByTagName('td')[1].firstChild);</script>\n")
|
||||||
);
|
);
|
||||||
if (isset($_GET["select"])) {
|
if (isset($_GET["select"])) {
|
||||||
hidden_fields(array("check" => (array) $_POST["check"], "clone" => $_POST["clone"], "all" => $_POST["all"]));
|
hidden_fields(array("check" => (array) $_POST["check"], "clone" => $_POST["clone"], "all" => $_POST["all"]));
|
||||||
|
|
|
@ -78,7 +78,7 @@ class Adminer {
|
||||||
</table>
|
</table>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var username = document.getElementById('username');
|
var username = document.getElementById('username');
|
||||||
username.focus();
|
focus(username);
|
||||||
username.form['auth[driver]'].onchange();
|
username.form['auth[driver]'].onchange();
|
||||||
</script>
|
</script>
|
||||||
<?php
|
<?php
|
||||||
|
|
|
@ -98,5 +98,6 @@ function page_footer($missing = "") {
|
||||||
<div id="menu">
|
<div id="menu">
|
||||||
<?php $adminer->navigation($missing); ?>
|
<?php $adminer->navigation($missing); ?>
|
||||||
</div>
|
</div>
|
||||||
|
<script type="text/javascript">setupSubmitHighlight(document);</script>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ if (!$row) {
|
||||||
|
|
||||||
<form action="" method="post">
|
<form action="" method="post">
|
||||||
<p><input name="name" id="name" value="<?php echo h($row["name"]); ?>" autocapitalize="off">
|
<p><input name="name" id="name" value="<?php echo h($row["name"]); ?>" autocapitalize="off">
|
||||||
<script type='text/javascript'>document.getElementById('name').focus();</script>
|
<script type='text/javascript'>focus(document.getElementById('name'));</script>
|
||||||
<input type="submit" value="<?php echo lang('Save'); ?>">
|
<input type="submit" value="<?php echo lang('Save'); ?>">
|
||||||
<?php
|
<?php
|
||||||
if ($_GET["ns"] != "") {
|
if ($_GET["ns"] != "") {
|
||||||
|
|
|
@ -195,7 +195,7 @@ if ($_POST) {
|
||||||
}
|
}
|
||||||
textarea("query", $q, 20);
|
textarea("query", $q, 20);
|
||||||
|
|
||||||
echo ($_POST ? "" : "<script type='text/javascript'>document.getElementsByTagName('textarea')[0].focus();</script>\n");
|
echo ($_POST ? "" : "<script type='text/javascript'>focus(document.getElementsByTagName('textarea')[0]);</script>\n");
|
||||||
echo "<p>" . (ini_bool("file_uploads")
|
echo "<p>" . (ini_bool("file_uploads")
|
||||||
? lang('File upload') . ': <input type="file" name="sql_file[]" multiple'
|
? lang('File upload') . ': <input type="file" name="sql_file[]" multiple'
|
||||||
. ($_FILES && $_FILES["sql_file"]["error"][0] != 4 ? '' : ' onchange="this.form[\'only_errors\'].checked = true;"') // 4 - UPLOAD_ERR_NO_FILE
|
. ($_FILES && $_FILES["sql_file"]["error"][0] != 4 ? '' : ' onchange="this.form[\'only_errors\'].checked = true;"') // 4 - UPLOAD_ERR_NO_FILE
|
||||||
|
|
|
@ -21,6 +21,7 @@ code { background: #eee; }
|
||||||
tbody tr:hover td, tbody tr:hover th { background: #eee; }
|
tbody tr:hover td, tbody tr:hover th { background: #eee; }
|
||||||
pre { margin: 1em 0 0; }
|
pre { margin: 1em 0 0; }
|
||||||
input[type=image] { vertical-align: middle; }
|
input[type=image] { vertical-align: middle; }
|
||||||
|
input.default { background: #ddf; }
|
||||||
.version { color: #777; font-size: 67%; }
|
.version { color: #777; font-size: 67%; }
|
||||||
.js .hidden, .nojs .jsonly { display: none; }
|
.js .hidden, .nojs .jsonly { display: none; }
|
||||||
.js .column { position: absolute; background: #ddf; padding: .3em 1ex .3em 0; margin-top: -.3em; }
|
.js .column { position: absolute; background: #ddf; padding: .3em 1ex .3em 0; margin-top: -.3em; }
|
||||||
|
|
|
@ -291,7 +291,7 @@ function editingAddRow(button, focus) {
|
||||||
var match = /(\d+)(\.\d+)?/.exec(button.name);
|
var match = /(\d+)(\.\d+)?/.exec(button.name);
|
||||||
var x = match[0] + (match[2] ? added.substr(match[2].length) : added) + '1';
|
var x = match[0] + (match[2] ? added.substr(match[2].length) : added) + '1';
|
||||||
var row = parentTag(button, 'tr');
|
var row = parentTag(button, 'tr');
|
||||||
var row2 = row.cloneNode(true);
|
var row2 = cloneNode(row);
|
||||||
var tags = row.getElementsByTagName('select');
|
var tags = row.getElementsByTagName('select');
|
||||||
var tags2 = row2.getElementsByTagName('select');
|
var tags2 = row2.getElementsByTagName('select');
|
||||||
for (var i=0; i < tags.length; i++) {
|
for (var i=0; i < tags.length; i++) {
|
||||||
|
@ -434,7 +434,7 @@ function partitionByChange(el) {
|
||||||
* @param HTMLInputElement
|
* @param HTMLInputElement
|
||||||
*/
|
*/
|
||||||
function partitionNameChange(el) {
|
function partitionNameChange(el) {
|
||||||
var row = parentTag(el, 'tr').cloneNode(true);
|
var row = cloneNode(parentTag(el, 'tr'));
|
||||||
row.firstChild.firstChild.value = '';
|
row.firstChild.firstChild.value = '';
|
||||||
parentTag(el, 'table').appendChild(row);
|
parentTag(el, 'table').appendChild(row);
|
||||||
el.onchange = function () {};
|
el.onchange = function () {};
|
||||||
|
@ -447,7 +447,7 @@ function partitionNameChange(el) {
|
||||||
*/
|
*/
|
||||||
function foreignAddRow(field) {
|
function foreignAddRow(field) {
|
||||||
field.onchange = function () { };
|
field.onchange = function () { };
|
||||||
var row = parentTag(field, 'tr').cloneNode(true);
|
var row = cloneNode(parentTag(field, 'tr'));
|
||||||
var selects = row.getElementsByTagName('select');
|
var selects = row.getElementsByTagName('select');
|
||||||
for (var i=0; i < selects.length; i++) {
|
for (var i=0; i < selects.length; i++) {
|
||||||
selects[i].name = selects[i].name.replace(/\]/, '1$&');
|
selects[i].name = selects[i].name.replace(/\]/, '1$&');
|
||||||
|
@ -463,7 +463,7 @@ function foreignAddRow(field) {
|
||||||
*/
|
*/
|
||||||
function indexesAddRow(field) {
|
function indexesAddRow(field) {
|
||||||
field.onchange = function () { };
|
field.onchange = function () { };
|
||||||
var row = parentTag(field, 'tr').cloneNode(true);
|
var row = cloneNode(parentTag(field, 'tr'));
|
||||||
var selects = row.getElementsByTagName('select');
|
var selects = row.getElementsByTagName('select');
|
||||||
for (var i=0; i < selects.length; i++) {
|
for (var i=0; i < selects.length; i++) {
|
||||||
selects[i].name = selects[i].name.replace(/indexes\[\d+/, '$&1');
|
selects[i].name = selects[i].name.replace(/indexes\[\d+/, '$&1');
|
||||||
|
@ -506,7 +506,7 @@ function indexesAddColumn(field, prefix) {
|
||||||
select.selectedIndex = 3;
|
select.selectedIndex = 3;
|
||||||
select.onchange();
|
select.onchange();
|
||||||
}
|
}
|
||||||
var column = field.parentNode.cloneNode(true);
|
var column = cloneNode(field.parentNode);
|
||||||
select = column.getElementsByTagName('select')[0];
|
select = column.getElementsByTagName('select')[0];
|
||||||
select.name = select.name.replace(/\]\[\d+/, '$&1');
|
select.name = select.name.replace(/\]\[\d+/, '$&1');
|
||||||
select.selectedIndex = 0;
|
select.selectedIndex = 0;
|
||||||
|
|
|
@ -240,7 +240,7 @@ function selectAddRow(field) {
|
||||||
selectFieldChange(field.form);
|
selectFieldChange(field.form);
|
||||||
};
|
};
|
||||||
field.onchange();
|
field.onchange();
|
||||||
var row = field.parentNode.cloneNode(true);
|
var row = cloneNode(field.parentNode);
|
||||||
var selects = row.getElementsByTagName('select');
|
var selects = row.getElementsByTagName('select');
|
||||||
for (var i=0; i < selects.length; i++) {
|
for (var i=0; i < selects.length; i++) {
|
||||||
selects[i].name = selects[i].name.replace(/[a-z]\[\d+/, '$&1');
|
selects[i].name = selects[i].name.replace(/[a-z]\[\d+/, '$&1');
|
||||||
|
@ -474,6 +474,7 @@ function selectClick(td, event, text, warning) {
|
||||||
}
|
}
|
||||||
td.innerHTML = '';
|
td.innerHTML = '';
|
||||||
td.appendChild(input);
|
td.appendChild(input);
|
||||||
|
setupSubmitHighlight(td);
|
||||||
input.focus();
|
input.focus();
|
||||||
if (text == 2) { // long text
|
if (text == 2) { // long text
|
||||||
return ajax(location.href + '&' + encodeURIComponent(td.id) + '=', function (request) {
|
return ajax(location.href + '&' + encodeURIComponent(td.id) + '=', function (request) {
|
||||||
|
@ -536,3 +537,88 @@ function eventStop(event) {
|
||||||
event.cancelBubble = true;
|
event.cancelBubble = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/** Setup highlighting of default submit button on form field focus
|
||||||
|
* @param HTMLElement
|
||||||
|
*/
|
||||||
|
function setupSubmitHighlight(parent) {
|
||||||
|
for (var key in { input: 1, select: 1, textarea: 1 }) {
|
||||||
|
var inputs = parent.getElementsByTagName(key);
|
||||||
|
for (var i = 0; i < inputs.length; i++) {
|
||||||
|
if (!/submit|image|file/.test(inputs[i].type)) {
|
||||||
|
addEvent(inputs[i], 'focus', inputFocus);
|
||||||
|
addEvent(inputs[i], 'blur', inputBlur);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Highlight default submit button
|
||||||
|
* @this HTMLInputElement
|
||||||
|
*/
|
||||||
|
function inputFocus() {
|
||||||
|
var submit = findDefaultSubmit(this.form);
|
||||||
|
if (submit) {
|
||||||
|
submit.className += ' default';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Unhighlight default submit button
|
||||||
|
* @this HTMLInputElement
|
||||||
|
*/
|
||||||
|
function inputBlur() {
|
||||||
|
var submit = findDefaultSubmit(this.form);
|
||||||
|
if (submit) {
|
||||||
|
submit.className = submit.className.replace(/ default( |$)/, '$1');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Find submit button used by Enter
|
||||||
|
* @param HTMLFormElement
|
||||||
|
* @return HTMLInputElement
|
||||||
|
*/
|
||||||
|
function findDefaultSubmit(form) {
|
||||||
|
var inputs = form.getElementsByTagName('input');
|
||||||
|
for (var i = 0; i < inputs.length; i++) {
|
||||||
|
var input = inputs[i];
|
||||||
|
if (input.type == 'submit') {
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/** Add event listener
|
||||||
|
* @param HTMLElement
|
||||||
|
* @param string without 'on'
|
||||||
|
* @param function
|
||||||
|
*/
|
||||||
|
function addEvent(el, action, handler) {
|
||||||
|
if (el.addEventListener) {
|
||||||
|
el.addEventListener(action, handler, false);
|
||||||
|
} else {
|
||||||
|
el.attachEvent('on' + action, handler);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Defer focusing element
|
||||||
|
* @param HTMLElement
|
||||||
|
*/
|
||||||
|
function focus(el) {
|
||||||
|
setTimeout(function () { // this has to be an anonymous function because Firefox passes some arguments to setTimeout callback
|
||||||
|
el.focus();
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Clone node and setup submit highlighting
|
||||||
|
* @param HTMLElement
|
||||||
|
* @return HTMLElement
|
||||||
|
*/
|
||||||
|
function cloneNode(el) {
|
||||||
|
var el2 = el.cloneNode(true);
|
||||||
|
setupSubmitHighlight(el2);
|
||||||
|
return el2;
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
Adminer 3.7.0-dev:
|
Adminer 3.7.0-dev:
|
||||||
Allow more SQL files to be uploaded at the same time
|
Allow more SQL files to be uploaded at the same time
|
||||||
Print run time next to executed queries
|
Print run time next to executed queries
|
||||||
|
Highlight default submit button
|
||||||
Disable SQL export when applying functions in select
|
Disable SQL export when applying functions in select
|
||||||
Allow using lang() in plugins (customization)
|
Allow using lang() in plugins (customization)
|
||||||
Remove bzip2 compression support
|
Remove bzip2 compression support
|
||||||
|
|
|
@ -49,7 +49,7 @@ class Adminer {
|
||||||
<tr><th><?php echo lang('Password'); ?><td><input type="password" name="auth[password]">
|
<tr><th><?php echo lang('Password'); ?><td><input type="password" name="auth[password]">
|
||||||
</table>
|
</table>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
document.getElementById('username').focus();
|
focus(document.getElementById('username'));
|
||||||
</script>
|
</script>
|
||||||
<?php
|
<?php
|
||||||
echo "<p><input type='submit' value='" . lang('Login') . "'>\n";
|
echo "<p><input type='submit' value='" . lang('Login') . "'>\n";
|
||||||
|
|
Loading…
Reference in a new issue