PageSourceSearch

https://lucky-ibaraki.com/module/js/ticker_.js

js lucky-ibaraki.com collected 2026-10-02 04:17:05 UTC 11,658 bytes, 298 lines download raw bytes

1/*
2 * jQuery ticker
3 *
4 * jQuery required.
5 * jQuery Easing Plugin extends this Plugin.
6 *
7 * Copyright 2011 (c) kamem
8 * http://develo.org/
9 * Licensed Under the MIT.
10 *
11 * Date: 2011.06.25 
12*/
13(function($){
14
15// リストにつくid名
16var tagId ="tickerId_"
17
18var count = [];
19var start = [];
20var end = [];
21
22var wrapArray = [];
23var wrapId = [];
24
25var wrapWidth = [];
26var wrapHegith = [];
27var ulHegith = [];
28
29var beforeTag= [];
30var tag= [];
31var nextTag= [];
32
33var info = {};
34
35var btn;
36
37//スマートフォンウィンドウサイズを変えたときに情報更新
38window.onresize = function() {
39	for(var i = 0;wrapId.length > i ;i++) {
40			if(info[i].type == "move1" || info[i].type == "normal") {
41				var userAgent = navigator.userAgent.toLowerCase();
42				if(userAgent.search(/iphone/) >= 0 || userAgent.search(/ipad/) >= 0 || userAgent.search(/Android/) >= 0) {
43					
44				wrapWidth[i] = wrapArray[i].width();
45				wrapHegith[i] = wrapArray[i].height();
46				
47				$("#" + wrapId[i] + " ul li").each(function(j){
48					$(this).queue([]).stop()
49					$(this).css("left",wrapWidth[i]);
50				});
51				ticker(
52				i,
53				info[i].target,
54				info[i].delay,
55				info[i].delay1,
56				info[i].delay2,
57				info[i].speed,
58				info[i].speed1,
59				info[i].speed2,
60				info[i].easing,
61				info[i].type
62				);
63				flag = false
64				}
65			}
66	}
67}
68
69$(function(){
70	$.fn.newsTicker = function(options){
71		//if(this.length<=1) return false;
72	
73		//親取得
74		wrapArray.push($(this).closest("ul").closest("div"));
75		wrapId.push($(this).closest("ul").closest("div").attr("id"));
76
77		//ページ内に複数Tikcrがある場合の番号付け
78		var num = wrapArray.length -1;
79		start[num] = count[num] = 0
80		end[num] = this.length-1
81		
82		//親の幅
83		wrapWidth[num] = wrapArray[num].width();
84		wrapHegith[num] = wrapArray[num].height();
85		ulHegith[num] = $("#" + wrapId[num] + " ul").height();
86		
87		var c = $.extend({
88			target: this,
89			delay: 2000,
90			delay1: 1000,
91			delay2: 500,
92			speed: 50,
93			speed1: 1000,
94			speed2: 50,
95			easing: "easeOutQuad",
96			type: "normal",
97			onresize: false
98		},options);
99		
100		info[num] =  {
101			target: c.target,
102			delay: c.delay,
103			delay1: c.delay1,
104			delay2: c.delay2,
105			speed: c.speed,
106			speed1: c.speed1,
107			speed2: c.speed2,
108			easing: c.easing,
109			type: c.type,
110			onresize: c.onresize
111		}
112
113		//初期設定
114		this.each(function(i){
115			//idをつける
116			$(this).attr("class",tagId+i);
117			
118			if(c.type == "fade") {
119				//最初以外は消す
120				if(i!=0) $(this).hide();
121			}
122			
123			if(c.type == "move1") {
124				$(this).css("left",$(this).closest("ul").closest("div").width());
125			}
126			
127			if(c.type == "normal") {
128				$(this).css("left",$(this).closest("ul").closest("div").width());
129			}
130			
131			if(c.type == "longitudinally") {
132				if(i == 0) {
133					$(this).css("top",0);
134				}
135				else {
136					$(this).css("top",ulHegith[num]);
137				}
138			}
139		});
140
141		$(window).bind("load",function(){
142			ticker(
143			num,
144			c.target,
145			c.delay,
146			c.delay1,
147			c.delay2,
148			c.speed,
149			c.speed1,
150			c.speed2,
151			c.easing,
152			c.type
153			);
154		});
155	}
156});
157
158function ticker(num,target,delay,delay1,delay2,speed,speed1,speed2,easing,type) {
159			
160	//今のタグと前のタグと次のタグ
161	beforeTag[num] = "#" + target.closest("ul").closest("div").attr("id") + " ." +tagId+ (count[num] == 0 ? end[num] : count[num] -1);
162	
163	tag[num] = "#" + target.closest("ul").closest("div").attr("id") + " ." +tagId+count[num];
164	
165	++count[num]	
166	if(count[num]>end[num]){
167		start[num] = 1;
168		count[num] = 0;
169	}
170	nextTag[num] = "#" + target.closest("ul").closest("div").attr("id") + " ." +tagId+ count[num];
171
172	//それぞれ横幅
173	var tagWidth =$(tag[num]).width();
174	var nextTagWidth =$(nextTag[num]).width();
175
176	switch (type) {
177	
178		//ノーマルティッカー
179		case "normal":
180			var time =  (tagWidth + wrapWidth[num]) / (speed / 1000);
181			$(tag[num]).delay(0).animate({ left : - tagWidth}, time, 'linear',
182				function(){$(tag[num]).delay(0).animate({ left: wrapWidth[num]}, 0, 'linear',
183				function(){ticker(num,target,delay,delay1,delay2,speed,speed1,speed2,easing,type);});
184				});
185			break;
186		
187		//縦バージョン
188		case "longitudinally":
189			//最初のひとつだけは少し待ってから処理
190			if(start[num] == 0 && tag[num].charAt(tag[num].length-1) == 0) {
191				$(tag[num]).delay(delay).animate({top : -ulHegith[num],opacity : 0}, 1000, easing);
192				$(nextTag[num]).delay(delay).animate({top : 0,opacity : 1}, 1000, easing,function(){$(tag[num]).delay(delay).animate({top: ulHegith[num],opacity : 0},0,
193				function(){ticker(num,target,delay,delay1,delay2,speed,speed1,speed2,easing,type);});});
194			}
195			else{
196				$(tag[num]).animate({top : -ulHegith[num],opacity : 0}, 1000, easing);
197				$(nextTag[num]).animate({top : 0,opacity : 1}, 1000, easing,function(){$(tag[num]).delay(delay).animate({top: ulHegith[num],opacity : 0},0,
198				function(){ticker(num,target,delay,delay1,delay2,speed,speed1,speed2,easing,type);});});
199			}
200			break;
201
202		//フェイドイン、フェイドアウト
203		case "fade":
204			//最初のひとつだけは少し待ってから処理
205			if(start[num] == 0 && tag[num].charAt(tag[num].length-1) == 0) {
206				$(tag[num]).delay(delay).fadeOut(1000);
207				$(nextTag[num]).delay(delay).fadeIn(1000,function(){$(tag[num]).delay(delay).animate({left: 0},0,
208				function(){ticker(num,target,delay,delay1,delay2,speed,speed1,speed2,easing,type);});});
209			}
210			else{
211				$(tag[num]).fadeOut(1000);
212				$(nextTag[num]).fadeIn(1000,function(){$(tag[num]).delay(delay).animate({left: 10},0,
213				function(){ticker(num,target,delay,delay1,delay2,speed,speed1,speed2,easing,type);});});
214			}
215			break;
216
217		//すばやく出てきて、そのあとにティッカー
218		case "move1":
219			var time =  (tagWidth + 10) / (speed2 / 1000);
220			$(tag[num]).animate({ left : 10}, speed1, easing,
221				function(){$(tag[num]).delay(delay1).animate({ left : - tagWidth}, time, 'linear',
222				function(){$(tag[num]).delay(delay2).animate({ left: wrapWidth[num]}, 0,
223				function(){ticker(num,target,delay,delay1,delay2,speed,speed1,speed2,easing,type);});});
224				});
225			break;
226	}
227}
228
229
230
231/*
232 * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
233 *
234 * Uses the built in easing capabilities added In jQuery 1.1
235 * to offer multiple easing options
236 *
237 * TERMS OF USE - jQuery Easing
238 * 
239 * Open source under the BSD License. 
240 * 
241 * Copyright %copy; 2008 George McGinley Smith
242 * All rights reserved.
243 * 
244 * Redistribution and use in source and binary forms, with or without modification, 
245 * are permitted provided that the following conditions are met:
246 * 
247 * Redistributions of source code must retain the above copyright notice, this list of 
248 * conditions and the following disclaimer.
249 * Redistributions in binary form must reproduce the above copyright notice, this list 
250 * of conditions and the following disclaimer in the documentation and/or other materials 
251 * provided with the distribution.
252 * 
253 * Neither the name of the author nor the names of contributors may be used to endorse 
254 * or promote products derived from this software without specific prior written permission.
255 * 
256 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
257 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
258 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
259 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
260 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
261 *  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
262 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
263 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
264 * OF THE POSSIBILITY OF SUCH DAMAGE. 
265 *
266*/
267
268jQuery.easing.jswing=jQuery.easing.swing;
269jQuery.easing.jswing=jQuery.easing.swing;
270jQuery.extend(jQuery.easing,{
271	def:"easeOutQuad",
272	swing:function(j,i,b,c,d){return jQuery.easing[jQuery.easing.def](j,i,b,c,d);},easeInQuad:function(j,i,b,c,d){return c*(i/=d)*i+b;},easeOutQuad:function(j,i,b,c,d){return -c*(i/=d)*(i-2)+b;},
273	easeInOutQuad:function(j,i,b,c,d){if((i/=d/2)<1){return c/2*i*i+b;}return -c/2*((--i)*(i-2)-1)+b;},easeInCubic:function(j,i,b,c,d){return c*(i/=d)*i*i+b;},easeOutCubic:function(j,i,b,c,d){return c*((i=i/d-1)*i*i+1)+b;},easeInOutCubic:function(j,i,b,c,d){if((i/=d/2)<1){return c/2*i*i*i+b;}return c/2*((i-=2)*i*i+2)+b;},
274	easeInQuart:function(j,i,b,c,d){return c*(i/=d)*i*i*i+b;},
275	easeOutQuart:function(j,i,b,c,d){return -c*((i=i/d-1)*i*i*i-1)+b;},
276	easeInOutQuart:function(j,i,b,c,d){if((i/=d/2)<1){return c/2*i*i*i*i+b;}return -c/2*((i-=2)*i*i*i-2)+b;},
277	easeInQuint:function(j,i,b,c,d){return c*(i/=d)*i*i*i*i+b;},
278	easeOutQuint:function(j,i,b,c,d){return c*((i=i/d-1)*i*i*i*i+1)+b;},
279	easeInOutQuint:function(j,i,b,c,d){if((i/=d/2)<1){return c/2*i*i*i*i*i+b;}return c/2*((i-=2)*i*i*i*i+2)+b;},
280	easeInSine:function(j,i,b,c,d){return -c*Math.cos(i/d*(Math.PI/2))+c+b;},
281	easeOutSine:function(j,i,b,c,d){return c*Math.sin(i/d*(Math.PI/2))+b;},
282	easeInOutSine:function(j,i,b,c,d){return -c/2*(Math.cos(Math.PI*i/d)-1)+b;},
283	easeInExpo:function(j,i,b,c,d){return(i==0)?b:c*Math.pow(2,10*(i/d-1))+b;},
284	easeOutExpo:function(j,i,b,c,d){return(i==d)?b+c:c*(-Math.pow(2,-10*i/d)+1)+b;},
285	easeInOutExpo:function(j,i,b,c,d){if(i==0){return b;}if(i==d){return b+c;}if((i/=d/2)<1){return c/2*Math.pow(2,10*(i-1))+b;}return c/2*(-Math.pow(2,-10*--i)+2)+b;},easeInCirc:function(j,i,b,c,d){return -c*(Math.sqrt(1-(i/=d)*i)-1)+b;},
286	easeOutCirc:function(j,i,b,c,d){return c*Math.sqrt(1-(i=i/d-1)*i)+b;},
287	easeInOutCirc:function(j,i,b,c,d){if((i/=d/2)<1){return -c/2*(Math.sqrt(1-i*i)-1)+b;}return c/2*(Math.sqrt(1-(i-=2)*i)+1)+b;},
288	easeInElastic:function(o,m,p,a,b){var d=1.70158;var c=0;var n=a;if(m==0){return p;}if((m/=b)==1){return p+a;}if(!c){c=b*0.3;}
288if(n<Math.abs(a)){n=a;var d=c/4;}else{var d=c/(2*Math.PI)*Math.asin(a/n);}return -(n*Math.pow(2,10*(m-=1))*Math.sin((m*b-d)*(2*Math.PI)/c))+p;},
289	easeOutElastic:function(o,m,p,a,b){var d=1.70158;var c=0;var n=a;if(m==0){return p;}if((m/=b)==1){return p+a;}if(!c){c=b*0.3;}if(n<Math.abs(a)){n=a;var d=c/4;}else{var d=c/(2*Math.PI)*Math.asin(a/n);}return n*Math.pow(2,-10*m)*Math.sin((m*b-d)*(2*Math.PI)/c)+a+p;},
290	easeInOutElastic:function(o,m,p,a,b){var d=1.70158;var c=0;var n=a;if(m==0){return p;}if((m/=b/2)==2){return p+a;}if(!c){c=b*(0.3*1.5);}if(n<Math.abs(a)){n=a;var d=c/4;}else{var d=c/(2*Math.PI)*Math.asin(a/n);}if(m<1){return -0.5*(n*Math.pow(2,10*(m-=1))*Math.sin((m*b-d)*(2*Math.PI)/c))+p;}return n*Math.pow(2,-10*(m-=1))*Math.sin((m*b-d)*(2*Math.PI)/c)*0.5+a+p;},
291	easeInBack:function(l,k,b,c,d,j){if(j==undefined){j=1.70158;}return c*(k/=d)*k*((j+1)*k-j)+b;},
292	easeOutBack:function(l,k,b,c,d,j){if(j==undefined){j=1.70158;}return c*((k=k/d-1)*k*((j+1)*k+j)+1)+b;},
293	easeInOutBack:function(l,k,b,c,d,j){if(j==undefined){j=1.70158;}if((k/=d/2)<1){return c/2*(k*k*(((j*=(1.525))+1)*k-j))+b;}return c/2*((k-=2)*k*(((j*=(1.525))+1)*k+j)+2)+b;},easeInBounce:function(j,i,b,c,d){return c-jQuery.easing.easeOutBounce(j,d-i,0,c,d)+b;},
294	easeOutBounce:function(j,i,b,c,d){if((i/=d)<(1/2.75)){return c*(7.5625*i*i)+b;}else{if(i<(2/2.75)){return c*(7.5625*(i-=(1.5/2.75))*i+0.75)+b;}else{if(i<(2.5/2.75)){return c*(7.5625*(i-=(2.25/2.75))*i+0.9375)+b;}else{return c*(7.5625*(i-=(2.625/2.75))*i+0.984375)+b;}}}},
295	easeInOutBounce:function(j,i,b,c,d){if(i<d/2){return jQuery.easing.easeInBounce(j,i*2,0,c,d)*0.5+b;}return jQuery.easing.easeOutBounce(j,i*2-d,0,c,d)*0.5+c*0.5+b;}
296});
297
298}(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.