From 662c96494fde621775f01afabc91ac4d293004c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 8 Aug 2011 14:33:23 +0200 Subject: [PATCH 1/3] Fix and simplify theme selection js --- js/functions.js | 6 ++---- libraries/Theme.class.php | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/js/functions.js b/js/functions.js index 9eb12442f9..b16cf80c40 100644 --- a/js/functions.js +++ b/js/functions.js @@ -3135,10 +3135,8 @@ $(document).ready(function() { /** * Theme changer. */ - $('.take_theme').live('click', function(e) { - alert(e.target.nodeName); - var evt = $(e); - var what = evt.target.id; + $('.take_theme').click(function(e) { + var what = this.name; if (window.opener && window.opener.document.forms['setTheme'].elements['set_theme']) { window.opener.document.forms['setTheme'].elements['set_theme'].value = what; window.opener.document.forms['setTheme'].submit(); diff --git a/libraries/Theme.class.php b/libraries/Theme.class.php index 252d554cec..f6b08a06d4 100644 --- a/libraries/Theme.class.php +++ b/libraries/Theme.class.php @@ -324,7 +324,7 @@ class PMA_Theme .' (' . htmlspecialchars($this->getVersion()) . ')'; echo '

'; echo ''; From 021e81165360a6762a24be3a99f9da4f480d07ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 8 Aug 2011 15:23:20 +0200 Subject: [PATCH 2/3] Use standard way for passing messages --- js/makegrid.js | 12 ++++++------ js/messages.php | 7 +++++++ libraries/display_tbl.lib.php | 6 ------ 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/js/makegrid.js b/js/makegrid.js index 00d839f9ce..7755d1ece1 100644 --- a/js/makegrid.js +++ b/js/makegrid.js @@ -489,12 +489,12 @@ g.tableCreateTime = $('#table_create_time').val(); // assign column reorder & column sort hint - g.reorderHint = $('#col_order_hint').val(); - g.sortHint = $('#sort_hint').val(); - g.markHint = $('#col_mark_hint').val(); - g.colVisibHint = $('#col_visib_hint').val(); - g.showAllColText = $('#show_all_col_text').val(); - + g.reorderHint = PMA_messages['strColOrderHint']; + g.sortHint = PMA_messages['strSortHint']; + g.markHint = PMA_messages['strMarkHint']; + g.colVisibHint = PMA_messages['strVisibHint']; + g.showAllColText = PMA_messages['strShowAll']; + // initialize column order $col_order = $('#col_order'); if ($col_order.length > 0) { diff --git a/js/messages.php b/js/messages.php index d5565ac09a..72d5f04ea3 100644 --- a/js/messages.php +++ b/js/messages.php @@ -268,6 +268,13 @@ $js_messages['strNewerVersion'] = __('A newer version of phpMyAdmin is available $js_messages['strLatestAvailable'] = __(', latest stable version:'); $js_messages['strUpToDate'] = __('up to date'); +/* Browsing grid */ +$js_messages['strColOrderHint'] = __('Drag to reorder'); +$js_messages['strSortHint'] = __('Click to sort'); +$js_messages['strMarkHint'] = __('Click to mark/unmark'); +$js_messages['strVisibHint'] = __('Click the drop-down arrow
to toggle column\'s visibility'); +$js_messages['strShowAll'] = __('Show all'); + echo "var PMA_messages = new Array();\n"; foreach ($js_messages as $name => $js_message) { PMA_printJsValue("PMA_messages['" . $name . "']", $js_message); diff --git a/libraries/display_tbl.lib.php b/libraries/display_tbl.lib.php index 2f95f11c2b..711998d18e 100644 --- a/libraries/display_tbl.lib.php +++ b/libraries/display_tbl.lib.php @@ -419,12 +419,6 @@ function PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query, $id_for_di PMA_Table::sGetStatusInfo($GLOBALS['db'], $GLOBALS['table'], 'Create_time') . '" />'; } } - // generate hints - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; ?> From f16efa15ddfa22852a9195d40c3cc39d8b26cd4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 8 Aug 2011 15:23:27 +0200 Subject: [PATCH 3/3] Whitespace cleanup --- js/makegrid.js | 108 ++++++++++++++++++++++++------------------------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/js/makegrid.js b/js/makegrid.js index 7755d1ece1..13fcc37a4c 100644 --- a/js/makegrid.js +++ b/js/makegrid.js @@ -4,7 +4,7 @@ var g = { // constant minColWidth: 15, - + // variables, assigned with default value, changed later actionSpan: 5, colOrder: new Array(), // array of column order @@ -21,7 +21,7 @@ showColVisibHint: false, showAllColText: '', // string, text for "show all" button under column visibility list visibleHeadersCount: 0, // number of visible data headers - + // functions dragStartRsz: function(e, obj) { // start column resize var n = $(this.cRsz).find('div').index(obj); @@ -35,7 +35,7 @@ $('body').css('cursor', 'col-resize'); $('body').noSelect(); }, - + dragStartMove: function(e, obj) { // start column move // prepare the cCpy and cPointer from the dragged column $(this.cCpy).text($(obj).text()); @@ -49,10 +49,10 @@ $(this.cPointer).css({ top: objPos.top }); - + // get the column index, zero-based var n = this.getHeaderIdx(obj); - + this.colMov = { x0: e.pageX, y0: e.pageY, @@ -66,7 +66,7 @@ $('body').css('cursor', 'move'); $('body').noSelect(); }, - + dragMove: function(e) { if (this.colRsz) { var dx = e.pageX - this.colRsz.x0; @@ -79,7 +79,7 @@ $(this.cCpy) .css('left', this.colMov.objLeft + dx) .show(); - + // pointer animation var hoveredCol = this.getHoveredCol(e); if (hoveredCol) { @@ -103,7 +103,7 @@ } } }, - + dragEnd: function(e) { if (this.colRsz) { var dx = e.pageX - this.colRsz.x0; @@ -114,7 +114,7 @@ var n = this.colRsz.n; // do the resizing this.resize(n, nw); - + $('body').css('cursor', 'default'); this.reposRsz(); this.reposDrop(); @@ -134,7 +134,7 @@ } this.refreshRestoreButton(); } - + // animate new column position $(this.cCpy).stop(true, true) .animate({ @@ -149,7 +149,7 @@ $('body').css('cursor', 'default'); $('body').noSelect(false); }, - + /** * Resize column n to new width "nw" */ @@ -160,7 +160,7 @@ .css('width', nw); }); }, - + /** * Reposition column resize bars. */ @@ -175,7 +175,7 @@ } $(this.cRsz).css('height', $(this.t).height()); }, - + /** * Shift column from index oldn to newn. */ @@ -195,7 +195,7 @@ }); // reposition the column resize bars this.reposRsz(); - + // adjust the column visibility list if (newn < oldn) { $(g.cList).find('.lDiv div:eq(' + newn + ')') @@ -213,7 +213,7 @@ this.colVisib.splice(oldn, 1); this.colVisib.splice(newn, 0, tmp); }, - + /** * Find currently hovered table column's header (excluding actions column). * @return the hovered column's th object or undefined if no hovered column found. @@ -230,14 +230,14 @@ }); return hoveredCol; }, - + /** * Get a zero-based index from a tag in a table. */ getHeaderIdx: function(obj) { return $(obj).parents('tr').find('th.draggable').index(obj); }, - + /** * Reposition the table back to normal order. */ @@ -259,7 +259,7 @@ } this.refreshRestoreButton(); }, - + /** * Send column preferences (column order and visibility) to the server. */ @@ -276,7 +276,7 @@ table_create_time: this.tableCreateTime }); }, - + /** * Refresh restore button state. * Make restore button disabled if the table is similar with initial state. @@ -299,7 +299,7 @@ $('.restore_column').show(); } }, - + /** * Update current hint using the boolean values (showReorderHint, showSortHint, etc.). * It will hide the hint if all the boolean values is false. @@ -324,16 +324,16 @@ text += text.length > 0 ? '
' : ''; text += this.colVisibHint; } - + // hide the hint if no text this.qtip.disable(!text && e.type == 'mouseenter'); - + this.qtip.updateContent(text, false); } else { this.qtip.disable(true); } }, - + /** * Toggle column's visibility. * After calling this function and it returns true, afterToggleCol() must be called. @@ -367,7 +367,7 @@ } return true; }, - + /** * This must be called after calling toggleCol() and the return value is true. * @@ -379,12 +379,12 @@ this.reposRsz(); this.reposDrop(); this.sendColPrefs(); - + // check visible first row headers count this.visibleHeadersCount = $(this.t).find('tr:first th.draggable:visible').length; this.refreshRestoreButton(); }, - + /** * Show columns' visibility list. */ @@ -404,7 +404,7 @@ $(obj).addClass('coldrop-hover'); } }, - + /** * Hide columns' visibility list. */ @@ -412,7 +412,7 @@ $(this.cList).hide(); $(g.cDrop).find('.coldrop-hover').removeClass('coldrop-hover'); }, - + /** * Reposition the column visibility drop-down arrow. */ @@ -427,7 +427,7 @@ }); } }, - + /** * Show all hidden columns. */ @@ -440,54 +440,54 @@ this.afterToggleCol(); } } - + // wrap all data cells, except actions cell, with span $(t).find('th, td:not(:has(span))') .wrapInner(''); - + g.gDiv = document.createElement('div'); // create global div g.cRsz = document.createElement('div'); // column resizer g.cCpy = document.createElement('div'); // column copy, to store copy of dragged column header g.cPointer = document.createElement('div'); // column pointer, used when reordering column g.cDrop = document.createElement('div'); // column drop-down arrows g.cList = document.createElement('div'); // column visibility list - + // adjust g.cCpy g.cCpy.className = 'cCpy'; $(g.cCpy).hide(); - + // adjust g.cPoint g.cPointer.className = 'cPointer'; $(g.cPointer).css('visibility', 'hidden'); - + // adjust g.cDrop g.cDrop.className = 'cDrop'; - + // adjust g.cList g.cList.className = 'cList'; $(g.cList).hide(); - + // chain table and grid together t.grid = g; g.t = t; - + // get first row data columns var $firstRowCols = $(t).find('tr:first th.draggable'); - + // initialize g.visibleHeadersCount g.visibleHeadersCount = $firstRowCols.filter(':visible').length; - + // assign first column (actions) span if (! $(t).find('tr:first th:first').hasClass('draggable')) { // action header exist g.actionSpan = $(t).find('tr:first th:first').prop('colspan'); } else { g.actionSpan = 0; } - + // 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 g.reorderHint = PMA_messages['strColOrderHint']; g.sortHint = PMA_messages['strSortHint']; @@ -508,7 +508,7 @@ g.colOrder.push(i); } } - + // initialize column visibility $col_visib = $('#col_visib'); if ($col_visib.length > 0) { @@ -522,7 +522,7 @@ g.colVisib.push(1); } } - + if ($firstRowCols.length > 1) { // create column drop-down arrow(s) $(t).find('th:not(.draggable)').each(function() { @@ -542,7 +542,7 @@ }); $(g.cDrop).append(cd); }); - + // add column visibility control g.cList.innerHTML = '

