1// @ts-ignore 2import Swiper from "swiper"; 3// @ts-ignore 4import { Pagination } from "swiper/modules"; 5export function formatViewerProgress(index, total) { 6 if (total <= 0) return ""; 7 return "".concat(index + 1, "/").concat(total); 8} 9export function setTextIfExists(target, text) { 10 if (target) { 11 target.textContent = text; 12 } 13} 14export function preventImagesContextMenu(root) { 15 root.querySelectorAll("img").forEach(function(img) { 16 img.addEventListener("contextmenu", function(event) { 17 return event.preventDefault(); 18 }); 19 }); 20} 21export function updateCompactSwiperBullets(swiper) { 22 var maxMain = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 5; 23 var bullets = Array.from(swiper.pagination.bullets || []); 24 var total = bullets.length; 25 var _swiper_realIndex; 26 var activeIndex = (_swiper_realIndex = swiper.realIndex) !== null && _swiper_realIndex !== void 0 ? _swiper_realIndex : 0; 27 if (!total) return; 28 bullets.forEach(function(bullet) { 29 return bullet.classList.remove("material-bullet--main", "material-bullet--tiny", "material-bullet--hidden"); 30 }); 31 if (total <= maxMain) { 32 bullets.forEach(function(bullet) { 33 return bullet.classList.add("material-bullet--main"); 34 }); 35 return; 36 } 37 var start = activeIndex - 2; 38 var end = activeIndex + 2; 39 if (start < 0) { 40 start = 0; 41 end = start + (maxMain - 1); 42 } 43 if (end > total - 1) { 44 end = total - 1; 45 start = end - (maxMain - 1); 46 } 47 bullets.forEach(function(bullet, index) { 48 if (index < start || index > end) { 49 bullet.classList.add("material-bullet--hidden"); 50 } else { 51 bullet.classList.add("material-bullet--main"); 52 } 53 }); 54 if (start > 0) { 55 var tinyPrev = bullets[start - 1]; 56 tinyPrev.classList.remove("material-bullet--hidden"); 57 tinyPrev.classList.add("material-bullet--tiny"); 58 } 59 if (end < total - 1) { 60 var tinyNext = bullets[end + 1]; 61 tinyNext.classList.remove("material-bullet--hidden"); 62 tinyNext.classList.add("material-bullet--tiny"); 63 } 64} 65export function createPaginationSwiper(param) { 66 var container = param.container, pagination = param.pagination, _param_autoHeight = param.autoHeight, autoHeight = _param_autoHeight === void 0 ? true : _param_autoHeight, onInit = param.onInit, onSlideChange = param.onSlideChange; 67 return new Swiper(container, { 68 modules: [ 69 Pagination 70 ], 71 pagination: { 72 el: pagination, 73 clickable: true 74 }, 75 loop: false, 76 autoHeight: autoHeight, 77 on: { 78 init: function(swiper) { 79 onInit === null || onInit === void 0 ? void 0 : onInit(swiper); 80 if (autoHeight) { 81 swiper.updateAutoHeight(); 82 } 83 }, 84 slideChange: function(swiper) { 85 onSlideChange === null || onSlideChange === void 0 ? void 0 : onSlideChange(swiper); 86 if (autoHeight) { 87 swiper.updateAutoHeight(); 88 } 89 } 90 } 91 }); 92}
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.