2017-10-22 18:00:42 +00:00
|
|
|
if (typeof jQuery === 'undefined') {
|
|
|
|
throw new Error('Baby Buddy requires jQuery.')
|
|
|
|
}
|
2020-01-27 22:56:37 +00:00
|
|
|
if (typeof moment === 'undefined') {
|
|
|
|
throw new Error('Baby Buddy requires moment.js.')
|
|
|
|
}
|
2017-10-22 18:00:42 +00:00
|
|
|
|
2020-01-27 22:56:37 +00:00
|
|
|
/**
|
|
|
|
* Baby Buddy Namespace
|
|
|
|
*
|
|
|
|
* Default namespace for the Baby Buddy app.
|
2020-02-04 18:52:05 +00:00
|
|
|
*
|
|
|
|
* @type {{}}
|
2020-01-27 22:56:37 +00:00
|
|
|
*/
|
2017-10-22 18:00:42 +00:00
|
|
|
var BabyBuddy = function () {
|
2020-01-27 22:56:37 +00:00
|
|
|
return {};
|
2017-10-22 18:00:42 +00:00
|
|
|
}();
|
2020-01-27 22:56:37 +00:00
|
|
|
|
|
|
|
/**
|
2020-02-04 18:52:05 +00:00
|
|
|
* Datetime Picker.
|
2020-01-27 22:56:37 +00:00
|
|
|
*
|
|
|
|
* Provides modifications and defaults for the base datetime picker widget.
|
2020-02-04 18:52:05 +00:00
|
|
|
*
|
|
|
|
* @type {{init: BabyBuddy.DatetimePicker.init}}
|
2020-01-27 22:56:37 +00:00
|
|
|
*/
|
2023-03-25 19:57:12 +00:00
|
|
|
BabyBuddy.DatetimePicker = function (moment) {
|
2020-01-27 22:56:37 +00:00
|
|
|
return {
|
|
|
|
init: function (element, options) {
|
2023-03-25 19:57:12 +00:00
|
|
|
let defaultOptions = {
|
|
|
|
display: {
|
|
|
|
buttons: {
|
|
|
|
close: true,
|
|
|
|
today: true,
|
|
|
|
},
|
|
|
|
components: {
|
|
|
|
calendar: true,
|
|
|
|
clock: true,
|
|
|
|
date: true,
|
|
|
|
decades: true,
|
|
|
|
hours: true,
|
|
|
|
minutes: true,
|
|
|
|
month: true,
|
|
|
|
seconds: false,
|
|
|
|
useTwentyfourHour: false,
|
|
|
|
year: true,
|
|
|
|
},
|
|
|
|
icons: {
|
|
|
|
clear: 'icon-delete',
|
|
|
|
close: 'icon-cancel',
|
|
|
|
date: 'icon-calendar',
|
|
|
|
down: 'icon-arrow-down',
|
|
|
|
next: 'icon-angle-circled-right',
|
|
|
|
previous: 'icon-angle-circled-left',
|
|
|
|
time: 'icon-clock',
|
|
|
|
today: 'icon-today',
|
|
|
|
up: 'icon-arrow-up',
|
|
|
|
},
|
|
|
|
viewMode: 'clock',
|
|
|
|
},
|
|
|
|
localization: {
|
|
|
|
locale: moment.locale(),
|
2021-09-04 03:17:38 +00:00
|
|
|
},
|
2020-01-27 22:56:37 +00:00
|
|
|
};
|
2022-07-31 03:12:59 +00:00
|
|
|
|
2023-03-25 19:57:12 +00:00
|
|
|
new tempusDominus.TempusDominus(element, Object.assign(defaultOptions, options));
|
2020-01-27 22:56:37 +00:00
|
|
|
}
|
|
|
|
};
|
2023-03-25 19:57:12 +00:00
|
|
|
}(moment);
|
2020-02-04 18:52:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Pull to refresh.
|
|
|
|
*
|
|
|
|
* @type {{init: BabyBuddy.PullToRefresh.init, onRefresh: BabyBuddy.PullToRefresh.onRefresh}}
|
|
|
|
*/
|
|
|
|
BabyBuddy.PullToRefresh = function(ptr) {
|
|
|
|
return {
|
|
|
|
init: function () {
|
|
|
|
ptr.init({
|
|
|
|
mainElement: 'body',
|
|
|
|
onRefresh: this.onRefresh
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
onRefresh: function() {
|
|
|
|
window.location.reload();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}(PullToRefresh);
|
2020-10-28 17:58:47 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Fix for duplicate form submission from double pressing submit
|
|
|
|
*/
|
2022-07-13 14:44:42 +00:00
|
|
|
function preventDoubleSubmit() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
$('form').off("submit", preventDoubleSubmit);
|
2020-10-28 17:58:47 +00:00
|
|
|
$("form").on("submit", function() {
|
2022-07-13 14:44:42 +00:00
|
|
|
$(this).on("submit", preventDoubleSubmit);
|
|
|
|
});
|