Permalink
Browse files

textareaKeydown is Adminer specific

  • Loading branch information...
1 parent 0060c60 commit 7ff2a67ae89a889b55957ff2bbce302953a32c73 @vrana committed Jun 22, 2011
Showing with 37 additions and 35 deletions.
  1. +37 −0 adminer/static/editing.js
  2. +0 −35 adminer/static/functions.js
View
@@ -69,6 +69,43 @@ function loginDriver(driver) {
+/** Handle Tab and Esc in textarea
+* @param HTMLTextAreaElement
+* @param KeyboardEvent
+* @return boolean
+*/
+function textareaKeydown(target, event) {
+ if (!event.shiftKey && !event.altKey && !event.ctrlKey && !event.metaKey) {
+ 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;
+}
+
+
+
var added = '.', rowCount;
/** Check if val is equal to a-delimiter-b where delimiter is '_', '' or big letter
@@ -155,41 +155,6 @@ function selectAddRow(field) {
-/** Handle Tab and Esc in textarea
-* @param HTMLTextAreaElement
-* @param KeyboardEvent
-* @return boolean
-*/
-function textareaKeydown(target, event) {
- if (!event.shiftKey && !event.altKey && !event.ctrlKey && !event.metaKey) {
- 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;
-}
-
/** Send form by Ctrl+Enter on <select> and <textarea>
* @param KeyboardEvent
* @param [string]

0 comments on commit 7ff2a67

Please sign in to comment.