-1) {
if($("#ctl00_panelLoggedOnTemplate").length && $("#ctl00_lnkProfile[href*='ProfileID=25'],#ctl00_lnkProfile[href*='ProfileID=132']").length){$("#indhold").prepend('Print alle Medlemskort');}
$("body").on("click",".membercard-link",function(e){e.preventDefault();var pid=$(this).attr("href").match(/ProfileID=(\d+)/)[1];window.open("/cms/clubploeks/medlemskort.html?teamid=2&profileid="+pid,"_blank");});
}
if (document.location.href.toLowerCase().indexOf('profilemaintenance') > -1) {
$("body").on("click","#ctl00_ContentPlaceHolderBody_ProfileMaintainance1_btnMemberCard",function(e){e.preventDefault();var pid=$(this).attr("href").match(/ProfileID=(\d+)/)[1];window.open("/cms/clubploeks/medlemskort.html?teamid=2&profileid="+pid,"_blank");});
}
if (document.location.href.toLowerCase().indexOf('newsarchiveoverview') > -1) {
function sortDescending(a, b) {
var date1 = $(a).find(".km-fullcard").attr('published');
date1 = date1.split('.');
date1 = new Date(date1[2], date1[1] -1, date1[0]);
var date2 = $(b).find(".km-fullcard").attr('published');
date2= date2.split('.');
date2= new Date(date2[2], date2[1] -1, date2[0]);
return date1 < date2 ? 1 : -1;
};
$(document).ready(function() {
$('#newsarchiveoverview .NewsArchiveItem').sort(sortDescending).appendTo('#newsarchiveoverview');
});
}
if (document.location.href.toLowerCase().indexOf('default.aspx') > -1) {
$(".GalleryWidgetPloeks").click(function(e) {
e.preventDefault();
window.location.href = "/cms/Gallery.aspx";
});
var r = 1;
$(".GalleryWidgetPloeks").each(function(){
var $this = $(this); // Store the reference to $(this) to maintain context
var slideCounter = 0; // Counter to track the number of slides added
var galleryItems = []; // Array to store image HTML to be added to Slick
$this.loadPage("../cms/include/api/gallery.aspx", function(response){
var rows = ( $.isNumeric($this.find(".rows").text().trim()) ) ? $this.find(".rows").text().trim() : 1;
var items = ( $.isNumeric($this.find(".items").text().trim()) ) ? $this.find(".items").text().trim() : 1;
var rowitems = items;
var height = ( $.isNumeric($this.find(".height").text().trim()) ) ? $this.find(".height").text().trim() : 300;
var width = ($this.find(".width").text().trim().length > 1) ? $this.find(".width").text().trim() : '100%';
var speed = ( $.isNumeric($this.find(".speed").text().trim()) ) ? $this.find(".speed").text().trim() : 5000;
var scrollspeed = ( $.isNumeric($this.find(".scrollspeed").text().trim()) ) ? $this.find(".scrollspeed").text().trim() : 3000;
var type = ($this.find(".type").text().trim().length > 1) ? $this.find(".type").text().trim() : true;
var color = ($this.find(".color").text().trim().length > 1) ? "background-color: " + $this.find(".color").text().trim() + ";" : "";
var image = ($this.find(".image").text().trim() == "original") ? "background-size: contain; background-repeat: no-repeat;" : "";
var category = ($this.find(".category").text().trim().length > 1) ? "[cat='" + $this.find(".category").text().trim() + "']" : "";
if (type === "scroll") {
type = false;
}
else {
type = true;
}
$this.find("table").remove();
if (rows > 1) {
$this.addClass("rows")
rowitems = 1;
}
if (rows == 1 && type == true) {
items = 1;
rowitems = 1;
}
$(response).find("a" + category).each(function(index) {
var href = $(this).attr("href");
var src = $(this).find("img").attr("lazy");
if(src != "") {
galleryItems.push("");
}
});
// Slick initialization options
var slickOptions = {
dots: false,
autoplay: true,
infinite: true,
arrows: false,
slidesPerRow: items,
rows: rows,
fade: type,
autoplaySpeed: speed,
speed: scrollspeed,
slidesToShow: rowitems,
slidesToScroll: 1,
responsive: [
{
breakpoint: 480,
settings: {
slidesPerRow: 1,
rows: 1,
}
}]
};
// Initialize Slick
var slider = $this; // Use $this instead of $(this)
slider.on('init', function(event, slick){
//console.log("Slick initialized");
});
slider.on('afterChange', function(event, slick, currentSlide) {
loadNextImage();
});
slider.slick(slickOptions);
var startSlick = 0;
// Function to handle loading of each image
function handleImageLoad(html) {
$(html).find("img").on('load', function() {
//console.log(startSlick)
var aspectRatio = this.naturalWidth / this.naturalHeight;
var index = $(html).find("img").index(this);
//console.log("Item " + (index + 1) + ": " + aspectRatio);
if (aspectRatio < 1) {
//console.log("Skipping item " + (index + 1) + " due to portrait aspect ratio.");
loadNextImage();
} else {
startSlick++
slider.slick('slickAdd', html);
if (startSlick == 2) { // Change 10 to your desired value
slider.slick('unslick'); // Unslick the slider
slider.slick(slickOptions); // Reinitialize Slick
loadNextImage();
//startSlick++
}
}
});
}
// Load each image one by one
function loadNextImage() {
if (galleryItems.length > 0) {
var nextHtml = galleryItems.shift();
handleImageLoad(nextHtml);
}
}
// Load the initial images
for (var i = 0; i < 3; i++) {
loadNextImage();
}
});
});
$("html #body").addClass("frontpage");
$(".hideOnSub").show();
$(".hideOnFront").remove();
}
});
/* WINDOW LOAD */
$(window).load(function() {
/* CLUBNAME ON MOBILE DEVICES */
if($("#menuHeaderClubName") && $("#menuHeaderClubName").html().length >= 15) {
$("#menuHeaderClubName").css({
"font-size": "14px",
"line-height": "16px"
});
}
$("#tripleboxes").lazy({
viewport: function(img) {
var load_url = location.protocol + "//" + location.host + "/cms/ShowContentPage.aspx?ContentPageID=78";
$("#tripleboxes").loadPage(load_url, function(response){
var html = "";
$(response).find("#ctl00_ContentPlaceHolderBody_lblPageContent a").each(function() {
var img = ($(this).find("img").length != 0) ? $(this).find("img") : "";
var src = (img != "" && img.attr("lazy") != "") ? img.attr("lazy") : "";
var href = $(this).attr("href");
html += ' Læs mere ';
});
$("#spotslide").append(html);
$('#spotslide').slick({
dots: false,
autoplay: true,
infinite: true,
arrows: true,
prevArrow: '#news .prev',
nextArrow: '#news .next',
autoplaySpeed: 6000,
speed: 1300,
slidesToShow: 3,
slidesToScroll: 1,
responsive: [{
breakpoint: 1024,
settings: {
slidesToShow: 2,
slidesToScroll: 1
}
},
{
breakpoint: 600,
settings: {
slidesToShow: 1,
slidesToScroll: 1
}
},
{
breakpoint: 480,
settings: {
slidesToShow: 1,
slidesToScroll: 1
}
}]
});
});
}
});
$("body #sponsors").lazy({
viewport: function(img) {
var load_url = location.protocol + "//" + location.host + "/cms/cmsbannerandsponsoriframe.aspx?issponsor=true";
$("body #sponsors").loadPage(load_url, function(response){
var html = "";
$(response).find("#indhold img").each(function(){
var img = ($(this).attr("lazy") != undefined) ? $(this).attr("lazy") : "";
var link = "";
if ($(this).parent().is("a")) {
link = $(this).parent().attr("href");
} else {
link = "#";
}
link = (typeof link == "undefined" || link == "undefined") ? "" : link;
html += "";
});
$("#sponsor-slider").append(html);
$('#sponsor-slider').slick({
dots: false,
autoplay: true,
infinite: true,
arrows: false,
prevArrow: '.prev',
nextArrow: '.next',
autoplaySpeed: 3000,
speed: 300,
slidesToShow: 3,
slidesToScroll: 3,
responsive: [{
breakpoint: 1024,
settings: {
slidesToShow: 2,
slidesToScroll: 2
}
},
{
breakpoint: 600,
settings: {
slidesToShow: 2,
slidesToScroll: 2
}
},
{
breakpoint: 480,
settings: {
slidesToShow: 1,
slidesToScroll: 1
}
}]
});
});
}
});
});
|