112 lines
2.3 KiB
JavaScript
112 lines
2.3 KiB
JavaScript
function showSpinner() {
|
|
$("#mySpinner").modal(
|
|
{
|
|
backdrop: "static",
|
|
keyboard: false
|
|
}
|
|
);
|
|
}
|
|
|
|
function hideSpinner() {
|
|
$("#mySpinner").modal("hide");
|
|
}
|
|
|
|
function showMessagePopup(title, message) {
|
|
$("#popupTitle").text(title);
|
|
$("#popupMessage").text(message);
|
|
|
|
$("#messagePopup").modal(
|
|
{
|
|
backdrop: "static",
|
|
keyboard: false
|
|
}
|
|
);
|
|
}
|
|
|
|
function showMessagePopupWithCallback(title, message, callback, executeCallbackByBothButtons) {
|
|
$("#popupTitle").text(title);
|
|
$("#popupMessage").text(message);
|
|
|
|
$("#message-popup-ok-btn").on("click", function() {
|
|
callback();
|
|
});
|
|
|
|
if (executeCallbackByBothButtons === true) {
|
|
$("#message-popup-close-btn").on("click",
|
|
function() {
|
|
callback();
|
|
});
|
|
}
|
|
|
|
$("#messagePopup").modal(
|
|
{
|
|
backdrop: "static",
|
|
keyboard: false
|
|
}
|
|
);
|
|
}
|
|
|
|
function submitForm(submitButton) {
|
|
if(hasEmptyRequiredFields($(submitButton.form))) {
|
|
return;
|
|
}
|
|
|
|
showSpinner();
|
|
submitButton.form.submit();
|
|
}
|
|
|
|
function isEmptyOrSpaces(str) {
|
|
return str === null || str === undefined || str.match(/^ *$/) !== null;
|
|
}
|
|
|
|
function isInArray(value, array) {
|
|
if(value === undefined || value === null || array === undefined || array === null) {
|
|
return false;
|
|
}
|
|
|
|
if(!Array.isArray(array)) {
|
|
return false;
|
|
}
|
|
|
|
var intValue = parseInt(value, 10);
|
|
|
|
if(isNaN(intValue)) {
|
|
return false;
|
|
}
|
|
|
|
for (var i = 0; i < array.length; i++) {
|
|
if (array[i] === intValue) {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
function showMessagePopupWithHtml(title, html) {
|
|
$("#popupTitle").text(title);
|
|
$("#popupMessage").html(html);
|
|
|
|
$("#messagePopup").modal(
|
|
{
|
|
backdrop: "static",
|
|
keyboard: false
|
|
}
|
|
);
|
|
}
|
|
|
|
function hasEmptyRequiredFields(form) {
|
|
var count = 0;
|
|
|
|
form.each(function() {
|
|
var requiredElements = $(this, "input, textarea, select").find("[required]");
|
|
|
|
requiredElements.each(function(index, element) {
|
|
if ($(element).val().length === 0) {
|
|
count++;
|
|
}
|
|
});
|
|
});
|
|
|
|
return count > 0;
|
|
} |