PageSourceSearch

https://urbancombatives.com/wp-content/themes/showcase/js/header.misc.js?ver=7.1.1

js urbancombatives.com collected 2026-09-28 13:38:46 UTC 10,953 bytes, 327 lines download raw bytes

1'use strict';
2
3var bt_enquire = {};
4
5bt_enquire.sizes = {};
6
7(function( $ ) {
8	
9	bt_enquire.register = function( size, handler ) {
10		size = parseInt( size.split( ':' )[1] );
11		bt_enquire.sizes[ size ] = {};
12		bt_enquire.sizes[ size ].handler = handler;
13	}
14
15	bt_enquire.handle = function() {
16		var width = ( window.innerWidth > 0 ) ? window.innerWidth : screen.width;
17		$.each( bt_enquire.sizes, function( size, obj ) {
18			if ( width <= size ) {
19				if ( obj.state != 'matched' ) {
20					obj.handler.match();
21					obj.state = 'matched';
22				}
23			} else {
24				if ( obj.state == 'matched' ) {
25					obj.handler.unmatch();
26					obj.state = 'unmatched';
27				}
28			}
29		});
30	}	
31	
32	var verticalMenuScroll = null;
33
34	$( document ).ready(function() {
35		
36		var isTouchDevice = ( 'ontouchstart' in window ) || ( navigator.MaxTouchPoints > 0 ) || ( navigator.msMaxTouchPoints > 0 );
37		
38		if ( isTouchDevice ) {
39			$( 'html' ).addClass( 'touch' );
40			$( 'html' ).removeClass( 'no-touch' );
41		} else {
42			$( 'html' ).addClass( 'no-touch' );
43			$( 'html' ).removeClass( 'touch' );
44		}
45		
46		var hasCentralMenu = $( 'body' ).hasClass( 'btMenuCenterEnabled' );
47		var verticalMenuEnabled = $( 'body' ).hasClass( 'btMenuVerticalLeftEnabled' ) || $( 'body' ).hasClass( 'btMenuVerticalRightEnabled' );
48		
49		var belowMenu = $( 'body' ).hasClass( 'btBelowMenu' );
50		var touchDevice = $( 'html' ).hasClass( 'touch' );
51		window.btStickyEnabled = $( 'body' ).hasClass( 'btStickyEnabled' );
52		window.btStickyOffset = 250;
53		var swapHeaderStyle = belowMenu && window.btStickyEnabled && ( $( '.btAltLogo' ).length > 0 || $( '.btTextLogo' ).length > 0 ); // If alt logo exists we will swap header skin
54
55		var skinToSwap = $( 'body' ).hasClass( 'btDarkSkin' ) ? "btLightSkin" : "btDarkSkin";
56		$( '.btPageWrap .btAltLogo' ).hide( );
57		$( '.btPageWrap .btMainLogo' ).show( );
58		
59		if ( ! $( '.logo img' ).length ) {
60			$( '.logo' ).addClass( 'boldthemes_logo_text' );
61		}
62
63		function divide_menu() {
64			if ( ! hasCentralMenu ) return false;
65			var logoWidth = $( '.mainHeader .logo' ).height() * $( '.mainHeader .logo .btMainLogo' ).data( 'hw' );
66			if ( $( '.boldthemes_logo_text' ).length ) {
67				logoWidth = $( '.boldthemes_logo_text' ).width();
68			}
69			$( '.menuPort nav' ).addClass( 'leftNav' );
70			$( '.menuPort' ).append( '<nav class="rightNav"><ul></ul></nav>' );
71			var halfItems = Math.ceil( $( '.mainHeader nav.leftNav ul>li:not(li li)' ).length * .5 );
72			$( '.mainHeader nav.rightNav > ul' ).append( $( '.mainHeader nav.leftNav > ul > li' ).slice ( halfItems ) );
73			$( '.mainHeader nav.leftNav > ul > li' ).slice ( halfItems ).remove();
74			
75			$( '.mainHeader .logo' ).css( 'transform', 'translateX(' + Math.round(-logoWidth * .5) + 'px)' );
76			$( '.mainHeader nav.leftNav' ).css( 'margin-right', Math.round(logoWidth * .5) + 'px' );
77			$( '.mainHeader nav.rightNav' ).css( 'margin-left', Math.round(logoWidth * .5) + 'px' );
78		}
79
80		function undivide_menu() {
81			if ( ! hasCentralMenu ) return false;
82			$( '.mainHeader nav.leftNav>ul:not(ul ul)' ).append( $( '.mainHeader nav.rightNav ul>li:not(li li)' ) );
83			$( '.mainHeader nav.rightNav' ).remove();
84			$( '.mainHeader .leftNav' ).removeAttr( 'style' );
85			$( '.menuPort nav' ).removeClass( 'leftNav' );
86			$( '.mainHeader .logo' ).removeAttr( 'style' );
87		}
88
89		/* Vertical menu setup */
90
91		function init_menu() {
92			if ( verticalMenuEnabled ) {
93				if ( $( 'body' ).hasClass( 'btMenuVerticalLeftEnabled' )) $( 'body' ).addClass( 'btMenuVerticalLeft btMenuVertical' );
94				if ( $( 'body' ).hasClass( 'btMenuVerticalRightEnabled' )) $( 'body' ).addClass( 'btMenuVerticalRight btMenuVertical' );
95				move_menu_to_vertical();
96			} else {
97				$( 'body' ).removeClass( 'btMenuVerticalLeft btMenuVerticalRight btMenuVertical btMenuVerticalOn' );
98				if ( $( 'body' ).hasClass( 'btMenuRightEnabled' )) $( 'body' ).addClass( 'btMenuRight btMenuHorizontal' );
99				if ( $( 'body' ).hasClass( 'btMenuLeftEnabled' )) $( 'body' ).addClass( 'btMenuLeft btMenuHorizontal' );
100				if ( $( 'body' ).hasClass( 'btMenuCenterEnabled' )) $( 'body' ).addClass( 'btMenuCenter btMenuHorizontal' );				
101			}	
102			
103		}
104
105		function move_menu_to_vertical() {
106			$( '.menuPort' ).prependTo( 'body' );
107			$( '.mainHeader .logo' ).clone().prependTo( '.menuPort' );
108			$( '.menuPort' ).prepend( '<div class="btCloseVertical"></div>');
109			$( '.btCloseVertical' ).on( 'click', function() {
110				$( 'body' ).toggleClass( 'btMenuVerticalOn' );
111			});
112
113			$( '.mainHeader .topBar' ).appendTo( '.menuPort' );
114			$( '.mainHeader .topBarInLogoArea' ).appendTo( '.menuPort' );
115			
116			$( 'body' ).removeClass( 'btStickyHeaderActive' );
117			if ( ! belowMenu ) $( '.btContentWrap' ).css( 'padding-top', $( '.mainHeader' ).height() +'px');
118			$( 'li.current-menu-ancestor, li.current_menu_item').each(function() {
119				$( this ).find( '.subToggler' ).first().addClass( 'on' ).next().next().show();
120			});
121			
122			// Vertical Menu Desktop Scroll
123
124			$( '.btMenuVertical .menuPort' ).wrapInner( '<div class="menuScrollPort"></div>' );
125			
126			if ( $( 'body' ).hasClass( 'btMenuVertical' ) && $( 'html' ).hasClass( 'no-touch' ) ) {
127
128				if ( verticalMenuScroll === null ) {
129					verticalMenuScroll = new IScroll( '.no-touch .btMenuVertical .menuPort', {
130						scrollbars: true,
131						mouseWheel: true,
132						click: true,
133						interactiveScrollbars: true,
134						shrinkScrollbars: 'scale',
135						fadeScrollbars: true
136					});
137				}
138			}
139		}
140
141		function reset_menu_to_original() {
142
143			$('.menuPort .menuScrollPort').contents().unwrap();
144			
145			init_menu();
146			
147			$( '.menuPort .sub-menu' ).removeAttr( 'style' );
148			
149			$( '.menuPort .logo' ).remove();
150			$( '.menuPort .btCloseVertical' ).remove();
151
152			if( $('.btBelowLogoArea').length == 0 ) {
153				$( '.menuPort' ).appendTo( '.btLogoArea' );	
154			} else {
155				$( '.menuPort' ).appendTo( '.btBelowLogoArea' );	
156			}
157			$( '.menuPort .topBar' ).prependTo( '.mainHeader > .port' );
158			$( '.mainHeader .topBarInLogoArea' ).insertAfter( '.mainHeader .logo' );
159			
160			$( 'body' ).removeClass( 'btStickyHeaderActive' );
161			divide_menu();
162			if ( ! belowMenu ) $( '.btContentWrap' ).css( 'padding-top', $( '.mainHeader' ).height() +'px');
163		}
164
165		/* activate sticky */
166		
167		window.boldthemes_activate_sticky = function() {
168			var fromTop = $( window ).scrollTop();
169			if ( window.btStickyEnabled ) {
170				if ( fromTop > window.btStickyOffset ) {
171					$( 'body' ).addClass( 'btStickyHeaderActive' );
172					if( swapHeaderStyle ) {
173						$( '.mainHeader' ).removeClass( skinToSwap );
174						$( '.btPageWrap .btAltLogo' ).hide( );
175						$( '.btPageWrap .btMainLogo' ).show( );
176					}
177					setTimeout( function() { $( 'body' ).addClass( 'btStickyHeaderOpen' ) }, 100 );
178				} else {
179					$( 'body' ).removeClass( 'btStickyHeaderOpen btStickyHeaderActive' );
180					if( swapHeaderStyle ) {
181						$( '.mainHeader' ).addClass( skinToSwap );	
182						if ( swapHeaderStyle )	{
183							$( '.btPageWrap .btAltLogo' ).show( );	
184							$( '.btPageWrap .btMainLogo' ).hide( );
185						}
186					}
187				}
188			}
189		}
190
191		/* Wide menu setup btMenuWideDropdown */
192
193		$('li.btMenuWideDropdown').addClass(function(){
194			return "btMenuWideDropdownCols-" + $(this).children('ul').children('li').length;
195		});
196		
197		$( 'li.btMenuWideDropdown' ).each(function() {
198			var maxChildItems = 0;
199			$(this).find( '> ul > li > ul' ).each(function( index ) {
200				if ( $( this ).children().length > maxChildItems ) {
201					maxChildItems = $( this ).children().length;
202				}
203			});
204			$(this).find( '> ul > li > ul' ).each(function( index ) {
205				var bt_menu_base_length = $( this ).children().length;
206				if ( bt_menu_base_length < maxChildItems ) {
207					for ( var i = 0; i < maxChildItems - bt_menu_base_length; i++ ) {
208						$( this ).append( '<li><a class="btEmptyElement">&nbsp;</a></li>' );
209					} 
210				}
211			});
212		});
213
214		/* Show hide menu */
215
216		$( '.btHorizontalMenuTrigger' ).on( 'click', function () {
217			$( '.mainHeader' ).toggleClass( 'btShowMenu' );
218			return false;
219		});
220
221		/* responsive menu toggler */
222
223		$( '.btVerticalMenuTrigger' ).on( 'click', function () {
224			$( 'body' ).toggleClass( 'btMenuVerticalOn' );
225			return false;
226		});
227
228		/* Top tools search */
229		
230		$('.btTopBox .btSearchInner').prependTo('body').addClass( 'btFromTopBox' );
231
232		$( '.btSearch .btIco, .btSearchInnerClose' ).on( 'click', function () {
233			$( 'body' ).toggleClass( 'btTopToolsSearchOpen' );
234			return false;
235		});
236
237		/* Vertical menu setup */
238		
239		init_menu();
240		setTimeout( function() { $( '.menuPort' ).css( 'visibility', 'visible' ); }, 400 );
241
242		/* Load enquire */
243
244		// turn on responsive menu for all touch devices
245
246		var responsiveResolution = '1023';
247
248		bt_enquire.register( 'screen and (max-width:' + responsiveResolution + 'px)', {
249			match: function() {
250				/* Force vertical menu */
251				if ( ! verticalMenuEnabled ) {
252					undivide_menu();
253					$( 'body' ).addClass( 'btMenuVerticalLeft btMenuVertical' ).removeClass( 'btMenuLeft btMenuCenter btMenuRight btMenuHorizontal btMenuVerticalRight' );
254					move_menu_to_vertical();
255				}
256			},
257			unmatch: function () {
258				if ( ! verticalMenuEnabled ) {
259					reset_menu_to_original();
260				}
261			}
262		});
263		
264		/* menu split */
265		
266		if ( hasCentralMenu ) divide_menu();
267
268		// move content bellow menu
269
270		if ( ! belowMenu ) {
271			$( '.btContentWrap' ).css( 'padding-top', $( '.mainHeader' ).height() +'px'); 		
272		} else {
273			if ( swapHeaderStyle ) {
274				$( '.mainHeader' ).addClass( skinToSwap );
275				$( '.btPageWrap .btAltLogo' ).show();	
276				$( '.btPageWrap .btMainLogo' ).hide();
277			}
278		}
279
280		/* responsive menu sub togglers */
281		$( '.menuPort ul ul' ).parent().prepend( '<div class="subToggler"></div>');
282
283		$( '.menuPort ul li' ).on( 'mouseover mouseout', function (e) {
284			if ( $( 'body' ).hasClass( 'btMenuVertical' ) || $( 'html' ).hasClass( 'touch' ) ) {
285				return false;
286			}
287			e.preventDefault();
288			$( this ).siblings().removeClass( 'on' );
289			$( this ).toggleClass( 'on' );
290		});
291
292		$( 'div.subToggler' ).on( 'click', function(e) {
293			var parent = $( this ).parent();
294			parent.siblings().removeClass( 'on' );
295			parent.toggleClass( 'on' );
296			if ( $( 'body' ).hasClass( 'btMenuVertical' ) ) {
297				parent.find( 'ul' ).first().slideToggle( 200 );
298				setTimeout(function () {
299					if ( verticalMenuScroll !== null ) {
300						verticalMenuScroll.refresh();
301					}
302				}, 280 );
303			}
304		});
305		
306		bt_enquire.handle();
307		
308		$( window ).resize(function() {
309			
310			bt_enquire.handle();
311			
312		});
313
314	});
315	
316	$( window ).on( 'load', function() {
317
318		// boldthemes_activate_sticky();
319		setTimeout( function() { 
320			$( window ).scroll(function(){
321				boldthemes_activate_sticky();
322			});
323		}, 1000 );
324
325	});	
326
327})( 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.