]> git.joonet.de Git - adminer.git/commitdiff
Highlight required fields in Chrome and after submit
authorJakub Vrana <jakub@vrana.cz>
Wed, 10 Jul 2013 20:13:36 +0000 (13:13 -0700)
committerJakub Vrana <jakub@vrana.cz>
Thu, 11 Jul 2013 18:20:04 +0000 (11:20 -0700)
adminer/create.inc.php
adminer/include/editing.inc.php
adminer/static/default.css
adminer/static/editing.js

index d59451fa19241e4c6224c8e83565d537967e7f93..a000ac7fd116b41953be13cbe6a4b6c8f0126644 100644 (file)
@@ -159,7 +159,7 @@ foreach ($engines as $engine) {
 <?php if ($TABLE == "" && !$_POST) { ?><script type='text/javascript'>focus(document.getElementById('form')['name']);</script><?php } ?>
 <?php echo ($engines ? html_select("Engine", array("" => "(" . lang('engine') . ")") + $engines, $row["Engine"]) : ""); ?>
  <?php echo ($collations && !ereg("sqlite|mssql", $jush) ? html_select("Collation", array("" => "(" . lang('collation') . ")") + $collations, $row["Collation"]) : ""); ?>
- <input type="submit" value="<?php echo lang('Save'); ?>" formnovalidate>
+ <input type="submit" value="<?php echo lang('Save'); ?>">
 <?php } ?>
 
 <?php if (support("table")) { ?>
@@ -187,10 +187,10 @@ edit_fields($row["fields"], $collations, "TABLE", $foreign_keys, $comments);
        : '')
 ; ?>
 <p>
-<input type="submit" value="<?php echo lang('Save'); ?>" formnovalidate>
+<input type="submit" value="<?php echo lang('Save'); ?>">
 <?php } ?>
 
-<?php if ($TABLE != "") { ?><input type="submit" name="drop" value="<?php echo lang('Drop'); ?>"<?php echo confirm(); ?> formnovalidate><?php } ?>
+<?php if ($TABLE != "") { ?><input type="submit" name="drop" value="<?php echo lang('Drop'); ?>"<?php echo confirm(); ?>><?php } ?>
 <?php
 if (support("partitioning")) {
        $partition_table = ereg('RANGE|LIST', $row["partition_by"]);
index e7280f8d1391744ed7c8733742bf9243efba0b0b..aa6d8d028ef6ca86ffe6d4cb6c25a7fce3e4a544 100644 (file)
@@ -140,7 +140,7 @@ function edit_type($key, $field, $collations, $foreign_keys = array()) {
        global $structured_types, $types, $unsigned, $on_actions;
        ?>
 <td><select name="<?php echo $key; ?>[type]" class="type" onfocus="lastType = selectValue(this);" onchange="editingTypeChange(this);"><?php echo optionlist((!$field["type"] || isset($types[$field["type"]]) ? array() : array($field["type"])) + $structured_types + ($foreign_keys ? array(lang('Foreign keys') => $foreign_keys) : array()), $field["type"]); ?></select>
-<td><input name="<?php echo $key; ?>[length]" value="<?php echo h($field["length"]); ?>" size="3" onfocus="editingLengthFocus(this);"<?php echo (ereg('var(char|binary)$', $field["type"]) ? " required" : ""); ?>><td class="options"><?php //! type="number" with enabled JavaScript
+<td><input name="<?php echo $key; ?>[length]" value="<?php echo h($field["length"]); ?>" size="3" onfocus="editingLengthFocus(this);"<?php echo (!$field["length"] && ereg('var(char|binary)$', $field["type"]) ? " class='required'" : ""); ?> onchange="editingLengthChange(this);" onkeyup="this.onchange();"><td class="options"><?php //! type="number" with enabled JavaScript
        echo "<select name='$key" . "[collation]'" . (ereg('(char|text|enum|set)$', $field["type"]) ? "" : " class='hidden'") . '><option value="">(' . lang('collation') . ')' . optionlist($collations, $field["collation"]) . '</select>';
        echo ($unsigned ? "<select name='$key" . "[unsigned]'" . (!$field["type"] || ereg('((^|[^o])int|float|double|decimal)$', $field["type"]) ? "" : " class='hidden'") . '><option>' . optionlist($unsigned, $field["unsigned"]) . '</select>' : '');
        echo (isset($field['on_update']) ? "<select name='$key" . "[on_update]'" . ($field["type"] == "timestamp" ? "" : " class='hidden'") . '>' . optionlist(array("" => "(" . lang('ON UPDATE') . ")", "CURRENT_TIMESTAMP"), $field["on_update"]) . '</select>' : '');
index d5ab5421ea9a21eed30e9560ec994b89dab0a6d0..0d5087244b300890e7215050dbe829f4c701037d 100644 (file)
@@ -22,6 +22,7 @@ tbody tr:hover td, tbody tr:hover th { background: #eee; }
 pre { margin: 1em 0 0; }
 input[type=image] { vertical-align: middle; }
 input.default { box-shadow: 1px 1px 1px #777; }
+input.required { box-shadow: 1px 1px 1px red; }
 .block { display: block; }
 .version { color: #777; font-size: 67%; }
 .js .hidden, .nojs .jsonly { display: none; }
index ca7742b546d3c67a0b3eb9d33ff94887f68a6902..a7c93f47b430eeff438fdc908dc970557b823cb8 100644 (file)
@@ -356,13 +356,13 @@ function editingTypeChange(type) {
        for (var i=0; i < type.form.elements.length; i++) {
                var el = type.form.elements[i];
                if (el.name == name + '[length]') {
-                       el.required = /var(char|binary)$/.test(text);
                        if (!(
                                (/(char|binary)$/.test(lastType) && /(char|binary)$/.test(text))
                                || (/(enum|set)$/.test(lastType) && /(enum|set)$/.test(text))
                        )) {
                                el.value = '';
                        }
+                       el.onchange.apply(el);
                }
                if (lastType == 'timestamp' && el.name == name + '[has_default]' && /timestamp/i.test(formField(type.form, name + '[default]').value)) {
                        el.checked = false;
@@ -382,6 +382,16 @@ function editingTypeChange(type) {
        }
 }
 
+/** Mark length as required
+* @param HTMLInputElement
+*/
+function editingLengthChange(el) {
+       el.className = el.className.replace(/( |^)required( |$)/, '$2');
+       if (!el.value.length && /var(char|binary)$/.test(selectValue(el.parentNode.previousSibling.firstChild))) {
+               el.className += ' required';
+       }
+}
+
 /** Edit enum or set
 * @param HTMLInputElement
 */