mirror of
https://github.com/vrana/adminer.git
synced 2025-08-22 14:12:51 +02:00
Use the fact that we handle oninput in whisper()
This commit is contained in:
@@ -461,7 +461,11 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5
|
|||||||
if ($options !== null) {
|
if ($options !== null) {
|
||||||
return (is_array($options)
|
return (is_array($options)
|
||||||
? "<select$attrs>" . optionlist($options, $value, true) . "</select>"
|
? "<select$attrs>" . optionlist($options, $value, true) . "</select>"
|
||||||
: "<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>"
|
: "<input value='" . h($value) . "'$attrs class='hidden'>"
|
||||||
|
. "<input value='" . h($options) . "' class='jsonly'>"
|
||||||
|
. "<div></div>"
|
||||||
|
. script("qsl('input').oninput = partial(whisper, '" . ME . "script=complete&source=" . urlencode($table) . "&field=" . urlencode($field["field"]) . "&value=');
|
||||||
|
qsl('div').onclick = whisperClick;", "")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (like_bool($field)) {
|
if (like_bool($field)) {
|
||||||
|
@@ -11,19 +11,12 @@ function helpMouseover() {
|
|||||||
function helpMouseout() {
|
function helpMouseout() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function whisperClick(event, field) {
|
/** Display typeahead
|
||||||
var el = getTarget(event);
|
* @param string
|
||||||
if (isTag(el, 'a') && !(event.button || event.shiftKey || event.altKey || isCtrl(event))) {
|
* @this HTMLInputElement
|
||||||
field.value = el.firstChild.data;
|
*/
|
||||||
field.previousSibling.value = decodeURIComponent(el.href.replace(/.*=/, ''));
|
|
||||||
field.nextSibling.style.display = 'none';
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function whisper(url) {
|
function whisper(url) {
|
||||||
var field = this;
|
var field = this;
|
||||||
if (field.orig != field.value) { // ignore arrows, Shift, ...
|
|
||||||
field.orig = field.value;
|
field.orig = field.value;
|
||||||
field.previousSibling.value = field.value; // accept number, reject string
|
field.previousSibling.value = field.value; // accept number, reject string
|
||||||
return ajax(url + encodeURIComponent(field.value), function (xmlhttp) {
|
return ajax(url + encodeURIComponent(field.value), function (xmlhttp) {
|
||||||
@@ -38,6 +31,21 @@ function whisper(url) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Select typeahead value
|
||||||
|
* @param MouseEvent
|
||||||
|
* @return boolean false for success
|
||||||
|
* @this HTMLDivElement
|
||||||
|
*/
|
||||||
|
function whisperClick(event) {
|
||||||
|
var field = this.previousSibling;
|
||||||
|
var el = getTarget(event);
|
||||||
|
if (isTag(el, 'a') && !(event.button || event.shiftKey || event.altKey || isCtrl(event))) {
|
||||||
|
field.value = el.firstChild.data;
|
||||||
|
field.previousSibling.value = decodeURIComponent(el.href.replace(/.*=/, ''));
|
||||||
|
field.nextSibling.style.display = 'none';
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Add new attachment field
|
/** Add new attachment field
|
||||||
|
Reference in New Issue
Block a user