mirror of
https://github.com/vrana/adminer.git
synced 2025-08-12 09:34:10 +02:00
Change focus by Tab in <textarea>
This commit is contained in:
@@ -118,7 +118,7 @@ function referencable_primary($self) {
|
|||||||
*/
|
*/
|
||||||
function textarea($name, $value, $rows = 10, $cols = 80) {
|
function textarea($name, $value, $rows = 10, $cols = 80) {
|
||||||
global $jush;
|
global $jush;
|
||||||
echo "<textarea name='$name' rows='$rows' cols='$cols' class='sqlarea jush-$jush' spellcheck='false' wrap='off' onkeydown='return textareaKeydown(this, event);'>"; // spellcheck, wrap - not valid before HTML5
|
echo "<textarea name='$name' rows='$rows' cols='$cols' class='sqlarea jush-$jush' spellcheck='false' wrap='off'>";
|
||||||
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[0]) . "\n\n\n"; // $val == array($query, $time)
|
echo h($val[0]) . "\n\n\n"; // $val == array($query, $time)
|
||||||
|
@@ -122,43 +122,6 @@ function dbChange(el) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** Handle Tab and Esc in textarea
|
|
||||||
* @param HTMLTextAreaElement
|
|
||||||
* @param KeyboardEvent
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
function textareaKeydown(target, event) {
|
|
||||||
if (!event.shiftKey && !event.altKey && !isCtrl(event)) {
|
|
||||||
if (event.keyCode == 9) { // 9 - Tab
|
|
||||||
// inspired by http://pallieter.org/Projects/insertTab/
|
|
||||||
if (target.setSelectionRange) {
|
|
||||||
var start = target.selectionStart;
|
|
||||||
var scrolled = target.scrollTop;
|
|
||||||
target.value = target.value.substr(0, start) + '\t' + target.value.substr(target.selectionEnd);
|
|
||||||
target.setSelectionRange(start + 1, start + 1);
|
|
||||||
target.scrollTop = scrolled;
|
|
||||||
return false; //! still loses focus in Opera, can be solved by handling onblur
|
|
||||||
} else if (target.createTextRange) {
|
|
||||||
document.selection.createRange().text = '\t';
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (event.keyCode == 27) { // 27 - Esc
|
|
||||||
var els = target.form.elements;
|
|
||||||
for (var i=1; i < els.length; i++) {
|
|
||||||
if (els[i-1] == target) {
|
|
||||||
els[i].focus();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** Check whether the query will be executed with index
|
/** Check whether the query will be executed with index
|
||||||
* @param HTMLFormElement
|
* @param HTMLFormElement
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user