PageSourceSearch

https://www.phinc.co.za/Portals/_default/Skins/minis/resource/vendor/minilightbox/minilightbox.min.js

js phinc.co.za collected 2026-09-29 00:00:25 UTC 7,809 bytes, 180 lines download raw bytes

1// Fixed Gallery lightbox early-click 2026-05-31: Capture-phase guard blocks image navigation until handlers are ready (long pages with defer/inline scripts). Agent: Composer
2function phGalleryLightboxMarkReady() {
3    window.__phGalleryLightboxReady = true;
4    var pending = window.__phGalleryLightboxPendingClick;
5    if (pending && typeof miniLightbox === "function") {
6        window.__phGalleryLightboxPendingClick = null;
7        miniLightbox(pending);
8    }
9}
10(function () {
11    if (window.__phGalleryLightboxGuardInit) return;
12    window.__phGalleryLightboxGuardInit = true;
13    window.__phGalleryLightboxReady = false;
14    function anchorFrom(target) {
15        for (var el = target; el && el !== document.documentElement; el = el.parentNode) {
16            if (el.nodeType === 1 && el.tagName === "A" && el.classList && el.classList.contains("is-lightbox")) {
17                return el;
18            }
19        }
20        return null;
21    }
22    document.addEventListener("click", function (e) {
23        var a = anchorFrom(e.target);
24        if (!a || typeof DNNapplyTypography !== "undefined") return;
25        e.preventDefault();
26        e.stopImmediatePropagation();
27        if (window.__phGalleryLightboxReady && typeof miniLightbox === "function") {
28            miniLightbox(a);
29        } else {
30            window.__phGalleryLightboxPendingClick = a;
31        }
32    }, true);
33})();
34
35function miniLightbox(e) {
36    var holder = $(".minilightbox-holder"),e=$(e),
37        type = e.data("ilightbox")?e.data("ilightbox"):"images",
38        url = e.attr("href"),
39        title =e.attr("title"),
40        pr= window.innerWidth -$(window).width() ,
41        groupImg=false,
42        currImg=false,
43        imgload=false;
44
45        if(e.find("img").hasClass("elm-active")) return false;
46
47        if(!holder.length){
48            $('body').append('<div class="minilightbox-holder" aria-hidden="true"><div class="minilightbox-close"></div><div class="minilightbox-mask"></div><div class="minilightbox-content"></div><div class="minilightbox-prev"><span></span></div><div class="minilightbox-next"><span></span></div></div>');
49            holder = $(".minilightbox-holder");
50        }
51
52        $('.minilightbox-prev,.minilightbox-next').hide();
53
54    var lightbox = $('.minilightbox-holder'),content = lightbox.find('.minilightbox-content'),html="";
55        switch(type){
56            case "image":
57                var t =
58                html ='<div class="box lightbox-image"><img src="'+url+'" alt="'+(title?title:"")+'">'+(title?'<div class="minilight-title">'+title+'</div>':'')+'</div>';
59                content.addClass("loading");
60            break;  
61            case "youtube":
62                html ='<div class="box lightbox-youtube"><iframe src="'+url+'" frameborder="0" hspace="0" vspace="0" scrolling="scroll" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen=""></iframe></div>';
63            break;
64            case "vimeo":
65                    html ='<div class="box lightbox-vimeo"><iframe src="'+url+'" frameborder="0" hspace="0" vspace="0" scrolling="scroll" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen=""></iframe></div>';
66                    break;
67            case "html5":
68                    html ='<div class="box lightbox-html5"><video preload="metadata" controls="controls" src="'+url+'">';
69                    html +='<source src="'+url+'" type="video/mp4">';
70                    html +='</video></div>';
71
72                    break;
73            case "map":
74                html ='<div class="box lightbox-map"><iframe src="'+url+'" frameborder="0" hspace="0" vspace="0" scrolling="scroll" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen=""></iframe></div>';
75                break;
76        }
77
78        function hideNextPrev(){
79            lightbox.find(".minilightbox-prev,.minilightbox-next").show();
80            lightbox.find(".minilightbox-prev,.minilightbox-next").removeClass("disabled");
81            if(currImg==0){
82                lightbox.find(".minilightbox-prev").addClass("disabled");
83            }else if(currImg==groupImg.length-1){
84                lightbox.find(".minilightbox-next").addClass("disabled");
85            }
86
87        }
88        if(e.attr("data-group") && $('.is-lightbox[data-ilightbox="image"][data-group="'+e.attr("data-group")+'"]').length > 1 ){
89            groupImg= $('.is-lightbox[data-ilightbox="image"][data-group="'+e.attr("data-group")+'"]');
90            currImg = groupImg.index(e);
91            hideNextPrev();
92        }
93
94        content.html(html);
95        $("html").css({"overflow":"hidden","padding-right":pr});
96        content.find("img,iframe").on("load",function(){
97            content.removeClass("loading");  
98        })
99
100
101        lightbox.fadeIn().addClass("active");
102        $(".minilightbox-close,.minilightbox-mask").one("click",function(){
103            lightbox.fadeOut(function(){
104                lightbox.removeClass("active"); 
105                content.html("");
106            });
107             $("html").css({"overflow":"","padding-right":''}); 
108        })
109
110      
111        lightbox.find(".minilightbox-prev,.minilightbox-next").off().on("click",function(){
112            if($(this).hasClass("disabled")) return;
113            if(groupImg){
114                if($(this).hasClass("minilightbox-next")){
115                    currImg ++;
116                var img = groupImg.eq(currImg);
117                }else{
118                    currImg --;
119                var img =  groupImg.eq(currImg);
120                }
121                hideNextPrev();
122                content.removeClass("loading");  
123            var url2 = img.attr("href"),
124                title2 =img.attr("title");
125                imgload =true;
126                content.children(".lightbox-image").addClass("remove").fadeOut(function(){
127                    $(this).remove();
128                    if(imgload){
129                        content.addClass("loading");  
130                        imgload =false;
131                    }
132                });
133               
134                var box  =$('<div class="box lightbox-image" style="display:none"><img src="'+url2+'" alt="'+(title2?title2:"")+'">'+(title2?'<div class="minilight-title">'+title2+'</div>
134':'')+'</div>');
135
136                content.append(box.fadeIn());
137                box.find("img").on("load",function(){
138                    content.removeClass("loading");  
139                    imgload =false;
140                })
141
142            }
143        }) 
144      
145
146}
147
148// Fixed Gallery lightbox early-click 2026-05-31: Bind as soon as jQuery is ready (was 5s setTimeout). Delegated + namespaced; skip .swiper-container (swiper.min.js handles those).
149// Agent: Composer
150(function () {
151    function attachLightboxClicks($) {
152        $(document).off("click.minilightbox", ".is-lightbox").on("click.minilightbox", ".is-lightbox", function (event) {
153            if ($(this).closest(".swiper-container").length) {
154                return;
155            }
156            event.preventDefault();
157            if (typeof DNNapplyTypography == "undefined") {
158                miniLightbox(this);
159            }
160        });
161    }
162    function initLightboxClicks() {
163        if (typeof jQuery === "undefined") {
164            return false;
165        }
166        jQuery(function ($) {
167            attachLightboxClicks($);
168            phGalleryLightboxMarkReady();
169        });
170        return true;
171    }
172    if (!initLightboxClicks()) {
173        var attempts = 0;
174        var waitForJq = setInterval(function () {
175            if (initLightboxClicks() || ++attempts > 200) {
176                clearInterval(waitForJq);
177            }
178        }, 25);
179    }
180})();

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.