1$(document).ready(function () { 2 $('.page-slider').each(function () { 3 const slider = $(this); 4 const pagination = slider.find('.page-slider-pagination'); 5 const wrapper = slider.find('.page-slider-wrapper'); 6 let autoSwitchInterval; 7 let isAutoSwitchEnabled = true; 8 9 pagination.data('stop-type', ''); 10 11 function changeSlide(newElement, disableAutoSwitch = false, stopType = '') { 12 if (disableAutoSwitch) 13 { 14 clearInterval(autoSwitchInterval); 15 isAutoSwitchEnabled = false; 16 } 17 18 if (stopType) 19 { 20 pagination.data('stop-type', stopType); 21 } 22 23 const currentPage = parseInt(newElement.html()); 24 const originalPage = parseInt(pagination.find('a.act').html()); 25 pagination.find('a.act').removeClass('act'); 26 newElement.addClass('act'); 27 wrapper.find(`.page-slider-content:nth-child(${originalPage})`) 28 .css('z-index', '1') 29 .fadeOut(function () { 30 wrapper.find(`.page-slider-content:nth-child(${currentPage})`) 31 .css('z-index', '10') 32 .fadeIn(); 33 }); 34 } 35 36 function startAutoSwitch() { 37 const autoSwitchValue = pagination.data('autoswitch') * 1000; 38 autoSwitchInterval = setInterval(() => { 39 if (!isAutoSwitchEnabled) return; 40 41 const activeButton = pagination.find('a.act'); 42 const maxSlide = parseInt(pagination.data('count')); 43 44 const currentPage = parseInt(activeButton.attr('rel')) || 1; 45 const nextPage = (currentPage % maxSlide) + 1; 46 47 const nextButton = pagination.find(`a[rel="${nextPage}"]`); 48 changeSlide(nextButton); 49 }, autoSwitchValue); 50 } 51 52 wrapper.find('.page-slider-content img').on('mouseover', function () { 53 clearInterval(autoSwitchInterval); 54 isAutoSwitchEnabled = false; 55 if(pagination.data('stop-type') !== 'click') 56 { 57 pagination.data('stop-type', 'mouseover'); 58 } 59 }); 60 61 wrapper.find('.page-slider-content img').on('mouseout', function () { 62 if (pagination.data('stop-type') === 'mouseover') { 63 isAutoSwitchEnabled = true; 64 startAutoSwitch(); 65 } 66 }); 67 68 pagination.find('a.toc').on('click', function () { 69 changeSlide($(this), true, 'click'); 70 }); 71 72 pagination.find('.next').on('click', function () { 73 const current = parseInt(pagination.find('a.act').html()); 74 const maxSlide = parseInt(pagination.data('count')); 75 let currentPage = current + 1; 76 if (currentPage > maxSlide) { 77 currentPage = 1; 78 } 79 const selector = pagination.find(`a:nth-child(${currentPage + 1})`); 80 changeSlide(selector, true, 'click'); 81 }); 82 83 pagination.find('.prev').on('click', function () { 84 const current = parseInt(pagination.find('a.act').html()); 85 const maxSlide = parseInt(pagination.data('count')); 86 let currentPage = current - 1; 87 if (currentPage <= 0) { 88 currentPage = maxSlide; 89 } 90 const selector = pagination.find(`a:nth-child(${currentPage + 1})`); 91 changeSlide(selector, true, 'click'); 92 }); 93 if(pagination.length > 0) 94 { 95 startAutoSwitch(); 96 } 97 98 function loadMaxImageHeight() { 99 const imageSources = wrapper.find('.page-slider-image').map(function () { 100 return $(this).attr('src'); 101 }).get(); 102 103 let maxHeight = 0; 104 let loadedImages = 0; 105 106 const sliderWidth = slider.width(); 107 108 imageSources.forEach(src => { 109 const img = new Image(); 110 img.src = src; 111 img.onload = function () {
112 const aspectRatio = img.height / img.width; 113 const adjustedHeight = Math.min(img.height, Math.floor(sliderWidth * aspectRatio)); 114 115 if (adjustedHeight > maxHeight) { 116 maxHeight = adjustedHeight; 117 } 118 119 loadedImages++; 120 if (loadedImages === imageSources.length) { 121 wrapper.css('height', maxHeight + 'px'); 122 } 123 }; 124 }); 125 } 126 127 loadMaxImageHeight(); 128 }); 129});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.