diff --git a/js/src/ajax.js b/js/src/ajax.js
index 0080d6f1ec..a07932eebf 100644
--- a/js/src/ajax.js
+++ b/js/src/ajax.js
@@ -1,12 +1,20 @@
-import { PMA_ajaxShowMessage, PMA_ajaxRemoveMessage } from './utils/show_ajax_messages';
+/* vim: set expandtab sw=4 ts=4 sts=4: */
+
+/**
+ * Module import
+ */
+import { PMA_ajaxShowMessage,
+ PMA_ajaxRemoveMessage
+} from './utils/show_ajax_messages';
import { PMA_Messages as PMA_messages } from './variables/export_variables';
-import { PMA_commonParams } from './variables/common_params';
+import CommonParams from './variables/common_params';
import { jQuery as $ } from './utils/JqueryExtended';
import { PMA_getImage } from './functions/get_image';
-import { PMA_ensureNaviSettings, PMA_reloadNavigation,
- PMA_disableNaviSettings } from './functions/navigation';
+import { PMA_ensureNaviSettings,
+ PMA_reloadNavigation,
+ PMA_disableNaviSettings
+} from './functions/navigation';
import { isStorageSupported } from './functions/config';
-
/**
* This object handles ajax requests for pages. It also
* handles the reloading of the main menu and scripts.
@@ -312,7 +320,7 @@ export let AJAX = {
$('html, body').animate({ scrollTop: 0 }, 'fast');
var url = isLink ? href : $(this).attr('action');
- var argsep = PMA_commonParams.get('arg_separator');
+ var argsep = CommonParams.get('arg_separator');
var params = 'ajax_request=true' + argsep + 'ajax_page_request=true';
var dataPost = AJAX.source.getPostData();
if (! isLink) {
@@ -461,7 +469,7 @@ export let AJAX = {
$('#selflink').find('> a').attr('href', data._selflink);
}
if (data._params) {
- PMA_commonParams.setAll(data._params);
+ CommonParams.setAll(data._params);
}
if (data._scripts) {
AJAX.scriptHandler.load(data._scripts);
@@ -590,7 +598,8 @@ export let AJAX = {
if (checkNewCode(file)) {
var fileImports = ['server_privileges', 'server_databases', 'error_report', 'navigation', 'server_status_advisor',
'server_status_processes', 'server_status_variables', 'server_plugins', 'server_status_sorter', 'server_status_queries',
- 'server_status_monitor', 'server_variables', 'server_user_groups', 'replication', 'export', 'import', 'config'
+ 'server_status_monitor', 'server_variables', 'server_user_groups', 'replication', 'export', 'import', 'config',
+ 'page_settings', 'shortcuts_handler'
];
if ($.inArray(file, fileImports) !== -1) {
// Dynamic import to load the files dynamically
@@ -638,10 +647,10 @@ export let AJAX = {
// Clear loaded scripts if they are from another version of phpMyAdmin.
// Depends on common params being set before loading scripts in responseHandler
if (self._scriptsVersion === null) {
- self._scriptsVersion = PMA_commonParams.get('PMA_VERSION');
- } else if (self._scriptsVersion !== PMA_commonParams.get('PMA_VERSION')) {
+ self._scriptsVersion = CommonParams.get('PMA_VERSION');
+ } else if (self._scriptsVersion !== CommonParams.get('PMA_VERSION')) {
self._scripts = [];
- self._scriptsVersion = PMA_commonParams.get('PMA_VERSION');
+ self._scriptsVersion = CommonParams.get('PMA_VERSION');
}
self._scriptsCompleted = false;
self._scriptsToBeFired = [];
diff --git a/js/src/classes/ErrorReport.js b/js/src/classes/ErrorReport.js
index 87fd2caa2a..b490544ceb 100644
--- a/js/src/classes/ErrorReport.js
+++ b/js/src/classes/ErrorReport.js
@@ -4,7 +4,7 @@
*/
import { AJAX } from '../ajax';
import { PMA_Messages as PMA_messages } from '../variables/export_variables';
-import { PMA_commonParams } from '../variables/common_params';
+import CommonParams from '../variables/common_params';
import { PMA_ajaxShowMessage } from '../utils/show_ajax_messages';
import { PMA_getImage } from '../functions/get_image';
import TraceKit from 'tracekit';
@@ -45,7 +45,7 @@ var ErrorReport = {
ErrorReport._last_exception = exception;
$.get('error_report.php', {
ajax_request: true,
- server: PMA_commonParams.get('server'),
+ server: CommonParams.get('server'),
get_settings: true,
exception_type: 'js'
}, function (data) {
diff --git a/js/src/classes/Server/ProcessList.js b/js/src/classes/Server/ProcessList.js
index dc730aac86..1a730f9423 100644
--- a/js/src/classes/Server/ProcessList.js
+++ b/js/src/classes/Server/ProcessList.js
@@ -1,7 +1,7 @@
import { PMA_ajaxShowMessage } from '../../utils/show_ajax_messages';
import { PMA_highlightSQL } from '../../utils/sql';
import { PMA_Messages as PMA_messages } from '../../variables/export_variables';
-import { PMA_commonParams } from '../../variables/common_params';
+import CommonParams from '../../variables/common_params';
import { PMA_getImage } from '../../functions/get_image';
import { escapeHtml } from '../../utils/Sanitise';
import { jQuery as $ } from '../../utils/JqueryExtended';
@@ -35,7 +35,7 @@ class ProcessList {
this.setRefreshLabel();
if (this.refreshUrl === null) {
this.refreshUrl = 'server_status_processes.php' +
- PMA_commonParams.get('common_query');
+ CommonParams.get('common_query');
}
if (this.refreshInterval === null) {
this.refreshInterval = $('#id_refreshRate').val();
diff --git a/js/src/config.js b/js/src/config.js
index 35d654a126..40a4a5e49e 100644
--- a/js/src/config.js
+++ b/js/src/config.js
@@ -1,11 +1,5 @@
/* vim: set expandtab sw=4 ts=4 sts=4: */
-
-import { isStorageSupported, updatePrefsDate, offerPrefsAutoimport,
- savePrefsToLocalStorage, setupRestoreField, getFieldType,
- setFieldValue, setupConfigTabs, adjustPrefsNotification, setTab,
- setupValidation } from './functions/config';
-
-
+import * as Config from './functions/config';
import { defaultValues } from './variables/get_config';
/**
@@ -36,7 +30,7 @@ export function onload1 () {
//
export function onload2 () {
- setupValidation();
+ Config.setupValidation();
}
//
@@ -48,8 +42,8 @@ export function onload2 () {
//
export function onload3 () {
- setupConfigTabs();
- adjustPrefsNotification();
+ Config.setupConfigTabs();
+ Config.adjustPrefsNotification();
// tab links handling, check each 200ms
// (works with history in FF, further browser support here would be an overkill)
@@ -61,7 +55,7 @@ export function onload3 () {
// session ID is sometimes appended here
var hash = prev_hash.substr(5).split('&')[0];
if ($('#' + hash).length) {
- setTab(hash);
+ Config.setTab(hash);
}
}
}
@@ -82,7 +76,7 @@ export function onload4 () {
$('.optbox input[type=button][name=submit_reset]').on('click', function () {
var fields = $(this).closest('fieldset').find('input, select, textarea');
for (var i = 0, imax = fields.length; i < imax; i++) {
- setFieldValue(fields[i], getFieldType(fields[i]), defaultValues[fields[i].id]);
+ Config.setFieldValue(fields[i], Config.getFieldType(fields[i]), defaultValues[fields[i].id]);
}
});
}
@@ -96,7 +90,7 @@ export function onload4 () {
//
export function onload5 () {
- setupRestoreField();
+ Config.setupRestoreField();
}
//
@@ -108,7 +102,7 @@ export function onload5 () {
//
export function onload6 () {
- offerPrefsAutoimport();
+ Config.offerPrefsAutoimport();
var $radios = $('#import_local_storage, #export_local_storage');
if (!$radios.length) {
return;
@@ -131,12 +125,12 @@ export function onload6 () {
});
// detect localStorage state
- var ls_supported = isStorageSupported('localStorage', true);
+ var ls_supported = Config.isStorageSupported('localStorage', true);
var ls_exists = ls_supported ? (window.localStorage.config || false) : false;
$('div.localStorage-' + (ls_supported ? 'un' : '') + 'supported').hide();
$('div.localStorage-' + (ls_exists ? 'empty' : 'exists')).hide();
if (ls_exists) {
- updatePrefsDate();
+ Config.updatePrefsDate();
}
$('form.prefs-form').on('change', function () {
var $form = $(this);
@@ -154,7 +148,7 @@ export function onload6 () {
if ($form.attr('name') === 'prefs_export' && $('#export_local_storage')[0].checked) {
e.preventDefault();
// use AJAX to read JSON settings and save them
- savePrefsToLocalStorage($form);
+ Config.savePrefsToLocalStorage($form);
} else if ($form.attr('name') === 'prefs_import' && $('#import_local_storage')[0].checked) {
// set 'json' input and submit form
$form.find('input[name=json]').val(window.localStorage.config);
diff --git a/js/src/consts/files.js b/js/src/consts/files.js
index 19c8bdd002..083a0a1f78 100644
--- a/js/src/consts/files.js
+++ b/js/src/consts/files.js
@@ -7,7 +7,7 @@
* @type {Object} files
*/
const files = {
- global: ['error_report', 'navigation', 'config'],
+ global: ['error_report', 'config', 'navigation', 'page_settings', 'shortcuts_handler'],
server_privileges: ['server_privileges'],
server_databases: ['server_databases'],
server_status_advisor: ['server_status_advisor'],
diff --git a/js/src/export.js b/js/src/export.js
index db61680d13..e49b15e345 100644
--- a/js/src/export.js
+++ b/js/src/export.js
@@ -1,19 +1,22 @@
/* 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
-} from './functions/export';
-import { PMA_Messages as PMA_messages } from './variables/export_variables';
-import { PMA_commonParams } from './variables/common_params';
+/**
+ * Module import
+ */
+import * as Export from './functions/export';
+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 +41,7 @@ export function teardown1 () {
$('form[name=\'dump\']').off('submit');
}
-export function onload1 () {
+function onloadExportTemplate () {
/**
* Export template handling code
*/
@@ -47,7 +50,7 @@ export function onload1 () {
e.preventDefault();
var name = $('input[name="templateName"]').val();
if (name.length) {
- createTemplate(name);
+ Export.createTemplate(name);
}
});
@@ -56,7 +59,7 @@ export function onload1 () {
e.preventDefault();
var id = $(this).val();
if (id.length) {
- loadTemplate(id);
+ Export.loadTemplate(id);
}
});
@@ -65,7 +68,7 @@ export function onload1 () {
e.preventDefault();
var id = $('select[name="template"]').val();
if (id.length) {
- updateTemplate(id);
+ Export.updateTemplate(id);
}
});
@@ -74,7 +77,7 @@ export function onload1 () {
e.preventDefault();
var id = $('select[name="template"]').val();
if (id.length) {
- deleteTemplate(id);
+ Export.deleteTemplate(id);
}
});
@@ -84,26 +87,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 +140,22 @@ export function onload1 () {
});
}
-export function onload2 () {
- toggle_save_to_file();
- $('input[type=\'radio\'][name=\'output_format\']').on('change', toggle_save_to_file);
+function onloadSaveToFile () {
+ Export.toggleSaveToFile();
+ $('input[type=\'radio\'][name=\'output_format\']').on('change', Export.toggleSaveToFile);
}
-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,12 +164,12 @@ 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();
+ Export.toggleSaveToFile();
}
$('#radio_view_as_text').prop('disabled', true).parent().fadeTo('fast', 0.4);
} else {
@@ -175,42 +178,42 @@ export function onload3 () {
});
$('input[type=\'radio\'][name$=\'_structure_or_data\']').on('change', function () {
- toggle_structure_data_opts();
+ Export.toggleStructureDataOpts();
});
$('input[name="table_select[]"]').on('change', function () {
- toggle_table_select($(this).closest('tr'));
- check_table_select_all();
- handleAddProcCheckbox();
- check_table_select_struture_or_data();
+ Export.toggleTableSelect($(this).closest('tr'));
+ Export.checkTableSelectAll();
+ Export.handleAddProcCheckbox();
+ Export.checkTableSelectStrutureOrData();
});
$('input[name="table_structure[]"]').on('change', function () {
- check_table_selected($(this).closest('tr'));
- check_table_select_all();
- handleAddProcCheckbox();
- check_table_select_struture_or_data();
+ Export.checkTableSelected($(this).closest('tr'));
+ Export.checkTableSelectAll();
+ Export.handleAddProcCheckbox();
+ Export.checkTableSelectStrutureOrData();
});
$('input[name="table_data[]"]').on('change', function () {
- check_table_selected($(this).closest('tr'));
- check_table_select_all();
- handleAddProcCheckbox();
- check_table_select_struture_or_data();
+ Export.checkTableSelected($(this).closest('tr'));
+ Export.checkTableSelectAll();
+ Export.handleAddProcCheckbox();
+ Export.checkTableSelectStrutureOrData();
});
$('#table_structure_all').on('change', function () {
- toggle_table_select_all_str();
- check_selected_tables();
- handleAddProcCheckbox();
- check_table_select_struture_or_data();
+ Export.toggleTableSelectAllStr();
+ Export.checkSelectedTables();
+ Export.handleAddProcCheckbox();
+ Export.checkTableSelectStrutureOrData();
});
$('#table_data_all').on('change', function () {
- toggle_table_select_all_data();
- check_selected_tables();
- handleAddProcCheckbox();
- check_table_select_struture_or_data();
+ Export.toggleTableSelectAllData();
+ Export.checkSelectedTables();
+ Export.handleAddProcCheckbox();
+ Export.checkTableSelectStrutureOrData();
});
if ($('input[name=\'export_type\']').val() === 'database') {
@@ -219,11 +222,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(
$('')
@@ -248,17 +251,17 @@ export function onload3 () {
.parent()
.fadeTo('fast', 0.4);
- setup_table_structure_or_data();
+ Export.setupTableStructureOrData();
}
/**
* Handle force structure_or_data
*/
- $('#plugins').on('change', setup_table_structure_or_data);
+ $('#plugins').on('change', Export.setupTableStructureOrData);
}
-export function onload4 () {
- $('input[type=\'radio\'][name=\'quick_or_custom\']').on('change', toggle_quick_or_custom);
+function onloadExportSubmit () {
+ $('input[type=\'radio\'][name=\'quick_or_custom\']').on('change', Export.toggleQuickOrCustom);
$('#scroll_to_options_msg').hide();
$('#format_specific_opts').find('div.format_specific_options')
@@ -270,37 +273,37 @@ export function onload4 () {
})
.find('h3')
.remove();
- toggle_quick_or_custom();
- toggle_structure_data_opts();
- toggle_sql_include_comments();
- check_table_select_all();
- handleAddProcCheckbox();
+ Export.toggleQuickOrCustom();
+ Export.toggleStructureDataOpts();
+ Export.toggleSqlIncludeComments();
+ Export.checkTableSelectAll();
+ Export.handleAddProcCheckbox();
/**
* Initially disables the "Dump some row(s)" sub-options
*/
- disable_dump_some_rows_sub_options();
+ Export.disableDumpSomeRowsSubOptions();
/**
* Disables the "Dump some row(s)" sub-options when it is not selected
*/
$('input[type=\'radio\'][name=\'allrows\']').on('change', function () {
if ($('input[type=\'radio\'][name=\'allrows\']').prop('checked')) {
- enable_dump_some_rows_sub_options();
+ Export.enableDumpSomeRowsSubOptions();
} else {
- disable_dump_some_rows_sub_options();
+ Export.disableDumpSomeRowsSubOptions();
}
});
// Open Alias Modal Dialog on click
- $('#btn_alias_config').on('click', createAliasModal);
+ $('#btn_alias_config').on('click', Export.createAliasModal);
$('.alias_remove').on('click', function () {
$(this).parents('tr').remove();
});
$('#db_alias_select').on('change', function () {
- aliasToggleRow($(this));
+ Export.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 +312,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'
};
@@ -328,10 +331,10 @@ export function onload4 () {
}
});
$('#table_alias_select').on('change', function () {
- aliasToggleRow($(this));
+ Export.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'
@@ -350,13 +353,13 @@ export function onload4 () {
});
});
$('#column_alias_select').on('change', function () {
- aliasToggleRow($(this));
+ Export.aliasToggleRow($(this));
});
$('#db_alias_button').on('click', function (e) {
e.preventDefault();
var db = $('#db_alias_select').val();
- addAlias(
- PMA_messages.strAliasDatabase,
+ Export.addAlias(
+ messages.strAliasDatabase,
db,
'aliases[' + db + '][alias]',
$('#db_alias_name').val()
@@ -367,8 +370,8 @@ export function onload4 () {
e.preventDefault();
var db = $('#db_alias_select').val();
var table = $('#table_alias_select').val();
- addAlias(
- PMA_messages.strAliasTable,
+ Export.addAlias(
+ messages.strAliasTable,
db + '.' + table,
'aliases[' + db + '][tables][' + table + '][alias]',
$('#table_alias_name').val()
@@ -380,8 +383,8 @@ export function onload4 () {
var db = $('#db_alias_select').val();
var table = $('#table_alias_select').val();
var column = $('#column_alias_select').val();
- addAlias(
- PMA_messages.strAliasColumn,
+ Export.addAlias(
+ messages.strAliasColumn,
db + '.' + table + '.' + column,
'aliases[' + db + '][tables][' + table + '][colums][' + column + ']',
$('#column_alias_name').val()
@@ -389,3 +392,14 @@ export function onload4 () {
$('#column_alias_name').val('');
});
}
+
+/**
+ * Module export
+ */
+export {
+ teardownExport,
+ onloadExportOptions,
+ onloadExportSubmit,
+ onloadExportTemplate,
+ onloadSaveToFile
+};
diff --git a/js/src/functions/Server/ServerStatusVariables.js b/js/src/functions/Server/ServerStatusVariables.js
new file mode 100644
index 0000000000..f270602ef4
--- /dev/null
+++ b/js/src/functions/Server/ServerStatusVariables.js
@@ -0,0 +1,63 @@
+/* vim: set expandtab sw=4 ts=4 sts=4: */
+
+/**
+ * Filters the status variables by name/category/alert in the variables tab
+ *
+ * @access public
+ *
+ * @param {Object} textFilter Regular expression for filtering text
+ *
+ * @param {boolean} alertFilter For filtering alert variables
+ *
+ * @param {string} categoryFilter
+ *
+ * @param {string} text Text based filtering
+*/
+function filterVariables (
+ textFilter,
+ alertFilter,
+ categoryFilter,
+ text
+) {
+ var usefulLinks = 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) {
+ usefulLinks++;
+ $(this).css('display', '');
+ } else {
+ $(this).css('display', 'none');
+ }
+ });
+ }
+
+ if (usefulLinks > 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 {
+ filterVariables
+};
diff --git a/js/src/functions/Server/ServerVariables.js b/js/src/functions/Server/ServerVariables.js
new file mode 100644
index 0000000000..77b5442d66
--- /dev/null
+++ b/js/src/functions/Server/ServerVariables.js
@@ -0,0 +1,114 @@
+/* vim: set expandtab sw=4 ts=4 sts=4: */
+
+/**
+ * Module import
+ */
+import { PMA_Messages as messages } from '../../variables/export_variables';
+import {
+ PMA_ajaxShowMessage,
+ PMA_ajaxRemoveMessage
+} from '../../utils/show_ajax_messages';
+
+/**
+ * Allows the user to edit a server variable
+ *
+ * @param {Element} link Edit button element
+ *
+ * @param {Element} $saveLink Save button element
+ *
+ * @param {Element} $cancelLink Cancel button element
+ *
+ * @return {void}
+ */
+function editVariable (link, $saveLink, $cancelLink) {
+ 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(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(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);
+ }
+ });
+}
+
+/**
+ * Module export
+ */
+export {
+ editVariable
+};
diff --git a/js/src/functions/export.js b/js/src/functions/export.js
index 8b25b2590c..1ac461e32d 100644
--- a/js/src/functions/export.js
+++ b/js/src/functions/export.js
@@ -1,3 +1,6 @@
+import { PMA_ajaxShowMessage } from '../utils/show_ajax_messages';
+import { PMA_Messages as messages } from '../variables/export_variables';
+import CommonParams from '../variables/common_params';
/**
* Functions used in the export tab
*
@@ -5,7 +8,7 @@
/**
* Disables the "Dump some row(s)" sub-options
*/
-export function disable_dump_some_rows_sub_options () {
+export function disableDumpSomeRowsSubOptions () {
$('label[for=\'limit_to\']').fadeTo('fast', 0.4);
$('label[for=\'limit_from\']').fadeTo('fast', 0.4);
$('input[type=\'text\'][name=\'limit_to\']').prop('disabled', 'disabled');
@@ -15,7 +18,7 @@ export function disable_dump_some_rows_sub_options () {
/**
* Enables the "Dump some row(s)" sub-options
*/
-export function enable_dump_some_rows_sub_options () {
+export function enableDumpSomeRowsSubOptions () {
$('label[for=\'limit_to\']').fadeTo('fast', 1);
$('label[for=\'limit_from\']').fadeTo('fast', 1);
$('input[type=\'text\'][name=\'limit_to\']').prop('disabled', '');
@@ -71,9 +74,9 @@ export function createTemplate (name) {
var params = {
ajax_request : true,
- server : PMA_commonParams.get('server'),
- db : PMA_commonParams.get('db'),
- table : PMA_commonParams.get('table'),
+ server : CommonParams.get('server'),
+ db : CommonParams.get('db'),
+ table : CommonParams.get('table'),
exportType : $('input[name="export_type"]').val(),
templateAction : 'create',
templateName : name,
@@ -90,7 +93,7 @@ export function createTemplate (name) {
$(this).prop('selected', true);
}
});
- PMA_ajaxShowMessage(PMA_messages.strTemplateCreated);
+ PMA_ajaxShowMessage(messages.strTemplateCreated);
} else {
PMA_ajaxShowMessage(response.error, false);
}
@@ -105,9 +108,9 @@ export function createTemplate (name) {
export function loadTemplate (id) {
var params = {
ajax_request : true,
- server : PMA_commonParams.get('server'),
- db : PMA_commonParams.get('db'),
- table : PMA_commonParams.get('table'),
+ server : CommonParams.get('server'),
+ db : CommonParams.get('db'),
+ table : CommonParams.get('table'),
exportType : $('input[name="export_type"]').val(),
templateAction : 'load',
templateId : id,
@@ -137,7 +140,7 @@ export function loadTemplate (id) {
}
});
$('input[name="template_id"]').val(id);
- PMA_ajaxShowMessage(PMA_messages.strTemplateLoaded);
+ PMA_ajaxShowMessage(messages.strTemplateLoaded);
} else {
PMA_ajaxShowMessage(response.error, false);
}
@@ -154,9 +157,9 @@ export function updateTemplate (id) {
var params = {
ajax_request : true,
- server : PMA_commonParams.get('server'),
- db : PMA_commonParams.get('db'),
- table : PMA_commonParams.get('table'),
+ server : CommonParams.get('server'),
+ db : CommonParams.get('db'),
+ table : CommonParams.get('table'),
exportType : $('input[name="export_type"]').val(),
templateAction : 'update',
templateId : id,
@@ -166,7 +169,7 @@ export function updateTemplate (id) {
PMA_ajaxShowMessage();
$.post('tbl_export.php', params, function (response) {
if (response.success === true) {
- PMA_ajaxShowMessage(PMA_messages.strTemplateUpdated);
+ PMA_ajaxShowMessage(messages.strTemplateUpdated);
} else {
PMA_ajaxShowMessage(response.error, false);
}
@@ -181,9 +184,9 @@ export function updateTemplate (id) {
export function deleteTemplate (id) {
var params = {
ajax_request : true,
- server : PMA_commonParams.get('server'),
- db : PMA_commonParams.get('db'),
- table : PMA_commonParams.get('table'),
+ server : CommonParams.get('server'),
+ db : CommonParams.get('db'),
+ table : CommonParams.get('table'),
exportType : $('input[name="export_type"]').val(),
templateAction : 'delete',
templateId : id,
@@ -193,22 +196,22 @@ export function deleteTemplate (id) {
$.post('tbl_export.php', params, function (response) {
if (response.success === true) {
$('#template').find('option[value="' + id + '"]').remove();
- PMA_ajaxShowMessage(PMA_messages.strTemplateDeleted);
+ PMA_ajaxShowMessage(messages.strTemplateDeleted);
} else {
PMA_ajaxShowMessage(response.error, false);
}
});
}
-export function setup_table_structure_or_data () {
+export function setupTableStructureOrData () {
if ($('input[name=\'export_type\']').val() !== 'database') {
return;
}
var pluginName = $('#plugins').find('option:selected').val();
var formElemName = pluginName + '_structure_or_data';
- var force_structure_or_data = !($('input[name=\'' + formElemName + '_default\']').length);
+ var forceStructureOrData = !($('input[name=\'' + formElemName + '_default\']').length);
- if (force_structure_or_data === true) {
+ if (forceStructureOrData === true) {
$('input[name="structure_or_data_forced"]').val(1);
$('.export_structure input[type="checkbox"], .export_data input[type="checkbox"]')
.prop('disabled', true);
@@ -219,16 +222,16 @@ export function setup_table_structure_or_data () {
.prop('disabled', false);
$('.export_structure, .export_data').fadeTo('fast', 1);
- var structure_or_data = $('input[name="' + formElemName + '_default"]').val();
+ var structureOrData = $('input[name="' + formElemName + '_default"]').val();
- if (structure_or_data === 'structure') {
+ if (structureOrData === 'structure') {
$('.export_data input[type="checkbox"]')
.prop('checked', false);
- } else if (structure_or_data === 'data') {
+ } else if (structureOrData === 'data') {
$('.export_structure input[type="checkbox"]')
.prop('checked', false);
}
- if (structure_or_data === 'structure' || structure_or_data === 'structure_and_data') {
+ if (structureOrData === 'structure' || structureOrData === 'structure_and_data') {
if (!$('.export_structure input[type="checkbox"]:checked').length) {
$('input[name="table_select[]"]:checked')
.closest('tr')
@@ -236,7 +239,7 @@ export function setup_table_structure_or_data () {
.prop('checked', true);
}
}
- if (structure_or_data === 'data' || structure_or_data === 'structure_and_data') {
+ if (structureOrData === 'data' || structureOrData === 'structure_and_data') {
if (!$('.export_data input[type="checkbox"]:checked').length) {
$('input[name="table_select[]"]:checked')
.closest('tr')
@@ -245,9 +248,9 @@ export function setup_table_structure_or_data () {
}
}
- check_selected_tables();
- check_table_select_all();
- check_table_select_struture_or_data();
+ checkSelectedTables();
+ checkTableSelectAll();
+ checkTableSelectStrutureOrData();
}
}
@@ -255,7 +258,7 @@ export function setup_table_structure_or_data () {
* Toggles the hiding and showing of plugin structure-specific and data-specific
* options
*/
-export function toggle_structure_data_opts () {
+export function toggleStructureDataOpts () {
var pluginName = $('select#plugins').val();
var radioFormName = pluginName + '_structure_or_data';
var dataDiv = '#' + pluginName + '_data';
@@ -277,7 +280,7 @@ export function toggle_structure_data_opts () {
/**
* Toggles the disabling of the "save to file" options
*/
-export function toggle_save_to_file () {
+export function toggleSaveToFile () {
var $ulSaveAsfile = $('#ul_save_asfile');
if (!$('#radio_dump_asfile').prop('checked')) {
$ulSaveAsfile.find('> li').fadeTo('fast', 0.4);
@@ -293,7 +296,7 @@ export function toggle_save_to_file () {
/**
* For SQL plugin, toggles the disabling of the "display comments" options
*/
-export function toggle_sql_include_comments () {
+export function toggleSqlIncludeComments () {
$('#checkbox_sql_include_comments').on('change', function () {
var $ulIncludeComments = $('#ul_include_comments');
if (!$('#checkbox_sql_include_comments').prop('checked')) {
@@ -311,116 +314,116 @@ export function toggle_sql_include_comments () {
});
}
-export function check_table_select_all () {
+export function checkTableSelectAll () {
var total = $('input[name="table_select[]"]').length;
- var str_checked = $('input[name="table_structure[]"]:checked').length;
- var data_checked = $('input[name="table_data[]"]:checked').length;
- var str_all = $('#table_structure_all');
- var data_all = $('#table_data_all');
+ var strChecked = $('input[name="table_structure[]"]:checked').length;
+ var dataChecked = $('input[name="table_data[]"]:checked').length;
+ var strAll = $('#table_structure_all');
+ var dataAll = $('#table_data_all');
- if (str_checked === total) {
- str_all
+ if (strChecked === total) {
+ strAll
.prop('indeterminate', false)
.prop('checked', true);
- } else if (str_checked === 0) {
- str_all
+ } else if (strChecked === 0) {
+ strAll
.prop('indeterminate', false)
.prop('checked', false);
} else {
- str_all
+ strAll
.prop('indeterminate', true)
.prop('checked', false);
}
- if (data_checked === total) {
- data_all
+ if (dataChecked === total) {
+ dataAll
.prop('indeterminate', false)
.prop('checked', true);
- } else if (data_checked === 0) {
- data_all
+ } else if (dataChecked === 0) {
+ dataAll
.prop('indeterminate', false)
.prop('checked', false);
} else {
- data_all
+ dataAll
.prop('indeterminate', true)
.prop('checked', false);
}
}
-export function check_table_select_struture_or_data () {
- var str_checked = $('input[name="table_structure[]"]:checked').length;
- var data_checked = $('input[name="table_data[]"]:checked').length;
- var auto_increment = $('#checkbox_sql_auto_increment');
+export function checkTableSelectStrutureOrData () {
+ var strChecked = $('input[name="table_structure[]"]:checked').length;
+ var dataChecked = $('input[name="table_data[]"]:checked').length;
+ var autoIncrement = $('#checkbox_sql_auto_increment');
var pluginName = $('select#plugins').val();
var dataDiv = '#' + pluginName + '_data';
var structureDiv = '#' + pluginName + '_structure';
- if (str_checked === 0) {
+ if (strChecked === 0) {
$(structureDiv).slideUp('slow');
} else {
$(structureDiv).slideDown('slow');
}
- if (data_checked === 0) {
+ if (dataChecked === 0) {
$(dataDiv).slideUp('slow');
- auto_increment.prop('disabled', true).parent().fadeTo('fast', 0.4);
+ autoIncrement.prop('disabled', true).parent().fadeTo('fast', 0.4);
} else {
$(dataDiv).slideDown('slow');
- auto_increment.prop('disabled', false).parent().fadeTo('fast', 1);
+ autoIncrement.prop('disabled', false).parent().fadeTo('fast', 1);
}
}
-export function toggle_table_select_all_str () {
- var str_all = $('#table_structure_all').is(':checked');
- if (str_all) {
+export function toggleTableSelectAllStr () {
+ var strAll = $('#table_structure_all').is(':checked');
+ if (strAll) {
$('input[name="table_structure[]"]').prop('checked', true);
} else {
$('input[name="table_structure[]"]').prop('checked', false);
}
}
-export function toggle_table_select_all_data () {
- var data_all = $('#table_data_all').is(':checked');
- if (data_all) {
+export function toggleTableSelectAllData () {
+ var dataAll = $('#table_data_all').is(':checked');
+ if (dataAll) {
$('input[name="table_data[]"]').prop('checked', true);
} else {
$('input[name="table_data[]"]').prop('checked', false);
}
}
-export function check_selected_tables (argument) {
+export function checkSelectedTables () {
$('.export_table_select tbody tr').each(function () {
- check_table_selected(this);
+ checkTableSelected(this);
});
}
-export function check_table_selected (row) {
+export function checkTableSelected (row) {
var $row = $(row);
- var table_select = $row.find('input[name="table_select[]"]');
- var str_check = $row.find('input[name="table_structure[]"]');
- var data_check = $row.find('input[name="table_data[]"]');
+ var tableSelect = $row.find('input[name="table_select[]"]');
+ var strCheck = $row.find('input[name="table_structure[]"]');
+ var dataCheck = $row.find('input[name="table_data[]"]');
- var data = data_check.is(':checked:not(:disabled)');
- var structure = str_check.is(':checked:not(:disabled)');
+ var data = dataCheck.is(':checked:not(:disabled)');
+ var structure = strCheck.is(':checked:not(:disabled)');
if (data && structure) {
- table_select.prop({ checked: true, indeterminate: false });
+ tableSelect.prop({ checked: true, indeterminate: false });
$row.addClass('marked');
} else if (data || structure) {
- table_select.prop({ checked: true, indeterminate: true });
+ tableSelect.prop({ checked: true, indeterminate: true });
$row.removeClass('marked');
} else {
- table_select.prop({ checked: false, indeterminate: false });
+ tableSelect.prop({ checked: false, indeterminate: false });
$row.removeClass('marked');
}
}
-export function toggle_table_select (row) {
+export function toggleTableSelect (row) {
var $row = $(row);
- var table_selected = $row.find('input[name="table_select[]"]').is(':checked');
+ var tableSelected = $row.find('input[name="table_select[]"]').is(':checked');
- if (table_selected) {
+ if (tableSelected) {
$row.find('input[type="checkbox"]:not(:disabled)').prop('checked', true);
$row.addClass('marked');
} else {
@@ -442,7 +445,7 @@ export function handleAddProcCheckbox () {
/**
* Toggles display of options when quick and custom export are selected
*/
-export function toggle_quick_or_custom () {
+export function toggleQuickOrCustom () {
if ($('input[name=\'quick_or_custom\']').length === 0 // custom_no_form option
|| $('#radio_custom_export').prop('checked') // custom
) {
@@ -451,8 +454,8 @@ export function toggle_quick_or_custom () {
$('#output').show();
$('#format_specific_opts').show();
$('#output_quick_export').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();
} else { // quick
$('#databases_and_tables').hide();
$('#rows').hide();
@@ -462,12 +465,12 @@ export function toggle_quick_or_custom () {
}
}
var time_out;
-export function check_time_out (time_limit) {
- if (typeof time_limit === 'undefined' || time_limit === 0) {
+export function check_time_out (timeLimit) {
+ if (typeof timeLimit === 'undefined' || timeLimit === 0) {
return true;
}
// margin of one second to avoid race condition to set/access session variable
- time_limit = time_limit + 1;
+ timeLimit = timeLimit + 1;
var href = 'export.php';
var params = {
'ajax_request' : true,
@@ -479,13 +482,13 @@ export function check_time_out (time_limit) {
if (data.message === 'timeout') {
PMA_ajaxShowMessage(
'' +
- PMA_messages.strTimeOutError +
+ messages.strTimeOutError +
'
',
false
);
}
});
- }, time_limit * 1000);
+ }, timeLimit * 1000);
}
/**
@@ -534,7 +537,7 @@ export function aliasSelectHandler (event) {
export function createAliasModal (event) {
event.preventDefault();
var dlgButtons = {};
- dlgButtons[PMA_messages.strSaveAndClose] = function () {
+ dlgButtons[messages.strSaveAndClose] = function () {
$(this).dialog('close');
$('#alias_modal').parent().appendTo($('form[name="dump"]'));
};
@@ -546,7 +549,7 @@ export function createAliasModal (event) {
buttons: dlgButtons,
create: function () {
$(this).css('maxHeight', $(window).height() - 150);
- var db = PMA_commonParams.get('db');
+ var db = CommonParams.get('db');
if (db) {
var option = $('');
option.text(db);
@@ -555,7 +558,7 @@ export function createAliasModal (event) {
} else {
var params = {
ajax_request : true,
- server : PMA_commonParams.get('server'),
+ server : CommonParams.get('server'),
type: 'list-databases'
};
$.post('ajax.php', params, function (response) {
diff --git a/js/src/functions/get_image.js b/js/src/functions/get_image.js
index 167197e84a..af11628837 100644
--- a/js/src/functions/get_image.js
+++ b/js/src/functions/get_image.js
@@ -1,20 +1,30 @@
+/* vim: set expandtab sw=4 ts=4 sts=4: */
+
+/**
+ * Module import
+ */
import { escapeHtml } from '../utils/Sanitise';
+
/**
* Returns an HTML IMG tag for a particular image from a theme,
* which may be an actual file or an icon from a sprite
*
- * @param string image The name of the file to get
- * @param string alternate Used to set 'alt' and 'title' attributes of the image
- * @param object attributes An associative array of other attributes
+ * @access public
*
- * @return Object The requested image, this object has two methods:
+ * @param {string} image The name of the file to get
+ *
+ * @param {string} alternate Used to set 'alt' and 'title' attributes of the image
+ *
+ * @param {object} attributes An associative array of other attributes
+ *
+ * @return {Object} The requested image, this object has two methods:
* .toString() - Returns the IMG tag for the requested image
* .attr(name) - Returns a particular attribute of the IMG
* tag given it's name
* .attr(name, value) - Sets a particular attribute of the IMG
* tag to the given value
*/
-export function PMA_getImage (image, alternate, attributes) {
+function PMA_getImage (image, alternate, attributes) {
// custom image object, it will eventually be returned by this functions
var retval = {
data: {
@@ -76,3 +86,10 @@ export function PMA_getImage (image, alternate, attributes) {
return retval;
}
+
+/**
+ * Module export
+ */
+export {
+ PMA_getImage
+};
diff --git a/js/src/functions/import.js b/js/src/functions/import.js
index 71e4dab109..2828733c75 100644
--- a/js/src/functions/import.js
+++ b/js/src/functions/import.js
@@ -1,20 +1,30 @@
+/* vim: set expandtab sw=4 ts=4 sts=4: */
+
+/**
+ * Module import
+ */
+import { PMA_Messages as messages } from '../variables/export_variables';
+
/**
* Functions used in the import tab
- *
*/
/**
* Toggles the hiding and showing of each plugin's options
* according to the currently selected plugin from the dropdown list
+ *
+ * @access public
+ *
+ * @return {void}
*/
-export function changePluginOpts () {
+function changePluginOpts () {
$('#format_specific_opts').find('div.format_specific_options').each(function () {
$(this).hide();
});
- var selected_plugin_name = $('#plugins').find('option:selected').val();
- $('#' + selected_plugin_name + '_options').fadeIn('slow');
- if (selected_plugin_name === 'csv') {
- $('#import_notification').text(PMA_messages.strImportCSV);
+ var selectedPluginName = $('#plugins').find('option:selected').val();
+ $('#' + selectedPluginName + '_options').fadeIn('slow');
+ if (selectedPluginName === 'csv') {
+ $('#import_notification').text(messages.strImportCSV);
} else {
$('#import_notification').text('');
}
@@ -23,19 +33,33 @@ export function changePluginOpts () {
/**
* 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
+ *
+ * @access public
+ *
+ * @param {string} fname Name of the file
+ *
+ * @return {void}
*/
-export function matchFile (fname) {
- var fname_array = fname.toLowerCase().split('.');
- var len = fname_array.length;
+function matchFile (fname) {
+ var fnameArray = fname.toLowerCase().split('.');
+ var len = fnameArray.length;
if (len !== 0) {
- var extension = fname_array[len - 1];
+ var extension = fnameArray[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').filterByValue(fname_array[len - 1]).length === 1) {
- $('select[name=\'format\'] option').filterByValue(fname_array[len - 1]).prop('selected', true);
+ if ($('select[name=\'format\'] option').filterByValue(fnameArray[len - 1]).length === 1) {
+ $('select[name=\'format\'] option').filterByValue(fnameArray[len - 1]).prop('selected', true);
changePluginOpts();
}
}
}
+
+/**
+ * Module export
+ */
+export {
+ changePluginOpts,
+ matchFile
+};
diff --git a/js/src/functions/navigation.js b/js/src/functions/navigation.js
index 59d43e6d25..9b62c799ef 100644
--- a/js/src/functions/navigation.js
+++ b/js/src/functions/navigation.js
@@ -3,9 +3,12 @@
*
* @returns void
*/
-import { PMA_commonParams } from '../variables/common_params';
+import CommonParams from '../variables/common_params';
import { setupRestoreField, setupConfigTabs, setupValidation } from './config';
-
+import { PMA_ajaxShowMessage, PMA_ajaxRemoveMessage } from '../utils/show_ajax_messages';
+import { PMA_Messages as PMA_messages } from '../variables/export_variables';
+import { isStorageSupported } from './config';
+import { configSet, configGet } from '../utils/config';
/**
* Traverse the navigation tree backwards to generate all the actual
* and virtual paths, as well as the positions in the pagination at
@@ -69,8 +72,8 @@ export function navTreeStateUpdate () {
// content to be stored exceeds storage capacity
try {
storage.setItem('navTreePaths', JSON.stringify(traverseNavigationForPaths()));
- storage.setItem('server', PMA_commonParams.get('server'));
- storage.setItem('token', PMA_commonParams.get('token'));
+ storage.setItem('server', CommonParams.get('server'));
+ storage.setItem('token', CommonParams.get('token'));
} catch (error) {
// storage capacity exceeded & old navigation tree
// state is no more valid, so remove it
@@ -88,18 +91,17 @@ export function PMA_selectCurrentDb () {
return false;
}
- if (PMA_commonParams.get('db')) { // db selected
+ if (CommonParams.get('db')) { // db selected
$naviDbSelect.show();
}
- $naviDbSelect.val(PMA_commonParams.get('db'));
- return $naviDbSelect.val() === PMA_commonParams.get('db');
+ $naviDbSelect.val(CommonParams.get('db'));
+ return $naviDbSelect.val() === CommonParams.get('db');
}
export function PMA_showCurrentNavigation () {
- var db = PMA_commonParams.get('db');
- var table = PMA_commonParams.get('table');
-
+ var db = CommonParams.get('db');
+ var table = CommonParams.get('table');
$('#pma_navigation_tree').find('li.selected').removeClass('selected');
if (db) {
var $dbItem = findLoadedItem($('#pma_navigation_tree').find('> div'), db, 'database', !table);
@@ -109,7 +111,7 @@ export function PMA_showCurrentNavigation () {
}
// If loaded database in navigation is not same as current one
if ($('#pma_navigation_tree_content').find('span.loaded_db:first').text() !== $('#navi_db_select').val()) {
- loadChildNodes(false, $('option:selected', $('#navi_db_select')), function (data) {
+ loadChildNodes(false, $('option:selected', $('#navi_db_select')), function () {
handleTableOrDb(table, $('#pma_navigation_tree_content'));
var $children = $('#pma_navigation_tree_content').children('div.list_container');
$children.promise().done(navTreeStateUpdate);
@@ -325,7 +327,7 @@ export function loadChildNodes (isNode, $expandElem, callback) {
if (window.location.href.indexOf('?') === -1) {
window.location.href += '?session_expired=1';
} else {
- window.location.href += PMA_commonParams.get('arg_separator') + 'session_expired=1';
+ window.location.href += CommonParams.get('arg_separator') + 'session_expired=1';
}
window.location.reload();
} else {
@@ -416,7 +418,7 @@ export function PMA_ensureNaviSettings (selflink) {
if (!$('#pma_navigation_settings').length) {
var params = {
getNaviSettings: true,
- server: PMA_commonParams.get('server'),
+ server: CommonParams.get('server'),
};
var url = $('#pma_navigation').find('a.navigation_url').attr('href');
$.post(url, params, function (data) {
@@ -691,7 +693,7 @@ export var PMA_fastFilter = {
* at the top of this file
*/
events: {
- focus: function (event) {
+ focus: function () {
var $obj = $(this).closest('div.list_container');
if (! $obj.data('fastFilter')) {
$obj.data(
@@ -705,7 +707,7 @@ export var PMA_fastFilter = {
$(this).select();
}
},
- blur: function (event) {
+ blur: function () {
if ($(this).val() === '') {
$(this).val(this.defaultValue);
}
@@ -853,7 +855,7 @@ PMA_fastFilter.filter.prototype.request = function () {
if (self.$this.find('> ul > li > form.fast_filter:first input[name=searchClause]').length === 0) {
var $input = $('#pma_navigation_tree').find('li.fast_filter.db_fast_filter input.searchClause');
if ($input.length && $input.val() !== $input[0].defaultValue) {
- params += PMA_commonParams.get('arg_separator') + 'searchClause=' + encodeURIComponent($input.val());
+ params += CommonParams.get('arg_separator') + 'searchClause=' + encodeURIComponent($input.val());
}
}
self.xhr = $.ajax({
@@ -1085,7 +1087,7 @@ export var ResizeHandler = function () {
*
* @return void
*/
- this.treeResize = function (event) {
+ this.treeResize = function () {
var $nav = $('#pma_navigation');
var $nav_tree = $('#pma_navigation_tree');
var $nav_header = $('#pma_navigation_header');
@@ -1136,12 +1138,12 @@ export function PMA_reloadNavigation (callback, paths) {
var params = {
reload: true,
no_debug: true,
- server: PMA_commonParams.get('server'),
+ server: CommonParams.get('server'),
};
paths = paths || traverseNavigationForPaths();
$.extend(params, paths);
if ($('#navi_db_select').length) {
- params.db = PMA_commonParams.get('db');
+ params.db = CommonParams.get('db');
requestNaviReload(params);
return;
}
@@ -1188,18 +1190,18 @@ export function PMA_navigationTreePagination ($this) {
params = 'ajax_request=true';
} else { // tagName === 'SELECT'
url = 'navigation.php';
- params = $this.closest('form').serialize() + PMA_commonParams.get('arg_separator') + 'ajax_request=true';
+ params = $this.closest('form').serialize() + CommonParams.get('arg_separator') + 'ajax_request=true';
}
var searchClause = PMA_fastFilter.getSearchClause();
if (searchClause) {
- params += PMA_commonParams.get('arg_separator') + 'searchClause=' + encodeURIComponent(searchClause);
+ params += CommonParams.get('arg_separator') + 'searchClause=' + encodeURIComponent(searchClause);
}
if (isDbSelector) {
- params += PMA_commonParams.get('arg_separator') + 'full=true';
+ params += CommonParams.get('arg_separator') + 'full=true';
} else {
var searchClause2 = PMA_fastFilter.getSearchClause2($this);
if (searchClause2) {
- params += PMA_commonParams.get('arg_separator') + 'searchClause2=' + encodeURIComponent(searchClause2);
+ params += CommonParams.get('arg_separator') + 'searchClause2=' + encodeURIComponent(searchClause2);
}
}
$.post(url, params, function (data) {
diff --git a/js/src/functions/page_settings.js b/js/src/functions/page_settings.js
new file mode 100644
index 0000000000..ff996aac4a
--- /dev/null
+++ b/js/src/functions/page_settings.js
@@ -0,0 +1,67 @@
+/* vim: set expandtab sw=4 ts=4 sts=4: */
+
+/**
+ * Module import
+ */
+import { PMA_Messages as messages } from '../variables/export_variables';
+
+/**
+ * @param {Element} selector jQuery element for which setting need to be show
+ *
+ * @access private
+ *
+ * @returns {void}
+ */
+function showSettings (selector) {
+ var buttons = {};
+ buttons[messages.strApply] = function () {
+ $('.config-form').submit();
+ };
+
+ buttons[messages.strCancel] = function () {
+ $(this).dialog('close');
+ };
+
+ // Keeping a clone to restore in case the user cancels the operation
+ var $clone = $(selector + ' .page_settings').clone(true);
+ $(selector)
+ .dialog({
+ title: messages.strPageSettings,
+ width: 700,
+ minHeight: 250,
+ modal: true,
+ open: function () {
+ $(this).dialog('option', 'maxHeight', $(window).height() - $(this).offset().top);
+ },
+ close: function () {
+ $(selector + ' .page_settings').replaceWith($clone);
+ },
+ buttons: buttons
+ });
+}
+
+/**
+ * @access public
+ *
+ * @return {void}
+ */
+function showPageSettings () {
+ showSettings('#page_settings_modal');
+}
+
+/**
+ * @access public
+ *
+ * @return {void}
+ */
+function showNaviSettings () {
+ showSettings('#pma_navigation_settings');
+}
+
+/**
+ * Module export
+ */
+export {
+ showNaviSettings,
+ showPageSettings
+};
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/index.js b/js/src/index.js
index 3ba2e8f153..b6ddf95105 100644
--- a/js/src/index.js
+++ b/js/src/index.js
@@ -1,9 +1,22 @@
-import { AJAX } from './ajax';
+/* vim: set expandtab sw=4 ts=4 sts=4: */
+
+/**
+ * Module import
+ */
import './variables/import_variables';
-import './variables/get_config';
import { jQuery as $ } from './utils/JqueryExtended';
+import { AJAX } from './ajax';
+import './variables/get_config';
import files from './consts/files';
import Console from './console';
+import { PMA_sprintf } from './utils/sprintf';
+import { PMA_Messages as PMA_messages } from './variables/export_variables';
+import { escapeHtml } from './utils/Sanitise';
+import { PMA_ajaxShowMessage } from './utils/show_ajax_messages';
+import PMA_commonParams from './variables/common_params';
+
+// console.log(PMA_messages);
+// console.log(PMA_ajaxShowMessage);
/**
* Page load event handler
@@ -69,6 +82,34 @@ $(function () {
}
});
+$(document).ajaxError(function (event, request, settings) {
+ if (AJAX._debug) {
+ console.log('AJAX error: status=' + request.status + ', text=' + request.statusText);
+ }
+ // Don't handle aborted requests
+ if (request.status !== 0 || request.statusText !== 'abort') {
+ var details = '';
+ var state = request.state();
+
+ if (request.status !== 0) {
+ details += '' + escapeHtml(PMA_sprintf(PMA_messages.strErrorCode, request.status)) + '
';
+ }
+ details += '' + escapeHtml(PMA_sprintf(PMA_messages.strErrorText, request.statusText + ' (' + state + ')')) + '
';
+ if (state === 'rejected' || state === 'timeout') {
+ details += '' + escapeHtml(PMA_messages.strErrorConnection) + '
';
+ }
+ PMA_ajaxShowMessage(
+ '' +
+ PMA_messages.strErrorProcessingRequest +
+ details +
+ '
',
+ false
+ );
+ AJAX.active = false;
+ AJAX.xhr = null;
+ }
+});
+
/**
* Adding common files for every page
*/
@@ -92,6 +133,10 @@ if (typeof files[firstPage] !== 'undefined' && firstPage.toLocaleLowerCase() !==
for (let i in files[indexPage]) {
AJAX.scriptHandler.add(files[indexPage][i], 1);
}
+} else if (typeof files[indexPage] !== 'undefined' && firstPage.toLocaleLowerCase() === 'index') {
+ for (let i in files[indexPage]) {
+ AJAX.scriptHandler.add(files[indexPage][i]);
+ }
}
$(function () {
diff --git a/js/src/navigation.js b/js/src/navigation.js
index 0095b51108..af942dc215 100644
--- a/js/src/navigation.js
+++ b/js/src/navigation.js
@@ -1,15 +1,7 @@
/* vim: set expandtab sw=4 ts=4 sts=4: */
-import { expandTreeNode,
- navTreeStateUpdate,
- PMA_showCurrentNavigation,
- navFilterStateRestore,
- collapseTreeNode,
- PMA_fastFilter,
- ResizeHandler,
- PMA_reloadNavigation,
- PMA_navigationTreePagination } from './functions/navigation';
+import * as Navigation from './functions/navigation';
import { PMA_Messages as PMA_messages } from './variables/export_variables';
-import { PMA_commonParams } from './variables/common_params';
+import CommonParams from './variables/common_params';
import { PMA_ajaxShowMessage, PMA_ajaxRemoveMessage, PMA_tooltip } from './utils/show_ajax_messages';
import { isStorageSupported } from './functions/config';
@@ -34,7 +26,7 @@ $(function () {
});
// Fire up the resize handlers
- new ResizeHandler();
+ new Navigation.ResizeHandler();
/**
* opens/closes (hides/shows) tree elements
@@ -45,9 +37,9 @@ $(function () {
event.stopImmediatePropagation();
var $icon = $(this).find('img');
if ($icon.is('.ic_b_plus')) {
- expandTreeNode($(this));
+ Navigation.expandTreeNode($(this));
} else {
- collapseTreeNode($(this));
+ Navigation.collapseTreeNode($(this));
}
});
@@ -65,7 +57,7 @@ $(function () {
var icon_reload_src = $icon.attr('src');
// replace the source of the reload icon with the one for throbber
$icon.attr('src', icon_throbber_src);
- PMA_reloadNavigation();
+ Navigation.PMA_reloadNavigation();
// after one second, put back the reload icon
setTimeout(function () {
$icon.attr('src', icon_reload_src);
@@ -74,8 +66,8 @@ $(function () {
$(document).on('change', '#navi_db_select', function () {
if (! $(this).val()) {
- PMA_commonParams.set('db', '');
- PMA_reloadNavigation();
+ CommonParams.set('db', '');
+ Navigation.PMA_reloadNavigation();
}
$(this).closest('form').trigger('submit');
});
@@ -149,24 +141,24 @@ $(function () {
.attr('alt', PMA_messages.unlinkWithMain)
.attr('title', PMA_messages.unlinkWithMain);
$('#pma_navigation_tree').addClass('synced');
- PMA_showCurrentNavigation();
+ Navigation.PMA_showCurrentNavigation();
}
});
/**
* Bind all "fast filter" events
*/
- $(document).on('click', '#pma_navigation_tree li.fast_filter span', PMA_fastFilter.events.clear);
- $(document).on('focus', '#pma_navigation_tree li.fast_filter input.searchClause', PMA_fastFilter.events.focus);
- $(document).on('blur', '#pma_navigation_tree li.fast_filter input.searchClause', PMA_fastFilter.events.blur);
- $(document).on('keyup', '#pma_navigation_tree li.fast_filter input.searchClause', PMA_fastFilter.events.keyup);
+ $(document).on('click', '#pma_navigation_tree li.fast_filter span', Navigation.PMA_fastFilter.events.clear);
+ $(document).on('focus', '#pma_navigation_tree li.fast_filter input.searchClause', Navigation.PMA_fastFilter.events.focus);
+ $(document).on('blur', '#pma_navigation_tree li.fast_filter input.searchClause', Navigation.PMA_fastFilter.events.blur);
+ $(document).on('keyup', '#pma_navigation_tree li.fast_filter input.searchClause', Navigation.PMA_fastFilter.events.keyup);
/**
* Ajax handler for pagination
*/
$(document).on('click', '#pma_navigation_tree div.pageselector a.ajax', function (event) {
event.preventDefault();
- PMA_navigationTreePagination($(this));
+ Navigation.PMA_navigationTreePagination($(this));
});
/**
@@ -243,7 +235,7 @@ $(function () {
event.preventDefault();
var url = $(this).attr('href').substr(
$(this).attr('href').indexOf('?') + 1
- ) + PMA_commonParams.get('arg_separator') + 'ajax_request=true';
+ ) + CommonParams.get('arg_separator') + 'ajax_request=true';
var title = PMA_messages.strAddIndex;
indexEditorDialog(url, title);
});
@@ -253,7 +245,7 @@ $(function () {
event.preventDefault();
var url = $(this).attr('href').substr(
$(this).attr('href').indexOf('?') + 1
- ) + PMA_commonParams.get('arg_separator') + 'ajax_request=true';
+ ) + CommonParams.get('arg_separator') + 'ajax_request=true';
var title = PMA_messages.strEditIndex;
indexEditorDialog(url, title);
});
@@ -270,12 +262,12 @@ $(function () {
$.ajax({
type: 'POST',
data: {
- server: PMA_commonParams.get('server'),
+ server: CommonParams.get('server'),
},
- url: $(this).attr('href') + PMA_commonParams.get('arg_separator') + 'ajax_request=true',
+ url: $(this).attr('href') + CommonParams.get('arg_separator') + 'ajax_request=true',
success: function (data) {
if (typeof data !== 'undefined' && data.success === true) {
- PMA_reloadNavigation();
+ Navigation.PMA_reloadNavigation();
} else {
PMA_ajaxShowMessage(data.error);
}
@@ -287,7 +279,7 @@ $(function () {
$(document).on('click', 'a.showUnhide.ajax', function (event) {
event.preventDefault();
var $msg = PMA_ajaxShowMessage();
- $.get($(this).attr('href') + PMA_commonParams.get('arg_separator') + 'ajax_request=1', function (data) {
+ $.get($(this).attr('href') + CommonParams.get('arg_separator') + 'ajax_request=1', function (data) {
if (typeof data !== 'undefined' && data.success === true) {
PMA_ajaxRemoveMessage($msg);
var buttonOptions = {};
@@ -321,14 +313,14 @@ $(function () {
$.ajax({
type: 'POST',
data: {
- server: PMA_commonParams.get('server'),
+ server: CommonParams.get('server'),
},
- url: $(this).attr('href') + PMA_commonParams.get('arg_separator') + 'ajax_request=true',
+ url: $(this).attr('href') + CommonParams.get('arg_separator') + 'ajax_request=true',
success: function (data) {
PMA_ajaxRemoveMessage($msg);
if (typeof data !== 'undefined' && data.success === true) {
$tr.remove();
- PMA_reloadNavigation();
+ Navigation.PMA_reloadNavigation();
} else {
PMA_ajaxShowMessage(data.error);
}
@@ -356,7 +348,7 @@ $(function () {
favorite_tables: (isStorageSupported('localStorage') && typeof window.localStorage.favorite_tables !== 'undefined')
? window.localStorage.favorite_tables
: '',
- server: PMA_commonParams.get('server'),
+ server: CommonParams.get('server'),
},
success: function (data) {
if (data.changes) {
@@ -388,15 +380,15 @@ $(function () {
if ($('#pma_navigation_tree_content').length &&
typeof storage.navTreePaths === 'undefined'
) {
- PMA_reloadNavigation();
- } else if (PMA_commonParams.get('server') === storage.server &&
- PMA_commonParams.get('token') === storage.token
+ Navigation.PMA_reloadNavigation();
+ } else if (CommonParams.get('server').toString() === storage.server.toString() &&
+ CommonParams.get('token').toString() === storage.token.toString()
) {
// Reload the tree to the state before page refresh
- PMA_reloadNavigation(navFilterStateRestore, JSON.parse(storage.navTreePaths));
+ Navigation.PMA_reloadNavigation(Navigation.navFilterStateRestore, JSON.parse(storage.navTreePaths));
} else {
// If the user is different
- navTreeStateUpdate();
+ Navigation.navTreeStateUpdate();
}
}
});
diff --git a/js/src/page_settings.js b/js/src/page_settings.js
new file mode 100644
index 0000000000..627425d05c
--- /dev/null
+++ b/js/src/page_settings.js
@@ -0,0 +1,49 @@
+/* vim: set expandtab sw=4 ts=4 sts=4: */
+
+/**
+ * @fileoverview function used for page-related settings
+ * @name Page-related settings
+ *
+ * @requires jQuery
+ * @requires jQueryUI
+ * @requires js/functions.js
+ */
+
+/**
+ * Module import
+ */
+import {
+ showNaviSettings,
+ showPageSettings
+} from './functions/page_settings';
+
+/**
+ * @package PhpMyAdmin
+ *
+ * Page Settings
+ */
+
+/**
+ * Unbind all event handlers before tearing down a page.
+ */
+function teardownPageSettings () {
+ $('#page_settings_icon').css('display', 'none');
+ $('#page_settings_icon').off('click');
+ $('#pma_navigation_settings_icon').off('click');
+}
+
+/**
+ * Binding event handler on page load.
+ */
+function onloadPageSettings () {
+ if ($('#page_settings_modal').length) {
+ $('#page_settings_icon').css('display', 'inline');
+ $('#page_settings_icon').on('click', showPageSettings);
+ }
+ $('#pma_navigation_settings_icon').on('click', showNaviSettings);
+}
+
+export {
+ teardownPageSettings,
+ onloadPageSettings
+};
diff --git a/js/src/server_databases.js b/js/src/server_databases.js
index af5c2c350f..f29e9f67aa 100644
--- a/js/src/server_databases.js
+++ b/js/src/server_databases.js
@@ -7,6 +7,10 @@
* @requires jQueryUI
* @required js/functions.js
*/
+
+/**
+ * Moduele import
+ */
import { PMA_sprintf } from './utils/sprintf';
import './variables/import_variables';
import { PMA_ajaxShowMessage } from './utils/show_ajax_messages';
@@ -14,17 +18,26 @@ import { escapeHtml } from './utils/Sanitise';
import { PMA_Messages as PMA_messages } from './variables/export_variables';
import { jQuery as $ } from './utils/JqueryExtended';
import { AJAX } from './ajax';
-import { PMA_commonParams } from './variables/common_params';
+import CommonParams from './variables/common_params';
+
+/**
+ * @package PhpMyAdmin
+ *
+ * Server Databases
+ */
/**
* Unbind all event handlers before tearing down a page
*/
-export function teardown1 () {
+function teardownServerDatabases () {
$(document).off('submit', '#dbStatsForm');
$(document).off('submit', '#create_database_form.ajax');
}
-export function onload1 () {
+/**
+ * Binding event handlers on page load
+ */
+function onloadServerDatabases () {
/**
* Attach Event Handler for 'Drop Databases'
*/
@@ -46,7 +59,7 @@ export function onload1 () {
if (! selected_dbs.length) {
PMA_ajaxShowMessage(
$('').text(
- PMA_messages.strNoDatabasesSelected
+ messages.strNoDatabasesSelected
),
2000
);
@@ -55,16 +68,16 @@ export function onload1 () {
/**
* @var question String containing the question to be asked for confirmation
*/
- var question = PMA_messages.strDropDatabaseStrongWarning + ' ' +
- PMA_sprintf(PMA_messages.strDoYouReally, selected_dbs.join('
'));
+ var question = messages.strDropDatabaseStrongWarning + ' ' +
+ PMA_sprintf(messages.strDoYouReally, selected_dbs.join('
'));
- var argsep = PMA_commonParams.get('arg_separator');
+ var argsep = CommonParams.get('arg_separator');
$(this).PMA_confirm(
question,
$form.prop('action') + '?' + $(this).serialize() +
argsep + 'drop_selected_dbs=1' + argsep + 'is_js_confirmed=1' + argsep + 'ajax_request=true',
function (url) {
- PMA_ajaxShowMessage(PMA_messages.strProcessingRequest, false);
+ PMA_ajaxShowMessage(messages.strProcessingRequest, false);
var params = getJSConfirmCommonParam(this);
@@ -105,12 +118,12 @@ export function onload1 () {
var newDbNameInput = $form.find('input[name=new_db]');
if (newDbNameInput.val() === '') {
newDbNameInput.focus();
- alert(PMA_messages.strFormEmpty);
+ alert(messages.strFormEmpty);
return;
}
// end remove
- PMA_ajaxShowMessage(PMA_messages.strProcessingRequest);
+ PMA_ajaxShowMessage(messages.strProcessingRequest);
PMA_prepareForAjaxRequest($form);
$.post($form.attr('action'), $form.serialize(), function (data) {
@@ -125,7 +138,7 @@ export function onload1 () {
// make ajax request to load db structure page - taken from ajax.js
var dbStruct_url = data.url_query;
dbStruct_url = dbStruct_url.replace(/amp;/ig, '');
- var params = 'ajax_request=true' + PMA_commonParams.get('arg_separator') + 'ajax_page_request=true';
+ var params = 'ajax_request=true' + CommonParams.get('arg_separator') + 'ajax_page_request=true';
if (! (history && history.pushState)) {
params += PMA_MicroHistory.menus.getRequestParam();
}
@@ -143,9 +156,14 @@ export function onload1 () {
}
var tableRows = $('.server_databases');
- $.each(tableRows, function (index, item) {
+ $.each(tableRows, function (index) {
$(this).click(function () {
PMA_commonActions.setDb($(this).attr('data'));
});
});
}
+
+export {
+ teardownServerDatabases,
+ onloadServerDatabases
+};
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_privileges.js b/js/src/server_privileges.js
index eca080c5c0..e1fe4a6728 100644
--- a/js/src/server_privileges.js
+++ b/js/src/server_privileges.js
@@ -6,17 +6,25 @@
* @requires jQuery
* @requires jQueryUI
* @requires js/functions.js
- *
+ */
+
+/**
+ * Module import
*/
import { PMA_sprintf } from './utils/sprintf';
import { checkPasswordStrength, displayPasswordGenerateButton } from './utils/password';
-// import { AJAX } from './ajax';
-import { PMA_Messages as PMA_messages } from './variables/export_variables';
+import { PMA_Messages as messages } from './variables/export_variables';
import { PMA_ajaxShowMessage, PMA_ajaxRemoveMessage } from './utils/show_ajax_messages';
-import { PMA_commonParams } from './variables/common_params';
+import CommonParams from './variables/common_params';
import { jQuery as $ } from './utils/JqueryExtended';
import { PMA_getSQLEditor } from './utils/sql';
+/**
+ * @package PhpMyAdmin
+ *
+ * Server Privileges
+ */
+
/**
* AJAX scripts for server_privileges page.
*
@@ -33,9 +41,9 @@ import { PMA_getSQLEditor } from './utils/sql';
*/
/**
- * Unbind all event handlers before tearing down a page
+ * Unbind all event handlers before tearing down a page.
*/
-export function teardown1 () {
+function teardownServerPrivileges () {
$('#fieldset_add_user_login').off('change', 'input[name=\'username\']');
$(document).off('click', '#fieldset_delete_user_footer #buttonGo.ajax');
$(document).off('click', 'a.edit_user_group_anchor.ajax');
@@ -49,7 +57,10 @@ export function teardown1 () {
$(document).off('change', '#select_authentication_plugin');
}
-export function onload1 () {
+/**
+ * Binding event handlers on page load.
+ */
+function onloadServerPrivileges () {
/**
* Display a warning if there is already a user by the name entered as the username.
*/
@@ -60,7 +71,7 @@ export function onload1 () {
var href = $('form[name=\'usersForm\']').attr('action');
var params = {
'ajax_request' : true,
- 'server' : PMA_commonParams.get('server'),
+ 'server' : CommonParams.get('server'),
'validate_username' : true,
'username' : username
};
@@ -79,29 +90,29 @@ export function onload1 () {
/**
* Indicating password strength
*/
- var meter_obj;
- var meter_obj_label;
+ var meterObj;
+ var meterObjLabel;
var username;
$(document).on('keyup', '#text_pma_pw', function () {
- meter_obj = $('#password_strength_meter');
- meter_obj_label = $('#password_strength');
+ meterObj = $('#password_strength_meter');
+ meterObjLabel = $('#password_strength');
username = $('input[name="username"]');
username = username.val();
- checkPasswordStrength($(this).val(), meter_obj, meter_obj_label, username);
+ checkPasswordStrength($(this).val(), meterObj, meterObjLabel, username);
});
$(document).on('keyup', '#text_pma_change_pw', function () {
- meter_obj = $('#change_password_strength_meter');
- meter_obj_label = $('#change_password_strength');
- checkPasswordStrength($(this).val(), meter_obj, meter_obj_label, PMA_commonParams.get('user'));
+ meterObj = $('#change_password_strength_meter');
+ meterObjLabel = $('#change_password_strength');
+ checkPasswordStrength($(this).val(), meterObj, meterObjLabel, CommonParams.get('user'));
});
/**
* Display a notice if sha256_password is selected
*/
$(document).on('change', '#select_authentication_plugin', function () {
- var selected_plugin = $(this).val();
- if (selected_plugin === 'sha256_password') {
+ var selectedPlugin = $(this).val();
+ if (selectedPlugin === 'sha256_password') {
$('#ssl_reqd_warning').show();
} else {
$('#ssl_reqd_warning').hide();
@@ -121,19 +132,19 @@ export function onload1 () {
var $thisButton = $(this);
var $form = $('#usersForm');
- $thisButton.PMA_confirm(PMA_messages.strDropUserWarning, $form.attr('action'), function (url) {
- var $drop_users_db_checkbox = $('#checkbox_drop_users_db');
- if ($drop_users_db_checkbox.is(':checked')) {
- var is_confirmed = confirm(PMA_messages.strDropDatabaseStrongWarning + '\n' + PMA_sprintf(PMA_messages.strDoYouReally, 'DROP DATABASE'));
- if (! is_confirmed) {
+ $thisButton.PMA_confirm(messages.strDropUserWarning, $form.attr('action'), function (url) {
+ var $dropUsersDbCheckbox = $('#checkbox_drop_users_db');
+ if ($dropUsersDbCheckbox.is(':checked')) {
+ var isConfirmed = confirm(messages.strDropDatabaseStrongWarning + '\n' + PMA_sprintf(messages.strDoYouReally, 'DROP DATABASE'));
+ if (! isConfirmed) {
// Uncheck the drop users database checkbox
- $drop_users_db_checkbox.prop('checked', false);
+ $dropUsersDbCheckbox.prop('checked', false);
}
}
- PMA_ajaxShowMessage(PMA_messages.strRemovingSelectedUsers);
+ PMA_ajaxShowMessage(messages.strRemovingSelectedUsers);
- var argsep = PMA_commonParams.get('arg_separator');
+ var argsep = CommonParams.get('arg_separator');
$.post(url, $form.serialize() + argsep + 'delete=' + $thisButton.val() + argsep + 'ajax_request=true', function (data) {
if (typeof data !== 'undefined' && data.success === true) {
PMA_ajaxShowMessage(data.message);
@@ -144,12 +155,12 @@ export function onload1 () {
}
// Remove the revoked user from the users list
$form.find('input:checkbox:checked').parents('tr').slideUp('medium', function () {
- var this_user_initial = $(this).find('input:checkbox').val().charAt(0).toUpperCase();
+ var thisUserInitial = $(this).find('input:checkbox').val().charAt(0).toUpperCase();
$(this).remove();
- // If this is the last user with this_user_initial, remove the link from #initials_table
- if ($('#tableuserrights').find('input:checkbox[value^="' + this_user_initial + '"], input:checkbox[value^="' + this_user_initial.toLowerCase() + '"]').length === 0) {
- $('#initials_table').find('td > a:contains(' + this_user_initial + ')').parent('td').html(this_user_initial);
+ // If this is the last user with thisUserInitial, remove the link from #initials_table
+ if ($('#tableuserrights').find('input:checkbox[value^="' + thisUserInitial + '"], input:checkbox[value^="' + thisUserInitial.toLowerCase() + '"]').length === 0) {
+ $('#initials_table').find('td > a:contains(' + thisUserInitial + ')').parent('td').html(thisUserInitial);
}
// Re-check the classes of each row
@@ -184,12 +195,12 @@ export function onload1 () {
if (typeof data !== 'undefined' && data.success === true) {
PMA_ajaxRemoveMessage($msg);
var buttonOptions = {};
- buttonOptions[PMA_messages.strGo] = function () {
+ buttonOptions[messages.strGo] = function () {
var usrGroup = $('#changeUserGroupDialog')
.find('select[name="userGroup"]')
.val();
var $message = PMA_ajaxShowMessage();
- var argsep = PMA_commonParams.get('arg_separator');
+ var argsep = CommonParams.get('arg_separator');
$.post(
'server_privileges.php',
$('#changeUserGroupDialog').find('form').serialize() + argsep + 'ajax_request=1',
@@ -211,7 +222,7 @@ export function onload1 () {
);
$(this).dialog('close');
};
- buttonOptions[PMA_messages.strClose] = function () {
+ buttonOptions[messages.strClose] = function () {
$(this).dialog('close');
};
var $dialog = $('')
@@ -249,15 +260,15 @@ export function onload1 () {
event.preventDefault();
// can't export if no users checked
if ($(this.form).find('input:checked').length === 0) {
- PMA_ajaxShowMessage(PMA_messages.strNoAccountSelected, 2000, 'success');
+ PMA_ajaxShowMessage(messages.strNoAccountSelected, 2000, 'success');
return;
}
var $msgbox = PMA_ajaxShowMessage();
- var button_options = {};
- button_options[PMA_messages.strClose] = function () {
+ var buttonOptions = {};
+ buttonOptions[messages.strClose] = function () {
$(this).dialog('close');
};
- var argsep = PMA_commonParams.get('arg_separator');
+ var argsep = CommonParams.get('arg_separator');
$.post(
$(this.form).prop('action'),
$(this.form).serialize() + argsep + 'submit_mult=export' + argsep + 'ajax_request=true',
@@ -268,7 +279,7 @@ export function onload1 () {
.dialog({
title: data.title,
width: 500,
- buttons: button_options,
+ buttons: buttonOptions,
close: function () {
$(this).remove();
}
@@ -289,10 +300,10 @@ export function onload1 () {
event.preventDefault();
var $msgbox = PMA_ajaxShowMessage();
/**
- * @var button_options Object containing options for jQueryUI dialog buttons
+ * @var buttonOptions Object containing options for jQueryUI dialog buttons
*/
- var button_options = {};
- button_options[PMA_messages.strClose] = function () {
+ var buttonOptions = {};
+ buttonOptions[messages.strClose] = function () {
$(this).dialog('close');
};
$.get($(this).attr('href'), { 'ajax_request': true }, function (data) {
@@ -302,7 +313,7 @@ export function onload1 () {
.dialog({
title: data.title,
width: 500,
- buttons: button_options,
+ buttons: buttonOptions,
close: function () {
$(this).remove();
}
@@ -346,7 +357,7 @@ export function onload1 () {
}); // end $.get
}); // end of the paginate users table
- $(document).on('change', 'input[name="ssl_type"]', function (e) {
+ $(document).on('change', 'input[name="ssl_type"]', function () {
var $div = $('#specified_div');
if ($('#ssl_type_SPECIFIED').is(':checked')) {
$div.find('input').prop('disabled', false);
@@ -355,7 +366,7 @@ export function onload1 () {
}
});
- $(document).on('change', '#checkbox_SSL_priv', function (e) {
+ $(document).on('change', '#checkbox_SSL_priv', function () {
var $div = $('#require_ssl_div');
if ($(this).is(':checked')) {
$div.find('input').prop('disabled', false);
@@ -372,10 +383,10 @@ export function onload1 () {
*/
var addOrUpdateSubmenu = function () {
var $topmenu2 = $('#topmenu2');
- var $edit_user_dialog = $('#edit_user_dialog');
- var submenu_label;
- var submenu_link;
- var link_number;
+ var $editUserDialog = $('#edit_user_dialog');
+ var submenuLabel;
+ var submenuLink;
+ var linkNumber;
// if submenu exists yet, remove it first
if ($topmenu2.length > 0) {
@@ -386,14 +397,14 @@ export function onload1 () {
$topmenu2 = $('').prop('id', 'topmenu2');
$('#edit_user_dialog .submenu-item').each(function () {
- submenu_label = $(this).find('legend[data-submenu-label]').data('submenu-label');
+ submenuLabel = $(this).find('legend[data-submenu-label]').data('submenu-label');
- submenu_link = $('')
+ submenuLink = $('')
.prop('href', '#')
- .html(submenu_label);
+ .html(submenuLabel);
$('')
- .append(submenu_link)
+ .append(submenuLink)
.appendTo($topmenu2);
});
@@ -408,15 +419,15 @@ export function onload1 () {
$(this).addClass('tabactive');
// which section to show now?
- link_number = $topmenu2.find('a').index($(this));
+ linkNumber = $topmenu2.find('a').index($(this));
// hide all sections but the one to show
- $('#edit_user_dialog .submenu-item').hide().eq(link_number).show();
+ $('#edit_user_dialog .submenu-item').hide().eq(linkNumber).show();
});
// make first menu item active
// TODO: support URL hash history
$topmenu2.find('> :first-child a').addClass('tabactive');
- $edit_user_dialog.prepend($topmenu2);
+ $editUserDialog.prepend($topmenu2);
// hide all sections but the first
$('#edit_user_dialog .submenu-item').hide().eq(0).show();
@@ -435,3 +446,11 @@ export function onload1 () {
var windowwidth = $(window).width();
$('.jsresponsive').css('max-width', (windowwidth - 35) + 'px');
}
+
+/**
+ * Module export
+ */
+export {
+ onloadServerPrivileges,
+ teardownServerPrivileges
+};
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/shortcuts_handler.js b/js/src/shortcuts_handler.js
new file mode 100644
index 0000000000..376bbb7670
--- /dev/null
+++ b/js/src/shortcuts_handler.js
@@ -0,0 +1,112 @@
+/* vim: set expandtab sw=4 ts=4 sts=4: */
+/**
+ * @fileoverview Handle shortcuts in various pages
+ * @name Shortcuts handler
+ *
+ * @requires jQuery
+ * @requires jQueryUI
+ */
+/**
+ * Module import
+ */
+import Console from './console';
+import CommonParams from './variables/common_params';
+
+/**
+ * @package PhpMyAdmin
+ *
+ * Shortcuts Handler
+ */
+
+/**
+ * Register key events on load
+ */
+$(document).ready(function () {
+ var databaseOp = false;
+ var tableOp = false;
+ var keyD = 68;
+ var keyT = 84;
+ var keyK = 75;
+ var keyS = 83;
+ var keyF = 70;
+ var keyE = 69;
+ var keyH = 72;
+ var keyC = 67;
+ var keyBackSpace = 8;
+ $(document).on('keyup', function (e) {
+ if (e.target.nodeName === 'INPUT' || e.target.nodeName === 'TEXTAREA' || e.target.nodeName === 'SELECT') {
+ return;
+ }
+
+ if (e.keyCode === keyD) {
+ setTimeout(function () {
+ databaseOp = false;
+ }, 2000);
+ } else if (e.keyCode === keyT) {
+ setTimeout(function () {
+ tableOp = false;
+ }, 2000);
+ }
+ });
+ $(document).on('keydown', function (e) {
+ if (e.ctrlKey && e.altKey && e.keyCode === keyC) {
+ Console.toggle();
+ }
+
+ if (e.ctrlKey && e.keyCode === keyK) {
+ e.preventDefault();
+ Console.toggle();
+ }
+
+ if (e.target.nodeName === 'INPUT' || e.target.nodeName === 'TEXTAREA' || e.target.nodeName === 'SELECT') {
+ return;
+ }
+
+ var isTable;
+ var isDb;
+ if (e.keyCode === keyD) {
+ databaseOp = true;
+ } else if (e.keyCode === keyK) {
+ e.preventDefault();
+ Console.toggle();
+ } else if (e.keyCode === keyS) {
+ if (databaseOp === true) {
+ isTable = CommonParams.get('table');
+ isDb = CommonParams.get('db');
+ if (isDb && ! isTable) {
+ $('.tab .ic_b_props').first().trigger('click');
+ }
+ } else if (tableOp === true) {
+ isTable = CommonParams.get('table');
+ isDb = CommonParams.get('db');
+ if (isDb && isTable) {
+ $('.tab .ic_b_props').first().trigger('click');
+ }
+ } else {
+ $('#pma_navigation_settings_icon').trigger('click');
+ }
+ } else if (e.keyCode === keyF) {
+ if (databaseOp === true) {
+ isTable = CommonParams.get('table');
+ isDb = CommonParams.get('db');
+ if (isDb && ! isTable) {
+ $('.tab .ic_b_search').first().trigger('click');
+ }
+ } else if (tableOp === true) {
+ isTable = CommonParams.get('table');
+ isDb = CommonParams.get('db');
+ if (isDb && isTable) {
+ $('.tab .ic_b_search').first().trigger('click');
+ }
+ }
+ } else if (e.keyCode === keyT) {
+ tableOp = true;
+ } else if (e.keyCode === keyE) {
+ $('.ic_b_export').first().trigger('click');
+ } else if (e.keyCode === keyBackSpace) {
+ window.history.back();
+ } else if (e.keyCode === keyH) {
+ $('.ic_b_home').first().trigger('click');
+ }
+ });
+});
diff --git a/js/src/utils/Sanitise.js b/js/src/utils/Sanitise.js
index ac7a8cb62f..4431a6e9f0 100644
--- a/js/src/utils/Sanitise.js
+++ b/js/src/utils/Sanitise.js
@@ -1,8 +1,15 @@
+/* vim: set expandtab sw=4 ts=4 sts=4: */
+
/**
+ * @access public
+ *
+ * @param {string} unsafe Unsafe html which needs to be escaped
+ *
+ * @return {string}
+ *
* HTML escaping
*/
-
-export function escapeHtml (unsafe) {
+function escapeHtml (unsafe) {
if (typeof(unsafe) !== 'undefined') {
return unsafe
.toString()
@@ -16,7 +23,14 @@ export function escapeHtml (unsafe) {
}
}
-export function escapeJsString (unsafe) {
+/**
+ * @access public
+ *
+ * @param {string} unsafe Unsafe javascript
+ *
+ * @return {string}
+ */
+function escapeJsString (unsafe) {
if (typeof(unsafe) !== 'undefined') {
return unsafe
.toString()
@@ -33,3 +47,11 @@ export function escapeJsString (unsafe) {
return false;
}
}
+
+/**
+ * Module export
+ */
+export {
+ escapeHtml,
+ escapeJsString
+};
diff --git a/js/src/utils/config.js b/js/src/utils/config.js
new file mode 100644
index 0000000000..bf86a86bb3
--- /dev/null
+++ b/js/src/utils/config.js
@@ -0,0 +1,113 @@
+/* vim: set expandtab sw=4 ts=4 sts=4: */
+
+/**
+ * Module import
+ */
+import CommonParams from '../variables/common_params';
+import { PMA_ajaxShowMessage } from '../utils/show_ajax_messages';
+
+/**
+ * Sets a configuration value.
+ *
+ * A configuration value may be set in both browser's local storage and
+ * remotely in server's configuration table.
+ *
+ * If the `only_local` argument is `true`, the value is store is stored only in
+ * browser's local storage and may be lost if the user resets his browser's
+ * settings.
+ *
+ * NOTE: Depending on server's configuration, the configuration table may be or
+ * not persistent.
+ *
+ * @access public
+ *
+ * @param {string} key Configuration key.
+ *
+ * @param {object} value Configuration value.
+ *
+ * @param {boolean} onlyLocal Configuration type.
+ *
+ * @return {void}
+ */
+function configSet (key, value, onlyLocal) {
+ onlyLocal = (typeof onlyLocal !== 'undefined') ? onlyLocal : false;
+ var serialized = JSON.stringify(value);
+ localStorage.setItem(key, serialized);
+ $.ajax({
+ url: 'ajax.php',
+ type: 'POST',
+ dataType: 'json',
+ data: {
+ key: key,
+ type: 'config-set',
+ server: CommonParams.get('server'),
+ value: serialized,
+ },
+ success: function (data) {
+ // Updating value in local storage.
+ if (! data.success) {
+ PMA_ajaxShowMessage(data.message);
+ }
+ // Eventually, call callback.
+ }
+ });
+}
+
+/**
+ * Gets a configuration value. A configuration value will be searched in
+ * browser's local storage first and if not found, a call to the server will be
+ * made.
+ *
+ * If value should not be cached and the up-to-date configuration value from
+ * right from the server is required, the third parameter should be `false`.
+ *
+ * @access public
+ *
+ * @param {string} key Configuration key.
+ *
+ * @param {boolean} cached Configuration type.
+ *
+ * @return {object} Configuration value.
+ */
+function configGet (key, cached) {
+ cached = (typeof cached !== 'undefined') ? cached : true;
+ var value = localStorage.getItem(key);
+ if (cached && value !== undefined && value !== null) {
+ return JSON.parse(value);
+ }
+
+ // Result not found in local storage or ignored.
+ // Hitting the server.
+ $.ajax({
+ // TODO: This is ugly, but usually when a configuration is needed,
+ // processing cannot continue until that value is found.
+ // Another solution is to provide a callback as a parameter.
+ async: false,
+ url: 'ajax.php',
+ type: 'POST',
+ dataType: 'json',
+ data: {
+ type: 'config-get',
+ server: CommonParams.get('server'),
+ key: key
+ },
+ success: function (data) {
+ // Updating value in local storage.
+ if (data.success) {
+ localStorage.setItem(key, JSON.stringify(data.value));
+ } else {
+ PMA_ajaxShowMessage(data.message);
+ }
+ // Eventually, call callback.
+ }
+ });
+ return JSON.parse(localStorage.getItem(key));
+}
+
+/**
+ * Module export
+ */
+export {
+ configGet,
+ configSet
+};
diff --git a/js/src/utils/password.js b/js/src/utils/password.js
index 99293230af..8b99400672 100644
--- a/js/src/utils/password.js
+++ b/js/src/utils/password.js
@@ -1,20 +1,27 @@
-import { PMA_Messages as PMA_messages } from '../variables/export_variables';
+/* vim: set expandtab sw=4 ts=4 sts=4: */
+
+/**
+ * Module import
+ */
import zxcvbn from 'zxcvbn';
+import { PMA_Messages as messages } from '../variables/export_variables';
/**
* Generate a new password and copy it to the password input areas
*
- * @param passwd_form object the form that holds the password fields
+ * @access private
*
- * @return boolean always true
+ * @param {Object} passwdForm the form that holds the password fields
+ *
+ * @return {boolean} always true
*/
-export function suggestPassword (passwd_form) {
+function suggestPassword (passwdForm) {
// restrict the password to just letters and numbers to avoid problems:
// "editors and viewers regard the password as multiple words and
// things like double click no longer work"
var pwchars = 'abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWYXZ';
var passwordlength = 16; // do we want that to be dynamic? no, keep it simple :)
- var passwd = passwd_form.generated_pw;
+ var passwd = passwdForm.generated_pw;
var randomWords = new Int32Array(passwordlength);
passwd.value = '';
@@ -36,13 +43,13 @@ export function suggestPassword (passwd_form) {
passwd.value += pwchars.charAt(Math.abs(randomWords[i]) % pwchars.length);
}
- var $jquery_passwd_form = $(passwd_form);
+ var $jqueryPasswdForm = $(passwdForm);
- passwd_form.elements.pma_pw.value = passwd.value;
- passwd_form.elements.pma_pw2.value = passwd.value;
- var meter_obj = $jquery_passwd_form.find('meter[name="pw_meter"]').first();
- var meter_obj_label = $jquery_passwd_form.find('span[name="pw_strength"]').first();
- checkPasswordStrength(passwd.value, meter_obj, meter_obj_label);
+ passwdForm.elements.pma_pw.value = passwd.value;
+ passwdForm.elements.pma_pw2.value = passwd.value;
+ var meterObj = $jqueryPasswdForm.find('meter[name="pw_meter"]').first();
+ var meterObjLabel = $jqueryPasswdForm.find('span[name="pw_strength"]').first();
+ checkPasswordStrength(passwd.value, meterObj, meterObjLabel);
return true;
}
@@ -50,13 +57,16 @@ export function suggestPassword (passwd_form) {
* for PhpMyAdmin\Display\ChangePassword
* libraries/user_password.php
*
+ * @access public
+ *
+ * @return {void}
*/
-export function displayPasswordGenerateButton () {
+function displayPasswordGenerateButton () {
var generatePwdRow = $('
').addClass('vmiddle');
- $(' | ').html(PMA_messages.strGeneratePassword).appendTo(generatePwdRow);
+ $(' | ').html(messages.strGeneratePassword).appendTo(generatePwdRow);
var pwdCell = $(' | ').appendTo(generatePwdRow);
var pwdButton = $('')
- .attr({ type: 'button', id: 'button_generate_password', value: PMA_messages.strGenerate })
+ .attr({ type: 'button', id: 'button_generate_password', value: messages.strGenerate })
.addClass('button')
.on('click', function () {
suggestPassword(this.form);
@@ -69,7 +79,7 @@ export function displayPasswordGenerateButton () {
var generatePwdDiv = $('').addClass('item');
$('').attr({ for: 'button_generate_password' })
- .html(PMA_messages.strGeneratePassword + ':')
+ .html(messages.strGeneratePassword + ':')
.appendTo(generatePwdDiv);
var optionsSpan = $('').addClass('options')
.appendTo(generatePwdDiv);
@@ -78,38 +88,46 @@ export function displayPasswordGenerateButton () {
$('#div_element_before_generate_password').parent().append(generatePwdDiv);
}
+
/**
* Validates the "add a user" form
*
+ * @access public
+ *
* @return {boolean} whether the form is validated or not
*/
-export function checkAddUser (the_form) {
- if (the_form.elements.pred_hostname.value === 'userdefined' && the_form.elements.hostname.value === '') {
- alert(PMA_messages.strHostEmpty);
- the_form.elements.hostname.focus();
+function checkAddUser (theForm) {
+ if (theForm.elements.pred_hostname.value === 'userdefined' && theForm.elements.hostname.value === '') {
+ alert(messages.strHostEmpty);
+ theForm.elements.hostname.focus();
return false;
}
- if (the_form.elements.pred_username.value === 'userdefined' && the_form.elements.username.value === '') {
- alert(PMA_messages.strUserEmpty);
- the_form.elements.username.focus();
+ if (theForm.elements.pred_username.value === 'userdefined' && theForm.elements.username.value === '') {
+ alert(messages.strUserEmpty);
+ theForm.elements.username.focus();
return false;
}
- return PMA_checkPassword($(the_form));
+ return checkPassword($(theForm));
} // end of the 'checkAddUser()' function
/**
* Function to check the password strength
*
+ * @access public
+ *
* @param {string} value Passworrd string
- * @param {object} meter_obj jQuery object to show strength in meter
- * @param {object} meter_object_label jQuery object to show text of password strnegth
+ *
+ * @param {object} meterObj jQuery object to show strength in meter
+ *
+ * @param {object} meterObjectLabel jQuery object to show text of password strnegth
+ *
* @param {string} username Username string
*
* @returns {void}
*/
-export function checkPasswordStrength (value, meter_obj, meter_object_label, username) {
+function checkPasswordStrength (value, meterObj, meterObjectLabel, username) {
// List of words we don't want to appear in the password
var customDict = [
'phpmyadmin',
@@ -122,58 +140,72 @@ export function checkPasswordStrength (value, meter_obj, meter_object_label, use
if (username !== null) {
customDict.push(username);
}
- var zxcvbn_obj = zxcvbn(value, customDict);
- var strength = zxcvbn_obj.score;
+ var zxcvbnObj = zxcvbn(value, customDict);
+ var strength = zxcvbnObj.score;
strength = parseInt(strength);
- meter_obj.val(strength);
+ meterObj.val(strength);
switch (strength) {
- case 0: meter_object_label.html(PMA_messages.strExtrWeak);
+ case 0: meterObjectLabel.html(messages.strExtrWeak);
break;
- case 1: meter_object_label.html(PMA_messages.strVeryWeak);
+ case 1: meterObjectLabel.html(messages.strVeryWeak);
break;
- case 2: meter_object_label.html(PMA_messages.strWeak);
+ case 2: meterObjectLabel.html(messages.strWeak);
break;
- case 3: meter_object_label.html(PMA_messages.strGood);
+ case 3: meterObjectLabel.html(messages.strGood);
break;
- case 4: meter_object_label.html(PMA_messages.strStrong);
+ case 4: meterObjectLabel.html(messages.strStrong);
}
}
/**
* Validates the password field in a form
*
- * @see PMA_messages.strPasswordEmpty
- * @see PMA_messages.strPasswordNotSame
- * @param object $the_form The form to be validated
- * @return bool
+ * @access private
+ *
+ * @see PMA_Messages.strPasswordEmpty
+ *
+ * @see PMA_Messages.strPasswordNotSame
+ *
+ * @param {Object} $the_form The form to be validated
+ *
+ * @return {bool}
*/
-function PMA_checkPassword ($the_form) {
+function checkPassword ($theForm) {
// Did the user select 'no password'?
- if ($the_form.find('#nopass_1').is(':checked')) {
+ if ($theForm.find('#nopass_1').is(':checked')) {
return true;
} else {
- var $pred = $the_form.find('#select_pred_password');
+ var $pred = $theForm.find('#select_pred_password');
if ($pred.length && ($pred.val() === 'none' || $pred.val() === 'keep')) {
return true;
}
}
- var $password = $the_form.find('input[name=pma_pw]');
- var $password_repeat = $the_form.find('input[name=pma_pw2]');
- var alert_msg = false;
+ var $password = $theForm.find('input[name=pma_pw]');
+ var $passwordRepeat = $theForm.find('input[name=pma_pw2]');
+ var alertMsg = false;
if ($password.val() === '') {
- alert_msg = PMA_messages.strPasswordEmpty;
- } else if ($password.val() !== $password_repeat.val()) {
- alert_msg = PMA_messages.strPasswordNotSame;
+ alertMsg = messages.strPasswordEmpty;
+ } else if ($password.val() !== $passwordRepeat.val()) {
+ alertMsg = messages.strPasswordNotSame;
}
- if (alert_msg) {
- alert(alert_msg);
+ if (alertMsg) {
+ alert(alertMsg);
$password.val('');
- $password_repeat.val('');
+ $passwordRepeat.val('');
$password.focus();
return false;
}
return true;
}
+
+/**
+ * Module export
+ */
+export {
+ checkAddUser,
+ checkPasswordStrength,
+ displayPasswordGenerateButton
+};
diff --git a/js/src/utils/show_ajax_messages.js b/js/src/utils/show_ajax_messages.js
index 9892907185..4c5afc840f 100644
--- a/js/src/utils/show_ajax_messages.js
+++ b/js/src/utils/show_ajax_messages.js
@@ -7,25 +7,29 @@
/**
* Module imports
*/
-import { PMA_Messages as PMA_messages } from '../variables/export_variables';
+import { PMA_Messages as messages } from '../variables/export_variables';
import { PMA_highlightSQL } from './sql';
/**
- * @var int ajax_message_count Number of AJAX messages shown since page load
+ * @var {int} ajax_message_count Number of AJAX messages shown since page load
*/
let ajax_message_count = 0;
/**
* Create a jQuery UI tooltip
*
+ * @access public
+ *
* @param $elements jQuery object representing the elements
+ *
* @param item the item
* (see https://api.jqueryui.com/tooltip/#option-items)
* @param myContent content of the tooltip
+ *
* @param additionalOptions to override the default options
*
*/
-export function PMA_tooltip ($elements, item, myContent, additionalOptions) {
+function PMA_tooltip ($elements, item, myContent, additionalOptions) {
if ($('#no_hint').length > 0) {
return;
}
@@ -65,6 +69,8 @@ export function PMA_tooltip ($elements, item, myContent, additionalOptions) {
* This will show a message that will not disappear automatically, but it
* can be dismissed by the user after he has finished reading it.
*
+ * @access public
+ *
* @param string message string containing the message to be shown.
* optional, defaults to 'Loading...'
* @param mixed timeout number of milliseconds for the message to be visible
@@ -81,11 +87,11 @@ export function PMA_tooltip ($elements, item, myContent, additionalOptions) {
* to remove the notification
*/
-export const PMA_ajaxShowMessage = (message, timeout, type) => {
+const PMA_ajaxShowMessage = (message, timeout, type) => {
/**
* @var self_closing Whether the notification will automatically disappear
*/
- var self_closing = true;
+ var selfClosing = true;
/**
* @var dismissable Whether the user will be able to remove
* the notification by clicking on it
@@ -97,19 +103,19 @@ export const PMA_ajaxShowMessage = (message, timeout, type) => {
return true;
} else if (! message) {
// If the message is undefined, show the default
- message = PMA_messages.strLoading;
+ message = messages.strLoading;
dismissable = false;
- self_closing = false;
- } else if (message === PMA_messages.strProcessingRequest) {
+ selfClosing = false;
+ } else if (message === messages.strProcessingRequest) {
// This is another case where the message should not disappear
dismissable = false;
- self_closing = false;
+ selfClosing = false;
}
// Figure out whether (or after how long) to remove the notification
if (timeout === undefined) {
timeout = 5000;
} else if (timeout === false) {
- self_closing = false;
+ selfClosing = false;
}
// Determine type of message, add styling as required
if (type === 'error') {
@@ -140,7 +146,7 @@ export const PMA_ajaxShowMessage = (message, timeout, type) => {
.html(message)
.show();
// If the notification is self-closing we should create a callback to remove it
- if (self_closing) {
+ if (selfClosing) {
$retval
.delay(timeout)
.fadeOut('medium', function () {
@@ -162,7 +168,7 @@ export const PMA_ajaxShowMessage = (message, timeout, type) => {
PMA_tooltip(
$retval,
'span',
- PMA_messages.strDismiss
+ messages.strDismiss
);
}
PMA_highlightSQL($retval);
@@ -173,19 +179,30 @@ export const PMA_ajaxShowMessage = (message, timeout, type) => {
/**
* Removes the message shown for an Ajax operation when it's completed
*
+ * @access public
+ *
* @param jQuery object jQuery Element that holds the notification
*
* @return nothing
*/
-export function PMA_ajaxRemoveMessage ($this_msgbox) {
- if ($this_msgbox !== undefined && $this_msgbox instanceof jQuery) {
- $this_msgbox
+function PMA_ajaxRemoveMessage ($thisMsgbox) {
+ if ($thisMsgbox !== undefined && $thisMsgbox instanceof jQuery) {
+ $thisMsgbox
.stop(true, true)
.fadeOut('medium');
- if ($this_msgbox.is(':data(tooltip)')) {
- $this_msgbox.tooltip('destroy');
+ if ($thisMsgbox.is(':data(tooltip)')) {
+ $thisMsgbox.tooltip('destroy');
} else {
- $this_msgbox.remove();
+ $thisMsgbox.remove();
}
}
}
+
+/**
+ * Module export
+ */
+export {
+ PMA_ajaxRemoveMessage,
+ PMA_ajaxShowMessage,
+ PMA_tooltip
+};
diff --git a/js/src/utils/sprintf.js b/js/src/utils/sprintf.js
index 77c56c626c..93d9523f71 100644
--- a/js/src/utils/sprintf.js
+++ b/js/src/utils/sprintf.js
@@ -1,3 +1,8 @@
+/* vim: set expandtab sw=4 ts=4 sts=4: */
+
+/**
+ * Module import
+ */
import sprintf from 'sprintf-js';
/**
@@ -6,7 +11,7 @@ import sprintf from 'sprintf-js';
* @return string A concated string of aguments passed
*/
-export function PMA_sprintf () {
+function PMA_sprintf () {
/**
* This package can be implemented in two ways
*
@@ -16,3 +21,10 @@ export function PMA_sprintf () {
*/
return sprintf.sprintf(...arguments);
}
+
+/**
+ * Module export
+ */
+export {
+ PMA_sprintf
+};
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);
diff --git a/libraries/classes/Header.php b/libraries/classes/Header.php
index b71492f16e..72b4717e5f 100644
--- a/libraries/classes/Header.php
+++ b/libraries/classes/Header.php
@@ -211,12 +211,13 @@ class Header
$this->_scripts->addFile('navigation.js');
$this->_scripts->addFile('indexes.js');
$this->_scripts->addFile('common.js');
- $this->_scripts->addFile('page_settings.js');
+
if($GLOBALS['cfg']['enable_drag_drop_import'] === true) {
$this->_scripts->addFile('drag_drop_import.js');
}
+ $this->_scripts->addFile('page_settings');
if (! $GLOBALS['PMA_Config']->get('DisableShortcutKeys')) {
- $this->_scripts->addFile('shortcuts_handler.js');
+ $this->_scripts->addFile('shortcuts_handler');
}
$this->_scripts->addCode($this->getJsParamsCode());
}