2024-02-06 08:26:41 +00:00
|
|
|
if (typeof jQuery === "undefined") {
|
|
|
|
throw new Error("Baby Buddy requires jQuery.");
|
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
|
|
|
*/
|
2024-02-06 08:26:41 +00:00
|
|
|
var BabyBuddy = (function () {
|
|
|
|
return {};
|
|
|
|
})();
|
2020-01-27 22:56:37 +00:00
|
|
|
|
2020-02-04 18:52:05 +00:00
|
|
|
/**
|
|
|
|
* Pull to refresh.
|
|
|
|
*
|
|
|
|
* @type {{init: BabyBuddy.PullToRefresh.init, onRefresh: BabyBuddy.PullToRefresh.onRefresh}}
|
|
|
|
*/
|
2024-02-06 08:26:41 +00:00
|
|
|
BabyBuddy.PullToRefresh = (function (ptr) {
|
|
|
|
return {
|
|
|
|
init: function () {
|
|
|
|
ptr.init({
|
|
|
|
mainElement: "body",
|
|
|
|
onRefresh: this.onRefresh,
|
|
|
|
});
|
|
|
|
},
|
2020-02-04 18:52:05 +00:00
|
|
|
|
2024-02-06 08:26:41 +00:00
|
|
|
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() {
|
2024-02-06 08:26:41 +00:00
|
|
|
return false;
|
2022-07-13 14:44:42 +00:00
|
|
|
}
|
2024-02-06 08:26:41 +00:00
|
|
|
$("form").off("submit", preventDoubleSubmit);
|
|
|
|
$("form").on("submit", function () {
|
|
|
|
$(this).on("submit", preventDoubleSubmit);
|
2022-07-13 14:44:42 +00:00
|
|
|
});
|
2024-02-07 07:11:52 +00:00
|
|
|
|
|
|
|
BabyBuddy.RememberAdvancedToggle = function (ptr) {
|
|
|
|
localStorage.setItem("advancedForm", event.newState);
|
|
|
|
};
|
|
|
|
|
|
|
|
(function toggleAdvancedFields() {
|
|
|
|
window.addEventListener("load", function () {
|
|
|
|
if (localStorage.getItem("advancedForm") !== "open") {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
document.querySelectorAll(".advanced-fields").forEach(function (node) {
|
|
|
|
node.open = true;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
})();
|