Utilize bodyKeydown function
This commit is contained in:
parent
b68ddcad2b
commit
7d152fbabf
|
@ -57,7 +57,7 @@ if ($_POST) {
|
||||||
<p>
|
<p>
|
||||||
<?php
|
<?php
|
||||||
echo ($_POST["add_x"] || strpos($name, "\n")
|
echo ($_POST["add_x"] || strpos($name, "\n")
|
||||||
? '<textarea id="name" name="name" rows="10" cols="40" onkeydown="return textareaKeydown(this, event);">' . h($name) . '</textarea><br>'
|
? '<textarea id="name" name="name" rows="10" cols="40">' . h($name) . '</textarea><br>'
|
||||||
: '<input id="name" name="name" value="' . h($name) . '" maxlength="64">'
|
: '<input id="name" name="name" value="' . h($name) . '" maxlength="64">'
|
||||||
) . "\n" . ($collations ? html_select("collation", array("" => "(" . lang('collation') . ")") + $collations, $collate) : "");
|
) . "\n" . ($collations ? html_select("collation", array("" => "(" . lang('collation') . ")") + $collations, $collate) : "");
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -218,7 +218,7 @@ if (DB != "") {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
echo "<tr><td><textarea name='databases' rows='10' cols='20' onkeydown='return textareaKeydown(this, event);'></textarea>";
|
echo "<tr><td><textarea name='databases' rows='10' cols='20'></textarea>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -106,7 +106,7 @@ function referencable_primary($self) {
|
||||||
* @return null
|
* @return null
|
||||||
*/
|
*/
|
||||||
function textarea($name, $value, $rows = 10, $cols = 80) {
|
function textarea($name, $value, $rows = 10, $cols = 80) {
|
||||||
echo "<textarea name='$name' rows='$rows' cols='$cols' class='sqlarea' spellcheck='false' wrap='off' onkeydown='return textareaKeydown(this, event, true);'>"; // spellcheck, wrap - not valid before HTML5
|
echo "<textarea name='$name' rows='$rows' cols='$cols' class='sqlarea' spellcheck='false' wrap='off' onkeydown='return textareaKeydown(this, event);'>"; // spellcheck, wrap - not valid before HTML5
|
||||||
if (is_array($value)) {
|
if (is_array($value)) {
|
||||||
foreach ($value as $val) { // not implode() to save memory
|
foreach ($value as $val) { // not implode() to save memory
|
||||||
echo h($val) . ";\n\n\n"; // rtrim(, ';') would possibly damage DELIMITER
|
echo h($val) . ";\n\n\n"; // rtrim(, ';') would possibly damage DELIMITER
|
||||||
|
|
|
@ -689,7 +689,7 @@ function input($field, $value, $function) {
|
||||||
} elseif (ereg('blob|bytea|raw|file', $field["type"]) && ini_bool("file_uploads")) {
|
} elseif (ereg('blob|bytea|raw|file', $field["type"]) && ini_bool("file_uploads")) {
|
||||||
echo "<input type='file' name='fields-$name'$onchange>";
|
echo "<input type='file' name='fields-$name'$onchange>";
|
||||||
} elseif (ereg('text|lob', $field["type"])) {
|
} elseif (ereg('text|lob', $field["type"])) {
|
||||||
echo "<textarea " . ($jush != "sqlite" || ereg("\n", $value) ? "cols='50' rows='12'" : "cols='30' rows='1' style='height: 1.2em;'") . "$attrs onkeydown='return textareaKeydown(this, event);'>" . h($value) . '</textarea>'; // 1.2em - line-height
|
echo "<textarea " . ($jush != "sqlite" || ereg("\n", $value) ? "cols='50' rows='12'" : "cols='30' rows='1' style='height: 1.2em;'") . "$attrs>" . h($value) . '</textarea>'; // 1.2em - line-height
|
||||||
} else {
|
} else {
|
||||||
// int(3) is only a display hint
|
// int(3) is only a display hint
|
||||||
$maxlength = (!ereg('int', $field["type"]) && preg_match('~^(\\d+)(,(\\d+))?$~', $field["length"], $match) ? ((ereg("binary", $field["type"]) ? 2 : 1) * $match[1] + ($match[3] ? 1 : 0) + ($match[2] && !$field["unsigned"] ? 1 : 0)) : ($types[$field["type"]] ? $types[$field["type"]] + ($field["unsigned"] ? 0 : 1) : 0));
|
$maxlength = (!ereg('int', $field["type"]) && preg_match('~^(\\d+)(,(\\d+))?$~', $field["length"], $match) ? ((ereg("binary", $field["type"]) ? 2 : 1) * $match[1] + ($match[3] ? 1 : 0) + ($match[2] && !$field["unsigned"] ? 1 : 0)) : ($types[$field["type"]] ? $types[$field["type"]] + ($field["unsigned"] ? 0 : 1) : 0));
|
||||||
|
|
|
@ -349,7 +349,7 @@ if (!$columns) {
|
||||||
$editable = is_utf8($val) && $rows[$n][$key] == $row[$key] && !$functions[$key];
|
$editable = is_utf8($val) && $rows[$n][$key] == $row[$key] && !$functions[$key];
|
||||||
$text = ereg('text|lob', $field["type"]);
|
$text = ereg('text|lob', $field["type"]);
|
||||||
echo (($_GET["modify"] && $editable) || isset($value)
|
echo (($_GET["modify"] && $editable) || isset($value)
|
||||||
? "<td>" . ($text ? "<textarea name='$id' cols='30' rows='" . (substr_count($row[$key], "\n") + 1) . "' onkeydown='return textareaKeydown(this, event);'>$h_value</textarea>" : "<input name='$id' value='$h_value' size='$lengths[$key]'>")
|
? "<td>" . ($text ? "<textarea name='$id' cols='30' rows='" . (substr_count($row[$key], "\n") + 1) . "'>$h_value</textarea>" : "<input name='$id' value='$h_value' size='$lengths[$key]'>")
|
||||||
: "<td id='$id' ondblclick=\"" . ($editable ? "selectDblClick(this, event" . ($long ? ", 2" : ($text ? ", 1" : "")) . ")" : "alert('" . h(lang('Use edit link to modify this value.')) . "')") . ";\">" . $adminer->selectVal($val, $link, $field)
|
: "<td id='$id' ondblclick=\"" . ($editable ? "selectDblClick(this, event" . ($long ? ", 2" : ($text ? ", 1" : "")) . ")" : "alert('" . h(lang('Use edit link to modify this value.')) . "')") . ";\">" . $adminer->selectVal($val, $link, $field)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,14 +157,13 @@ function selectAddRow(field) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** Handle Ctrl+Enter and optionally Tab in textarea
|
/** Handle Tab and Esc in textarea
|
||||||
* @param HTMLTextAreaElement
|
* @param HTMLTextAreaElement
|
||||||
* @param KeyboardEvent
|
* @param KeyboardEvent
|
||||||
* @param boolean handle also Tab
|
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function textareaKeydown(target, event, tab) {
|
function textareaKeydown(target, event) {
|
||||||
if (tab && !event.shiftKey && !event.altKey && !event.ctrlKey && !event.metaKey) {
|
if (!event.shiftKey && !event.altKey && !event.ctrlKey && !event.metaKey) {
|
||||||
if (event.keyCode == 9) { // 9 - Tab
|
if (event.keyCode == 9) { // 9 - Tab
|
||||||
// inspired by http://pallieter.org/Projects/insertTab/
|
// inspired by http://pallieter.org/Projects/insertTab/
|
||||||
if (target.setSelectionRange) {
|
if (target.setSelectionRange) {
|
||||||
|
@ -187,6 +186,7 @@ function textareaKeydown(target, event, tab) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -421,9 +421,6 @@ function selectDblClick(td, event, text) {
|
||||||
rows++;
|
rows++;
|
||||||
});
|
});
|
||||||
input.rows = rows;
|
input.rows = rows;
|
||||||
input.onkeydown = function (event) {
|
|
||||||
return textareaKeydown(input, event || window.event);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
if (document.selection) {
|
if (document.selection) {
|
||||||
var range = document.selection.createRange();
|
var range = document.selection.createRange();
|
||||||
|
|
|
@ -281,7 +281,7 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5
|
||||||
print_fieldset("email", lang('E-mail'), $_POST["email_append"]);
|
print_fieldset("email", lang('E-mail'), $_POST["email_append"]);
|
||||||
echo "<p>" . lang('From') . ": <input name='email_from' value='" . h($_POST ? $_POST["email_from"] : $_COOKIE["adminer_email"]) . "'>\n";
|
echo "<p>" . lang('From') . ": <input name='email_from' value='" . h($_POST ? $_POST["email_from"] : $_COOKIE["adminer_email"]) . "'>\n";
|
||||||
echo lang('Subject') . ": <input name='email_subject' value='" . h($_POST["email_subject"]) . "'>\n";
|
echo lang('Subject') . ": <input name='email_subject' value='" . h($_POST["email_subject"]) . "'>\n";
|
||||||
echo "<p><textarea name='email_message' rows='15' cols='75' onkeydown='return textareaKeydown(this, event, false, this.form.email);'>" . h($_POST["email_message"] . ($_POST["email_append"] ? '{$' . "$_POST[email_addition]}" : "")) . "</textarea><br>\n";
|
echo "<p><textarea name='email_message' rows='15' cols='75'>" . h($_POST["email_message"] . ($_POST["email_append"] ? '{$' . "$_POST[email_addition]}" : "")) . "</textarea><br>\n"; //! Ctrl+Enter for this.form.email
|
||||||
echo html_select("email_addition", $columns, $_POST["email_addition"]) . "<input type='submit' name='email_append' value='" . lang('Insert') . "'>\n"; //! JavaScript
|
echo html_select("email_addition", $columns, $_POST["email_addition"]) . "<input type='submit' name='email_append' value='" . lang('Insert') . "'>\n"; //! JavaScript
|
||||||
echo "<p>" . lang('Attachments') . ": <input type='file' name='email_files[]' onchange=\"this.onchange = function () { }; var el = this.cloneNode(true); el.value = ''; this.parentNode.appendChild(el);\">";
|
echo "<p>" . lang('Attachments') . ": <input type='file' name='email_files[]' onchange=\"this.onchange = function () { }; var el = this.cloneNode(true); el.value = ''; this.parentNode.appendChild(el);\">";
|
||||||
echo "<p>" . (count($emailFields) == 1 ? '<input type="hidden" name="email_field" value="' . h(key($emailFields)) . '">' : html_select("email_field", $emailFields));
|
echo "<p>" . (count($emailFields) == 1 ? '<input type="hidden" name="email_field" value="' . h(key($emailFields)) . '">' : html_select("email_field", $emailFields));
|
||||||
|
|
|
@ -9,7 +9,7 @@ class AdminerEditTextarea {
|
||||||
|
|
||||||
function editInput($table, $field, $attrs, $value) {
|
function editInput($table, $field, $attrs, $value) {
|
||||||
if (ereg('char', $field["type"])) {
|
if (ereg('char', $field["type"])) {
|
||||||
return "<textarea cols='30' rows='1' style='height: 1.2em;'$attrs onkeydown='return textareaKeydown(this, event);'>" . h($value) . '</textarea>';
|
return "<textarea cols='30' rows='1' style='height: 1.2em;'$attrs>" . h($value) . '</textarea>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue