]> git.joonet.de Git - adminer.git/commitdiff
Use oninput instead of onkeyup
authorJakub Vrana <jakub@vrana.cz>
Fri, 12 Jan 2018 17:46:44 +0000 (18:46 +0100)
committerJakub Vrana <jakub@vrana.cz>
Fri, 12 Jan 2018 17:46:44 +0000 (18:46 +0100)
adminer/include/editing.inc.php
adminer/include/functions.inc.php
adminer/static/editing.js
adminer/static/functions.js
editor/include/adminer.inc.php
plugins/tables-filter.php

index 40b2274fd79446dd8a217b4cee15c24999411c6d..d10cd2537c69b8d728d930c56684a26a512d845c 100644 (file)
@@ -152,7 +152,7 @@ echo optionlist($structured_types, $type);
 ?></select>
 <?php echo on_help("getTarget(event).value", 1); ?>
 <?php echo script("mixin(qsl('select'), {onfocus: function () { lastType = selectValue(this); }, onchange: editingTypeChange});"); ?>
-<td><input name="<?php echo h($key); ?>[length]" value="<?php echo h($field["length"]); ?>" size="3"<?php echo (!$field["length"] && preg_match('~var(char|binary)$~', $type) ? " class='required'" : ""); ?> aria-labelledby="label-length"><?php echo script("mixin(qsl('input'), {onfocus: editingLengthFocus, onchange: editingLengthChange, onkeyup: function () { this.onchange(); }});", ""); ?><td class="options"><?php //! type="number" with enabled JavaScript
+<td><input name="<?php echo h($key); ?>[length]" value="<?php echo h($field["length"]); ?>" size="3"<?php echo (!$field["length"] && preg_match('~var(char|binary)$~', $type) ? " class='required'" : ""); ?> aria-labelledby="label-length"><?php echo script("mixin(qsl('input'), {onfocus: editingLengthFocus, oninput: editingLengthChange});", ""); ?><td class="options"><?php //! type="number" with enabled JavaScript
        echo "<select name='" . h($key) . "[collation]'" . (preg_match('~(char|text|enum|set)$~', $type) ? "" : " class='hidden'") . '><option value="">(' . lang('collation') . ')' . optionlist($collations, $field["collation"]) . '</select>';
        echo ($unsigned ? "<select name='" . h($key) . "[unsigned]'" . (!$type || preg_match('~((^|[^o])int|float|double|decimal)$~', $type) ? "" : " class='hidden'") . '><option>' . optionlist($unsigned, $field["unsigned"]) . '</select>' : '');
        echo (isset($field['on_update']) ? "<select name='" . h($key) . "[on_update]'" . (preg_match('~timestamp|datetime~', $type) ? "" : " class='hidden'") . '>' . optionlist(array("" => "(" . lang('ON UPDATE') . ")", "CURRENT_TIMESTAMP"), $field["on_update"]) . '</select>' : '');
@@ -267,13 +267,13 @@ function edit_fields($fields, $collations, $type = "TABLE", $foreign_keys = arra
                ?>
 <tr<?php echo ($display ? "" : " style='display: none;'"); ?>>
 <?php echo ($type == "PROCEDURE" ? "<td>" . html_select("fields[$i][inout]", explode("|", $inout), $field["inout"]) : ""); ?>
-<th><?php if ($display) { ?><input name="fields[<?php echo $i; ?>][field]" value="<?php echo h($field["field"]); ?>" onchange="editingNameChange.call(this);<?php echo ($field["field"] != "" || count($fields) > 1 ? '' : ' editingAddRow.call(this);" onkeyup="if (this.value) editingAddRow.call(this);'); ?>" maxlength="64" autocapitalize="off" aria-labelledby="label-name"><?php } ?>
+<th><?php if ($display) { ?><input name="fields[<?php echo $i; ?>][field]" value="<?php echo h($field["field"]); ?>" oninput="editingNameChange.call(this);<?php echo ($field["field"] != "" || count($fields) > 1 ? '' : ' editingAddRow.call(this);'); ?>" maxlength="64" autocapitalize="off" aria-labelledby="label-name"><?php } ?>
 <input type="hidden" name="fields[<?php echo $i; ?>][orig]" value="<?php echo h($orig); ?>">
 <?php edit_type("fields[$i]", $field, $collations, $foreign_keys); ?>
 <?php if ($type == "TABLE") { ?>
 <td><?php echo checkbox("fields[$i][null]", 1, $field["null"], "", "", "block", "label-null"); ?>
 <td><label class="block"><input type="radio" name="auto_increment_col" value="<?php echo $i; ?>"<?php if ($field["auto_increment"]) { ?> checked<?php } ?> onclick="var field = this.form['fields[' + this.value + '][field]']; if (!field.value) { field.value = 'id'; field.onchange(); }" aria-labelledby="label-ai"></label><td><?php
-echo checkbox("fields[$i][has_default]", 1, $field["has_default"], "", "", "", "label-default"); ?><input name="fields[<?php echo $i; ?>][default]" value="<?php echo h($field["default"]); ?>" onkeyup="keyupChange.call(this);" onchange="this.previousSibling.checked = true;" aria-labelledby="label-default">
+echo checkbox("fields[$i][has_default]", 1, $field["has_default"], "", "", "", "label-default"); ?><input name="fields[<?php echo $i; ?>][default]" value="<?php echo h($field["default"]); ?>" oninput="this.previousSibling.checked = true;" aria-labelledby="label-default">
 <?php echo (support("comment") ? "<td" . ($comments ? "" : " class='hidden'") . "><input name='fields[$i][comment]' value='" . h($field["comment"]) . "' maxlength='" . ($connection->server_info >= 5.5 ? 1024 : 255) . "' aria-labelledby='label-comment'>" : ""); ?>
 <?php } ?>
 <?php
index 527c86108caeee48e6df6333a8fc9446d69a1bf8..5abadf7ff1ad9f486cf797e84ffd9e842c7841c6 100644 (file)
@@ -890,7 +890,7 @@ function input($field, $value, $function) {
                        }
                        $first++;
                }
