]> git.joonet.de Git - adminer.git/commitdiff
Make maxlength in edit fields a soft limit
authorJakub Vrana <jakub@vrana.cz>
Mon, 19 Sep 2016 15:21:41 +0000 (17:21 +0200)
committerJakub Vrana <jakub@vrana.cz>
Mon, 19 Sep 2016 17:12:33 +0000 (10:12 -0700)
adminer/include/functions.inc.php
adminer/static/default.css
adminer/static/functions.js
changes.txt

index 42e780e9d387823a8c10aa34140dce72dcc8b8d2..5f6e6d8ac41580455dc78ed60de07988932d5c78 100644 (file)
@@ -914,7 +914,7 @@ function input($field, $value, $function) {
                        // type='date' and type='time' display localized value which may be confusing, type='datetime' uses 'T' as date and time separator
                        echo "<input"
                                . ((!$has_function || $function === "") && preg_match('~(?<!o)int~', $field["type"]) ? " type='number'" : "")
-                               . " value='" . h($value) . "'" . ($maxlength ? " maxlength='$maxlength'" : "")
+                               . " value='" . h($value) . "'" . ($maxlength ? " data-maxlength='$maxlength'" : "")
                                . (preg_match('~char|binary~', $field["type"]) && $maxlength > 20 ? " size='40'" : "")
                                . "$attrs>"
                        ;
index 63f5b93c4f2c467240af492c7a2603ccb30b8562..39ce6e064214a636bcc8c2b81cb2e42986c8191b 100644 (file)
@@ -26,6 +26,7 @@ pre, textarea { font: 100%/1.25 monospace; }
 input[type=image] { vertical-align: middle; }
 input.default { box-shadow: 1px 1px 1px #777; }
 input.required { box-shadow: 1px 1px 1px red; }
+input.maxlength { box-shadow: 1px 1px 1px red; }
 .block { display: block; }
 .version { color: #777; font-size: 67%; }
 .js .hidden, .nojs .jsonly { display: none; }
index f7c048d1b379b657aeb3a1f10cf32f624243d1ef..710653131a58cb40fc84201c40035afcb36acc69 100644 (file)
@@ -460,16 +460,17 @@ function functionChange(select) {
        if (selectValue(select)) {
                if (input.origType === undefined) {
                        input.origType = input.type;
-                       input.origMaxLength = input.maxLength;
+                       input.origMaxLength = input.getAttribute('data-maxlength');
                }
-               input.removeAttribute('maxlength');
+               input.removeAttribute('data-maxlength');
                input.type = 'text';
        } else if (input.origType) {
                input.type = input.origType;
                if (input.origMaxLength >= 0) {
-                       input.maxLength = input.origMaxLength;
+                       input.setAttribute('data-maxlength', input.origMaxLength);
                }
        }
+       oninput({target: input});
        helpClose();
 }
 
@@ -793,3 +794,9 @@ function cloneNode(el) {
        setupSubmitHighlight(el2);
        return el2;
 }
+
+oninput = function (event) {
+       var target = event.target;
+       var maxLength = target.getAttribute('data-maxlength');
+       alterClass(target, 'maxlength', target.value && maxLength != null && target.value.length > maxLength); // maxLength could be 0
+};
index 59f041dba9dcd94e67b4a18c812a3fa28a1900a0..dde42ec9918b73956289dd76fc558b31b5f7ac02 100644 (file)
@@ -1,5 +1,6 @@
 Adminer 4.2.6-dev:
 Add accessibility labels to Create Table fields
+Make maxlength in edit fields a soft limit
 
 Adminer 4.2.5 (released 2016-06-01):
 Fix remote execution in SQLite query