Files
LeafWeb/WebCms/scripts/site.js
T
2019-12-15 21:18:51 -05:00

139 lines
3.6 KiB
JavaScript

(function($) {
// disable anchors in menu links which are disabled
$("li.disabled a").click(function () {
return false;
});
$("form.confirm").submit(function () {
var form = this;
var text = "Confirm";
var confirmMsg = $(form).attr("confirm-msg");
if (confirmMsg) {
text = confirmMsg;
}
$("<div>" + text + "</div>")
.dialog({
title: "Confirm", // title
buttons: {
"Confirm": function () {
form.submit();
},
"Cancel": function () {
$(this).dialog("close");
}
}
});
return false;
});
/*
// Making elements equal height
var equalheight = function(container){
var currentTallest = 0,
currentRowStart = 0,
rowDivs = new Array(),
$el,
topPosition = 0;
$(container).find('.equal').each(function() {
$el = $(this);
$($el).height('auto');
topPostion = $el.position().top;
if (currentRowStart !== topPostion) {
for (currentDiv = 0; currentDiv < rowDivs.length; currentDiv++) {
rowDivs[currentDiv].height(currentTallest);
}
rowDivs.length = 0; // empty the array
currentRowStart = topPostion;
currentTallest = $el.height();
rowDivs.push($el);
} else {
rowDivs.push($el);
currentTallest = (currentTallest < $el.height()) ? ($el.height()) : (currentTallest);
}
for (currentDiv = 0; currentDiv < rowDivs.length; currentDiv++) {
rowDivs[currentDiv].height(currentTallest);
}
});
};
// Check for window width before resizing
function equalHeightChecker () {
if ( window.innerWidth > 767 && !heightIsSet ) {
$('.equalizer')
.each(function(){
equalheight(this);
heightIsSet = true;
});
}
else if (window.innerWidth<768 && heightIsSet) {
$('.equalizer')
.each(function(){
$(this).find('.equal').each(function () {
this.style.height = 'auto';
});
heightIsSet = false;
});
}
}
// Initialize equal height script
var heightIsSet;
// On load
$(window).on('load', function() {
equalHeightChecker();
});
// and on resize
$(window).on('resize', function(){
equalHeightChecker();
});
// Navigation
$('#toggle').click(function(){
$('.has-child').removeClass('selected');
$('nav').toggleClass('open');
$('.cross').toggleClass('open');
});
$('.has-child').click(function(){
if ( window.innerWidth < 768 ) {
if ( $( this ).hasClass('selected')){
$('.has-child').removeClass('selected');
} else {
$('.has-child').removeClass('selected');
$(this).toggleClass('selected');
}
}
}); */
$(".read-more")
.click(function () {
var control = $(this).attr('readcontrol');
$("#" + control).toggleClass("read-less");
if ($(this).text() === "Show Less")
$(this).text("Show More");
else
$(this).text("Show Less");
return false;
});
// https://stackoverflow.com/a/58215644/99492
$.validator.setDefaults({
errorClass: "",
validClass: "",
highlight: function (element, errorClass, validClass) {
$(element).addClass("is-invalid").removeClass("is-valid");
$(element.form).find("[data-valmsg-for=" + element.id + "]").addClass("invalid-feedback");
},
unhighlight: function (element, errorClass, validClass) {
$(element).addClass("is-valid").removeClass("is-invalid");
$(element.form).find("[data-valmsg-for=" + element.id + "]").removeClass("invalid-feedback");
}
});
})(jQuery);