1/** 2Core script to handle the entire theme and core functions 3**/ 4var Layout = function () { 5 6 var layoutImgPath = 'admin/layout3/img/'; 7 8 var layoutCssPath = 'admin/layout3/css/'; 9 10 var resBreakpointMd = Metronic.getResponsiveBreakpoint('md'); 11 12 //* BEGIN:CORE HANDLERS *// 13 // this function handles responsive layout on screen size resize or mobile device rotate. 14 15 // Handles header 16 var handleHeader = function () { 17 // handle search box expand/collapse 18 $('.page-header').on('click', '.search-form', function (e) { 19 $(this).addClass("open"); 20 $(this).find('.form-control').focus(); 21 22 $('.page-header .search-form .form-control').on('blur', function (e) { 23 $(this).closest('.search-form').removeClass("open"); 24 $(this).unbind("blur"); 25 }); 26 }); 27 28 // handle hor menu search form on enter press 29 $('.page-header').on('keypress', '.hor-menu .search-form .form-control', function (e) { 30 if (e.which == 13) { 31 $(this).closest('.search-form').submit(); 32 return false; 33 } 34 }); 35 36 // handle header search button click 37 $('.page-header').on('mousedown', '.search-form.open .submit', function (e) { 38 e.preventDefault(); 39 e.stopPropagation(); 40 $(this).closest('.search-form').submit(); 41 }); 42 43 // handle scrolling to top on responsive menu toggler click when header is fixed for mobile view 44 $('body').on('click', '.page-header-top-fixed .page-header-top .menu-toggler', function(){ 45 Metronic.scrollTop(); 46 }); 47 }; 48 49 // Handles main menu 50 var handleMainMenu = function () { 51 52 // handle menu toggler icon click 53 $(".page-header .menu-toggler").on("click", function(event) { 54 if (Metronic.getViewPort().width < resBreakpointMd) { 55 var menu = $(".page-header .page-header-menu"); 56 if (menu.is(":visible")) { 57 menu.slideUp(300); 58 } else { 59 menu.slideDown(300); 60 } 61 62 if ($('body').hasClass('page-header-top-fixed')) { 63 Metronic.scrollTop(); 64 } 65 } 66 }); 67 68 // handle sub dropdown menu click for mobile devices only 69 $(".hor-menu .dropdown-submenu > a").on("click", function(e) { 70 if (Metronic.getViewPort().width < resBreakpointMd) { 71 if ($(this).next().hasClass('dropdown-menu')) { 72 e.stopPropagation(); 73 if ($(this).parent().hasClass("open")) { 74 $(this).parent().removeClass("open"); 75 $(this).next().hide(); 76 } else { 77 $(this).parent().addClass("open"); 78 $(this).next().show(); 79 } 80 } 81 } 82 }); 83 84 // handle hover dropdown menu for desktop devices only 85 if (Metronic.getViewPort().width >= resBreakpointMd) { 86 $('.hor-menu [data-hover="megamenu-dropdown"]').not('.hover-initialized').each(function() { 87 $(this).dropdownHover(); 88 $(this).addClass('hover-initialized'); 89 }); 90 } 91 92 // handle auto scroll to selected sub menu node on mobile devices 93 $(document).on('click', '.hor-menu .menu-dropdown > a[data-hover="megamenu-dropdown"]', function() { 94 if (Metronic.getViewPort().width < resBreakpointMd) { 95 Metronic.scrollTo($(this)); 96 } 97 }); 98 99 // hold mega menu content open on click/tap. 100 $(document).on('click', '.mega-menu-dropdown .dropdown-menu, .classic-menu-dropdown .dropdown-menu', function (e) { 101 e.stopPropagation(); 102 }); 103 104 // handle fixed mega menu(minimized) 105 $(window).scroll(function() { 106 var offset = 75; 107 if ($('body').hasClass('page-header-menu-fixed')) { 108 if ($(window).scrollTop() > offset){ 109 $(".page-header-menu").addClass("fixed"); 110 } else { 111 $(".page-header-menu").removeClass("fixed"); 112 } 113 } 114 115 if ($('body').hasClass('page-header-top-fixed')) { 116 if ($(window).scrollTop() > offset){ 117 $(".page-header-top").addClass("fixed"); 118 } else { 119 $(".page-header-top").removeClass("fixed"); 120 } 121 } 122 }); 123 }; 124 125 // Handle sidebar menu links 126 var handleMainMenuActiveLink = function(mode, el) { 127 var url = location.hash.toLowerCase(); 128 129 var menu = $('.hor-menu'); 130 131 if (mode === 'click' || mode === 'set') { 132 el = $(el); 133 } else if (mode === 'match') { 134 menu.find("li > a").each(function() { 135 var path = $(this).attr("href").toLowerCase(); 136 // url match condition 137 if (path.length > 1 && url.substr(1, path.length - 1) == path.substr(1)) { 138 el = $(this); 139 return; 140 } 141 }); 142 } 143 144 if (!el || el.size() == 0) { 145 return; 146 } 147 148 if (el.attr('href').toLowerCase() === 'javascript:;' || el.attr('href').toLowerCase() === '#') { 149 return; 150 } 151 152 // disable active states 153 menu.find('li.active').removeClass('active'); 154 menu.find('li > a > .selected').remove(); 155 menu.find('li.open').removeClass('open'); 156 157 el.parents('li').each(function () { 158 $(this).addClass('active'); 159 160 if ($(this).parent('ul.navbar-nav').size() === 1) { 161 $(this).find('> a').append('<span class="selected"></span>'); 162 } 163 }); 164 }; 165 166 // Handles main menu on window resize 167 var handleMainMenuOnResize = function() { 168 // handle hover dropdown menu for desktop devices only 169 var width = Metronic.getViewPort().width; 170 var menu = $(".page-header-menu"); 171 172 if (width >= resBreakpointMd && menu.data('breakpoint') !== 'desktop') { 173 // reset active states 174 $('.hor-menu [data-toggle="dropdown"].active').removeClass('open'); 175 176 menu.data('breakpoint', 'desktop'); 177 $('.hor-menu [data-hover="megamenu-dropdown"]').not('.hover-initialized').each(function() { 178 $(this).dropdownHover(); 179 $(this).addClass('hover-initialized'); 180 }); 181 $('.hor-menu .navbar-nav li.open').removeClass('open'); 182 $(".page-header-menu").css("display", "block"); 183 } else if (width < resBreakpointMd && menu.data('breakpoint') !== 'mobile') { 184 // set active states as open 185 $('.hor-menu [data-toggle="dropdown"].active').addClass('open'); 186 187 menu.data('breakpoint', 'mobile'); 188 // disable hover bootstrap dropdowns plugin 189 $('.hor-menu [data-hover="megamenu-dropdown"].hover-initialized').each(function() { 190 $(this).unbind('hover'); 191 $(this).parent().unbind('hover').find('.dropdown-submenu').each(function() { 192 $(this).unbind('hover'); 193 }); 194 $(this).removeClass('hover-initialized'); 195 }); 196 } else if (width < resBreakpointMd) { 197 //$(".page-header-menu").css("display", "none"); 198 } 199 }; 200 201 var handleContentHeight = function() { 202 var height; 203 204 if ($('body').height() < Metronic.getViewPort().height) { 205 height = Metronic.getViewPort().height - 206 $('.page-header').outerHeight() - 207 ($('.page-container').outerHeight() - $('.page-content').outerHeight()) - 208 $('.page-prefooter').outerHeight() - 209 $('.page-footer').outerHeight(); 210 211 $('.page-content').css('min-height', height); 212 } 213 }; 214 215 // Handles the go to top button at the footer 216 var handleGoTop = function () { 217 var offset = 100; 218 var duration = 500; 219 220 if (navigator.userAgent.match(/iPhone|iPad|iPod/i)) { // ios supported 221 $(window).bind("touchend touchcancel touchleave", function(e){
222 if ($(this).scrollTop() > offset) { 223 $('.scroll-to-top').fadeIn(duration); 224 } else { 225 $('.scroll-to-top').fadeOut(duration); 226 } 227 }); 228 } else { // general 229 $(window).scroll(function() { 230 if ($(this).scrollTop() > offset) { 231 $('.scroll-to-top').fadeIn(duration); 232 } else { 233 $('.scroll-to-top').fadeOut(duration); 234 } 235 }); 236 } 237 238 $('.scroll-to-top').click(function(e) { 239 e.preventDefault(); 240 $('html, body').animate({scrollTop: 0}, duration); 241 return false; 242 }); 243 }; 244 245 //* END:CORE HANDLERS *// 246 247 return { 248 249 // Main init methods to initialize the layout 250 // IMPORTANT!!!: Do not modify the core handlers call order. 251 252 initHeader: function() { 253 handleHeader(); // handles horizontal menu 254 handleMainMenu(); // handles menu toggle for mobile 255 Metronic.addResizeHandler(handleMainMenuOnResize); // handle main menu on window resize 256 257 if (Metronic.isAngularJsApp()) { 258 handleMainMenuActiveLink('match'); // init sidebar active links 259 } 260 }, 261 262 initContent: function() { 263 handleContentHeight(); // handles content height 264 }, 265 266 initFooter: function() { 267 handleGoTop(); //handles scroll to top functionality in the footer 268 }, 269 270 init: function () { 271 this.initHeader(); 272 this.initContent(); 273 this.initFooter(); 274 }, 275 276 setMainMenuActiveLink: function(mode, el) { 277 handleMainMenuActiveLink(mode, el); 278 }, 279 280 closeMainMenu: function() { 281 $('.hor-menu').find('li.open').removeClass('open'); 282 283 if (Metronic.getViewPort().width < resBreakpointMd && $('.page-header-menu').is(":visible")) { // close the menu on mobile view while laoding a page 284 $('.page-header .menu-toggler').click(); 285 } 286 }, 287 288 getLayoutImgPath: function() { 289 return Metronic.getAssetsPath() + layoutImgPath; 290 }, 291 292 getLayoutCssPath: function() { 293 return Metronic.getAssetsPath() + layoutCssPath; 294 } 295 }; 296 297}();
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.