PageSourceSearch

https://www.steamvr.com/cs/public/shared/javascript/shared_responsive_adapter.js?v=JLaSFRMcvYON&_cdn=fastly

js steamvr.com collected 2026-09-24 23:00:16 UTC 24,409 bytes, 793 lines download raw bytes

1"use strict";
2
3// build our menu on init
4jQuery( function($) {
5	var mqQuerySmallMode = window.matchMedia ? window.matchMedia("(max-width: 910px)") : {matches: false};
6	var mqQuerySmallModeWhenWideEnabled = window.matchMedia ? window.matchMedia("(max-width: 1200px)") : {matches: false};
7	var mqMobileMode = window.matchMedia ? window.matchMedia("(max-width: 500px)") : {matches: false};
8
9	var $HTML = $J('html');
10	window.UseTouchFriendlyMode = function() {
11		return $HTML.hasClass( 'responsive' ) && ( mqQuerySmallMode.matches || $HTML.hasClass('touch') );
12	};
13	window.UseSmallScreenMode = function( isWideModeEnabled ) {
14		return $HTML.hasClass( 'responsive' ) && ( isWideModeEnabled ? mqQuerySmallModeWhenWideEnabled.matches : mqQuerySmallMode.matches );
15	};
16	window.UseMobileScreenMode = function() {
17		return $HTML.hasClass( 'responsive' ) && mqMobileMode.matches;
18	};
19	window.UseTabletScreenMode = function() {
20		return $HTML.hasClass( 'responsive' ) && $HTML.hasClass( 'tablet' );
21	};
22	window.UseNewMobileAppMode = function() {
23		// the new mobile app can run on screen widths wider than responsive_css_maxwidth
24		return $HTML.hasClass( 'responsive' ) && $HTML.hasClass( 'rn_mobile_app' );
25	};
26
27	// main menu
28
29	var $Menu = $('#responsive_page_menu');
30	var $Frame = $('.responsive_page_frame');
31	var $ContentCtn = $('.responsive_page_content' );
32	var $ContentOverlay = $('.responsive_page_content_overlay');
33
34	var fnResetMenuState = function() {
35		$Frame.removeClass( 'mainmenu_active');
36		$Frame.removeClass('localmenu_active');
37		$J(document.body).removeClass( 'overflow_hidden' );
38
39		$ContentOverlay.off( 'click.ReponsiveMenuDismiss');
40	};
41
42	$J(document).on('click.OnClickDismissMenu', '.responsive_OnClickDismissMenu', fnResetMenuState );
43
44	var strLastExpandedSubmenu = WebStorage.GetLocalSession( 'responsiveMenuLastSubmenu' );
45
46	var fnMakeExpandableMenuItem = function( $MenuItem, $Submenu )
47	{
48		$MenuItem.append( $J('<div/>', {'class': 'chevron' } ) );
49
50
51		var $SubmenuWrapper = $J('<div/>', {'class': 'menuitem_submenu_wrapper' });
52		$MenuItem.after( $SubmenuWrapper.append( $Submenu ) );
53		$Submenu.wrap( $('<div/>', {'class': 'inner_borders' } ) );
54
55		// if this was the last used submenu, start with it expanded
56		if ( strLastExpandedSubmenu && strLastExpandedSubmenu == $Submenu.data('submenuid') )
57		{
58			$SubmenuWrapper.css( 'height', $Submenu.height() + 'px' );
59			$MenuItem.addClass( 'submenu_active' );
60			$SubmenuWrapper.addClass('active');
61		}
62		else
63		{
64			$SubmenuWrapper.css( 'height', 0 );
65		}
66
67		$Submenu.show();
68
69		$MenuItem.click( function(e) {
70			e.preventDefault();
71			if ( $SubmenuWrapper.hasClass('active' ) )
72			{
73				$SubmenuWrapper.removeClass('active' ).css('height',0);
74				$MenuItem.removeClass('submenu_active');
75				WebStorage.SetLocalSession( 'responsiveMenuLastSubmenu', null );
76			}
77			else
78			{
79				$SubmenuWrapper.siblings( '.menuitem_submenu_wrapper.active' ).css('height',0 ).removeClass('active');
80				$MenuItem.siblings('.menuitem').removeClass('submenu_active');
81				$SubmenuWrapper.css( 'height', $Submenu.height() + 'px' );
82				$MenuItem.addClass( 'submenu_active' );
83				$SubmenuWrapper.addClass('active');
84				WebStorage.SetLocalSession( 'responsiveMenuLastSubmenu', $Submenu.data('submenuid') );
85			}
86		});
87	};
88
89	var fnBuildMenuEvents = function( $Menu, strMenuName, fnFirstTimeInitialization )
90	{
91		var strActiveClass = strMenuName + '_active';
92		var fnGPOnClosingModalWindow = null;
93
94		var fnDismissMenu = function() {
95			$ContentCtn.off( 'click.ReponsiveMenuDismiss');
96			$Frame.removeClass(strActiveClass);
97			$J(document.body).removeClass('overflow_hidden' );
98
99			// tell gamepad navigation we're closing the menu
100			if ( fnGPOnClosingModalWindow )
101			{
102				fnGPOnClosingModalWindow();
103				fnGPOnClosingModalWindow = null;
104			}
105
106			window.setTimeout( function() {
107				if ( !$Frame.hasClass('mainmenu_active') && !$Frame.hasClass('localmenu_active') )
108				{
109					fnResetMenuState();
110				}
111			}, 500 );
112		};
113
114		var bInitialized = false;
115		var fnActivateMenu = function() {
116			if ( !bInitialized )
117			{
118				fnFirstTimeInitialization && fnFirstTimeInitialization();
119				bInitialized = true;
120			}
121
122			if ( $Frame.hasClass( strActiveClass ) )
123			{
124				fnDismissMenu();
125			}
126			else
127			{
128				$J(document.body).addClass('overflow_hidden' );
129				$Menu.removeClass('secondary_active');
130				$Frame.addClass( strActiveClass );
131				$ContentOverlay.one( 'click.ResponsiveMenuDismiss', function() {
132					fnDismissMenu();
133				});
134
135				// tell gamepad navigation to treat this menu as a modal dialog
136				if ( typeof GPOnShowingModalWindow === "function" )
137					fnGPOnClosingModalWindow = GPOnShowingModalWindow( $Menu.get( 0 ) );
138			}
139		};
140
141		return { fnActivateMenu: fnActivateMenu, fnDismissMenu: fnDismissMenu };
142	};
143
144	var fnInitMainMenu = function() {
145		$('.responsive_page_menu' ).find( '.supernav').each( function() {
146			var $Element = $(this);
147			$Element.attr('href','');
148			var strSubmenuSelector = $Element.data('tooltip-content');
149			var $Submenu = $Element.parent().find(strSubmenuSelector);
150			if ( $Submenu.length )
151			{
152				fnMakeExpandableMenuItem( $Element, $Submenu );
153			}
154		});
155
156		var $NotificationItem = $Menu.find( '.notifications_item' );
157		var $NotificationSubmenu = $Menu.find('.notification_submenu');
158		if ( $NotificationItem.length && $NotificationSubmenu.length )
159		{
160			fnMakeExpandableMenuItem( $NotificationItem, $NotificationSubmenu );
161		}
162		Responsive_BuildChangeLanguageOption( $Menu.find( '.change_language_action' ) );
163	};
164
165	var MainMenuEvents = null;
166	if ( $Menu.length )
167	{
168		MainMenuEvents = fnBuildMenuEvents( $Menu, 'mainmenu', fnInitMainMenu );
169
170
171		$('#responsive_menu_logo' ).click( function( e ) {
172			MainMenuEvents.fnActivateMenu();
173		} );
174	}
175
176
177	// local (page-specific) menu
178
179	var $LocalMenuContent = $('.responsive_local_menu');
180	var $LocalMenu = null;
181	var LocalMenuEvents = null;
182	if ( $LocalMenuContent.length )
183	{
184		var bLocalMenuEnabed = false;
185		var rgMenuContents = [];
186
187		var fnInitLocalMenu = function() {
188			if ( rgMenuContents.length )
189				return;
190
191			for ( var i = 0; i < $LocalMenuContent.length; i++ )
192			{
193				var $LocalMenuElement = $($LocalMenuContent[i] ).wrap( $J('<div/>', {'class': 'responsive_local_menu_placeholder' } ) );
194				var $LocalMenuWrapper = $($LocalMenuContent[i]).parent();
195				rgMenuContents.push( {
196					wrapper: $LocalMenuWrapper,
197					content: $LocalMenuElement
198				});
199			}
200		};
201
202		$LocalMenu = $J('#responsive_page_local_menu');
203		var $Affordance = $J('.responsive_local_menu_tab');
204
205		LocalMenuEvents = fnBuildMenuEvents( $LocalMenu, 'localmenu' );
206
207		$Affordance.click( function( e ) {
208			LocalMenuEvents.fnActivateMenu();
209		});
210
211		g_fnActivateLocalMenu = LocalMenuEvents.fnActivateMenu;
212
213		$(window ).on( 'Responsive_SmallScreenModeToggled.ReponsiveLocalMenu', function() {
214			var bShouldUseResponsiveMenu = UseSmallScreenMode() || UseTabletScreenMode(); 
215			if ( bLocalMenuEnabed != bShouldUseResponsiveMenu )
216			{
217				if ( bShouldUseResponsiveMenu )
218				{
219					$Affordance.addClass( 'active' );
220					fnInitLocalMenu();
221					$LocalMenu.find('.localmenu_content' ).append( $LocalMenuContent );
222				}
223				else
224				{
225					fnResetMenuState();
226					$Affordance.removeClass('active');
227					for ( var i = 0; i < rgMenuContents.length; i++ )
228					{
229						rgMenuContents[i].wrapper.append( rgMenuContents[i].content );
230					}
231				}
232				bLocalMenuEnabed = bShouldUseResponsiveMenu;
233			}
234		} ).trigger( 'Responsive_SmallScreenModeToggled.ReponsiveLocalMenu');
235
236		// menu is available, so set the action description for the page content.
237		GPNavUpdateActionDescriptions( $('#responsive_page_template_content'), { onOptionsActionDescription:'Nabídka' } );
238		$('#responsive_page_template_content').on( 'vgp_onoptions', function() { LocalMenuEvents.fnActivateMenu(); } );
239	}
240
241	Responsive_InitMenuSwipes( $, $Menu, $LocalMenu, MainMenuEvents, LocalMenuEvents );
242
243	Responsive_InitFixOnScroll( $ );
244
245	Responsive_InitTouchDetection( $ );
246
247	Responsive_InitTabSelect( $ );
248
249	Responsive_InitResponsiveToggleEvents( $ );
250
251	Responsive_InitJQPlotHooks( $ );
252
253	if ( window.UseTabletScreenMode && window.UseTabletScreenMode() )
254		Responsive_InitForTablet( $ );
255});
256
257function Responsive_InitForTablet( $ )
258{
259	// support using gamepad to change slider position
260	$( 'input[type=range]' ).on( 'vgp_ondirection', function( event ) {
261
262		if ( event.originalEvent.detail.button == 11 || event.originalEvent.detail.button == 12 )
263		{
264			if ( event.originalEvent.detail.button == 11 ) // EGamepadButton.DIR_LEFT
265				this.stepDown();
266			else if ( event.originalEvent.detail.button == 12 ) // EGamepadButton.DIR_RIGHT
267				this.stepUp();
268
269			$( this ).trigger( 'input' ).trigger( 'change' );
270
271			return false; // prevent the message from propagating
272		}
273	} );
274}
275
276function Responsive_InitMenuSwipes( $, $Menu, $LocalMenu, MainMenuEvents, LocalMenuEvents )
277{
278	if ( !MainMenuEvents && !LocalMenuEvents )
279		return;
280
281	var $Frame = $('.responsive_page_frame');
282	// set up touch drag events
283	var bInMainMenuDrag = false;
284	var bInLocalMenuDrag = false;
285	var bInDismissMenuDrag = false;
286	var bLooksLikeSwipe = false;
287	var nDragMenuWidth = 0;
288
289	var nCurDragOffset = 0;
290	var nTouchStartPageX = 0;	// page/CSS coordinates because that's how we measure the menu width
291	var nTouchStartPageY = 0;
292
293	var fnGetSingleTouch = function(e) {
294		var TouchEvent = e.originalEvent;
295		var rgTouches = TouchEvent ? TouchEvent.touches : null;
296		if ( !rgTouches || rgTouches.length != 1 )
297			return null;
298		return rgTouches[0];
299	};
300	var fnCancelDrag = function()
301	{
302		$Frame.removeClass('in_menu_drag');
303		if ( bLooksLikeSwipe )
304		{
305			var DragMenuEvents = bInMainMenuDrag ? MainMenuEvents : LocalMenuEvents;
306			var $DragMenu = bInMainMenuDrag ? $Menu : $LocalMenu;
307			$DragMenu.parents('.responsive_page_menu_ctn' ).css( 'left', '' ).css( 'right', '' );
308			if ( ( !bInDismissMenuDrag && nCurDragOffset < nDragMenuWidth / 2 ) ||
309				( bInDismissMenuDrag && nCurDragOffset > nDragMenuWidth / 2 ) )
310			{
311				DragMenuEvents.fnDismissMenu();
312			}
313		}
314
315		bInLocalMenuDrag = bInMainMenuDrag = bLooksLikeSwipe = bInDismissMenuDrag = false;
316	};
317	$(window ).on('touchstart.ResponsiveMenuActivate', function(e) {
318		if ( !UseSmallScreenMode() )
319			return;
320
321		if ( e && e.target && $( e.target ).parents( '.responsive_menu_ignore_touch' ).length > 0 )
322			return;
323
324		var Touch = fnGetSingleTouch(e);
325		if ( !Touch )
326			return;
327
328		if ( $Frame.hasClass('mainmenu_active') )
329		{
330			if ( Touch.clientX > $Menu.width() * 0.9 )
331			{
332				bInMainMenuDrag = true;
333				bInDismissMenuDrag = true;
334			}
335		}
336		else if ( $Frame.hasClass('localmenu_active') )
337		{
338			if ( Touch.clientX < ( window.innerWidth - $LocalMenu.width() * 0.9 ) )
339			{
340				bInLocalMenuDrag = true;
341				bInDismissMenuDrag = true;
342			}
343		}
344		else
345		{
346			var nClientXAsPct = 100 * Touch.clientX / window.innerWidth;
347			bInDismissMenuDrag = false;
348			if ( nClientXAsPct > 93 && LocalMenuEvents )
349				bInLocalMenuDrag = true;
350			else if ( nClientXAsPct < 7 && MainMenuEvents )
351				bInMainMenuDrag = true;
352		}
353
354		if ( bInLocalMenuDrag || bInMainMenuDrag )
355		{
356			bLooksLikeSwipe = false;
357			nTouchStartPageX = Touch.pageX;
358			nTouchStartPageY = Touch.pageY;
359		}
360	});
361	$(window ).on('touchmove.ResponsiveMenuActive', function(e) {
362		if ( !bInLocalMenuDrag && !bInMainMenuDrag )
363			return;
364
365		var Touch = fnGetSingleTouch(e);
366		if ( !Touch )
367			return;
368		var nDeltaPageX = Touch.pageX - nTouchStartPageX;
369		var nDeltaPageY = Touch.pageY - nTouchStartPageY;
370
371		if ( ( bInLocalMenuDrag && !bInDismissMenuDrag ) || ( bInMainMenuDrag && bInDismissMenuDrag ) )
372			nDeltaPageX = -nDeltaPageX;
373
374		var DragMenuEvents = bInMainMenuDrag ? MainMenuEvents : LocalMenuEvents;
375		var $DragMenu = bInMainMenuDrag ? $Menu : $LocalMenu;
376
377		if ( !bLooksLikeSwipe && nDeltaPageX > 25 && nDeltaPageX > nDeltaPageY * 2 )
378		{
379			// horizontal drag
380			$Frame.addClass('in_menu_drag');
381			if ( !bInDismissMenuDrag )
382				DragMenuEvents.fnActivateMenu();
383			//$Frame.addClass( bInLocalMenuDrag ? 'localmenu_active' : 'mainmenu_active' );
384			nDragMenuWidth = $DragMenu.width();
385			bLooksLikeSwipe = true;
386		}
387		else if ( nDeltaPageY > 2 * nDeltaPageX )
388		{
389			// looks like scrolling?
390			fnCancelDrag();
391			return;
392		}
393
394
395		if ( bLooksLikeSwipe )
396		{
397			nCurDragOffset = Math.max( Math.min( nDeltaPageX, nDragMenuWidth ), 0 );
398
399			var nOffset = bInDismissMenuDrag ? -nCurDragOffset : -(nDragMenuWidth - nCurDragOffset);
400
401			$DragMenu.parents('.responsive_page_menu_ctn' ).css( bInLocalMenuDrag ? 'right' : 'left', nOffset + 'px' );
402		}
403	});
404	$(window ).on('touchend.ResponsiveMenuActivate touchcancel.ResponsiveMenuActivate', function(e) {
405		fnCancelDrag();
406	});
407}
408
409function Responsive_InitTouchDetection( $ )
410{
411	var $HTML= $J('html');
412	if ( !$HTML.hasClass('touch') && $HTML.hasClass('responsive') )
413	{
414		$J(window ).one('touchstart', function() {
415			// user is on a touch device - enable touch-friendly accessors and
416			// remember for the rest of this session
417
418			$HTML.addClass('touch');
419			V_SetCookie( "strResponsiveViewPrefs", 'touch', 0 );
420		} );
421	}
422}
423
424function Responsive_InitTabSelect( $ )
425{
426	// handle any tab dropdowns
427	$J(document).on('change.ResponsiveTabSelect', 'select.responsive_tab_select', function() {
428		var url = $J(this ).val();
429		if ( url != window.location )
430			window.location = url;
431	});
432}
433
434function Responsive_InitFixOnScroll($)
435{
436	var $Ctn = $J('.responsive_fixonscroll_ctn');
437	var $Elements = $J('.responsive_fixonscroll');
438	if ( $Elements.length )
439	{
440		var nCtnTop = -1;
441		var nCtnHeight = 0;
442
443		$J(window).on('scroll.ResponsiveFixOnScroll resize.ResponsiveFixOnScroll', function() {
444			var nHeaderOffset = GetResponsiveHeaderFixedOffsetAdjustment();
445			var nScrollTop = $J(window ).scrollTop() + nHeaderOffset + nCtnHeight;
446
447			if ( nHeaderOffset != nCtnTop )
448			{
449				nCtnTop = nHeaderOffset;
450				$Ctn.css( 'top', nCtnTop + 'px' );
451			}
452			$Elements.each( function() {
453				var $Element = $J(this);
454				if ( !$Element.is(':visible') )
455				{
456					if ( $Element.hasClass('in_fixed_ctn') && $Element.data('originalContents') )
457					{
458						$Element.append( $Element.data('originalContents') );
459						$Element.removeClass('in_fixed_ctn');
460						$Element.css('height', '');
461						nCtnHeight = $Ctn.height();
462					}
463					return;
464				}
465
466				var nElementTop = $Element.offset().top;
467				if ( nElementTop > nScrollTop )
468				{
469					if ( $Element.hasClass('in_fixed_ctn') )
470					{
471						$Element.append( $Element.data('originalContents') );
472						$Element.removeClass('in_fixed_ctn');
473						$Element.css('height', '');
474						nCtnHeight = $Ctn.height();
475					}
476				}
477				else
478				{
479					if ( !$Element.hasClass('in_fixed_ctn') )
480					{
481						$Element.css('height', $Element.height() + 'px' );
482						$Element.data( 'originalContents', $Element.children() );
483						$Ctn.append( $Element.children() );
484						$Element.addClass( 'in_fixed_ctn' );
485						nCtnHeight = $Ctn.height();
486					}
487				}
488			});
489		} );
490	}
491}
492
493function Responsive_BuildChangeLanguageOption( $MenuItem )
494{
495	$MenuItem.click( function() {
496		var $LanguageForm = $J('<form/>', {'class': 'responsive_change_language_form' } );
497		var $SelectBox = $J('<select/>', {'class': 'responsive_change_language_select' } );
498		$SelectBox.append(
499			$J('<option/>', {value: "czech"} ).text( 'Čeština (Czech)' )
500		);
501					$SelectBox.append(
502				$J('<option/>', {value: "schinese"} ).text( '简体中文 (Zjednodušená čínština)' )
503			);
504					$SelectBox.append(
505				$J('<option/>', {value: "tchinese"} ).text( '繁體中文 (Tradiční čínština)' )
506			);
507					$SelectBox.append(
508				$J('<option/>', {value: "japanese"} ).text( '日本語 (Japonština)' )
509			);
510					$SelectBox.append(
511				$J('<option/>', {value: "koreana"} ).text( '한국어 (Korejština)' )
512			);
513					$SelectBox.append(
514				$J('<option/>', {value: "thai"} ).text( 'ไทย (Thajština)' )
515			);
516					$SelectBox.append(
517				$J('<option/>', {value: "bulgarian"} ).text( 'български (Bulharština)' )
518			);
519					$SelectBox.append(
520				$J('<option/>', {value: "danish"} ).text( 'Dansk (Dánština)' )
521			);
522					$SelectBox.append(
523				$J('<option/>', {value: "german"} ).text( 'Deutsch (Němčina)' )
524			);
525					$SelectBox.append(
526				$J('<option/>', {value: "english"} ).text( 'English (Angličtina)' )
527			);
528					$SelectBox.append(
529				$J('<option/>', {value: "spanish"} ).text( 'Español-España (Evropská španělština)' )
530			);
531					$SelectBox.append(
532				$J('<option/>', {value: "latam"} ).text( 'Español-Latinoamérica (Latin. španělština)' )
533			);
534					$SelectBox.append(
535				$J('<option/>', {value: "greek"} ).text( 'Ελληνικά (Řečtina)' )
536			);
537					$SelectBox.append(
538				$J('<option/>', {value: "french"} ).text( 'Français (Francouzština)' )
539			);
540					$SelectBox.append(
541				$J('<option/>', {value: "italian"} ).text( 'Italiano (Italština)' )
542			);
543					$SelectBox.append(
544				$J('<option/>', {value: "hungarian"} ).text( 'Magyar (Maďarština)' )
545			);
546					$SelectBox.append(
547				$J('<option/>', {value: "dutch"} ).text( 'Nederlands (Nizozemština)' )
548			);
549					$SelectBox.append(
550				$J('<option/>', {value: "norwegian"} ).text( 'Norsk (Norština)' )
551			);
552					$SelectBox.append(
553				$J('<option/>', {value: "polish"} ).text( 'Polski (Polština)' )
554			);
555					$SelectBox.append(
556				$J('<option/>', {value: "portuguese"} ).text( 'Português (Evropská portugalština)' )
557			);
558					$SelectBox.append(
559				$J('<option/>', {value: "brazilian"} ).text( 'Português-Brasil (Brazilská portugalština)' )
560			);
561					$SelectBox.append(
562				$J('<option/>', {value: "romanian"} ).text( 'Română (Rumunština)' )
563			);
564					$SelectBox.append(
565				$J('<option/>', {value: "russian"} ).text( 'Русский (Ruština)' )
566			);
567					$SelectBox.append(
568				$J('<option/>', {value: "finnish"} ).text( 'Suomi (Finština)' )
569			);
570					$SelectBox.append(
571				$J('<option/>', {value: "swedish"} ).text( 'Svenska (Švédština)' )
572			);
573					$SelectBox.append(
574				$J('<option/>', {value: "turkish"} ).text( 'Türkçe (Turečtina)' )
575			);
576					$SelectBox.append(
577				$J('<option/>', {value: "vietnamese"} ).text( 'Tiếng Việt (Vietnamština)' )
578			);
579					$SelectBox.append(
580				$J('<option/>', {value: "ukrainian"} ).text( 'Українська (Ukrajinština)' )
581			);
582		
583		var Modal = null;
584
585		var fnChangeLanguage = function() {
586			if ( $SelectBox.val() != "czech" )
587				ChangeLanguage( $SelectBox.val() );
588			Modal && Modal.Dismiss();
589		};
590
591		$LanguageForm.submit( function(e) {
592			e.preventDefault();
593			fnChangeLanguage();
594		});
595		$SelectBox.change( fnChangeLanguage );
596
597		$LanguageForm.append( $SelectBox );
598		$LanguageForm.append( $J('<input/>', {type: 'submit'} ).hide() );
599		Modal = ShowConfirmDialog( 'Změnit jazyk', $LanguageForm, 'Změnit jazyk' ).done( fnChangeLanguage );
600		$SelectBox.focus();
601	});
602}
603
604function Responsive_RequestDesktopView()
605{
606	// we can dynamically switch, but this doesn't trigger the phone to zoom out and some elements don't resize right
607	/*
608	$J('html' ).removeClass('responsive touch' ).addClass('force_desktop');
609	$J('meta[name=viewport]' ).attr('value', '' );
610	$J(window ).trigger('resize');
611	*/
612	Responsive_UpdateResponsivePrefs( 'desktop', true );
613	window.location.reload();
614}
615
616function Responsive_RequestMobileView()
617{
618	/*
619	$J('html' ).removeClass('force_desktop' ).addClass('responsive');
620	$J('meta[name=viewport]' ).attr('value', 'width=device-width,initial-scale=1' );
621	$J(window ).trigger('resize');
622	*/
623	Responsive_UpdateResponsivePrefs( 'desktop', false );
624	window.location.reload();
625}
626
627
628function Responsive_UpdateResponsivePrefs( strFlag, bEnabled )
629{
630	if ( bEnabled )
631	{
632		V_SetCookie( "strResponsiveViewPrefs", strFlag, 365 );
633	}
634	else
635	{
636		V_SetCookie( "strResponsiveViewPrefs", null, -1 );
637	}
638}
639
640function Responsive_InitResponsiveToggleEvents( $ )
641{
642	// initially undefined, so we will fire the events at at start
643	var bTouchFriendly, bSmallScreen, bMobileScreen, bTabletScreen;
644
645	$(window).on('resize.ResponsiveToggle', function() {
646		if ( window.UseTouchFriendlyMode() !== bTouchFriendly )
647		{
648			bTouchFriendly = window.UseTouchFriendlyMode();
649			$(window).trigger('Responsive_TouchFriendlyModeToggled');
650		}
651
652		if ( window.UseSmallScreenMode() !== bSmallScreen )
653		{
654			bSmallScreen = window.UseSmallScreenMode();
655			$(window).trigger('Responsive_SmallScreenModeToggled');
656		}
657
658		if ( window.UseMobileScreenMode() !== bMobileScreen )
659		{
660			bMobileScreen = window.UseMobileScreenMode();
661			$(window).trigger('Responsive_MobileScreenModeToggled');
662		}
663
664		if ( window.UseTabletScreenMode() !== bTabletScreen )
665		{
666			bTabletScreen = window.UseTabletScreenMode();
667			$(window).trigger('Responsive_TabletScreenModeToggled');
668		}
669
670
671	} ).trigger( 'resize.ResponsiveToggle' );
672}
673
674/* reparent element when screen width is up to MOBILE_RESPONSIVE_CSS_MAXWIDTH */
675function Responsive_ReparentItemsInMobileMode( strItemSelector, $CtnOrFn )
676{
677	return _Responsive_ReparentItems( strItemSelector, $CtnOrFn, function() { return window.UseMobileScreenMode && window.UseMobileScreenMode(); }, 'Responsive_MobileScreenModeToggled' );
678}
679
680/* reparent element when we're rendering in the tablet layout (which could be any screen size given docked tablet scenarios) */
681function Responsive_ReparentItemsInTabletMode( strItemSelector, $CtnOrFn )
682{
683	return _Responsive_ReparentItems( strItemSelector, $CtnOrFn, function() { return window.UseTabletScreenMode && window.UseTabletScreenMode(); }, 'Responsive_TabletScreenModeToggled' );
684}
685
686/* reparent element when screen width is up to RESPONSIVE_CSS_MAXWIDTH, or we're in TabletScreenMode */
687function Responsive_ReparentItemsInResponsiveMode( strItemSelector, $CtnOrFn, isWideModeEnabled )
688{
689	var fnShouldReparent = function()
690	{
691		return ( ( window.UseSmallScreenMode && window.UseSmallScreenMode( isWideModeEnabled ) ) ||
692			( window.UseTabletScreenMode && window.UseTabletScreenMode() ) );
693	}
694
695	return _Responsive_ReparentItems( strItemSelector, $CtnOrFn, fnSh
695ouldReparent, 'Responsive_SmallScreenModeToggled' );
696}
697
698function _Responsive_ReparentItems( strItemSelector, $CtnOrFn, fnShouldReparent, bEvent )
699{
700	var fnReparentItems = function() {
701
702		var $MoveElements = $J(strItemSelector);
703		$MoveElements.each( function() {
704			var $Element = $J(this);
705			var $OriginalSpot = $Element.data('originalSpot' + bEvent);
706
707			if ( fnShouldReparent() )
708			{
709                if ( !$OriginalSpot )
710                {
711                	$OriginalSpot = $J( '<div/>' );
712                    $Element.after( $OriginalSpot );
713                    $Element.data('originalSpot' + bEvent, $OriginalSpot );
714                }
715
716				var $Ctn;
717				if ( typeof $CtnOrFn === 'function' ) {
718					$Ctn = $CtnOrFn( $Element );
719				} else {
720					$Ctn = $CtnOrFn;
721				}
722
723				$Ctn.append( $Element );
724			}
725			else
726			{
727				if ( $OriginalSpot )
728				{
729					// If we've tracked an original parent, put us back
730					$OriginalSpot.after( $Element );
731					$OriginalSpot.remove();
732					$Element.removeData( 'originalSpot' + bEvent );
733				}
734				// Otherwise, we should already be where we want
735			}
736		});
737
738	};
739
740	fnReparentItems();
741	$J( window ).on( bEvent, fnReparentItems );
742}
743
744function Responsive_InitJQPlotHooks( $ )
745{
746	if ( $.jqplot )
747	{
748		$.jqplot.postInitHooks.push( function( name, data, options ) {
749			var jqplot = this;
750			var bWasInResponsiveMode;
751
752			//replotting is very expensive, so we try to delay if the user is actively resizing
753			var iReplotInterval;
754			$J(window).resize( function() {
755				if ( ( UseSmallScreenMode() || bWasInResponsiveMode ) )
756				{
757					if ( iReplotInterval )
758					{
759						// we will reschedule for 100ms from now
760						window.clearInterval( iReplotInterval );
761					}
762					else
763					{
764						//interval hasn't been scheduled yet, must be the first resize.
765						// set overflow to hidden so the plot doesn't stretch the page while resizing
766						jqplot.target.css( 'overflow', 'hidden' );
767					}
768
769					iReplotInterval = window.setTimeout( function() {
770						iReplotInterval = null;
771
772						jqplot.replot();
773
774						jqplot.target.css( 'overflow', '' );
775					}, 100 );
776
777					bWasInResponsiveMode = UseSmallScreenMode();
778				}
779			});
780		});
781	}
782}
783
784// Enable toggling the local menu via JS
785// Added so search can support use of a gamepad button to open the filter window
786var g_fnActivateLocalMenu = false;
787function Responsive_ToggleLocalMenu()
788{
789	if ( g_fnActivateLocalMenu )
790		g_fnActivateLocalMenu();
791	else
792		console.error("attempted to open a local menu which does not exist");
793}

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.