]> git.joonet.de Git - adminer.git/commitdiff
Update UI when coming from history
authorJakub Vrana <jakub@vrana.cz>
Fri, 9 Feb 2018 16:35:17 +0000 (17:35 +0100)
committerJakub Vrana <jakub@vrana.cz>
Fri, 9 Feb 2018 16:35:17 +0000 (17:35 +0100)
adminer/create.inc.php
adminer/static/editing.js

index 0f8bbb9ff577cfa39b1bbd953dc5651d5b799601..03e023cafbe5170c585c8439b93be95fcb249553 100644 (file)
@@ -190,8 +190,8 @@ edit_fields($row["fields"], $collations, "TABLE", $foreign_keys, $comments);
 <?php if (!$_POST["defaults"]) { echo script("editingHideDefaults();"); } ?>
 <?php echo (support("comment")
        ? "<label><input type='checkbox' name='comments' value='1' class='jsonly'" . ($comments ? " checked" : "") . ">" . lang('Comment') . "</label>"
-               . script("qsl('input').onclick = function () { columnShow(this.checked, 6); toggle('Comment'); if (this.checked) this.form['Comment'].focus(); };")
-               . ' <input name="Comment" id="Comment" value="' . h($row["Comment"]) . '" maxlength="' . (min_version(5.5) ? 2048 : 60) . '"' . ($comments ? '' : ' class="hidden"') . '>'
+               . script("qsl('input').onclick = partial(editingCommentsClick, true);")
+               . ' <input name="Comment" value="' . h($row["Comment"]) . '" maxlength="' . (min_version(5.5) ? 2048 : 60) . '"' . ($comments ? '' : ' class="hidden"') . '>'
        : '')
 ; ?>
 <p>
@@ -225,3 +225,4 @@ foreach ($row["partition_names"] as $key => $val) {
 ?>
 <input type="hidden" name="token" value="<?php echo $token; ?>">
 </form>
+<?php echo script("qs('#form')['defaults'].onclick();" . (support("comment") ? " editingCommentsClick.call(qs('#form')['comments']);" : "")); ?>
index 694dd76ece499da38e704b1f8d2b205ea96d7d09..bba8f8881c609453e9f3d3c5158580ac4dc735d2 100644 (file)
@@ -409,6 +409,19 @@ function partitionNameChange() {
        this.oninput = function () {};
 }
 
+/** Show or hide comment fields
+* @param [boolean] whether to focus Comment if checked
+* @this HTMLInputElement
+*/
+function editingCommentsClick(focus) {
+       var comment = this.form['Comment'];
+       columnShow(this.checked, 6);
+       alterClass(comment, 'hidden', !this.checked);
+       if (focus && this.checked) {
+               comment.focus();
+       }
+}
+
 
 
 /** Uncheck 'all' checkbox