The branch, master has been updated
via 8f618e6f013262963c279b71c1f2fff1d1d74e3d (commit)
via 84fda7ff95a1a53ede47d6b6b9b6b7fe3660a947 (commit)
from 51b54c954c900058a141a7444f3ec53ce9fbfce8 (commit)
- Log -----------------------------------------------------------------
commit 8f618e6f013262963c279b71c1f2fff1d1d74e3d
Author: Michal Čihař <mcihar(a)suse.cz>
Date: Mon Aug 8 13:29:20 2011 +0200
Convert more occurences of inline autosubmit code to external js
commit 84fda7ff95a1a53ede47d6b6b9b6b7fe3660a947
Author: Michal Čihař <mcihar(a)suse.cz>
Date: Mon Aug 8 13:24:53 2011 +0200
Automatic form submission on change.
-----------------------------------------------------------------------
Summary of changes:
db_structure.php | 2 +-
js/functions.js | 13 ++++++++++---
libraries/Config.class.php | 2 +-
libraries/Theme_Manager.class.php | 3 +--
libraries/common.lib.php | 2 +-
libraries/display_select_lang.lib.php | 2 +-
libraries/display_tbl.lib.php | 2 +-
libraries/mysql_charsets.lib.php | 2 +-
libraries/schema/User_Schema.class.php | 2 +-
libraries/select_server.lib.php | 3 +--
server_privileges.php | 4 ++--
setup/frames/index.inc.php | 2 +-
.../common/PMA_display_html_checkbox_test.php | 8 ++++----
13 files changed, 26 insertions(+), 21 deletions(-)
diff --git a/db_structure.php b/db_structure.php
index 01c2156..d76bcca 100644
--- a/db_structure.php
+++ b/db_structure.php
@@ -489,7 +489,7 @@ $checkall_url = 'db_structure.php?' . PMA_generate_common_url($db);
<?php echo __('Check tables having overhead'); ?></a>
<?php } ?>
-<select name="submit_mult" onchange="this.form.submit();" style="margin: 0 3em 0 3em;">
+<select name="submit_mult" class="autosubmit" style="margin: 0 3em 0 3em;">
<?php
echo ' <option value="' . __('With selected:') . '" selected="selected">'
. __('With selected:') . '</option>' . "\n";
diff --git a/js/functions.js b/js/functions.js
index d531c24..9b80619 100644
--- a/js/functions.js
+++ b/js/functions.js
@@ -3112,12 +3112,19 @@ function PMA_createqTip($elements, content, options)
$elements.qtip($.extend(true, o, options));
}
-/**
- * Theme selector.
- */
$(document).ready(function() {
+ /**
+ * Theme selector.
+ */
$('a.themeselect').live('click',function(e) {
window.open(e.target + '?foo=bar', 'themes','left=10,top=20,width=510,height=350,scrollbars=yes,status=yes,resizable=yes');
return false;
});
+
+ /**
+ * Automatic form submission on change.
+ */
+ $('.autosubmit').change(function(e) {
+ e.target.form.submit();
+ });
});
diff --git a/libraries/Config.class.php b/libraries/Config.class.php
index 0130252..9822807 100644
--- a/libraries/Config.class.php
+++ b/libraries/Config.class.php
@@ -1152,7 +1152,7 @@ class PMA_Config
$options = PMA_Config::_getFontsizeOptions($current_size);
$return = '<label for="select_fontsize">' . __('Font size') . ':</label>' . "\n";
- $return .= '<select name="set_fontsize" id="select_fontsize" onchange="this.form.submit();">' . "\n";
+ $return .= '<select name="set_fontsize" id="select_fontsize" class="autosubmit">' . "\n";
foreach ($options as $option) {
$return .= '<option value="' . $option . '"';
if ($option == $current_size) {
diff --git a/libraries/Theme_Manager.class.php b/libraries/Theme_Manager.class.php
index 8b60ef5..d6c4ea0 100644
--- a/libraries/Theme_Manager.class.php
+++ b/libraries/Theme_Manager.class.php
@@ -283,8 +283,7 @@ class PMA_Theme_Manager
$theme_preview_href = '<a href="' . $theme_preview_path . '" target="themes" class="themeselect">';
$select_box .= $theme_preview_href . __('Theme') . '</a>:' . "\n";
- $select_box .= '<select name="set_theme" xml:lang="en" dir="ltr"'
- .' onchange="this.form.submit();" >';
+ $select_box .= '<select name="set_theme" xml:lang="en" dir="ltr" class="autosubmit">';
foreach ($this->themes as $each_theme_id => $each_theme) {
$select_box .= '<option value="' . $each_theme_id . '"';
if ($this->active_theme === $each_theme_id) {
diff --git a/libraries/common.lib.php b/libraries/common.lib.php
index e491adb..5de802b 100644
--- a/libraries/common.lib.php
+++ b/libraries/common.lib.php
@@ -2316,7 +2316,7 @@ function PMA_externalBug($functionality, $component, $minimum_version, $bugref)
function PMA_display_html_checkbox($html_field_name, $label, $checked, $onclick)
{
- echo '<input type="checkbox" name="' . $html_field_name . '" id="' . $html_field_name . '"' . ($checked ? ' checked="checked"' : '') . ($onclick ? ' onclick="this.form.submit();"' : '') . ' /><label for="' . $html_field_name . '">' . $label . '</label>';
+ echo '<input type="checkbox" name="' . $html_field_name . '" id="' . $html_field_name . '"' . ($checked ? ' checked="checked"' : '') . ($onclick ? ' class="autosubmit"' : '') . ' /><label for="' . $html_field_name . '">' . $label . '</label>';
}
/**
diff --git a/libraries/display_select_lang.lib.php b/libraries/display_select_lang.lib.php
index 202378d..fcc2b72 100644
--- a/libraries/display_select_lang.lib.php
+++ b/libraries/display_select_lang.lib.php
@@ -55,7 +55,7 @@ function PMA_select_language($use_fieldset = false, $show_doc = true)
}
?>
- <select name="lang" onchange="this.form.submit();" xml:lang="en" dir="ltr">
+ <select name="lang" class="autosubmit" xml:lang="en" dir="ltr">
<?php
uasort($GLOBALS['available_languages'], 'PMA_language_cmp');
diff --git a/libraries/display_tbl.lib.php b/libraries/display_tbl.lib.php
index 19a1749..2f95f11 100644
--- a/libraries/display_tbl.lib.php
+++ b/libraries/display_tbl.lib.php
@@ -552,7 +552,7 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
echo '<form action="sql.php" method="post">' . "\n";
echo PMA_generate_common_hidden_inputs($db, $table);
- echo __('Sort by key') . ': <select name="sql_query" onchange="this.form.submit();">' . "\n";
+ echo __('Sort by key') . ': <select name="sql_query" class="autosubmit">' . "\n";
$used_index = false;
$local_order = (isset($sort_expression) ? $sort_expression : '');
foreach ($indexes as $index) {
diff --git a/libraries/mysql_charsets.lib.php b/libraries/mysql_charsets.lib.php
index 4eec97e..45f9255 100644
--- a/libraries/mysql_charsets.lib.php
+++ b/libraries/mysql_charsets.lib.php
@@ -104,7 +104,7 @@ function PMA_generateCharsetDropdownBox($type = PMA_CSDROPDOWN_COLLATION,
$return_str = '<select xml:lang="en" dir="ltr" name="'
. htmlspecialchars($name) . '"'
. (empty($id) ? '' : ' id="' . htmlspecialchars($id) . '"')
- . ($submitOnChange ? ' onchange="this.form.submit();"' : '') . '>' . "\n";
+ . ($submitOnChange ? ' class="autosubmit"' : '') . '>' . "\n";
if ($label) {
$return_str .= '<option value="">'
. ($type == PMA_CSDROPDOWN_COLLATION ? __('Collation') : __('Charset'))
diff --git a/libraries/schema/User_Schema.class.php b/libraries/schema/User_Schema.class.php
index aa39ec5..2ea0a2b 100644
--- a/libraries/schema/User_Schema.class.php
+++ b/libraries/schema/User_Schema.class.php
@@ -145,7 +145,7 @@ class PMA_User_Schema
</legend>
<?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
<input type="hidden" name="do" value="selectpage" />
- <select name="chpage" id="chpage" onchange="this.form.submit()">
+ <select name="chpage" id="chpage" class="autosubmit">
<option value="0"><?php echo __('Select page'); ?></option>
<?php
while ($curr_page = PMA_DBI_fetch_assoc($page_rs)) {
diff --git a/libraries/select_server.lib.php b/libraries/select_server.lib.php
index 6d230ea..4d7b8f8 100644
--- a/libraries/select_server.lib.php
+++ b/libraries/select_server.lib.php
@@ -31,8 +31,7 @@ function PMA_select_server($not_only_options, $ommit_fieldset)
}
echo '<label for="select_server">' . __('Current Server') . ':</label> ';
- echo '<select name="server" id="select_server"'
- . ' onchange="if (this.value != \'\') this.form.submit();">';
+ echo '<select name="server" id="select_server" class="autosubmit">';
echo '<option value="">(' . __('Servers') . ') ...</option>' . "\n";
} elseif ($list) {
echo __('Current Server') . ':<br />';
diff --git a/server_privileges.php b/server_privileges.php
index 2d7732c..64a5975 100644
--- a/server_privileges.php
+++ b/server_privileges.php
@@ -2091,7 +2091,7 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs
echo ' <label for="text_dbname">' . __('Add privileges on the following database') . ':</label>' . "\n";
if (!empty($pred_db_array)) {
- echo ' <select name="pred_dbname" onchange="this.form.submit();">' . "\n"
+ echo ' <select name="pred_dbname" class="autosubmit">' . "\n"
. ' <option value="" selected="selected">' . __('Use text field') . ':</option>' . "\n";
foreach ($pred_db_array as $current_db) {
$current_db = PMA_escape_mysql_wildcards($current_db);
@@ -2121,7 +2121,7 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs
PMA_DBI_free_result($res);
unset($res, $row);
if (!empty($pred_tbl_array)) {
- echo ' <select name="pred_tablename" onchange="this.form.submit();">' . "\n"
+ echo ' <select name="pred_tablename" class="autosubmit">' . "\n"
. ' <option value="" selected="selected">' . __('Use text field') . ':</option>' . "\n";
foreach ($pred_tbl_array as $current_table) {
echo ' <option value="' . htmlspecialchars($current_table) . '">' . htmlspecialchars($current_table) . '</option>' . "\n";
diff --git a/setup/frames/index.inc.php b/setup/frames/index.inc.php
index 6b170f0..3ad1cfc 100644
--- a/setup/frames/index.inc.php
+++ b/setup/frames/index.inc.php
@@ -71,7 +71,7 @@ if (!$is_https) {
<bdo xml:lang="en" dir="ltr"><label for="lang">
<?php echo __('Language') . (__('Language') != 'Language' ? ' - Language' : '') ?>
</label></bdo><br />
- <select id="lang" name="lang" onchange="this.form.submit();" xml:lang="en" dir="ltr">
+ <select id="lang" name="lang" class="autosubmit" xml:lang="en" dir="ltr">
<?php
// create language list
$lang_list = array();
diff --git a/test/libraries/common/PMA_display_html_checkbox_test.php b/test/libraries/common/PMA_display_html_checkbox_test.php
index c779d72..b33a5fe 100644
--- a/test/libraries/common/PMA_display_html_checkbox_test.php
+++ b/test/libraries/common/PMA_display_html_checkbox_test.php
@@ -38,7 +38,7 @@ class PMA_display_html_checkbox_test extends PHPUnit_Extensions_OutputTestCase
$name = "test_display_html_checkbox";
$label = "text_label_for_checkbox";
- $this->expectOutputString('<input type="checkbox" name="' . $name . '" id="' . $name . '" onclick="this.form.submit();" /><label for="' . $name . '">' . $label . '</label>');
+ $this->expectOutputString('<input type="checkbox" name="' . $name . '" id="' . $name . '" class="autosubmit" /><label for="' . $name . '">' . $label . '</label>');
PMA_display_html_checkbox($name,$label,false,true);
}
@@ -47,9 +47,9 @@ class PMA_display_html_checkbox_test extends PHPUnit_Extensions_OutputTestCase
$name = "test_display_html_checkbox";
$label = "text_label_for_checkbox";
- $this->expectOutputString('<input type="checkbox" name="' . $name . '" id="' . $name . '" checked="checked" onclick="this.form.submit();" /><label for="' . $name . '">' . $label . '</label>');
+ $this->expectOutputString('<input type="checkbox" name="' . $name . '" id="' . $name . '" checked="checked" class="autosubmit" /><label for="' . $name . '">' . $label . '</label>');
PMA_display_html_checkbox($name,$label,true,true);
}
}
-
-//PMA_display_html_checkbox
\ No newline at end of file
+
+//PMA_display_html_checkbox
hooks/post-receive
--
phpMyAdmin