Move textarea function to editing.*
This commit is contained in:
parent
9929cc6796
commit
d6ac5f1ad2
|
@ -96,6 +96,17 @@ function referencable_primary($self) {
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Print SQL <textarea> tag
|
||||||
|
* @param string
|
||||||
|
* @param int
|
||||||
|
* @param int
|
||||||
|
* @param string
|
||||||
|
* @return null
|
||||||
|
*/
|
||||||
|
function textarea($name, $value, $rows = 10, $cols = 80) {
|
||||||
|
echo "<textarea name='$name' rows='$rows' cols='$cols' style='width: 98%;' spellcheck='false' onkeydown='return textareaKeydown(this, event);'>" . h($value) . "</textarea>"; // spellcheck - not valid before HTML5
|
||||||
|
}
|
||||||
|
|
||||||
/** Print table columns for type edit
|
/** Print table columns for type edit
|
||||||
* @param string
|
* @param string
|
||||||
* @param array
|
* @param array
|
||||||
|
|
|
@ -116,17 +116,6 @@ function html_select($name, $options, $value = "", $onchange = true) {
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Print SQL <textarea> tag
|
|
||||||
* @param string
|
|
||||||
* @param int
|
|
||||||
* @param int
|
|
||||||
* @param string
|
|
||||||
* @return null
|
|
||||||
*/
|
|
||||||
function textarea($name, $value, $rows = 10, $cols = 80) {
|
|
||||||
echo "<textarea name='$name' rows='$rows' cols='$cols' style='width: 98%;' spellcheck='false' onkeydown='return textareaKeydown(this, event);'>" . h($value) . "</textarea>"; // spellcheck - not valid before HTML5
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// other functions
|
// other functions
|
||||||
|
|
|
@ -407,3 +407,27 @@ function schemaMouseup(ev) {
|
||||||
cookie('adminer_schema=' + encodeURIComponent(s.substr(1)), 30, '; path="' + location.pathname + location.search + '"');
|
cookie('adminer_schema=' + encodeURIComponent(s.substr(1)), 30, '; path="' + location.pathname + location.search + '"');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Handle Tab and Ctrl+Enter in textarea
|
||||||
|
* @param HTMLTextAreaElement
|
||||||
|
* @param KeyboardEvent
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
function textareaKeydown(target, event) {
|
||||||
|
if (event.keyCode == 9 && !event.shiftKey && !event.altKey && !event.ctrlKey && !event.metaKey) {
|
||||||
|
// inspired by http://pallieter.org/Projects/insertTab/
|
||||||
|
if (target.setSelectionRange) {
|
||||||
|
var start = target.selectionStart;
|
||||||
|
target.value = target.value.substr(0, start) + '\t' + target.value.substr(target.selectionEnd);
|
||||||
|
target.setSelectionRange(start + 1, start + 1);
|
||||||
|
return false;
|
||||||
|
} else if (target.createTextRange) {
|
||||||
|
document.selection.createRange().text = '\t';
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (event.ctrlKey && (event.keyCode == 13 || event.keyCode == 10) && !event.altKey && !event.metaKey) { // shiftKey allowed
|
||||||
|
target.form.submit();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
@ -123,30 +123,6 @@ function selectAddRow(field) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** Handle Tab and Ctrl+Enter in textarea
|
|
||||||
* @param HTMLTextAreaElement
|
|
||||||
* @param KeyboardEvent
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
function textareaKeydown(target, event) {
|
|
||||||
if (event.keyCode == 9 && !event.shiftKey && !event.altKey && !event.ctrlKey && !event.metaKey) {
|
|
||||||
// inspired by http://pallieter.org/Projects/insertTab/
|
|
||||||
if (target.setSelectionRange) {
|
|
||||||
var start = target.selectionStart;
|
|
||||||
target.value = target.value.substr(0, start) + '\t' + target.value.substr(target.selectionEnd);
|
|
||||||
target.setSelectionRange(start + 1, start + 1);
|
|
||||||
return false;
|
|
||||||
} else if (target.createTextRange) {
|
|
||||||
document.selection.createRange().text = '\t';
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (event.ctrlKey && (event.keyCode == 13 || event.keyCode == 10) && !event.altKey && !event.metaKey) { // shiftKey allowed
|
|
||||||
target.form.submit();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** Display edit field
|
/** Display edit field
|
||||||
|
|
Loading…
Reference in a new issue