diff options
| -rw-r--r-- | phpBB/adm/style/timezone.js | 40 | ||||
| -rw-r--r-- | phpBB/adm/style/timezone_option.html | 2 | ||||
| -rw-r--r-- | phpBB/styles/subsilver2/template/timezone.js | 117 | ||||
| -rw-r--r-- | phpBB/styles/subsilver2/template/timezone_option.html | 6 |
4 files changed, 24 insertions, 141 deletions
diff --git a/phpBB/adm/style/timezone.js b/phpBB/adm/style/timezone.js index d1667699da..4556ea5f94 100644 --- a/phpBB/adm/style/timezone.js +++ b/phpBB/adm/style/timezone.js @@ -1,35 +1,11 @@ -/** -* Hide the optgroups that are not the selected timezone -* -* @param bool keep_selection Shall we keep the value selected, or shall the user be forced to repick one. -*/ -function phpbb_switch_tz_date(keep_selection) -{ - $('#timezone > optgroup').css("display", "none"); - $("#timezone > optgroup[label='" + $('#tz_date').val() + "']").css("display", "block"); +(function($) { // Avoid conflicts with other libraries - if ($("#timezone > optgroup[label='" + $('#tz_date').val() + "'] > option").size() == 1) - { - // If there is only one timezone for the selected date, we just select that automatically. - $("#timezone > optgroup[label='" + $('#tz_date').val() + "'] > option:first").attr("selected", true); - keep_selection = true; - } +$('#tz_date').change(function() { + phpbb.timezone_switch_date(false); +}); - if (typeof keep_selection !== 'undefined') - { - if (!keep_selection) - { - $('#timezone > option:first').attr("selected", true); - } - } -} +$(document).ready( + phpbb.timezone_enable_date_selection +); -/** -* Display the date/time select -*/ -function phpbb_enable_tz_dates() -{ - $('#tz_select_date').css("display", "block"); -} - -phpbb_enable_tz_dates(); +})(jQuery); // Avoid conflicts with other libraries diff --git a/phpBB/adm/style/timezone_option.html b/phpBB/adm/style/timezone_option.html index e12219b1c0..23c0ee19e9 100644 --- a/phpBB/adm/style/timezone_option.html +++ b/phpBB/adm/style/timezone_option.html @@ -2,7 +2,7 @@ <dt><label for="timezone">{L_BOARD_TIMEZONE}:</label></dt> <!-- IF S_TZ_DATE_OPTIONS --> <dd id="tz_select_date" style="display: none;"> - <select name="tz_date" id="tz_date" class="autowidth tz_select" onchange="phpbb_switch_tz_date(false);"> + <select name="tz_date" id="tz_date" class="autowidth tz_select"> <option value="">{L_SELECT_CURRENT_TIME}</option> {S_TZ_DATE_OPTIONS} </select> diff --git a/phpBB/styles/subsilver2/template/timezone.js b/phpBB/styles/subsilver2/template/timezone.js index b8d3c2f152..da0a2b0bfd 100644 --- a/phpBB/styles/subsilver2/template/timezone.js +++ b/phpBB/styles/subsilver2/template/timezone.js @@ -1,108 +1,19 @@ -/** -* Hide the optgroups that are not the selected timezone -* -* @param bool keep_selection Shall we keep the value selected, or shall the user be forced to repick one. -*/ -function phpbb_switch_tz_date(keep_selection) -{ - $('#timezone > optgroup').css("display", "none"); - $("#timezone > optgroup[label='" + $('#tz_date').val() + "']").css("display", "block"); +(function($) { // Avoid conflicts with other libraries - if ($("#timezone > optgroup[label='" + $('#tz_date').val() + "'] > option").size() == 1) - { - // If there is only one timezone for the selected date, we just select that automatically. - $("#timezone > optgroup[label='" + $('#tz_date').val() + "'] > option:first").attr("selected", true); - keep_selection = true; - } - - if (typeof keep_selection !== 'undefined') - { - if (!keep_selection) - { - $('#timezone > option:first').attr("selected", true); - } - } -} - -/** -* Display the date/time select -*/ -function phpbb_enable_tz_dates() -{ - $('#tz_select_date').css("display", "block"); -} - -/** -* Preselect a date/time or suggest one, if it is not picked. -* -* @param bool force_selector Shall we select the suggestion? -*/ -function phpbb_preselect_tz_select(force_selector) -{ - - // 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; - - var selector_options = $('#tz_date > option'); - for (var i = 0; i < selector_options.length; ++i) - { - var option = selector_options[i]; - if (option.value.substring(0, prefix_length) == prefix) - { - if ($('#tz_date').val() != option.value && !force_selector) - { - // We do not select the option for the user, but notify him, - // that we would suggest a different setting. - $('#tz_select_date_suggest').css("display", "inline"); - $('#tz_select_date_suggest').attr("title", $('#tz_select_date_suggest').attr('data-l-suggestion').replace("%s", option.innerHTML)); - $('#tz_select_date_suggest').attr("value", $('#tz_select_date_suggest').attr('data-l-suggestion').replace("%s", option.innerHTML.substring(0, 9))); - phpbb_switch_tz_date(true); - } - else - { - option.selected = true; - phpbb_switch_tz_date(!force_selector); - $('#tz_select_date_suggest').css("display", "none"); - } - break; - } - } -} +$('#tz_date').change(function() { + phpbb.timezone_switch_date(false); +}); $('#tz_select_date_suggest').click(function(){ - phpbb_preselect_tz_select(true, ''); + phpbb.timezone_preselect_select(true); }); -phpbb_enable_tz_dates(); -phpbb_preselect_tz_select($('#tz_select_date_suggest').attr('data-is-registration') == "true"); +$(document).ready( + phpbb.timezone_enable_date_selection +); + +$(document).ready( + phpbb.timezone_preselect_select($('#tz_select_date_suggest').attr('data-is-registration') == 'true') +); + +})(jQuery); // Avoid conflicts with other libraries diff --git a/phpBB/styles/subsilver2/template/timezone_option.html b/phpBB/styles/subsilver2/template/timezone_option.html index affeee91ac..3f1e14b33d 100644 --- a/phpBB/styles/subsilver2/template/timezone_option.html +++ b/phpBB/styles/subsilver2/template/timezone_option.html @@ -3,7 +3,7 @@ <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);"> + <select name="tz_date" id="tz_date" class="autowidth tz_select"> <option value="">{L_SELECT_CURRENT_TIME}</option> {S_TZ_DATE_OPTIONS} </select><br /> @@ -15,10 +15,6 @@ {S_TZ_OPTIONS} </select> - <script type="text/javascript"> - var is_registration = <!-- IF S_REGISTRATION -->true<!-- ELSE -->false<!-- ENDIF -->; - var l_timezone_date_suggestion = "{L_TIMEZONE_DATE_SUGGESTION}"; - </script> <!-- INCLUDEJS template/timezone.js --> </td> </tr> |
