Send all forms by Ctrl+Enter on <select>
This commit is contained in:
parent
1804f71b96
commit
b68ddcad2b
|
@ -28,7 +28,7 @@ function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") {
|
||||||
<link rel="stylesheet" type="text/css" href="adminer.css">
|
<link rel="stylesheet" type="text/css" href="adminer.css">
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
<body class="<?php echo lang('ltr'); ?> nojs" onclick="return bodyClick(event, '<?php echo js_escape(DB); ?>', '<?php echo js_escape($_GET["ns"]); ?>');" onload="bodyLoad('<?php echo (is_object($connection) ? substr($connection->server_info, 0, 3) : ""); ?>');<?php echo (isset($_COOKIE["adminer_version"]) ? "" : " verifyVersion('$protocol');"); ?>">
|
<body class="<?php echo lang('ltr'); ?> nojs" onclick="return bodyClick(event, '<?php echo js_escape(DB); ?>', '<?php echo js_escape($_GET["ns"]); ?>');" onkeydown="bodyKeydown(event);" onload="bodyLoad('<?php echo (is_object($connection) ? substr($connection->server_info, 0, 3) : ""); ?>');<?php echo (isset($_COOKIE["adminer_version"]) ? "" : " verifyVersion('$protocol');"); ?>">
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var areYouSure = '<?php echo lang('Are you sure?'); ?>';
|
var areYouSure = '<?php echo lang('Are you sure?'); ?>';
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -196,7 +196,7 @@ $adminer->selectLinks($table_status, $set);
|
||||||
if (!$columns) {
|
if (!$columns) {
|
||||||
echo "<p class='error'>" . lang('Unable to select the table') . ($fields ? "." : ": " . error()) . "\n";
|
echo "<p class='error'>" . lang('Unable to select the table') . ($fields ? "." : ": " . error()) . "\n";
|
||||||
} else {
|
} else {
|
||||||
echo "<form action='' id='form' onkeydown='searchKeydown(this, event);'>\n";
|
echo "<form action='' id='form'>\n";
|
||||||
echo "<div style='display: none;'>";
|
echo "<div style='display: none;'>";
|
||||||
hidden_fields_get();
|
hidden_fields_get();
|
||||||
echo (DB != "" ? '<input type="hidden" name="db" value="' . h(DB) . '">' . (isset($_GET["ns"]) ? '<input type="hidden" name="ns" value="' . h($_GET["ns"]) . '">' : "") : ""); // not used in Editor
|
echo (DB != "" ? '<input type="hidden" name="db" value="' . h(DB) . '">' . (isset($_GET["ns"]) ? '<input type="hidden" name="ns" value="' . h($_GET["ns"]) . '">' : "") : ""); // not used in Editor
|
||||||
|
@ -394,7 +394,7 @@ if (!$columns) {
|
||||||
if (!information_schema(DB)) {
|
if (!information_schema(DB)) {
|
||||||
?>
|
?>
|
||||||
<fieldset><legend><?php echo lang('Edit'); ?></legend><div>
|
<fieldset><legend><?php echo lang('Edit'); ?></legend><div>
|
||||||
<input type="submit" id="save" value="<?php echo lang('Save'); ?>" title="<?php echo lang('Double click on a value to modify it.'); ?>" class="jsonly">
|
<input type="submit" value="<?php echo lang('Save'); ?>" title="<?php echo lang('Double click on a value to modify it.'); ?>" class="jsonly">
|
||||||
<input type="submit" name="edit" value="<?php echo lang('Edit'); ?>">
|
<input type="submit" name="edit" value="<?php echo lang('Edit'); ?>">
|
||||||
<input type="submit" name="clone" value="<?php echo lang('Clone'); ?>">
|
<input type="submit" name="clone" value="<?php echo lang('Clone'); ?>">
|
||||||
<input type="submit" name="delete" value="<?php echo lang('Delete'); ?>" onclick="return confirm('<?php echo lang('Are you sure?'); ?> (' + (this.form['all'].checked ? <?php echo $found_rows; ?> : formChecked(this, /check/)) + ')');">
|
<input type="submit" name="delete" value="<?php echo lang('Delete'); ?>" onclick="return confirm('<?php echo lang('Are you sure?'); ?> (' + (this.form['all'].checked ? <?php echo $found_rows; ?> : formChecked(this, /check/)) + ')');">
|
||||||
|
|
|
@ -161,10 +161,9 @@ function selectAddRow(field) {
|
||||||
* @param HTMLTextAreaElement
|
* @param HTMLTextAreaElement
|
||||||
* @param KeyboardEvent
|
* @param KeyboardEvent
|
||||||
* @param boolean handle also Tab
|
* @param boolean handle also Tab
|
||||||
* @param HTMLInputElement submit button
|
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function textareaKeydown(target, event, tab, button) {
|
function textareaKeydown(target, event, tab) {
|
||||||
if (tab && !event.shiftKey && !event.altKey && !event.ctrlKey && !event.metaKey) {
|
if (tab && !event.shiftKey && !event.altKey && !event.ctrlKey && !event.metaKey) {
|
||||||
if (event.keyCode == 9) { // 9 - Tab
|
if (event.keyCode == 9) { // 9 - Tab
|
||||||
// inspired by http://pallieter.org/Projects/insertTab/
|
// inspired by http://pallieter.org/Projects/insertTab/
|
||||||
|
@ -190,26 +189,21 @@ function textareaKeydown(target, event, tab, button) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (event.ctrlKey && (event.keyCode == 13 || event.keyCode == 10) && !event.altKey && !event.metaKey) { // 13|10 - Enter, shiftKey allowed
|
|
||||||
target.blur();
|
|
||||||
if (button) {
|
|
||||||
button.click();
|
|
||||||
} else if ((!target.form.onsubmit || target.form.onsubmit() !== false) && !ajaxForm(target.form)) {
|
|
||||||
target.form.submit();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Send form by Enter on <select>
|
/** Send form by Enter on <select>
|
||||||
* @param HTMLFormElement
|
|
||||||
* @param KeyboardEvent
|
* @param KeyboardEvent
|
||||||
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function searchKeydown(form, event) {
|
function bodyKeydown(event) {
|
||||||
var target = event.target || event.srcElement;
|
var target = event.target || event.srcElement;
|
||||||
if (/select/i.test(target.tagName)) {
|
if (event.ctrlKey && (event.keyCode == 13 || event.keyCode == 10) && !event.altKey && !event.metaKey && /select|textarea/i.test(target.tagName)) { // 13|10 - Enter, shiftKey allowed
|
||||||
textareaKeydown(target, event);
|
target.blur();
|
||||||
|
if ((!target.form.onsubmit || target.form.onsubmit() !== false) && !ajaxForm(target.form)) {
|
||||||
|
target.form.submit();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -384,6 +378,9 @@ onpopstate = function (event) {
|
||||||
* @return XMLHttpRequest or false in case of an error
|
* @return XMLHttpRequest or false in case of an error
|
||||||
*/
|
*/
|
||||||
function ajaxForm(form, data) {
|
function ajaxForm(form, data) {
|
||||||
|
if (/&(database|scheme|create|view|sql|user|dump|call)=/.test(location.href) && !/\./.test(data)) { // . - type="image"
|
||||||
|
return false;
|
||||||
|
}
|
||||||
var params = [ ];
|
var params = [ ];
|
||||||
for (var i=0; i < form.elements.length; i++) {
|
for (var i=0; i < form.elements.length; i++) {
|
||||||
var el = form.elements[i];
|
var el = form.elements[i];
|
||||||
|
@ -425,7 +422,7 @@ function selectDblClick(td, event, text) {
|
||||||
});
|
});
|
||||||
input.rows = rows;
|
input.rows = rows;
|
||||||
input.onkeydown = function (event) {
|
input.onkeydown = function (event) {
|
||||||
return textareaKeydown(input, event || window.event, false, document.getElementById('save'));
|
return textareaKeydown(input, event || window.event);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (document.selection) {
|
if (document.selection) {
|
||||||
|
@ -477,12 +474,12 @@ function bodyClick(event, db, ns) {
|
||||||
if (/^a$/i.test(el.parentNode.tagName)) {
|
if (/^a$/i.test(el.parentNode.tagName)) {
|
||||||
el = el.parentNode;
|
el = el.parentNode;
|
||||||
}
|
}
|
||||||
if (/^a$/i.test(el.tagName) && !/^https?:|#|&download=/i.test(el.getAttribute('href')) && /[&?]username=/.exec(el.href)) {
|
if (/^a$/i.test(el.tagName) && !/^:|#|&download=/i.test(el.getAttribute('href')) && /[&?]username=/.test(el.href)) {
|
||||||
var match = /&db=([^&]*)/.exec(el.href);
|
var match = /&db=([^&]*)/.exec(el.href);
|
||||||
var match2 = /&ns=([^&]*)/.exec(el.href);
|
var match2 = /&ns=([^&]*)/.exec(el.href);
|
||||||
return !(db == (match ? match[1] : '') && ns == (match2 ? match2[1] : '') && ajaxSend(el.href));
|
return !(db == (match ? match[1] : '') && ns == (match2 ? match2[1] : '') && ajaxSend(el.href));
|
||||||
}
|
}
|
||||||
if (/^input$/i.test(el.tagName) && (el.type == 'image' || (el.type == 'submit' && !/&(database|scheme|create|view|sql|user|dump|call)=/.test(location.href)))) {
|
if (/^input$/i.test(el.tagName) && /image|submit/.test(el.type)) {
|
||||||
return !ajaxForm(el.form, (el.name ? encodeURIComponent(el.name) + (el.type == 'image' ? '.x' : '') + '=1' : ''));
|
return !ajaxForm(el.form, (el.name ? encodeURIComponent(el.name) + (el.type == 'image' ? '.x' : '') + '=1' : ''));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -3,7 +3,7 @@ Ability to save expression in edit
|
||||||
Respect default database collation (bug #3191489)
|
Respect default database collation (bug #3191489)
|
||||||
Don't export triggers without table (bug #3193489)
|
Don't export triggers without table (bug #3193489)
|
||||||
Esc to focus next field in Tab textarea (thanks to David Grudl)
|
Esc to focus next field in Tab textarea (thanks to David Grudl)
|
||||||
Send select search form by Ctrl+Enter on <select>
|
Send forms by Ctrl+Enter on <select>
|
||||||
Enum editor and textarea Ctrl+Enter working in IE
|
Enum editor and textarea Ctrl+Enter working in IE
|
||||||
AJAX forms in Google Chrome
|
AJAX forms in Google Chrome
|
||||||
Parse UTF-16 and UTF-8 BOM in all text uploads
|
Parse UTF-16 and UTF-8 BOM in all text uploads
|
||||||
|
|
Loading…
Reference in a new issue