aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVjacheslav Trushkin <cyberalien@gmail.com>2013-08-16 18:20:00 +0300
committerVjacheslav Trushkin <cyberalien@gmail.com>2013-09-14 10:10:42 +0300
commit605cd0cafb9cab5f64b1185965d1a354228181e7 (patch)
tree59718e8e0deab7e68f08612224a756948831d183
parent235e3f55956001ad98c6c584913b4e9723112607 (diff)
downloadforums-605cd0cafb9cab5f64b1185965d1a354228181e7.tar
forums-605cd0cafb9cab5f64b1185965d1a354228181e7.tar.gz
forums-605cd0cafb9cab5f64b1185965d1a354228181e7.tar.bz2
forums-605cd0cafb9cab5f64b1185965d1a354228181e7.tar.xz
forums-605cd0cafb9cab5f64b1185965d1a354228181e7.zip
[ticket/11795] Redo form elements auto-focus
Use data-focus attribute for forms to focus elements when document is loaded instead of adding JavaScript PHPBB3-11795
-rw-r--r--phpBB/styles/prosilver/template/forum_fn.js17
-rw-r--r--phpBB/styles/prosilver/template/login_body.html10
-rw-r--r--phpBB/styles/prosilver/template/search_body.html10
3 files changed, 12 insertions, 25 deletions
diff --git a/phpBB/styles/prosilver/template/forum_fn.js b/phpBB/styles/prosilver/template/forum_fn.js
index 4fb8f7b284..49b3bc5dd9 100644
--- a/phpBB/styles/prosilver/template/forum_fn.js
+++ b/phpBB/styles/prosilver/template/forum_fn.js
@@ -293,20 +293,23 @@ function apply_onkeypress_event() {
jQuery(document).ready(apply_onkeypress_event);
/**
-* Adjust HTML code for IE8 and older versions
+* Run onload functions
*/
(function($) {
$(document).ready(function() {
+ // Focus forms
+ $('form[data-focus]:first').each(function() {
+ $('#' + this.getAttribute('data-focus')).focus();
+ });
+
+ // Adjust HTML code for IE8 and older versions
var test = document.createElement('div'),
oldBrowser = (typeof test.style.borderRadius == 'undefined');
delete test;
- if (!oldBrowser) {
- return;
+ if (oldBrowser) {
+ // Fix .linkslist.bulletin lists
+ $('ul.linklist.bulletin li:first-child, ul.linklist.bulletin li.rightside:last-child').addClass('no-bulletin');
}
-
- // Fix .linkslist.bulletin lists
- $('ul.linklist.bulletin li:first-child, ul.linklist.bulletin li.rightside:last-child').addClass('no-bulletin');
});
})(jQuery);
-
diff --git a/phpBB/styles/prosilver/template/login_body.html b/phpBB/styles/prosilver/template/login_body.html
index a1c2735ca9..38d9f8c68b 100644
--- a/phpBB/styles/prosilver/template/login_body.html
+++ b/phpBB/styles/prosilver/template/login_body.html
@@ -1,14 +1,6 @@
<!-- INCLUDE overall_header.html -->
-<script type="text/javascript">
-// <![CDATA[
- onload_functions.push(function () {
- document.getElementById("<!-- IF S_ADMIN_AUTH -->{PASSWORD_CREDENTIAL}<!-- ELSE -->{USERNAME_CREDENTIAL}<!-- ENDIF -->").focus();
- });
-// ]]>
-</script>
-
-<form action="{S_LOGIN_ACTION}" method="post" id="login">
+<form action="{S_LOGIN_ACTION}" method="post" id="login" data-focus="<!-- IF S_ADMIN_AUTH -->{PASSWORD_CREDENTIAL}<!-- ELSE -->{USERNAME_CREDENTIAL}<!-- ENDIF -->">
<div class="panel">
<div class="inner">
diff --git a/phpBB/styles/prosilver/template/search_body.html b/phpBB/styles/prosilver/template/search_body.html
index fedbdc6642..d4c1f98a2a 100644
--- a/phpBB/styles/prosilver/template/search_body.html
+++ b/phpBB/styles/prosilver/template/search_body.html
@@ -1,16 +1,8 @@
<!-- INCLUDE overall_header.html -->
-<script type="text/javascript">
-// <![CDATA[
- onload_functions.push(function () {
- document.getElementById("keywords").focus();
- });
-// ]]>
-</script>
-
<h2 class="solo">{L_SEARCH}</h2>
-<form method="get" action="{S_SEARCH_ACTION}">
+<form method="get" action="{S_SEARCH_ACTION}" data-focus="keywords">
<div class="panel">
<div class="inner">