Merge remote branch 'origin/master' into export_branch

This commit is contained in:
Adnan
2010-08-20 11:34:36 +05:00
125 changed files with 81027 additions and 55088 deletions

221
js/export.js Normal file
View File

@@ -0,0 +1,221 @@
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Functions used in the export tab
*
* @version $Id$
*/
/**
* Toggles the hiding and showing of each plugin's options
* according to the currently selected plugin from the dropdown list
*/
$(document).ready(function() {
$("#plugins").change(function() {
$(".format_specific_options").each(function() {
$(this).hide();
});
var selected_plugin_name = $("#plugins option:selected").attr("value");
$("#" + selected_plugin_name + "_options").show();
});
});
/**
* Toggles the enabling and disabling of the SQL plugin's comment options that apply only when exporting structure
*/
$(document).ready(function() {
$("input[type='radio'][name$='sql_structure_or_data']").change(function() {
var show = $("input[type='radio'][name$='sql_structure_or_data']:checked").attr("value");
if(show == 'data') {
// disable the SQL comment options
$("#checkbox_sql_dates").parent().fadeTo('fast', 0.4);
$("#checkbox_sql_dates").attr('disabled', 'disabled');
$("#checkbox_sql_relation").parent().fadeTo('fast', 0.4);
$("#checkbox_sql_relation").attr('disabled', 'disabled');
$("#checkbox_sql_mime").parent().fadeTo('fast', 0.4);
$("#checkbox_sql_mime").attr('disabled', 'disabled');
} else {
// enable the SQL comment options
$("#checkbox_sql_dates").parent().fadeTo('fast', 1);
$("#checkbox_sql_dates").removeAttr('disabled');
$("#checkbox_sql_relation").parent().fadeTo('fast', 1);
$("#checkbox_sql_relation").removeAttr('disabled');
$("#checkbox_sql_mime").parent().fadeTo('fast', 1);
$("#checkbox_sql_mime").removeAttr('disabled');
}
});
});
/**
* Toggles the hiding and showing of plugin structure-specific and data-specific
* options
*/
function toggle_structure_data_opts(pluginName) {
var radioFormName = pluginName + "_structure_or_data";
var dataDiv = "#" + pluginName + "_data";
var structureDiv = "#" + pluginName + "_structure";
var show = $("input[type='radio'][name='" + radioFormName + "']:checked").attr("value");
if(show == 'data') {
$(dataDiv).slideDown('slow');
$(structureDiv).slideUp('slow');
} else {
$(structureDiv).slideDown('slow');
if(show == 'structure') {
$(dataDiv).slideUp('slow');
} else {
$(dataDiv).slideDown('slow');
}
}
}
$(document).ready(function() {
$("input[type='radio'][name='latex_structure_or_data']").change(function() {
toggle_structure_data_opts("latex");
});
$("input[type='radio'][name='odt_structure_or_data']").change(function() {
toggle_structure_data_opts("odt");
});
$("input[type='radio'][name='texytext_structure_or_data']").change(function() {
toggle_structure_data_opts("texytext");
});
$("input[type='radio'][name='htmlword_structure_or_data']").change(function() {
toggle_structure_data_opts("htmlword");
});
$("input[type='radio'][name='sql_structure_or_data']").change(function() {
toggle_structure_data_opts("sql");
});
});
/**
* Toggles the disabling of the "save to file" options
*/
$(document).ready(function() {
$("input[type='radio'][name='output_format']").change(function() {
if($("#radio_dump_asfile:checked").length == 0) {
$("#ul_save_asfile > li").fadeTo('fast', 0.4);
$("#ul_save_asfile > li > input").attr('disabled', 'disabled');
$("#ul_save_asfile > li> select").attr('disabled', 'disabled');
} else {
$("#ul_save_asfile > li").fadeTo('fast', 1);
$("#ul_save_asfile > li > input").removeAttr('disabled');
$("#ul_save_asfile > li> select").removeAttr('disabled');
}
});
});
/**
* For SQL plugin, toggles the disabling of the "display comments" options
*/
function toggle_sql_include_comments() {
$("#checkbox_sql_include_comments").change(function() {
if($("#checkbox_sql_include_comments:checked").length == 0) {
$("#ul_include_comments > li").fadeTo('fast', 0.4);
$("#ul_include_comments > li > input").attr('disabled', 'disabled');
} else {
// If structure is not being exported, the comment options for structure should not be enabled
if($("#radio_sql_structure_or_data_data:checked").length == 1) {
$("#text_sql_header_comment").parent("li").fadeTo('fast', 1);
$("#text_sql_header_comment").removeAttr('disabled');
} else {
$("#ul_include_comments > li").fadeTo('fast', 1);
$("#ul_include_comments > li > input").removeAttr('disabled');
}
}
});
}
/**
* For SQL plugin, if "CREATE TABLE options" is checked/unchecked, check/uncheck each of its sub-options
*/
$(document).ready(function() {
$("#checkbox_sql_create_table_statements").change(function() {
if($("#checkbox_sql_create_table_statements:checked").length == 0) {
$("#checkbox_sql_if_not_exists").removeAttr('checked');
$("#checkbox_sql_auto_increment").removeAttr('checked');
} else {
$("#checkbox_sql_if_not_exists").attr('checked', 'checked');
$("#checkbox_sql_auto_increment").attr('checked', 'checked');
}
});
});
/**
* Disables the view output as text option if the output must be saved as a file
*/
$(document).ready(function() {
$("#plugins").change(function() {
var active_plugin = $("#plugins option:selected").attr("value");
var force_file = $("#force_file_" + active_plugin).attr("value");
if(force_file == "true") {
$("#radio_view_as_text").attr('disabled', 'disabled');
$("#radio_view_as_text").parent().fadeTo('fast', 0.4);
} else {
$("#radio_view_as_text").removeAttr('disabled');
$("#radio_view_as_text").parent().fadeTo('fast', 1);
}
});
});
/**
* Toggles display of options when quick and custom export are selected
*/
function toggle_quick_or_custom() {
if($("$(this):checked").attr("value") == "custom") {
$("#databases_and_tables").show();
$("#rows").show();
$("#output").show();
$("#format_specific_opts").show();
$("#output_quick_export").hide();
var selected_plugin_name = $("#plugins option:selected").attr("value");
$("#" + selected_plugin_name + "_options").show();
} else {
$("#databases_and_tables").hide();
$("#rows").hide();
$("#output").hide();
$("#format_specific_opts").hide();
$("#output_quick_export").show();
}
}
$(document).ready(function() {
$("input[type='radio'][name='quick_or_custom']").change(function() {
toggle_quick_or_custom();
});
});
/**
* Sets up the interface for Javascript-enabled browsers since the default is for
* Javascript-disabled browsers
*/
$(document).ready(function() {
if($("input[type='hidden'][name='export_method']").attr("value") != "custom-no-form") {
$("#quick_or_custom").show();
}
$("#scroll_to_options_msg").hide();
$(".format_specific_options").hide();
$(".format_specific_options").css({ "border": 0, "margin": 0, "padding": 0});
$(".format_specific_options h3").remove();
toggle_quick_or_custom();
toggle_structure_data_opts($("select[id='plugins']").attr("value"));
toggle_sql_include_comments();
});
/**
* Disables the "Dump some row(s)" sub-options when it is not selected
*/
$(document).ready(function() {
$("input[type='radio'][name='allrows']").change(function() {
if($("input[type='radio'][name='allrows']:checked").attr("value") == "1") {
$("label[for='limit_to']").fadeTo('fast', 0.4);
$("label[for='limit_from']").fadeTo('fast', 0.4);
$("input[type='text'][name='limit_to']").attr('disabled', 'disabled');
$("input[type='text'][name='limit_from']").attr('disabled', 'disabled');
} else {
$("label[for='limit_to']").fadeTo('fast', 1);
$("label[for='limit_from']").fadeTo('fast', 1);
$("input[type='text'][name='limit_to']").removeAttr('disabled');
$("input[type='text'][name='limit_from']").removeAttr('disabled');
}
});
});

