1'use strict'; 2 3var bt_initHeader; 4 5(function( $ ) { 6 7 var hasCentralMenu, verticalMenuEnabled, belowMenu, btStickyEnabled, responsiveMenuPosition, fullScreenMenuEnabled; 8 9 function initial_header_setup() { 10 11 var isTouchDevice = ( 'ontouchstart' in window ) || ( navigator.MaxTouchPoints > 0 ) || ( navigator.msMaxTouchPoints > 0 ); 12 13 if ( isTouchDevice ) { 14 $( 'html' ).addClass( 'touch' ); 15 $( 'html' ).removeClass( 'no-touch' ); 16 } else { 17 $( 'html' ).addClass( 'no-touch' ); 18 $( 'html' ).removeClass( 'touch' ); 19 } 20 21 hasCentralMenu = $( 'body' ).hasClass( 'btMenuCenterEnabled' ); 22 verticalMenuEnabled = $( 'body' ).hasClass( 'btMenuVerticalLeftEnabled' ) || $( 'body' ).hasClass( 'btMenuVerticalRightEnabled' ); 23 fullScreenMenuEnabled = $( 'body' ).hasClass( 'btMenuFullScreenCenter' ); 24 25 if ( $( 'body' ).hasClass( 'rtl' ) ) { 26 responsiveMenuPosition = 'Right'; 27 } else { 28 responsiveMenuPosition = 'Left'; 29 } 30 31 belowMenu = $( 'body' ).hasClass( 'btBelowMenu' ); 32 btStickyEnabled = $( 'body' ).hasClass( 'btStickyEnabled' ); 33 34 if ( typeof window.btStickyOffset == 'undefined' ) window.btStickyOffset = 250; 35 if ( typeof window.responsiveResolution == 'undefined' ) window.responsiveResolution = '1200'; 36 } 37 38 function final_header_setup() { 39 40 $( 'li.btMenuWideDropdown' ).addClass(function(){ 41 return 'btMenuWideDropdownCols-' + $( this ).children( 'ul' ).children( 'li' ).length; 42 }); 43 44 $( 'li.btMenuWideDropdown' ).each(function() { 45 var maxChildItems = 0; 46 $( this ).find( '> ul > li > ul' ).each(function( index ) { 47 if ( $( this ).children().length > maxChildItems ) { 48 maxChildItems = $( this ).children().length; 49 } 50 }); 51 $( this ).find( '> ul > li > ul' ).each(function( index ) { 52 var bt_menu_base_length = $( this ).children().length; 53 if ( bt_menu_base_length < maxChildItems ) { 54 for ( var i = 0; i < maxChildItems - bt_menu_base_length; i++ ) { 55 $( this ).append( '<li class="btEmptyParentElement"><a class="btEmptyElement"> </a></li>' ); 56 } 57 } 58 }); 59 }); 60 61 /* Show hide menu */ 62 63 $( '.btHorizontalMenuTrigger, .bt-horizontal-menu-trigger' ).on( 'click', function () { 64 $( 'body' ).toggleClass( 'btShowMenu' ); 65 return false; 66 }); 67 68 $( '.bt-fullscreen-menu-trigger' ).on( 'click', function () { 69 $( 'body' ).toggleClass( 'bt-show-fullscreen-menu' ); 70 return false; 71 }); 72 73 /* responsive menu toggler */ 74 75 $( '.btVerticalMenuTrigger, .bt-vertical-menu-trigger' ).on( 'click', function () { 76 $( 'body' ).toggleClass( 'btMenuVerticalOn' ); 77 return false; 78 }); 79 } 80
81 function top_tools_search() { 82 /* Top tools search */ 83 84 $('.mainHeader .btSearchInner').prependTo('body').addClass( 'btFromTopBox' ); 85 86 $('.mainHeader .widget_search').addClass( 'btIconWidget' ); 87 $( '.mainHeader .btSearch, .btFromTopBox .btSearchInnerClose' ).on( 'click', function () { 88 $( 'body' ).toggleClass( 'btTopToolsSearchOpen' ); 89 90 if( $( 'body' ).hasClass( 'btTopToolsSearchOpen' ) ) { 91 if ( $( '.btSearchInnerContent form input:text:visible:first' ).length ) boldthemes_requestTimeout( add_focus_to_serach, 500); 92 } 93 return false; 94 }); 95 96 } 97 98 function add_focus_to_serach() { 99 // Focus to search field 100 $( '.btSearchInnerContent form input:text:visible:first' ).focus(); 101 } 102 103 function divide_menu() { 104 105 if ( $( '.btTextLogo' ).length ) { 106 var logoWidth = $( '.mainHeader .logo' ).width(); 107 } else { 108 if ( $( '.mainHeader .logo .btMainLogo' ).data( 'hw' ) ) { 109 var logoWidth = $( '.mainHeader .logo' ).height() * $( '.mainHeader .logo .btMainLogo' ).data( 'hw' ); 110 } else { 111 var logoWidth = $( '.mainHeader .logo' ).height() * 3; 112 } 113 114 } 115 116 $( '.menuPort nav' ).addClass( 'leftNav' ); 117 $( '.menuPort' ).append( '<nav class="rightNav"><ul></ul></nav>' ); 118 var halfItems = Math.ceil( $( '.menuPort nav.leftNav ul>li:not(li li)' ).length * .5 ); 119 $( '.menuPort nav.rightNav > ul' ).append( $( '.menuPort nav.leftNav > ul > li' ).slice ( halfItems ) ); 120 $( '.menuPort nav.leftNav > ul > li' ).slice( halfItems ).remove(); 121 122 $( '.mainHeader .logo' ).css( 'transform', 'translateX(' + Math.round(-logoWidth * .5) + 'px)' ); 123 $( '.mainHeader .logo' ).css( 'width', logoWidth + 'px' ); 124 $( '.menuPort nav.leftNav' ).attr( 'style', '--margin:' + Math.round( logoWidth * .5 ) + 'px;margin-right:' + Math.round( logoWidth * .5 ) + 'px;' ); 125 $( '.menuPort nav.rightNav' ).attr( 'style', '--margin:' + Math.round( logoWidth * .5 ) + 'px;margin-left:' + Math.round( logoWidth * .5 ) + 'px;' ); 126 } 127 128 /* Activate sticky function and call */ 129 130 function boldthemes_activate_sticky() { 131 132 var fromTop = $( window ).scrollTop(); 133 if ( fromTop > window.btStickyOffset && !$('body').hasClass('btStickyHeaderActive') ) { 134 $( 'body' ).addClass( 'btStickyHeaderActive' ); 135 /* 136 window.bt_openHeader = setTimeout( function() { 137 boldthemes_activate_sticky_open(); 138 }, 500 ); 139 */ 140 boldthemes_requestTimeout( boldthemes_activate_sticky_open, 500); 141 } else if ( fromTop <= window.btStickyOffset && $('body').hasClass('btStickyHeaderActive') && !$('body').hasClass('btStickyHeaderClosed') ) { 142 $( 'body' ).addClass( 'btStickyHeaderClosed' ); 143 /* 144 window.bt_closeHeader = setTimeout( function() { 145 boldthemes_activate_sticky_close() 146 }, 250 ); 147 */ 148 boldthemes_requestTimeout( boldthemes_activate_sticky_close, 500); 149 } 150 } 151 152 function boldthemes_activate_sticky_open() { 153 $( 'body' ).addClass( 'btStickyHeaderOpen' ); 154 } 155 function boldthemes_activate_sticky_close() { 156 $( 'body' ).removeClass( 'btStickyHeaderActive btStickyHeaderOpen btStickyHeaderClosed' ); 157 } 158 159 window.boldthemes_requestTimeout = function(fn, delay) { 160 if( !window.requestAnimationFrame && 161 !window.webkitRequestAnimationFrame && 162 !(window.mozRequestAnimationFrame && window.mozCancelRequestAnimationFrame) && // Firefox 5 ships without cancel support 163 !window.oRequestAnimationFrame && 164 !window.msRequestAnimationFrame) 165 return window.setTimeout(fn, delay); 166 167 var start = new Date().getTime(), 168 handle = new Object(); 169 170 function loop(){ 171 var current = new Date().getTime(), 172 delta = current - start; 173 174 delta >= delay ? fn.call() : handle.value = boldthemes_requestAnimFrame(loop); 175 }; 176 177 handle.value = boldthemes_requestAnimFrame(loop); 178 return handle; 179 }; 180 181 window.boldthemes_requestAnimFrame = (function() { 182 return window.requestAnimationFrame || 183 window.webkitRequestAnimationFrame || 184 window.mozRequestAnimationFrame || 185 window.oRequestAnimationFrame || 186 window.msRequestAnimationFrame || 187 function(/* function */ callback, /* DOMElement */ element){ 188 window.setTimeout(callback, 1000 / 60); 189 }; 190 })(); 191 192 /* Vertical menu setup */ 193 194 function responsive_menu_handler() { 195 if ( !fullScreenMenuEnabled ) { 196 if ( !verticalMenuEnabled ) { 197 $(window).on("resize", function(event){ 198 if( window.innerWidth < window.responsiveResolution ) { 199 $( 'body' ).addClass( 'btMenuVertical' + responsiveMenuPosition + ' btMenuVertical' ).removeClass( 'btMenuHorizontal' ); 200 } else { 201 $( 'body' ).removeClass( 'btMenuVertical btMenuVertical' + responsiveMenuPosition + ' btMenuVerticalOn' ).addClass( 'btMenuHorizontal' ); 202 } 203 boldthemes_calculate_content_padding(); 204 }); 205 } 206 } 207 } 208 209 function init_menu() { 210 211 initial_header_setup(); 212 213 if ( !fullScreenMenuEnabled ) { 214 if ( verticalMenuEnabled ) { 215 if ( $( 'body' ).hasClass( 'btMenuVerticalLeftEnabled' )) $( 'body' ).addClass( 'btMenuVerticalLeft btMenuVertical' ); 216 if ( $( 'body' ).hasClass( 'btMenuVerticalRightEnabled' )) $( 'body' ).addClass( 'btMenuVerticalRight btMenuVertical' ); 217 } else { 218 if ( $( 'body' ).hasClass( 'btMenuRightEnabled' )) $( 'body' ).addClass( 'btMenuRight btMenuHorizontal' ); 219 if ( $( 'body' ).hasClass( 'btMenuLeftEnabled' )) $( 'body' ).addClass( 'btMenuLeft btMenuHorizontal' ); 220 if ( $( 'body' ).hasClass( 'btMenuCenterBelowEnabled' )) $( 'body' ).addClass( 'btMenuCenterBelow btMenuHorizontal' ); 221 if ( $( 'body' ).hasClass( 'btMenuCenterEnabled' )) $( 'body' ).addClass( 'btMenuCenter btMenuHorizontal' ); 222 /* Switch to vertical */ 223 if( window.innerWidth < window.responsiveResolution ) { 224 $( 'body' ).addClass( 'btMenuVertical' + responsiveMenuPosition + ' btMenuVertical' ).removeClass( 'btMenuHorizontal' ); 225 } else { 226 $( 'body' ).removeClass( 'btMenuVertical btMenuVertical' + responsiveMenuPosition + ' btMenuVerticalOn' ).addClass( 'btMenuHorizontal' ); 227 } 228 } 229 } 230 231 // Move content below menu, must be donne after menu switch 232 if ( ! belowMenu ) { 233 boldthemes_calculate_content_padding(); 234 } 235 236 setTimeout( function() { $( 'body' ).addClass( 'btMenuInitFinished' ); }, 100 ); 237 238 if ( btStickyEnabled ) { 239 setTimeout( function() { 240 $( window ).scroll(function(){ 241 boldthemes_activate_sticky(); 242 }); 243 }, 1000 ); 244 } 245 246 /* Menu split */ 247 248 if ( hasCentralMenu ) divide_menu(); 249 250 /* Menu sub togglers */ 251 252 $( '.menuPort ul ul' ).parent().prepend( '<div class="subToggler"></div>'); 253 254 $( '.menuPort ul li' ).on( 'mouseenter mouseleave', function (e) { 255 if ( $( 'body' ).hasClass( 'btMenuVertical' ) || $( 'body' ).hasClass( 'btMenuFullScreenCenter' ) || $( 'html' ).hasClass( 'touch' ) ) { 256 return false; 257 } 258 e.preventDefault(); 259 $( this ).siblings().removeClass( 'on' ); 260 $( this ).toggleClass( 'on' ); 261 }); 262 263 $( '.menuPort ul.menu' ).on( 'mouseenter mouseleave', function (e) { 264 if ( $( 'body' ).hasClass( 'btMenuVertical' ) || $( 'body' ).hasClass( 'btMenuFullScreenCenter' ) || $( 'html' ).hasClass( 'touch' ) ) { 265 return false; 266 } 267 $( this ).toggleClass( 'hover' ); 268 }); 269 270 $( 'div.subToggler' ).on( 'click', function(e) { 271 var parent_item = $( this ).parent(); 272 parent_item.siblings().removeClass( 'on' ); 273 parent_item.toggleClass( 'on' ); 274 if ( parent_item.parent().hasClass( 'menu' ) ) parent_item.parent().toggleClass( 'hover' ); 275 if ( $( 'body' ).hasClass( 'btMenuVertical' ) ) { 276 parent_item.find( 'ul' ).first().slideToggle( 200 ); 277 } 278 return false; 279 }); 280 281 final_header_setup(); 282 283 } 284 285 /* Calculate content padding for not below menu */ 286 287 function boldthemes_calculate_content_padding() { 288 if ( ! belowMenu ) { 289 if( $( window ).width() < window.responsiveResolution || verticalMenuEnabled || fullScreenMenuEnabled ) { 290 $( '.btContentWrap, .bt-content-wrap' ).css( 'padding-top', $( '.btVerticalHeaderTop, .bt-vertical-header-top' ).height() +'px'); 291 } else if ( !$( 'body' ).hasClass( 'btStickyHeaderActive' ) ) { 292 $( '.btContentWrap, .bt-content-wrap' ).css( 'padding-top', $( '.mainHeader' ).height() +'px'); 293 } 294 } 295 } 296 297 function reinit_menu() { 298 top_tools_search(); 299 setTimeout(function(){ init_menu(); }, 100); 300 boldthemes_calculate_content_padding(); 301 } 302 303 $( window ).on( 'load', function() { 304 boldthemes_calculate_content_padding(); 305 }); 306 307 bt_initHeader = reinit_menu; 308 top_tools_search(); 309 init_menu(); 310 responsive_menu_handler(); 311 312 313})( jQuery );
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.