-               $onchange = ($first ? " onchange=\"var f = this.form['function[" . h(js_escape(bracket_escape($field["field"]))) . "]']; if ($first > f.selectedIndex) f.selectedIndex = $first;\" onkeyup='keyupChange.call(this);'" : "");
+               $onchange = ($first ? " oninput=\"var f = this.form['function[" . h(js_escape(bracket_escape($field["field"]))) . "]']; if ($first > f.selectedIndex) f.selectedIndex = $first;\"" : "");
                $attrs .= $onchange;
                $has_function = (in_array($function, $functions) || isset($functions[$function]));
                echo (count($functions) > 1
@@ -1382,8 +1382,8 @@ function edit_form($TABLE, $fields, $row, $update) {
                }
                if (!support("table")) {
                        echo "<tr>"
-                               . "<th><input name='field_keys[]' value=''>" // needs empty value for keyupChange()
-                               . script("mixin(qsl('input'), {onkeyup: keyupChange, onchange: fieldChange});")
+                               . "<th><input name='field_keys[]'>"
+                               . script("qsl('input').oninput = fieldChange;")
                                . "<td class='function'>" . html_select("field_funs[]", $adminer->editFunctions(array("null" => isset($_GET["select"]))))
                                . "<td><input name='field_vals[]'>"
                                . "\n"
index 56441fea7f5d129288ccfbb8f3bd0fd099048298..dba475e1fcdc7ce216d4e13c0f3c132515a06a96 100644 (file)
@@ -241,14 +241,10 @@ function editingAddRow(focus) {
                        tags2[i].checked = false;
                }
        }
-       tags[0].onchange = editingNameChange;
-       tags[0].onkeyup = function () {
-       };
+       tags[0].oninput = editingNameChange;
        row.parentNode.insertBefore(row2, row.nextSibling);
        if (focus) {
-               input.onchange = editingNameChange;
-               input.onkeyup = function () {
-               };
+               input.oninput = editingNameChange;
                input.focus();
        }
        added += '0';
index dc7342ac0157710f49d96ac872992411a2c9fbdd..0b475f826dc7b9422b382b9d80b7bf78e0f35325 100644 (file)
@@ -538,16 +538,6 @@ function functionChange() {
        helpClose();
 }
 
-/** Call this.onchange() if value changes
-* @this HTMLInputElement
-*/
-function keyupChange() {
-       if (this.value != this.getAttribute('value')) {
-               this.onchange();
-               this.setAttribute('value', this.value);
-       }
-}
-
 /** Add new field in schema-less edit
 * @this HTMLInputElement
 */
@@ -861,7 +851,7 @@ function cloneNode(el) {
        var origEls = qsa(selector, el);
        var cloneEls = qsa(selector, el2);
        for (var i=0; i < origEls.length; i++) {
-               for (var key in {onchange: 1, onkeydown: 1, onsearch: 1}) {
+               for (var key in {onchange: 1, onkeydown: 1, onsearch: 1, oninput: 1}) {
                        if (origEls[i][key]) {
                                cloneEls[i][key] = origEls[i][key];
                        }
index c65bd78d3a854dd72c7c71de2fe03f5d69f59c5f..3a5ed3222cbb30d79982b1d0a0578e22f38a22a6 100644 (file)
@@ -458,7 +458,7 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5
                if ($options !== null) {
                        return (is_array($options)
                                ? "<select$attrs>" . optionlist($options, $value, true) . "</select>"
-                               :  "<input value='" . h($value) . "'$attrs class='hidden'><input value='" . h($options) . "' class='jsonly' onkeyup=\"whisper.call(this, '" . h(ME . "script=complete&source=" . urlencode($table) . "&field=" . urlencode($field["field"])) . "&value=');\"><div onclick='return whisperClick(event, this.previousSibling);'></div>"
+                               :  "<input value='" . h($value) . "'$attrs class='hidden'><input value='" . h($options) . "' class='jsonly' oninput=\"whisper.call(this, '" . h(ME . "script=complete&source=" . urlencode($table) . "&field=" . urlencode($field["field"])) . "&value=');\"><div onclick='return whisperClick(event, this.previousSibling);'></div>"
                        );
                }
                if (like_bool($field)) {
index a8753eeb0cdb5c0b798009a98fdfb1b7cf504b00..37cb9b199d07ad01e89f54a67c0469cb54805373 100644 (file)
@@ -8,7 +8,7 @@
 */
 class AdminerTablesFilter {
        function tablesPrint($tables) { ?>
-<p class="jsonly"><input id="filter-field" onkeyup="tablesFilterInput();" autocomplete="off">
+<p class="jsonly"><input id="filter-field" oninput="tablesFilterInput();" autocomplete="off">
 <ul id='tables' onmouseover='menuOver.call(this, event);' onmouseout='menuOut.call(this);'>
 <?php
 foreach ($tables as $table => $status) {