The branch, master has been updated via 22f9ac76daceb370f468d6720462eb0e61903cf5 (commit) via 8f16bfbc531b654fd61a4b8c6ee78f2f491b6c00 (commit) from 5de751bd99285cdbcb2212ed03dff0b67155e9db (commit)
- Log ----------------------------------------------------------------- commit 22f9ac76daceb370f468d6720462eb0e61903cf5 Merge: 8f16bfbc531b654fd61a4b8c6ee78f2f491b6c00 5de751bd99285cdbcb2212ed03dff0b67155e9db Author: Marc Delisle marc@infomarc.info Date: Sun Apr 24 08:58:25 2011 -0400
Merge branch 'master' of ssh://phpmyadmin.git.sourceforge.net/gitroot/phpmyadmin/phpmyadmin
commit 8f16bfbc531b654fd61a4b8c6ee78f2f491b6c00 Author: Marc Delisle marc@infomarc.info Date: Sun Apr 24 08:56:54 2011 -0400
Move common code into a function
-----------------------------------------------------------------------
Summary of changes: js/db_operations.js | 13 +++---------- js/db_search.js | 5 +---- js/functions.js | 29 ++++++++++++++++------------- js/sql.js | 4 +--- js/tbl_change.js | 4 +--- js/tbl_select.js | 5 +---- 6 files changed, 23 insertions(+), 37 deletions(-)
diff --git a/js/db_operations.js b/js/db_operations.js index 5169b55..b053694 100644 --- a/js/db_operations.js +++ b/js/db_operations.js @@ -34,10 +34,7 @@ $(document).ready(function() {
var question = 'CREATE DATABASE ' + $('#new_db_name').val() + ' / DROP DATABASE ' + window.parent.db;
- if (! $form.find('input:hidden').is('#ajax_request_hidden')) { - $form.append('<input type="hidden" id="ajax_request_hidden" name="ajax_request" value="true" />'); - } - + PMA_prepareForAjaxRequest($form); /** * @var button_options Object containing options for jQueryUI dialog buttons */ @@ -95,9 +92,7 @@ $(document).ready(function() {
var $form = $(this);
- if (! $form.find('input:hidden').is('#ajax_request_hidden')) { - $form.append('<input type="hidden" id="ajax_request_hidden" name="ajax_request" value="true" />'); - } + PMA_prepareForAjaxRequest($form);
$.get($form.attr('action'), $form.serialize(), function(data) { // use messages that stay on screen @@ -135,9 +130,7 @@ $(document).ready(function() {
var $form = $(this);
- if (! $form.find('input:hidden').is('#ajax_request_hidden')) { - $form.append('<input type="hidden" id="ajax_request_hidden" name="ajax_request" value="true" />'); - } + PMA_prepareForAjaxRequest($form);
PMA_ajaxShowMessage(PMA_messages['strChangingCharset']);
diff --git a/js/db_search.js b/js/db_search.js index 73bea25..79c444e 100644 --- a/js/db_search.js +++ b/js/db_search.js @@ -142,10 +142,7 @@ $(document).ready(function() { // jQuery object to reuse $form = $(this);
- // add this hidden field just once - if (! $form.find('input:hidden').is('#ajax_request_hidden')) { - $form.append('<input type="hidden" id="ajax_request_hidden" name="ajax_request" value="true" />'); - } + PMA_prepareForAjaxRequest($form);
$.post($form.attr('action'), $form.serialize() + "&submit_search=" + $("#buttonGo").val(), function(response) { if (typeof response == 'string') { diff --git a/js/functions.js b/js/functions.js index 1016b2f..6894e15 100644 --- a/js/functions.js +++ b/js/functions.js @@ -21,6 +21,18 @@ var only_once_elements = new Array(); var ajax_message_init = false;
/** + * Add a hidden field to the form to indicate that this will be an + * Ajax request (only if this hidden field does not exist) + * + * @param object the form + */ +function PMA_prepareForAjaxRequest($form) { + if (! $form.find('input:hidden').is('#ajax_request_hidden')) { + $form.append('<input type="hidden" id="ajax_request_hidden" name="ajax_request" value="true" />'); + } +} + +/** * Generate a new password and copy it to the password input areas * * @param object the form that holds the password fields @@ -1403,9 +1415,7 @@ $(document).ready(function() { button_options_error[PMA_messages['strOK']] = function() {$(this).dialog('close').remove();}
var $msgbox = PMA_ajaxShowMessage(); - if (! $form.find('input:hidden').is('#ajax_request_hidden')) { - $form.append('<input type="hidden" id="ajax_request_hidden" name="ajax_request" value="true" />'); - } + PMA_prepareForAjaxRequest($form);
$.get($form.attr('action'), $form.serialize(), function(data) { //in the case of an error, show the error message returned. @@ -1467,9 +1477,7 @@ $(document).ready(function() { // OK, form passed validation step if ($form.hasClass('ajax')) { PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']); - if (! $form.find('input:hidden').is('#ajax_request_hidden')) { - $form.append('<input type="hidden" id="ajax_request_hidden" name="ajax_request" value="true" />'); - } + PMA_prepareForAjaxRequest($form); //User wants to submit the form $.post($form.attr('action'), $form.serialize() + "&do_save_data=" + $(this).val(), function(data) { if(data.success == true) { @@ -1561,9 +1569,7 @@ $(document).ready(function() { var $form = $("#create_table_form");
var $msgbox = PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']); - if (! $form.find('input:hidden').is('#ajax_request_hidden')) { - $form.append('<input type="hidden" id="ajax_request_hidden" name="ajax_request" value="true" />'); - } + PMA_prepareForAjaxRequest($form);
//User wants to add more fields to the table $.post($form.attr('action'), $form.serialize() + "&submit_num_fields=" + $(this).val(), function(data) { @@ -1670,10 +1676,7 @@ $(document).ready(function() { $form = $(this);
PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']); - - if (! $form.find('input:hidden').is('#ajax_request_hidden')) { - $form.append('<input type="hidden" id="ajax_request_hidden" name="ajax_request" value="true" />'); - } + PMA_prepareForAjaxRequest($form);
$.post($form.attr('action'), $form.serialize(), function(data) { if(data.success == true) { diff --git a/js/sql.js b/js/sql.js index 8a97eec..77717a7 100644 --- a/js/sql.js +++ b/js/sql.js @@ -254,9 +254,7 @@ $(document).ready(function() { $form = $(this); var $msgbox = PMA_ajaxShowMessage();
- if (! $form.find('input:hidden').is('#ajax_request_hidden')) { - $form.append('<input type="hidden" id="ajax_request_hidden" name="ajax_request" value="true" />'); - } + PMA_prepareForAjaxRequest($form);
$.post($(this).attr('action'), $(this).serialize() , function(data) { if(data.success == true) { diff --git a/js/tbl_change.js b/js/tbl_change.js index e5b800f..2d33884 100644 --- a/js/tbl_change.js +++ b/js/tbl_change.js @@ -283,9 +283,7 @@ $(document).ready(function() { event.preventDefault();
PMA_ajaxShowMessage(); - if (! $form.find('input:hidden').is('#ajax_request_hidden')) { - $form.append('<input type="hidden" id="ajax_request_hidden" name="ajax_request" value="true" />'); - } + PMA_prepareForAjaxRequest($form);
$.post($form.attr('action'), $form.serialize(), function(data) { if (typeof data.success != 'undefined') { diff --git a/js/tbl_select.js b/js/tbl_select.js index 88aceff..8115245 100644 --- a/js/tbl_select.js +++ b/js/tbl_select.js @@ -60,10 +60,7 @@ $(document).ready(function() { $("#sqlqueryresults").empty(); var msgbox = PMA_ajaxShowMessage(PMA_messages['strSearching']);
- // add this hidden field just once - if (! $search_form.find('input:hidden').is('#ajax_request_hidden')) { - $search_form.append('<input type="hidden" id="ajax_request_hidden" name="ajax_request" value="true" />'); - } + PMA_prepareForAjaxRequest($search_form);
$.post($search_form.attr('action'), $search_form.serialize(), function(response) { if (typeof response == 'string') {
hooks/post-receive