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