Built motion from commit 5e31ea4.|0.0.32
[motion.git] / public / assets / scripts / global / layout.js
index 5b6762e..f010909 100644 (file)
@@ -1,7 +1,7 @@
 /**
 Core script to handle the entire theme and core functions
 **/
-var Layout = function () {
+var Layout = function() {
 
   var layoutImgPath = 'img/';
 
@@ -13,7 +13,7 @@ var Layout = function () {
   // this function handles responsive layout on screen size resize or mobile device rotate.
 
   // Set proper height for sidebar and content. The content and sidebar height must be synced always.
-  var handleSidebarAndContentHeight = function () {
+  var handleSidebarAndContentHeight = function() {
     var content = $('.page-content');
     var sidebar = $('.page-sidebar');
     var body = $('body');
@@ -49,7 +49,7 @@ var Layout = function () {
   };
 
   // Handle sidebar menu links
-  var handleSidebarMenuActiveLink = function (mode, el) {
+  var handleSidebarMenuActiveLink = function(mode, el) {
     var url = location.hash.toLowerCase();
 
     var menu = $('.page-sidebar-menu');
@@ -57,7 +57,7 @@ var Layout = function () {
     if (mode === 'click' || mode === 'set') {
       el = $(el);
     } else if (mode === 'match') {
-      menu.find("li > a").each(function () {
+      menu.find("li > a").each(function() {
         var path = $(this).attr("href").toLowerCase();
         // url match condition
         if (path.length > 1 && url.substr(1, path.length - 1) == path.substr(1)) {
@@ -83,7 +83,7 @@ var Layout = function () {
     menu.find('li > a > .selected').remove();
 
     if (menu.hasClass('page-sidebar-menu-hover-submenu') === false) {
-      menu.find('li.open').each(function () {
+      menu.find('li.open').each(function() {
         if ($(this).children('.sub-menu').size() === 0) {
           $(this).removeClass('open');
           $(this).find('> a > .arrow.open').removeClass('open');
@@ -93,7 +93,7 @@ var Layout = function () {
       menu.find('li.open').removeClass('open');
     }
 
-    el.parents('li').each(function () {
+    el.parents('li').each(function() {
       $(this).addClass('active');
       $(this).find('> a > span.arrow').addClass('open');
 
@@ -114,9 +114,9 @@ var Layout = function () {
   };
 
   // Handle sidebar menu
-  var handleSidebarMenu = function () {
+  var handleSidebarMenu = function() {
     // handle sidebar link click
-    jQuery('.page-sidebar').on('click', 'li > a', function (e) {
+    jQuery('.page-sidebar').on('click', 'li > a', function(e) {
       var hasSubMenu = $(this).next().hasClass('sub-menu');
 
       if (Metronic.getViewPort().width >= resBreakpointMd && $(this).parents('.page-sidebar-menu-hover-submenu').size() === 1) { // exit of hover sidebar menu
@@ -154,7 +154,7 @@ var Layout = function () {
       if (sub.is(":visible")) {
         jQuery('.arrow', jQuery(this)).removeClass("open");
         jQuery(this).parent().removeClass("open");
-        sub.slideUp(slideSpeed, function () {
+        sub.slideUp(slideSpeed, function() {
           if (autoScroll === true && $('body').hasClass('page-sidebar-closed') === false) {
             if ($('body').hasClass('page-sidebar-fixed')) {
               menu.slimScroll({
@@ -169,7 +169,7 @@ var Layout = function () {
       } else if (hasSubMenu) {
         jQuery('.arrow', jQuery(this)).addClass("open");
         jQuery(this).parent().addClass("open");
-        sub.slideDown(slideSpeed, function () {
+        sub.slideDown(slideSpeed, function() {
           if (autoScroll === true && $('body').hasClass('page-sidebar-closed') === false) {
             if ($('body').hasClass('page-sidebar-fixed')) {
               menu.slimScroll({
@@ -187,7 +187,7 @@ var Layout = function () {
     });
 
     // handle ajax links within sidebar menu
-    jQuery('.page-sidebar').on('click', ' li > a.ajaxify', function (e) {
+    jQuery('.page-sidebar').on('click', ' li > a.ajaxify', function(e) {
       e.preventDefault();
       Metronic.scrollTop();
 
@@ -199,7 +199,7 @@ var Layout = function () {
       menuContainer.children('li.active').removeClass('active');
       menuContainer.children('arrow.open').removeClass('open');
 
-      $(this).parents('li').each(function () {
+      $(this).parents('li').each(function() {
         $(this).addClass('active');
         $(this).children('a > span.arrow').addClass('open');
       });
@@ -218,7 +218,7 @@ var Layout = function () {
         cache: false,
         url: url,
         dataType: "html",
-        success: function (res) {
+        success: function(res) {
           if (the.parents('li.open').size() === 0) {
             $('.page-sidebar-menu > li.open > a').click();
           }
@@ -228,7 +228,7 @@ var Layout = function () {
           Layout.fixContentHeight(); // fix content height
           Metronic.initAjax(); // initialize core stuff
         },
-        error: function (xhr, ajaxOptions, thrownError) {
+        error: function(xhr, ajaxOptions, thrownError) {
           Metronic.stopPageLoading();
           pageContentBody.html('<h4>Could not load the requested content.</h4>');
         }
@@ -236,7 +236,7 @@ var Layout = function () {
     });
 
     // handle ajax link within main content
-    jQuery('.page-content').on('click', '.ajaxify', function (e) {
+    jQuery('.page-content').on('click', '.ajaxify', function(e) {
       e.preventDefault();
       Metronic.scrollTop();
 
@@ -255,13 +255,13 @@ var Layout = function () {
         cache: false,
         url: url,
         dataType: "html",
-        success: function (res) {
+        success: function(res) {
           Metronic.stopPageLoading();
           pageContentBody.html(res);
           Layout.fixContentHeight(); // fix content height
           Metronic.initAjax(); // initialize core stuff
         },
-        error: function (xhr, ajaxOptions, thrownError) {
+        error: function(xhr, ajaxOptions, thrownError) {
           pageContentBody.html('<h4>Could not load the requested content.</h4>');
           Metronic.stopPageLoading();
         }
@@ -272,13 +272,13 @@ var Layout = function () {
     handleFixedSidebarHoverEffect();
 
     // handle the search bar close
-    $('.page-sidebar').on('click', '.sidebar-search .remove', function (e) {
+    $('.page-sidebar').on('click', '.sidebar-search .remove', function(e) {
       e.preventDefault();
       $('.sidebar-search').removeClass("open");
     });
 
     // handle the search query submit on enter press
-    $('.page-sidebar .sidebar-search').on('keypress', 'input.form-control', function (e) {
+    $('.page-sidebar .sidebar-search').on('keypress', 'input.form-control', function(e) {
       if (e.which == 13) {
         $('.sidebar-search').submit();
         return false; //<---- Add this line
@@ -304,11 +304,11 @@ var Layout = function () {
 
     // handle close on body click
     if ($('.sidebar-search').size() !== 0) {
-      $('.sidebar-search .input-group').on('click', function (e) {
+      $('.sidebar-search .input-group').on('click', function(e) {
         e.stopPropagation();
       });
 
-      $('body').on('click', function () {
+      $('body').on('click', function() {
         if ($('.sidebar-search').hasClass('open')) {
           $('.sidebar-search').removeClass("open");
         }
@@ -317,7 +317,7 @@ var Layout = function () {
   };
 
   // Helper function to calculate sidebar height for fixed sidebar layout.
-  var _calculateFixedSidebarViewportHeight = function () {
+  var _calculateFixedSidebarViewportHeight = function() {
     var sidebarHeight = Metronic.getViewPort().height - $('.page-header').outerHeight();
     if ($('body').hasClass("page-footer-fixed")) {
       sidebarHeight = sidebarHeight - $('.page-footer').outerHeight();
@@ -327,7 +327,7 @@ var Layout = function () {
   };
 
   // Handles fixed sidebar
-  var handleFixedSidebar = function () {
+  var handleFixedSidebar = function() {
     var menu = $('.page-sidebar-menu');
 
     Metronic.destroySlimScroll(menu);
@@ -345,14 +345,14 @@ var Layout = function () {
   };
 
   // Handles sidebar toggler to close/hide the sidebar.
-  var handleFixedSidebarHoverEffect = function () {
+  var handleFixedSidebarHoverEffect = function() {
     var body = $('body');
     if (body.hasClass('page-sidebar-fixed')) {
-      $('.page-sidebar').on('mouseenter', function () {
+      $('.page-sidebar').on('mouseenter', function() {
         if (body.hasClass('page-sidebar-closed')) {
           $(this).find('.page-sidebar-menu').removeClass('page-sidebar-menu-closed');
         }
-      }).on('mouseleave', function () {
+      }).on('mouseleave', function() {
         if (body.hasClass('page-sidebar-closed')) {
           $(this).find('.page-sidebar-menu').addClass('page-sidebar-menu-closed');
         }
@@ -361,7 +361,7 @@ var Layout = function () {
   };
 
   // Hanles sidebar toggler
-  var handleSidebarToggler = function () {
+  var handleSidebarToggler = function() {
     var body = $('body');
     if ($.cookie && $.cookie('sidebar_closed') === '1' && Metronic.getViewPort().width >= resBreakpointMd) {
       $('body').addClass('page-sidebar-closed');
@@ -373,36 +373,36 @@ var Layout = function () {
     }
 
     // handle sidebar show/hide
-    $('body').on('click', '.sidebar-toggler', function (e) {
-      var sidebar = $('.page-sidebar');
-      var sidebarMenu = $('.page-sidebar-menu');
-      $(".sidebar-search", sidebar).removeClass("open");
-
-      if (body.hasClass("page-sidebar-closed")) {
-        body.removeClass("page-sidebar-closed");
-        sidebarMenu.removeClass("page-sidebar-menu-closed");
-        if ($.cookie) {
-          $.cookie('sidebar_closed', '0');
-        }
-      } else {
-        body.addClass("page-sidebar-closed");
-        sidebarMenu.addClass("page-sidebar-menu-closed");
-        if (body.hasClass("page-sidebar-fixed")) {
-          sidebarMenu.trigger("mouseleave");
-        }
-        if ($.cookie) {
-          $.cookie('sidebar_closed', '1');
-        }
-      }
-
-      $(window).trigger('resize');
-    });
+    // $('body').on('click', '.sidebar-toggler', function (e) {
+    //   var sidebar = $('.page-sidebar');
+    //   var sidebarMenu = $('.page-sidebar-menu');
+    //   $(".sidebar-search", sidebar).removeClass("open");
+    //
+    //   if (body.hasClass("page-sidebar-closed")) {
+    //     body.removeClass("page-sidebar-closed");
+    //     sidebarMenu.removeClass("page-sidebar-menu-closed");
+    //     if ($.cookie) {
+    //       $.cookie('sidebar_closed', '0');
+    //     }
+    //   } else {
+    //     body.addClass("page-sidebar-closed");
+    //     sidebarMenu.addClass("page-sidebar-menu-closed");
+    //     if (body.hasClass("page-sidebar-fixed")) {
+    //       sidebarMenu.trigger("mouseleave");
+    //     }
+    //     if ($.cookie) {
+    //       $.cookie('sidebar_closed', '1');
+    //     }
+    //   }
+    //
+    //   $(window).trigger('resize');
+    // });
   };
 
   // Handles the horizontal menu
-  var handleHorizontalMenu = function () {
+  var handleHorizontalMenu = function() {
     //handle tab click
-    $('.page-header').on('click', '.hor-menu a[data-toggle="tab"]', function (e) {
+    $('.page-header').on('click', '.hor-menu a[data-toggle="tab"]', function(e) {
       e.preventDefault();
       var nav = $(".hor-menu .nav");
       var active_link = nav.find('li.current');
@@ -414,18 +414,18 @@ var Layout = function () {
     });
 
     // handle search box expand/collapse
-    $('.page-header').on('click', '.search-form', function (e) {
+    $('.page-header').on('click', '.search-form', function(e) {
       $(this).addClass("open");
       $(this).find('.form-control').focus();
 
-      $('.page-header .search-form .form-control').on('blur', function (e) {
+      $('.page-header .search-form .form-control').on('blur', function(e) {
         $(this).closest('.search-form').removeClass("open");
         $(this).unbind("blur");
       });
     });
 
     // handle hor menu search form on enter press
-    $('.page-header').on('keypress', '.hor-menu .search-form .form-control', function (e) {
+    $('.page-header').on('keypress', '.hor-menu .search-form .form-control', function(e) {
       if (e.which == 13) {
         $(this).closest('.search-form').submit();
         return false;
@@ -433,38 +433,38 @@ var Layout = function () {
     });
 
     // handle header search button click
-    $('.page-header').on('mousedown', '.search-form.open .submit', function (e) {
+    $('.page-header').on('mousedown', '.search-form.open .submit', function(e) {
       e.preventDefault();
       e.stopPropagation();
       $(this).closest('.search-form').submit();
     });
 
     // handle hover dropdown menu for desktop devices only
-    $('[data-hover="megamenu-dropdown"]').not('.hover-initialized').each(function () {
+    $('[data-hover="megamenu-dropdown"]').not('.hover-initialized').each(function() {
       $(this).dropdownHover();
       $(this).addClass('hover-initialized');
     });
 
-    $(document).on('click', '.mega-menu-dropdown .dropdown-menu', function (e) {
+    $(document).on('click', '.mega-menu-dropdown .dropdown-menu', function(e) {
       e.stopPropagation();
     });
   };
 
   // Handles Bootstrap Tabs.
-  var handleTabs = function () {
+  var handleTabs = function() {
     // fix content height on tab click
-    $('body').on('shown.bs.tab', 'a[data-toggle="tab"]', function () {
+    $('body').on('shown.bs.tab', 'a[data-toggle="tab"]', function() {
       handleSidebarAndContentHeight();
     });
   };
 
   // Handles the go to top button at the footer
-  var handleGoTop = function () {
+  var handleGoTop = function() {
     var offset = 300;
     var duration = 500;
 
     if (navigator.userAgent.match(/iPhone|iPad|iPod/i)) { // ios supported
-      $(window).bind("touchend touchcancel touchleave", function (e) {
+      $(window).bind("touchend touchcancel touchleave", function(e) {
         if ($(this).scrollTop() > offset) {
           $('.scroll-to-top').fadeIn(duration);
         } else {
@@ -472,7 +472,7 @@ var Layout = function () {
         }
       });
     } else { // general
-      $(window).scroll(function () {
+      $(window).scroll(function() {
         if ($(this).scrollTop() > offset) {
           $('.scroll-to-top').fadeIn(duration);
         } else {
@@ -481,7 +481,7 @@ var Layout = function () {
       });
     }
 
-    $('.scroll-to-top').click(function (e) {
+    $('.scroll-to-top').click(function(e) {
       e.preventDefault();
       $('html, body').animate({
         scrollTop: 0
@@ -491,7 +491,7 @@ var Layout = function () {
   };
 
   // Hanlde 100% height elements(block, portlet, etc)
-  var handle100HeightContent = function () {
+  var handle100HeightContent = function() {
 
     var target = $('.full-height-content');
     var height;
@@ -543,15 +543,15 @@ var Layout = function () {
     // Main init methods to initialize the layout
     //IMPORTANT!!!: Do not modify the core handlers call order.
 
-    initHeader: function () {
+    initHeader: function() {
       handleHorizontalMenu(); // handles horizontal menu
     },
 
-    setSidebarMenuActiveLink: function (mode, el) {
+    setSidebarMenuActiveLink: function(mode, el) {
       handleSidebarMenuActiveLink(mode, el);
     },
 
-    initSidebar: function () {
+    initSidebar: function() {
       //layout handlers
       handleFixedSidebar(); // handles fixed sidebar menu
       handleSidebarMenu(); // handles main menu
@@ -564,7 +564,7 @@ var Layout = function () {
       Metronic.addResizeHandler(handleFixedSidebar); // reinitialize fixed sidebar on window resize
     },
 
-    initContent: function () {
+    initContent: function() {
       handle100HeightContent(); // handles 100% height elements(block, portlet, etc)
       handleTabs(); // handle bootstrah tabs
 
@@ -572,11 +572,11 @@ var Layout = function () {
       Metronic.addResizeHandler(handle100HeightContent); // reinitialize content height on window resize
     },
 
-    initFooter: function () {
+    initFooter: function() {
       handleGoTop(); //handles scroll to top functionality in the footer
     },
 
-    init: function () {
+    init: function() {
       this.initHeader();
       this.initSidebar();
       this.initContent();
@@ -584,23 +584,23 @@ var Layout = function () {
     },
 
     //public function to fix the sidebar and content height accordingly
-    fixContentHeight: function () {
+    fixContentHeight: function() {
       handleSidebarAndContentHeight();
     },
 
-    initFixedSidebarHoverEffect: function () {
+    initFixedSidebarHoverEffect: function() {
       handleFixedSidebarHoverEffect();
     },
 
-    initFixedSidebar: function () {
+    initFixedSidebar: function() {
       handleFixedSidebar();
     },
 
-    getLayoutImgPath: function () {
+    getLayoutImgPath: function() {
       return Metronic.getAssetsPath() + layoutImgPath;
     },
 
-    getLayoutCssPath: function () {
+    getLayoutCssPath: function() {
       return Metronic.getAssetsPath() + layoutCssPath;
     }
   };