PageSourceSearch

https://www.city.hanamaki.iwate.jp/_template_/_site_/_default_/_res/js/scroll_menu_a.js

js city.hanamaki.iwate.jp collected 2026-10-02 05:46:08 UTC 6,893 bytes, 242 lines download raw bytes

1//------------------------------------------------------------------------------
2//	メニュースクロール(透過表示・再生/停止機能付きバージョン)
3//------------------------------------------------------------------------------
4(function(){
5var $ = FI.jQuery;
6$(
7	function() {
8
9		var isPlay = true;//play and stop
10		var isHover = false;
11		var play=0;
12
13		//Change active Paging
14		tabListSwitch = function($active){
15			$("#scroll_a .paging ul li").attr({'aria-selected': 'false','tabindex': -1});
16			$active.attr({'aria-selected': 'true','tabindex': 0});
17			$("#scroll_a .paging ul li").each(function(){
18				var $tl_img = $(this).find("img")
19				if($(this).attr('aria-selected') == 'true'){
20					$tl_img.attr('src', $tl_img.attr('src').replace('_d.', '_o.'));
21				}else{
22					$tl_img.attr('src', $tl_img.attr('src').replace('_o.', '_d.'));
23				}
24			});
25		};
26
27		//Paging and Slider Function
28		rotate = function($active){
29			if($("#scroll_a .main:visible").size() > 0 && !isHover){
30				//delete effect & delete all tabindex for a-img
31				$("#scroll_a .photoleft a").attr({'tabindex': -1});
32				$("#scroll_a .photoleft img").attr({'tabindex': -1});
33				$("#scroll_a .main:visible").stop(true,true).animate({ opacity: 'hide'},500).attr({'aria-hidden': true});
34
35				//active effect
36				var act_panel_id = $active.attr('aria-controls');
37				var $act_pnl = $("#scroll_a .main[id='" + act_panel_id + "']");
38				$act_pnl.stop(true,true).animate({ opacity: 'show'},500).attr({'aria-hidden': false})
39				var $act_a = $act_pnl.find("a");
40				$act_a.size() > 0 ? $act_a.attr({'tabindex': 0}) : $act_pnl.find("img").attr({'tabindex': 0}) ;
41			}
42		}; 
43
44		//Rotation  and Timing Event
45		rotateSwitch = function(){
46			if(!isHover && isPlay){
47				var $active;
48				if(play){clearInterval(play);}
49				play = setInterval(function(){ //Set timer
50					$active = $("#scroll_a .paging ul li[aria-selected=true]").next();
51					if ( $active.length === 0 || !$active.is("li")) {
52						$active = $('#scroll_a .paging ul li:first');
53					}
54					tabListSwitch($active);
55					rotate($active);
56				}, 7000); //Timer speed in milliseconds (4秒)
57			}
58		};
59
60		//hover&tab in action
61		var evt_select_1 = function (self) {
62			if($("#scroll_a .main:visible").size() > 0){
63				clearInterval(play); //Stop the rotation
64				tabListSwitch($(self));
65				rotate($(self)); //Activate the clicked paging
66			}
67		};
68		//hover&tab out action
69		var evt_select_2 = function (self) {
70			if($("#scroll_a .main:visible").size() > 0 ){
71				rotateSwitch();
72			}
73		};
74
75		//keyboard and mouse action
76		//TabPanel
77		$("#scroll_a .main")
78		//On Hover
79		.hover(
80			function() {
81				clearInterval(play);
82				isHover = true;
83			}, 
84			function() {
85				isHover = false;
86				rotateSwitch();
87			}
88		);	
89		$("#scroll_a .photoleft a , #scroll_a .photoleft img")
90		//Tab focus
91		.focusin(function() {
92			clearInterval(play);
93			isHover = true;
94		})
95		.focusout(function() {
96			isHover = false;
97			rotateSwitch();
98		});
99
100		//TabList
101		$("#scroll_a .paging li")
102		//On Hover
103		.hover(
104			function() {
105				var $tl_img = $(this).find("img")
106				$tl_img.attr('src', $tl_img.attr('src').replace('_d.', '_o.'));
107			}, 
108			function() {
109				if($(this).attr('aria-selected') != 'true'){
110					var $tl_img = $(this).find("img")
111					$tl_img.attr('src', $tl_img.attr('src').replace('_o.', '_d.'));
112				}
113			}
114		)
115		//Tab focus
116		.focusin(function(event){
117			evt_select_1(this);
118			isHover = true;
119			})
120		.focusout(function(event){
121			isHover = false;
122			evt_select_2(this);
123		})
124		//click
125		.click(function(event){
126			clearInterval(play);
127			if ($("#scroll_a #image_reel_stop").is(':visible')){
128				$("#scroll_a #image_reel_stop").hide();
129				$("#scroll_a #image_reel_play").show();
130			}
131			isPlay = false;
132			})
133
134		//keyboard
135		$("#scroll_a .paging li").each(function(){
136			$(this).keydown(function(e){
137				switch(e.which) {
138					case 13:	//Enter
139						var act_panel_id = $("#scroll_a .paging ul li[aria-selected=true]").attr('aria-controls');
140						var $act_pnl = $("#scroll_a .main[id='" + act_panel_id + "']");
141						var $target = $act_pnl.find('a').size() > 0 ? $act_pnl.find('a') : $act_pnl.find('img');
142						$target.focus();
143						return false;
144					break;
145
146					case 36:	//Home
147						keyFunc($("#scroll_a .paging li:first"));
148						return false;
149					break;
150
151					case 35:	//End
152						keyFunc($("#scroll_a .paging li:last"));
153						return false;
154					break;
155
156					case 37:	//←
157					case 38:	//↑
158						var $active = $("#scroll_a .paging ul li[aria-selected=true]").prev();
159						if ( $active.length === 0 || !$active.is("li")) {
160							$active = $('#scroll_a .paging ul li:last');
161						}
162						keyFunc($active);
163						return false;
164					break;
165
166					case 39:	//→
167					case 40:	//↓
168						var $active = $("#scroll_a .paging ul li[aria-selected=true]").next();
169						if ( $active.length === 0 || !$active.is("li")) {
170							$active = $('#scroll_a .paging ul li:first');
171						}
172						keyFunc($active);
173						return false;
174					break;
175				}
176			});
177		});
178
179		var keyFunc = function ($active){
180			isHover = false;
181			evt_select_1($active);
182			$active.focus();
183			isHover = true;
184		}
185
186		//Play and Stop
187		var toggleButton = function (){
188			$("#scroll_a #image_reel_stop").toggle();
189			$("#scroll_a #image_reel_play").toggle();
190		}
191		$("#scroll_a #image_reel_stop").click(function(e){
192			clearInterval(play);
193			toggleButton();
194			$("#scroll_a #image_reel_play").focus();
195			isPlay = false;
196			return false;
197		});
198		$("#scroll_a #image_reel_play").click(function(){
199			isPlay = true;
200			rotateSwitch();
201			toggleButton();
202			$("#scroll_a #image_reel_stop").focus();
203			return false;
204		});
205
206		//----------------------------------------------------------------------------
207		//Set Default State of each portfolio piece
208		$("#scroll_a .main").each(function(i,ele){
209			$(this).attr({
210				'id': 'mvpanel' + (i+1),
211				'role': 'tabpanel',
212				'aria-hidden': true,
213				'aria-labeledby': 'mvtab' + (i+1)
214			});
215		});
216		$("#scroll_a .paging ul").attr({'role': 'tablist'});
217		$("#scroll_a .paging ul li").each(function(i,ele){
218			$(this).attr({
219				'id': 'mvtab' + (i+1),
220				'aria-controls': 'mvpanel' + (i+1),
221				'role': 'tab',
222				'aria-selected': false,
223				'data-rel': (i+1),
224				'tabindex': -1
225			})
226			.find("a").attr({'role': 'presentation','tabindex': -1});
227		});
228
229		//first view
230		$("#scroll_a .paging").show();
231		tabListSwitch($("#scroll_a .paging li:first"));
232		if($("#scroll_a .main:visible").size() > 0){
233			$("#scroll_a .main").hide();
234			$("#scroll_a .main:first").show();
235			$("#scroll_a #image_reel_stop").show();
236			$("#scroll_a #image_reel_play").hide();
237			rotateSwitch();
238		}
239
240	});
241
242})();

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.