'; var $listDiv = $(g.cList).find('div'); @@ -576,7 +576,7 @@ }); } } - + // create column borders $firstRowCols.each(function() { $this = $(this); @@ -588,15 +588,15 @@ $(g.cRsz).append(cb); }); g.reposRsz(); - + // bind event to update currently hovered qtip API $(t).find('th').mouseenter(function(e) { g.qtip = $(this).qtip('api'); }); - + // create qtip for each with draggable class PMA_createqTip($(t).find('th.draggable')); - + // register events if (g.reorderHint) { // make sure columns is reorderable $(t).find('th.draggable') @@ -621,7 +621,7 @@ } if ($firstRowCols.length > 1) { var $colVisibTh = $(t).find('th:not(.draggable)'); - + PMA_createqTip($colVisibTh); $colVisibTh.mouseenter(function(e) { g.showColVisibHint = true; @@ -663,10 +663,10 @@ $(t).find('td, th.draggable').mouseenter(function() { g.hideColList(); }); - + // add table class $(t).addClass('pma_table'); - + // link all divs $(t).before(g.gDiv); $(g.gDiv).append(t); @@ -686,13 +686,13 @@ return false; }); }; - + // document ready checking var docready = false; $(document).ready(function() { docready = true; }); - + // Additional jQuery functions /** * Make resizable, reorderable grid. @@ -732,6 +732,6 @@ } }); } - + })(jQuery);