aboutsummaryrefslogtreecommitdiff
path: root/resources/assets/javascripts/studip-ui.js
diff options
context:
space:
mode:
Diffstat (limited to 'resources/assets/javascripts/studip-ui.js')
-rw-r--r--resources/assets/javascripts/studip-ui.js252
1 files changed, 129 insertions, 123 deletions
diff --git a/resources/assets/javascripts/studip-ui.js b/resources/assets/javascripts/studip-ui.js
index 897604a..cc9f61e 100644
--- a/resources/assets/javascripts/studip-ui.js
+++ b/resources/assets/javascripts/studip-ui.js
@@ -45,140 +45,146 @@ import Timepicker from './studip-ui/time-picker.js';
'use strict';
// Exit if datepicker is undefined (which it should never be)
- if ($.datepicker === undefined) {
+ if (!Datepicker.supportsNativeInput && $.datepicker === undefined) {
return;
}
- // Setup defaults and default locales
- var defaults = {},
- locale = {
- closeText: $gettext('Schließen'),
- prevText: $gettext('Zurück'),
- nextText: $gettext('Vor'),
- currentText: $gettext('Jetzt'),
- monthNames: [
- $gettext('Januar'),
- $gettext('Februar'),
- $gettext('März'),
- $gettext('April'),
- $gettext('Mai'),
- $gettext('Juni'),
- $gettext('Juli'),
- $gettext('August'),
- $gettext('September'),
- $gettext('Oktober'),
- $gettext('November'),
- $gettext('Dezember')
- ],
- monthNamesShort: [
- $gettext('Jan'),
- $gettext('Feb'),
- $gettext('Mär'),
- $gettext('Apr'),
- $gettext('Mai'),
- $gettext('Jun'),
- $gettext('Jul'),
- $gettext('Aug'),
- $gettext('Sep'),
- $gettext('Okt'),
- $gettext('Nov'),
- $gettext('Dez')
- ],
- dayNames: [
- $gettext('Sonntag'),
- $gettext('Montag'),
- $gettext('Dienstag'),
- $gettext('Mittwoch'),
- $gettext('Donnerstag'),
- $gettext('Freitag'),
- $gettext('Samstag')
- ],
- dayNamesShort: [
- $gettext('So'),
- $gettext('Mo'),
- $gettext('Di'),
- $gettext('Mi'),
- $gettext('Do'),
- $gettext('Fr'),
- $gettext('Sa')
- ],
- weekHeader: $gettext('Wo'),
- dateFormat: 'dd.mm.yy',
- firstDay: 1,
- isRTL: false,
- showMonthAfterYear: false,
- yearSuffix: '',
- changeMonth: true,
- changeYear: true,
- };
- // Set dayNamesMin to dayNamesShort since they are equal
- locale.dayNamesMin = locale.dayNamesShort;
-
-
- // Apply defaults including date picker handlers
- defaults = Object.assign({}, locale, {
- beforeShow (input) {
- DatePicker.refresh();
-
- if ($(input).parents('.ui-dialog').length > 0) {
- return;
+ if (!Datepicker.supportsNativeInput) {
+ // Setup defaults and default locales
+ var defaults = {},
+ locale = {
+ closeText: $gettext('Schließen'),
+ prevText: $gettext('Zurück'),
+ nextText: $gettext('Vor'),
+ currentText: $gettext('Jetzt'),
+ monthNames: [
+ $gettext('Januar'),
+ $gettext('Februar'),
+ $gettext('März'),
+ $gettext('April'),
+ $gettext('Mai'),
+ $gettext('Juni'),
+ $gettext('Juli'),
+ $gettext('August'),
+ $gettext('September'),
+ $gettext('Oktober'),
+ $gettext('November'),
+ $gettext('Dezember')
+ ],
+ monthNamesShort: [
+ $gettext('Jan'),
+ $gettext('Feb'),
+ $gettext('Mär'),
+ $gettext('Apr'),
+ $gettext('Mai'),
+ $gettext('Jun'),
+ $gettext('Jul'),
+ $gettext('Aug'),
+ $gettext('Sep'),
+ $gettext('Okt'),
+ $gettext('Nov'),
+ $gettext('Dez')
+ ],
+ dayNames: [
+ $gettext('Sonntag'),
+ $gettext('Montag'),
+ $gettext('Dienstag'),
+ $gettext('Mittwoch'),
+ $gettext('Donnerstag'),
+ $gettext('Freitag'),
+ $gettext('Samstag')
+ ],
+ dayNamesShort: [
+ $gettext('So'),
+ $gettext('Mo'),
+ $gettext('Di'),
+ $gettext('Mi'),
+ $gettext('Do'),
+ $gettext('Fr'),
+ $gettext('Sa')
+ ],
+ weekHeader: $gettext('Wo'),
+ dateFormat: 'dd.mm.yy',
+ firstDay: 1,
+ isRTL: false,
+ showMonthAfterYear: false,
+ yearSuffix: '',
+ changeMonth: true,
+ changeYear: true,
+ };
+ // Set dayNamesMin to dayNamesShort since they are equal
+ locale.dayNamesMin = locale.dayNamesShort;
+
+
+ // Apply defaults including date picker handlers
+ defaults = Object.assign({}, locale, {
+ beforeShow (input) {
+ Datepicker.refresh();
+
+ if ($(input).parents('.ui-dialog').length > 0) {
+ return;
+ }
+
+ $(input).css({
+ 'position': 'relative',
+ 'z-index': 1002
+ });
+ },
+ onSelect: function (value, instance) {
+ if (value !== instance.lastVal) {
+ $(this).change();
+ }
}
-
- $(input).css({
- 'position': 'relative',
- 'z-index': 1002
- });
- },
- onSelect: function (value, instance) {
- if (value !== instance.lastVal) {
- $(this).change();
+ });
+
+ $.datepicker.setDefaults(Object.assign({}, defaults, {
+ beforeShow (input) {
+ // Don't lose original behaviour
+ defaults.beforeShow(input);
+
+ if ($(input).parents('.ui-dialog').length > 0) {
+ $('.ui-dialog-content').bind('scroll.datepicker-scroll', _.debounce($.proxy(DpHideOnScroll, null, input), 100, {leading:true, trailing:false}));
+ }
+ $(window).bind('scroll.datepicker-scroll', _.debounce($.proxy(DpHideOnScroll, null, input), 100, {leading:true, trailing:false}));
+
+ if ($(input).closest('#sidebar').length === 0) {
+ return;
+ }
+
+ const button = input.nextElementSibling;
+ if (button && button.matches('input[type="submit"]')) {
+ button.style.position = 'relative';
+ button.style.zIndex = input.style.zIndex;
+ }
+ },
+ onClose (date, inst) {
+ $(this).one('click.picker', function () {
+ $(this).datepicker('show');
+ }).on('blur', function () {
+ $(this).off('click.picker');
+ });
+
+ if ($(this).parents('.ui-dialog').length > 0) {
+ $('.ui-dialog-content').unbind('scroll.datepicker-scroll');
+ } else {
+ $(window).unbind('scroll.datepicker-scroll');
+ }
}
- }
- });
+ }));
- $.datepicker.setDefaults(Object.assign({}, defaults, {
- beforeShow (input) {
- // Don't lose original behaviour
- defaults.beforeShow(input);
-
- if ($(input).parents('.ui-dialog').length > 0) {
- $('.ui-dialog-content').bind('scroll.datepicker-scroll', _.debounce($.proxy(DpHideOnScroll, null, input), 100, {leading:true, trailing:false}));
- }
- $(window).bind('scroll.datepicker-scroll', _.debounce($.proxy(DpHideOnScroll, null, input), 100, {leading:true, trailing:false}));
-
- if ($(input).closest('#sidebar').length === 0) {
- return;
- }
-
- const button = input.nextElementSibling;
- if (button && button.matches('input[type="submit"]')) {
- button.style.position = 'relative';
- button.style.zIndex = input.style.zIndex;
- }
- },
- onClose (date, inst) {
- $(this).one('click.picker', function () {
- $(this).datepicker('show');
- }).on('blur', function () {
- $(this).off('click.picker');
- });
-
- if ($(this).parents('.ui-dialog').length > 0) {
- $('.ui-dialog-content').unbind('scroll.datepicker-scroll');
- } else {
- $(window).unbind('scroll.datepicker-scroll');
- }
+ var DpHideOnScroll = function () {
+ var input = arguments[0];
+ $(input).blur();
+ $(input).datepicker('hide');
}
- }));
-
- var DpHideOnScroll = function () {
- var input = arguments[0];
- $(input).blur();
- $(input).datepicker('hide');
}
// Attach global focus handler on date picker elements
$(document).on('focus', Datepicker.selector, () => {
+ if (!$(event.target).is('input[type="date"]')) {
+ $(event.target).attr('type', 'date');
+ }
+
Datepicker.init();
});