Unselect original function on key up

This commit is contained in:
Jakub Vrana 2013-08-09 17:00:05 -07:00
parent 3f47f63c61
commit 657191eed8
3 changed files with 12 additions and 2 deletions

View file

@ -267,7 +267,7 @@ function edit_fields($fields, $collations, $type = "TABLE", $foreign_keys = arra
<?php if ($type == "TABLE") { ?>
<td><?php echo checkbox("fields[$i][null]", 1, $field["null"], "", "", "block"); ?>
<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(); }"></label><td><?php
echo checkbox("fields[$i][has_default]", 1, $field["has_default"]); ?><input name="fields[<?php echo $i; ?>][default]" value="<?php echo h($field["default"]); ?>" onkeyup="if (this.value != this.getAttribute('value')) { this.onchange(); this.setAttribute('value', this.value) }" onchange="this.previousSibling.checked = true;">
echo checkbox("fields[$i][has_default]", 1, $field["has_default"]); ?><input name="fields[<?php echo $i; ?>][default]" value="<?php echo h($field["default"]); ?>" onkeyup="keyupChange.call(this);" onchange="this.previousSibling.checked = true;">
<?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) . "'>" : ""); ?>
<?php } ?>
<?php

View file

@ -805,7 +805,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;\"" : "");
$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);'" : "");
$attrs .= $onchange;
echo (count($functions) > 1
? "<select name='function[$name]' onchange='functionChange(this);'" . on_help("getTarget(event).value.replace(/^SQL\$/, '')", 1) . ">" . optionlist($functions, $function === null || in_array($function, $functions) || isset($functions[$function]) ? $function : "") . "</select>"

View file

@ -435,6 +435,16 @@ function functionChange(select) {
helpClose();
}
/** Call this.onchange() if value changes
* @this HTMLInputElement
*/
function keyupChange() {
if (this.value != this.getAttribute('value')) {
this.onchange();
this.setAttribute('value', this.value);
}
}
/** Create AJAX request