From 039d56f97534f2c720df73f4e5325f3a9c838023 Mon Sep 17 00:00:00 2001 From: Aris Feryanto Date: Mon, 13 Jun 2011 08:28:21 +0700 Subject: [PATCH 1/4] Better CSS unit --- js/makegrid.js | 4 ++-- themes/original/css/theme_right.css.php | 13 +++++++------ themes/pmahomme/css/theme_right.css.php | 25 +++++++++++++------------ 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/js/makegrid.js b/js/makegrid.js index b43b163149..2a76d45259 100644 --- a/js/makegrid.js +++ b/js/makegrid.js @@ -338,7 +338,7 @@ $(this.dHint) .stop(true, true) .css({ - top: e.pageY - 10, + top: e.pageY, left: e.pageX + 15 }) .show('fast'); @@ -365,7 +365,7 @@ updateDraggableHint: function(e) { if (this.hintShown) { $(this.dHint).css({ - top: e.pageY - 10, + top: e.pageY, left: e.pageX + 15 }); } diff --git a/themes/original/css/theme_right.css.php b/themes/original/css/theme_right.css.php index d3c9468aac..1d602f706b 100644 --- a/themes/original/css/theme_right.css.php +++ b/themes/original/css/theme_right.css.php @@ -1915,15 +1915,16 @@ span.mysql-number { background: #333; border:1px solid #000; color: #FFF; - font-size: 8pt; + font-size: 0.8em; font-weight: bold; - height: 14px; + height: 1.2em; + margin-top: -1em; opacity: 0.8; overflow: hidden; - padding: 5px 10px; + padding: 0.5em 1em; position: absolute; text-shadow: -1px -1px #000; - -moz-border-radius: 5px; - -webkit-border-radius: 5px; - border-radius: 5px; + -moz-border-radius: 0.3em; + -webkit-border-radius: 0.3em; + border-radius: 0.3em; } diff --git a/themes/pmahomme/css/theme_right.css.php b/themes/pmahomme/css/theme_right.css.php index 65cf285967..fcbc3414fe 100644 --- a/themes/pmahomme/css/theme_right.css.php +++ b/themes/pmahomme/css/theme_right.css.php @@ -2237,12 +2237,12 @@ span.mysql-number { position: absolute; text-shadow: -1px -1px #000; - -moz-box-shadow: 0 0 8px #000; - -webkit-box-shadow: 0 0 8px #000; - box-shadow: 0 0 8px #000; - -moz-border-radius: 3px; - -webkit-border-radius: 3px; - border-radius: 3px; + -moz-box-shadow: 0 0 0.7em #000; + -webkit-box-shadow: 0 0 0.7em #000; + box-shadow: 0 0 0.7em #000; + -moz-border-radius: 0.3em; + -webkit-border-radius: 0.3em; + border-radius: 0.3em; } .cPointer { @@ -2267,15 +2267,16 @@ span.mysql-number { background: #333; border:1px solid #000; color: #FFF; - font-size: 8pt; + font-size: 0.8em; font-weight: bold; - height: 14px; + height: 1.2em; + margin-top: -1em; opacity: 0.8; overflow: hidden; - padding: 5px 10px; + padding: 0.5em 1em; position: absolute; text-shadow: -1px -1px #000; - -moz-border-radius: 5px; - -webkit-border-radius: 5px; - border-radius: 5px; + -moz-border-radius: 0.3em; + -webkit-border-radius: 0.3em; + border-radius: 0.3em; } From c89e0aa2ab2629eb9b47255b070eb14eef75aa19 Mon Sep 17 00:00:00 2001 From: Aris Feryanto Date: Mon, 13 Jun 2011 11:21:09 +0700 Subject: [PATCH 2/4] Merge hint for column sorting --- js/makegrid.js | 75 +++++++++++++++++-------- libraries/display_tbl.lib.php | 3 +- themes/original/css/theme_right.css.php | 2 - themes/pmahomme/css/theme_right.css.php | 2 - 4 files changed, 53 insertions(+), 29 deletions(-) diff --git a/js/makegrid.js b/js/makegrid.js index 2a76d45259..82fe8684b6 100644 --- a/js/makegrid.js +++ b/js/makegrid.js @@ -8,9 +8,13 @@ // variables, assigned with default value, changed later alignment: 'horizontal', // 3 possibilities: vertical, horizontal, horizontalflipped actionSpan: 5, - colOrder: new Array(), - tableCreateTime: null, - hintShown: false, + colOrder: new Array(), // array of column order + tableCreateTime: null, // table creation time + hintShown: false, // true if hint balloon is shown, used by updateHint() method + reorderHint: '', // string, hint for column reordering + sortHint: '', // string, hint for column sorting + showSortHint: false, // boolean, used by showHint() method + hintIsHiding: false, // true when hint is still shown, but hide() already called // functions dragStartRsz: function(e, obj) { // start column resize @@ -67,7 +71,7 @@ objLeft: objPos.left }; $('body').css('cursor', 'move'); - this.hideDraggableHint(); + this.hideHint(); $('body').noSelect(); }, @@ -331,38 +335,49 @@ }, /** - * Show draggable hint. + * Show hint with the text supplied. */ - showDraggableHint: function(e) { - if (!this.colMov) { // if not dragging - $(this.dHint) - .stop(true, true) - .css({ - top: e.pageY, - left: e.pageX + 15 - }) - .show('fast'); - this.hintShown = true; + showHint: function(e) { + if (!this.colRsz && !this.colMov) { // if not resizing or dragging + var text = this.reorderHint; + if (this.showSortHint) { + text += '
' + this.sortHint; + } + + $(this.dHint).html(text); + if (!this.hintShown || this.hintIsHiding) { + $(this.dHint) + .stop(true, true) + .css({ + top: e.pageY, + left: e.pageX + 15 + }) + .show('fast'); + this.hintShown = true; + this.hintIsHiding = false; + } } }, /** - * Hide draggable hint. + * Hide the hint. */ - hideDraggableHint: function() { + hideHint: function() { if (this.hintShown) { $(this.dHint) .stop(true, true) - .hide(150, function() { + .hide(300, function() { g.hintShown = false; + g.hintIsHiding = false; }); + this.hintIsHiding = true; } }, /** - * Update the draggable hint position. + * Update hint position. */ - updateDraggableHint: function(e) { + updateHint: function(e) { if (this.hintShown) { $(this.dHint).css({ top: e.pageY, @@ -391,7 +406,6 @@ // adjust g.dHint g.dHint.className = 'dHint'; - $(g.dHint).html($('#col_order_hint').val()); $(g.dHint).hide(); // chain table and grid together @@ -415,6 +429,10 @@ // assign table create time g.tableCreateTime = $('#table_create_time').val(); + // assign column reorder & column sort hint + g.reorderHint = $('#col_order_hint').val(); + g.sortHint = $('#sort_hint').val(); + // initialize column order $col_order = $('#col_order'); if ($col_order.length > 0) { @@ -453,14 +471,23 @@ }) // show/hide draggable column .mouseenter(function(e) { - g.showDraggableHint(e); + g.showHint(e); }) .mouseleave(function(e) { - g.hideDraggableHint(); + g.hideHint(); + }); + $(t).find('th.draggable a') + .mouseenter(function(e) { + g.showSortHint = true; + g.showHint(e); + }) + .mouseleave(function(e) { + g.showSortHint = false; + g.showHint(e); }); $(document).mousemove(function(e) { g.dragMove(e); - g.updateDraggableHint(e); + g.updateHint(e); }); $(document).mouseup(function(e) { g.dragEnd(e); diff --git a/libraries/display_tbl.lib.php b/libraries/display_tbl.lib.php index 77592b4257..aea4e4b7ba 100644 --- a/libraries/display_tbl.lib.php +++ b/libraries/display_tbl.lib.php @@ -388,6 +388,8 @@ function PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query, $id_for_di PMA_Table::sGetStatusInfo($GLOBALS['db'], $GLOBALS['table'], 'CREATE_TIME') . '" />'; // generate text for draggable column hint echo ''; + // generate text for sortable column hint + echo ''; ?> @@ -884,7 +886,6 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $ && $GLOBALS['cfg']['HeaderFlipType'] == 'css') { $order_link_params['style'] = 'direction: ltr; writing-mode: tb-rl;'; } - $order_link_params['title'] = __('Sort'); $order_link_content = ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped' && $GLOBALS['cfg']['HeaderFlipType'] == 'fake' ? PMA_flipstring(htmlspecialchars($fields_meta[$i]->name), "
\n") : htmlspecialchars($fields_meta[$i]->name)); $order_link = PMA_linkOrButton($order_url, $order_link_content . $order_img, $order_link_params, false, true); diff --git a/themes/original/css/theme_right.css.php b/themes/original/css/theme_right.css.php index 1d602f706b..8c99054fc5 100644 --- a/themes/original/css/theme_right.css.php +++ b/themes/original/css/theme_right.css.php @@ -1917,10 +1917,8 @@ span.mysql-number { color: #FFF; font-size: 0.8em; font-weight: bold; - height: 1.2em; margin-top: -1em; opacity: 0.8; - overflow: hidden; padding: 0.5em 1em; position: absolute; text-shadow: -1px -1px #000; diff --git a/themes/pmahomme/css/theme_right.css.php b/themes/pmahomme/css/theme_right.css.php index fcbc3414fe..3481fa55e7 100644 --- a/themes/pmahomme/css/theme_right.css.php +++ b/themes/pmahomme/css/theme_right.css.php @@ -2269,10 +2269,8 @@ span.mysql-number { color: #FFF; font-size: 0.8em; font-weight: bold; - height: 1.2em; margin-top: -1em; opacity: 0.8; - overflow: hidden; padding: 0.5em 1em; position: absolute; text-shadow: -1px -1px #000; From cf64d5282be2c3c20d323256c8aa9fc295fd5ee8 Mon Sep 17 00:00:00 2001 From: Aris Feryanto Date: Mon, 13 Jun 2011 12:08:17 +0700 Subject: [PATCH 3/4] Remember column order only in 'Browse' tab --- js/makegrid.js | 13 +++++--- libraries/Table.class.php | 6 ++-- libraries/display_tbl.lib.php | 62 +++++++++++++++++++++++++---------- sql.php | 3 ++ 4 files changed, 61 insertions(+), 23 deletions(-) diff --git a/js/makegrid.js b/js/makegrid.js index 82fe8684b6..bb998957da 100644 --- a/js/makegrid.js +++ b/js/makegrid.js @@ -9,7 +9,7 @@ alignment: 'horizontal', // 3 possibilities: vertical, horizontal, horizontalflipped actionSpan: 5, colOrder: new Array(), // array of column order - tableCreateTime: null, // table creation time + tableCreateTime: null, // table creation time, only available in "Browse tab" hintShown: false, // true if hint balloon is shown, used by updateHint() method reorderHint: '', // string, hint for column reordering sortHint: '', // string, hint for column sorting @@ -163,7 +163,9 @@ this.colMov.objLeft = objPos.left; this.colMov.n = this.colMov.newn; // send request to server to remember the column order - this.sendColOrder(); + if (this.tableCreateTime) { + this.sendColOrder(); + } this.refreshRestoreButton(); } @@ -293,8 +295,10 @@ this.shiftCol(i, j + 1); } } - // send request to server to remember the column order - this.sendColOrder(); + if (this.tableCreateTime) { + // send request to server to remember the column order + this.sendColOrder(); + } this.refreshRestoreButton(); }, @@ -427,6 +431,7 @@ } // assign table create time + // #table_create_time will only available if we are in "Browse" tab g.tableCreateTime = $('#table_create_time').val(); // assign column reorder & column sort hint diff --git a/libraries/Table.class.php b/libraries/Table.class.php index 712fa448c9..ae76194dd3 100644 --- a/libraries/Table.class.php +++ b/libraries/Table.class.php @@ -1375,12 +1375,14 @@ class PMA_Table if ($property == self::PROP_COLUMN_ORDER) { $curr_create_time = self::sGetStatusInfo($this->db_name, $this->name, 'CREATE_TIME'); if (isset($table_create_time) && - $table_create_time < $curr_create_time) { + $table_create_time > $curr_create_time) { + $this->uiprefs['CREATE_TIME'] = $curr_create_time; + } else { + // there is no $table_create_time, or // supplied $table_create_time is older than current create time, // so don't save return false; } - $this->uiprefs['CREATE_TIME'] = $curr_create_time; } // save the value $this->uiprefs[$property] = $value; diff --git a/libraries/display_tbl.lib.php b/libraries/display_tbl.lib.php index aea4e4b7ba..d2fb33b724 100644 --- a/libraries/display_tbl.lib.php +++ b/libraries/display_tbl.lib.php @@ -184,6 +184,20 @@ function PMA_setDisplayMode(&$the_disp_mode, &$the_total) } // end of the 'PMA_setDisplayMode()' function +/** + * Return true if we are currently browsing a table from the browse tab + * + * @return boolean + */ +function PMA_isBrowsing() +{ + return basename($GLOBALS['PMA_PHP_SELF']) == 'sql.php' + && ! ($is_count || $is_export || $is_func || $is_analyse) + && isset($analyzed_sql[0]['queryflags']['select_from']) + && count($analyzed_sql[0]['table_ref']) == 1; +} + + /** * Displays a navigation button * @@ -377,15 +391,17 @@ function PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query, $id_for_di getUiProp(PMA_Table::PROP_COLUMN_ORDER); - if ($col_order) { - echo ''; + if (PMA_isBrowsing()) { + // generate the column order, if it is set + $pmatable = new PMA_Table($GLOBALS['table'], $GLOBALS['db']); + $col_order = $pmatable->getUiProp(PMA_Table::PROP_COLUMN_ORDER); + if ($col_order) { + echo ''; + } + // generate table create time + echo ''; } - // generate table create time - echo ''; // generate text for draggable column hint echo ''; // generate text for sortable column hint @@ -753,9 +769,13 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $ } } - // prepare to get the column order, if there is - $pmatable = new PMA_Table($GLOBALS['table'], $GLOBALS['db']); - $col_order = $pmatable->getUiProp(PMA_Table::PROP_COLUMN_ORDER); + if (PMA_isBrowsing()) { + // prepare to get the column order, if available + $pmatable = new PMA_Table($GLOBALS['table'], $GLOBALS['db']); + $col_order = $pmatable->getUiProp(PMA_Table::PROP_COLUMN_ORDER); + } else { + $col_order = false; + } for ($j = 0; $j < $fields_cnt; $j++) { // assign $i with appropriate column order @@ -1315,9 +1335,13 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) { // 2. Displays the rows' values - // prepare to get the column order, if there is - $pmatable = new PMA_Table($GLOBALS['table'], $GLOBALS['db']); - $col_order = $pmatable->getUiProp(PMA_Table::PROP_COLUMN_ORDER); + if (PMA_isBrowsing()) { + // prepare to get the column order, if available + $pmatable = new PMA_Table($GLOBALS['table'], $GLOBALS['db']); + $col_order = $pmatable->getUiProp(PMA_Table::PROP_COLUMN_ORDER); + } else { + $col_order = false; + } for ($j = 0; $j < $fields_cnt; ++$j) { // assign $i with appropriate column order @@ -1689,9 +1713,13 @@ function PMA_displayVerticalTable() echo '' . "\n"; } // end if - // prepare to get the column order, if there is - $pmatable = new PMA_Table($GLOBALS['table'], $GLOBALS['db']); - $col_order = $pmatable->getUiProp(PMA_Table::PROP_COLUMN_ORDER); + if (PMA_isBrowsing()) { + // prepare to get the column order, if available + $pmatable = new PMA_Table($GLOBALS['table'], $GLOBALS['db']); + $col_order = $pmatable->getUiProp(PMA_Table::PROP_COLUMN_ORDER); + } else { + $col_order = false; + } // Displays data foreach ($vertical_display['desc'] AS $j => $val) { diff --git a/sql.php b/sql.php index 17e0974ece..b1b3e242d0 100644 --- a/sql.php +++ b/sql.php @@ -153,6 +153,9 @@ if(isset($_REQUEST['get_set_values']) && $_REQUEST['get_set_values'] == true) { PMA_ajaxResponse(NULL, true, $extra_data); } +/** + * Check ajax request to set the column order + */ if(isset($_REQUEST['set_col_order']) && $_REQUEST['set_col_order'] == true) { $pmatable = new PMA_Table($table, $db); $retval = $pmatable->setUiProp(PMA_Table::PROP_COLUMN_ORDER, $_REQUEST['col_order'], $_REQUEST['table_create_time']); From 4d27d21e80ef895990c919a5164fac535c9283d4 Mon Sep 17 00:00:00 2001 From: Aris Feryanto Date: Mon, 13 Jun 2011 13:46:18 +0700 Subject: [PATCH 4/4] No reorder column for table with only 1 column --- js/makegrid.js | 42 ++++++++++++++++++++++++----------- libraries/Table.class.php | 2 +- libraries/display_tbl.lib.php | 4 ++++ 3 files changed, 34 insertions(+), 14 deletions(-) diff --git a/js/makegrid.js b/js/makegrid.js index bb998957da..040f35d183 100644 --- a/js/makegrid.js +++ b/js/makegrid.js @@ -13,6 +13,7 @@ hintShown: false, // true if hint balloon is shown, used by updateHint() method reorderHint: '', // string, hint for column reordering sortHint: '', // string, hint for column sorting + showReorderHint: false, // boolean, used by showHint() method showSortHint: false, // boolean, used by showHint() method hintIsHiding: false, // true when hint is still shown, but hide() already called @@ -343,9 +344,19 @@ */ showHint: function(e) { if (!this.colRsz && !this.colMov) { // if not resizing or dragging - var text = this.reorderHint; + var text = ''; + if (this.showReorderHint) { + text += this.reorderHint; + } if (this.showSortHint) { - text += '
' + this.sortHint; + text += this.showReorderHint ? '
' : ''; + text += this.sortHint; + } + + // hide the hint if no text + if (!text) { + this.hideHint(); + return; } $(this.dHint).html(text); @@ -438,6 +449,9 @@ g.reorderHint = $('#col_order_hint').val(); g.sortHint = $('#sort_hint').val(); + // determine whether to show the column reordering hint or not + g.showReorderHint = $firstRowCols.length > 1; + // initialize column order $col_order = $('#col_order'); if ($col_order.length > 0) { @@ -470,17 +484,19 @@ .wrapInner(''); // register events - $(t).find('th.draggable') - .mousedown(function(e) { - g.dragStartMove(e, this); - }) - // show/hide draggable column - .mouseenter(function(e) { - g.showHint(e); - }) - .mouseleave(function(e) { - g.hideHint(); - }); + if ($firstRowCols.length > 1) { + $(t).find('th.draggable') + .mousedown(function(e) { + g.dragStartMove(e, this); + }) + // show/hide draggable column + .mouseenter(function(e) { + g.showHint(e); + }) + .mouseleave(function(e) { + g.hideHint(); + }); + } $(t).find('th.draggable a') .mouseenter(function(e) { g.showSortHint = true; diff --git a/libraries/Table.class.php b/libraries/Table.class.php index ae76194dd3..cfc28d6ee5 100644 --- a/libraries/Table.class.php +++ b/libraries/Table.class.php @@ -1375,7 +1375,7 @@ class PMA_Table if ($property == self::PROP_COLUMN_ORDER) { $curr_create_time = self::sGetStatusInfo($this->db_name, $this->name, 'CREATE_TIME'); if (isset($table_create_time) && - $table_create_time > $curr_create_time) { + $table_create_time == $curr_create_time) { $this->uiprefs['CREATE_TIME'] = $curr_create_time; } else { // there is no $table_create_time, or diff --git a/libraries/display_tbl.lib.php b/libraries/display_tbl.lib.php index d2fb33b724..2a15a340f8 100644 --- a/libraries/display_tbl.lib.php +++ b/libraries/display_tbl.lib.php @@ -191,6 +191,10 @@ function PMA_setDisplayMode(&$the_disp_mode, &$the_total) */ function PMA_isBrowsing() { + // global variables set from sql.php + global $is_count, $is_export, $is_func, $is_analyze; + global $analyzed_sql; + return basename($GLOBALS['PMA_PHP_SELF']) == 'sql.php' && ! ($is_count || $is_export || $is_func || $is_analyse) && isset($analyzed_sql[0]['queryflags']['select_from'])