1 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 * Functions used in the export tab
8 * Disables the "Dump some row(s)" sub-options
10 function disable_dump_some_rows_sub_options () {
11 $('label[for=\'limit_to\']').fadeTo('fast', 0.4);
12 $('label[for=\'limit_from\']').fadeTo('fast', 0.4);
13 $('input[type=\'text\'][name=\'limit_to\']').prop('disabled', 'disabled');
14 $('input[type=\'text\'][name=\'limit_from\']').prop('disabled', 'disabled');
18 * Enables the "Dump some row(s)" sub-options
20 function enable_dump_some_rows_sub_options () {
21 $('label[for=\'limit_to\']').fadeTo('fast', 1);
22 $('label[for=\'limit_from\']').fadeTo('fast', 1);
23 $('input[type=\'text\'][name=\'limit_to\']').prop('disabled', '');
24 $('input[type=\'text\'][name=\'limit_from\']').prop('disabled', '');
28 * Return template data as a json object
30 * @returns template data
32 function getTemplateData () {
33 var $form = $('form[name="dump"]');
34 var blacklist = ['token', 'server', 'db', 'table', 'single_table',
35 'export_type', 'export_method', 'sql_query', 'template_id'];
37 var arr = $form.serializeArray();
38 $.each(arr, function () {
39 if ($.inArray(this.name, blacklist) < 0) {
40 if (obj[this.name] !== undefined) {
41 if (! obj[this.name].push) {
42 obj[this.name] = [obj[this.name]];
44 obj[this.name].push(this.value || '');
46 obj[this.name] = this.value || '';
50 // include unchecked checboxes (which are ignored by serializeArray()) with null
51 // to uncheck them when loading the template
52 $form.find('input[type="checkbox"]:not(:checked)').each(function () {
53 if (obj[this.name] === undefined) {
54 obj[this.name] = null;
57 // include empty multiselects
58 $form.find('select').each(function () {
59 if ($(this).find('option:selected').length === 0) {
67 * Create a template with selected options
69 * @param name name of the template
71 function createTemplate (name) {
72 var templateData = getTemplateData();
76 server : PMA_commonParams.get('server'),
77 db : PMA_commonParams.get('db'),
78 table : PMA_commonParams.get('table'),
79 exportType : $('input[name="export_type"]').val(),
80 templateAction : 'create',
82 templateData : JSON.stringify(templateData)
85 PMA_ajaxShowMessage();
86 $.post('tbl_export.php', params, function (response) {
87 if (response.success === true) {
88 $('#templateName').val('');
89 $('#template').html(response.data);
90 $('#template').find('option').each(function () {
91 if ($(this).text() === name) {
92 $(this).prop('selected', true);
95 PMA_ajaxShowMessage(PMA_messages.strTemplateCreated);
97 PMA_ajaxShowMessage(response.error, false);
105 * @param id ID of the template to load
107 function loadTemplate (id) {
110 server : PMA_commonParams.get('server'),
111 db : PMA_commonParams.get('db'),
112 table : PMA_commonParams.get('table'),
113 exportType : $('input[name="export_type"]').val(),
114 templateAction : 'load',
118 PMA_ajaxShowMessage();
119 $.post('tbl_export.php', params, function (response) {
120 if (response.success === true) {
121 var $form = $('form[name="dump"]');
122 var options = JSON.parse(response.data);
123 $.each(options, function (key, value) {
124 var $element = $form.find('[name="' + key + '"]');
125 if ($element.length) {
126 if (($element.is('input') && $element.attr('type') === 'checkbox') && value === null) {
127 $element.prop('checked', false);
129 if (($element.is('input') && $element.attr('type') === 'checkbox') ||
130 ($element.is('input') && $element.attr('type') === 'radio') ||
131 ($element.is('select') && $element.attr('multiple') === 'multiple')) {
138 $element.trigger('change');
141 $('input[name="template_id"]').val(id);
142 PMA_ajaxShowMessage(PMA_messages.strTemplateLoaded);
144 PMA_ajaxShowMessage(response.error, false);
150 * Updates an existing template with current options
152 * @param id ID of the template to update
154 function updateTemplate (id) {
155 var templateData = getTemplateData();
159 server : PMA_commonParams.get('server'),
160 db : PMA_commonParams.get('db'),
161 table : PMA_commonParams.get('table'),
162 exportType : $('input[name="export_type"]').val(),
163 templateAction : 'update',
165 templateData : JSON.stringify(templateData)
168 PMA_ajaxShowMessage();
169 $.post('tbl_export.php', params, function (response) {
170 if (response.success === true) {
171 PMA_ajaxShowMessage(PMA_messages.strTemplateUpdated);
173 PMA_ajaxShowMessage(response.error, false);
181 * @param id ID of the template to delete
183 function deleteTemplate (id) {
186 server : PMA_commonParams.get('server'),
187 db : PMA_commonParams.get('db'),
188 table : PMA_commonParams.get('table'),
189 exportType : $('input[name="export_type"]').val(),
190 templateAction : 'delete',
194 PMA_ajaxShowMessage();
195 $.post('tbl_export.php', params, function (response) {
196 if (response.success === true) {
197 $('#template').find('option[value="' + id + '"]').remove();
198 PMA_ajaxShowMessage(PMA_messages.strTemplateDeleted);
200 PMA_ajaxShowMessage(response.error, false);
206 * Unbind all event handlers before tearing down a page
208 AJAX.registerTeardown('export.js', function () {
209 $('#plugins').off('change');
210 $('input[type=\'radio\'][name=\'sql_structure_or_data\']').off('change');
211 $('input[type=\'radio\'][name$=\'_structure_or_data\']').off('change');
212 $('input[type=\'radio\'][name=\'output_format\']').off('change');
213 $('#checkbox_sql_include_comments').off('change');
214 $('input[type=\'radio\'][name=\'quick_or_custom\']').off('change');
215 $('input[type=\'radio\'][name=\'allrows\']').off('change');
216 $('#btn_alias_config').off('click');
217 $('.alias_remove').off('click');
218 $('#db_alias_button').off('click');
219 $('#table_alias_button').off('click');
220 $('#column_alias_button').off('click');
221 $('input[name="table_select[]"]').off('change');
222 $('input[name="table_structure[]"]').off('change');
223 $('input[name="table_data[]"]').off('change');
224 $('#table_structure_all').off('change');
225 $('#table_data_all').off('change');
226 $('input[name="createTemplate"]').off('click');
227 $('select[name="template"]').off('change');
228 $('input[name="updateTemplate"]').off('click');
229 $('input[name="deleteTemplate"]').off('click');
232 AJAX.registerOnload('export.js', function () {
234 * Export template handling code
236 // create a new template
237 $('input[name="createTemplate"]').on('click', function (e) {
239 var name = $('input[name="templateName"]').val();
241 createTemplate(name);
245 // load an existing template
246 $('select[name="template"]').on('change', function (e) {
248 var id = $(this).val();
254 // udpate an existing template with new criteria
255 $('input[name="updateTemplate"]').on('click', function (e) {
257 var id = $('select[name="template"]').val();
263 // delete an existing template
264 $('input[name="deleteTemplate"]').on('click', function (e) {
266 var id = $('select[name="template"]').val();
273 * Toggles the hiding and showing of each plugin's options
274 * according to the currently selected plugin from the dropdown list
276 $('#plugins').change(function () {
277 $('#format_specific_opts').find('div.format_specific_options').hide();
278 var selected_plugin_name = $('#plugins').find('option:selected').val();
279 $('#' + selected_plugin_name + '_options').show();
283 * Toggles the enabling and disabling of the SQL plugin's comment options that apply only when exporting structure
285 $('input[type=\'radio\'][name=\'sql_structure_or_data\']').change(function () {
286 var comments_are_present = $('#checkbox_sql_include_comments').prop('checked');
287 var show = $('input[type=\'radio\'][name=\'sql_structure_or_data\']:checked').val();
288 if (show === 'data') {
289 // disable the SQL comment options
290 if (comments_are_present) {
291 $('#checkbox_sql_dates').prop('disabled', true).parent().fadeTo('fast', 0.4);
293 $('#checkbox_sql_relation').prop('disabled', true).parent().fadeTo('fast', 0.4);
294 $('#checkbox_sql_mime').prop('disabled', true).parent().fadeTo('fast', 0.4);
296 // enable the SQL comment options
297 if (comments_are_present) {
298 $('#checkbox_sql_dates').prop('disabled', false).parent().fadeTo('fast', 1);
300 $('#checkbox_sql_relation').prop('disabled', false).parent().fadeTo('fast', 1);
301 $('#checkbox_sql_mime').prop('disabled', false).parent().fadeTo('fast', 1);
304 if (show === 'structure') {
305 $('#checkbox_sql_auto_increment').prop('disabled', true).parent().fadeTo('fast', 0.4);
307 $('#checkbox_sql_auto_increment').prop('disabled', false).parent().fadeTo('fast', 1);
311 // For separate-file exports only ZIP compression is allowed
312 $('input[type="checkbox"][name="as_separate_files"]').change(function () {
313 if ($(this).is(':checked')) {
314 $('#compression').val('zip');
318 $('#compression').change(function () {
319 if ($('option:selected').val() !== 'zip') {
320 $('input[type="checkbox"][name="as_separate_files"]').prop('checked', false);
325 function setup_table_structure_or_data () {
326 if ($('input[name=\'export_type\']').val() !== 'database') {
329 var pluginName = $('#plugins').find('option:selected').val();
330 var formElemName = pluginName + '_structure_or_data';
331 var force_structure_or_data = !($('input[name=\'' + formElemName + '_default\']').length);
333 if (force_structure_or_data === true) {
334 $('input[name="structure_or_data_forced"]').val(1);
335 $('.export_structure input[type="checkbox"], .export_data input[type="checkbox"]')
336 .prop('disabled', true);
337 $('.export_structure, .export_data').fadeTo('fast', 0.4);
339 $('input[name="structure_or_data_forced"]').val(0);
340 $('.export_structure input[type="checkbox"], .export_data input[type="checkbox"]')
341 .prop('disabled', false);
342 $('.export_structure, .export_data').fadeTo('fast', 1);
344 var structure_or_data = $('input[name="' + formElemName + '_default"]').val();
346 if (structure_or_data === 'structure') {
347 $('.export_data input[type="checkbox"]')
348 .prop('checked', false);
349 } else if (structure_or_data === 'data') {
350 $('.export_structure input[type="checkbox"]')
351 .prop('checked', false);
353 if (structure_or_data === 'structure' || structure_or_data === 'structure_and_data') {
354 if (!$('.export_structure input[type="checkbox"]:checked').length) {
355 $('input[name="table_select[]"]:checked')
357 .find('.export_structure input[type="checkbox"]')
358 .prop('checked', true);
361 if (structure_or_data === 'data' || structure_or_data === 'structure_and_data') {
362 if (!$('.export_data input[type="checkbox"]:checked').length) {
363 $('input[name="table_select[]"]:checked')
365 .find('.export_data input[type="checkbox"]')
366 .prop('checked', true);
370 check_selected_tables();
371 check_table_select_all();
372 check_table_select_struture_or_data();
377 * Toggles the hiding and showing of plugin structure-specific and data-specific
380 function toggle_structure_data_opts () {
381 var pluginName = $('select#plugins').val();
382 var radioFormName = pluginName + '_structure_or_data';
383 var dataDiv = '#' + pluginName + '_data';
384 var structureDiv = '#' + pluginName + '_structure';
385 var show = $('input[type=\'radio\'][name=\'' + radioFormName + '\']:checked').val();
386 // Show the #rows if 'show' is not structure
387 $('#rows').toggle(show !== 'structure');
388 if (show === 'data') {
389 $(dataDiv).slideDown('slow');
390 $(structureDiv).slideUp('slow');
392 $(structureDiv).slideDown('slow');
393 if (show === 'structure') {
394 $(dataDiv).slideUp('slow');
396 $(dataDiv).slideDown('slow');
402 * Toggles the disabling of the "save to file" options
404 function toggle_save_to_file () {
405 var $ulSaveAsfile = $('#ul_save_asfile');
406 if (!$('#radio_dump_asfile').prop('checked')) {
407 $ulSaveAsfile.find('> li').fadeTo('fast', 0.4);
408 $ulSaveAsfile.find('> li > input').prop('disabled', true);
409 $ulSaveAsfile.find('> li > select').prop('disabled', true);
411 $ulSaveAsfile.find('> li').fadeTo('fast', 1);
412 $ulSaveAsfile.find('> li > input').prop('disabled', false);
413 $ulSaveAsfile.find('> li > select').prop('disabled', false);
417 AJAX.registerOnload('export.js', function () {
418 toggle_save_to_file();
419 $('input[type=\'radio\'][name=\'output_format\']').change(toggle_save_to_file);
423 * For SQL plugin, toggles the disabling of the "display comments" options
425 function toggle_sql_include_comments () {
426 $('#checkbox_sql_include_comments').change(function () {
427 var $ulIncludeComments = $('#ul_include_comments');
428 if (!$('#checkbox_sql_include_comments').prop('checked')) {
429 $ulIncludeComments.find('> li').fadeTo('fast', 0.4);
430 $ulIncludeComments.find('> li > input').prop('disabled', true);
432 // If structure is not being exported, the comment options for structure should not be enabled
433 if ($('#radio_sql_structure_or_data_data').prop('checked')) {
434 $('#text_sql_header_comment').prop('disabled', false).parent('li').fadeTo('fast', 1);
436 $ulIncludeComments.find('> li').fadeTo('fast', 1);
437 $ulIncludeComments.find('> li > input').prop('disabled', false);
443 function check_table_select_all () {
444 var total = $('input[name="table_select[]"]').length;
445 var str_checked = $('input[name="table_structure[]"]:checked').length;
446 var data_checked = $('input[name="table_data[]"]:checked').length;
447 var str_all = $('#table_structure_all');
448 var data_all = $('#table_data_all');
450 if (str_checked === total) {
452 .prop('indeterminate', false)
453 .prop('checked', true);
454 } else if (str_checked === 0) {
456 .prop('indeterminate', false)
457 .prop('checked', false);
460 .prop('indeterminate', true)
461 .prop('checked', false);
464 if (data_checked === total) {
466 .prop('indeterminate', false)
467 .prop('checked', true);
468 } else if (data_checked === 0) {
470 .prop('indeterminate', false)
471 .prop('checked', false);
474 .prop('indeterminate', true)
475 .prop('checked', false);
479 function check_table_select_struture_or_data () {
480 var str_checked = $('input[name="table_structure[]"]:checked').length;
481 var data_checked = $('input[name="table_data[]"]:checked').length;
482 var auto_increment = $('#checkbox_sql_auto_increment');
484 var pluginName = $('select#plugins').val();
485 var dataDiv = '#' + pluginName + '_data';
486 var structureDiv = '#' + pluginName + '_structure';
488 if (str_checked === 0) {
489 $(structureDiv).slideUp('slow');
491 $(structureDiv).slideDown('slow');
494 if (data_checked === 0) {
495 $(dataDiv).slideUp('slow');
496 auto_increment.prop('disabled', true).parent().fadeTo('fast', 0.4);
498 $(dataDiv).slideDown('slow');
499 auto_increment.prop('disabled', false).parent().fadeTo('fast', 1);
503 function toggle_table_select_all_str () {
504 var str_all = $('#table_structure_all').is(':checked');
506 $('input[name="table_structure[]"]').prop('checked', true);
508 $('input[name="table_structure[]"]').prop('checked', false);
512 function toggle_table_select_all_data () {
513 var data_all = $('#table_data_all').is(':checked');
515 $('input[name="table_data[]"]').prop('checked', true);
517 $('input[name="table_data[]"]').prop('checked', false);
521 function check_selected_tables (argument) {
522 $('.export_table_select tbody tr').each(function () {
523 check_table_selected(this);
527 function check_table_selected (row) {
529 var table_select = $row.find('input[name="table_select[]"]');
530 var str_check = $row.find('input[name="table_structure[]"]');
531 var data_check = $row.find('input[name="table_data[]"]');
533 var data = data_check.is(':checked:not(:disabled)');
534 var structure = str_check.is(':checked:not(:disabled)');
536 if (data && structure) {
537 table_select.prop({ checked: true, indeterminate: false });
538 $row.addClass('marked');
539 } else if (data || structure) {
540 table_select.prop({ checked: true, indeterminate: true });
541 $row.removeClass('marked');
543 table_select.prop({ checked: false, indeterminate: false });
544 $row.removeClass('marked');
548 function toggle_table_select (row) {
550 var table_selected = $row.find('input[name="table_select[]"]').is(':checked');
552 if (table_selected) {
553 $row.find('input[type="checkbox"]:not(:disabled)').prop('checked', true);
554 $row.addClass('marked');
556 $row.find('input[type="checkbox"]:not(:disabled)').prop('checked', false);
557 $row.removeClass('marked');
561 function handleAddProcCheckbox () {
562 if ($('#table_structure_all').is(':checked') === true
563 && $('#table_data_all').is(':checked') === true
565 $('#checkbox_sql_procedure_function').prop('checked', true);
567 $('#checkbox_sql_procedure_function').prop('checked', false);
571 AJAX.registerOnload('export.js', function () {
573 * For SQL plugin, if "CREATE TABLE options" is checked/unchecked, check/uncheck each of its sub-options
575 var $create = $('#checkbox_sql_create_table_statements');
576 var $create_options = $('#ul_create_table_statements').find('input');
577 $create.change(function () {
578 $create_options.prop('checked', $(this).prop('checked'));
580 $create_options.change(function () {
581 if ($create_options.is(':checked')) {
582 $create.prop('checked', true);
587 * Disables the view output as text option if the output must be saved as a file
589 $('#plugins').change(function () {
590 var active_plugin = $('#plugins').find('option:selected').val();
591 var force_file = $('#force_file_' + active_plugin).val();
592 if (force_file === 'true') {
593 if ($('#radio_dump_asfile').prop('checked') !== true) {
594 $('#radio_dump_asfile').prop('checked', true);
595 toggle_save_to_file();
597 $('#radio_view_as_text').prop('disabled', true).parent().fadeTo('fast', 0.4);
599 $('#radio_view_as_text').prop('disabled', false).parent().fadeTo('fast', 1);
603 $('input[type=\'radio\'][name$=\'_structure_or_data\']').on('change', function () {
604 toggle_structure_data_opts();
607 $('input[name="table_select[]"]').on('change', function () {
608 toggle_table_select($(this).closest('tr'));
609 check_table_select_all();
610 handleAddProcCheckbox();
611 check_table_select_struture_or_data();
614 $('input[name="table_structure[]"]').on('change', function () {
615 check_table_selected($(this).closest('tr'));
616 check_table_select_all();
617 handleAddProcCheckbox();
618 check_table_select_struture_or_data();
621 $('input[name="table_data[]"]').on('change', function () {
622 check_table_selected($(this).closest('tr'));
623 check_table_select_all();
624 handleAddProcCheckbox();
625 check_table_select_struture_or_data();
628 $('#table_structure_all').on('change', function () {
629 toggle_table_select_all_str();
630 check_selected_tables();
631 handleAddProcCheckbox();
632 check_table_select_struture_or_data();
635 $('#table_data_all').on('change', function () {
636 toggle_table_select_all_data();
637 check_selected_tables();
638 handleAddProcCheckbox();
639 check_table_select_struture_or_data();
642 if ($('input[name=\'export_type\']').val() === 'database') {
643 // Hide structure or data radio buttons
644 $('input[type=\'radio\'][name$=\'_structure_or_data\']').each(function () {
646 var name = $this.prop('name');
647 var val = $('input[name="' + name + '"]:checked').val();
648 var name_default = name + '_default';
649 if (!$('input[name="' + name_default + '"]').length) {
652 $('<input type="hidden" name="' + name_default + '" value="' + val + '" disabled>')
655 $('<input type="hidden" name="' + name + '" value="structure_and_data">')
657 $this.parent().find('label').remove();
659 $this.parent().remove();
662 $('input[type=\'radio\'][name$=\'_structure_or_data\']').remove();
664 // Disable CREATE table checkbox for sql
665 var createTableCheckbox = $('#checkbox_sql_create_table');
666 createTableCheckbox.prop('checked', true);
667 var dummyCreateTable = $('#checkbox_sql_create_table')
670 .attr('type', 'hidden');
672 .prop('disabled', true)
673 .after(dummyCreateTable)
675 .fadeTo('fast', 0.4);
677 setup_table_structure_or_data();
681 * Handle force structure_or_data
683 $('#plugins').change(setup_table_structure_or_data);
687 * Toggles display of options when quick and custom export are selected
689 function toggle_quick_or_custom () {
690 if ($('input[name=\'quick_or_custom\']').length === 0 // custom_no_form option
691 || $('#radio_custom_export').prop('checked') // custom
693 $('#databases_and_tables').show();
696 $('#format_specific_opts').show();
697 $('#output_quick_export').hide();
698 var selected_plugin_name = $('#plugins').find('option:selected').val();
699 $('#' + selected_plugin_name + '_options').show();
701 $('#databases_and_tables').hide();
704 $('#format_specific_opts').hide();
705 $('#output_quick_export').show();
709 function check_time_out (time_limit) {
710 if (typeof time_limit === 'undefined' || time_limit === 0) {
713 // margin of one second to avoid race condition to set/access session variable
714 time_limit = time_limit + 1;
715 var href = 'export.php';
717 'ajax_request' : true,
718 'check_time_out' : true
720 clearTimeout(time_out);
721 time_out = setTimeout(function () {
722 $.get(href, params, function (data) {
723 if (data.message === 'timeout') {
725 '<div class="error">' +
726 PMA_messages.strTimeOutError +
732 }, time_limit * 1000);
736 * Handler for Database/table alias select
738 * @param event object the event object
742 function aliasSelectHandler (event) {
743 var sel = event.data.sel;
744 var type = event.data.type;
745 var inputId = $(this).val();
746 var $label = $(this).next('label');
747 $('input#' + $label.attr('for')).addClass('hide');
748 $('input#' + inputId).removeClass('hide');
749 $label.attr('for', inputId);
750 $('#alias_modal ' + sel + '[id$=' + type + ']:visible').addClass('hide');
751 var $inputWrapper = $('#alias_modal ' + sel + '#' + inputId + type);
752 $inputWrapper.removeClass('hide');
753 if (type === '_cols' && $inputWrapper.length > 0) {
754 var outer = $inputWrapper[0].outerHTML;
755 // Replace opening tags
756 var regex = /<dummy_inp/gi;
757 if (outer.match(regex)) {
758 var newTag = outer.replace(regex, '<input');
759 // Replace closing tags
760 regex = /<\/dummy_inp/gi;
761 newTag = newTag.replace(regex, '</input');
762 // Assign replacement
763 $inputWrapper.replaceWith(newTag);
765 } else if (type === '_tables') {
766 $('.table_alias_select:visible').change();
768 $('#alias_modal').dialog('option', 'position', 'center');
772 * Handler for Alias dialog box
774 * @param event object the event object
778 function createAliasModal (event) {
779 event.preventDefault();
781 dlgButtons[PMA_messages.strSaveAndClose] = function () {
782 $(this).dialog('close');
783 $('#alias_modal').parent().appendTo($('form[name="dump"]'));
785 $('#alias_modal').dialog({
786 width: Math.min($(window).width() - 100, 700),
787 maxHeight: $(window).height(),
789 dialogClass: 'alias-dialog',
791 create: function () {
792 $(this).css('maxHeight', $(window).height() - 150);
793 var db = PMA_commonParams.get('db');
795 var option = $('<option></option>');
797 option.attr('value', db);
798 $('#db_alias_select').append(option).val(db).change();
802 server : PMA_commonParams.get('server'),
803 type: 'list-databases'
805 $.post('ajax.php', params, function (response) {
806 if (response.success === true) {
807 $.each(response.databases, function (idx, value) {
808 var option = $('<option></option>');
810 option.attr('value', value);
811 $('#db_alias_select').append(option);
814 PMA_ajaxShowMessage(response.error, false);
821 $(this).find('input[type="text"]').each(function () {
822 // trim empty input fields on close
826 $(this).parents('tr').remove();
829 // Toggle checkbox based on aliases
830 $('input#btn_alias_config').prop('checked', !isEmpty);
832 position: { my: 'center top', at: 'center top', of: window }
836 function aliasToggleRow (elm) {
837 var inputs = elm.parents('tr').find('input,button');
839 inputs.attr('disabled', false);
841 inputs.attr('disabled', true);
845 function addAlias (type, name, field, value) {
850 var row = $('#alias_data tfoot tr').clone();
851 row.find('th').text(type);
852 row.find('td:first').text(name);
853 row.find('input').attr('name', field);
854 row.find('input').val(value);
855 row.find('.alias_remove').on('click', function () {
856 $(this).parents('tr').remove();
859 var matching = $('#alias_data [name="' + $.escapeSelector(field) + '"]');
860 if (matching.length > 0) {
861 matching.parents('tr').remove();
864 $('#alias_data tbody').append(row);
867 AJAX.registerOnload('export.js', function () {
868 $('input[type=\'radio\'][name=\'quick_or_custom\']').change(toggle_quick_or_custom);
870 $('#scroll_to_options_msg').hide();
871 $('#format_specific_opts').find('div.format_specific_options')
880 toggle_quick_or_custom();
881 toggle_structure_data_opts();
882 toggle_sql_include_comments();
883 check_table_select_all();
884 handleAddProcCheckbox();
887 * Initially disables the "Dump some row(s)" sub-options
889 disable_dump_some_rows_sub_options();
892 * Disables the "Dump some row(s)" sub-options when it is not selected
894 $('input[type=\'radio\'][name=\'allrows\']').change(function () {
895 if ($('input[type=\'radio\'][name=\'allrows\']').prop('checked')) {
896 enable_dump_some_rows_sub_options();
898 disable_dump_some_rows_sub_options();
902 // Open Alias Modal Dialog on click
903 $('#btn_alias_config').on('click', createAliasModal);
904 $('.alias_remove').on('click', function () {
905 $(this).parents('tr').remove();
907 $('#db_alias_select').on('change', function () {
908 aliasToggleRow($(this));
909 var db = $(this).val();
910 var table = PMA_commonParams.get('table');
912 var option = $('<option></option>');
914 option.attr('value', table);
915 $('#table_alias_select').append(option).val(table).change();
919 server : PMA_commonParams.get('server'),
923 $.post('ajax.php', params, function (response) {
924 if (response.success === true) {
925 $.each(response.tables, function (idx, value) {
926 var option = $('<option></option>');
928 option.attr('value', value);
929 $('#table_alias_select').append(option);
932 PMA_ajaxShowMessage(response.error, false);
937 $('#table_alias_select').on('change', function () {
938 aliasToggleRow($(this));
941 server : PMA_commonParams.get('server'),
942 db : $('#db_alias_select').val(),
943 table: $(this).val(),
946 $.post('ajax.php', params, function (response) {
947 if (response.success === true) {
948 $.each(response.columns, function (idx, value) {
949 var option = $('<option></option>');
951 option.attr('value', value);
952 $('#column_alias_select').append(option);
955 PMA_ajaxShowMessage(response.error, false);
959 $('#column_alias_select').on('change', function () {
960 aliasToggleRow($(this));
962 $('#db_alias_button').on('click', function (e) {
964 var db = $('#db_alias_select').val();
966 PMA_messages.strAliasDatabase,
968 'aliases[' + db + '][alias]',
969 $('#db_alias_name').val()
971 $('#db_alias_name').val('');
973 $('#table_alias_button').on('click', function (e) {
975 var db = $('#db_alias_select').val();
976 var table = $('#table_alias_select').val();
978 PMA_messages.strAliasTable,
980 'aliases[' + db + '][tables][' + table + '][alias]',
981 $('#table_alias_name').val()
983 $('#table_alias_name').val('');
985 $('#column_alias_button').on('click', function (e) {
987 var db = $('#db_alias_select').val();
988 var table = $('#table_alias_select').val();
989 var column = $('#column_alias_select').val();
991 PMA_messages.strAliasColumn,
992 db + '.' + table + '.' + column,
993 'aliases[' + db + '][tables][' + table + '][colums][' + column + ']',
994 $('#column_alias_name').val()
996 $('#column_alias_name').val('');