PageSourceSearch

https://www.book-sloan.com/wp-content/themes/incubator/core/assets/js/scripts.js?ver=7.1.2

js book-sloan.com collected 2026-10-04 13:56:40 UTC 17,684 bytes, 480 lines download raw bytes

1// ------------------------------------------------------------------------
2// Check if element is in ViewPort
3// ------------------------------------------------------------------------
4(function($) {
5    "use strict";
6    $.belowthefold = function(element, settings) {
7        var fold = $(window).height() + $(window).scrollTop();
8        return fold <= $(element).offset().top - settings.threshold;
9    };
10    $.abovethetop = function(element, settings) {
11        var top = $(window).scrollTop();
12        return top >= $(element).offset().top + $(element).height() - settings.threshold;
13    };
14    $.rightofscreen = function(element, settings) {
15        var fold = $(window).width() + $(window).scrollLeft();
16        return fold <= $(element).offset().left - settings.threshold;
17    };
18    $.leftofscreen = function(element, settings) {
19        var left = $(window).scrollLeft();
20        return left >= $(element).offset().left + $(element).width() - settings.threshold;
21    };
22    $.inviewport = function(element, settings) {
23        return !$.rightofscreen(element, settings) && !$.leftofscreen(element, settings) && !$.belowthefold(element, settings) && !$.abovethetop(element, settings);
24    };
25    $.extend($.expr[':'], {
26        "below-the-fold": function(a, i, m) {
27            return $.belowthefold(a, {
28                threshold: 0
29            });
30        },
31        "above-the-top": function(a, i, m) {
32            return $.abovethetop(a, {
33                threshold: 0
34            });
35        },
36        "left-of-screen": function(a, i, m) {
37            return $.leftofscreen(a, {
38                threshold: 0
39            });
40        },
41        "right-of-screen": function(a, i, m) {
42            return $.rightofscreen(a, {
43                threshold: 0
44            });
45        },
46        "in-viewport": function(a, i, m) {
47            return $.inviewport(a, {
48                threshold: 0
49            });
50        }
51    });
52    // ------------------------------------------------------------------------
53    // On window load
54    // ------------------------------------------------------------------------
55      $(window).load(function() {
56        if ($('#preloader').length > 0) {
57          $('#preloader').fadeOut('slow', function() {
58              $(this).remove();
59          });
60        }
61
62        // ------------------------------------------------------------------------
63        // Portfolio masonry init
64        // ------------------------------------------------------------------------
65        if ($('#portfolio-items').length > 0) {
66            var container = document.querySelector('#portfolio-items');
67            var msnry = new Masonry(container, {
68                itemSelector: '.portfolio-item',
69                columnWidth: '.portfolio-sizer',
70                percentPosition: true
71            });
72        }
73
74        if ($('.portfolio-sidebar.sidebar-list').length > 0) {
75            var $sidebar = $(".portfolio-sidebar.sidebar-list"),
76            $window = $(window),
77            $listHeight = $(".portfolio-gallery-list").height(),
78            offset = $sidebar.offset(),
79            topPadding = 0;
80            $sidebar.css('width',$sidebar.width());
81            $window.scroll(function() {
82                if ($window.scrollTop() > offset.top - 120) {
83                    $sidebar.stop().addClass('fixed-sidebar');
84                    if ($window.scrollTop() > offset.top + $listHeight - $sidebar.height() - 100 )  {
85                           $sidebar.addClass('absolute-sidebar');
86                    }
87                    else {
88                        $sidebar.removeClass('absolute-sidebar');
89                    }
90
91                }  else
92                {
93                    $sidebar.stop().removeClass('fixed-sidebar');
94                }
95            });
96        }
97
98
99    });
100
101    $(document).ready(function() {
102
103         if ($('#single-page').length > 0) {
104            $('body').addClass('single-post');
105         }
106
107        // ------------------------------------------------------------------------
108        // Live Preview Customizer
109        // ------------------------------------------------------------------------
110
111        $("#customizer .switcher").click(function() {
112        $("#customizer").toggleClass('active');
113        });
114
115        function draw() {
116            requestAnimationFrame(draw);
117            scrollEvent();
118        }
119        draw();
120
121
122        // ------------------------------------------------------------------------
123        // Fixed Footer
124        // ------------------------------------------------------------------------
125        if ($("#footer.fixed").length) {
126            var footerHeight = $("#footer.fixed").height();
127            $("#wrapper").css("margin-bottom", footerHeight);
128        }
129
130        // ------------------------------------------------------------------------
131        // Custom Search Field
132        // ------------------------------------------------------------------------
133        $("#s").each(function(index, elem) {
134            var eId = $(elem).attr("id");
135            var label = null;
136            if (eId && (label = $(elem).parents("form").find("label[for=" + eId + "]")).length == 1) {
137                $(elem).attr("placeholder", 'Search');
138                $(label).remove();
139            }
140        });
141        $(".searchform input[type='submit']").val('');
142        $(".woocommerce-product-search input[type='submit']").val('');
143        // ------------------------------------------------------------------------
144        // Contact Form Buttons
145        // ------------------------------------------------------------------------
146        $(document).on("click", ".section .wpcf7-not-valid-tip,.section .wpcf7-mail-sent-ok, .subscribe-form header .wpcf7-response-output, .modal-content-inner .wpcf7-not-valid-tip", function() {
147            $(this).fadeOut();
148        });
149        // ------------------------------------------------------------------------
150        // Reset reCaptcha for modal window
151        // ------------------------------------------------------------------------
152        if ($('.wpcf7-recaptcha').length > 0) {
153    			$(document).on("click", ".modal-menu-item", function() {
154    				grecaptcha.reset();
155    			});
156    		}
157        // ------------------------------------------------------------------------
158        // Main Menu One Page Links
159        // ------------------------------------------------------------------------
160        $('.navbar-nav > li.one-page-link > a:first-child, .footer_widget .menu li.one-page-link > a:first-child').each(function() {
161            var href = $(this).attr("href");
162            var link = href.replace(/\/$/, '');
163            if ($("body").hasClass("home")) {
164                var anchor = link.substr(link.lastIndexOf('/') + 1);
165                if (anchor.indexOf("?page_id") >= 0) { anchor = '';}
166                $(this).attr("href", '#' + anchor);
167            } else {
168                if (!$(this).hasClass("first")) {
169                    var pos = link.lastIndexOf('/');
170                    link = link.substring(0, pos) + '#' + link.substring(pos + 1);
171                    $(this).attr("href", link);
172                }
173            }
174        });
175
176        $( "<span class='mobile-dropdown'></span>" ).appendTo( $( ".navbar-nav .menu-item-has-children" ) );
177
178        $(".navbar-nav .menu-item-has-children .mobile-dropdown").click(function() {
179        $(this).closest(".menu-item-has-children").toggleClass('mobile-visible');
180        });
181
182        // ------------------------------------------------------------------------
183        // Main Smooth Scroll and Scroll Spy
184        // ------------------------------------------------------------------------
185        $('.navbar-collapse ul li a, .navbar-collapse .modal-menu-item.scroll-section').click(function() {
186            $('.navbar-toggle:visible').click();
187        });
188        $(function() {
189            $('.navbar-nav .one-page-link a, .footer_widget .menu li a, .scroll-section, .demo-button').bind('click', function(event) {
190                if ($("body").hasClass("home")) {
191                var anchor = $(this);
192                $('html, body').stop().animate({
193                    scrollTop: $(anchor.attr('href')).offset().top - 68
194                }, 1500, 'easeInOutExpo');
195                event.preventDefault();
196                }
197            });
198        });
199        $(function() {
200            $('.portfolio-demo-button, .kd-calltoaction.smooth-scroll .tt_button').bind('click', function(event) {
201                var anchor = $(this);
202                $('html, body').stop().animate({
203                    scrollTop: $(anchor.attr('href')).offset().top - 250
204                }, 1500, 'easeInOutExpo');
205                event.preventDefault();
206            });
207        });
208        $('body').scrollspy({
209            offset: 69,
210            target: '.navbar-fixed-top'
211        });
212
213        // ------------------------------------------------------------------------
214        // Search Bar
215        // ------------------------------------------------------------------------
216
217        $(".header-search-bar .toggle-search").click(function() {
218            $(".header-search-bar .header-search-container").toggleClass('active');
219            $(this).toggleClass('fa-times');
220        });
221
222        // ------------------------------------------------------------------------
223        // WPGlobus compatibility - NavWalker conflict
224        // ------------------------------------------------------------------------
225
226        if ($('.wpglobus-selector-link').length > 0) {
227            $('.wpglobus-selector-link .dropdown-menu').addClass('sub-menu');
228        }
229
230        // ------------------------------------------------------------------------
231        // Slider scroll down button
232        // ------------------------------------------------------------------------
233        $('.slider-scroll-down a').click(function(event) {
234            $('html, body').animate({
235                scrollTop: $("#wrapper .section").offset().top - 68
236            }, 1500, 'easeInOutExpo');
237            event.preventDefault();
238        });
239
240        // ------------------------------------------------------------------------
241        // Back to top button
242        // ------------------------------------------------------------------------
243        $(window).bind("scroll", function() {
244            if ($(window).scrollTop() > $(window).height()) {
245                $('.back-to-top').addClass('active');
246            }
247            if ($(window).scrollTop() < $(window).height()) {
248                $('.back-to-top').removeClass('active');
249            }
250        });
251        $('.back-to-top').click(function(event) {
252            event.preventDefault();
253            $('html, body').animate({
254                scrollTop: 0
255            }, 1000);
256            return false;
257        });
258
259    });
260    // ------------------------------------------------------------------------
261    // Portfolio image slider
262    // ------------------------------------------------------------------------
263
264    if ($(".owlslider-portfolio").length) {
265        $(".owlslider-portfolio").owlCarousel({
266            navigation: false,
267            pagination: true,
268            singleItem: true,
269            autoPlay: false,
270            animateOut: 'fadeOut',
271        });
272    }
273
274    // ------------------------------------------------------------------------
275    // Portfolio photoSwipe init
276    // ------------------------------------------------------------------------
277    var PhotoSwipe = window.PhotoSwipe,
278        PhotoSwipeUI_Default = window.PhotoSwipeUI_Default;
279
280    $('body').on('click', 'a[data-size]', function(e) {
281        if (!PhotoSwipe || !PhotoSwipeUI_Default) {
282            return;
283        }
284
285        e.preventDefault();
286        openPhotoSwipe(this);
287    });
288
289    var parseThumbnailElements = function(gallery, el) {
290        var elements = $(gallery).find('a[data-size]').has('img'),
291            galleryItems = [],
292            index;
293
294        elements.each(function(i) {
295            var $el = $(this),
296                size = $el.data('size').split('x'),
297                caption;
298
299            if ($el.next().is('.wp-caption-text')) {
300                // image with caption
301                caption = $el.next().text();
302            } else if ($el.parent().next().is('.wp-caption-text')) {
303                // gallery icon with caption
304                caption = $el.parent().next().text();
305            } else {
306                caption = $el.attr('title');
307            }
308
309            galleryItems.push({
310                src: $el.attr('href'),
311                w: parseInt(size[0], 10),
312                h: parseInt(size[1], 10),
313                title: caption,
314                msrc: $el.find('img').attr('src'),
315                el: $el
316            });
317            if (el === $el.get(0)) {
318                index = i;
319            }
320        });
321
322        return [galleryItems, parseInt(index, 10)];
323    };
324
325    var openPhotoSwipe = function(element, disableAnimation) {
326        var pswpElement = $('.pswp').get(0),
327            galleryElement = $(element).parents('.gallery, .hentry, .main, body').first(),
328            gallery,
329            options,
330            items, index;
331
332        items = parseThumbnailElements(galleryElement, element);
333        index = items[1];
334        items = items[0];
335
336        options = {
337            index: index,
338            getThumbBoundsFn: function(index) {
339                var image = items[index].el.find('img'),
340                    offset = image.offset();
341
342                return {
343                    x: offset.left,
344                    y: offset.top,
345                    w: image.width()
346                };
347            },
348            showHideOpacity: true,
349            history: false
350        };
351
352        if (disableAnimation) {
353            options.showAnimationDuration = 0;
354        }
355
356        // Pass data to PhotoSwipe and initialize it
357        gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, options);
358        gallery.init();
359    };
360
361
362    // ------------------------------------------------------------------------
363    // Classie Script
364    // ------------------------------------------------------------------------
365    (function(window) {
366
367        function classReg(className) {
368            return new RegExp("(^|\\s+)" + className + "(\\s+|$)");
369        }
370        var hasClass, addClass, removeClass;
371        if ('classList' in document.documentElement) {
372            hasClass = function(elem, c) {
373                return elem.classList.contains(c);
374            };
375            addClass = function(elem, c) {
376                elem.classList.add(c);
377            };
378            removeClass = function(elem, c) {
379                elem.classList.remove(c);
380            };
381        } else {
382            hasClass = function(elem, c) {
383                return classReg(c).test(elem.className);
384            };
385            addClass = function(elem, c) {
386                if (!hasClass(elem, c)) {
387                    elem.className = elem.className + ' ' + c;
388                }
389            };
390            removeClass = function(elem, c) {
391                elem.className = elem.className.replace(classReg(c), ' ');
392            };
393        }
394
395        function toggleClass(elem, c) {
396            var fn = hasClass(elem, c) ? removeClass : addClass;
397            fn(elem, c);
398        }
399        var classie = {
400            hasClass: hasClass,
401            addClass: addClass,
402            removeClass: removeClass,
403            toggleClass: toggleClass,
404            has: hasClass,
405            add: addClass,
406            remove: removeClass,
407            toggle: toggleClass
408        };
409        if (typeof define === 'function' && define.amd) {
410            define(classie);
411        } else {
412            window.classie = classie;
413        }
414
415    })(window);
416    // ------------------------------------------------------------------------
417    // Animated Header
418    // ------------------------------------------------------------------------
419
420    var cbpAnimatedHeader = (function() {
421        var docElem = document.documentElement,
422            header = document.querySelector('.navbar-default'),
423            didScroll = false,
424            changeHeaderOn = 50;
425
426        function init() {
427            window.addEventListener('scroll', function(event) {
428                if (!didScroll) {
429                    didScroll = true;
430                    setTimeout(scrollPage, 100);
431                }
432            }, false);
433            window.addEventListener('load', function(event) {
434                if (!didScroll) {
435                    didScroll = true;
436                    setTimeout(scrollPage, 100);
437                }
438            }, false);
439        }
440
441        function scrollPage() {
442            var sy = scrollY();
443            if (sy >= changeHeaderOn) {
444                classie.add(header, 'navbar-shrink');
445            } else {
446                classie.remove(header, 'navbar-shrink');
447            }
448            didScroll = false;
449        }
450
451        function scrollY() {
452            return window.pageYOffset || docElem.scrollTop;
453        }
454        init();
455    })();
456
457
458})(jQuery);
459
460
461
462function scrollEvent() {
463
464    if (!is_touch_device()) {
465        viewportTop = jQuery(window).scrollTop();
466
467        if (jQuery(window).width())
468
469            jQuery('.parallax-overlay').each(function() {
470            elementOffset = jQuery(this).offset().top;
471            distance = -(elementOffset - viewportTop) * 0.35;
472            jQuery(this).css('transform', 'translate3d(0, ' + distance + 'px,0)');
473        });
474
475    }
476}
477
478function is_touch_device() {
479    return 'ontouchstart' in window || 'onmsgesturechange' in window;
480}

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.