diff --git a/js/src/export.js b/js/src/export.js index db61680d13..a0724010c8 100644 --- a/js/src/export.js +++ b/js/src/export.js @@ -1,19 +1,45 @@ /* vim: set expandtab sw=4 ts=4 sts=4: */ -import { createTemplate, loadTemplate, updateTemplate, - deleteTemplate, toggle_save_to_file, toggle_structure_data_opts, - check_table_select_all, handleAddProcCheckbox, check_table_select_struture_or_data, - check_table_selected, toggle_table_select, toggle_table_select_all_str, - check_selected_tables, toggle_table_select_all_data, setup_table_structure_or_data, - toggle_quick_or_custom, toggle_sql_include_comments, disable_dump_some_rows_sub_options, - enable_dump_some_rows_sub_options, aliasToggleRow, addAlias, createAliasModal, check_time_out +/** + * Module import + */ +import { + createTemplate, + loadTemplate, + updateTemplate, + deleteTemplate, + toggle_save_to_file, + toggle_structure_data_opts, + check_table_select_all, + handleAddProcCheckbox, + check_table_select_struture_or_data, + check_table_selected, + toggle_table_select, + toggle_table_select_all_str, + check_selected_tables, + toggle_table_select_all_data, + setup_table_structure_or_data, + toggle_quick_or_custom, + toggle_sql_include_comments, + disable_dump_some_rows_sub_options, + enable_dump_some_rows_sub_options, + aliasToggleRow, + addAlias, + createAliasModal } from './functions/export'; -import { PMA_Messages as PMA_messages } from './variables/export_variables'; -import { PMA_commonParams } from './variables/common_params'; +import { PMA_Messages as messages } from './variables/export_variables'; +import CommonParams from './variables/common_params'; import { PMA_ajaxShowMessage } from './utils/show_ajax_messages'; + +/** + * @package PhpMyAdmin + * + * Export + */ + /** * Unbind all event handlers before tearing down a page */ -export function teardown1 () { +function teardownExport () { $('#plugins').off('change'); $('input[type=\'radio\'][name=\'sql_structure_or_data\']').off('change'); $('input[type=\'radio\'][name$=\'_structure_or_data\']').off('change'); @@ -38,7 +64,7 @@ export function teardown1 () { $('form[name=\'dump\']').off('submit'); } -export function onload1 () { +function onloadExportTemplate () { /** * Export template handling code */ @@ -84,26 +110,26 @@ export function onload1 () { */ $('#plugins').on('change', function () { $('#format_specific_opts').find('div.format_specific_options').hide(); - var selected_plugin_name = $('#plugins').find('option:selected').val(); - $('#' + selected_plugin_name + '_options').show(); + var selectedPluginName = $('#plugins').find('option:selected').val(); + $('#' + selectedPluginName + '_options').show(); }); /** * Toggles the enabling and disabling of the SQL plugin's comment options that apply only when exporting structure */ $('input[type=\'radio\'][name=\'sql_structure_or_data\']').on('change', function () { - var comments_are_present = $('#checkbox_sql_include_comments').prop('checked'); + var commentsArePresent = $('#checkbox_sql_include_comments').prop('checked'); var show = $('input[type=\'radio\'][name=\'sql_structure_or_data\']:checked').val(); if (show === 'data') { // disable the SQL comment options - if (comments_are_present) { + if (commentsArePresent) { $('#checkbox_sql_dates').prop('disabled', true).parent().fadeTo('fast', 0.4); } $('#checkbox_sql_relation').prop('disabled', true).parent().fadeTo('fast', 0.4); $('#checkbox_sql_mime').prop('disabled', true).parent().fadeTo('fast', 0.4); } else { // enable the SQL comment options - if (comments_are_present) { + if (commentsArePresent) { $('#checkbox_sql_dates').prop('disabled', false).parent().fadeTo('fast', 1); } $('#checkbox_sql_relation').prop('disabled', false).parent().fadeTo('fast', 1); @@ -137,22 +163,22 @@ export function onload1 () { }); } -export function onload2 () { +function onloadSaveToFile () { toggle_save_to_file(); $('input[type=\'radio\'][name=\'output_format\']').on('change', toggle_save_to_file); } -export function onload3 () { +function onloadExportOptions () { /** * For SQL plugin, if "CREATE TABLE options" is checked/unchecked, check/uncheck each of its sub-options */ var $create = $('#checkbox_sql_create_table_statements'); - var $create_options = $('#ul_create_table_statements').find('input'); + var $createOptions = $('#ul_create_table_statements').find('input'); $create.on('change', function () { - $create_options.prop('checked', $(this).prop('checked')); + $createOptions.prop('checked', $(this).prop('checked')); }); - $create_options.on('change', function () { - if ($create_options.is(':checked')) { + $createOptions.on('change', function () { + if ($createOptions.is(':checked')) { $create.prop('checked', true); } }); @@ -161,9 +187,9 @@ export function onload3 () { * Disables the view output as text option if the output must be saved as a file */ $('#plugins').on('change', function () { - var active_plugin = $('#plugins').find('option:selected').val(); - var force_file = $('#force_file_' + active_plugin).val(); - if (force_file === 'true') { + var activePlugin = $('#plugins').find('option:selected').val(); + var forceFile = $('#force_file_' + activePlugin).val(); + if (forceFile === 'true') { if ($('#radio_dump_asfile').prop('checked') !== true) { $('#radio_dump_asfile').prop('checked', true); toggle_save_to_file(); @@ -219,11 +245,11 @@ export function onload3 () { var $this = $(this); var name = $this.prop('name'); var val = $('input[name="' + name + '"]:checked').val(); - var name_default = name + '_default'; - if (!$('input[name="' + name_default + '"]').length) { + var nameDefault = name + '_default'; + if (!$('input[name="' + nameDefault + '"]').length) { $this .after( - $('') + $('') ) .after( $('') @@ -257,7 +283,7 @@ export function onload3 () { $('#plugins').on('change', setup_table_structure_or_data); } -export function onload4 () { +function onloadExportSubmit () { $('input[type=\'radio\'][name=\'quick_or_custom\']').on('change', toggle_quick_or_custom); $('#scroll_to_options_msg').hide(); @@ -300,7 +326,7 @@ export function onload4 () { $('#db_alias_select').on('change', function () { aliasToggleRow($(this)); // var db = $(this).val(); - var table = PMA_commonParams.get('table'); + var table = CommonParams.get('table'); if (table) { var option = $(''); option.text(table); @@ -309,7 +335,7 @@ export function onload4 () { } else { var params = { ajax_request : true, - server : PMA_commonParams.get('server'), + server : CommonParams.get('server'), db : $(this).val(), type: 'list-tables' }; @@ -331,7 +357,7 @@ export function onload4 () { aliasToggleRow($(this)); var params = { ajax_request : true, - server : PMA_commonParams.get('server'), + server : CommonParams.get('server'), db : $('#db_alias_select').val(), table: $(this).val(), type: 'list-columns' @@ -356,7 +382,7 @@ export function onload4 () { e.preventDefault(); var db = $('#db_alias_select').val(); addAlias( - PMA_messages.strAliasDatabase, + messages.strAliasDatabase, db, 'aliases[' + db + '][alias]', $('#db_alias_name').val() @@ -368,7 +394,7 @@ export function onload4 () { var db = $('#db_alias_select').val(); var table = $('#table_alias_select').val(); addAlias( - PMA_messages.strAliasTable, + messages.strAliasTable, db + '.' + table, 'aliases[' + db + '][tables][' + table + '][alias]', $('#table_alias_name').val() @@ -381,7 +407,7 @@ export function onload4 () { var table = $('#table_alias_select').val(); var column = $('#column_alias_select').val(); addAlias( - PMA_messages.strAliasColumn, + messages.strAliasColumn, db + '.' + table + '.' + column, 'aliases[' + db + '][tables][' + table + '][colums][' + column + ']', $('#column_alias_name').val() @@ -389,3 +415,14 @@ export function onload4 () { $('#column_alias_name').val(''); }); } + +/** + * Module export + */ +export { + teardownExport, + onloadExportOptions, + onloadExportSubmit, + onloadExportTemplate, + onloadSaveToFile +}; diff --git a/js/src/import.js b/js/src/import.js index 1d0cfec98e..9fd8c27ab3 100644 --- a/js/src/import.js +++ b/js/src/import.js @@ -1,11 +1,22 @@ /* vim: set expandtab sw=4 ts=4 sts=4: */ + +/** + * Module import + */ import { changePluginOpts, matchFile } from './functions/import'; import { PMA_ajaxShowMessage } from './utils/show_ajax_messages'; -import { PMA_Messages as PMA_messages } from './variables/export_variables'; +import { PMA_Messages as messages } from './variables/export_variables'; + +/** + * @package PhpMyAdmin + * + * Import + */ + /** * Unbind all event handlers before tearing down a page */ -export function teardown1 () { +function teardownImport () { $('#plugins').off('change'); $('#input_import_file').off('change'); $('#select_local_import_file').off('change'); @@ -14,12 +25,15 @@ export function teardown1 () { $('#text_csv_enclosed').add('#text_csv_escaped').off('keyup'); } -export function onload1 () { +/** + * Binding event handlers on page load + */ +function onloadImport () { // import_file_form validation. $(document).on('submit', '#import_file_form', function () { var radioLocalImport = $('#radio_local_import_file'); var radioImport = $('#radio_import_file'); - var fileMsg = '
' + PMA_messages.strImportDialogMessage + '
'; + var fileMsg = '
' + messages.strImportDialogMessage + '
'; if (radioLocalImport.length !== 0) { // remote upload. @@ -32,7 +46,7 @@ export function onload1 () { if (radioLocalImport.is(':checked')) { if ($('#select_local_import_file').length === 0) { - PMA_ajaxShowMessage('
' + PMA_messages.strNoImportFile + '
', false); + PMA_ajaxShowMessage('
' + messages.strNoImportFile + '
', false); return false; } @@ -113,3 +127,11 @@ export function onload1 () { return true; }); } + +/** + * Module export + */ +export { + teardownImport, + onloadImport +}; diff --git a/js/src/server_plugins.js b/js/src/server_plugins.js index 97f153c719..c02c2c4528 100644 --- a/js/src/server_plugins.js +++ b/js/src/server_plugins.js @@ -1,9 +1,15 @@ /* vim: set expandtab sw=4 ts=4 sts=4: */ + /** - * Functions used in server plugins pages + * @package PhpMyAdmin + * + * Server Plugins */ -// import { jQuery as $ } from './utils/extend_jquery'; -export function onload1 () { + +/** + * Binding event handlers on page load. + */ +function onloadServerPlugins () { // Make columns sortable, but only for tables with more than 1 data row var $tables = $('#plugins_plugins table:has(tbody tr + tr)'); $tables.tablesorter({ @@ -15,3 +21,10 @@ export function onload1 () { $tables.find('thead th') .append('
'); } + +/** + * Module export + */ +export { + onloadServerPlugins +}; diff --git a/js/src/server_status_advisor.js b/js/src/server_status_advisor.js index f3eb162d21..af2bd63982 100644 --- a/js/src/server_status_advisor.js +++ b/js/src/server_status_advisor.js @@ -1,23 +1,30 @@ /* vim: set expandtab sw=4 ts=4 sts=4: */ -/** - * Server Status Advisor - * - * @package PhpMyAdmin - */ -import { PMA_Messages as PMA_messages } from './variables/export_variables'; +/** + * Module import + */ +import { PMA_Messages as messages } from './variables/export_variables'; + +/** + * @package PhpMyAdmin + * + * Server Status Advisor + */ /** * Unbind all event handlers before tearing down a page */ -export function teardown1 () { +function teardownServerStatusAdvisor () { $('a[href="#openAdvisorInstructions"]').off('click'); $('#statustabs_advisor').html(''); $('#advisorDialog').remove(); $('#instructionsDialog').remove(); } -export function onload1 () { +/** + * Binding event handlers on page load + */ +function onloadServerStatusAdvisor () { // if no advisor is loaded if ($('#advisorData').length === 0) { return; @@ -31,11 +38,11 @@ export function onload1 () { $('a[href="#openAdvisorInstructions"]').click(function () { var dlgBtns = {}; - dlgBtns[PMA_messages.strClose] = function () { + dlgBtns[messages.strClose] = function () { $(this).dialog('close'); }; $instructionsDialog.dialog({ - title: PMA_messages.strAdvisorSystem, + title: messages.strAdvisorSystem, width: 700, buttons: dlgBtns }); @@ -62,9 +69,9 @@ export function onload1 () { } if (data.run.fired.length > 0) { - $cnt.append('

' + PMA_messages.strPerformanceIssues + '

'); + $cnt.append('

' + messages.strPerformanceIssues + '

'); $cnt.append('' + - '
' + PMA_messages.strIssuse + '' + PMA_messages.strRecommendation + + '' + messages.strIssuse + '' + messages.strRecommendation + '
'); $tbody = $cnt.find('table#rulesFired'); @@ -81,17 +88,17 @@ export function onload1 () { $tr.click(function () { var rule = $(this).data('rule'); $dialog - .dialog({ title: PMA_messages.strRuleDetails }) + .dialog({ title: messages.strRuleDetails }) .html( - '

' + PMA_messages.strIssuse + ':
' + rule.issue + '

' + - '

' + PMA_messages.strRecommendation + ':
' + rule.recommendation + '

' + - '

' + PMA_messages.strJustification + ':
' + rule.justification + '

' + - '

' + PMA_messages.strFormula + ':
' + rule.formula + '

' + - '

' + PMA_messages.strTest + ':
' + rule.test + '

' + '

' + messages.strIssuse + ':
' + rule.issue + '

' + + '

' + messages.strRecommendation + ':
' + rule.recommendation + '

' + + '

' + messages.strJustification + ':
' + rule.justification + '

' + + '

' + messages.strFormula + ':
' + rule.formula + '

' + + '

' + messages.strTest + ':
' + rule.test + '

' ); var dlgBtns = {}; - dlgBtns[PMA_messages.strClose] = function () { + dlgBtns[messages.strClose] = function () { $(this).dialog('close'); }; @@ -100,3 +107,11 @@ export function onload1 () { }); } } + +/** + * Module export + */ +export { + teardownServerStatusAdvisor, + onloadServerStatusAdvisor +}; diff --git a/js/src/server_status_processes.js b/js/src/server_status_processes.js index d880907f5c..a873d58127 100644 --- a/js/src/server_status_processes.js +++ b/js/src/server_status_processes.js @@ -1,11 +1,20 @@ /* vim: set expandtab sw=4 ts=4 sts=4: */ + /** - * Server Status Processes - * - * @package PhpMyAdmin + * Module import */ import processList from './classes/Server/ProcessList'; -export function onload1 () { + +/** + * @package PhpMyAdmin + * + * Server Status Processes + */ + +/** + * Binding event handlers on page load + */ +function onloadServerStatusProcesses () { processList.init(); // Bind event handler for kill_process $('#tableprocesslist').on('click', 'a.kill_process', function (event) { @@ -31,7 +40,7 @@ export function onload1 () { /** * Unbind all event handlers before tearing down a page */ -export function teardown1 () { +function teardownServerStatusProcesses () { $('#tableprocesslist').off('click', 'a.kill_process'); $('a#toggleRefresh').off('click'); $('#id_refreshRate').off('change'); @@ -39,3 +48,11 @@ export function teardown1 () { // stop refreshing further processList.abortRefresh(); } + +/** + * Module export + */ +export { + teardownServerStatusProcesses, + onloadServerStatusProcesses +}; diff --git a/js/src/server_status_queries.js b/js/src/server_status_queries.js index e2086f5c10..f5b151dd96 100644 --- a/js/src/server_status_queries.js +++ b/js/src/server_status_queries.js @@ -1,21 +1,29 @@ /* vim: set expandtab sw=4 ts=4 sts=4: */ + /** + * Module import */ -import { PMA_createProfilingChart } from './functions/chart'; +import { createProfilingChart } from './functions/chart'; import { jQuery as $ } from './utils/JqueryExtended'; +import { initTableSorter } from './server_status_sorter'; + +/** + * @package PhpMyAdmin + * + * Server Status Queries + */ + /** * Unbind all event handlers before tearing down a page */ -import { initTableSorter } from './server_status_sorter'; - -export function teardown1 () { +function teardownServerStatusQueries () { var queryPieChart = $('#serverstatusquerieschart').data('queryPieChart'); if (queryPieChart) { queryPieChart.destroy(); } } -export function onload1 () { +function onloadServerStatusQueries () { // Build query statistics chart var cdata = []; try { @@ -24,7 +32,7 @@ export function onload1 () { }); $('#serverstatusquerieschart').data( 'queryPieChart', - PMA_createProfilingChart( + createProfilingChart( 'serverstatusquerieschart', cdata ) @@ -35,3 +43,11 @@ export function onload1 () { initTableSorter('statustabs_queries'); } + +/** + * Module export + */ +export { + teardownServerStatusQueries, + onloadServerStatusQueries +}; diff --git a/js/src/server_status_variables.js b/js/src/server_status_variables.js index b2db6e80b4..0082a96f8d 100644 --- a/js/src/server_status_variables.js +++ b/js/src/server_status_variables.js @@ -1,21 +1,30 @@ /* vim: set expandtab sw=4 ts=4 sts=4: */ + +/** + * Module import + */ +import { filterVariables } from './functions/Server/ServerStatusVariables'; + /** - * - * * @package PhpMyAdmin + * + * Server Status Variables */ /** * Unbind all event handlers before tearing down a page */ -export function teardown1 () { +function teardownServerStatusVariables () { $('#filterAlert').off('change'); $('#filterText').off('keyup'); $('#filterCategory').off('change'); $('#dontFormat').off('change'); } -export function onload1 () { +/** + * Binding event handlers on page load + */ +function onloadServerStatusVariables () { // Filters for status variables var textFilter = null; var alertFilter = $('#filterAlert').prop('checked'); @@ -25,12 +34,12 @@ export function onload1 () { /* 3 Filtering functions */ $('#filterAlert').change(function () { alertFilter = this.checked; - filterVariables(); + filterVariables(textFilter, alertFilter, categoryFilter, text); }); $('#filterCategory').change(function () { categoryFilter = $(this).val(); - filterVariables(); + filterVariables(textFilter, alertFilter, categoryFilter, text); }); $('#dontFormat').change(function () { @@ -41,7 +50,7 @@ export function onload1 () { $('#serverstatusvariables').show(); }).trigger('change'); - $('#filterText').keyup(function (e) { + $('#filterText').keyup(function () { var word = $(this).val().replace(/_/g, ' '); if (word.length === 0) { textFilter = null; @@ -57,44 +66,14 @@ export function onload1 () { } } text = word; - filterVariables(); + filterVariables(textFilter, alertFilter, categoryFilter, text); }).trigger('keyup'); - - /* Filters the status variables by name/category/alert in the variables tab */ - function filterVariables () { - var useful_links = 0; - var section = text; - - if (categoryFilter.length > 0) { - section = categoryFilter; - } - - if (section.length > 1) { - $('#linkSuggestions').find('span').each(function () { - if ($(this).attr('class').indexOf('status_' + section) !== -1) { - useful_links++; - $(this).css('display', ''); - } else { - $(this).css('display', 'none'); - } - }); - } - - if (useful_links > 0) { - $('#linkSuggestions').css('display', ''); - } else { - $('#linkSuggestions').css('display', 'none'); - } - - $('#serverstatusvariables').find('th.name').each(function () { - if ((textFilter === null || textFilter.exec($(this).text())) && - (! alertFilter || $(this).next().find('span.attention').length > 0) && - (categoryFilter.length === 0 || $(this).parent().hasClass('s_' + categoryFilter)) - ) { - $(this).parent().css('display', ''); - } else { - $(this).parent().css('display', 'none'); - } - }); - } } + +/** + * Module export + */ +export { + teardownServerStatusVariables, + onloadServerStatusVariables +}; diff --git a/js/src/server_user_groups.js b/js/src/server_user_groups.js index 4f71e1161c..1c0dec0758 100644 --- a/js/src/server_user_groups.js +++ b/js/src/server_user_groups.js @@ -1,18 +1,29 @@ +/* vim: set expandtab sw=4 ts=4 sts=4: */ + /** - * Unbind all event handlers before tearing down a page + * Module import */ import { PMA_Messages as PMA_messages } from './variables/export_variables'; import { PMA_sprintf } from './utils/sprintf'; import { escapeHtml } from './utils/Sanitise'; -export function teardown1 () { +/** + * @package PhpMyAdmin + * + * Server User Groups + */ + +/** + * Unbind all event handlers before tearing down a page + */ +function teardownServerUserGroups () { $(document).off('click', 'a.deleteUserGroup.ajax'); } /** - * Bind event handlers + * Bind event handlers on page load. */ -export function onload1 () { +function onloadServerUserGroups () { // update the checkall checkbox on Edit user group page $(checkboxes_sel).trigger('change'); @@ -43,3 +54,11 @@ export function onload1 () { }); }); } + +/** + * Module export + */ +export { + teardownServerUserGroups, + onloadServerUserGroups +}; diff --git a/js/src/server_variables.js b/js/src/server_variables.js index 4507963e08..c49fcb29a0 100644 --- a/js/src/server_variables.js +++ b/js/src/server_variables.js @@ -1,15 +1,28 @@ /* vim: set expandtab sw=4 ts=4 sts=4: */ -import { PMA_Messages as PMA_messages } from './variables/export_variables'; -import { PMA_ajaxShowMessage, PMA_ajaxRemoveMessage } from './utils/show_ajax_messages'; + /** - * Unbind all event handlers before tearing down a page + * Module import */ -export function teardown1 () { +import { editVariable } from './functions/Server/ServerVariables'; + +/** + * @package PhpMyAdmin + * + * Server Variables + */ + +/** + * Unbind all event handlers before tearing down a page. + */ +function teardownServerVariables () { $(document).off('click', 'a.editLink'); $('#serverVariables').find('.var-name').find('a img').remove(); } -export function onload1 () { +/** + * Binding event handlers on page load. + */ +function onloadServerVariables () { // var $editLink = $('a.editLink'); var $saveLink = $('a.saveLink'); var $cancelLink = $('a.cancelLink'); @@ -21,93 +34,11 @@ export function onload1 () { /* Launches the variable editor */ $(document).on('click', 'a.editLink', function (event) { event.preventDefault(); - editVariable(this); + editVariable(this, $saveLink, $cancelLink); }); - - /* Allows the user to edit a server variable */ - function editVariable (link) { - var $link = $(link); - var $cell = $link.parent(); - var $valueCell = $link.parents('.var-row').find('.var-value'); - var varName = $link.data('variable'); - var $mySaveLink = $saveLink.clone().css('display', 'inline-block'); - var $myCancelLink = $cancelLink.clone().css('display', 'inline-block'); - var $msgbox = PMA_ajaxShowMessage(); - var $myEditLink = $cell.find('a.editLink'); - - $cell.addClass('edit'); // variable is being edited - $myEditLink.remove(); // remove edit link - - $mySaveLink.on('click', function () { - var $msgbox = PMA_ajaxShowMessage(PMA_messages.strProcessingRequest); - $.post($(this).attr('href'), { - ajax_request: true, - type: 'setval', - varName: varName, - varValue: $valueCell.find('input').val() - }, function (data) { - if (data.success) { - $valueCell - .html(data.variable) - .data('content', data.variable); - PMA_ajaxRemoveMessage($msgbox); - } else { - if (data.error === '') { - PMA_ajaxShowMessage(PMA_messages.strRequestFailed, false); - } else { - PMA_ajaxShowMessage(data.error, false); - } - $valueCell.html($valueCell.data('content')); - } - $cell.removeClass('edit').html($myEditLink); - }); - return false; - }); - - $myCancelLink.on('click', function () { - $valueCell.html($valueCell.data('content')); - $cell.removeClass('edit').html($myEditLink); - return false; - }); - - $.get($mySaveLink.attr('href'), { - ajax_request: true, - type: 'getval', - varName: varName - }, function (data) { - if (typeof data !== 'undefined' && data.success === true) { - var $links = $('
') - .append($myCancelLink) - .append('   ') - .append($mySaveLink); - var $editor = $('
', { 'class': 'serverVariableEditor' }) - .append( - $('
').append( - $('', { type: 'text' }).val(data.message) - ) - ); - // Save and replace content - $cell - .html($links) - .children() - .css('display', 'flex'); - $valueCell - .data('content', $valueCell.html()) - .html($editor) - .find('input') - .focus() - .on('keydown', function (event) { // Keyboard shortcuts - if (event.keyCode === 13) { // Enter key - $mySaveLink.trigger('click'); - } else if (event.keyCode === 27) { // Escape key - $myCancelLink.trigger('click'); - } - }); - PMA_ajaxRemoveMessage($msgbox); - } else { - $cell.removeClass('edit').html($myEditLink); - PMA_ajaxShowMessage(data.error); - } - }); - } } + +export { + teardownServerVariables, + onloadServerVariables +}; diff --git a/js/src/variables/common_params.js b/js/src/variables/common_params.js index bfbfd21ac2..0c1e81a835 100644 --- a/js/src/variables/common_params.js +++ b/js/src/variables/common_params.js @@ -1,24 +1,40 @@ +/* vim: set expandtab sw=4 ts=4 sts=4: */ + +/** + * Module imports + */ import { PMA_sprintf } from '../utils/sprintf'; import { PMA_showCurrentNavigation } from '../functions/navigation'; /** + * * Holds common parameters such as server, db, table, etc * * The content for this is normally loaded from Header.php or * Response.php and executed by ajax.js + * + * @module CommonParams + * */ -export const PMA_commonParams = (function () { +const CommonParams = (function () { /** - * @var hash params An associative array of key value pairs + * @type {hash} params An associative array of key value pairs + * * @access private */ var params = {}; - // The returned object is the public part of the module + /** + * The returned object is the public part of the module. + * + * @method + * + * @access public + */ return { /** * Saves all the key value pair that * are provided in the input array * - * @param obj hash The input array + * @param {Hash} obj The input array * * @return void */ @@ -33,8 +49,8 @@ export const PMA_commonParams = (function () { } params[i] = obj[i]; } - if (updateNavigation && - $('#pma_navigation_tree').hasClass('synced') + if (updateNavigation + && $('#pma_navigation_tree').hasClass('synced') ) { PMA_showCurrentNavigation(); } @@ -43,9 +59,9 @@ export const PMA_commonParams = (function () { * Retrieves a value given its key * Returns empty string for undefined values * - * @param name string The key + * @param {string} name The key * - * @return string + * @return {string} */ get: function (name) { return params[name]; @@ -53,10 +69,11 @@ export const PMA_commonParams = (function () { /** * Saves a single key value pair * - * @param name string The key - * @param value string The value + * @param {string} name The key * - * @return self For chainability + * @param {string} value The value + * + * @return {self} For chainability */ set: function (name, value) { var updateNavigation = false; @@ -76,12 +93,12 @@ export const PMA_commonParams = (function () { /** * Returns the url query string using the saved parameters * - * @return string + * @return {string} */ getUrlQuery: function () { var common = this.get('common_query'); var separator = '?'; - var argsep = PMA_commonParams.get('arg_separator'); + var argsep = CommonParams.get('arg_separator'); if (common.length > 0) { separator = argsep; } @@ -96,3 +113,8 @@ export const PMA_commonParams = (function () { } }; }()); + +/** + * Module Export + */ +export default CommonParams; diff --git a/js/src/variables/export_variables.js b/js/src/variables/export_variables.js index f3a454dc85..dd9a5367c5 100644 --- a/js/src/variables/export_variables.js +++ b/js/src/variables/export_variables.js @@ -1,10 +1,39 @@ -import { Variables } from './global_variables'; +/* vim: set expandtab sw=4 ts=4 sts=4: */ -export const PMA_Messages = Variables.getMessages(); +/** + * Module Imports + */ +import Variables from './global_variables'; -export const timePicker = Variables.getTimePickerVars(); +/** + * @type {hash} Messages Contains the message string to be used + * inside PMA. + */ +const PMA_Messages = Variables.getMessages(); -export const GlobalVariables = Variables.getGlobalVars(); +/** + * @type {hash} TimePicker Contains the strings for time and date. + */ +const timePicker = Variables.getTimePickerVars(); -export const validations = Variables.getValidatorMessages(); +/** + * @type {hash} GlobalVariables Global variables to bee used inside for PMA + * like doc template, theme etc + */ +const GlobalVariables = Variables.getGlobalVars(); +/** + * @type {hash} JqueryValidations Contains the hash for replacing the default + * jQuery validation with language specific validations. + */ +const JqueryValidations = Variables.getValidatorMessages(); + +/** + * Module Export + */ +export { + PMA_Messages, + timePicker, + GlobalVariables, + JqueryValidations +}; diff --git a/js/src/variables/get_config.js b/js/src/variables/get_config.js index ef2d6c3acb..4d4d2809be 100644 --- a/js/src/variables/get_config.js +++ b/js/src/variables/get_config.js @@ -1,16 +1,34 @@ +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * Module import + */ import { validators } from '../classes/Config'; import { PMA_Messages as PMA_messages } from './export_variables'; +/** + * @type {Object} defaultValues Default values for the Settings data. + */ let defaultValues = {}; + +/** + * @type {Object} validate Validations for the settings input fields. + */ let validate = {}; /** * Registers validator for given field * + * @access private + * * @param {String} id field id + * * @param {String} type validator (key in validators object) + * * @param {boolean} onKeyUp whether fire on key up + * * @param {Array} params validation function parameters + * + * @return {void} */ function validateField (id, type, onKeyUp, params) { if (typeof validators[type] === 'undefined') { @@ -22,12 +40,26 @@ function validateField (id, type, onKeyUp, params) { validate[id].push([type, params, onKeyUp]); } +/** + * @access public + */ window.getConfigData = function () { + // Passing the arguments inside validate for validating fields. for (var i = 0; i < arguments.length - 3; i++) { validateField(...arguments[i]); } + + // Extending the Messages for validation. $.extend(PMA_messages, arguments[arguments.length - 2]); + + // Extending defaultValues object for default values of settings. $.extend(defaultValues, arguments[arguments.length - 1]); }; -export { defaultValues, validate }; +/** + * Object export + */ +export { + defaultValues, + validate +}; diff --git a/js/src/variables/global_variables.js b/js/src/variables/global_variables.js index 4f6b1807f3..78a0b2130e 100644 --- a/js/src/variables/global_variables.js +++ b/js/src/variables/global_variables.js @@ -3,113 +3,128 @@ /** * Takes parameters defined in messages.php file like messages, validations, * jquery-ui-timepicker edits + * + * @module */ -export const Variables = (function () { +class PmaVariables { /** - * @var obj params An associate array having key value pairs - * of messages to show in js files. - * - * @access private + * @constructor */ - let pmaMessages = new Array(); + constructor () { + /** + * @var obj params An associate array having key value pairs + * of messages to show in js files. + * + * @access private + */ + this.pmaMessages = new Array(); + /** + * @var obj params Associative array having global configurations + * + * @access private + */ + this.globalVariables = new Array(); + /** + * @var obj params Associative array having timepicker edits + * + * @access private + */ + this.timePickerVars = new Array(); + /** + * + * @var obj params Object having validation edits for jQuery + */ + this.validationVars = {}; + } /** - * @var obj params Associative array having global configurations + * Retrieves the messages array * - * @access private + * @return array */ - let globalVariables = new Array(); + getMessages () { + return this.pmaMessages; + } /** - * @var obj params Associative array having timepicker edits + * Retrieves the globalVars array * - * @access private + * @return array */ - let timePickerVars = new Array(); + getGlobalVars () { + return this.globalVariables; + } /** + * Retrieves the timePickerVars array * - * @var obj params Object having validation edits for jQuery + * @return array */ - let validationVars = {}; - return { - /** - * Retrieves the messages array - * - * @return array - */ - getMessages: () => { - return pmaMessages; - }, - /** - * Retrieves the globalVars array - * - * @return array - */ - getGlobalVars: () => { - return globalVariables; - }, - /** - * Retrieves the timePickerVars array - * - * @return array - */ - getTimePickerVars: () => { - return timePickerVars; - }, - /** - * Retrieves the validationVars array - * - * @return array - */ - getValidatorMessages: () => { - return validationVars; - }, - /** - * Saves the key value pair provided in input - * - * @param obj array The input array of messages - * - * @return void - */ - setAllMessages: (obj) => { - for (var i in obj) { - pmaMessages[i] = obj[i]; - } - }, - /** - * Saves the key value pair provided in input - * - * @param obj array The input array of global variables - * - * @return void - */ - setGlobalVars: (obj) => { - for (var i in obj) { - globalVariables[i] = obj[i]; - } - }, - /** - * Saves the key value pair provided in input - * - * @param obj array The input array of timepicker edits - * - * @return void - */ - setTimePickerVars: (obj) => { - for (var i in obj) { - timePickerVars[i] = obj[i]; - } - }, - /** - * Saves the key value pair provided in input - * - * @param obj array The input array jQuery validation edits - * - * @return void - */ - setValidatorMessages: (obj) => { - for (var i in obj) { - validationVars[i] = obj[i]; - } - }, - }; -}()); + getTimePickerVars () { + return this.timePickerVars; + } + /** + * Retrieves the validationVars array + * + * @return array + */ + getValidatorMessages () { + return this.validationVars; + } + /** + * Saves the key value pair provided in input + * + * @param obj array The input array of messages + * + * @return void + */ + setAllMessages (obj) { + for (var i in obj) { + this.pmaMessages[i] = obj[i]; + } + } + /** + * Saves the key value pair provided in input + * + * @param obj array The input array of global variables + * + * @return void + */ + setGlobalVars (obj) { + for (var i in obj) { + this.globalVariables[i] = obj[i]; + } + } + /** + * Saves the key value pair provided in input + * + * @param obj array The input array of timepicker edits + * + * @return void + */ + setTimePickerVars (obj) { + for (var i in obj) { + this.timePickerVars[i] = obj[i]; + } + } + /** + * Saves the key value pair provided in input + * + * @param obj array The input array jQuery validation edits + * + * @return void + */ + setValidatorMessages (obj) { + for (var i in obj) { + this.validationVars[i] = obj[i]; + } + } +} + +/** + * @type {Object} Variables + */ +let Variables = new PmaVariables(); + +/** + * Module export + */ +export default Variables; diff --git a/js/src/variables/import_variables.js b/js/src/variables/import_variables.js index 23baf33133..6117b02bb7 100644 --- a/js/src/variables/import_variables.js +++ b/js/src/variables/import_variables.js @@ -1,20 +1,51 @@ -import { Variables } from './global_variables'; -import { PMA_commonParams } from './common_params'; +/* vim: set expandtab sw=4 ts=4 sts=4: */ -var jqueryValidations = { - validationFormat: window.validateFormat, - validationMessage: window.validationMessage -}; +/** + * Module Imports + */ +import Variables from './global_variables'; +import CommonParams from './common_params'; + +/** + * Importing message strings from window of document which need + * to be used in the files for messages. + * + * @argument {hash} window.PMA_messages + */ Variables.setAllMessages(window.PMA_messages); + +/** + * Importing time and date rrelated strings like day, date, time + * etc for using with different languages. + * + * @argument {hash} window.timePicker + */ Variables.setTimePickerVars({ datePicker: window.datePicker, timePicker: window.timePicker }); -Variables.setValidatorMessages(jqueryValidations); + +/** + * Importing validation strings for jQuery validations for diifferent. + * language validations. + * + * @argument {hash} Object + */ +Variables.setValidatorMessages({ + validateFormat: window.validateFormat, + validationMessage: window.validationMessage +}); + +/** + * Importing global variable from window for theme and doc template. + * + * @argument {hash} window.globalVars + */ Variables.setGlobalVars(window.globalVars); /** - * This statement to be placed in the file going to be - * executed firstly like functions.js + * Importing common parameters like db, table, url etc + * + * @argument {hash} window.common_params */ -PMA_commonParams.setAll(window.common_params); +CommonParams.setAll(window.common_params);