aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2012-06-19 18:57:20 +0200
committerJoas Schilling <nickvergessen@gmx.de>2012-06-19 18:57:20 +0200
commit7b4f9765f8ab515c19d360818d7e57e5d6e47bd3 (patch)
tree9da2e208fbfb6ff1d0396363496034766850872e /phpBB
parent79a03909706d78efe6d49e88a0ac089186a65368 (diff)
downloadforums-7b4f9765f8ab515c19d360818d7e57e5d6e47bd3.tar
forums-7b4f9765f8ab515c19d360818d7e57e5d6e47bd3.tar.gz
forums-7b4f9765f8ab515c19d360818d7e57e5d6e47bd3.tar.bz2
forums-7b4f9765f8ab515c19d360818d7e57e5d6e47bd3.tar.xz
forums-7b4f9765f8ab515c19d360818d7e57e5d6e47bd3.zip
[feature/new-tz-handling] Move js functions into assets core.js
PHPBB3-9558
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/assets/javascript/core.js85
-rw-r--r--phpBB/styles/prosilver/template/timezone.js89
2 files changed, 87 insertions, 87 deletions
diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js
index 958b6c9ff6..ab1aaa8505 100644
--- a/phpBB/assets/javascript/core.js
+++ b/phpBB/assets/javascript/core.js
@@ -411,6 +411,91 @@ phpbb.ajaxify = function(options) {
return this;
}
+/**
+* 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.
+*/
+phpbb.timezone_switch_date = function(keep_selection) {
+ $('#timezone > optgroup').css('display', 'none');
+ $("#timezone > optgroup[label='" + $('#tz_date').val() + "']").css('display', 'block');
+
+ 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' && !keep_selection) {
+ $('#timezone > option:first').attr('selected', true);
+ }
+}
+
+/**
+* Display the date/time select
+*/
+phpbb.timezone_enable_date_selection = function() {
+ $('#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?
+*/
+phpbb.timezone_preselect_select = function(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.timezone_switch_date(true);
+ } else {
+ option.selected = true;
+ phpbb.timezone_switch_date(!force_selector);
+ $('#tz_select_date_suggest').css('display', 'none');
+ }
+ break;
+ }
+ }
+}
+
phpbb.ajax_callbacks = {};
/**
diff --git a/phpBB/styles/prosilver/template/timezone.js b/phpBB/styles/prosilver/template/timezone.js
index 30f4b87425..da0a2b0bfd 100644
--- a/phpBB/styles/prosilver/template/timezone.js
+++ b/phpBB/styles/prosilver/template/timezone.js
@@ -1,92 +1,5 @@
(function($) { // Avoid conflicts with other libraries
-/**
-* 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.
-*/
-phpbb.timezone_switch_date = function(keep_selection) {
- $('#timezone > optgroup').css('display', 'none');
- $("#timezone > optgroup[label='" + $('#tz_date').val() + "']").css('display', 'block');
-
- 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' && !keep_selection) {
- $('#timezone > option:first').attr('selected', true);
- }
-}
-
-/**
-* Display the date/time select
-*/
-phpbb.timezone_enable_date_selection = function() {
- $('#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?
-*/
-phpbb.timezone_preselect_select = function(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.timezone_switch_date(true);
- } else {
- option.selected = true;
- phpbb.timezone_switch_date(!force_selector);
- $('#tz_select_date_suggest').css('display', 'none');
- }
- break;
- }
- }
-}
-
-})(jQuery); // Avoid conflicts with other libraries
-
$('#tz_date').change(function() {
phpbb.timezone_switch_date(false);
});
@@ -102,3 +15,5 @@ $(document).ready(
$(document).ready(
phpbb.timezone_preselect_select($('#tz_select_date_suggest').attr('data-is-registration') == 'true')
);
+
+})(jQuery); // Avoid conflicts with other libraries