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