Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/js/sql.js
diff options
context:
space:
mode:
authorMadhura Jayaratne <madhura.cj@gmail.com>2014-11-27 18:13:59 +0300
committerMadhura Jayaratne <madhura.cj@gmail.com>2014-11-27 18:13:59 +0300
commitb1ab5e3e5b0b196bdcc997836359d45f5dab916e (patch)
tree8bb185cd33e21e60aea11671ce98460bfe9b1919 /js/sql.js
parent823a68f60124e3f9c20254aca52ac61dd011500d (diff)
Avoid using #table_results for jQuery selections
Signed-off-by: Madhura Jayaratne <madhura.cj@gmail.com>
Diffstat (limited to 'js/sql.js')
-rw-r--r--js/sql.js92
1 files changed, 48 insertions, 44 deletions
diff --git a/js/sql.js b/js/sql.js
index e9838f139b..e01ebc2398 100644
--- a/js/sql.js
+++ b/js/sql.js
@@ -40,23 +40,24 @@ function PMA_urlencode(str)
* Get the field name for the current field. Required to construct the query
* for grid editing
*
- * @param $this_field jQuery object that points to the current field's tr
+ * @param $table_results enclosing results table
+ * @param $this_field jQuery object that points to the current field's tr
*/
-function getFieldName($this_field)
+function getFieldName($table_results, $this_field)
{
var this_field_index = $this_field.index();
// ltr or rtl direction does not impact how the DOM was generated
// check if the action column in the left exist
- var left_action_exist = !$('#table_results').find('th:first').hasClass('draggable');
+ var left_action_exist = !$table_results.find('th:first').hasClass('draggable');
// number of column span for checkbox and Actions
- var left_action_skip = left_action_exist ? $('#table_results').find('th:first').attr('colspan') - 1 : 0;
+ var left_action_skip = left_action_exist ? $table_results.find('th:first').attr('colspan') - 1 : 0;
// If this column was sorted, the text of the a element contains something
// like <small>1</small> that is useful to indicate the order in case
// of a sort on multiple columns; however, we dont want this as part
// of the column name so we strip it ( .clone() to .end() )
- var field_name = $('#table_results')
+ var field_name = $table_results
.find('thead')
.find('th:eq(' + (this_field_index - left_action_skip) + ') a')
.clone() // clone the element
@@ -66,7 +67,7 @@ function getFieldName($this_field)
.text(); // grab the text
// happens when just one row (headings contain no a)
if (field_name === '') {
- var $heading = $('#table_results').find('thead').find('th:eq(' + (this_field_index - left_action_skip) + ')').children('span');
+ var $heading = $table_results.find('thead').find('th:eq(' + (this_field_index - left_action_skip) + ')').children('span');
// may contain column comment enclosed in a span - detach it temporarily to read the column name
var $tempColComment = $heading.children().detach();
field_name = $heading.text();
@@ -94,7 +95,6 @@ AJAX.registerTeardown('sql.js', function () {
$("#sqlqueryform.ajax").die('submit');
$("input[name=navig].ajax").die('click');
$("#pageselector").die('change');
- $("#table_results.ajax").find("a[title=Sort]").die('click');
$(".displayOptionsForm.ajax").die('submit');
$('th.column_heading.pointer').die('hover');
$('th.column_heading.marker').die('click');
@@ -168,7 +168,9 @@ AJAX.registerOnload('sql.js', function () {
* @memberOf jQuery
*/
$("#sqlqueryresults").live('makegrid', function () {
- PMA_makegrid($('#table_results')[0]);
+ $('.table_results').each(function () {
+ PMA_makegrid(this);
+ });
});
/*
@@ -177,15 +179,16 @@ AJAX.registerOnload('sql.js', function () {
* @memberOf jQuery
*/
$("#sqlqueryresults").live('stickycolumns', function () {
- if ($("#table_results").length === 0) {
- return;
- }
- //add sticky columns div
- initStickyColumns();
- rearrangeStickyColumns();
- //adjust sticky columns on scroll
- $(window).bind('scroll', function() {
- handleStickyColumns();
+ $(".sticky_columns").remove();
+ $(".table_results").each(function () {
+ var $table_results = $(this);
+ //add sticky columns div
+ var $stick_columns = initStickyColumns($table_results);
+ rearrangeStickyColumns($stick_columns, $table_results);
+ //adjust sticky columns on scroll
+ $(window).bind('scroll', function() {
+ handleStickyColumns($stick_columns, $table_results);
+ });
});
});
@@ -557,7 +560,7 @@ function PMA_changeClassForColumn($this_th, newclass, isAddClass)
if (has_big_t) {
th_index--;
}
- var $tds = $("#table_results").find('tbody tr').find('td.data:eq(' + th_index + ')');
+ var $tds = $this_th.parents(".table_results").find('tbody tr').find('td.data:eq(' + th_index + ')');
if (isAddClass === undefined) {
$tds.toggleClass(newclass);
} else {
@@ -725,39 +728,35 @@ function initProfilingTables()
/*
* Set position, left, top, width of sticky_columns div
*/
-function setStickyColumnsPosition(position, top, left) {
- if ($("#sticky_columns").length !== 0) {
- $("#sticky_columns")
- .css("position", position)
- .css("top", top)
- .css("left", left ? left : "auto")
- .css("width", $("#table_results").width());
- }
+function setStickyColumnsPosition($sticky_columns, $table_results, position, top, left) {
+ $sticky_columns
+ .css("position", position)
+ .css("top", top)
+ .css("left", left ? left : "auto")
+ .css("width", $table_results.width());
}
/*
* Initialize sticky columns
*/
-function initStickyColumns() {
+function initStickyColumns($table_results) {
fixedTop = $('#floating_menubar').height();
- if ($("#sticky_columns").length === 0) {
- $('<table id="sticky_columns"></table>')
- .insertBefore('#page_content')
+ var $sticky_columns = $('<table class="sticky_columns"></table>')
+ .insertBefore($table_results)
.css("position", "fixed")
.css("z-index", "99")
- .css("width", $("#table_results").width())
+ .css("width", $table_results.width())
.css("margin-left", $('#page_content').css("margin-left"))
.css("top", fixedTop)
.css("display", "none");
- }
+ return $sticky_columns;
}
/*
* Arrange/Rearrange columns in sticky header
*/
-function rearrangeStickyColumns() {
- var $sticky_columns = $("#sticky_columns");
- var $originalHeader = $("#table_results > thead");
+function rearrangeStickyColumns($sticky_columns, $table_results) {
+ var $originalHeader = $table_results.find("thead");
var $originalColumns = $originalHeader.find("tr:first").children();
var $clonedHeader = $originalHeader.clone();
// clone width per cell
@@ -768,25 +767,30 @@ function rearrangeStickyColumns() {
}
/*
+ * Adjust sticky columns on horizontal/vertical scroll for all tables
+ */
+function handleAllStickyColumns() {
+ $('.sticky_columns').each(function () {
+ handleStickyColumns($(this), $(this).next('.table_results'));
+ });
+}
+
+/*
* Adjust sticky columns on horizontal/vertical scroll
*/
-function handleStickyColumns() {
- if ($("#table_results").length === 0) {
- return;
- }
+function handleStickyColumns($sticky_columns, $table_results) {
var currentScrollX = $(window).scrollLeft();
var windowOffset = $(window).scrollTop();
- var tableStartOffset = $("#table_results").offset().top;
- var tableEndOffset = tableStartOffset + $("#table_results").height();
- var $sticky_columns = $("#sticky_columns");
+ var tableStartOffset = $table_results.offset().top;
+ var tableEndOffset = tableStartOffset + $table_results.height();
if (windowOffset >= tableStartOffset && windowOffset <= tableEndOffset) {
//for horizontal scrolling
if(prevScrollX != currentScrollX) {
prevScrollX = currentScrollX;
- setStickyColumnsPosition("absolute", fixedTop + windowOffset);
+ setStickyColumnsPosition($sticky_columns, $table_results, "absolute", fixedTop + windowOffset);
//for vertical scrolling
} else {
- setStickyColumnsPosition("fixed", fixedTop, $("#pma_navigation").width() - currentScrollX);
+ setStickyColumnsPosition($sticky_columns, $table_results, "fixed", fixedTop, $("#pma_navigation").width() - currentScrollX);
}
$sticky_columns.show();
} else {