PageSourceSearch

https://www.purplewaveindia.com/js/bootsnav.js

js purplewaveindia.com collected 2026-10-01 13:04:21 UTC 27,701 bytes, 578 lines download raw bytes

1(function ($) {
2	"use strict";
3    
4    var bootsnav = {
5        initialize: function() {
6            this.event();
7            this.hoverDropdown();
8            this.navbarSticky();
9            this.navbarScrollspy();
10        },
11        event : function(){
12            
13            // ------------------------------------------------------------------------------ //
14            // Variable
15            // ------------------------------------------------------------------------------ //
16            var getNav = $("nav.navbar.bootsnav");
17            
18            // ------------------------------------------------------------------------------ //
19            // Navbar Sticky 
20            // ------------------------------------------------------------------------------ //
21            var navSticky = getNav.hasClass("navbar-sticky");
22            if( navSticky ){
23                // Wraped navigation
24                getNav.wrap("<div class='wrap-sticky'></div>");
25            }   
26            
27            // ------------------------------------------------------------------------------ //
28            // Navbar Center 
29            // ------------------------------------------------------------------------------ //
30            if( getNav.hasClass("brand-center")){                
31                var postsArr = new Array(),
32                    index = $("nav.brand-center"),
33                    $postsList = index.find('ul.navbar-nav');
34
35                //Create array of all posts in lists
36                index.find('ul.navbar-nav > li').each(function(){
37                    postsArr.push($(this).html());
38                });
39                
40                //Split the array at this point. The original array is altered.
41                var firstList = postsArr.splice(0, Math.round(postsArr.length / 2)),
42                    secondList = postsArr,
43                    ListHTML = '';
44                
45                var createHTML = function(list){
46                    ListHTML = '';
47                    for (var i = 0; i < list.length; i++) {
48                        ListHTML += '<li>' + list[i] + '</li>'
49                    }
50                }
51                
52                //Generate HTML for first list
53                createHTML(firstList);
54                $postsList.html(ListHTML);
55                index.find("ul.nav").first().addClass("navbar-left");
56                
57                //Generate HTML for second list
58                createHTML(secondList);
59                //Create new list after original one
60                $postsList.after('<ul class="nav navbar-nav"></ul>').next().html(ListHTML);
61                index.find("ul.nav").last().addClass("navbar-right");
62                
63                //Wrap navigation menu
64                index.find("ul.nav.navbar-left").wrap("<div class='col-half left'></div>");
65                index.find("ul.nav.navbar-right").wrap("<div class='col-half right'></div>");
66                
67                //Selection Class
68                index.find('ul.navbar-nav > li').each(function(){ 
69                    var dropDown = $("ul.dropdown-menu", this),
70                        megaMenu = $("ul.megamenu-content", this);
71                    dropDown.closest("li").addClass("dropdown");
72                    megaMenu.closest("li").addClass("megamenu-fw");
73                });
74            }
75            
76            
77            // ------------------------------------------------------------------------------ //
78            // Navbar Sidebar 
79            // ------------------------------------------------------------------------------ //
80            if( getNav.hasClass("navbar-sidebar")){
81                // Add Class to body
82                $("body").addClass("wrap-nav-sidebar");
83                getNav.wrapInner("<div class='scroller'></div>");
84            }else{
85                $(".bootsnav").addClass("on");
86            }
87            
88            // ------------------------------------------------------------------------------ //
89            // Menu Center 
90            // ------------------------------------------------------------------------------ //
91            if( getNav.find("ul.nav").hasClass("navbar-center")){
92                getNav.addClass("menu-center");
93            }
94            
95            // ------------------------------------------------------------------------------ //
96            // Navbar Full
97            // ------------------------------------------------------------------------------ //
98            if( getNav.hasClass("navbar-full")){
99                // Add Class to body
100                $("nav.navbar.bootsnav").find("ul.nav").wrap("<div class='wrap-full-menu'></div>");
101                $(".wrap-full-menu").wrap("<div class='nav-full'></div>");
102                $("ul.nav.navbar-nav").prepend("<li class='close-full-menu'><a href='#'><i class='fa fa-times'></i></a></li>");
103            }else if( getNav.hasClass("navbar-mobile")){
104                getNav.removeClass("no-full");
105            }else{
106                getNav.addClass("no-full");
107            }
108                
109            // ------------------------------------------------------------------------------ //
110            // Navbar Mobile
111            // ------------------------------------------------------------------------------ //
112            if( getNav.hasClass("navbar-mobile")){
113                // Add Class to body
114                $('.navbar-collapse').on('shown.bs.collapse', function() {
115                    $("body").addClass("side-right");
116                });
117                $('.navbar-collapse').on('hide.bs.collapse', function() {
118                    $("body").removeClass("side-right");
119                });
120                
121                $(window).on("resize", function(){
122                    $("body").removeClass("side-right");
123                });
124            }
125            
126            // ------------------------------------------------------------------------------ //
127            // Navbar Fixed
128            // ------------------------------------------------------------------------------ //
129            if( getNav.hasClass("no-background")){
130                $(window).on("scroll", function(){
131                    var scrollTop = $(window).scrollTop();
132                    if(scrollTop >34){
133                        $(".navbar-fixed").removeClass("no-background");
134                    }else {
135                        $(".navbar-fixed").addClass("no-background");
136                    }
137                });
138            }
139            
140            // ------------------------------------------------------------------------------ //
141            // Navbar Fixed
142            // ------------------------------------------------------------------------------ //
143            if( getNav.hasClass("navbar-transparent")){
144                $(window).on("scroll", function(){
145                    var scrollTop = $(window).scrollTop();
146                    if(scrollTop >34){
147                        $(".navbar-fixed").removeClass("navbar-transparent");
148                    }else {
149                        $(".navbar-fixed").addClass("navbar-transparent");
150                    }
151                });
152            }
153            
154            // ------------------------------------------------------------------------------ //
155            // Button Cart
156            // ------------------------------------------------------------------------------ //
157            $(".btn-cart").on("click", function(e){
158                e.stopPropagation();
159            });
160            
161            // ------------------------------------------------------------------------------ //
162            // Toggle Search
163            // ------------------------------------------------------------------------------ //
164            $("nav.navbar.bootsnav .attr-nav").each(function(){  
165                $("li.search > a", this).on("click", function(e){
166                    e.preventDefault();
167                    $(".top-search").slideToggle();
168                });
169            });
170            $(".input-group-addon.close-search").on("click", function(){
171                $(".top-search").slideUp();
172            });
173            
174            // ------------------------------------------------------------------------------ //
175            // Toggle Side Menu
176            // ------------------------------------------------------------------------------ //
177            $("nav.navbar.bootsnav .attr-nav").each(function(){  
178                $("li.side-menu > a", this).on("click", function(e){
179                    e.preventDefault();
180                    $("nav.navbar.bootsnav > .side").toggleClass("on");
181                    $("body").toggleClass("on-side");
182                });
183            });
184            $(".side .close-side").on("click", function(e){
185                e.preventDefault();
186                $("nav.navbar.bootsnav > .side").removeClass("on");
187                $("body").removeClass("on-side");
188            });  
189            
190            
191            
192            // ------------------------------------------------------------------------------ //
193            // Wrapper
194            // ------------------------------------------------------------------------------ //
195            $("body").wrapInner( "<div class='wrapper'></div>");
196        }, 
197        
198
199        // ------------------------------------------------------------------------------ //
200        // Change dropdown to hover on dekstop
201        // ------------------------------------------------------------------------------ //
202        hoverDropdown : function(){
203            var getNav = $("nav.navbar.bootsnav"),
204                getWindow = $(window).width(),
205                getHeight = $(window).height(),
206                getIn = getNav.find("ul.nav").data("in"),
207                getOut = getNav.find("ul.nav").data("out");
208            
209            if( getWindow < 981 ){
210                
211                // Height of scroll navigation sidebar
212                $(".scroller").css("height", "auto");
213                
214                // Disable mouseenter event
215                $("nav.navbar.bootsnav ul.nav").find("li.dropdown").off("mouseenter");
216                $("nav.navbar.bootsnav ul.nav").find("li.dropdown").off("mouseleave");
217                $("nav.navbar.bootsnav ul.nav").find(".title").off("mouseenter"); 
218                $("nav.navbar.bootsnav ul.nav").off("mouseleave");    
219                $(".navbar-collapse").removeClass("animated");
220                
221                // Enable click event
222                $("nav.navbar.bootsnav ul.nav").each(function(){
223                    $(".dropdown-menu", this).addClass("animated");
224                    $(".dropdown-menu", this).removeClass(getOut);
225                    
226                    // Dropdown Fade Toggle
227                    $("a.dropdown-toggle", this).off('click');
228                    $("a.dropdown-toggle", this).on('click', function (e) {
229                        e.stopPropagation();
230                        $(this).closest("li.dropdown").find(".dropdown-menu").first().stop().fadeToggle().toggleClass(getIn);
231                        $(this).closest("li.dropdown").first().toggleClass("on");                        
232                        return false;
233                    });   
234                    
235                    // Hidden dropdown action
236                    $('li.dropdown', this).each(function () {
237                        $(this).find(".dropdown-menu").stop().fadeOut();
238                        $(this).on('hidden.bs.dropdown', function () {
239                            $(this).find(".dropdown-menu").stop().fadeOut();
240                        });
241                        return false;
242                    });
243
244                    // Megamenu style
245                    $(".megamenu-fw", this).each(function(){
246                        $(".col-menu", this).each(function(){
247                            $(".content", this).addClass("animated");
248                            $(".content", this).stop().fadeOut();
249                            $(".title", this).off("click");
250                            $(".title", this).on("click", function(){
251                                $(this).closest(".col-menu").find(".content").stop().fadeToggle().addClass(getIn);
252                                $(this).closest(".col-menu").toggleClass("on");
253                                return false;
254                            });
255
256                            $(".content", this).on("click", function(e){
257                                e.stopPropagation();
258                            });
259                        });
260                    });  
261                }); 
262                
263                // Hidden dropdown
264                var cleanOpen = function(){
265                    $('li.dropdown', this).removeClass("on");
266                    $(".dropdown-menu", this).stop().fadeOut();
267                    $(".dropdown-menu", this).removeClass(getIn);
268                    $(".col-menu", this).removeClass("on");
269                    $(".col-menu .content", this).stop().fadeOut();
270                    $(".col-menu .content", this).removeClass(getIn);
271                }
272                
273                // Hidden om mouse leave
274                $("nav.navbar.bootsnav").on("mouseleave", function(){
275                    cleanOpen();
276                });
277                
278                // Enable click atribute navigation
279                $("nav.navbar.bootsnav .attr-nav").each(function(){  
280                    $(".dropdown-menu", this).removeClass("animated");
281                    $("li.dropdown", this).off("mouseenter");
282                    $("li.dropdown", this).off("mouseleave");                    
283                    $("a.dropdown-toggle", this).off('click');
284                    $("a.dropdown-toggle", this).on('click', function (e) {
285                        e.stopPropagation();
286                        $(this).closest("li.dropdown").find(".dropdown-menu").first().stop().fadeToggle();
287                        $(".navbar-toggle").each(function(){
288                            $(".fa", this).removeClass("fa-times");
289                            $(".fa", this).addClass("fa-bars");
290                            $(".navbar-collapse").removeClass("in");
291                            $(".navbar-collapse").removeClass("on");
292                        });
293                    });
294                    
295                    $(this).on("mouseleave", function(){
296                        $(".dropdown-menu", this).stop().fadeOut();
297                        $("li.dropdown", this).removeClass("on");
298                        return false;
299                    });
300                });
301                
302                // Toggle Bars
303                $(".navbar-toggle").each(function(){
304                    $(this).off("click");
305                    $(this).on("click", function(){
306                        $(".fa", this).toggleClass("fa-bars");
307                        $(".fa", this).toggleClass("fa-times");
308                        cleanOpen();
309                    });
310                });
311
312            }else if( getWindow > 981 ){
313                // Height of scroll navigation sidebar
314                $(".scroller").css("height", getHeight + "px");
315                
316                // Navbar Sidebar
317                if( getNav.hasClass("navbar-sidebar")){
318                    // Hover effect Sidebar Menu
319                    $("nav.navbar.bootsnav ul.nav").each(function(){  
320                        $("a.dropdown-toggle", this).off('click');
321                        $("a.dropdown-toggle", this).on('click', function (e) {
322                            e.stopPropagation();
323                        }); 
324
325                        $(".dropdown-menu", this).addClass("animated");
326                        $("li.dropdown", this).on("mouseenter", function(){
327                            $(".dropdown-menu", this).eq(0).removeClass(getOut);
328                            $(".dropdown-menu", this).eq(0).stop().fadeIn().addClass(getIn);
329                            $(this).addClass("on");
330                            return false;
331                        });
332                        
333                        $(".col-menu").each(function(){
334                            $(".content", this).addClass("animated");
335                            $(".title", this).on("mouseenter", function(){
336                                $(this).closest(".col-menu").find(".content").stop().fadeIn().addClass(getIn);
337                                $(this).closest(".col-menu").addClass("on");
338                                return false;
339                            });
340                        });
341                        
342                        $(this).on("mouseleave", function(){
343                            $(".dropdown-menu", this).stop().removeClass(getIn);
344                            $(".dropdown-menu", this).stop().addClass(getOut).fadeOut();
345                            $(".col-menu", this).find(".content").stop().fadeOut().removeClass(getIn);
346                            $(".col-menu", this).removeClass("on");
347                            $("li.dropdown", this).removeClass("on");
348                            return false;
349                        });
350                    }); 
351                }else{
352                    // Hover effect Default Menu
353                    $("nav.navbar.bootsnav ul.nav").each(function(){  
354                        $("a.dropdown-toggle", this).off('click');
355                        $("a.dropdown-toggle", this).on('click', function (e) {
356                            e.stopPropagation();
357                        }); 
358
359                        $(".megamenu-fw", this).each(function(){
360                            $(".title", this).off("click");
361                            $("a.dropdown-toggle", this).off("click");
362                            $(".content").removeClass("animated");
363                        });
364
365                        $(".dropdown-menu", this).addClass("animated");
366                        $("li.dropdown", this).on("mouseenter", function(){
367                            $(".dropdown-menu", this).eq(0).removeClass(getOut);
368                            $(".dropdown-menu", this).eq(0).stop().fadeIn().addClass(getIn);
369                            $(this).addClass("on");
370                            return false;
371                        });
372
373                        $("li.dropdown", this).on("mouseleave", function(){
374                            $(".dropdown-menu", this).eq(0).removeClass(getIn);
375                            $(".dropdown-menu", this).eq(0).stop().fadeOut().addClass(getOut);
376                            $(this).removeClass("on");
377                        });
378
379                        $(this).on("mouseleave", function(){
380                            $(".dropdown-menu", this).removeClass(getIn);
381                            $(".dropdown-menu", this).eq(0).stop().fadeOut().addClass(getOut);
382                            $("li.dropdown", this).removeClass("on");
383                            return false;
384                        });
385                    });
386                }
387                
388                // ------------------------------------------------------------------------------ //
389                // Hover effect Atribute Navigation
390                // ------------------------------------------------------------------------------ //
391                $("nav.navbar.bootsnav .attr-nav").each(function(){                      
392                    $("a.dropdown-toggle", this).off('click');
393                    $("a.dropdown-toggle", this).on('click', function (e) {
394                        e.stopPropagation();
395                    }); 
396                    
397                    $(".dropdown-menu", this).addClass("animated");
398                    $("li.dropdown", this).on("mouseenter", function(){
399                        $(".dropdown-menu", this).eq(0).removeClass(getOut);
400                        $(".dropdown-menu", this).eq(0).stop().fadeIn().addClass(getIn);
401                        $(this).addClass("on");
402                        return false;
403                    });
404
405                    $("li.dropdown", this).on("mouseleave", function(){
406                        $(".dropdown-menu", this).eq(0).removeClass(getIn);
407                        $(".dropdown-menu", this).eq(0).stop().fadeOut().addClass(getOut);
408                        $(this).removeClass("on");
409                    });
410
411                    $(this).on("mouseleave", function(){
412                        $(".dropdown-menu", this).removeClass(getIn);
413                        $(".dropdown-menu", this).eq(0).stop().fadeOut().addClass(getOut);
414                        $("li.dropdown", this).removeClass("on");
415                        return false;
416                    });
417                });
418            }
419            
420            // ------------------------------------------------------------------------------ //
421            // Menu Fullscreen
422            // ------------------------------------------------------------------------------ //
423            if( getNav.hasClass("navbar-full")){
424                var windowHeight = $(window).height(),
425                    windowWidth =  $(window).width();
426
427                $(".nav-full").css("height", windowHeight + "px");
428                $(".wrap-full-menu").css("height", windowHeight + "px");
429                $(".wrap-full-menu").css("width", windowWidth + "px");
430                
431                $(".navbar-collapse").addClass("animated");
432                $(".navbar-toggle").each(function(){
433                    var getId = $(this).data("target");
434                    $(this).off("click");
435                    $(this).on("click", function(e){
436                        e.preventDefault();
437                        $(getId).removeClass(getOut);
438                        $(getId).addClass("in");
439                        $(getId).addClass(getIn);
440                        return false;
441                    });
442                    
443                    $("li.close-full-menu").on("click", function(e){
444                        e.preventDefault();
445                        $(getId).addClass(getOut);
446                        setTimeout(function(){
447                            $(getId).removeClass("in");
448                            $(getId).removeClass(getIn);
449                        }, 500);
450                        return false;
451                    });
452                });
453            }
454        },
455        
456        // ------------------------------------------------------------------------------ //
457        // Navbar Sticky
458        // ------------------------------------------------------------------------------ //
459        navbarSticky : function(){  
460            var getNav = $("nav.navbar.bootsnav"),
461                navSticky = getNav.hasClass("navbar-sticky");
462            
463            if( navSticky ){
464                
465                // Set Height Navigation
466                var getHeight = getNav.height();             
467                $(".wrap-sticky").height(getHeight);
468                
469                // Windown on scroll
470                var getOffset = $(".wrap-sticky").offset().top;
471                $(window).on("scroll", function(){  
472                    var scrollTop = $(window).scrollTop();
473                    if(scrollTop > getOffset){
474                        getNav.addClass("sticked");
475                    }else {
476                        getNav.removeClass("sticked");
477                    }
478                });
479            }   
480        },
481        
482        // ------------------------------------------------------------------------------ //
483        // Navbar Scrollspy
484        // ------------------------------------------------------------------------------ //
485        navbarScrollspy : function(){ 
486            var navScrollSpy = $(".navbar-scrollspy"),
487                $body   = $('body'), 
488                getNav = $('nav.navbar.bootsnav'),
489                offset  = getNav.outerHeight();
490            
491            if( navScrollSpy.length ){
492                $body.scrollspy({target: '.navbar', offset: offset });
493                
494                // Animation Scrollspy
495                $('.scroll').on('click', function(event) {
496                    event.preventDefault();
497
498                    // Active link
499                    $('.scroll').removeClass("active");
500                    $(this).addClass("active");
501
502                    // Remove navbar collapse
503                    $(".navbar-collapse").removeClass("in");
504
505                    // Toggle Bars
506                    $(".navbar-toggle").each(function(){
507                        $(".fa", this).removeClass("fa-times");
508                        $(".fa", this).addClass("fa-bars");
509                    });
510
511                    // Scroll
512                    var scrollTop = $(window).scrollTop(),
513                        $anchor = $(this).find('a'),
514                        $section = $($anchor.attr('href')).offset().top,
515                        $window = $(window).width(),
516                        $minusDesktop = getNav.data("minus-value-desktop"),
517                        $minusMobile = getNav.data("minus-value-mobile"),
518                        $speed = getNav.data("speed");
519                    
520                    if( $window > 992 ){
521                        var $position = $section - $minusDesktop;
522                    }else{
523                        var $position = $section - $minusMobile;
524                    }             
525                        
526                    $('html, body').stop().animate({
527                        scrollTop: $position
528                    }, $speed);
529                });
530                
531                // Activate Navigation
532                var fixSpy = function() {
533                    var data = $body.data('bs.scrollspy');
534                    if (data) {
535                        offset = getNav.outerHeight();
536                        data.options.offset = offset;
537                        $body.data('bs.scrollspy', data);
538                        $body.scrollspy('refresh');
539                    }
540                }
541                
542                // Activate Navigation on resize
543                var resizeTimer;
544                $(window).on('resize', function() {
545                    clearTimeout(resizeTimer);
546                    var resizeTimer = setTimeout(fixSpy, 200);
547                });
548            }
549        }
550    };
551    
552    // Initialize
553    $(document).ready(function(){
554        bootsnav.initialize();
555    });
556    
557    // Reset on resize
558    $(window).on("resize", function(){   
559        bootsnav.hoverDropdown();
560        
561        $(".top-search").slideUp();
562        setTimeout(function(){
563            bootsnav.navbarSticky();
564        }, 500);
565        
566        // Toggle Bars
567        $(".navbar-toggle").each(function(){
568            $(".fa", this).removeClass("fa-times");
569            $(".fa", this).addClass("fa-bars");
570            $(this).removeClass("fixed");
571        });        
572        $(".navbar-collapse").removeClass("in");
573        $(".navbar-collapse").removeClass("on");
574        $(".navbar-collapse").removeClass("bounceIn");      
575    });
576    
577}(jQuery));
578

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.