]> git.joonet.de Git - adminer.git/commitdiff
Send all forms by Ctrl+Enter on <select>
authorJakub Vrana <jakub@vrana.cz>
Mon, 21 Mar 2011 11:15:38 +0000 (12:15 +0100)
committerJakub Vrana <jakub@vrana.cz>
Mon, 21 Mar 2011 11:15:38 +0000 (12:15 +0100)
adminer/include/design.inc.php
adminer/select.inc.php
adminer/static/functions.js
changes.txt

index f380fcefcb120908ac66efcd7a58af49eab5e63c..b96177cafb14c16e428ee14414de95c1f9b7964e 100644 (file)
@@ -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>
index abb17cfdb9edffb58f23ba3ffa664a6570a2a6af..914f38e06981e2a429b0ccf8c66b407c9731a084 100644 (file)
@@ -196,7 +196,7 @@ $adminer->selectLinks($table_status, $set);
 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 (!$columns) {
                        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/)) + ')');">
index b9f2898deefe6a355cefbdc849c19b0c1e0233a3..867aa8a3430876a0626c82e7f044b69c187901ff 100644 (file)
@@ -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;
index b055a6c1d6e9373e482037841203de662b6d1af7..dcc2dcbc18591a5b276c2ad5f0b0878dcf56b558 100644 (file)
@@ -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