PageSourceSearch

https://universalstudentuk.com/ar/wp-content/themes/townhub/assets/js/scripts.js

js universalstudentuk.com collected 2026-10-07 15:18:08 UTC 23,026 bytes, 591 lines download raw bytes

1(function($) {
2    "use strict";
3    //   all ------------------
4    function initTownHub() {
5        //   loader ------------------
6        $(".loader-wrap").fadeOut(300, function() {
7            $("#main-theme").animate({
8                opacity: "1"
9            }, 300);
10        });
11        if ($('#top-menu').length) {
12            $('#top-menu li.menu-item-has-children > a').append(' <i class="fas fa-caret-down"></i>')
13        }
14        //   Background image ------------------
15        var a = $(".bg");
16        a.each(function(a) {
17            if ($(this).attr("data-bg")) $(this).css("background-image", "url(" + $(this).data("bg") + ")");
18        });
19        //   scrollToFixed------------------
20        var adminbarheight = 0;
21        var hheight = parseFloat(_townhub.hheight);
22        if( isNaN(hheight) ) hheight = 80;
23        if ($('#wpadminbar').length) adminbarheight = $('#wpadminbar').outerHeight()
24        if ($(".scroll-nav-wrapper").length) {
25            $(".scroll-nav-wrapper").each(function() {
26                var $lscn = $(this),
27                    mW = 769;
28                if ($lscn.hasClass('lscroll-mobile-yes')) mW = 100
29                $lscn.scrollToFixed({
30                    minWidth: mW,
31                    zIndex: 12,
32                    marginTop: hheight + adminbarheight,
33                    removeOffsets: true,
34                    limit: function() {
35                        var a = $(".limit-box").offset().top - $(".scroll-nav-wrapper").outerHeight(true) - 50;
36                        return a;
37                    },
38                    spacerClass: 'scroll-nav-fixed-spacer'
39                });
40            });
41        }
42        $(".fixed-listing-header").scrollToFixed({
43            minWidth: 1064,
44            marginTop: hheight + adminbarheight,
45            removeOffsets: true,
46            limit: function() {
47                var a = $(".limit-box").offset().top - $(".fixed-listing-header").outerHeight();
48                return a;
49            }
50        });
51        $(".fixed-scroll-column-item").scrollToFixed({
52            minWidth: 1064,
53            marginTop: 200,
54            removeOffsets: true,
55            limit: function() {
56                var a = $(".limit-box").offset().top - $(".fixed-scroll-column-item").outerHeight() - 46;
57                return a;
58            }
59        });
60        if ( $(window).width() > 1064 ) {
61            $(".fix-map").scrollToFixed({
62                minWidth: 1064,
63                zIndex: 0,
64                marginTop: hheight,
65                
66                removeOffsets: true,
67                
68            });
69        }
70            
71        
72        $(".back-tofilters").scrollToFixed({
73            minWidth: 1064,
74            zIndex: 12,
75            marginTop: 90,
76            removeOffsets: true,
77            limit: function() {
78                var a = $(".limit-box").offset().top - $(".back-tofilters").outerHeight(true);
79                return a;
80            },
81            spacerClass: 'back-to-filter-fixed-spacer'
82        });
83        $(".help-bar").scrollToFixed({
84            minWidth: 1064,
85            zIndex: 12,
86            marginTop: 100,
87            removeOffsets: true,
88            limit: function() {
89                var a = $(".limit-box").offset().top - $(".help-bar").outerHeight(true) - 60;
90                return a;
91            }
92        });
93        if( $(".fixed-bar").outerHeight(true) < $(".post-container").outerHeight(true) - 100 ) {
94            $(".fixed-bar").addClass("fixbar-action");
95            $(".fixbar-action").scrollToFixed({
96                minWidth: 1064,
97                zIndex: 12,
98                marginTop: function() {
99                    var a = $(window).height() - $(".fixed-bar").outerHeight(true) - 100;
100                    if (a >= 0) return 20;
101                    return a;
102                },
103                removeOffsets: true,
104                limit: function() {
105                    var a = $(".limit-box").offset().top - $(".fixed-bar").outerHeight() - 60;
106                    return a;
107                },
108                spacerClass: 'dashboard-fixed-spacer'
109            });
110        } else $(".fixed-bar").removeClass("fixbar-action");
111
112        // // filter show -----------------
113        // var shf = $(".shsb_btn"),
114        //     ahimcocn = $(".anim_clw"),
115        //     mapover = $(".map-overlay , .close_sbfilters");
116        // function showhiddenfilters() {
117        //     shf.removeClass("shsb_btn_act");
118        //     ahimcocn.addClass("hidsb_act");
119        //     mapover.fadeIn(200);
120        // }
121        // function hidehiddenfilters() {
122        //     shf.addClass("shsb_btn_act");
123        //     ahimcocn.removeClass("hidsb_act");
124        //     mapover.fadeOut(200);
125        // }
126        // shf.on("click", function () {
127        //     if ($(this).hasClass("shsb_btn_act")) showhiddenfilters();
128        //     else hidehiddenfilters();
129        // });
130        // mapover.on("click", function () {
131        //     hidehiddenfilters();
132        // });
133        // normal filter
134        $(".show-list-wrap-search").on("click", function (e) {
135            $(".lws_mobile").slideToggle(400);
136            $(this).toggleClass("slsw_vis");
137
138        });
139        
140        //   appear------------------
141        $(".stats").appear(function() {
142            $(".num").countTo();
143        });
144        //   scroll to------------------
145        $(".custom-scroll-link").on("click", function() {
146            var a = 70 + $(".scroll-nav-wrapper").height() + adminbarheight;
147            if (location.pathname.replace(/^\//, "") == this.pathname.replace(/^\//, "") || location.hostname == this.hostname) {
148                var b = $(this.hash);
149                b = b.length ? b : $("[name=" + this.hash.slice(1) + "]");
150                if (b.length) {
151                    $("html,body").animate({
152                        scrollTop: b.offset().top - a
153                    }, {
154                        queue: false,
155                        duration: 1200,
156                        easing: "easeInOutExpo"
157                    });
158                    return false;
159                }
160            }
161        });
162        $(".scroll-init  ul ").singlePageNav({
163            filter: ":not(.external)",
164            updateHash: false,
165            offset: 160 + adminbarheight,
166            threshold: 150,
167            speed: 1200,
168            currentClass: "act-scrlink"
169        });
170        $('.scroll-init a').each(function() {
171            if (!$(this.hash).length) {
172                $(this).parent().hide()
173            }
174        })
175        $(".to-top").on("click", function(a) {
176            a.preventDefault();
177            $("html, body").animate({
178                scrollTop: 0
179            }, 800);
180            return false;
181        });
182        // scroll animation ------------------
183        $(window).on("scroll", function(a) {
184            if ($(this).scrollTop() > 150) {
185                $(".to-top").fadeIn(500);
186                $(".clbtg").fadeIn(500);
187            } else {
188                $(".to-top").fadeOut(500);
189                $(".clbtg").fadeOut(500);
190            }
191        });
192        
193        // Styles ------------------
194        if ($("footer.main-footer").hasClass("fixed-footer")) {
195            $('<div class="height-emulator fl-wrap"></div>').appendTo("#main-theme");
196        }
197
198        function csselem() {
199            $(".height-emulator").css({
200                height: $(".fixed-footer").outerHeight(true)
201            });
202            $(".slideshow-container .slideshow-item").css({
203                height: $(".slideshow-container").outerHeight(true)
204            });
205            $(".slider-container .slider-item").css({
206                height: $(".slider-container").outerHeight(true)
207            });
208        }
209        csselem();
210        // Mob Menu------------------
211        $(".nav-button-wrap").on("click", function() {
212            $(".main-menu").toggleClass("vismobmenu");
213        });
214
215        function mobMenuInit() {
216            var ww = $(window).width();
217            if (ww < 1064) {
218                $(".menusb").remove();
219                $(".main-menu").removeClass("nav-holder");
220                $(".main-menu nav").clone().addClass("menusb").appendTo(".main-menu");
221                $(".menusb").slidingMenu();
222            } else {
223                $(".menusb").remove();
224                $(".main-menu").addClass("nav-holder");
225            }
226        }
227        mobMenuInit();
228        //   css ------------------
229        var $window = $(window);
230        $window.resize(function() {
231            csselem();
232            mobMenuInit();
233        });
234        // $(document.body).bind('added_to_cart', function(event, fragments, cart_hash) {
235        //     if (fragments && fragments['div.widget_shopping_cart_content']) {
236        //         var cart_content = fragments['div.widget_shopping_cart_content'];
237        //         if ($(cart_content).find('.mini_cart_item')) {
238        //             var cart_quantity_total = 0;
239        //             $(cart_content).find('.mini_cart_item').each(function() {
240        //                 cart_quantity_total += parseInt($('span.quantity', this).text());
241        //             });
242        //             $('.attr-nav .cart-link .cart-count').text(cart_quantity_total);
243        //         }
244        //     }
245        // });
246        // new from townhub
247        $(".show-hidden-map").on("click", function(e) {
248            e.preventDefault();
249            var optext = $(this).data('optext'),
250                cltext = $(this).data('cltext');
251            $(".show-hidden-map").find("span").text( $(".show-hidden-map span").text() === cltext ? optext : cltext );
252            $(".hidden-map-container").slideToggle(400);
253        });
254
255        function showColumnhiddenmap() {
256            if ($(window).width() < 1064) {
257                $(".hid-mob-map").animate({
258                    right: 0
259                }, 500, "easeInOutExpo").addClass("fixed-mobile");
260            }
261        }
262        $(".schm").on("click", function(e) {
263            e.preventDefault();
264            showColumnhiddenmap();
265        });
266        if( $(".map-container").length ){
267            $(document).on("click", ".map-item", function(e) {
268                e.preventDefault();
269                showColumnhiddenmap();
270            });
271        }
272        $('.map-close').on("click", function(e) {
273            $(".hid-mob-map").animate({
274                right: "-100%"
275            }, 500, "easeInOutExpo").removeClass("fixed-mobile");
276        });
277        
278
279        function heroAnim() {
280            function a(a) {
281                var b = a.length,
282                    c, d;
283                while (b) {
284                    d = Math.floor(Math.random() * b--);
285                    c = a[b];
286                    a[b] = a[d];
287                    a[d] = c;
288                }
289                return a;
290            }
291            var b = $(".footer-bg-pin");
292            $(a(b).slice(0, $(".footer-bg").data("ran"))).each(function(a) {
293                var bc = $(this);
294                b.removeClass("footer-bg-pin-vis")
295                bc.addClass("footer-bg-pin-vis");
296            });
297        }
298        setInterval(function() {
299            heroAnim();
300        }, 2000);
301        // header search
302        var headSearch = $(".header-search"),
303            ssbut = $(".show-search-button"),
304            op_text = ssbut.data('optext'),
305            cl_text = ssbut.data('cltext'),
306            wlwrp = $(".header-modal"),
307            wllink = $(".show-header-modal"),
308            mainheader = $(".main-header");
309
310        function showSearch() {
311            headSearch.addClass("vis-head-search").removeClass("vis-search");
312            ssbut.find("span").text(cl_text);
313            ssbut.find("i").addClass("vis-head-search-close");
314            mainheader.addClass("vis-searchdec");
315            hideWishlist();
316        }
317
318        function hideSearch() {
319            headSearch.removeClass("vis-head-search").addClass("vis-search");
320            ssbut.find("span").text(op_text);
321            ssbut.find("i").removeClass("vis-head-search-close");
322            mainheader.removeClass("vis-searchdec");
323        }
324        ssbut.on("click", function() {
325            if ($(".header-search").hasClass("vis-search")) showSearch();
326            else hideSearch();
327        });
328        $(".header-search_close").on("click", function() {
329            hideSearch();
330        });
331
332        function showWishlist() {
333            wlwrp.fadeIn(1).addClass("vis-wishlist").removeClass("novis_wishlist")
334            hideSearch();
335            wllink.addClass("scwllink");
336        }
337
338        function hideWishlist() {
339            wlwrp.fadeOut(1).removeClass("vis-wishlist").addClass("novis_wishlist");
340            wllink.removeClass("scwllink");
341        }
342        wllink.on("click", function() {
343            if (wlwrp.hasClass("novis_wishlist")) showWishlist();
344            else hideWishlist();
345        });
346        $(".close-header-modal").on("click", function() {
347            hideWishlist();
348        });
349        
350
351        $(".show-more-snopt").on("click", function (e) {
352            e.preventDefault();
353            $(".show-more-snopt-tooltip").toggleClass("show-more-snopt-tooltip_vis");
354        });
355        // rating item
356        $(".rate-item-bg").each(function () {
357            $(this).find(".rate-item-line").css({
358                width: $(this).attr("data-percent")
359            });
360        });
361
362
363
364        // woocart
365        //   show hide------------------
366        $(".show-cart").on("click", function() {
367            $(".cart-overlay").fadeIn(400);
368            $(".cart-modal").animate({
369                right: 0
370            }, 400);
371            return false;
372        });
373        $(".cart-overlay , .close-cart").on("click", function() {
374            $(".cart-overlay").fadeOut(400);
375            $(".cart-modal").animate({
376                right: "-350px"
377            }, 400);
378            return false;
379        });
380
381        $( document.body ).bind( 'added_to_cart', function( event, fragments, cart_hash ) {
382            if( fragments && fragments['div.widget_shopping_cart_content'] ){
383                var cart_content = fragments['div.widget_shopping_cart_content'];
384
385                if($(cart_content).find('.mini_cart_item')){
386                    var cart_quantity_total = 0;
387                    $(cart_content).find('.mini_cart_item').each(function(){
388                        cart_quantity_total += parseInt($('span.quantity', this).text());
389                    });
390
391                    $('.show-cart .cart-count').text(cart_quantity_total);
392                }
393            }
394        });
395        $( document.body ).bind( 'removed_from_cart', function( event, fragments, cart_hash ) {
396            if( fragments && fragments['div.widget_shopping_cart_content'] ){
397                var cart_content = fragments['div.widget_shopping_cart_content'];
398
399                if($(cart_content).find('.mini_cart_item')){
400                    var cart_quantity_total = 0;
401                    $(cart_content).find('.mini_cart_item').each(function(){
402                        cart_quantity_total += parseInt($('span.quantity', this).text());
403                    });
404
405                    $('.show-cart .cart-count').text(cart_quantity_total);
406                }
407            }
408        });
409
410    }
411    //   Parallax ------------------
412    function initparallax() {
413        if ($('.shapes-decor').length) {
414            $('.shapes-decor').each(function() {
415                $(this).attr('data-scrollax-parent', true);
416                $('<div class="gradient-bg-figure" style="right:-30px;top:10px;"></div>').appendTo($(this));
417                $('<div class="gradient-bg-figure" style="left:-20px;bottom:30px;"></div>').appendTo($(this));
418                $('<div class="circle-wrap" style="left:270px;top:120px;" data-scrollax="properties: { translateY: \'-200px\' }"><div class="circle_bg-bal circle_bg-bal_small"></div></div>').appendTo($(this));
419                $('<div class="circle-wrap" style="right:420px;bottom:-70px;" data-scrollax="properties: { translateY: \'150px\' }"><div class="circle_bg-bal circle_bg-bal_big"></div></div>').appendTo($(this));
420                $('<div class="circle-wrap" style="left:420px;top:-70px;" data-scrollax="properties: { translateY: \'100px\' }"><div class="circle_bg-bal circle_bg-bal_big"></div></div>').appendTo($(this));
421                $('<div class="circle-wrap" style="left:40%;bottom:-70px;"><div class="circle_bg-bal circle_bg-bal_middle"></div></div>').appendTo($(this));
422                $('<div class="circle-wrap" style="right:40%;top:-10px;"><div class="circle_bg-bal circle_bg-bal_versmall" data-scrollax="properties: { translateY: \'-350px\' }"></div></div>').appendTo($(this));
423                $('<div class="circle-wrap" style="right:55%;top:90px;"  ><div class="circle_bg-bal circle_bg-bal_versmall" data-scrollax="properties: { translateY: \'-350px\' }"></div></div>').appendTo($(this));
424            });
425        }
426        var a = {
427            Android: function() {
428                return navigator.userAgent.match(/Android/i);
429            },
430            BlackBerry: function() {
431                return navigator.userAgent.match(/BlackBerry/i);
432            },
433            iOS: function() {
434                return navigator.userAgent.match(/iPhone|iPad|iPod/i);
435            },
436            Opera: function() {
437                return navigator.userAgent.match(/Opera Mini/i);
438            },
439            Windows: function() {
440                return navigator.userAgent.match(/IEMobile/i);
441            },
442            any: function() {
443                return a.Android() || a.BlackBerry() || a.iOS() || a.Opera() || a.Windows();
444            }
445        };
446        var trueMobile = a.any();
447        if (null == trueMobile) {
448            var b = new Scrollax();
449            b.reload();
450            b.init();
451        }
452        if (trueMobile) $(".bgvid , .background-vimeo , .background-youtube-wrapper ").remove();
453
454        if( trueMobile ){
455            resizeOSMMAp();
456            $( window ).resize( function() {
457                resizeOSMMAp();
458            });
459        }
460    }
461    function resizeOSMMAp(){
462        if( $('#map-osm-main').length ){
463            $('#map-osm-main').css('width', $( window ).width() ).css('height', $( window ).height() )
464        }
465    }
466    //   Init All ------------------
467    $(function() {
468        initTownHub();
469        initparallax();
470
471        // // A sample code to change map style
472        // // https://developers.google.com/maps/documentation/javascript/styling#style-example
473        // window.addEventListener('listingsMapInit', function(e){
474            
475        //     window.listingsMap.setOptions({
476        //         scrollwheel: true,
477        //         styles: [
478        //             {
479        //                 featureType: 'poi.business',
480        //                 stylers: [{visibility: 'off'}]
481        //             },
482        //             {
483        //                 featureType: 'transit',
484        //                 elementType: 'labels.icon',
485        //                 stylers: [{visibility: 'off'}]
486        //             }
487        //         ]
488        //     });
489
490
491        // });
492        
493    });
494
495    // new sticky nav
496    // Variables and DOM Caching.
497    var $body = $( 'body' ),
498        $customHeader = $body.find( '.townhub-header' ),
499        $navigation = $body.find( '.nav-holder.main-menu' ),
500        navigationFixedClass = 'site-header-fixed',
501        isFrontPage = $body.hasClass( 'townhub-front-page' ) || $body.hasClass( 'home blog' ),
502        $menuToggle = $body.find( '.nav-button-wrap' ),
503        headerOffset,
504        navIsNotTooTall;
505
506    // Set properties of navigation.
507    function setNavProps() {
508        // navigationHeight      = $navigation.height();
509        // navigationOuterHeight = $navigation.outerHeight();
510        // navPadding            = parseFloat( $navWrap.css( 'padding-top' ) ) * 2;
511        // navMenuItemHeight     = $navMenuItem.outerHeight() * 2;
512        // idealNavHeight        = navPadding + navMenuItemHeight;
513        navIsNotTooTall       = true; // navigationHeight <= idealNavHeight;
514    }
515
516    // Make navigation 'stick'.
517    function adjustScrollClass() {
518
519        // Make sure we're not on a mobile screen.
520        if ( 'none' === $menuToggle.css( 'display' ) ) {
521
522            // Make sure the nav isn't taller than two rows.
523            if ( navIsNotTooTall ) {
524
525                // // When there's a custom header image or video, the header offset includes the height of the navigation.
526                // if ( isFrontPage && ( $body.hasClass( 'has-header-image' ) || $body.hasClass( 'has-header-video' ) ) ) {
527                //     headerOffset = $customHeader.innerHeight() - navigationOuterHeight;
528                // } else {
529                //     headerOffset = $customHeader.innerHeight();
530                // }
531
532
533                headerOffset = $customHeader.innerHeight();
534
535                // If the scroll is more than the custom header, set the fixed class.
536                if ( $( window ).scrollTop() >= headerOffset ) {
537                    $customHeader.addClass( navigationFixedClass );
538                } else {
539                    $customHeader.removeClass( navigationFixedClass );
540                }
541
542            } else {
543
544                // Remove 'fixed' class if nav is taller than two rows.
545                $customHeader.removeClass( navigationFixedClass );
546            }
547        }
548    }
549    // Fire on document ready.
550    $( document ).ready( function() {
551        // If navigation menu is present on page, setNavProps and adjustScrollClass.
552        if ( $customHeader.length ) {
553            setNavProps();
554            adjustScrollClass();
555        }
556    });
557    // If navigation menu is present on page, adjust it on scroll and screen resize.
558    if ( $customHeader.length ) {
559
560        // On scroll, we want to stick/unstick the navigation.
561        $( window ).on( 'scroll', function() {
562            adjustScrollClass();
563        });
564
565        // Also want to make sure the navigation is where it should be on resize.
566        $( window ).resize( function() {
567            setNavProps();
568            setTimeout( adjustScrollClass, 500 );
569        });
570    }
571})(jQuery);
572// open login modal when site loaded
573// (function($) {
574//     "use strict";
575//     $(window).load(function(){
576
577//         setTimeout(function(){
578//             if( $('#ctb-logreg-modal').length ){
579//                 let $modal = $('#ctb-logreg-modal'),
580//                     message = (typeof $(this).data('message') != 'undefined'? $(this).data('message') : '');
581//                 $modal.find('.prelog-message').text('')
582//                 if(message!='') $modal.find('.prelog-message').text(message)
583//                 $modal.fadeIn(200);
584//                 $('.reg-overlay').fadeIn(200);
585//                 $modal.find(".modal_main").addClass("vis_mr");
586//                 $("html, body").addClass("hid-body");
587//             }
588//         }, 3000 );
589
590//     })
591// })(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.