PageSourceSearch

https://motochemica.pl/plugins/jquery.jcontent.0.8.js

js motochemica.pl collected 2026-10-03 00:16:21 UTC 8,824 bytes, 352 lines download raw bytes

1/*
2 * jContent - jQuery Simple Content Slider Plugin v0.8
3 * http://do-web.com/jcontent/overview
4 *
5 * Copyright 2011, Miriam Zusin
6 * Dual licensed under the MIT or GPL Version 2 licenses.
7 * http://do-web.com/jcontent/license
8 */
9
10(function($){
11	$.fn.jContent = function(options){
12		
13		var jhndl = this;
14		var options = $.extend({
15			speed: 500,
16			orientation: 'horizontal', //horizontal, vertical,
17			auto: false,
18			direction: 'next',
19			pause: 5000,
20			circle: false,
21			easing: '', //easeOutCirc, easeOutBounce,
22			xml: '',
23			pause_on_hover: false,
24			width: 655,
25			height: 170,
26			click: false,
27			videos: false
28		},options);
29
30		this.init = function(hndl){
31				
32			//init
33			hndl.div = $(hndl);			
34			hndl.slides_div = $(hndl).children("div.slides").css("overflow", "hidden").css("position", "relative").css("width", options.width).css("height", options.height).css("float", "left");	
35			hndl.currentSlide = 0;
36			hndl.lastDirection = '';
37			hndl.isMouseHover = false;
38			hndl.intervalId;
39			
40			//init classes
41			hndl.div.addClass("jContent");
42			if(options.orientation == 'horizontal'){
43				hndl.div.addClass("jc-horizontal");
44			}
45			else{
46				hndl.div.addClass("jc-vertical");
47			}
48			
49			if(options.auto){
50				hndl.div.addClass("jc-auto");
51			}
52			
53			if(options.circle){
54				hndl.div.addClass("jc-circle");
55			}
56			
57			//init slides
58			hndl.slides = hndl.slides_div.children("div").css("width", options.width).css("height", options.height).hide();
59			hndl.count = hndl.slides.length;
60			
61			//init arrows
62			hndl.left_arr = hndl.div.children("a").eq(0);
63			hndl.right_arr = hndl.div.children("a").eq(1);			
64			
65			//create panel
66			hndl.slides_div.append("<div class='panel'></div>");
67			hndl.panel = hndl.slides_div.children("div.panel").css("position", "absolute");
68			
69			//orientation
70			switch(options.orientation){
71				case 'horizontal':{	
72					hndl.slides.css("float", "left");
73					hndl.panel.css("width", 3*options.width).css("height", options.height);
74					break;
75				}
76				case 'vertical':{
77					hndl.panel.css("height", 3*options.height).css("width", options.width);
78					break;
79				}
80			}			
81			
82			hndl.getNextIndex = function(){
83				if(hndl.currentSlide >= hndl.count - 1){
84					return 0;
85				}
86				else{
87					return hndl.currentSlide + 1;
88				}
89			};
90			
91			hndl.getPrevIndex = function(){
92				if(hndl.currentSlide <= 0){
93					return hndl.count - 1;
94				}
95				else{
96					return hndl.currentSlide - 1;
97				}			
98			};
99			
100			//standard jquery clone function fails with IE + flash
101			hndl.clone_slide = function(index){
102				var slide = hndl.slides.eq(index).show();
103				var html = "<div style='" + slide.attr("style") + "'>" + slide.html() + "</div>";
104				slide.hide();
105				return html;
106			};
107			
108			hndl.initItemsPosition = function(direction){
109			
110				if(hndl.panel.children().length == 0){	
111					hndl.panel.append(hndl.clone_slide(hndl.getPrevIndex()));
112					hndl.panel.append(hndl.clone_slide(hndl.currentSlide));
113					hndl.panel.append(hndl.clone_slide(hndl.getNextIndex()));
114				}
115				else{
116					if(direction == 'prev'){
117						
118						//add prev as first item
119						hndl.panel.prepend(hndl.clone_slide(hndl.getPrevIndex()));
120						
121						//remove the last one
122						hndl.panel.children().eq(3).remove();
123						
124						if(options.videos){
125							//replace the last (third) item
126							hndl.panel.children().eq(2).replaceWith(hndl.slides.eq(hndl.getNextIndex()).show());
127						}
128					}
129					else{
130						//add next to the last
131						hndl.panel.append(hndl.clone_slide(hndl.getNextIndex()));
132						
133						//remove the first
134						hndl.panel.children().eq(0).remove();
135						
136						if(options.videos){
137							//replace the last (third) item
138							hndl.panel.children().eq(0).replaceWith(hndl.slides.eq(hndl.getPrevIndex()).show());
139						}
140					}
141					
142					
143				}
144				
145				
146			
147				switch(options.orientation){
148					case 'horizontal':{	
149						hndl.panel = hndl.slides_div.children("div.panel").css("left", -1*options.width);
150						break;
151					}
152					case 'vertical':{
153						hndl.panel = hndl.slides_div.children("div.panel").css("top", -1*options.height);
154						break;
155					}
156				}
157				
158			};
159
160			hndl.isLastItem = function(){
161				return hndl.currentSlide >= hndl.count - 1;
162			};
163			
164			hndl.isFirstItem = function(){
165				return hndl.currentSlide <= 0;
166			};
167			
168			hndl.updateArrows = function(){
169				if(hndl.count > 1){
170					if(!options.auto && !options.circle){
171						if(hndl.isLastItem()){
172							hndl.left_arr.removeClass("hide").removeClass("show").addClass("show");
173							hndl.right_arr.removeClass("hide").removeClass("show").addClass("hide");
174						}
175						else{
176							if(hndl.isFirstItem()){
177								hndl.left_arr.removeClass("hide").removeClass("show").addClass("hide");
178								hndl.right_arr.removeClass("hide").removeClass("show").addClass("show");
179							}
180							else{
181								hndl.left_arr.removeClass("hide").removeClass("show").addClass("show");
182								hndl.right_arr.removeClass("hide").removeClass("show").addClass("show");					
183							}
184						}
185					}
186				}
187				else{
188					hndl.left_arr.addClass("hide");
189					hndl.right_arr.addClass("hide");
190				}
191			};
192			
193			hndl.getAnimateArgs = function(direction){
194				var args;
195				
196				switch(options.orientation){
197					case 'horizontal':{	
198						if(direction == 'prev'){
199							args = {left: 0};
200						}
201						else{//next
202							args = {left:-2*options.width};
203						}						
204						break;
205					}
206					case 'vertical':{
207						if(direction == 'prev'){
208							args = {top: 0};
209						}
210						else{//next
211							args = {top:-2*options.height};
212						}	
213						break;
214					}
215				}
216				
217				return args;				
218			};
219			
220			
221			hndl.performAimate = function(direction){
222				
223				hndl.panel.animate(hndl.getAnimateArgs(direction), options.speed, options.easing, function(){	
224					
225					if(direction == 'prev'){
226						hndl.currentSlide = hndl.getPrevIndex();
227					}
228					else{
229						hndl.currentSlide = hndl.getNextIndex();
230					}
231					
232					hndl.initItemsPosition(direction);	
233					hndl.updateArrows();
234					
235					if(options.auto == true){	
236
237						hndl.go(direction);
238					}
239				});	
240
241			};
242			
243			hndl.animation = function(direction){
244			
245				hndl.lastDirection = direction;	
246				
247				if(options.auto && !options.click){//auto
248				
249					varTimeout = setTimeout(function(){//delay
250						
251						//pause on hover
252						if(options.pause_on_hover && hndl.isMouseHover){
253						
254							hndl.intervalId = setInterval(function(){
255									if(!hndl.isMouseHover){
256										clearInterval(hndl.intervalId);	
257										hndl.performAimate(direction);
258									}
259								}, 250);
260						}
261						else{
262							hndl.performAimate(direction);
263						}				
264					
265					}, options.pause);
266				}
267				else{//click
268          clearTimeout( varTimeout );
269          if(options.click) options.click = false;
270					hndl.performAimate(direction);
271				}
272				
273			};
274			
275			hndl.go = function(direction){									
276				if(direction == 'prev'){
277					if(!hndl.isFirstItem() || options.auto || options.circle){
278						hndl.animation('prev');
279					}
280				}
281				else{//next
282					if(!hndl.isLastItem() || options.auto || options.circle){
283						hndl.animation('next');
284					}				
285				}
286								
287			};
288			
289			hndl.left_arr.click(function(){	
290        if(options.auto) options.click = true;
291				hndl.go('prev');
292				return false;
293			});
294			
295			hndl.right_arr.click(function()
296			{
297        if(options.auto) options.click = true;
298				hndl.go('next');
299				return false;
300			});
301			
302			hndl.div.mouseenter(function(){
303				if(options.pause_on_hover){					
304					hndl.isMouseHover = true;
305				}
306			});
307			
308			hndl.div.mouseleave(function(e){
309				if(options.pause_on_hover){						
310					hndl.isMouseHover = false;						
311				}	
312			});
313			
314			//start
315			hndl.updateArrows();
316			hndl.initItemsPosition('');
317			
318			//autostart
319			if(options.auto){				
320				hndl.go(options.direction);
321			}			
322		};
323		
324		return this.each(function() {			
325			var hndl = this;
326			
327			//ajax
328			if(options.xml != '')
329			{
330				$.ajax({url: options.xml,
331						type: "GET",
332						cache: false, 
333						success: function(XmlDoc){
334							var slides = $("slide", XmlDoc);
335							
336							//build data
337							$(hndl).html("<a title='' href='#' class='prev'></a><div class='slides'></div><a title='' href='#' class='next'></a>");
338							slides.each(function(){	
339								$(hndl).find("div.slides").append($(this).text());
340							});
341							
342							//init
343							jhndl.init(hndl);
344						},			
345						dataType: "xml"});				
346			}else{
347				jhndl.init(hndl);
348			}
349
350		});	
351	};
352})(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.