aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/styles/prosilver
diff options
context:
space:
mode:
authorOleg Pudeyev <oleg@bsdpower.com>2011-03-15 07:45:43 -0400
committerOleg Pudeyev <oleg@bsdpower.com>2012-03-14 22:57:31 -0400
commitda8009603d05acdccaff15cd610353d85c365220 (patch)
tree0afff6695015477109bda8a1f298a9d9bcbc6d61 /phpBB/styles/prosilver
parentbb461c8daa97358e8bcce923a21eba0abd6ea3dc (diff)
downloadforums-da8009603d05acdccaff15cd610353d85c365220.tar
forums-da8009603d05acdccaff15cd610353d85c365220.tar.gz
forums-da8009603d05acdccaff15cd610353d85c365220.tar.bz2
forums-da8009603d05acdccaff15cd610353d85c365220.tar.xz
forums-da8009603d05acdccaff15cd610353d85c365220.zip
[feature/new-tz-handling] Preselect a timezone in registration.
Use Javascript to obtain client's timezone offset and select the first timezone in our list with that offset. Changes for prosilver only. The javascript file should be shared between styles. PHPBB3-9558
Diffstat (limited to 'phpBB/styles/prosilver')
-rw-r--r--phpBB/styles/prosilver/template/timezone.js54
-rw-r--r--phpBB/styles/prosilver/template/ucp_prefs_personal.html10
-rw-r--r--phpBB/styles/prosilver/template/ucp_register.html10
3 files changed, 72 insertions, 2 deletions
diff --git a/phpBB/styles/prosilver/template/timezone.js b/phpBB/styles/prosilver/template/timezone.js
new file mode 100644
index 0000000000..5d07b1d3ad
--- /dev/null
+++ b/phpBB/styles/prosilver/template/timezone.js
@@ -0,0 +1,54 @@
+function phpbb_preselect_tz_select()
+{
+ var selector = document.getElementsByClassName('tz_select')[0];
+ if (selector.value)
+ {
+ return;
+ }
+ // The offset returned here is in minutes and negated.
+ // http://www.w3schools.com/jsref/jsref_getTimezoneOffset.asp
+ var offset = (new Date()).getTimezoneOffset();
+ if (offset < 0)
+ {
+ var sign = '+';
+ offset = -offset;
+ }
+ else
+ {
+ var sign = '-';
+ }
+ var minutes = offset % 60;
+ var hours = (offset - minutes) / 60;
+ if (hours < 10)
+ {
+ hours = '0' + hours.toString();
+ }
+ else
+ {
+ hours = hours.toString();
+ }
+ if (minutes < 10)
+ {
+ minutes = '0' + minutes.toString();
+ }
+ else
+ {
+ minutes = minutes.toString();
+ }
+ var prefix = 'GMT' + sign + hours + ':' + minutes;
+ var prefix_length = prefix.length;
+ for (var i = 0; i < selector.options.length; ++i)
+ {
+ var option = selector.options[i];
+ if (option.value.substring(0, prefix_length) == prefix)
+ {
+ // Firefox scrolls the selector only to put the option into view;
+ // for negative-offset timezones, this means the first timezone
+ // of a particular offset will be the bottom one, and selected,
+ // with all other timezones not visible. Not much can be done
+ // about that here unfortunately.
+ option.selected = true;
+ break;
+ }
+ }
+}
diff --git a/phpBB/styles/prosilver/template/ucp_prefs_personal.html b/phpBB/styles/prosilver/template/ucp_prefs_personal.html
index 635f321469..eae37b8021 100644
--- a/phpBB/styles/prosilver/template/ucp_prefs_personal.html
+++ b/phpBB/styles/prosilver/template/ucp_prefs_personal.html
@@ -75,7 +75,12 @@
<!-- ENDIF -->
<dl>
<dt><label for="timezone">{L_BOARD_TIMEZONE}:</label></dt>
- <dd><select name="tz" id="timezone" class="autowidth">{S_TZ_OPTIONS}</select></dd>
+ <dd>
+ <select name="tz" id="timezone" class="autowidth tz_select">
+ <option value="">{L_SELECT_TIMEZONE}</option>
+ {S_TZ_OPTIONS}
+ </select>
+ </dd>
</dl>
<dl>
<dt><label for="dst1">{L_BOARD_DST}:</label></dt>
@@ -141,4 +146,7 @@
// ]]>
</script>
+<script type="text/javascript" src="{T_SUPER_TEMPLATE_PATH}/timezone.js"></script>
+<script type="text/javascript">phpbb_preselect_tz_select();</script>
+
<!-- INCLUDE ucp_footer.html -->
diff --git a/phpBB/styles/prosilver/template/ucp_register.html b/phpBB/styles/prosilver/template/ucp_register.html
index dd0e5ad02a..542a860f23 100644
--- a/phpBB/styles/prosilver/template/ucp_register.html
+++ b/phpBB/styles/prosilver/template/ucp_register.html
@@ -59,7 +59,12 @@
</dl>
<dl>
<dt><label for="tz">{L_TIMEZONE}:</label></dt>
- <dd><select name="tz" id="tz" tabindex="7" class="autowidth">{S_TZ_OPTIONS}</select></dd>
+ <dd>
+ <select name="tz" id="tz" tabindex="7" class="autowidth tz_select">
+ <option value="">{L_SELECT_TIMEZONE}</option>
+ {S_TZ_OPTIONS}
+ </select>
+ </dd>
</dl>
<!-- IF .profile_fields -->
@@ -110,4 +115,7 @@
</div>
</form>
+<script type="text/javascript" src="{T_SUPER_TEMPLATE_PATH}/timezone.js"></script>
+<script type="text/javascript">phpbb_preselect_tz_select();</script>
+
<!-- INCLUDE overall_footer.html -->