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