').append(data.message).dialog({
title: PMA_messages.strBrowseForeignValues,
width: Math.min($(window).width() - 100, 700),
maxHeight: $(window).height() - 100,
dialogClass: 'browse_foreign_modal',
close: function (ev, ui) {
// remove event handlers attached to elements related to dialog
$(tableId).off('click', 'td a.foreign_value');
$(formId).off('click', showAllId);
$(formId).off('submit');
// remove dialog itself
$(this).remove();
},
modal: true
});
}).done(function () {
var showAll = false;
$(tableId).on('click', 'td a.foreign_value', function (e) {
e.preventDefault();
var $input = $this_a.prev('input[type=text]');
// Check if input exists or get CEdit edit_box
if ($input.length === 0) {
$input = $this_a.closest('.edit_area').prev('.edit_box');
}
// Set selected value as input value
$input.val($(this).data('key'));
$dialog.dialog('close');
});
$(formId).on('click', showAllId, function () {
showAll = true;
});
$(formId).on('submit', function (e) {
e.preventDefault();
// if filter value is not equal to old value
// then reset page number to 1
if ($(filterId).val() !== $(filterId).data('old')) {
$(formId).find('select[name=pos]').val('0');
}
var postParams = $(this).serializeArray();
// if showAll button was clicked to submit form then
// add showAll button parameter to form
if (showAll) {
postParams.push({
name: $(showAllId).attr('name'),
value: $(showAllId).val()
});
}
// updates values in dialog
$.post($(this).attr('action') + '?ajax_request=1', postParams, function (data) {
var $obj = $('
').html(data.message);
$(formId).html($obj.find(formId).html());
$(tableId).html($obj.find(tableId).html());
});
showAll = false;
});
});
}
AJAX.registerOnload('sql.js', function () {
$('body').on('click', 'a.browse_foreign', function (e) {
e.preventDefault();
browseForeignDialog($(this));
});
/**
* vertical column highlighting in horizontal mode when hovering over the column header
*/
$(document).on('mouseenter', 'th.column_heading.pointer', function (e) {
PMA_changeClassForColumn($(this), 'hover', true);
});
$(document).on('mouseleave', 'th.column_heading.pointer', function (e) {
PMA_changeClassForColumn($(this), 'hover', false);
});
/**
* vertical column marking in horizontal mode when clicking the column header
*/
$(document).on('click', 'th.column_heading.marker', function () {
PMA_changeClassForColumn($(this), 'marked');
});
/**
* create resizable table
*/
$('.sqlqueryresults').trigger('makegrid').trigger('stickycolumns');
});
/*
* Profiling Chart
*/
function makeProfilingChart () {
if ($('#profilingchart').length === 0 ||
$('#profilingchart').html().length !== 0 ||
!$.jqplot || !$.jqplot.Highlighter || !$.jqplot.PieRenderer
) {
return;
}
var data = [];
$.each(JSON.parse($('#profilingChartData').html()), function (key, value) {
data.push([key, parseFloat(value)]);
});
// Remove chart and data divs contents
$('#profilingchart').html('').show();
$('#profilingChartData').html('');
PMA_createProfilingChart('profilingchart', data);
}
/*
* initialize profiling data tables
*/
function initProfilingTables () {
if (!$.tablesorter) {
return;
}
$('#profiletable').tablesorter({
widgets: ['zebra'],
sortList: [[0, 0]],
textExtraction: function (node) {
if (node.children.length > 0) {
return node.children[0].innerHTML;
} else {
return node.innerHTML;
}
}
});
$('#profilesummarytable').tablesorter({
widgets: ['zebra'],
sortList: [[1, 1]],
textExtraction: function (node) {
if (node.children.length > 0) {
return node.children[0].innerHTML;
} else {
return node.innerHTML;
}
}
});
}
/*
* Set position, left, top, width of sticky_columns div
*/
function setStickyColumnsPosition ($sticky_columns, $table_results, position, top, left, margin_left) {
$sticky_columns
.css('position', position)
.css('top', top)
.css('left', left ? left : 'auto')
.css('margin-left', margin_left ? margin_left : '0px')
.css('width', $table_results.width());
}
/*
* Initialize sticky columns
*/
function initStickyColumns ($table_results) {
return $('
')
.insertBefore($table_results)
.css('position', 'fixed')
.css('z-index', '99')
.css('width', $table_results.width())
.css('margin-left', $('#page_content').css('margin-left'))
.css('top', $('#floating_menubar').height())
.css('display', 'none');
}
/*
* Arrange/Rearrange columns in sticky header
*/
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
$clonedHeader.find('tr:first').children().width(function (i,val) {
var width = $originalColumns.eq(i).width();
var is_firefox = navigator.userAgent.indexOf('Firefox') > -1;
if (! is_firefox) {
width += 1;
}
return width;
});
$sticky_columns.empty().append($clonedHeader);
}
/*
* 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 ($sticky_columns, $table_results) {
var currentScrollX = $(window).scrollLeft();
var windowOffset = $(window).scrollTop();
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($sticky_columns, $table_results, 'absolute', $('#floating_menubar').height() + windowOffset - tableStartOffset);
// for vertical scrolling
} else {
setStickyColumnsPosition($sticky_columns, $table_results, 'fixed', $('#floating_menubar').height(), $('#pma_navigation').width() - currentScrollX, $('#page_content').css('margin-left'));
}
$sticky_columns.show();
} else {
$sticky_columns.hide();
}
}
AJAX.registerOnload('sql.js', function () {
makeProfilingChart();
initProfilingTables();
});