Files
BeWoPlaner/BeWoPlanerMobil/Scripts/utils.js
Christian cc642e9838 CB
2018-06-29 16:35:19 +02:00

80 lines
1.5 KiB
JavaScript

function makeAjaxCall(pType, pUrl, pSuccess, pData, pComplete) {
$.ajax({
type: pType,
url: pUrl,
data: pData,
success: pSuccess,
error: showAjaxError,
complete: pComplete
});
}
function removeElementFromArray(pArray, pKey) {
var newArray = {};
for(var key in pArray) {
var keyAsNumber = Number(key);
if(keyAsNumber !== pKey) {
newArray[keyAsNumber] = pArray[keyAsNumber];
}
}
return newArray;
}
function toggleLabel(inputId) {
var label = $('label[for="' + inputId + '"]');
var topValue;
if($('#' + inputId).is(":focus")) {
$(label).animate({ top: "-6px" }, 100);
return;
}
topValue = "12px";
if($('#' + inputId).val()) {
topValue = "-6px";
}
$(label).animate({ top: topValue }, 75);
}
function adjustLabel(inputId) {
var label = $('label[for="' + inputId + '"]');
var topValue;
topValue = "12px";
if($('#' + inputId).val()) {
topValue = "-6px";
}
$(label).animate({ top: topValue }, 75);
}
function isInEditingMode() {
return $("#isInEditModeIndicator").val() == "true";
}
function isElementInArray(array, element) {
try {
var contains = false;
array.forEach(function (e, index) {
if (e === element) {
contains = true;
}
});
return contains;
} catch (error) {
console.log(error.message);
return false;
}
}