/* * Inspinia js helpers, adapted from the original Inspinia template's inspinia.js: * * correctHeight() - fix the height of main wrapper * detectBody() - detect windows size * smoothlyMenu() - add smooth fade in/out on navigation show/hide * */ declare let require: any; const jQuery = require('./theme/js/jquery.min.js'); export class InspiniaHelper { public toggleNavMenu() { jQuery('body').toggleClass('mini-navbar'); this.smoothlyMenu(); } public smoothlyMenu() { if (!jQuery('body').hasClass('mini-navbar') || jQuery('body').hasClass('body-small')) { // Hide menu in order to smoothly turn on when maximize menu jQuery('#side-menu').hide(); // For smoothly turn on menu setTimeout( function () { jQuery('#side-menu').fadeIn(400); }, 200); } else if (jQuery('body').hasClass('fixed-sidebar')) { jQuery('#side-menu').hide(); setTimeout( function () { jQuery('#side-menu').fadeIn(400); }, 100); } else { // Remove all inline style from jquery fadeIn function to reset menu state jQuery('#side-menu').removeAttr('style'); } } public adjustSize() { const correctHeight = this.correctHeight; const detectBody = this.detectBody; // Run correctHeight function on load and resize window event jQuery(window).bind('load resize', function () { correctHeight(); detectBody(); }); // Correct height of wrapper after metisMenu animation. jQuery('.metismenu a').click(() => { setTimeout(() => { correctHeight(); }, 300) }); } private correctHeight() { const pageWrapper = jQuery('#page-wrapper'); const navbarHeight = jQuery('nav.navbar-default').height(); const wrapperHeigh = pageWrapper.height(); console.log('correctHeight!!'); if (navbarHeight > wrapperHeigh) { pageWrapper.css('min-height', navbarHeight + 'px'); } if (navbarHeight < wrapperHeigh) { if (navbarHeight < jQuery(window).height()) { pageWrapper.css('min-height', jQuery(window).height() + 'px'); } else { pageWrapper.css('min-height', navbarHeight + 'px'); } } if (jQuery('body').hasClass('fixed-nav')) { if (navbarHeight > wrapperHeigh) { pageWrapper.css('min-height', navbarHeight + 'px'); } else { pageWrapper.css('min-height', jQuery(window).height() - 60 + 'px'); } } } private detectBody() { console.log('detectBody!!'); if (jQuery(document).width() < 769) { jQuery('body').addClass('body-small') } else { jQuery('body').removeClass('body-small') } } }