]> git.joonet.de Git - adminer.git/commitdiff
Merge from master
authorJakub Vrana <jakub@vrana.cz>
Sun, 17 Oct 2010 05:55:58 +0000 (07:55 +0200)
committerJakub Vrana <jakub@vrana.cz>
Sun, 17 Oct 2010 05:55:58 +0000 (07:55 +0200)
1  2 
adminer/include/functions.inc.php
adminer/select.inc.php
adminer/static/editing.js
adminer/static/functions.js
editor/include/adminer.inc.php

Simple merge
Simple merge
Simple merge
index f554758ae17ad6d27e7d216f4fab48531c78a688,ca4332a5f37ddb973855630af5326cc4ca44ff80..0a441d583195070e967d50296b94dce3ddba2b92
@@@ -131,64 -123,36 +131,96 @@@ function selectAddRow(field) 
  
  
  
+ /** Handle Ctrl+Enter and optionally Tab in textarea
+ * @param HTMLTextAreaElement
+ * @param KeyboardEvent
+ * @param boolean handle also Tab
+ * @param HTMLInputElement submit button
+ * @return boolean
+ */
+ function textareaKeydown(target, event, tab, button) {
+       if (tab && 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; //! still loses focus in Opera, can be solved by handling onblur
+               } 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
+               if (button) {
+                       button.click();
+               } else {
+                       target.form.submit();
+               }
+       }
+       return true;
+ }
++
++
 +var ajaxState = 0;
 +var ajaxTimeout;
 +
 +/** Create AJAX request
 +* @param string
 +* @param string
 +* @return XMLHttpRequest or false in case of an error
 +*/
 +function ajax(url, data) {
 +      var xmlhttp = (window.XMLHttpRequest ? new XMLHttpRequest() : (window.ActiveXObject ? new ActiveXObject('Microsoft.XMLHTTP') : false));
 +      if (xmlhttp) {
 +              var currentState = ++ajaxState;
 +              clearTimeout(ajaxTimeout);
 +              ajaxTimeout = setTimeout(function () {
 +                      setHtml('main', '<img src="../adminer/static/loader.gif" alt="">');
 +              }, 500); // defer displaying loader
 +              var method = (data === undefined ? 'GET' : 'POST');
 +              xmlhttp.open(method, url);
 +              if (method == 'POST') {
 +                      xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
 +              }
 +              xmlhttp.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
 +              xmlhttp.onreadystatechange = function () {
 +                      if (xmlhttp.readyState == 4 && currentState == ajaxState) {
 +                              clearTimeout(ajaxTimeout);
 +                              setHtml('main', xmlhttp.responseText);
 +                              if (window.jush) {
 +                                      jush.highlight_tag('code');
 +                                      jush.highlight_tag('pre', 0);
 +                              }
 +                      }
 +              };
 +              xmlhttp.send(data);
 +      }
 +      return xmlhttp;
 +}
 +
 +/** Send form by AJAX GET
 +* @param HTMLFormElement
 +* @return XMLHttpRequest or false in case of an error
 +*/
 +function ajaxForm(form) {
 +      var params = [ ];
 +      for (var i=0; i < form.elements.length; i++) {
 +              var el = form.elements[i];
 +              if (el.name && (!/checkbox|radio|submit|file/i.test(el.type) || el.checked)) {
 +                      params.push(encodeURIComponent(el.name) + '=' + encodeURIComponent(/select/i.test(el.tagName) ? selectValue(el) : el.value));
 +              }
 +      }
 +      if (form.method == 'post') {
 +              return ajax(form.action || location.href, params.join('&'));
 +      } else {
 +              return ajax((form.action || location.pathname) + '?' + params.join('&'));
 +      }
 +}
 +
 +
 +
  /** Display edit field
  * @param HTMLElement
  * @param MouseEvent
Simple merge