PageSourceSearch

https://efsewi.org/library/assets/js/bootsnav.js

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

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.