PageSourceSearch

https://www.radcork.com/wp-content/plugins/cr-wpbakery-extend/assets/library/slickLightbox/slick-lightbox.js

js radcork.com collected 2026-10-07 18:34:10 UTC 22,111 bytes, 440 lines download raw bytes

vendor: 4,786 bytes, lines 1-91
1'use strict';
2(function ($) {
3    var SlickLightbox, defaults;
4    SlickLightbox = function () {
5        /*
6  The core class.
7   */
8        function SlickLightbox(element, options1) { 
9            var slickLightbox;
10            this.options = options1;
11            /* Binds the plugin. */
12            this.$element = $(element);
13            this.didInit = false;
14            slickLightbox = this;
15            this.$element.on('click.slickLightbox', this.options.itemSelector, function (e) {
16                var $clickedItem, $items;
17                e.preventDefault();
18                $clickedItem = $(this);
19                $clickedItem.blur();
20                if (typeof slickLightbox.options.shouldOpen === 'function') {
21                    if (!slickLightbox.options.shouldOpen(slickLightbox, $clickedItem, e)) {
22                        return;
23                    }
24                }
25                $items = slickLightbox.$element.find(slickLightbox.options.itemSelector);
26                if (slickLightbox.elementIsSlick()) {
27                    $items = slickLightbox.filterOutSlickClones($items);
28                    $clickedItem = slickLightbox.handlePossibleCloneClick($clickedItem, $items);
29                }
30                return slickLightbox.init($items.index($clickedItem));
31            });
32        }
33        SlickLightbox.prototype.init = function (index) {
34            /* Creates the lightbox, opens it, binds events and calls `slick`. Accepts `index` of the element, that triggered it (so that we know, on which slide to start slick). */
35            this.didInit = true;
36            this.detectIE();
37            this.createModal();
38            this.bindEvents();
39            this.initSlick(index);
40            return this.open();
41        };
42        SlickLightbox.prototype.createModalItems = function () {
43            /* Creates individual slides to be used with slick. If `options.images` array is specified, it uses it's contents, otherwise loops through elements' `options.itemSelector`. */
44            var $items, createItem, itemTemplate, lazyPlaceholder, length, links;
45            var useVideo = this.options.lazyPlaceholder;
46            lazyPlaceholder = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
47            itemTemplate = function (source, caption, lazy) {
48                var imgSourceParams;
49                if (lazy === true) {
50                    imgSourceParams = ' data-lazy="' + source + '" src="' + lazyPlaceholder + '" ';
51                } else {
52                    imgSourceParams = ' src="' + source + '" ';
53                }
54
55                if(useVideo == "video"){
56                    return '<div class="slick-lightbox-slick-item">\n  <div class="slick-lightbox-slick-item-inner">\n <div class="innerwrap">\n    <div class="videoWrapper"><iframe class="yt_player_iframe" width="560" height="315" src="' + source + '?enablejsapi=1&version=3&playerapiid=ytplayer" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen  allowscriptaccess="always"></iframe></div>\n    ' + caption + '\n  </div>\n  </div>\n</div>';
57
58                } else {
59                    return '<div class="slick-lightbox-slick-item">\n  <div class="slick-lightbox-slick-item-inner">\n <div class="innerwrap">\n    <img class="slick-lightbox-slick-img" ' + imgSourceParams + ' />\n    ' + caption + '\n  </div>\n  </div>\n</div>';
60
61                }
62            };
63            if (this.options.images) {
64                links = $.map(this.options.images, function (_this) {
65                    return function (img) {
66                        return itemTemplate(img, _this.options.lazy);
67                    };
68                }(this));
69            } else {
70                $items = this.filterOutSlickClones(this.$element.find(this.options.itemSelector));
71                length = $items.length;
72                createItem = function (_this) {
73                    return function (el, index) {
74                        var caption, info, src;
75                        info = {
76                            index: index,
77                            length: length
78                        };
79                        caption = _this.getElementCaption(el, info);
80                        src = _this.getElementSrc(el);
81                        return itemTemplate(src, caption, _this.options.lazy);
82                    };
83                }(this);
84                links = $.map($items, createItem);
85            }
86            return links;
87        };
88        SlickLightbox.prototype.createModal = function () {
89            /* Creates a `slick`-friendly modal. */
90            var html, links;
91            links = this.createModalItems();
92            html = '<div class="slick-lightbox slick-lightbox-hide-init' + (this.isIE ? ' slick-lightbox-ie' : '') + '" style="background: ' + this.options.background + ';">\n  <div class="slick-lightbox-inner">\n    <div class="slick-lightbox-slick slick-caption-' + this.options.captionPosition + '">' + links.join('') + '</div>\n  <div>\n<div>';
93            this.$modalElement = $(html);
94            this.$parts = {};
95            this.$parts['closeButton'] = $(this.options.layouts.closeButton);
96            this.$modalElement.find('.slick-lightbox-inner').append(this.$parts['closeButton']);
97            return $('body').append(this.$modalElement);
98        };
99        SlickLightbox.prototype.initSlick = function (index) {
100            /* Runs slick by default, using `options.slick` if provided. If `options.slick` is a function, it gets fired instead of us initializing slick. Merges in initialSlide option. */
101            var additional;
102            additional = { initialSlide: index };
103            if (this.options.lazy) {
104                additional.lazyLoad = 'ondemand';
105            }
106            if (this.options.slick != null) {
107                if (typeof this.options.slick === 'function') {
108                    this.slick = this.options.slick(this.$modalElement);
109                } else {
110
111                    var speedSlick = 500;
112                    if (/Edge\/\d./i.test(navigator.userAgent)){
113                       speedSlick = 700;
114                    }
115                    
116                    this.slick = this.$modalElement.find('.slick-lightbox-slick').slick($.extend({}, { 
117                    speed: speedSlick,
118                    cssEase: 'linear',
119                    useTransform: true,
120                    infinite: true,
121                    centerMode: true,
122                    //centerPadding: '10%', 
123                    slidesToShow: 1,
124                    touchMove: true,
125                    variableWidth: true,
126                    prevArrow: '<a class="property-slider-arrow-left"><svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 15.3 30"><defs><style>.cls-1{fill:#fff;}</style></defs><g id="Layer_4" data-name="Layer 4"><polygon id="scroll_down_arrow" data-name="scroll down arrow" class="cls-1" points="15.1 27 2.8 15.2 15 3 12.2 3 0 15.2 0 15.2 0 15.2 12.3 27 15.1 27"/></g></svg></a>',
127                    nextArrow: '<a class="property-slider-arrow-right"><svg id="Layer_2" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 15.3 30"><defs><style>.cls-1{fill:#fff;}</style></defs><g id="Layer_4" data-name="Layer 4"><polygon id="scroll_down_arrow" data-name="scroll down arrow" class="cls-1" points="0 3 12.3 14.8 0.1 27 2.9 27 15.1 14.8 15.1 14.8 15.1 14.8 2.8 3 0 3"/></g></svg></a>',
128
129                    focusOnSelect:true,
130                    slidesToScroll: 1,}, additional));
131
132
133                    this.slick.on('beforeChange', function(event, slick, currentSlide, nextSlide){
134
135                        $('.slick-lightbox-slick .slick-slide').removeClass("inactive");
136                        
137                        setTimeout(function(){
138                            $( ".slick-lightbox-slick .slick-slide" ).each(function( index ) {
139                               var indexSlide = $(this).attr('data-slick-index');
140                               if (parseInt(indexSlide) !== nextSlide) {
141                                    jQuery(this).addClass('inactive');
142                               }
143                            });
144                        }, 400);
145                        
146
147                        var slideWidth = jQuery( ".slick-slide[data-slick-index='"+nextSlide+"']", this ).width();
148                        //jQuery( ".slick-lightbox-slick" ).css('max-width', (slideWidth));
149                        //jQuery( ".slick-lightbox-slick" ).animate({max-width: slideWidth,}, 5000, function() {});
150                        var bodySize = $( window ).width();
151                        console.log(bodySize+" "+slideWidth);
152                        if(bodySize>1199){
153                            var arrowPosition = ((bodySize/2) - (sl
vendor: 13,119 bytes, lines 153-440
153ideWidth/2)) - 50; 
154                        // } else if (bodySize>500) {
155                        //     var arrowPosition = ((bodySize/2) - (slideWidth/2)) - 20;
156                        } else {
157                            var arrowPosition = 60 ;
158                        }
159                        jQuery( ".property-slider-arrow-left" ).animate({left: arrowPosition,}, 600, function() {});
160                        jQuery( ".property-slider-arrow-right" ).animate({right: arrowPosition,}, 600, function() {});
161
162                        if ( $( ".cr-video-gallery-isotope" ).length ) {
163                            $('.yt_player_iframe').each(function(){ 
164                              this.contentWindow.postMessage('{"event":"command","func":"stopVideo","args":""}', '*')
165                            });
166                        }
167                        
168
169                    });
170                }
171            } else {
172                this.slick = this.$modalElement.find('.slick-lightbox-slick').slick();
173            }
174
175            jQuery('.slick-lightbox-slick.slick-initialized .slick-slide').addClass('inactive');
176            var bodySize = $( window ).width();
177            var slideWidth = jQuery( ".slick-lightbox-slick.slick-initialized .slick-current" ).width();
178            var bodySize = $( window ).width();
179            if(bodySize>1199){
180                var arrowPosition = ((bodySize/2) - (slideWidth/2)) - 50;
181            // } else if (bodySize>500) {
182            //     var arrowPosition = ((bodySize/2) - (slideWidth/2)) - 20;
183            } else {
184                var arrowPosition = 60 ;
185            }
186            jQuery( ".property-slider-arrow-left" ).animate({left: arrowPosition,}, 700, function() {});
187            jQuery( ".property-slider-arrow-right" ).animate({right: arrowPosition,}, 700, function() {});
188
189            jQuery( "body" ).addClass('noScroll');
190
191            // jQuery( ".slick-lightbox-slick" ).css('max-width', (slideWidth));
192            // $('.slick-lightbox-slick').slick('setPosition');
193            return this.$modalElement.trigger('init.slickLightbox');
194        };
195        SlickLightbox.prototype.open = function () {
196            /* Opens the lightbox. */
197            if (this.options.useHistoryApi) {
198                this.writeHistory();
199            }
200            this.$element.trigger('show.slickLightbox');
201            setTimeout(function (_this) {
202                return function () {
203                    return _this.$element.trigger('shown.slickLightbox');
204                };
205            }(this), this.getTransitionDuration());
206            return this.$modalElement.removeClass('slick-lightbox-hide-init');
207        };
208        SlickLightbox.prototype.close = function () {
209            /* Closes the lightbox and destroys it, maintaining the original element bindings. */
210            this.$element.trigger('hide.slickLightbox');
211            setTimeout(function (_this) {
212                return function () {
213                    return _this.$element.trigger('hidden.slickLightbox');
214                };
215            }(this), this.getTransitionDuration());
216            this.$modalElement.addClass('slick-lightbox-hide');
217            jQuery( "body" ).removeClass('noScroll');
218            return this.destroy();
219        };
220        SlickLightbox.prototype.bindEvents = function () {
221            /* Binds global events. */
222            var resizeSlides;
223            resizeSlides = function (_this) {
224                return function () {
225                    var h;
226                    h = _this.$modalElement.find('.slick-lightbox-inner').height();
227                    _this.$modalElement.find('.slick-lightbox-slick-item').height(h);
228                    return _this.$modalElement.find('.slick-lightbox-slick-img, .slick-lightbox-slick-item-inner').css('max-height', Math.round(_this.options.imageMaxHeight * h));
229                };
230            }(this);
231            $(window).on('orientationchange.slickLightbox resize.slickLightbox', resizeSlides);
232            if (this.options.useHistoryApi) {
233                $(window).on('popstate.slickLightbox', function (_this) {
234                    return function () {
235                        return _this.close();
236                    };
237                }(this));
238            }
239            this.$modalElement.on('init.slickLightbox', resizeSlides);
240            this.$modalElement.on('destroy.slickLightbox', function (_this) {
241                return function () {
242                    return _this.destroy();
243                };
244            }(this));
245            this.$element.on('destroy.slickLightbox', function (_this) {
246                return function () {
247                    return _this.destroy(true);
248                };
249            }(this));
250            this.$parts['closeButton'].on('click.slickLightbox touchstart.slickLightbox', function (_this) {
251                return function (e) {
252                    e.preventDefault();
253                    return _this.close();
254                };
255            }(this));
256            if (this.options.closeOnEscape || this.options.navigateByKeyboard) {
257                $(document).on('keydown.slickLightbox', function (_this) {
258                    return function (e) {
259                        var code;
260                        code = e.keyCode ? e.keyCode : e.which;
261                        if (_this.options.navigateByKeyboard) {
262                            if (code === 37) {
263                                _this.slideSlick('left');
264                            } else if (code === 39) {
265                                _this.slideSlick('right');
266                            }
267                        }
268                        if (_this.options.closeOnEscape) {
269                            if (code === 27) {
270                                return _this.close();
271                            }
272                        }
273                    };
274                }(this));
275            }
276            if (this.options.closeOnBackdropClick) {
277                this.$modalElement.on('click.slickLightbox touchstart.slickLightbox', '.slick-lightbox-slick-img', function (e) {
278                    return e.stopPropagation();
279                });
280                return this.$modalElement.on('click.slickLightbox', '.slick-lightbox-slick-item', function (_this) {
281                    return function (e) {
282                        e.preventDefault();
283                        return _this.close();
284                    };
285                }(this));
286            }
287        };
288        SlickLightbox.prototype.slideSlick = function (direction) {
289            /* Moves the slick prev or next. */
290            if (direction === 'left') {
291                return this.slick.slick('slickPrev');
292            } else {
293                return this.slick.slick('slickNext');
294            }
295        };
296        SlickLightbox.prototype.detectIE = function () {
297            /* Detects usage of IE8 and lower. */
298            var ieversion;
299            this.isIE = false;
300            if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) {
301                ieversion = new Number(RegExp.$1);
302                if (ieversion < 9) {
303                    return this.isIE = true;
304                }
305            }
306        };
307        SlickLightbox.prototype.getElementCaption = function (el, info) {
308            /* Returns caption for each slide based on the type of `options.caption`. */
309            var c;
310            if (!this.options.caption) {
311                return '';
312            }
313            c = function () {
314                switch (typeof this.options.caption) {
315                case 'function':
316                    return this.options.caption(el, info);
317                case 'string':
318                    return $(el).data(this.options.caption);
319                }
320            }.call(this);
321            return '<span class="slick-lightbox-slick-caption">' + c + '</span>';
322        };
323        SlickLightbox.prototype.getElementSrc = function (el) {
324            /* Returns src for each slide image based on the type of `options.src`. */
325            switch (typeof this.options.src) {
326            case 'function':
327                return this.options.src(el);
328            case 'string':
329                return $(el).attr(this.options.src);
330            default:
331                return el.href;
332            }
333        };
334        SlickLightbox.prototype.unbindEvents = function () {
335            /* Unbinds global events. */
336            $(window).off('.slickLightbox');
337            $(document).off('.slickLightbox');
338            return this.$modalElement.off('.slickLightbox');
339        };
340        SlickLightbox.prototype.destroy = function (unbindAnchors) {
341            if (unbindAnchors == null) {
342                unbindAnchors = false;
343            }
344            /* Destroys the lightbox and unbinds global events. If `true` is passed as an argument, unbinds the original element as well. */
345            if (this.didInit) {
346                this.unbindEvents();
347                setTimeout(function (_this) {
348                    return function () {
349                        return _this.$modalElement.remove();
350                    };
351                }(this), this.options.destroyTimeout);
352            }
353            if (unbindAnchors) {
354                this.$element.off('.slickLightbox');
355                return this.$element.off('.slickLightbox', this.options.itemSelector);
356            }
357        };
358        SlickLightbox.prototype.destroyPrevious = function () {
359            /* Destroys lightboxes currently in DOM. */
360            return $('body').children('.slick-lightbox').trigger('destroy.slickLightbox');
361        };
362        SlickLightbox.prototype.getTransitionDuration = function () {
363            /* Detects the transition duration to know when to remove stuff from DOM etc. */
364            var duration;
365            if (this.transitionDuration) {
366                return this.transitionDuration;
367            }
368            duration = this.$modalElement.css('transition-duration');
369            if (typeof duration === 'undefined') {
370                return this.transitionDuration = 500;
371            } else {
372                return this.transitionDuration = duration.indexOf('ms') > -1 ? parseFloat(duration) : parseFloat(duration) * 1000;
373            }
374        };
375        SlickLightbox.prototype.writeHistory = function () {
376            /* Writes an empty state to the history API if supported. */
377            return typeof history !== 'undefined' && history !== null ? typeof history.pushState === 'function' ? history.pushState(null, null, '') : void 0 : void 0;
378        };
379        SlickLightbox.prototype.filterOutSlickClones = function ($items) {
380            /* Removes all slick clones from the set of elements. Only does so, if the target element is a slick slider. */
381            if (!this.elementIsSlick()) {
382                return $items;
383            }
384            return $items = $items.filter(function () {
385                var $item;
386                $item = $(this);
387                return !$item.hasClass('slick-cloned') && $item.parents('.slick-cloned').length === 0;
388            });
389        };
390        SlickLightbox.prototype.handlePossibleCloneClick = function ($clickedItem, $items) {
391            var href;
392            if (!this.elementIsSlick()) {
393                return $clickedItem;
394            }
395            if (!$clickedItem.closest('.slick-slide').hasClass('slick-cloned')) {
396                return $clickedItem;
397            }
398            href = $clickedItem.attr('href');
399            return $items.filter(function () {
400                return $(this).attr('href') === href;
401            }).first();
402        };
403        SlickLightbox.prototype.elementIsSlick = function () {
404            return this.$element.hasClass('slick-slider');
405        };
406        return SlickLightbox;
407    }();
408    defaults = {
409        background: 'rgba(0,0,0,.8)',
410        closeOnEscape: true,
411        closeOnBackdropClick: true,
412        destroyTimeout: 500,
413        itemSelector: 'a',
414        navigateByKeyboard: true,
415        src: false,
416        caption: false,
417        captionPosition: 'dynamic',
418        images: false,
419        slick: {},
420        useHistoryApi: false,
421        layouts: { closeButton: '<button type="button" class="slick-lightbox-close"></button>' },
422        shouldOpen: null,
423        imageMaxHeight: 0.9,
424        lazy: false
425    };
426    $.fn.slickLightbox = function (options) {
427        /* Fires the plugin. */
428        options = $.extend({}, defaults, options);
429        $(this).each(function () {
430            return this.slickLightbox = new SlickLightbox(this, options);
431        });
432        return this;
433    };
434    $.fn.unslickLightbox = function () {
435        /* Removes everything. */
436        return $(this).trigger('destroy.slickLightbox').each(function () {
437            return this.slickLightbox = null;
438        });
439    };
440}(jQuery));

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.