View File

@@ -1741,3 +1741,200 @@ $(document).ready(function(){
}
});
/**
* Hides/shows the "Open in ENUM/SET editor" message, depending on the data type of the column currently selected
*/
function toggle_enum_notice(selectElement) {
var enum_notice_id = selectElement.attr("id").split("_")[1];
enum_notice_id += "_" + (parseInt(selectElement.attr("id").split("_")[2]) + 1);
var selectedType = selectElement.attr("value");
if(selectedType == "ENUM" || selectedType == "SET") {
$("p[id='enum_notice_" + enum_notice_id + "']").show();
} else {
$("p[id='enum_notice_" + enum_notice_id + "']").hide();
}
}
/**
* Toggle the hiding/showing of the "Open in ENUM/SET editor" message when
* the page loads and when the selected data type changes
*/
$(document).ready(function() {
$.each($("select[class='column_type']"), function() {
toggle_enum_notice($(this));
});
$("select[class='column_type']").change(function() {
toggle_enum_notice($(this));
});
});
/**
* Closes the ENUM/SET editor and removes the data in it
*/
function disable_popup() {
$("#popup_background").fadeOut("fast");
$("#enum_editor").fadeOut("fast");
// clear the data from the text boxes
$("#enum_editor #values input").remove();
$("#enum_editor input[type='hidden']").remove();
}
/**
* Opens the ENUM/SET editor and controls its functions
*/
$(document).ready(function() {
$("a[class='open_enum_editor']").click(function() {
// Center the popup
var windowWidth = document.documentElement.clientWidth;
var windowHeight = document.documentElement.clientHeight;
var popupWidth = windowWidth/2;
var popupHeight = windowHeight*0.8;
var popupOffsetTop = windowHeight/2 - popupHeight/2;
var popupOffsetLeft = windowWidth/2 - popupWidth/2;
$("#enum_editor").css({"position":"absolute", "top": popupOffsetTop, "left": popupOffsetLeft, "width": popupWidth, "height": popupHeight});
// Make it appear
$("#popup_background").css({"opacity":"0.7"});
$("#popup_background").fadeIn("fast");
$("#enum_editor").fadeIn("fast");
// Get the values
var values = $(this).parent().prev("input").attr("value").split(",");
$.each(values, function(index, val) {
if(jQuery.trim(val) != "") {
// enclose the string in single quotes if it's not already
if(val.substr(0, 1) != "'") {
val = "'" + val;
}
if(val.substr(val.length-1, val.length) != "'") {
val = val + "'";
}
// escape the single quotes, except the mandatory ones enclosing the entire string
val = val.substr(1, val.length-2).replace(/'/g, "'");
// escape the greater-than symbol
val = val.replace(/>/g, ">");
$("#enum_editor #values").append("<input type='text' value=" + val + " />");
}
});
// So we know which column's data is being edited
$("#enum_editor").append("<input type='hidden' value='" + $(this).parent().prev("input").attr("id") + "' />");
return false;
});
// If the "close" link is clicked, close the enum editor
$("a[class='close_enum_editor']").click(function() {
disable_popup();
});
// If the "cancel" link is clicked, close the enum editor
$("a[class='cancel_enum_editor']").click(function() {
disable_popup();
});
// When "add a new value" is clicked, append an empty text field
$("a[class='add_value']").click(function() {
$("#enum_editor #values").append("<input type='text' />");
});
// When the submit button is clicked, put the data back into the original form
$("#enum_editor input[type='submit']").click(function() {
var value_array = new Array();
$.each($("#enum_editor #values input"), function(index, input_element) {
val = jQuery.trim(input_element.value);
if(val != "") {
value_array.push("'" + val + "'");
}
});
// get the Length/Values text field where this value belongs
var values_id = $("#enum_editor input[type='hidden']").attr("value");
$("input[id='" + values_id + "']").attr("value", value_array.join(","));
disable_popup();
});
/**
* Hides certain table structure actions, replacing them with the word "More". They are displayed
* in a dropdown menu when the user hovers over the word "More."
*/
// Remove the actions from the table cells (they are available by default for JavaScript-disabled browsers)
// if the table is not a view or information_schema (otherwise there is only one action to hide and there's no point)
if($("input[type='hidden'][name='table_type']").attr("value") == "table") {
$("table[id='tablestructure'] td[class='browse']").remove();
$("table[id='tablestructure'] td[class='primary']").remove();
$("table[id='tablestructure'] td[class='unique']").remove();
$("table[id='tablestructure'] td[class='index']").remove();
$("table[id='tablestructure'] td[class='fulltext']").remove();
$("table[id='tablestructure'] th[class='action']").attr("colspan", 3);
// Display the "more" text
$("table[id='tablestructure'] td[class='more_opts']").show()
// Position the dropdown
$.each($(".structure_actions_dropdown"), function() {
// The top offset must be set for IE even if it didn't change
var cell_right_edge_offset = $(this).parent().offset().left + $(this).parent().innerWidth();
var left_offset = cell_right_edge_offset - $(this).innerWidth();
var top_offset = $(this).parent().offset().top + $(this).parent().innerHeight();
$(this).offset({ top: top_offset, left: left_offset });
});
// A hack for IE6 to prevent the after_field select element from being displayed on top of the dropdown by
// positioning an iframe directly on top of it
$("iframe[class='IE_hack']").width($("select[name='after_field']").width());
$("iframe[class='IE_hack']").height($("select[name='after_field']").height());
$("iframe[class='IE_hack']").offset({ top: $("select[name='after_field']").offset().top, left: $("select[name='after_field']").offset().left });
// When "more" is hovered over, show the hidden actions
$("table[id='tablestructure'] td[class='more_opts']").mouseenter(
function() {
if($.browser.msie && $.browser.version == "6.0") {
$("iframe[class='IE_hack']").show();
$("iframe[class='IE_hack']").width($("select[name='after_field']").width()+4);
$("iframe[class='IE_hack']").height($("select[name='after_field']").height()+4);
$("iframe[class='IE_hack']").offset({ top: $("select[name='after_field']").offset().top, left: $("select[name='after_field']").offset().left});
}
$(".structure_actions_dropdown").hide(); // Hide all the other ones that may be open
$(this).children(".structure_actions_dropdown").show();
// Need to do this again for IE otherwise the offset is wrong
if($.browser.msie) {
var left_offset_IE = $(this).offset().left + $(this).innerWidth() - $(this).children(".structure_actions_dropdown").innerWidth();
var top_offset_IE = $(this).offset().top + $(this).innerHeight();
$(this).children(".structure_actions_dropdown").offset({ top: top_offset_IE, left: left_offset_IE });
}
});
$(".structure_actions_dropdown").mouseleave(function() {
$(this).hide();
if($.browser.msie && $.browser.version == "6.0") {
$("iframe[class='IE_hack']").hide();
}
});
}
});
/* Displays tooltips */
$(document).ready(function() {
// Hide the footnotes from the footer (which are displayed for
// JavaScript-disabled browsers) since the tooltip is sufficient
$(".footnotes").hide();
$(".footnotes span").each(function() {
$(this).children("sup").remove();
});
// The border and padding must be removed otherwise a thin yellow box remains visible
$(".footnotes").css("border", "none");
$(".footnotes").css("padding", "0px");
// Replace the superscripts with the help icon
$("sup[class='footnotemarker']").hide();
$("img[class='footnotemarker']").show();
$("img[class='footnotemarker']").each(function() {
var span_id = $(this).attr("id");
span_id = span_id.split("_")[1];
var tooltip_text = $(".footnotes span[id='footnote_" + span_id + "']").html();
$(this).qtip({
content: tooltip_text,
show: { delay: 0 },
hide: { when: 'unfocus', delay: 0 },
style: { background: '#ffffcc' }
});
});
});

83
js/import.js Normal file
View File

@@ -0,0 +1,83 @@
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Functions used in the import tab
*
* @version $Id$
*/
/**
* Toggles the hiding and showing of each plugin's options
* according to the currently selected plugin from the dropdown list
*/
function changePluginOpts() {
$(".format_specific_options").each(function() {
$(this).hide();
});
var selected_plugin_name = $("#plugins option:selected").attr("value");
$("#" + selected_plugin_name + "_options").fadeIn('slow');
if(selected_plugin_name == "csv") {
$("#import_notification").text("Note: If the file contains multiple tables, they will be combined into one");
} else {
$("#import_notification").text("");
}
}
/**
* Toggles the hiding and showing of each plugin's options and sets the selected value
* in the plugin dropdown list according to the format of the selected file
*/
function matchFile(fname) {
var fname_array = fname.toLowerCase().split(".");
var len = fname_array.length;
if(len != 0) {
var extension = fname_array[len - 1];
if (extension == "gz" || extension == "bz2" || extension == "zip") {
len--;
}
// Only toggle if the format of the file can be imported
if($("select[name='format'] option[value='" + fname_array[len - 1] + "']").length == 1) {
$("#plugins option:selected").removeAttr("selected");
$("select[name='format'] option[value='" + fname_array[len - 1] + "']").attr('selected', 'selected');
changePluginOpts();
}
}
}
$(document).ready(function() {
// Initially display the options for the selected plugin
changePluginOpts();
// Whenever the selected plugin changes, change the options displayed
$("#plugins").change(function() {
changePluginOpts();
});
$("#input_import_file").change(function() {
matchFile($(this).attr("value"));
});
$("#select_local_import_file").change(function() {
matchFile($(this).attr("value"));
});
/*
* When the "Browse the server" form is clicked or the "Select from the web server upload directory"
* form is clicked, the radio button beside it becomes selected and the other form becomes disabled.
*/
$("#input_import_file").focus(function() {
$("#radio_import_file").attr('checked', 'checked');
$("#radio_local_import_file").removeAttr('checked');
});
$("#select_local_import_file").focus(function() {
$("#radio_local_import_file").attr('checked', 'checked');
$("#radio_import_file").removeAttr('checked');
});
/**
* Set up the interface for Javascript-enabled browsers since the default is for
* Javascript-disabled browsers
*/
$("#scroll_to_options_msg").hide();
$(".format_specific_options").css({ "border": 0, "margin": 0, "padding": 0 });
$(".format_specific_options h3").remove();
});

15
js/jquery.qtip-1.0.0.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -6,7 +6,7 @@
$(document).ready(function() {
$('#li_custom_color').show();
// Choosing another id does not work!
$('#colorSelector').ColorPicker({
$("input[type='submit'][name='custom_color_choose']").ColorPicker({
color: '#0000ff',
onShow: function (colpkr) {
$(colpkr).fadeIn(500);

View File

@@ -187,6 +187,11 @@ function clear_fast_filter() {
$(document).ready(function(){
/* Display filter */
$('#NavFilter').css('display', 'inline');
$('input[id="fast_filter"]').focus(function() {
if($(this).attr("value") === "filter tables by name") {
clear_fast_filter();
}
});
$('#clear_fast_filter').click(clear_fast_filter);
$('#fast_filter').focus(function (evt) {evt.target.select();});
$('#fast_filter').keyup(function (evt) {fast_filter(evt.target.value);});

View File

@@ -1,212 +0,0 @@
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Displays the Tooltips (hints), if we have some
* 2005-01-20 added by Michael Keck (mkkeck)
*
* @version $Id$
*/
/**
*
*/
var ttXpos = 0, ttYpos = 0;
var ttXadd = 10, ttYadd = -10;
var ttDisplay = 0, ttHoldIt = 0;
// Check if browser does support dynamic content and dhtml
if (document.getElementById) {
// DOM-compatible browsers
var ttDOM = 1;
} else {
// the old Netscape 4
var ttNS4 = (document.layers) ? 1 : 0;
// browser wich uses document.all
var ttIE4 = (document.all) ? 1 : 0;
}
var myTooltipContainer = null;
/**
* initialize tooltip
*/
function PMA_TT_init()
{
// get all 'light bubbles' on page
var tooltip_icons = window.parent.getElementsByClassName('footnotemarker', document, 'sup');
var tooltip_count = tooltip_icons.length;
if (tooltip_count < 1) {
// no 'bubbles' found
return;
}
// insert tooltip container
myTooltipContainer = document.createElement("div");
myTooltipContainer.id = 'TooltipContainer';
window.parent.addEvent(myTooltipContainer, 'mouseover', holdTooltip);
window.parent.addEvent(myTooltipContainer, 'mouseout', swapTooltip);
document.body.appendChild(myTooltipContainer);
// capture mouse-events
for (i = 0; i < tooltip_count; i++) {
window.parent.addEvent(tooltip_icons[i], 'mousemove', mouseMove);
window.parent.addEvent(tooltip_icons[i], 'mouseover', pmaTooltip);
window.parent.addEvent(tooltip_icons[i], 'mouseout', swapTooltip);
}
}
/**
* init the tooltip and write the text into it
*
* @param string theText tooltip content
*/
function PMA_TT_setText(theText)
{
if (ttDOM || ttIE4) { // document.getEelementById || document.all
myTooltipContainer.innerHTML = ""; // we should empty it first
myTooltipContainer.innerHTML = theText;
} else if (ttNS4) { // document.layers
var layerNS4 = myTooltipContainer.document;
layerNS4.write(theText);
layerNS4.close();
}
}
/**
* @var integer
*/
var ttTimerID = 0;
/**
* swap the Tooltip // show and hide
*
* @param boolean stat view status
*/
function swapTooltip(stat)
{
if (ttHoldIt != 1) {
if (stat == 'true') {
showTooltip(true);
} else if (ttDisplay) {
ttTimerID = setTimeout("showTooltip(false);", 500);
} else {
showTooltip(true);
}
} else {
if (ttTimerID) {
clearTimeout(ttTimerID);
ttTimerID = 0;
}
showTooltip(true);
}
}
/**
* show / hide the Tooltip
*
* @param boolean stat view status
*/
function showTooltip(stat)
{
if (stat == false) {
if (ttNS4)
myTooltipContainer.visibility = "hide";
else
myTooltipContainer.style.visibility = "hidden";
ttDisplay = 0;
} else {
if (ttNS4)
myTooltipContainer.visibility = "show";
else
myTooltipContainer.style.visibility = "visible";
ttDisplay = 1;
}
}
/**
* hold it, if we create or move the mouse over the tooltip
*/
function holdTooltip()
{
ttHoldIt = 1;
swapTooltip('true');
ttHoldIt = 0;
}
/**
* move the tooltip to mouse position
*
* @param integer posX horiz. position
* @param integer posY vert. position
*/
function moveTooltip(posX, posY)
{
if (ttDOM || ttIE4) {
myTooltipContainer.style.left = posX + "px";
myTooltipContainer.style.top = posY + "px";
} else if (ttNS4) {
myTooltipContainer.left = posX;
myTooltipContainer.top = posY;
}
}
/**
* build the tooltip
* usally called from eventhandler
*
* @param string theText tooltip content
*/
function pmaTooltip(e)
{
var theText = document.getElementById('footnote_' + this.innerHTML).innerHTML;
var plusX = 0, plusY = 0, docX = 0, docY = 0;
var divHeight = myTooltipContainer.clientHeight;
var divWidth = myTooltipContainer.clientWidth;
if (navigator.appName.indexOf("Explorer") != -1) {
// IE ...
if (document.documentElement && document.documentElement.scrollTop) {
plusX = document.documentElement.scrollLeft;
plusY = document.documentElement.scrollTop;
docX = document.documentElement.offsetWidth + plusX;
docY = document.documentElement.offsetHeight + plusY;
} else {
plusX = document.body.scrollLeft;
plusY = document.body.scrollTop;
docX = document.body.offsetWidth + plusX;
docY = document.body.offsetHeight + plusY;
}
} else {
docX = document.body.clientWidth;
docY = document.body.clientHeight;
}
ttXpos = ttXpos + plusX;
ttYpos = ttYpos + plusY;
if ((ttXpos + divWidth) > docX)
ttXpos = ttXpos - (divWidth + (ttXadd * 2));
if ((ttYpos + divHeight) > docY)
ttYpos = ttYpos - (divHeight + (ttYadd * 2));
PMA_TT_setText(theText);
moveTooltip((ttXpos + ttXadd), (ttYpos + ttYadd));
holdTooltip();
}
/**
* register mouse moves
*
* @param event e
*/
function mouseMove(e) {
if ( typeof( event ) != 'undefined' ) {
ttXpos = event.x;
ttYpos = event.y;
} else {
ttXpos = e.pageX;
ttYpos = e.pageY;
}
moveTooltip((ttXpos + ttXadd), (ttYpos + ttYadd));
}