PageSourceSearch

https://www.kidzlearn.co/files/theme/custom.js

js kidzlearn.co collected 2026-10-01 14:20:26 UTC 5,906 bytes, 201 lines download raw bytes

1jQuery(function($) {
2
3  // Check your elements
4  $.fn.checkNavPositioning = function($el, $nav, scrollClass) {
5    var navHeight = $nav.outerHeight();
6
7    if(((this.outerHeight() - $(window).scrollTop()) < $nav.outerHeight()) && !$el.hasClass(scrollClass)) {
8      $el.addClass(scrollClass);
9      $el.css('padding-top', navHeight);
10    } else if((this.outerHeight() >= $(window).scrollTop()) && $el.hasClass(scrollClass)) {
11      $el.removeClass(scrollClass);
12      $el.css('padding-top', 0);
13    }
14  }
15
16  // Mobile sidebars
17  $.fn.expandableSidebar = function(expandedClass) {
18    var $me = this;
19
20    $me.on('click', function() {
21      if(!$me.hasClass(expandedClass)) {
22        $me.addClass(expandedClass);
23      } else {
24        $me.removeClass(expandedClass);
25      }
26    });
27  }
28
29  // Interval loop
30  $.fn.intervalLoop = function(condition, action, duration, limit) {
31    var counter = 0;
32    var looper = setInterval(function(){
33      if (counter >= limit || $.fn.checkIfElementExists(condition)) {
34        clearInterval(looper);
35      } else {
36        action();
37        counter++;
38      }
39    }, duration);
40  }
41
42  // Check if element exists
43  $.fn.checkIfElementExists = function(selector) {
44    return $(selector).length;
45  }
46
47
48  var centoController = {
49    init: function(opts) {
50      var base = this;
51
52      // Check content positioning
53      if($(window).width() > 767) {
54        $('.cento-header').checkNavPositioning($('body:not(.wsite-checkout-page)'), $('.nav-wrap'), 'affix');
55      }
56
57      // Add classes to elements
58      base._addClasses();
59        base._attachEvents();
60
61        setTimeout(function() {
62            $.fn.intervalLoop('', base._checkCartItems, 800, 3);
63        }, 500);
64    },
65
66    _addClasses: function() {
67      var base = this;
68
69      // Add class to nav items with subnav
70      $('.wsite-menu-default').find('li.wsite-menu-item-wrap').each(function(){
71        var $me = $(this);
72
73        if($me.children('.wsite-menu-wrap').length > 0) {
74
75          $me.addClass('has-submenu');
76          $('<span class="icon-caret"></span>').insertAfter($me.children('a.wsite-menu-item'));
77        }
78      });
79
80      // Add class to subnav items with subnav
81      $('.wsite-menu').find('li.wsite-menu-subitem-wrap').each(function(){
82        var $me = $(this);
83
84        if($me.children('.wsite-menu-wrap').length > 0) {
85
86          $me.addClass('has-submenu');
87          $('<span class="icon-caret"></span>').insertAfter($me.children('a.wsite-menu-subitem'));
88        }
89      });
90
91      // Keep subnav open if submenu item is active
92    $('li.wsite-menu-subitem-wrap.wsite-nav-current').parents('.wsite-menu-wrap').addClass('open');
93
94      // Add placeholder text to inputs
95      $('.wsite-form-sublabel').each(function(){
96        var sublabel = $(this).text();
97        $(this).prev('.wsite-form-input').attr('placeholder', sublabel);
98      });
99
100      // Add fullwidth class to gallery thumbs if less than 6
101      $('.imageGallery').each(function(){
102        if ($(this).children('div').length <= 6) {
103          $(this).children('div').addClass('fullwidth-mobile');
104        }
105      });
106    },
107
108    _checkCartItems: function() {
109      var base = this;
110
111      if($('#wsite-mini-cart').find('li.wsite-product-item').length > 0) {
112        $('body').addClass('cart-full');
113      } else {
114        $('body').removeClass('cart-full');
115      }
116    },
117
118    _moveLogin: function() {
119      var loginDetach = $('#member-login').detach();
120      $('.mobile-nav .wsite-menu-default > li:last-child').after(loginDetach);
121    },
122
123    _attachEvents: function() {
124      var base = this;
125
126        // Nav toggle
127        $('.hamburger').on('click', function(e) {
128          e.preventDefault();
129            if(!$('body').hasClass('nav-open')) {
130                $('body').addClass('nav-open');
131            } else {
132                $('body').removeClass('nav-open');
133            }
134        });
135
136      // Move cart + login
137      if ($(window).width() <= 992) {
138        $.fn.intervalLoop('.mobile-nav #member-login', base._moveLogin, 800, 5);
139      }
140
141      // Window scroll
142      $(window).on('scroll', function(){
143        // Affix nav
144        if($(window).width() > 767) {
145          $('.cento-header').checkNavPositioning($('body:not(.wsite-checkout-page)'), $('.nav-wrap'), 'affix');
146        }
147      });
148
149        // Subnav toggle
150        $('li.has-submenu span.icon-caret').on('click', function() {
151            var $me = $(this);
152
153            if($me.siblings('.wsite-menu-wrap').hasClass('open')) {
154                $me.siblings('.wsite-menu-wrap').removeClass('open');
155            } else {
156                $me.siblings('.wsite-menu-wrap').addClass('open');
157            }
158        });
159
160
161      // Store category dropdown
162      $('.wsite-com-sidebar').expandableSidebar('sidebar-expanded');
163
164      // Search filters dropdown
165      $('#wsite-search-sidebar').expandableSidebar('sidebar-expanded');
166
167      // Init fancybox swipe on mobile
168      if ('ontouchstart' in window) {
169        $('body').on('click', 'a.w-fancybox', function() {
170          base._initSwipeGallery();
171        });
172      }
173
174      $('.wsite-product-button, #wsite-com-product-add-to-cart, .wsite-product-item .wsite-remove-button').on('click', function(){
175          setTimeout(function() { base._checkCartItems(); }, 800);
176        });
177    },
178
179    _initSwipeGallery: function() {
180      var base = this;
181
182      setTimeout(function(){
183        var touchGallery = document.getElementsByClassName('fancybox-wrap')[0];
184        var mc = new Hammer(touchGallery);
185        mc.on("panleft panright", function(ev) {
186          if (ev.type == "panleft") {
187            $("a.fancybox-next").trigger("click");
188          } else if (ev.type == "panright") {
189            $("a.fancybox-prev").trigger("click");
190          }
191          base._initSwipeGallery();
192        });
193      }, 500);
194    }
195  }
196
197  $(document).ready(function(){
198    centoController.init();
199  });
200
201});

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.