PageSourceSearch

https://www.myarena.ru/js/jquery.rotator.js?95

js myarena.ru collected 2026-09-29 09:21:06 UTC 10,764 bytes, 253 lines download raw bytes

1/** Ротатор баннеров jquery.rotator.js
2 *  http://biznesguide.ru/coding/152.html
3 *  Copyright (c) 2011 Шамшур Иван (http://twitter.com/ivanshamshur)
4 *  Dual licensed under the MIT and GPL licenses
5 */
6 
7//				{url:'/',img:'images/news/top/ny2014.png'},
8//{url:'/game_jc2.html',img:'images/news/top/ny2014.png'},
9
10
11
12//				{url:'/game_mc.html',img:'images/news/top/mc-10day.png'},
13
14//				{url:'/game_rust.html',img:'images/news/top/rust_banner.png'},
15//            			{url:'/game_csgo.html',img:'images/news/top/big_csgo.jpg'},
16//				{url:'/',img:'images/news/top/wow2.jpg'},
17//				{url:'/',img:'images/news/top/wow2.jpg'},
18
19
20
21
22;(function($){
23	var defaults = {
24		slides: [
25				
26				//{url:'/vknews.html',img:'/images/news/top/wow2.jpg'}
27				{url:'/',img:'/images/news/rotator/gameDdosProtect.jpg'},
28				{url:'/vds_kvm.html',img:'/images/news/rotator/vdskvm.jpg'},
29//                                {url:'/',img:'/images/news/rotator/antiddoshttp.jpg'}
30//				{url:'/fullnews.html?id=88',img:'/images/news/rotator/NG-20-MA.jpg'},
31//				{url:'/game_dayz.html',img:'/images/news/rotator/dayz-guard-arena.jpg'},
32//				{url:'/webhosting.html',img:'/images/news/rotator/new_web.jpg'},
33//				{url:'/vds_kvm.html',img:'/images/news/rotator/vds-kvm.jpg'},
34//				{url:'/fullnews.html?id=60',img:'/images/news/top/30free.jpg'},
35
36
37
38//				{url:'/fullnews.html?id=68',img:'/images/news/top/ng2016.png'},
39//				{url:'/fullnews.html?id=66',img:'/images/news/top/ng-16-3.jpg'},
40
41				//{url:'/game_arma3.html',img:'images/news/rotator/arma3.png'},
42				//{url:'/game_mcpe.html',img:'images/news/rotator/mcpe.jpg'},
43				//{url:'/game_garrysmod.html',img:'images/news/top/garrysmod.png'},
44	//			{url:'/fullnews.html?id=53',img:'images/news/top/mc_pro.png'},
45	//			{url:'/fullnews.html?id=52',img:'images/news/top/android.png'},
46				//{url:'/fullnews.html?id=51',img:'images/news/top/cometoarena.jpg'},
47//				{url:'/fullnews.html?id=50',img:'images/news/top/mc-getbukkit.jpg'},
48//				{url:'/game_mc.html',img:'images/news/top/minecraft-price20.jpg'},
49//				{url:'/game_rust.html',img:'images/news/top/rust_banner.png'},
50//				{url:'/game_csgo.html',img:'images/news/rotator/csgobanner.jpg'},
51//				{url:'/game_css.html',img:'images/news/rotator/cssbanner.jpg'},
52//				{url:'/game_cs.html',img:'images/news/rotator/csbanner.jpg'},				
53				
54
55			
56            		],
57		speed: 700,
58		timeout: 15000,
59		width: 918,
60		height: 246,
61		random: false, 
62		autorun: true,
63		fx: 'slide',
64		nav: false,		
65	};
66
67	$.rotator = function(e, o) {
68		this.options = $.extend({}, defaults, o || {});
69		this.el = $(e);
70        this.step = -1;
71        this.current = 0;
72        this.previous = 0;
73        this.animating = false;
74        this.intervalID = null;
75		this.nav_left = $('<a href="javascript:void(0);" class="rotator-nav" id="rotator-left"><div></div></a>');
76		this.nav_right = $('<a href="javascript:void(0);" class="rotator-nav" id="rotator-right"><div></div></a>');
77		this.preloader = $('<div class="preloader_rotator"></div>');
78		this.main_rotator = $('<div class="main_rotator"></div>');
79		this.slides_rotator = $('<ul class="slides_rotator"></ul>');
80		this.count = this.options.slides.length - 1;
81		this.init();
82	};
83	
84	var $r = $.rotator;
85	$r.fn = $r.prototype = {
86        rotator: '0.1'
87    };
88	
89	$r.fn.extend = $r.extend = $.extend;
90    $r.fn.extend({
91    	init: function(){
92    		this.preload();
93            var self = this;
94            this.nav_left.bind('click.rotator',function(){
95				self.prev();
96			});
97			this.nav_right.bind('click.rotator',function(){
98				self.next();
99			});
100			this.el.hover(function(){
101                $('.rotator-nav',this).show();
102            },
103            function(){
104                $('.rotator-nav',this).hide();
105            });
106    		
107    	},
108        add: function(slides){
109            if(slides.length == 0) return false;
110            var render = [], self = this;
111            this.count += slides.length-1;
112	    	$.each(slides,function(i,slide){
113//	    		render.push('<li><div class="img_rotator"><a rel="nofollow" href="'+slide.url+'" target="_parent _blank"><img src="'+slide.img+'" width="'+self.options.width+'" height="'+self.options.height+'" alt="*" /></a></div></li>');
114	    		render.push('<li><div class="img_rotator"><a rel="nofollow" href="'+slide.url+'" ><img src="'+slide.img+'" width="'+self.options.width+'" height="'+self.options.height+'" alt="*" /></a></div></li>');
115	    	});
116
117	    	this.slides_rotator
118            .append(render.join(''))
119            .find('li')
120            .css({'position': 'absolute','z-index': 1,'left':this.options.width});
121        },
122    	preload: function(){
123    		//Индикатор загрузки
124	    	this.el.html(this.preloader.append('<img src="images/ajax-loader.gif" width="32"/>'));               		    	
125	        var loaded = 0,pic = [],self = this;
126            //Добавляем html-разметку слайдов    
127            this.slides = this.render().find('li').css({'position': 'absolute','z-index': 1});
128            this.main_rotator.css({display: 'none'});
129            this.slides_rotator.css({width:this.options.width,height:this.options.height}); 
130	        if(this.options.fx == 'fade'){
131	    		//Скрываем все слайды, кроме первого
132		        this.slides.css('opacity',0).eq(0).css({'z-index': 2,'opacity':1});
133	    	}
134	    	else{
135	    		this.slides_rotator.css('overflow','hidden'); 
136	    		//Задаем начальную позицию слайдам
137		        this.slides.css('left',this.options.width).eq(0).css({'z-index': 2,'left':0});
138             }
139             //Когда все изображения слайдов загрузятся
140	        //прячем индикатор загрузки и выводим первый слайд
141	        for (i=0; i <= this.count; i++) {
142	           pic[i] = new Image();
143               pic[i].onload = function() {
144	                loaded++;
145                    //Когда все картинки загружены
146                    //прячем индикатор загрузки и выводим слайды
147	                if(loaded >= self.count){
148	                	self.main_rotator.show();
149                        //$('.rotator-nav').show();
150	                	self.preloader.hide();
151	                	if(self.options.autorun){
152	                		self.start();
153	                	}
154	                }
155	            };
156                pic[i].src = this.options.slides[i].img;
157	        }
158		},
159		render: function(){
160            this.el.append(this.main_rotator);
161            if(this.options.nav){
162                this.el.append(this.nav_left,this.nav_right);
163                $('.rotator-nav').hide();
164            }
165	        //Перемешиваем слайды
166            if(this.options.random){
167                this.options.slides.sort(function() {return 0.5 - Math.random()});
168            }
169	    	var render = [], self = this;
170	    	$.each(this.options.slides,function(i,slide){
171//	    		render.push('<li><div class="img_rotator"><a rel="nofollow" href="'+slide.url+'" target="_parent _blank"><img src="'+slide.img+'" width="'+self.options.width+'" height="'+self.options.height+'" alt="*" /></a></div></li>');
172	    		render.push('<li><div class="img_rotator"><a rel="nofollow" href="'+slide.url+'"><img src="'+slide.img+'" width="'+self.options.width+'" height="'+self.options.height+'" alt="*" /></a></div></li>');
173	    	});
174	    	return this.slides_rotator.html(render.join('')).appendTo(this.main_rotator);
175	    },
176        start: function(){
177            var self = this;
178            this.step = -1; 
179	    	this.intervalID = setInterval(function(){self.next();},this.options.timeout);   	
180	    },
181        stop: function(){
182            clearInterval(this.intervalID);    	        
183        },
184        next: function(){
185            if(this.animating) return false;
186            this.step = -1;  
187	    	if(this.current >= this.count) this.current = -1;
188	    	this.previous = this.current;
189	    	this.current++;
190	    	if(this.current == 0) this.previous = this.count;
191	    	this.run();
192	    },
193        prev: function(){
194            if(this.animating) return false;
195            this.step = 1;
196	    	this.previous = this.current;
197	    	this.current--;
198	    	if(this.current < 0) this.current = this.count;
199        	this.run();
200        },
201        run: function(){
202            var self = this;
203            this.animating = true; //начало анимации
204            if(this.options.autorun) this.stop();
205        	if(this.options.fx == 'fade'){
206                this.slides.eq(this.previous)
207                .css('z-index',1)
208                .stop(true,true)
209                .animate({'opacity': 0},this.options.speed);  
210        		this.slides.eq(this.current)
211                .css('z-index',2)
212                .stop(true,true)
213                .animate({'opacity': 1},this.options.speed,function(){                    
214                    self.animating = false; //конец анимации
215                });  
216        	}
217        	else{
218                this.slides.eq(this.previous)
219                .css('z-index',1)
220                .stop(true,true)
221                .animate({'left': this.step*this.options.width},this.options.speed,function(){
222                    $(this).css('left',this.step*self.options.width);
223                });
224                var sc = this.slides.eq(this.current);
225                if(sc.css('left').match(/([-\d]+)/)[1] != -this.step*this.options.width){
226                    sc.css('left',-this.step*this.options.width);
227                }
228                sc.css({'z-index':2}).stop(true,true).animate({'left': 0},this.options.speed,function(){
229                    self.animating = false; //конец анимации
230                });
231        	}
232            if(this.options.autorun) this.start();
233        }
234    });
235    $.fn.rotator = function(o){
236    	if (typeof o == 'string') {
237            var instance = $(this).data('rotator'), args = Array.prototype.slice.call(arguments, 1);
238            return instance[o].apply(instance, args);
239        } else {
240            return this.each(function() {
241                var instance = $(this).data('rotator');
242                if (instance) {
243                    if (o) {
244                        $.extend(instance.options, o);
245                    }
246                    instance.init();
247                } else {
248                    $(this).data('rotator', new $r(this, o));
249                }
250            });
251        }
252    };   
253})(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.