initial commit
This commit is contained in:
709
think.greaterchiangmai.com/public/js/bootsnav.js
Normal file
709
think.greaterchiangmai.com/public/js/bootsnav.js
Normal file
@@ -0,0 +1,709 @@
|
||||
// ------------------------------------------------------------------------------ //
|
||||
//
|
||||
// Template name : Bootsnav - Multi Purpose Header
|
||||
// Categorie : Bootstrap Menu in CSS
|
||||
// Author : adamnurdin01
|
||||
// Version : v.1.2
|
||||
// Created : 2016-06-02
|
||||
// Last update : 2016-10-19
|
||||
//
|
||||
// ------------------------------------------------------------------------------ //
|
||||
|
||||
(function ($) {
|
||||
"use strict";
|
||||
|
||||
var bootsnav = {
|
||||
initialize: function () {
|
||||
this.event();
|
||||
this.hoverDropdown();
|
||||
this.navbarSticky();
|
||||
this.navbarScrollspy();
|
||||
},
|
||||
event: function () {
|
||||
|
||||
// ------------------------------------------------------------------------------ //
|
||||
// Variable
|
||||
// ------------------------------------------------------------------------------ //
|
||||
var getNav = $("nav.navbar.bootsnav");
|
||||
|
||||
// ------------------------------------------------------------------------------ //
|
||||
// Navbar Sticky
|
||||
// ------------------------------------------------------------------------------ //
|
||||
var navSticky = getNav.hasClass("navbar-sticky");
|
||||
if (navSticky) {
|
||||
// Wraped navigation
|
||||
getNav.wrap("<div class='wrap-sticky'></div>");
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------ //
|
||||
// Navbar Center
|
||||
// ------------------------------------------------------------------------------ //
|
||||
if (getNav.hasClass("brand-center")) {
|
||||
var postsArr = new Array(),
|
||||
index = $("nav.brand-center"),
|
||||
$postsList = index.find('ul.navbar-nav');
|
||||
|
||||
index.prepend("<span class='storage-name' style='display:none;'></span>");
|
||||
|
||||
//Create array of all posts in lists
|
||||
index.find('ul.navbar-nav > li').each(function () {
|
||||
if ($(this).hasClass("active")) {
|
||||
var getElement = $("a", this).eq(0).text();
|
||||
$(".storage-name").html(getElement);
|
||||
}
|
||||
postsArr.push($(this).html());
|
||||
});
|
||||
|
||||
//Split the array at this point. The original array is altered.
|
||||
var firstList = postsArr.splice(0, Math.round(postsArr.length / 2)),
|
||||
secondList = postsArr,
|
||||
ListHTML = '';
|
||||
|
||||
var createHTML = function (list) {
|
||||
ListHTML = '';
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
ListHTML += '<li>' + list[i] + '</li>'
|
||||
}
|
||||
}
|
||||
|
||||
//Generate HTML for first list
|
||||
createHTML(firstList);
|
||||
$postsList.html(ListHTML);
|
||||
index.find("ul.nav").first().addClass("navbar-left");
|
||||
|
||||
//Generate HTML for second list
|
||||
createHTML(secondList);
|
||||
//Create new list after original one
|
||||
$postsList.after('<ul class="nav navbar-nav"></ul>').next().html(ListHTML);
|
||||
index.find("ul.nav").last().addClass("navbar-right");
|
||||
|
||||
//Wrap navigation menu
|
||||
index.find("ul.nav.navbar-left").wrap("<div class='col-half left'></div>");
|
||||
index.find("ul.nav.navbar-right").wrap("<div class='col-half right'></div>");
|
||||
|
||||
//Selection Class
|
||||
index.find('ul.navbar-nav > li').each(function () {
|
||||
var dropDown = $("ul.dropdown-menu", this),
|
||||
//added for center logo header
|
||||
simpleMenu = $("ul.simple-dropdown", this),
|
||||
megaMenu = $("ul.megamenu-content", this);
|
||||
dropDown.closest("li").addClass("dropdown");
|
||||
simpleMenu.closest("li").addClass("simple-dropdown");
|
||||
megaMenu.closest("li").addClass("megamenu-fw");
|
||||
});
|
||||
|
||||
var getName = $(".storage-name").html();
|
||||
if (!getName == "") {
|
||||
$("ul.navbar-nav > li:contains('" + getName + "')").addClass("active");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------ //
|
||||
// Navbar Sidebar
|
||||
// ------------------------------------------------------------------------------ //
|
||||
if (getNav.hasClass("navbar-sidebar")) {
|
||||
// Add Class to body
|
||||
$("body").addClass("wrap-nav-sidebar");
|
||||
getNav.wrapInner("<div class='scroller'></div>");
|
||||
} else {
|
||||
$(".bootsnav").addClass("on");
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------ //
|
||||
// Menu Center
|
||||
// ------------------------------------------------------------------------------ //
|
||||
if (getNav.find("ul.nav").hasClass("navbar-center")) {
|
||||
getNav.addClass("menu-center");
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------ //
|
||||
// Navbar Full
|
||||
// ------------------------------------------------------------------------------ //
|
||||
if (getNav.hasClass("navbar-full")) {
|
||||
// Add Class to body
|
||||
$("nav.navbar.bootsnav").find("ul.nav").wrap("<div class='wrap-full-menu'></div>");
|
||||
$(".wrap-full-menu").wrap("<div class='nav-full'></div>");
|
||||
$("ul.nav.navbar-nav").prepend("<li class='close-full-menu'><a href='#'><i class='fa fa-times'></i></a></li>");
|
||||
} else if (getNav.hasClass("navbar-mobile")) {
|
||||
getNav.removeClass("no-full");
|
||||
} else {
|
||||
getNav.addClass("no-full");
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------ //
|
||||
// Navbar Mobile
|
||||
// ------------------------------------------------------------------------------ //
|
||||
if (getNav.hasClass("navbar-mobile")) {
|
||||
// Add Class to body
|
||||
$('.navbar-collapse').on('shown.bs.collapse', function () {
|
||||
$("body").addClass("side-right");
|
||||
});
|
||||
$('.navbar-collapse').on('hide.bs.collapse', function () {
|
||||
$("body").removeClass("side-right");
|
||||
});
|
||||
|
||||
$(window).on("resize", function () {
|
||||
$("body").removeClass("side-right");
|
||||
});
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------ //
|
||||
// Navbar Fixed
|
||||
// ------------------------------------------------------------------------------ //
|
||||
if (getNav.hasClass("no-background")) {
|
||||
$(window).on("scroll", function () {
|
||||
var scrollTop = $(window).scrollTop();
|
||||
if (scrollTop > 34) {
|
||||
$(".navbar-fixed").removeClass("no-background");
|
||||
} else {
|
||||
$(".navbar-fixed").addClass("no-background");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------ //
|
||||
// Navbar Fixed
|
||||
// ------------------------------------------------------------------------------ //
|
||||
if (getNav.hasClass("navbar-transparent")) {
|
||||
$(window).on("scroll", function () {
|
||||
var scrollTop = $(window).scrollTop();
|
||||
if (scrollTop > 34) {
|
||||
$(".navbar-fixed").removeClass("navbar-transparent");
|
||||
} else {
|
||||
$(".navbar-fixed").addClass("navbar-transparent");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------ //
|
||||
// Button Cart
|
||||
// ------------------------------------------------------------------------------ //
|
||||
$(".btn-cart").on("click", function (e) {
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
// ------------------------------------------------------------------------------ //
|
||||
// Toggle Search
|
||||
// ------------------------------------------------------------------------------ //
|
||||
$("nav.navbar.bootsnav .attr-nav").each(function () {
|
||||
$("li.search > a", this).on("click", function (e) {
|
||||
e.preventDefault();
|
||||
$(".top-search").slideToggle();
|
||||
});
|
||||
});
|
||||
$(".input-group-addon.close-search").on("click", function () {
|
||||
$(".top-search").slideUp();
|
||||
});
|
||||
|
||||
// ------------------------------------------------------------------------------ //
|
||||
// Toggle Side Menu
|
||||
// ------------------------------------------------------------------------------ //
|
||||
$("nav.navbar.bootsnav .attr-nav").each(function () {
|
||||
$("li.side-menu > a", this).on("click", function (e) {
|
||||
e.preventDefault();
|
||||
$("nav.navbar.bootsnav > .side").toggleClass("on");
|
||||
$("body").toggleClass("on-side");
|
||||
});
|
||||
});
|
||||
$(".side .close-side").on("click", function (e) {
|
||||
e.preventDefault();
|
||||
$("nav.navbar.bootsnav > .side").removeClass("on");
|
||||
$("body").removeClass("on-side");
|
||||
});
|
||||
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------ //
|
||||
// Wrapper
|
||||
// ------------------------------------------------------------------------------ //
|
||||
//$("body").wrapInner("<div class='wrapper'></div>");
|
||||
},
|
||||
// ------------------------------------------------------------------------------ //
|
||||
// Change dropdown to hover on dekstop
|
||||
// ------------------------------------------------------------------------------ //
|
||||
hoverDropdown: function () {
|
||||
var getNav = $("nav.navbar.bootsnav"),
|
||||
getWindow = $(window).width(),
|
||||
getHeight = $(window).height(),
|
||||
getIn = getNav.find("ul.nav").data("in"),
|
||||
getOut = getNav.find("ul.nav").data("out");
|
||||
|
||||
if (getWindow < 991) {
|
||||
|
||||
// Height of scroll navigation sidebar
|
||||
$(".scroller").css("height", "auto");
|
||||
|
||||
// Disable mouseenter event
|
||||
$("nav.navbar.bootsnav ul.nav").find("li.dropdown").off("mouseenter");
|
||||
$("nav.navbar.bootsnav ul.nav").find("li.dropdown").off("mouseleave");
|
||||
$("nav.navbar.bootsnav ul.nav").find(".title").off("mouseenter");
|
||||
$("nav.navbar.bootsnav ul.nav").off("mouseleave");
|
||||
$(".navbar-collapse").removeClass("animated");
|
||||
|
||||
// Enable click event
|
||||
$("nav.navbar.bootsnav ul.nav").each(function () {
|
||||
$(".dropdown-menu", this).addClass("animated");
|
||||
$(".dropdown-menu", this).removeClass(getOut);
|
||||
|
||||
// Dropdown Fade Toggle
|
||||
$("a.dropdown-toggle", this).off('click');
|
||||
$("a.dropdown-toggle", this).on('click', function (e) {
|
||||
e.stopPropagation();
|
||||
$(this).closest("li.dropdown").find(".dropdown-menu").first().stop().fadeToggle().toggleClass(getIn);
|
||||
$(this).closest("li.dropdown").first().toggleClass("on");
|
||||
return false;
|
||||
});
|
||||
|
||||
// Hidden dropdown action
|
||||
$('li.dropdown', this).each(function () {
|
||||
$(this).find(".dropdown-menu").stop().fadeOut('fast');
|
||||
$(this).on('hidden.bs.dropdown', function () {
|
||||
$(this).find(".dropdown-menu").stop().fadeOut('fast');
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
// Megamenu style
|
||||
$(".megamenu-fw", this).each(function () {
|
||||
$(".col-menu", this).each(function () {
|
||||
$(".content", this).addClass("animated");
|
||||
$(".content", this).stop().fadeOut();
|
||||
$(".title", this).off("click");
|
||||
$(".title", this).on("click", function () {
|
||||
$(this).closest(".col-menu").find(".content").stop().fadeToggle('fast').addClass(getIn);
|
||||
$(this).closest(".col-menu").toggleClass("on");
|
||||
return false;
|
||||
});
|
||||
|
||||
$(".content", this).on("click", function (e) {
|
||||
e.stopPropagation();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Hidden dropdown
|
||||
var cleanOpen = function () {
|
||||
$('li.dropdown', this).removeClass("on");
|
||||
$(".dropdown-menu", this).stop().fadeOut('fast');
|
||||
$(".dropdown-menu", this).removeClass(getIn);
|
||||
$(".col-menu", this).removeClass("on");
|
||||
$(".col-menu .content", this).stop().fadeOut('fast');
|
||||
$(".col-menu .content", this).removeClass(getIn);
|
||||
}
|
||||
|
||||
// Hidden om mouse leave
|
||||
$("nav.navbar.bootsnav").on("mouseleave", function () {
|
||||
cleanOpen();
|
||||
});
|
||||
|
||||
|
||||
// Enable click atribute navigation
|
||||
$("nav.navbar.bootsnav .attr-nav").each(function () {
|
||||
$(".dropdown-menu", this).removeClass("animated");
|
||||
$("li.dropdown", this).off("mouseenter");
|
||||
$("li.dropdown", this).off("mouseleave");
|
||||
$("a.dropdown-toggle", this).off('click');
|
||||
$("a.dropdown-toggle", this).on('click', function (e) {
|
||||
e.stopPropagation();
|
||||
$(this).closest("li.dropdown").find(".dropdown-menu").first().stop().fadeToggle();
|
||||
$(".navbar-toggle").each(function () {
|
||||
$(".fa", this).removeClass("fa-times");
|
||||
$(".fa", this).addClass("fa-bars");
|
||||
$(".navbar-collapse").removeClass("in");
|
||||
$(".navbar-collapse").removeClass("on");
|
||||
});
|
||||
});
|
||||
|
||||
$(this).on("mouseleave", function () {
|
||||
$(".dropdown-menu", this).stop().fadeOut();
|
||||
$("li.dropdown", this).removeClass("on");
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
// Toggle Bars
|
||||
$(".navbar-toggle").each(function () {
|
||||
$(this).off("click");
|
||||
$(this).on("click", function () {
|
||||
$(".fa", this).toggleClass("fa-bars");
|
||||
$(".fa", this).toggleClass("fa-times");
|
||||
cleanOpen();
|
||||
});
|
||||
});
|
||||
|
||||
} else if (getWindow > 991) {
|
||||
// Height of scroll navigation sidebar
|
||||
$(".scroller").css("height", getHeight + "px");
|
||||
|
||||
// Navbar Sidebar
|
||||
if (getNav.hasClass("navbar-sidebar")) {
|
||||
// Hover effect Sidebar Menu
|
||||
$("nav.navbar.bootsnav ul.nav").each(function () {
|
||||
$("a.dropdown-toggle", this).off('click');
|
||||
$("a.dropdown-toggle", this).on('click', function (e) {
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
$(".dropdown-menu", this).addClass("animated");
|
||||
$("li.dropdown", this).on("mouseenter", function () {
|
||||
$(".dropdown-menu", this).eq(0).removeClass(getOut);
|
||||
$(".dropdown-menu", this).eq(0).stop().fadeIn('fast').addClass(getIn);
|
||||
$(this).addClass("on");
|
||||
return false;
|
||||
});
|
||||
|
||||
$(".col-menu").each(function () {
|
||||
$(".content", this).addClass("animated");
|
||||
$(".title", this).on("mouseenter", function () {
|
||||
$(this).closest(".col-menu").find(".content").stop().fadeIn('fast').addClass(getIn);
|
||||
$(this).closest(".col-menu").addClass("on");
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
$(this).on("mouseleave", function () {
|
||||
$(".dropdown-menu", this).stop().removeClass(getIn);
|
||||
$(".dropdown-menu", this).stop().addClass(getOut).fadeOut('fast');
|
||||
$(".col-menu", this).find(".content").stop().fadeOut('fast').removeClass(getIn);
|
||||
$(".col-menu", this).removeClass("on");
|
||||
$("li.dropdown", this).removeClass("on");
|
||||
return false;
|
||||
});
|
||||
});
|
||||
} else {
|
||||
var isSafari = !!navigator.userAgent.match(/Version\/[\d\.]+.*Safari/);
|
||||
|
||||
// Hover effect Default Menu
|
||||
$("nav.navbar.bootsnav ul.nav").each(function () {
|
||||
$("a.dropdown-toggle", this).off('click');
|
||||
$("a.dropdown-toggle", this).on('click', function (e) {
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
$(".megamenu-fw", this).each(function () {
|
||||
$(".title", this).off("click");
|
||||
$("a.dropdown-toggle", this).off("click");
|
||||
$(".content").removeClass("animated");
|
||||
});
|
||||
|
||||
$(".dropdown-menu", this).addClass("animated");
|
||||
|
||||
// user hover on single menu then hide its sibling children menu
|
||||
if( $( '.navbar-left-sidebar' ).length > 0 || $( '.left-nav-sidebar' ).length > 0 ) {
|
||||
|
||||
$("li:not(.dropdown)", this).on("mouseenter", function () {
|
||||
$(this).parent().find('.dropdown-menu').stop().fadeOut('fast');
|
||||
});
|
||||
|
||||
$( document ).on( 'click', '.side-left-menu-close.active', function(e) {
|
||||
$( this ).removeClass( 'active' );
|
||||
});
|
||||
}
|
||||
|
||||
$("li.dropdown", this).on("mouseenter", function () {
|
||||
var _this = this;
|
||||
/** iPad scroll issue - start **/
|
||||
$('.re-open').removeClass('re-open');
|
||||
/** iPad scroll issue - end **/
|
||||
|
||||
$( '.side-left-menu-close' ).addClass( 'active' );
|
||||
|
||||
if( $( '.navbar-left-sidebar' ).length > 0 || $( '.left-nav-sidebar' ).length > 0 ) {
|
||||
|
||||
$(this).parent().find('.dropdown').removeClass("on");
|
||||
if( $(this).parents('.dropdown-menu').length > 0 ) { // child
|
||||
$(this).parents('.dropdown-menu').find('.dropdown-menu').not( $( '.dropdown-menu', this ) ).stop().fadeOut('fast');
|
||||
} else { // main
|
||||
$(this).parents('.bootsnav .nav').find('.dropdown-menu').not( $( '.dropdown-menu', this ) ).stop().fadeOut('fast');
|
||||
$(":not(.second-level)", this).find('.third-level').stop().fadeOut('fast');
|
||||
}
|
||||
|
||||
if( $(this).parent().hasClass( "second-level" ) ) {
|
||||
$(this).parents( '.navbar-nav' ).addClass( "enter" );
|
||||
} else if( $( this ).parent().hasClass( "enter" ) ) {
|
||||
$( '.navbar-nav' ).removeClass( "enter" );
|
||||
}
|
||||
}
|
||||
|
||||
$(".dropdown-menu", this).eq(0).removeClass(getOut);
|
||||
if(isSafari)
|
||||
$(".dropdown-menu", _this).eq(0).stop().fadeIn('fast').addClass(getIn);
|
||||
else
|
||||
$(".dropdown-menu", _this).eq(0).stop().fadeIn('fast').addClass(getIn);
|
||||
$(this).addClass("on");
|
||||
|
||||
if( $( '.navbar-left-sidebar' ).length > 0 || $( '.left-nav-sidebar' ).length > 0 ) {
|
||||
|
||||
if( $( '.left-nav-sidebar' ).length > 0 ) {
|
||||
var menu_width = $( '.sidebar-part1' ).outerWidth();
|
||||
menu_width = menu_width + 20;
|
||||
menu_width = menu_width + $( '.left-nav-on .navbar-nav' ).outerWidth();
|
||||
} else {
|
||||
var menu_width = $( '.navbar-nav' ).outerWidth();
|
||||
}
|
||||
|
||||
var mainWidth = $(window).width();
|
||||
setTimeout( function() {
|
||||
|
||||
$( '.dropdown' ).each( function() {
|
||||
if( $( this ).hasClass( 'on' ) ) {
|
||||
menu_width = menu_width + $( '.dropdown-menu li', this ).outerWidth();
|
||||
}
|
||||
});
|
||||
$( '.side-left-menu-close' ).width(mainWidth - menu_width);
|
||||
}, 300 );
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
$("li.dropdown", this).on("mouseleave", function () {
|
||||
$(".dropdown-menu", this).eq(0).removeClass(getIn);
|
||||
|
||||
if ( $(".dropdown-menu", this).css("display") == "none" || !( $( '.navbar-left-sidebar' ).length > 0 || $( '.left-nav-sidebar' ).length > 0 ) || $(this).parents( '.bootsnav .nav' ).hasClass( "enter" ) ) {
|
||||
|
||||
if(isSafari)
|
||||
$(".dropdown-menu", this).eq(0).stop().fadeOut('fast').addClass(getOut);
|
||||
else
|
||||
$(".dropdown-menu", this).eq(0).stop().fadeOut('fast').addClass(getOut);
|
||||
|
||||
$(this).removeClass("on");
|
||||
}
|
||||
|
||||
|
||||
|
||||
if( $( '.navbar-left-sidebar' ).length > 0 || $( '.left-nav-sidebar' ).length > 0 ) {
|
||||
|
||||
$( '.side-left-menu-close' ).addClass( 'active' );
|
||||
|
||||
if( $( '.left-nav-sidebar' ).length > 0 ) {
|
||||
var menu_width = $( '.sidebar-part1' ).outerWidth();
|
||||
menu_width = menu_width + 20;
|
||||
menu_width = menu_width + $( '.left-nav-on .navbar-nav' ).outerWidth();
|
||||
} else {
|
||||
var menu_width = $( '.navbar-nav' ).outerWidth();
|
||||
}
|
||||
|
||||
var mainWidth = $(window).width();
|
||||
setTimeout( function() {
|
||||
|
||||
$( '.dropdown' ).each( function() {
|
||||
if( $( this ).hasClass( 'on' ) ) {
|
||||
menu_width = menu_width + $( '.dropdown-menu li', this ).outerWidth();
|
||||
}
|
||||
});
|
||||
$( '.side-left-menu-close' ).width( mainWidth - menu_width );
|
||||
}, 300 );
|
||||
}
|
||||
});
|
||||
|
||||
$(this).on("mouseleave", function () {
|
||||
$(".dropdown-menu", this).removeClass(getIn);
|
||||
$( '.side-left-menu-close' ).removeClass( 'active' );
|
||||
|
||||
if (isSafari)
|
||||
$(".dropdown-menu", this).eq(0).stop().fadeOut('fast').addClass(getOut);
|
||||
else
|
||||
$(".dropdown-menu", this).eq(0).stop().fadeOut('fast').addClass(getOut);
|
||||
$("li.dropdown", this).removeClass("on");
|
||||
|
||||
if( $( '.navbar-left-sidebar' ).length > 0 || $( '.left-nav-sidebar' ).length > 0 ) {
|
||||
if( $( '.bootsnav .nav' ).hasClass( "enter" ) ) {
|
||||
$( '.bootsnav .nav' ).removeClass( "enter" );
|
||||
} else {
|
||||
$( '.bootsnav .nav' ).find('.dropdown-menu').fadeOut('fast');
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------ //
|
||||
// Hover effect Atribute Navigation
|
||||
// ------------------------------------------------------------------------------ //
|
||||
$("nav.navbar.bootsnav .attr-nav").each(function () {
|
||||
$("a.dropdown-toggle", this).off('click');
|
||||
$("a.dropdown-toggle", this).on('click', function (e) {
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
$(".dropdown-menu", this).addClass("animated");
|
||||
$("li.dropdown", this).on("mouseenter", function () {
|
||||
$(".dropdown-menu", this).eq(0).removeClass(getOut);
|
||||
$(".dropdown-menu", this).eq(0).stop().fadeIn('fast').addClass(getIn);
|
||||
$(this).addClass("on");
|
||||
return false;
|
||||
});
|
||||
|
||||
$("li.dropdown", this).on("mouseleave", function () {
|
||||
$(".dropdown-menu", this).eq(0).removeClass(getIn);
|
||||
$(".dropdown-menu", this).eq(0).stop().fadeOut('fast').addClass(getOut);
|
||||
$(this).removeClass("on");
|
||||
});
|
||||
|
||||
$(this).on("mouseleave", function () {
|
||||
$(".dropdown-menu", this).removeClass(getIn);
|
||||
$(".dropdown-menu", this).eq(0).stop().fadeOut('fast').addClass(getOut);
|
||||
$("li.dropdown", this).removeClass("on");
|
||||
return false;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------ //
|
||||
// Menu Fullscreen
|
||||
// ------------------------------------------------------------------------------ //
|
||||
if (getNav.hasClass("navbar-full")) {
|
||||
var windowHeight = $(window).height(),
|
||||
windowWidth = $(window).width();
|
||||
|
||||
$(".nav-full").css("height", windowHeight + "px");
|
||||
$(".wrap-full-menu").css("height", windowHeight + "px");
|
||||
$(".wrap-full-menu").css("width", windowWidth + "px");
|
||||
|
||||
$(".navbar-collapse").addClass("animated");
|
||||
$(".navbar-toggle").each(function () {
|
||||
var getId = $(this).data("target");
|
||||
$(this).off("click");
|
||||
$(this).on("click", function (e) {
|
||||
e.preventDefault();
|
||||
$(getId).removeClass(getOut);
|
||||
$(getId).addClass("in");
|
||||
$(getId).addClass(getIn);
|
||||
return false;
|
||||
});
|
||||
|
||||
$("li.close-full-menu").on("click", function (e) {
|
||||
e.preventDefault();
|
||||
$(getId).addClass(getOut);
|
||||
setTimeout(function () {
|
||||
$(getId).removeClass("in");
|
||||
$(getId).removeClass(getIn);
|
||||
}, 500);
|
||||
return false;
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
// ------------------------------------------------------------------------------ //
|
||||
// Navbar Sticky
|
||||
// ------------------------------------------------------------------------------ //
|
||||
navbarSticky: function () {
|
||||
var getNav = $("nav.navbar.bootsnav"),
|
||||
navSticky = getNav.hasClass("navbar-sticky");
|
||||
|
||||
if (navSticky) {
|
||||
|
||||
// Set Height Navigation
|
||||
var getHeight = getNav.height();
|
||||
$(".wrap-sticky").height(getHeight);
|
||||
|
||||
// Windown on scroll
|
||||
var getOffset = $(".wrap-sticky").offset().top;
|
||||
$(window).on("scroll", function () {
|
||||
var scrollTop = $(window).scrollTop();
|
||||
if (scrollTop > getOffset) {
|
||||
getNav.addClass("sticked");
|
||||
} else {
|
||||
getNav.removeClass("sticked");
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
// ------------------------------------------------------------------------------ //
|
||||
// Navbar Scrollspy
|
||||
// ------------------------------------------------------------------------------ //
|
||||
navbarScrollspy: function () {
|
||||
var navScrollSpy = $(".navbar-scrollspy"),
|
||||
$body = $('body'),
|
||||
getNav = $('nav.navbar.bootsnav'),
|
||||
offset = getNav.outerHeight();
|
||||
|
||||
if (navScrollSpy.length) {
|
||||
$body.scrollspy({ target: '.navbar', offset: offset });
|
||||
|
||||
// Animation Scrollspy
|
||||
$('.scroll').on('click', function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
// Active link
|
||||
$('.scroll').removeClass("active");
|
||||
$(this).addClass("active");
|
||||
|
||||
// Remove navbar collapse
|
||||
$(".navbar-collapse").removeClass("in");
|
||||
|
||||
// Toggle Bars
|
||||
$(".navbar-toggle").each(function () {
|
||||
$(".fa", this).removeClass("fa-times");
|
||||
$(".fa", this).addClass("fa-bars");
|
||||
});
|
||||
|
||||
// Scroll
|
||||
var scrollTop = $(window).scrollTop(),
|
||||
$anchor = $(this).find('a'),
|
||||
$section = $($anchor.attr('href')).offset().top,
|
||||
$window = $(window).width(),
|
||||
$minusDesktop = getNav.data("minus-value-desktop"),
|
||||
$minusMobile = getNav.data("minus-value-mobile"),
|
||||
$speed = getNav.data("speed");
|
||||
|
||||
if ($window > 992) {
|
||||
var $position = $section - $minusDesktop;
|
||||
} else {
|
||||
var $position = $section - $minusMobile;
|
||||
}
|
||||
|
||||
$('html, body').stop().animate({
|
||||
scrollTop: $position
|
||||
}, $speed);
|
||||
});
|
||||
|
||||
// Activate Navigation
|
||||
var fixSpy = function () {
|
||||
var data = $body.data('bs.scrollspy');
|
||||
if (data) {
|
||||
offset = getNav.outerHeight();
|
||||
data.options.offset = offset;
|
||||
$body.data('bs.scrollspy', data);
|
||||
$body.scrollspy('refresh');
|
||||
}
|
||||
}
|
||||
|
||||
// Activate Navigation on resize
|
||||
var resizeTimer;
|
||||
$(window).on('resize', function () {
|
||||
clearTimeout(resizeTimer);
|
||||
var resizeTimer = setTimeout(fixSpy, 200);
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Initialize
|
||||
$(document).ready(function () {
|
||||
bootsnav.initialize();
|
||||
});
|
||||
|
||||
// Reset on resize
|
||||
$(window).on("resize", function () {
|
||||
bootsnav.hoverDropdown();
|
||||
setTimeout(function () {
|
||||
bootsnav.navbarSticky();
|
||||
}, 500);
|
||||
|
||||
// Toggle Bars
|
||||
$(".navbar-toggle").each(function () {
|
||||
$(".fa", this).removeClass("fa-times");
|
||||
$(".fa", this).addClass("fa-bars");
|
||||
$(this).removeClass("fixed");
|
||||
});
|
||||
$(".navbar-collapse").removeClass("in");
|
||||
$(".navbar-collapse").removeClass("on");
|
||||
$(".navbar-collapse").removeClass("bounceIn");
|
||||
});
|
||||
|
||||
} (jQuery));
|
||||
File diff suppressed because one or more lines are too long
64
think.greaterchiangmai.com/public/js/hamburger-menu.js
Normal file
64
think.greaterchiangmai.com/public/js/hamburger-menu.js
Normal file
@@ -0,0 +1,64 @@
|
||||
/*==============================================================
|
||||
pull menu
|
||||
==============================================================*/
|
||||
|
||||
function bindEvent(el, eventName, eventHandler) {
|
||||
if (el.addEventListener) {
|
||||
el.addEventListener(eventName, eventHandler, false);
|
||||
} else if (el.attachEvent) {
|
||||
el.attachEvent('on' + eventName, eventHandler);
|
||||
}
|
||||
}
|
||||
|
||||
(function () {
|
||||
|
||||
var bodyEl = document.body,
|
||||
//content = document.querySelector( '.content-wrap' ),
|
||||
openbtn = document.getElementById('open-button'),
|
||||
closebtn = document.getElementById('close-button'),
|
||||
isOpen = false;
|
||||
|
||||
function init() {
|
||||
initEvents();
|
||||
}
|
||||
|
||||
function initEvents() {
|
||||
if (openbtn) {
|
||||
bindEvent(openbtn, 'click', toggleMenu);
|
||||
|
||||
}
|
||||
//openbtn.addEventListener( 'click', toggleMenu );
|
||||
if (closebtn) {
|
||||
|
||||
bindEvent(closebtn, 'click', toggleMenu);
|
||||
//closebtn.addEventListener( 'click', toggleMenu );
|
||||
}
|
||||
|
||||
// close the menu element if the target it´s not the menu element or one of its descendants..
|
||||
|
||||
}
|
||||
|
||||
function toggleMenu() {
|
||||
|
||||
if (isOpen) {
|
||||
classie.remove(bodyEl, 'show-menu');
|
||||
if ( $( ".full-width-pull-menu" ).length ) {
|
||||
classie.remove(bodyEl, 'overflow-hidden');
|
||||
classie.remove(bodyEl, 'position-fixed');
|
||||
}
|
||||
}
|
||||
else {
|
||||
classie.add(bodyEl, 'show-menu');
|
||||
|
||||
if ( $( ".full-width-pull-menu" ).length ) {
|
||||
classie.add(bodyEl, 'overflow-hidden');
|
||||
classie.add(bodyEl, 'position-fixed');
|
||||
}
|
||||
|
||||
}
|
||||
isOpen = !isOpen;
|
||||
}
|
||||
|
||||
init();
|
||||
|
||||
})();
|
||||
2
think.greaterchiangmai.com/public/js/jquery.min.js
vendored
Normal file
2
think.greaterchiangmai.com/public/js/jquery.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
224
think.greaterchiangmai.com/public/js/jquery.nav.js
Normal file
224
think.greaterchiangmai.com/public/js/jquery.nav.js
Normal file
@@ -0,0 +1,224 @@
|
||||
/*
|
||||
* jQuery One Page Nav Plugin
|
||||
* http://github.com/davist11/jQuery-One-Page-Nav
|
||||
*
|
||||
* Copyright (c) 2010 Trevor Davis (http://trevordavis.net)
|
||||
* Dual licensed under the MIT and GPL licenses.
|
||||
* Uses the same license as jQuery, see:
|
||||
* http://jquery.org/license
|
||||
*
|
||||
* @version 3.0.0
|
||||
*
|
||||
* Example usage:
|
||||
* $('#nav').onePageNav({
|
||||
* currentClass: 'current',
|
||||
* changeHash: false,
|
||||
* scrollSpeed: 750
|
||||
* });
|
||||
*/
|
||||
|
||||
;(function($, window, document, undefined){
|
||||
|
||||
// our plugin constructor
|
||||
var OnePageNav = function(elem, options){
|
||||
this.elem = elem;
|
||||
this.$elem = $(elem);
|
||||
this.options = options;
|
||||
this.metadata = this.$elem.data('plugin-options');
|
||||
this.$win = $(window);
|
||||
this.sections = {};
|
||||
this.didScroll = false;
|
||||
this.$doc = $(document);
|
||||
this.docHeight = this.$doc.height();
|
||||
};
|
||||
|
||||
// the plugin prototype
|
||||
OnePageNav.prototype = {
|
||||
defaults: {
|
||||
navItems: 'a',
|
||||
currentClass: 'current',
|
||||
changeHash: false,
|
||||
easing: 'swing',
|
||||
filter: '',
|
||||
scrollSpeed: 750,
|
||||
scrollThreshold: 0.5,
|
||||
begin: false,
|
||||
end: false,
|
||||
scrollChange: false
|
||||
},
|
||||
|
||||
init: function() {
|
||||
// Introduce defaults that can be extended either
|
||||
// globally or using an object literal.
|
||||
this.config = $.extend({}, this.defaults, this.options, this.metadata);
|
||||
|
||||
//this.$nav = this.$elem.find(this.config.navItems)
|
||||
this.$nav = this.$elem.find(this.config.navItems).not(".directpage");
|
||||
|
||||
//Filter any links out of the nav
|
||||
if(this.config.filter !== '') {
|
||||
this.$nav = this.$nav.filter(this.config.filter);
|
||||
}
|
||||
|
||||
//Handle clicks on the nav
|
||||
this.$nav.on('click.onePageNav', $.proxy(this.handleClick, this));
|
||||
|
||||
//Get the section positions
|
||||
this.getPositions();
|
||||
|
||||
//Handle scroll changes
|
||||
this.bindInterval();
|
||||
|
||||
//Update the positions on resize too
|
||||
this.$win.on('resize.onePageNav', $.proxy(this.getPositions, this));
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
adjustNav: function(self, $parent) {
|
||||
self.$elem.find('.' + self.config.currentClass).removeClass(self.config.currentClass);
|
||||
$parent.addClass(self.config.currentClass);
|
||||
},
|
||||
|
||||
bindInterval: function() {
|
||||
var self = this;
|
||||
var docHeight;
|
||||
|
||||
self.$win.on('scroll.onePageNav', function() {
|
||||
self.didScroll = true;
|
||||
});
|
||||
|
||||
self.t = setInterval(function() {
|
||||
docHeight = self.$doc.height();
|
||||
|
||||
//If it was scrolled
|
||||
if(self.didScroll) {
|
||||
self.didScroll = false;
|
||||
self.scrollChange();
|
||||
}
|
||||
|
||||
//If the document height changes
|
||||
if(docHeight !== self.docHeight) {
|
||||
self.docHeight = docHeight;
|
||||
self.getPositions();
|
||||
}
|
||||
}, 250);
|
||||
},
|
||||
|
||||
getHash: function($link) {
|
||||
return $link.attr('href').split('#')[1];
|
||||
},
|
||||
|
||||
getPositions: function() {
|
||||
var self = this;
|
||||
var linkHref;
|
||||
var topPos;
|
||||
var $target;
|
||||
|
||||
self.$nav.each(function() {
|
||||
linkHref = self.getHash($(this));
|
||||
$target = $('#' + linkHref);
|
||||
|
||||
if($target.length) {
|
||||
topPos = $target.offset().top;
|
||||
self.sections[linkHref] = Math.round(topPos);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
getSection: function(windowPos) {
|
||||
var returnValue = null;
|
||||
var windowHeight = Math.round(this.$win.height() * this.config.scrollThreshold);
|
||||
|
||||
for(var section in this.sections) {
|
||||
if((this.sections[section] - windowHeight) < windowPos) {
|
||||
returnValue = section;
|
||||
}
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
},
|
||||
|
||||
handleClick: function(e) {
|
||||
var self = this;
|
||||
var $link = $(e.currentTarget);
|
||||
var $parent = $link.parent();
|
||||
var newLoc = '#' + self.getHash($link);
|
||||
|
||||
if(!$parent.hasClass(self.config.currentClass)) {
|
||||
//Start callback
|
||||
if(self.config.begin) {
|
||||
self.config.begin();
|
||||
}
|
||||
|
||||
//Change the highlighted nav item
|
||||
self.adjustNav(self, $parent);
|
||||
|
||||
//Removing the auto-adjust on scroll
|
||||
self.unbindInterval();
|
||||
|
||||
//Scroll to the correct position
|
||||
self.scrollTo(newLoc, function() {
|
||||
//Do we need to change the hash?
|
||||
if(self.config.changeHash) {
|
||||
window.location.hash = newLoc;
|
||||
}
|
||||
|
||||
//Add the auto-adjust on scroll back in
|
||||
self.bindInterval();
|
||||
|
||||
//End callback
|
||||
if(self.config.end) {
|
||||
self.config.end();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
},
|
||||
|
||||
scrollChange: function() {
|
||||
var windowTop = this.$win.scrollTop();
|
||||
var position = this.getSection(windowTop);
|
||||
var $parent;
|
||||
|
||||
//If the position is set
|
||||
if(position !== null) {
|
||||
$parent = this.$elem.find('a[href$="#' + position + '"]').parent();
|
||||
|
||||
//If it's not already the current section
|
||||
if(!$parent.hasClass(this.config.currentClass)) {
|
||||
//Change the highlighted nav item
|
||||
this.adjustNav(this, $parent);
|
||||
|
||||
//If there is a scrollChange callback
|
||||
if(this.config.scrollChange) {
|
||||
this.config.scrollChange($parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
scrollTo: function(target, callback) {
|
||||
var offset = $(target).offset().top;
|
||||
|
||||
$('html, body').animate({
|
||||
scrollTop: offset
|
||||
}, this.config.scrollSpeed, this.config.easing, callback);
|
||||
},
|
||||
|
||||
unbindInterval: function() {
|
||||
clearInterval(this.t);
|
||||
this.$win.unbind('scroll.onePageNav');
|
||||
}
|
||||
};
|
||||
|
||||
OnePageNav.defaults = OnePageNav.prototype.defaults;
|
||||
|
||||
$.fn.onePageNav = function(options) {
|
||||
return this.each(function() {
|
||||
new OnePageNav(this, options).init();
|
||||
});
|
||||
};
|
||||
|
||||
})( jQuery, window , document );
|
||||
1899
think.greaterchiangmai.com/public/js/main.js
Normal file
1899
think.greaterchiangmai.com/public/js/main.js
Normal file
File diff suppressed because it is too large
Load Diff
1
think.greaterchiangmai.com/public/js/retina.min.js.map
Normal file
1
think.greaterchiangmai.com/public/js/retina.min.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"retina.min.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
||||
File diff suppressed because one or more lines are too long
138
think.greaterchiangmai.com/public/js/theme-vendors.min.js
vendored
Normal file
138
think.greaterchiangmai.com/public/js/theme-vendors.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user