]> git.joonet.de Git - adminer.git/commitdiff
Highlight checked rows
authorJakub Vrana <jakub@vrana.cz>
Thu, 11 Aug 2011 11:48:27 +0000 (13:48 +0200)
committerJakub Vrana <jakub@vrana.cz>
Thu, 11 Aug 2011 11:48:27 +0000 (13:48 +0200)
adminer/db.inc.php
adminer/include/connect.inc.php
adminer/processlist.inc.php
adminer/select.inc.php
adminer/static/default.css
adminer/static/functions.js
changes.txt
editor/db.inc.php

index 815f92ce9c2022b6c1d2062fe387f85c3d9f7747..e618bb90391d1d9c79169d7401fb6fcb302d6a2b 100644 (file)
@@ -48,7 +48,7 @@ if ($adminer->homepage()) {
                        if ($_POST["search"] && $_POST["query"] != "") {
                                search_tables();
                        }
-                       echo "<table cellspacing='0' class='nowrap' onclick='tableClick(event);'>\n";
+                       echo "<table cellspacing='0' class='nowrap checkable' onclick='tableClick(event);'>\n";
                        echo '<thead><tr class="wrap"><td><input id="check-all" type="checkbox" onclick="formCheck(this, /^(tables|views)\[/);">';
                        echo '<th>' . lang('Table');
                        echo '<td>' . lang('Engine');
@@ -89,6 +89,7 @@ if ($adminer->homepage()) {
                                echo "<td align='right' id='sum-$key'>&nbsp;";
                        }
                        echo "</table>\n";
+                       echo "<script type='text/javascript'>tableCheck();</script>\n";
                        if (!information_schema(DB)) {
                                echo "<p>" . ($jush == "sql" ? "<input type='submit' value='" . lang('Analyze') . "'> <input type='submit' name='optimize' value='" . lang('Optimize') . "'> <input type='submit' name='check' value='" . lang('Check') . "'> <input type='submit' name='repair' value='" . lang('Repair') . "'> " : "") . "<input type='submit' name='truncate' value='" . lang('Truncate') . "'" . confirm("formChecked(this, /tables/)") . "> <input type='submit' name='drop' value='" . lang('Drop') . "'" . confirm("formChecked(this, /tables|views/)", 1) . ">\n"; // 1 - eventStop
                                $databases = (support("scheme") ? schemas() : get_databases());
index 1f354e142944537bd273ffec4274253893bb9dad..fc11ecf217d01782485783175dd2d100bbe4dcd0 100644 (file)
@@ -31,7 +31,7 @@ function connect_error() {
                        $scheme = support("scheme");
                        $collations = collations();
                        echo "<form action='' method='post'>\n";
-                       echo "<table cellspacing='0' onclick='tableClick(event);'>\n";
+                       echo "<table cellspacing='0' class='checkable' onclick='tableClick(event);'>\n";
                        echo "<thead><tr><td>&nbsp;<th>" . lang('Database') . "<td>" . lang('Collation') . "<td>" . lang('Tables') . "</thead>\n";
                        foreach ($databases as $db) {
                                $root = h(ME) . "db=" . urlencode($db);
@@ -42,6 +42,7 @@ function connect_error() {
                                echo "\n";
                        }
                        echo "</table>\n";
+                       echo "<script type='text/javascript'>tableCheck();</script>\n";
                        echo "<p><input type='submit' name='drop' value='" . lang('Drop') . "'" . confirm("formChecked(this, /db/)", 1) . ">\n"; // 1 - eventStop
                        echo "<input type='hidden' name='token' value='$token'>\n";
                        echo "<a href='" . h(ME) . "refresh=1' onclick='eventStop(event);'>" . lang('Refresh') . "</a>\n";
index c71abacafd0f8251100e9a258fe4ac0cb9d7d754..fd39cb5e3f46fa962579c994636764496ad7d5cd 100644 (file)
@@ -13,7 +13,7 @@ page_header(lang('Process list'), $error);
 ?>
 
 <form action="" method="post">
-<table cellspacing="0" onclick="tableClick(event);" class="nowrap">
+<table cellspacing="0" onclick="tableClick(event);" class="nowrap checkable">
 <?php
 // HTML valid because there is always at least one process
 $i = -1;
@@ -29,6 +29,7 @@ foreach (process_list() as $i => $row) {
 }
 ?>
 </table>
+<script type='text/javascript'>tableCheck();</script>
 <p>
 <?php
 if (support("kill")) {
index 1220954e99ebdd3be6dfa44fab597c438539e747..ddd237b2cf7b6318dc8f61ce24b8a0482d4f6086 100644 (file)
@@ -250,7 +250,7 @@ if (!$columns) {
                } else {
                        $backward_keys = $adminer->backwardKeys($TABLE, $table_name);
                        
-                       echo "<table cellspacing='0' class='nowrap' onclick='tableClick(event);' onkeydown='return editingKeydown(event);'>\n";
+                       echo "<table cellspacing='0' class='nowrap checkable' onclick='tableClick(event);' onkeydown='return editingKeydown(event);'>\n";
                        echo "<thead><tr>" . (!$group && $select ? "" : "<td><input type='checkbox' id='all-page' onclick='formCheck(this, /check/);'> <a href='" . h($_GET["modify"] ? remove_from_uri("modify") : $_SERVER["REQUEST_URI"] . "&modify=1") . "'>" . lang('edit') . "</a>");
                        $names = array();
                        $functions = array();
@@ -368,6 +368,7 @@ if (!$columns) {
                                echo "</tr>\n"; // close to allow white-space: pre
                        }
                        echo "</table>\n";
+                       echo (!$group && $select ? "" : "<script type='text/javascript'>tableCheck();</script>\n");
                }
                
                if ($rows || $page) {
index fe3caa9057d3fe8917021ce2d942a70d49cad3ee..1d7b37076762967d4c488b07c6d5be3ca773c635 100644 (file)
@@ -17,7 +17,7 @@ p { margin: .8em 20px 0 0; }
 img { vertical-align: middle; border: 0; }
 td img { max-width: 200px; max-height: 200px; }
 code { background: #eee; }
-tr:hover td, tr:hover th { background: #ddf; }
+tbody tr:hover td, tbody tr:hover th { background: #eee; }
 pre { margin: 1em 0 0; }
 input[type=image] { vertical-align: middle; }
 .version { color: #777; font-size: 67%; }
@@ -33,6 +33,7 @@ input[type=image] { vertical-align: middle; }
 .enum { color: #007F7F; }
 .binary { color: red; }
 .odd td { background: #F5F5F5; }
+.js .checked td, .js .checked th { background: #ddf; }
 .time { color: silver; font-size: 70%; }
 .function { text-align: right; }
 .number { text-align: right; }
index 182e803d80e103f0d7971ddb4d7ff6f2a82800af..149cc1324bedcda36139868ee9747db021c2b3cd 100644 (file)
@@ -38,6 +38,14 @@ function selectValue(select) {
        return ((selected.attributes.value || {}).specified ? selected.value : selected.text);
 }
 
+/** Set checked class
+* @param HTMLInputElement
+*/
+function trCheck(el) {
+       var tr = el.parentNode.parentNode;
+       tr.className = tr.className.replace(/(^|\s)checked(\s|$)/, '$2') + (el.checked ? ' checked' : '');
+}
+
 /** Check all elements matching given name
 * @param HTMLInputElement
 * @param RegExp
@@ -47,6 +55,21 @@ function formCheck(el, name) {
        for (var i=0; i < elems.length; i++) {
                if (name.test(elems[i].name)) {
                        elems[i].checked = el.checked;
+                       trCheck(elems[i]);
+               }
+       }
+}
+
+/** Check all rows in <table class="checkable">
+*/
+function tableCheck() {
+       var tables = document.getElementsByTagName('table');
+       for (var i=0; i < tables.length; i++) {
+               if (/(^|\s)checkable(\s|$)/.test(tables[i].className)) {
+                       var trs = tables[i].getElementsByTagName('tr');
+                       for (var j=0; j < trs.length; j++) {
+                               trCheck(trs[j].firstChild.firstChild);
+                       }
                }
        }
 }
@@ -55,7 +78,9 @@ function formCheck(el, name) {
 * @param string
 */
 function formUncheck(id) {
-       document.getElementById(id).checked = false;
+       var el = document.getElementById(id);
+       el.checked = false;
+       trCheck(el);
 }
 
 /** Get number of checked elements matching given name
@@ -78,16 +103,23 @@ function formChecked(el, name) {
 * @param MouseEvent
 */
 function tableClick(event) {
+       var click = true;
        var el = event.target || event.srcElement;
        while (!/^tr$/i.test(el.tagName)) {
-               if (/^(table|a|input|textarea)$/i.test(el.tagName)) {
+               if (/^table$/i.test(el.tagName)) {
                        return;
                }
+               if (/^(a|input|textarea)$/i.test(el.tagName)) {
+                       click = false;
+               }
                el = el.parentNode;
        }
        el = el.firstChild.firstChild;
-       el.click && el.click();
-       el.onclick && el.onclick();
+       if (click) {
+               el.click && el.click();
+               el.onclick && el.onclick();
+       }
+       trCheck(el);
 }
 
 /** Set HTML code of an element
index 5e58906ab6de593ee9be5bf13c098da5d00bbb96..b8c44e5c99bd4de5b6eb3f62e514187958ff1833 100644 (file)
@@ -1,4 +1,5 @@
 Adminer 3.3.3-dev:
+Highlight checked rows
 Titles of links in database overview and navigation
 Fix trigger export (SQLite)
 Default trigger statement (SQLite, PostgreSQL)
index 9c8e7f66a70da4fa4668d2506a5474d3be2d50cb..3eaac33206bda52243d0f558cafa8dc0a18e1fd3 100644 (file)
@@ -7,7 +7,7 @@ if ($adminer->homepage()) {
        if ($_POST["query"] != "") {
                search_tables();
        }
-       echo "<table cellspacing='0' class='nowrap' onclick='tableClick(event);'>\n";
+       echo "<table cellspacing='0' class='nowrap checkable' onclick='tableClick(event);'>\n";
        echo '<thead><tr class="wrap"><td><input id="check-all" type="checkbox" onclick="formCheck(this, /^tables\[/);"><th>' . lang('Table') . '<td>' . lang('Rows') . "</thead>\n";
        foreach (table_status() as $table => $row) {
                $name = $adminer->tableName($row);
@@ -19,5 +19,6 @@ if ($adminer->homepage()) {
                }
        }
        echo "</table>\n";
+       echo "<script type='text/javascript'>tableCheck();</script>\n";
        echo "</form>\n";
 }