Permalink
Browse files

Send all forms by Ctrl+Enter on <select>

  • Loading branch information...
1 parent 1804f71 commit b68ddcad2b53bdc1e4014b652c7f745328429758 @vrana committed Mar 21, 2011
Showing with 19 additions and 22 deletions.
  1. +1 −1 adminer/include/design.inc.php
  2. +2 −2 adminer/select.inc.php
  3. +15 −18 adminer/static/functions.js
  4. +1 −1 changes.txt
@@ -28,7 +28,7 @@ function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") {
<link rel="stylesheet" type="text/css" href="adminer.css">
<?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">
var areYouSure = '<?php echo lang('Are you sure?'); ?>';
</script>
View
@@ -196,7 +196,7 @@
if (!$columns) {
echo "<p class='error'>" . lang('Unable to select the table') . ($fields ? "." : ": " . error()) . "\n";
} else {
- echo "<form action='' id='form' onkeydown='searchKeydown(this, event);'>\n";
+ echo "<form action='' id='form'>\n";
echo "<div style='display: none;'>";
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
@@ -394,7 +394,7 @@
if (!information_schema(DB)) {
?>
<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="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/)) + ')');">
@@ -161,10 +161,9 @@ function selectAddRow(field) {
* @param HTMLTextAreaElement
* @param KeyboardEvent
* @param boolean handle also Tab
-* @param HTMLInputElement submit button
* @return boolean
*/
-function textareaKeydown(target, event, tab, button) {
+function textareaKeydown(target, event, tab) {
if (tab && !event.shiftKey && !event.altKey && !event.ctrlKey && !event.metaKey) {
if (event.keyCode == 9) { // 9 - Tab
// 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;
}
/** Send form by Enter on <select>
-* @param HTMLFormElement
* @param KeyboardEvent
+* @return boolean
*/
-function searchKeydown(form, event) {
+function bodyKeydown(event) {
var target = event.target || event.srcElement;
- if (/select/i.test(target.tagName)) {
- textareaKeydown(target, event);
+ if (event.ctrlKey && (event.keyCode == 13 || event.keyCode == 10) && !event.altKey && !event.metaKey && /select|textarea/i.test(target.tagName)) { // 13|10 - Enter, shiftKey allowed
+ 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
*/
function ajaxForm(form, data) {
+ if (/&(database|scheme|create|view|sql|user|dump|call)=/.test(location.href) && !/\./.test(data)) { // . - type="image"
+ return false;
+ }
var params = [ ];
for (var i=0; i < form.elements.length; i++) {
var el = form.elements[i];
@@ -425,7 +422,7 @@ function selectDblClick(td, event, text) {
});
input.rows = rows;
input.onkeydown = function (event) {
- return textareaKeydown(input, event || window.event, false, document.getElementById('save'));
+ return textareaKeydown(input, event || window.event);
};
}
if (document.selection) {
@@ -477,12 +474,12 @@ function bodyClick(event, db, ns) {
if (/^a$/i.test(el.parentNode.tagName)) {
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 match2 = /&ns=([^&]*)/.exec(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 true;
View
@@ -3,7 +3,7 @@ Ability to save expression in edit
Respect default database collation (bug #3191489)
Don't export triggers without table (bug #3193489)
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
AJAX forms in Google Chrome
Parse UTF-16 and UTF-8 BOM in all text uploads

0 comments on commit b68ddca

Please sign in to comment.