/home/hdwebsolution/public_html/ns-interior/js/mmenu.js
/* ----------------- Start Document ----------------- */
(function($){
"use strict";
$(document).ready(function(){
/*--------------------------------------------------*/
/* Mobile Menu - mmenu.js
/*--------------------------------------------------*/
$(function() {
function mmenuInit() {
var wi = $(window).width();
if(wi <= '992') {
$('#footer').removeClass("sticky-footer");
$(".mmenu-init" ).remove();
$("#navigation").clone().addClass("mmenu-init").insertBefore("#navigation").removeAttr('id').removeClass('style-1 style-2').find('ul').removeAttr('id');
$(".mmenu-init").find(".container").removeClass("container");
$(".mmenu-init").mmenu({
"counters": true
}, {
// configuration
offCanvas: {
pageNodetype: "#wrapper"
}
});
var mmenuAPI = $(".mmenu-init").data( "mmenu" );
var $icon = $(".hamburger");
$(".mmenu-trigger").click(function() {
mmenuAPI.open();
});
mmenuAPI.bind( "open:finish", function() {
setTimeout(function() {
$icon.addClass( "is-active" );
});
});
mmenuAPI.bind( "close:finish", function() {
setTimeout(function() {
$icon.removeClass( "is-active" );
});
});
}
$(".mm-next").addClass("mm-fullsubopen");
}
mmenuInit();
$(window).resize(function() { mmenuInit(); });
});
/* User Menu */
$('.user-menu').on('click', function(){
$(this).toggleClass('active');
});
/*----------------------------------------------------*/
/* Sticky Header
/*----------------------------------------------------*/
$( "#header" ).not( "#header-container.header-style-2 #header" ).clone(true).addClass('cloned unsticky').insertAfter( "#header" );
$( "#navigation.style-2" ).clone(true).addClass('cloned unsticky').insertAfter( "#navigation.style-2" );
// Logo for header style 2
$( "#logo .sticky-logo" ).clone(true).prependTo("#navigation.style-2.cloned ul#responsive");
// sticky header script
var headerOffset = $("#header-container").height() * 2; // height on which the sticky header will shows
$(window).scroll(function(){
if($(window).scrollTop() >= headerOffset){
$("#header.cloned").addClass('sticky').removeClass("unsticky");
$("#navigation.style-2.cloned").addClass('sticky').removeClass("unsticky");
} else {
$("#header.cloned").addClass('unsticky').removeClass("sticky");
$("#navigation.style-2.cloned").addClass('unsticky').removeClass("sticky");
}
});
/*----------------------------------------------------*/
/* Tabs
/*----------------------------------------------------*/
var $tabsNav = $('.tabs-nav'),
$tabsNavLis = $tabsNav.children('li');
$tabsNav.each(function() {
var $this = $(this);
$this.next().children('.tab-content').stop(true,true).hide()
.first().show();
$this.children('li').first().addClass('active').stop(true,true).show();
});
$tabsNavLis.on('click', function(e) {
var $this = $(this);
$this.siblings().removeClass('active').end()
.addClass('active');
$this.parent().next().children('.tab-content').stop(true,true).hide()
.siblings( $this.find('a').attr('href') ).fadeIn();
e.preventDefault();
});
var hash = window.location.hash;
var anchor = $('.tabs-nav a[href="' + hash + '"]');
if (anchor.length === 0) {
$(".tabs-nav li:first").addClass("active").show(); //Activate first tab
$(".tab-content:first").show(); //Show first tab content
} else {
console.log(anchor);
anchor.parent('li').click();
}
/*----------------------------------------------------*/
/* Toggle
/*----------------------------------------------------*/
$(".toggle-container").hide();
$('.trigger, .trigger.opened').on('click', function(a){
$(this).toggleClass('active');
a.preventDefault();
});
$(".trigger").on('click', function(){
$(this).next(".toggle-container").slideToggle(300);
});
$(".trigger.opened").addClass("active").next(".toggle-container").show();
/*----------------------------------------------------*/
/* Panel Dropdown
/*----------------------------------------------------*/
function close_panel_dropdown() {
$('.panel-dropdown').removeClass("active");
$('.fs-inner-container.content').removeClass("faded-out");
}
$('.panel-dropdown a').on('click', function(e) {
if ( $(this).parent().is(".active") ) {
close_panel_dropdown();
} else {
close_panel_dropdown();
$(this).parent().addClass('active');
$('.fs-inner-container.content').addClass("faded-out");
}
e.preventDefault();
});
// Apply / Close buttons
$('.panel-buttons button').on('click', function(e) {
$('.panel-dropdown').removeClass('active');
$('.fs-inner-container.content').removeClass("faded-out");
});
// Closes dropdown on click outside the conatainer
var mouse_is_inside = false;
$('.panel-dropdown').hover(function(){
mouse_is_inside=true;
}, function(){
mouse_is_inside=false;
});
$("body").mouseup(function(){
if(! mouse_is_inside) close_panel_dropdown();
});
// Adjusting Panel Dropdown Width
$(window).on('load resize', function() {
var panelTrigger = $('.booking-widget .panel-dropdown a');
$('.booking-widget .panel-dropdown .panel-dropdown-content').css({
'width' : panelTrigger.outerWidth()
});
});
// ------------------ End Document ------------------ //
});
})(this.jQuery);