Permalink
Browse files

Support one click search in Editor

  • Loading branch information...
1 parent 95f0a5f commit 1dd6dbcce2a9e9131b51455b0eb4b82ff6ef24cb @vrana committed Aug 5, 2012
Showing with 63 additions and 58 deletions.
  1. +58 −0 adminer/static/editing.js
  2. +1 −57 adminer/static/functions.js
  3. +1 −1 editor/include/adminer.inc.php
  4. +3 −0 editor/static/editing.js
View
@@ -109,6 +109,64 @@ function textareaKeydown(target, event) {
+/** Check whether the query will be executed with index
+* @param HTMLFormElement
+*/
+function selectFieldChange(form) {
+ var ok = (function () {
+ var inputs = form.getElementsByTagName('input');
+ for (var i=0; i < inputs.length; i++) {
+ if (inputs[i].value && /^fulltext/.test(inputs[i].name)) {
+ return true;
+ }
+ }
+ var ok = form.limit.value;
+ var selects = form.getElementsByTagName('select');
+ var group = false;
+ var columns = {};
+ for (var i=0; i < selects.length; i++) {
+ var select = selects[i];
+ var col = selectValue(select);
+ var match = /^(where.+)col\]/.exec(select.name);
+ if (match) {
+ var op = selectValue(form[match[1] + 'op]']);
+ var val = form[match[1] + 'val]'].value;
+ if (col in indexColumns && (!/LIKE|REGEXP/.test(op) || (op == 'LIKE' && val.charAt(0) != '%'))) {
+ return true;
+ } else if (col || val) {
+ ok = false;
+ }
+ }
+ if ((match = /^(columns.+)fun\]/.exec(select.name))) {
+ if (/^(avg|count|count distinct|group_concat|max|min|sum)$/.test(col)) {
+ group = true;
+ }
+ var val = selectValue(form[match[1] + 'col]']);
+ if (val) {
+ columns[col && col != 'count' ? '' : val] = 1;
+ }
+ }
+ if (col && /^order/.test(select.name)) {
+ if (!(col in indexColumns)) {
+ ok = false;
+ }
+ break;
+ }
+ }
+ if (group) {
+ for (var col in columns) {
+ if (!(col in indexColumns)) {
+ ok = false;
+ }
+ }
+ }
+ return ok;
+ })();
+ setHtml('noindex', (ok ? '' : '!'));
+}
+
+
+
var added = '.', rowCount;
/** Check if val is equal to a-delimiter-b where delimiter is '_', '' or big letter
@@ -220,62 +220,6 @@ function selectAddRow(field) {
field.parentNode.parentNode.appendChild(row);
}
-/** Check whether the query will be executed with index
-* @param HTMLFormElement
-*/
-function selectFieldChange(form) {
- var ok = (function () {
- var inputs = form.getElementsByTagName('input');
- for (var i=0; i < inputs.length; i++) {
- if (inputs[i].value && /^fulltext/.test(inputs[i].name)) {
- return true;
- }
- }
- var ok = form.limit.value;
- var selects = form.getElementsByTagName('select');
- var group = false;
- var columns = {};
- for (var i=0; i < selects.length; i++) {
- var select = selects[i];
- var col = selectValue(select);
- var match = /^(where.+)col\]/.exec(select.name);
- if (match) {
- var op = selectValue(form[match[1] + 'op]']);
- var val = form[match[1] + 'val]'].value;
- if (col in indexColumns && (!/LIKE|REGEXP/.test(op) || (op == 'LIKE' && val.charAt(0) != '%'))) {
- return true;
- } else if (col || val) {
- ok = false;
- }
- }
- if ((match = /^(columns.+)fun\]/.exec(select.name))) {
- if (/^(avg|count|count distinct|group_concat|max|min|sum)$/.test(col)) {
- group = true;
- }
- var val = selectValue(form[match[1] + 'col]']);
- if (val) {
- columns[col && col != 'count' ? '' : val] = 1;
- }
- }
- if (col && /^order/.test(select.name)) {
- if (!(col in indexColumns)) {
- ok = false;
- }
- break;
- }
- }
- if (group) {
- for (var col in columns) {
- if (!(col in indexColumns)) {
- ok = false;
- }
- }
- }
- return ok;
- })();
- setHtml('noindex', (ok ? '' : '!'));
-}
-
/** Toggles column context menu
@@ -302,7 +246,7 @@ function selectSearch(name) {
var divs = el.getElementsByTagName('div');
for (var i=0; i < divs.length; i++) {
var div = divs[i];
- if (selectValue(div.firstChild) == name) {
+ if (/select/i.test(div.firstChild.tagName) && selectValue(div.firstChild) == name) {
break;
}
}
@@ -193,7 +193,7 @@ function selectColumnsPrint($select, $columns) {
function selectSearchPrint($where, $columns, $indexes) {
$where = (array) $_GET["where"];
- echo '<fieldset><legend>' . lang('Search') . "</legend><div>\n";
+ echo '<fieldset id="fieldset-search"><legend>' . lang('Search') . "</legend><div>\n";
$keys = array();
foreach ($where as $key => $val) {
$keys[$val["col"]] = $key;
View
@@ -3,6 +3,9 @@
function bodyLoad(version) {
}
+function selectFieldChange(form) {
+}
+
function whisperClick(event, field) {
var el = event.target || event.srcElement;
if (/^a$/i.test(el.tagName) && !(event.button || event.ctrlKey || event.shiftKey || event.altKey || event.metaKey)) {

0 comments on commit 1dd6dbc

Please sign in to comment.