mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
[feature/new-tz-handling] Fix timezone selection in subsilver2
PHPBB3-9558
This commit is contained in:
parent
4fbee37752
commit
a6bace039a
4 changed files with 121 additions and 10 deletions
95
phpBB/styles/subsilver2/template/timezone.js
Normal file
95
phpBB/styles/subsilver2/template/timezone.js
Normal file
|
@ -0,0 +1,95 @@
|
||||||
|
function phpbb_switch_tz_date(keep_selection)
|
||||||
|
{
|
||||||
|
var timezone_groups = document.getElementById("timezone");
|
||||||
|
for (var i = 0; i < timezone_groups.childElementCount; i++) {
|
||||||
|
if (timezone_groups.children[i].tagName == "OPTGROUP" &&
|
||||||
|
timezone_groups.children[i].label != document.getElementById("tz_date").value)
|
||||||
|
{
|
||||||
|
timezone_groups.children[i].style.display = "none";
|
||||||
|
}
|
||||||
|
else if (timezone_groups.children[i].tagName == "OPTGROUP")
|
||||||
|
{
|
||||||
|
// Display other options
|
||||||
|
timezone_groups.children[i].style.display = "block";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (typeof keep_selection !== 'undefined')
|
||||||
|
{
|
||||||
|
if (!keep_selection)
|
||||||
|
{
|
||||||
|
timezone_groups.children[0].selected = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function phpbb_enable_tz_dates()
|
||||||
|
{
|
||||||
|
var tz_select_date = document.getElementById("tz_select_date");
|
||||||
|
tz_select_date.style.display = "block";
|
||||||
|
}
|
||||||
|
|
||||||
|
function phpbb_preselect_tz_select(force_selector, l_suggestion)
|
||||||
|
{
|
||||||
|
|
||||||
|
var selector = document.getElementById('tz_date');
|
||||||
|
// 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)
|
||||||
|
{
|
||||||
|
if (selector.value && selector.value != option.value && !force_selector)
|
||||||
|
{
|
||||||
|
// We do not select the option for the user, but notify him,
|
||||||
|
// that we would suggest a different setting.
|
||||||
|
document.getElementById("tz_select_date_suggest").style.display = "inline";
|
||||||
|
document.getElementById("tz_select_date_suggest").title = l_suggestion.replace("%s", option.innerHTML);
|
||||||
|
document.getElementById("tz_select_date_suggest").innerHTML = l_suggestion.replace("%s", option.innerHTML.substring(0, 9));
|
||||||
|
phpbb_switch_tz_date(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 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;
|
||||||
|
phpbb_switch_tz_date(!force_selector);
|
||||||
|
document.getElementById("tz_select_date_suggest").style.display = "none";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
22
phpBB/styles/subsilver2/template/timezone_option.html
Normal file
22
phpBB/styles/subsilver2/template/timezone_option.html
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
<tr>
|
||||||
|
<td class="row1" width="50%"><b class="genmed">{L_BOARD_TIMEZONE}:</b></td>
|
||||||
|
<td class="row2">
|
||||||
|
<!-- IF S_TZ_DATE_OPTIONS -->
|
||||||
|
<div id="tz_select_date" style="display: none;">
|
||||||
|
<select name="tz_date" id="tz_date" class="autowidth tz_select" onchange="phpbb_switch_tz_date(false);">
|
||||||
|
<option value="">{L_SELECT_CURRENT_TIME}</option>
|
||||||
|
{S_TZ_DATE_OPTIONS}
|
||||||
|
</select><br />
|
||||||
|
<a id="tz_select_date_suggest" style="display: none;" href="javascript: phpbb_preselect_tz_select(true, '');">{L_TIMEZONE_DATE_SUGGESTION}</a><br />
|
||||||
|
</div>
|
||||||
|
<!-- ENDIF -->
|
||||||
|
<select name="tz" id="timezone" class="autowidth tz_select">
|
||||||
|
<option value="">{L_SELECT_TIMEZONE}</option>
|
||||||
|
{S_TZ_OPTIONS}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<script type="text/javascript" src="{T_SUPER_TEMPLATE_PATH}/timezone.js"></script>
|
||||||
|
<script type="text/javascript">phpbb_enable_tz_dates();</script>
|
||||||
|
<script type="text/javascript">phpbb_preselect_tz_select(<!-- IF S_REGISTRATION -->true<!-- ELSE -->false<!-- ENDIF -->, '{L_TIMEZONE_DATE_SUGGESTION}');</script>
|
||||||
|
</td>
|
||||||
|
</tr>
|
|
@ -71,12 +71,7 @@
|
||||||
<td class="row2"><select name="style">{S_STYLE_OPTIONS}</select></td>
|
<td class="row2"><select name="style">{S_STYLE_OPTIONS}</select></td>
|
||||||
</tr>
|
</tr>
|
||||||
<!-- ENDIF -->
|
<!-- ENDIF -->
|
||||||
<tr>
|
<!-- INCLUDE timezone_option.html -->
|
||||||
<td class="row1" width="50%"><b class="genmed">{L_BOARD_TIMEZONE}:</b></td>
|
|
||||||
<td class="row2">
|
|
||||||
<select id="tz" name="tz">{S_TZ_OPTIONS}</select>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class="row1" width="50%"><b class="genmed">{L_BOARD_DATE_FORMAT}:</b><br /><span class="gensmall">{L_BOARD_DATE_FORMAT_EXPLAIN}</span></td>
|
<td class="row1" width="50%"><b class="genmed">{L_BOARD_DATE_FORMAT}:</b><br /><span class="gensmall">{L_BOARD_DATE_FORMAT_EXPLAIN}</span></td>
|
||||||
<td class="row2">
|
<td class="row2">
|
||||||
|
|
|
@ -53,10 +53,9 @@
|
||||||
<td class="row1"><b class="genmed">{L_LANGUAGE}: </b></td>
|
<td class="row1"><b class="genmed">{L_LANGUAGE}: </b></td>
|
||||||
<td class="row2"><select name="lang" onchange="change_language(this.value); return false;">{S_LANG_OPTIONS}</select></td>
|
<td class="row2"><select name="lang" onchange="change_language(this.value); return false;">{S_LANG_OPTIONS}</select></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
|
||||||
<td class="row1"><b class="genmed">{L_TIMEZONE}: </b></td>
|
<!-- INCLUDE timezone_option.html -->
|
||||||
<td class="row2"><select name="tz">{S_TZ_OPTIONS}</select></td>
|
|
||||||
</tr>
|
|
||||||
<!-- IF .profile_fields -->
|
<!-- IF .profile_fields -->
|
||||||
<tr>
|
<tr>
|
||||||
<td class="row2" colspan="2"><span class="gensmall">{L_ITEMS_REQUIRED}</span></td>
|
<td class="row2" colspan="2"><span class="gensmall">{L_ITEMS_REQUIRED}</span></td>
|
||||||
|
|
Loading…
Add table
Reference in a new issue