From: <gi...@ma...> - 2010-06-28 07:37:45
|
The branch, master has been updated via c5329886b4c191f3c9249cb88669687c0f8cd544 (commit) from 0551d94bc409ba2245938ceaf32265616d9768f5 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit c5329886b4c191f3c9249cb88669687c0f8cd544 Author: David Hicks <hic...@op...> Date: Mon Jun 28 17:34:41 2010 +1000 Issue #11826: Convert form field autofocus scripts to jQuery This commit furthers the goal of removing inline JavaScript from within the MantisBT codebase. Instead of using inline JavaScript to toggle automatic focus on form fields we can use jQuery instead. All one needs to do is place a field within a form with the "autofocus" class specified. ----------------------------------------------------------------------- Summary of changes: bug_report_page.php | 12 ++---------- core/authentication_api.php | 18 ++++-------------- javascript/dev/common.js | 2 +- login_page.php | 23 ++++++++++------------- lost_pwd_page.php | 15 +-------------- signup_page.php | 15 +-------------- 6 files changed, 19 insertions(+), 66 deletions(-) ----------------------------------------------------------------------- commit c5329886b4c191f3c9249cb88669687c0f8cd544 Author: David Hicks <hic...@op...> Date: Mon Jun 28 17:34:41 2010 +1000 Issue #11826: Convert form field autofocus scripts to jQuery This commit furthers the goal of removing inline JavaScript from within the MantisBT codebase. Instead of using inline JavaScript to toggle automatic focus on form fields we can use jQuery instead. All one needs to do is place a field within a form with the "autofocus" class specified. diff --git a/bug_report_page.php b/bug_report_page.php index 1059c87..b8eebaf 100644 --- a/bug_report_page.php +++ b/bug_report_page.php @@ -222,7 +222,7 @@ print_recently_visited(); <?php if ( $t_changed_project ) { echo "[" . project_get_field( $t_bug->project_id, 'name' ) . "] "; } ?> - <select <?php echo helper_get_tab_index() ?> name="category_id"> + <select <?php echo helper_get_tab_index() ?> name="category_id" class="autofocus"> <?php print_category_option_list( $f_category_id ); ?> @@ -563,15 +563,7 @@ print_recently_visited(); </table> </form> </div> - -<!-- Autofocus JS --> -<?php if ( ON == config_get( 'use_javascript' ) ) { ?> -<script type="text/javascript"> -<!-- - window.document.report_bug_form.category_id.focus(); ---> -</script> -<?php } +<?php if ( $tpl_show_due_date ) { date_finish_calendar( 'due_date', 'trigger' ); } diff --git a/core/authentication_api.php b/core/authentication_api.php index dbbbf07..c16dd94 100644 --- a/core/authentication_api.php +++ b/core/authentication_api.php @@ -713,12 +713,12 @@ function auth_reauthenticate_page( $p_user_id, $p_username ) { <tr class="row-1"> <th class="category"><?php echo lang_get( 'username' );?></th> - <td><input type="text" disabled="disabled" size="32" maxlength="<?php echo USERLEN;?>" value="<?php echo $p_username;?>" /></td> + <td><input type="text" disabled="disabled" size="32" maxlength="<?php echo USERLEN;?>" value="<?php echo string_attribute( $p_username );?>" /></td> </tr> <tr class="row-2"> <th class="category"><?php echo lang_get( 'password' );?></th> - <td><input type="password" name="password" size="16" maxlength="<?php echo PASSLEN;?>" /></td> + <td><input type="password" name="password" size="16" maxlength="<?php echo PASSLEN;?>" class="autofocus" /></td> </tr> <tr> @@ -729,18 +729,8 @@ function auth_reauthenticate_page( $p_user_id, $p_username ) { </form> </div> -<?php if ( ON == config_get( 'use_javascript' ) ) { ?> -<!-- Autofocus JS --> -<script type="text/javascript"> -<!-- - window.document.reauth_form.password.focus(); -// --> -</script> -<?php } ?> - - <?php - html_page_bottom(); - +<?php + html_page_bottom(); exit; } diff --git a/javascript/dev/common.js b/javascript/dev/common.js index 4cf2906..97e222d 100644 --- a/javascript/dev/common.js +++ b/javascript/dev/common.js @@ -77,7 +77,7 @@ $(document).ready( function() { } }); - $('input.autofocus:first').focus(); + $('input.autofocus:first, select.autofocus:first, textarea.autofocus:first').focus(); var stopwatch = { timerID: null, diff --git a/login_page.php b/login_page.php index d25dda9..2e3cd2d 100644 --- a/login_page.php +++ b/login_page.php @@ -113,6 +113,14 @@ if ( $t_session_validation ) { } } +# Determine whether the username or password field should receive automatic focus. +$t_username_field_autofocus = 'autofocus'; +$t_password_field_autofocus = ''; +if ( $f_username ) { + $t_username_field_autofocus = ''; + $t_password_field_autofocus = 'autofocus'; +} + echo '</div>'; ?> @@ -145,7 +153,7 @@ echo '</div>'; <?php echo lang_get( 'username' ) ?> </th> <td> - <input type="text" name="username" size="28" maxlength="<?php echo USERLEN;?>" value="<?php echo string_attribute( $f_username ); ?>" /> + <input type="text" name="username" size="28" maxlength="<?php echo USERLEN;?>" value="<?php echo string_attribute( $f_username ); ?>" class="<?php echo $t_username_field_autofocus ?>" /> </td> </tr> <tr class="row-2"> @@ -153,7 +161,7 @@ echo '</div>'; <?php echo lang_get( 'password' ) ?> </th> <td> - <input type="password" name="password" size="16" maxlength="<?php echo PASSLEN;?>" /> + <input type="password" name="password" size="16" maxlength="<?php echo PASSLEN;?>" class="<?php echo $t_password_field_autofocus ?>" /> </td> </tr> <tr class="row-1"> @@ -265,16 +273,5 @@ if ( config_get_global( 'admin_checks' ) == ON ) { } } # if 'admin_checks' -?> - -<!-- Autofocus JS --> -<?php if ( ON == config_get( 'use_javascript' ) ) { ?> -<script type="text/javascript"> -<!-- - window.document.login_form.<?php if ( is_blank( $f_username ) ) { echo 'username'; } else { echo 'password'; } ?>.focus(); -// --> -</script> -<?php -} html_page_bottom1a( __FILE__ ); diff --git a/lost_pwd_page.php b/lost_pwd_page.php index e479cfc..2c0a8df 100644 --- a/lost_pwd_page.php +++ b/lost_pwd_page.php @@ -75,7 +75,7 @@ if ( $t_allow_passwd ) { <?php echo lang_get( 'username' ) ?> </th> <td width="75%"> - <input type="text" name="username" size="32" maxlength="<?php echo USERLEN;?>" /> + <input type="text" name="username" size="32" maxlength="<?php echo USERLEN;?>" class="autofocus" /> </td> </tr> <tr class="row-2"> @@ -123,17 +123,4 @@ echo ' '; print_signup_link(); echo '</div>'; -if ( ON == config_get( 'use_javascript' ) ) { -?> -<!-- Autofocus JS --> -<?php if ( ON == config_get( 'use_javascript' ) ) { ?> -<script type="text/javascript"> -<!-- - window.document.lost_password_form.username.focus(); -// --> -</script> -<?php - } -} - html_page_bottom1a( __FILE__ ); diff --git a/signup_page.php b/signup_page.php index 95e34c2..4b36ba4 100644 --- a/signup_page.php +++ b/signup_page.php @@ -72,7 +72,7 @@ $t_public_key = crypto_generate_uri_safe_nonce( 64 ); <?php echo lang_get( 'username_label' ) ?> </th> <td width="70%" colspan="2"> - <input type="text" name="username" size="32" maxlength="<?php echo USERLEN;?>" /> + <input type="text" name="username" size="32" maxlength="<?php echo USERLEN;?>" class="autofocus" /> </td> </tr> <tr class="row-2"> @@ -137,17 +137,4 @@ echo ' '; print_lost_password_link(); echo '</div>'; -if ( ON == config_get( 'use_javascript' ) ) { -?> -<!-- Autofocus JS --> -<?php if ( ON == config_get( 'use_javascript' ) ) { ?> -<script type="text/javascript"> -<!-- - window.document.signup_form.username.focus(); -// --> -</script> -<?php - } -} - html_page_bottom1a( __FILE__ ); ----------------------------------------------------------------------- -- Mantis Bug Tracker |