PageSourceSearch

https://ampeg.jp/js/topnav2.js

js ampeg.jp collected 2026-09-29 22:55:37 UTC 9,895 bytes, 305 lines download raw bytes

1var app = new Object;
2
3$(document).ready(function(e) {
4	var width = $(window).width(); // window width
5	var navFadeSpeed = 200;
6	var navFadeSpeedFaster = 100;
7	var mobilePageWidth = 767;
8	var largePageWidth = 992;
9	var default_scrollThreshold = 84; // when nav will collapse
10    var init_mobile_nav_timeout = '';
11    
12	app = {
13		nav : function () {
14			// mobile nav
15			var dropdownStates = new Array();
16			var navStates = new Array();
17            var nav_container = '.navbar';
18			
19			dropdownStates['products-subnav'] = false;
20			dropdownStates['search-subnav'] = false;
21			dropdownStates['account-subnav'] = false;
22			dropdownStates['region-subnav'] = false;
23			dropdownStates['nav-mobile'] = false;
24			
25			navStates['products'] = false;
26			
27			function toggleDropdowns(dropdown) {
28                //console.log("Toggle "+dropdown+" nc "+ nav_container);
29				
30                if (dropdown) {
31					toggleNavs(null);
32				}
33                else {
34                    $('#global-topnav-mobile').removeClass('is-active');
35                }
36
37				for (key in dropdownStates) {
38					if (key == dropdown) {
39						if (dropdownStates[dropdown] == false) {
40							dropdownStates[dropdown] = true;
41							$(nav_container + ' #'+dropdown+"-container").fadeIn();
42							//alert('showing '+key);
43						} else {
44							dropdownStates[dropdown] = false;
45							$(nav_container + ' #'+dropdown+"-container").fadeOut();
46							//alert('hiding '+key + ' since already open');
47						}
48					} else {
49						dropdownStates[key] = false;
50						$(nav_container + ' #'+key+"-container").fadeOut();
51					}
52				}
53			}
54			
55			function toggleNavs (nav) {
56				if (nav) {
57					toggleDropdowns(null);
58				}
59				
60				$(nav_container + ' .main-item').removeClass('dropdown');
61				
62				for (key in navStates) {
63					if (key == nav) {
64						if (navStates[nav] == false) {
65							navStates[nav] = true;
66                            console.log('1:'+nav);
67							$(nav_container + ' #'+nav+'-subnav-container').fadeIn(navFadeSpeed,null,function() {
68								$(nav_container + ' #'+nav+'-subnav-container').slideDown(navFadeSpeedFaster);
69							});
70						} else {
71							navStates[nav] = false;
72                            console.log('2:'+nav);
73							$(nav_container + ' #'+nav+'-subnav-container').slideUp(navFadeSpeedFaster,null,function () {
74								$(nav_container  + ' #'+nav+'-subnav-container').hide();	
75							});
76						}
77					} else {
78						navStates[key] = false;
79						$("#desktop_subnav_container " + '.'+key+'-container').slideUp(navFadeSpeedFaster);
80						$(nav_container + '.'+key+'-nav').hide();	
81					}
82				}
83			}
84			
85			// suppress default click behavior in the
86            // nav for elements with menus
87			$('.main-item.products, .search-desktop-form-container, .profile-desktop-form-container, .nav-mobile-main-item, .nav-mobile-sub-item, .nav-mobile-sub-sub-item').on('click', function(e) {
88				e.stopPropagation();
89			});
90			
91			// process clicks so the menu collapses 
92			$('html').on('click', function() {
93				toggleDropdowns(null);
94				toggleNavs(null);
95			});
96			
97            //mobile main menu
98			$('#global-topnav-mobile').on('click', function (e) { // open menu
99				e.stopPropagation();
100				e.preventDefault();
101                $(this).toggleClass('is-active');
102				toggleDropdowns('nav-mobile');
103			});
104						
105            //mobile search
106			$('#search-mobile-wrapper').on('click', function (e) { // open search
107				e.stopPropagation();
108				e.preventDefault();
109            });
110			$('.search-mobile-button-holder, .search-mobile-button-holder-selected').on('click', function (e) { // open search
111				e.stopPropagation();
112				e.preventDefault();
113				toggleDropdowns('search-mobile');
114                $(".search-mobile-form-field input#searchq").focus();
115			});
116						
117            //mobile menu item
118			$('.nav-mobile-main-item').on('click', function (e) {
119                
120                var clicked_element = $(this);
121				if ($(this).find('ul').length) {
122					$(this).find('ul').first().slideToggle();
123				} 
124			});
125			
126            //mobile menu sub item
127			$('.nav-mobile-sub-item').on('click', function (e) {
128				var clickedItem = $(this);
129				if (clickedItem.find('ul').length) {
130					e.preventDefault();
131					if (clickedItem.hasClass('selected')) {
132						clickedItem.removeClass('selected');
133					} else {
134						clickedItem.addClass('selected');
135					}
136					clickedItem.find('ul').slideToggle();
137				}
138			});
139			
140			// desktop nav
141			$('.header-button-search').on('click', function (e) { // open search
142				e.stopPropagation();
143				e.preventDefault();
144				toggleDropdowns('search-subnav');
145                $(".search-desktop-form-field input#searchq").focus();
146			});
147			
148			$('.header-button-region').on('click', function (e) { // open region
149				e.stopPropagation();
150				e.preventDefault();
151				toggleDropdowns('region-subnav');
152			});
153			
154			$('.header-button-account').on('click', function (e) { // open profile
155				e.stopPropagation();
156				e.preventDefault();
157				toggleDropdowns('account-subnav');
158			});
159			
160			$('.main-item.products').on('click',function (e) {
161				e.preventDefault();
162				toggleNavs('products'); 				
163			});
164          },	
165		resizePage : function(section) { // get page width and height
166            width = init_width();
167
168            if (width > mobilePageWidth && $('.thumb').length) { // unfog thumbs for desktop/tablet versions
169                $('.thumb').foggy(false);
170            }
171
172            if ($(".main-video")) {
173                var container_width = $(".main-video").parent().width();
174                var container_height = parseInt(container_width/(16/9))-2;
175
176                $(".main-video").css({
177                       'height' : container_height,
178                       'width' : container_width
179                });
180            }
181
182            if (init_mobile_nav_timeout != undefined) {
183                clearTimeout(init_mobile_nav_timeout);
184            }
185            init_mobile_nav_timeout = setTimeout(function(){init_mobile_nav()},100);
186		},
187		
188		checkScroll : function() { // collapse navs
189			var scrollVal = 0;
190			
191			$(window).scroll( function() { 
192				scrollVal = $(document).scrollTop().valueOf();
193                scrollThreshold = default_scrollThreshold;
194                if ($('#page-subnav').length) {
195                    scrollThreshold = $('#page-subnav').first().position().top;
196                }
197				
198				if (scrollVal > scrollThreshold) {
199					$('body').addClass('collapsed');
200				} else {
201					$('body').removeClass('collapsed');
202				}
203            });
204		},
205		reveals : function() {
206            //hide when reveal is embeded in the page_divider content                 
207            $('.section_page_divider .reveal-single').hide();
208
209			// double reveal processing
210			$('.reveal-double .reveal-cta .cta').on('click', function(e) { // double reveals show
211				e.preventDefault();
212				$(this).parent().find('.reveal-content').fadeIn();
213			});
214			
215			$('.reveal-content').on('click', function(e) { // double reveals hide
216				e.preventDefault();
217				$(this).fadeOut();
218			});
219			
220			$('.reveal-cta-inactive').on('click',function(e) {
221				e.preventDefault();
222				$(this).toggleClass('reveal-cta-inactive');
223				$(this).toggleClass('reveal-cta-active');
224				$(this).parent().parent().find('.reveal-single').slideToggle();
225			});
226			
227		},
228	} //app
229	
230	$(window).resize(function(){
231		app.resizePage();
232	});
233	
234	if ($('body').hasClass('homepage')) {
235		app.resizePage();
236	}
237	
238	if ($('#node_content').hasClass('node_v2')) {
239		app.reveals();
240	}
241
242    if (!$('body').hasClass('disable_nav')) {
243        app.nav();
244    }
245
246    if ($('.page-nav').length) {
247        app.checkScroll();
248    }
249
250    var mobile_con = $('.page-nav.visible-xs .nav-container');
251    var mobile_nav = $('.page-nav.visible-xs .nav-links');
252    var mobile_nav_offset = 0;
253    //because a font loads for this element the initialization needs
254    //to be delayed to ensure the calculations are for the final elements with fonts loaded
255    setTimeout(function(){init_mobile_nav()},500);
256
257    function init_mobile_nav() {
258        mobile_con = $('.page-nav.visible-xs .nav-container');
259        mobile_nav = $('.page-nav.visible-xs .nav-links');
260
261        if (width <= mobilePageWidth) { // calculate nav links width for mobile nav horizontal scroll
262            var navWidth = 16;
263            mobile_nav.find('a').each(function(index, element) {
264                var element_width = $(this).outerWidth(true);
265                navWidth = navWidth+element_width;
266                navWidth = navWidth + (element_width*.07);
267            });
268            
269            mobile_nav.css('width',navWidth);
270        }
271
272        if (mobile_con.length && mobile_nav.length) {
273            if (mobile_con.width() >= mobile_nav.width()) {
274                $('.scroll-indicator').css('display','none');
275            }
276            else {
277                $('.scroll-indicator').css('display','block');
278            }
279            mobile_nav.animate({'left':0});
280        }
281
282        mobile_nav_offset = mobile_con.width() - mobile_nav.width();
283    }
284
285    $('.page-nav.visible-xs .scroll-indicator').mousedown(function() {
286        if (mobile_nav.position().left < 0) { 
287            mobile_nav.css('position','relative').animate({left:0});
288        }
289        else {
290            if (mobile_nav_offset < 0) {
291                mobile_nav.css('position','relative').animate({left:mobile_nav_offset});
292            }
293        }
294    });
295});
296
297function init_width() {
298    var maxPageWidth = 1400;
299    width = $(window).width(); 
300
301    if (width > maxPageWidth) {// set max page width
302        width = maxPageWidth;
303    } 
304    return width;
305}

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.