PageSourceSearch

https://motociclismodobrasil.com.br/wp-content/themes/verticalmenu/js/functions.js?ver=20150330

js motociclismodobrasil.com.br collected 2026-10-02 01:18:18 UTC 5,598 bytes, 173 lines download raw bytes

1/* global screenReaderText */
2/**
3 * Theme functions file.
4 *
5 * Contains handlers for navigation and widget area.
6 */
7
8( function( $ ) {
9	var $body, $window, $sidebar, resizeTimer,
10		secondary, button;
11
12	function initMainNavigation( container ) {
13		// Add dropdown toggle that display child menu items.
14		container.find( '.menu-item-has-children > a' ).after( '<button class="dropdown-toggle" aria-expanded="false">' + screenReaderText.expand + '</button>' );
15
16		// Toggle buttons and submenu items with active children menu items.
17		container.find( '.current-menu-ancestor > button' ).addClass( 'toggle-on' );
18		container.find( '.current-menu-ancestor > .sub-menu' ).addClass( 'toggled-on' );
19
20		container.find( '.dropdown-toggle' ).on( 'click', function( e ) {
21			var _this = $( this );
22			e.preventDefault();
23			_this.toggleClass( 'toggle-on' );
24			_this.next( '.children, .sub-menu' ).toggleClass( 'toggled-on' );
25			_this.attr( 'aria-expanded', _this.attr( 'aria-expanded' ) === 'false' ? 'true' : 'false' );
26			_this.html( _this.html() === screenReaderText.expand ? screenReaderText.collapse : screenReaderText.expand );
27		} );
28	}
29	initMainNavigation( $( '.main-navigation' ) );
30
31	// Re-initialize the main navigation when it is updated, persisting any existing submenu expanded states.
32	$( document ).on( 'customize-preview-menu-refreshed', function( e, params ) {
33		if ( 'primary' === params.wpNavMenuArgs.theme_location ) {
34			initMainNavigation( params.newContainer );
35
36			// Re-sync expanded states from oldContainer.
37			params.oldContainer.find( '.dropdown-toggle.toggle-on' ).each(function() {
38				var containerId = $( this ).parent().prop( 'id' );
39				$( params.newContainer ).find( '#' + containerId + ' > .dropdown-toggle' ).triggerHandler( 'click' );
40			});
41		}
42	});
43
44	secondary = $( '#secondary' );
45	button = $( '.site-branding' ).find( '.secondary-toggle' );
46
47	// Enable menu toggle for small screens.
48	( function() {
49		var menu, widgets, social;
50		if ( ! secondary.length || ! button.length ) {
51			return;
52		}
53
54		// Hide button if there are no widgets and the menus are missing or empty.
55		menu    = secondary.find( '.nav-menu' );
56		widgets = secondary.find( '#widget-area' );
57		social  = secondary.find( '#social-navigation' );
58		if ( ! widgets.length && ! social.length && ( ! menu.length || ! menu.children().length ) ) {
59			button.hide();
60			return;
61		}
62
63		button.on( 'click.verticalmenu', function() {
64			secondary.toggleClass( 'toggled-on' );
65			secondary.trigger( 'resize' );
66			$( this ).toggleClass( 'toggled-on' );
67			if ( $( this, secondary ).hasClass( 'toggled-on' ) ) {
68				$( this ).attr( 'aria-expanded', 'true' );
69				secondary.attr( 'aria-expanded', 'true' );
70			} else {
71				$( this ).attr( 'aria-expanded', 'false' );
72				secondary.attr( 'aria-expanded', 'false' );
73			}
74		} );
75	} )();
76
77	/**
78	 * Add or remove ARIA attributes.
79	 *
80	 * Uses jQuery's width() function to determine the size of the window and add
81	 * the default ARIA attributes for the menu toggle if it's visible.
82	 *
83	 * @since Twenty Fifteen 1.1
84	 */
85	function onResizeARIA() {
86		if ( 955 > $window.width() ) {
87			button.attr( 'aria-expanded', 'false' );
88			secondary.attr( 'aria-expanded', 'false' );
89			button.attr( 'aria-controls', 'secondary' );
90		} else {
91			button.removeAttr( 'aria-expanded' );
92			secondary.removeAttr( 'aria-expanded' );
93			button.removeAttr( 'aria-controls' );
94		}
95	}
96
97	// Sidebar scrolling.
98	function resizeAndScroll() {
99		if (typeof $window !== 'undefined') {
100			var windowPos = $window.scrollTop(),
101				windowHeight = $window.height(),
102				sidebarHeight = $sidebar.height(),
103				pageHeight = $( '#page' ).height();
104
105			if ( 1041 < $window.width() && pageHeight > sidebarHeight && ( windowPos + windowHeight ) >= sidebarHeight ) {
106				$sidebar.css({
107					position: 'fixed',
108					bottom: sidebarHeight > windowHeight ? 0 : 'auto'
109				});
110			} else {
111				$sidebar.css('position', 'relative');
112			}
113		}
114	}
115
116	$( function() {
117		$body          = $( document.body );
118		$window        = $( window );
119		$sidebar       = $( '#sidebar' ).first();
120
121		$window
122			.on( 'scroll.verticalmenu', resizeAndScroll )
123			.on( 'load.verticalmenu', onResizeARIA )
124			.on( 'resize.verticalmenu', function() {
125				clearTimeout( resizeTimer );
126				resizeTimer = setTimeout( resizeAndScroll, 500 );
127				onResizeARIA();
128			} );
129		$sidebar.on( 'click.verticalmenu keydown.verticalmenu', 'button', resizeAndScroll );
130
131		for ( var i = 0; i < 6; i++ ) {
132			setTimeout( resizeAndScroll, 100 * i );
133		}
134	} );
135
136
137	$("#display_loading").fadeOut("slow");
138	var amountScrolled = 300;
139	$(window).scroll(function () {
140		if ($(window).scrollTop() > amountScrolled) {
141			$('a.back-to-top').fadeIn('fast');
142		} else {
143			$('a.back-to-top').fadeOut('fast');
144		}
145	});
146	$('a.back-to-top, a.simple-back-to-top').click(function () {
147		$("html, body").animate({ scrollTop: 0 }, "fast");
148		return false;
149	});
150	resizeAndScroll();
151	for (var i = 1; i < 6; i++) {
152		setTimeout(resizeAndScroll, 100 * i);
153	}
154
155
156
157} )( jQuery );
158
159    /* Toggle for ajax search  */
160	function changeClass(el)
161	{
162		 classe = document.getElementById("verticalmenu_m_search").className;
163		 if (classe == "verticalmenu_m_search1")
164		 {
165				document.getElementById("verticalmenu_m_search").className = "verticalmenu_m_search";
166				document.getElementById("verticalmenu_shopping_cart").className = "verticalmenu_shopping_cart";
167		 }
168		 else
169		 {
170				document.getElementById("verticalmenu_m_search").className = "verticalmenu_m_search1";
171				document.getElementById("verticalmenu_shopping_cart").className = "verticalmenu_shopping_cart1";
172		 }
173   } 

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.