]> git.joonet.de Git - adminer.git/commitdiff
Display help in tooltip
authorJakub Vrana <jakub@vrana.cz>
Fri, 19 Jul 2013 17:35:31 +0000 (10:35 -0700)
committerJakub Vrana <jakub@vrana.cz>
Fri, 19 Jul 2013 17:35:31 +0000 (10:35 -0700)
Also rename Analyze to Vacuum outside MySQL

adminer/db.inc.php
adminer/include/adminer.inc.php
adminer/include/design.inc.php
adminer/include/editing.inc.php
adminer/include/functions.inc.php
adminer/lang/cs.inc.php
adminer/lang/xx.inc.php
adminer/processlist.inc.php
adminer/static/default.css
adminer/static/editing.js

index a33adb2b1fdb53d67c092ce416e0dd7248a1fd9d..c5e4c873ae6d6f16de2a71be696e01202459cf0a 100644 (file)
@@ -114,17 +114,17 @@ if ($adminer->homepage()) {
                        
                        echo "</table>\n";
                        if (!information_schema(DB)) {
-                               $analyze = "<input type='submit' value='" . lang('Analyze') . "'>";
-                               $optimize = "<input type='submit' name='optimize' value='" . lang('Optimize') . "'>";
+                               $vacuum = "<input type='submit' value='" . lang('Vacuum') . "'" . on_help("VACUUM") . "> ";
+                               $optimize = "<input type='submit' name='optimize' value='" . lang('Optimize') . "'" . on_help($jush == "sql" ? "OPTIMIZE TABLE" : "VACUUM OPTIMIZE") . "> ";
                                echo "<fieldset><legend>" . lang('Selected') . " <span id='selected'></span></legend><div>"
-                               . ($jush == "sqlite" ? $optimize . doc_command("vacuum") . " "
-                               : ($jush == "pgsql" ? $analyze . doc_command("vacuum") . " $optimize" . doc_command("vacuum") . " "
-                               : ($jush == "sql" ? $analyze . doc_command("analyze-table") . " $optimize" . doc_command("optimize-table") . " "
-                                       . "<input type='submit' name='check' value='" . lang('Check') . "'>" . doc_command("check-table") . " "
-                                       . "<input type='submit' name='repair' value='" . lang('Repair') . "'>" . doc_command("repair-table") . " "
+                               . ($jush == "sqlite" ? $vacuum
+                               : ($jush == "pgsql" ? $vacuum . $optimize
+                               : ($jush == "sql" ? "<input type='submit' value='" . lang('Analyze') . "'" . on_help("ANALYZE TABLE") . "> " . $optimize
+                                       . "<input type='submit' name='check' value='" . lang('Check') . "'" . on_help("CHECK TABLE") . "> "
+                                       . "<input type='submit' name='repair' value='" . lang('Repair') . "'" . on_help("REPAIR TABLE") . "> "
                                : "")))
-                               . (support("table") ? "<input type='submit' name='truncate' value='" . lang('Truncate') . "'" . confirm() . ">" . doc_command($jush == "sqlite" ? "delete" : "truncate" . ($jush == "pgsql" ? "" : "-table")) . " " : "")
-                               . "<input type='submit' name='drop' value='" . lang('Drop') . "'" . confirm() . ">" . doc_command("drop-table") . "\n";
+                               . (support("table") ? "<input type='submit' name='truncate' value='" . lang('Truncate') . "'" . confirm() . "" . on_help($jush == "sqlite" ? "DELETE" : "TRUNCATE" . ($jush == "pgsql" ? "" : " TABLE")) . "> " : "")
+                               . "<input type='submit' name='drop' value='" . lang('Drop') . "'" . confirm() . "" . on_help("DROP TABLE") . ">\n";
                                $databases = (support("scheme") ? schemas() : $adminer->databases());
                                if (count($databases) != 1 && $jush != "sqlite") {
                                        $db = (isset($_POST["target"]) ? $_POST["target"] : (support("scheme") ? $_GET["ns"] : DB));
index 04941b02d4155da9eb5145d92a52e661174f7452..edadec9ac276fb01310a7cc8477d4361adefadbb 100644 (file)
@@ -233,14 +233,13 @@ username.form['auth[driver]'].onchange();
                print_fieldset("select", lang('Select'), $select);
                $i = 0;
                $fun_group = array_filter(array(lang('Functions') => $functions, lang('Aggregation') => $grouping));
+               $select[""] = array();
                foreach ($select as $key => $val) {
                        $val = $_GET["columns"][$key];
-                       echo "<div>" . html_select("columns[$i][fun]", array(-1 => "") + $fun_group, $val["fun"]);
-                       echo "(" . select_input(" name='columns[$i][col]' onchange='selectFieldChange(this.form);'", $columns, $val["col"]) . ")</div>\n";
+                       echo "<div>" . html_select("columns[$i][fun]", array(-1 => "") + $fun_group, $val["fun"], ($key !== "" ? "" : " this.nextSibling.nextSibling.onchange();"));
+                       echo "(" . select_input(" name='columns[$i][col]' onchange='" . ($key !== ""  ? "selectFieldChange(this.form)" : "selectAddRow(this)") . ";'", $columns, $val["col"]) . ")</div>\n";
                        $i++;
                }
-               echo "<div>" . html_select("columns[$i][fun]", array(-1 => "") + $fun_group, "", "this.nextSibling.nextSibling.onchange();");
-               echo "(" . select_input(" name='columns[$i][col]' onchange='selectAddRow(this);'", $columns) . ")</div>\n";
                echo "</div></fieldset>\n";
        }
        
@@ -786,6 +785,7 @@ username.form['auth[driver]'].onchange();
                                                $links[] = preg_quote($table, '/');
                                        }
                                        echo "<script type='text/javascript'>\n";
+                                       echo "var jushLang = '$jush';\n";
                                        echo "var jushLinks = { $jush: [ '" . js_escape(ME) . (support("table") ? "table=" : "select=") . "\$&', /\\b(" . implode("|", $links) . ")\\b/g ] };\n";
                                        foreach (array("bac", "bra", "sqlite_quo", "mssql_bra") as $val) {
                                                echo "jushLinks.$val = jushLinks.$jush;\n";
index 65332058133d7505eab1cec3ae475118f7a7efe7..c567d37f60006aba2111df76dbacbba90049b8fe 100644 (file)
@@ -7,7 +7,7 @@
 * @return null
 */
 function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") {
-       global $LANG, $adminer, $connection, $drivers;
+       global $LANG, $adminer, $connection, $drivers, $jush;
        page_headers();
        $title_all = $title . ($title2 != "" ? ": $title2" : "");
        $title_page = strip_tags($title_all . (SERVER != "" && SERVER != "localhost" ? h(" - " . SERVER) : "") . " - " . $adminer->name());
@@ -34,6 +34,8 @@ function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") {
 document.body.className = document.body.className.replace(/ nojs/, ' js');
 </script>
 
+<div id="help" class="jush-<?php echo $jush; ?> jsonly hidden" onmouseover="helpOpen = 1;" onmouseout="helpMouseout();"></div>
+
 <div id="content">
 <?php
        if ($breadcrumb !== null) {
index 3c74f93aa288570b4d1dd9eb90b2fdd92e82e8f7..32b35a4755782f598e1e38d0fdfa455edd089f6a 100644 (file)
@@ -49,7 +49,7 @@ function select($result, $connection2 = null, $orgtables = array()) {
                                }
                                $types[$j] = $field->type;
                                echo "<th" . ($orgtable != "" || $field->name != $orgname ? " title='" . h(($orgtable != "" ? "$orgtable." : "") . $orgname) . "'" : "") . ">" . h($name)
-                                       . ($orgtables && $jush == "sql" ? doc_link("explain-output.html#explain_" . strtolower($name)) : "")
+                                       . ($orgtables ? doc_link("explain-output.html#explain_" . strtolower($name)) : "")
                                ;
                        }
                        echo "</thead>\n";
@@ -458,35 +458,21 @@ function doc_link($path) {
        global $jush, $connection;
        $urls = array(
                 'sql' => "http://dev.mysql.com/doc/refman/" . substr($connection->server_info, 0, 3) . "/en/",
+                /* not used:
                 'sqlite' => "http://www.sqlite.org/",
                 'pgsql' => "http://www.postgresql.org/docs/" . substr($connection->server_info, 0, 3) . "/static/",
                 'mssql' => "http://msdn.microsoft.com/library/",
                 'oracle' => "http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/",
+                */
        );
        return ($urls[$jush] ? "<a href='$urls[$jush]$path' target='_blank' rel='noreferrer'><sup>?</sup></a>" : "");
 }
 
-/** Create link to documentation of database command
-* @param string lower-case
-* @return string HTML code
+/** Return events to display help on mouse over
+* @param string
+* @param bool
+* @return string
 */
-function doc_command($command) {
-       global $jush;
-       switch ($jush) {
-               case 'sql': return doc_link("$command.html");
-               case 'sqlite': return doc_link("lang_" . str_replace("-", "", $command) . ".html");
-               case 'pgsql': return doc_link("sql-" . str_replace("-", "", $command) . ".html");
-               case 'mssql':
-                       $links = array(
-                               'drop-table' => 'ms173790',
-                               'truncate-table' => 'ms177570',
-                       );
-                       return doc_link("$links[$command].aspx");
-               case 'oracle':
-                       $links = array(
-                               'drop-table' => 'statements_9003.htm',
-                               'truncate-table' => 'statements_10006.htm',
-                       );
-                       return doc_link($links[$command]);
-       }
+function on_help($command, $right = 0) {
+       return " onmouseover=\"helpMouseover(this, '" . js_escape($command) . "', $right);\" onmouseout='helpMouseout();'";
 }
index f046ec441fc01fd71f9595d9d0d3753f006d74b3..0f9a7ba410c49926fc3a9524ba5477069ab443b8 100644 (file)
@@ -799,7 +799,10 @@ function input($field, $value, $function) {
                }
                $onchange = ($first ? " onchange=\"var f = this.form['function[" . h(js_escape(bracket_escape($field["field"]))) . "]']; if ($first > f.selectedIndex) f.selectedIndex = $first;\"" : "");
                $attrs .= $onchange;
-               echo (count($functions) > 1 ? html_select("function[$name]", $functions, $function === null || in_array($function, $functions) || isset($functions[$function]) ? $function : "", "functionChange(this);") : nbsp(reset($functions))) . '<td>';
+               echo (count($functions) > 1
+                       ? html_select("function[$name]", $functions, $function === null || in_array($function, $functions) || isset($functions[$function]) ? $function : "", "functionChange(this);")
+                       : nbsp(reset($functions))
+               ) . '<td>';
                $input = $adminer->editInput($_GET["edit"], $field, $attrs, $value); // usage in call is without a table
                if ($input != "") {
                        echo $input;
index 721c5efb3135701b72ac196f1b957218f3e52572..1d776e4396843211134f4c3f87fd700574985d07 100644 (file)
@@ -104,6 +104,7 @@ $translations = array(
        '%d in total' => '%d celkem',
        'Analyze' => 'Analyzovat',
        'Optimize' => 'Optimalizovat',
+       'Vacuum' => 'Vyčistit',
        'Check' => 'Zkontrolovat',
        'Repair' => 'Opravit',
        'Truncate' => 'Vyprázdnit',
index d84bf2a737f93377681b0801e6f3a1de80872d4f..05b62853eb3811406ec4ed54e3101d937dd702c4 100644 (file)
@@ -104,6 +104,7 @@ $translations = array(
        '%d in total' => 'xx',
        'Analyze' => 'xx',
        'Optimize' => 'xx',
+       'Vacuum' => 'xx',
        'Check' => 'xx',
        'Repair' => 'xx',
        'Truncate' => 'xx',
index 5d8cb84bd074dc2d5e1e537796f8ce9e3251b542..da66cfdd3b4d57818e7b743b6d1a151850dc7f1b 100644 (file)
@@ -22,9 +22,7 @@ foreach (process_list() as $i => $row) {
        if (!$i) {
                echo "<thead><tr lang='en'>" . (support("kill") ? "<th>&nbsp;" : "");
                foreach ($row as $key => $val) {
-                       echo "<th>$key"
-                       . ($jush == "sql" ? doc_link("show-processlist.html#processlist_" . strtolower($key)) : "")
-                       ;
+                       echo "<th>$key" . doc_link("show-processlist.html#processlist_" . strtolower($key));
                }
                echo "</thead>\n";
        }
index 9cfde19351de0dc9c177af238afac45793586d5d..d8bd140642c075c894c8903e73b01f0cc283d5e7 100644 (file)
@@ -68,6 +68,7 @@ input.required { box-shadow: 1px 1px 1px red; }
 #schema { margin-left: 60px; position: relative; -moz-user-select: none; -webkit-user-select: none; }
 #schema .table { border: 1px solid silver; padding: 0 2px; cursor: move; position: absolute; }
 #schema .references { position: absolute; }
+#help { position: absolute; border: 1px solid #999; background: #eee; padding: 5px; font-family: monospace; z-index: 1; }
 
 .rtl h2 { margin: 0 -18px 20px 0; }
 .rtl p, .rtl table, .rtl .error, .rtl .message { margin: 1em 0 0 20px; }
index 92b053d8d7096d4159bcc693781544568f27d187..64fbc9c5107a6fcb0718b5c51889946e01fca5c0 100644 (file)
@@ -612,3 +612,35 @@ function schemaMouseup(ev, db) {
                cookie('adminer_schema-' + db + '=' + s, 30); //! special chars in db
        }
 }
+
+var helpOpen;
+
+function helpMouseover(el, text, right) {
+       if (window.jush) {
+               helpOpen = 1;
+               var help = document.getElementById('help');
+               help.innerHTML = text;
+               jush.highlight_tag([ help ]);
+               alterClass(help, 'hidden');
+               var top = 0, left = 0, parent = el;
+               do {
+                       top += parent.offsetTop;
+                       left += parent.offsetLeft;
+               } while (parent = parent.offsetParent);
+               help.style.top = (top - (right ? (help.offsetHeight - el.offsetHeight) / 2 : help.offsetHeight)) + 'px';
+               help.style.left = (left + (right ? el.offsetWidth : (el.offsetWidth - help.offsetWidth) / 2)) + 'px';
+       }
+}
+
+function helpMouseout() {
+       helpOpen = 0;
+       setTimeout(function () {
+               if (!helpOpen) {
+                       helpClose();
+               }
+       }, 200);
+}
+
+function helpClose() {
+       alterClass(document.getElementById('help'), 'hidden', true);
+}