PageSourceSearch

https://www.tvcorner.com/wo/site/navigation/javascript/jquery.theatre-1.0.js

js tvcorner.com collected 2026-10-08 17:51:27 UTC 14,978 bytes, 411 lines download raw bytes

1
2
3
4/////////////////////////////// COPYRIGHT WEBOPERATOR ///////////////////////////////
5// Copyright © WebOperator ® 2003-2014 Tous droits réservés
6// Ce programme informatique est protégé par les droits d'auteur
7// TOUTE MODIFICATION, REPRODUCTION OU CONTREFACON EST INTERDITE
8//
9// Copyright © WebOperator ® 2003-2014 All rights reserved
10// This data-processing program is protected by author's right
11// ANY MODIFICATION, REPRODUCTION OR COUNTERFEIT PROHIBITED
12//
13// WebOperator 
14// 85, bd Auguste Blanqui
15// 75013 Paris
16// France
17// [email protected]
18// http://www.weboperator.net
19/////////////////////////////////////////////////////////////////////////////////////
20
21/**
22 * ELIXON THEATRE
23 * Project Homepage: http://www.webdevelopers.eu/jquery/theatre
24 *
25 * LICENSE
26 *   http://www.webdevelopers.eu/jquery/theatre/license
27 *   Commons Attribution-NonCommercial 3.0
28 *
29 *   Get a commercial license at
30 *   http://www.webdevelopers.eu/jquery/theatre/buy 
31 *
32 * DEMO
33 *    http://www.webdevelopers.eu/jquery/theatre/demo 
34 * 
35 * DOCUMENTATION
36 *    http://www.webdevelopers.eu/jquery/theatre/documentation
37 *    
38 * @project    Elixon CMS, http://www.webdevelopers.eu/
39 * @package    JQuery
40 * @subpackage Theatre
41 * @author     Daniel Sevcik <[email protected]>
42 * @version    1.0.6
43 * @copyright  2010 Daniel Sevcik
44 * @since      2010-11-11T22:10:07+0100
45 * @revision   $Revision: 4675 $
46 * @changed    $Date: 2011-02-09 12:10:32 +0100 (Wed, 09 Feb 2011) $
47 * @access     public
48 */
49(function($) {
50	var effects={};
51	var methods={};
52	var urlBase;
53
54	$.fn.theatre=function() {
55		var currArguments=arguments;
56		(this.length ? this : $(document)).each(function() {
57				methods.initAll.apply($(this), currArguments);
58			});
59		return this;
60	}
61
62	// name:string - 'FILE:EFFECT' or 'EFFECT', one file may register EFFECT or multiple effect prefixed by FILE string
63	methods.loadEffect=function(name) { 
64		if (!urlBase) { // Find the locations
65			$('script[src*="jquery.theatre-"], link[href*="theatre.css"]').first().each(function() {
66					urlBase=(this.href || this.src).replace(/\/[^\/]*(#.*)?$/, '');
67				});
68		}
69		var url=urlBase+'/effect.'+name.split(':')[0]+'.js';
70		$('head').append('<script type="text/javascript" src="'+url+'"></script>');
71		return effects[name];
72	}
73
74	methods.initAll=function(method) {
75		// Init theatre
76		if (typeof method == 'object' || !method || method == 'init') { 
77			return methods.init.apply(this, arguments);
78		}
79		
80		// Register Effect
81		if (method == 'effect') {
82			// Register new effect
83			if (typeof arguments[2] == 'function') {
84				return effects[arguments[1]]=arguments[2];
85			} else {
86				$.error("Elixon Theatre cannot register effect object unless it is a Function.");
87			}
88		}
89
90		var theatre=this.data('theatre');
91		if (!theatre) return false; // not initialized yet
92		
93		switch(method) {
94		case 'jump':
95		    var jumpTo;
96			switch(jumpTo) {
97			case 'first': jumpTo=0; break;
98			case 'last' : jumpTo=theatre.actors.length - 1; break;
99			default     :
100				jumpTo=(parseInt(arguments[1]) - 1) % theatre.actors.length;
101				jumpTo=(Math.abs(Math.floor(jumpTo / theatre.actors.length) * theatre.actors.length) + jumpTo) % theatre.actors.length; //normalize				
102			}
103			while(theatre.index != jumpTo) {
104			  if (theatre.effect.jump) {
105				  theatre.effect.jump(jumpTo);
106				  theatre.index=jumpTo;
107			  } else {
108				  this.theatre(theatre.index < jumpTo ? 'next' : 'prev');
109			  }
110			}
111		    break;
112		case 'next':
113		case 'prev':		
114			// Call next/prev custom effects
115			if (!arguments[1]) this.theatre('stop'); // stop animation if no second param == true
116		    theatre.index=(theatre.index + (method == 'next' ? 1 : -1)) % theatre.actors.length;
117			theatre.index=(Math.abs(Math.floor(theatre.index / theatre.actors.length) * theatre.actors.length) + theatre.index) % theatre.actors.length; //normalize
118		    if (typeof theatre.settings.onMove == 'function') theatre.settings.onMove.apply(this, [theatre.index, theatre.actors[theatre.index]]);
119		    methods.updatePaging.apply(this);
120		    theatre.effect[method].apply(theatre.effect, Array.prototype.slice.call(arguments, 1));
121			break;
122		case 'play':
123		case 'stop':		
124			methods[method].apply(this, arguments);
125		    break;
126		default: // Unsupported
127			$.error('Elixon Theatre method "'+method+'" does not exist on jQuery.theatre!');
128		}
129	}
130
131	methods.init=function(options) {
132		methods.destroy.apply(this); // Reset old if any
133		
134		// Default settings
135		var settings={
136			selector: '> *:not(".theatre-control")',
137			effect: 'horizontal', // 'horizontal'|'vertical'|'fade'|'show'|'slide'|'3d'|CUSTOM EFFECT NAME|OBJECT with constructor implementing the init,next,prev methods
138			speed: 1000, // Transition speed
139			still: 3000, // Time between transitions
140			autoplay: true,
141			controls: 'horizontal', // display control buttons 'horizontal' or 'vertical' or 'none'
142			itemWidth: false, // width of the item or 'max' or false. 
143			itemHeight: false, // height of the item or 'max' or false. 
144			width: false, // set the height of the container. By default honors the already set size using CSS
145			height: false, // set the height of the container. By default honors the already set size using CSS
146			onMove: false // function(index) {}, execution context is the Stage
147		}
148		if (options) {
149			$.extend(settings, options);
150		}
151
152		// Init effect object
153		var actors=$(settings.selector, this);
154		var theatre={paging: settings.paging && $(settings.paging), actors: actors, effect: false, settings: settings, interval: false, index: 0};
155		var effect=(typeof settings.effect == 'function' ? settings.effect : effects[settings.effect] || methods.loadEffect(settings.effect));
156		if (!effect) $.error('Elixon Theatre does not support effect "'+settings.effect+'"!');
157		theatre.effect=new effects[settings.effect](this, actors, settings, theatre);
158		
159		// Stage
160		this.addClass('theatre').data('theatre', theatre);
161		this.addClass('theatre-'+settings.effect.replace(/[^a-z0-9]+/ig, '-'));
162		if (settings.width) this.css('width', settings.width);
163		if (settings.height) this.css('height', settings.height);
164		
165		// Actors
166		actors.each(function(){var $this=$(this); if (!$this.data('theatre')) $this.data('theatre', {width: $this.width(), height: $this.height()});});		
167		if (settings.itemWidth || settings.itemHeight) {
168			var thisObj=this;
169			actors.each(function() {
170					var $this=$(this);
171					if (settings.itemWidth) {
172						$this.css('width', settings.itemWidth == 'max' ? (thisObj.width() - $this.outerWidth() + $this.width())+'px' : settings.itemWidth);
173					}
174					if (settings.itemHeight) {
175						$this.css('height', settings.itemHeight == 'max' ? (thisObj.height() - $this.outerHeight() + $this.height())+'px' : settings.itemHeight);
176					}
177				});
178		}
179		
180		actors.addClass('theatre-actor').stop(true, true);
181		theatre.effect.init();
182
183		if (settings.autoplay) {
184			methods.play.apply(this);
185		}
186
187		// Controls
188		methods.appendControls.apply(this);
189		methods.generatePaging.apply(this); 		
190	}
191
192	methods.generatePaging=function() {
193		var stage=this;
194		var theatre=this.data('theatre');
195		if (!theatre.paging) return;
196
197		theatre.paging.each(function() {
198				var $this=$(this);
199				var jumpers=[];
200				$('> *', $this).each(function() {jumpers.push($('<div></div>').append(this).html());});
201				var template=jumpers[jumpers.length - 1];
202				
203				// Re-generate
204				for(var i=0; i < theatre.actors.length; i++) {
205					var jumpHTML=jumpers.length < i + 1 ? template : jumpers[i];
206					(function (pos) {
207						$this.append(jumpHTML.replace('{#}', pos)+"\n");
208						$this.children().last().click(function() {stage.theatre('jump', pos);});
209					})(i+1);
210				}
211			});
212		methods.updatePaging.apply(this);
213	}
214
215	methods.updatePaging=function() {
216		var theatre=this.data('theatre');
217		if (!theatre.paging) return;		
218
219		theatre.paging.each(function() {
220				var $this=$(this);
221				$('> *', $this).removeClass('active').eq(theatre.index).addClass('active');
222			});		
223	}
224
225	methods.appendControls=function() {
226		settings=this.data('theatre').settings;
227		// Controls
228		if (settings.controls == 'horizontal' || settings.controls == 'vertical') {
229			var thisObj=this;
230			this.append('<a class="theatre-control theatre-control-'+settings.controls+'-next theatre-next"><span></span></a>');
231			this.append('<a class="theatre-control theatre-control-'+settings.controls+'-prev theatre-prev"><span></span></a>');
232			this.append('<a class="theatre-control theatre-control-'+settings.controls+'-play theatre-play"><span></span></a>');
233			this.append('<a class="theatre-control theatre-control-'+settings.controls+'-stop theatre-stop"><span></span></a>');
234			$('.theatre-next', this).click(function() {thisObj.theatre('next');});
235			$('.theatre-prev', this).click(function() {thisObj.theatre('prev');});
236			$('.theatre-play', this).click(function() {thisObj.theatre('play');});
237			$('.theatre-stop', this).click(function() {thisObj.theatre('stop');});
238			this.mouseenter(function() {$('.theatre-control', thisObj).fadeIn();});
239			this.mouseleave(function() {$('.theatre-control', thisObj).fadeOut();});
240			$('.theatre-control', this).fadeOut(0);
241		}
242
243		this.append('<a class="theatre-control theatre-sign" rel="copyright license" style="position: absolute !important; display: none !important;" href="http://www.webdevelopers.eu/jquery/theatre" title="jQuery carousel plugin"><span style="display: none !important;">Elixon Theatre jQuery Plugin</span></a>');		
244	}
245
246	methods.destroy=function() {
247		var theatre=this.data('theatre');
248		if (theatre) { 
249			clearInterval(theatre.interval);
250			this.theatre('jump', 0);
251			if (typeof theatre.effect.destroy == 'function') theatre.effect.destroy();
252			this.removeClass('theatre-'+theatre.settings.effect.replace(/[^a-z0-9]+/ig, '-'));
253			theatre.actors.each(function(){ // Restore original sizes
254					var $this=$(this);
255					var theatre=$this.data('theatre');
256					$this.width(theatre.width);
257					$this.height(theatre.height);
258				})
259		}
260		$('.theatre-control', this).remove();
261	}
262
263	methods.play=function() {
264		var theatre=this.data('theatre');
265		var stage=this;
266		//methods.stop.apply(this);
267		//stage.theatre('next');
268		theatre.interval=setInterval(function() {stage.theatre('next', true);}, theatre.settings.speed + theatre.settings.still);
269	}
270
271	methods.stop=function() {
272		var theatre=this.data('theatre');
273		clearInterval(theatre.interval);
274		theatre.interval=false;
275	}
276
277	effects['fade']=
278	effects['slide']=
279	effects['show']=function(stage, actors, settings, theatre) {
280		var x={
281			fade: {show: 'fadeIn', hide: 'fadeOut', initStyle: {margin: 0, top: 0, left: 0, position: 'absolute', display: 'none'}},
282			slide: {show: 'slideDown', hide: 'slideUp', initStyle: {}},
283			show: {show: 'show', hide:'hide', initStyle: {}}
284		}[settings.effect];
285		
286		this.init=function() {
287			actors[x.hide](0).css(x.initStyle).first()[x.show](0); // actors.fadeOut(0) - does not hide it if stage has height=0 - assigning 'display:none'
288		}
289		this.next=function() {
290			actors.stop(true, true).css('z-index', 0)[x.hide](settings.speed)
291				.eq(theatre.index).css('z-index', 10)[x.show](settings.speed);			
292		}
293		this.prev=function() {
294			actors.stop(true, true).css('z-index', 0)[x.hide](settings.speed)
295				.eq(theatre.index).css('z-index', 10)[x.show](settings.speed);						
296		}
297		this.destroy=function() {
298			actors.stop(true, true).css({zIndex: '', top: '', left: '', position: '', margin: ''})[x.show](0);			
299		}
300	}
301
302	effects['vertical']=	
303	effects['horizontal']=function(stage, actors, settings) {
304		var x={
305			horizontal: {'size': 'outerWidth', 'direction': 'left'},
306			vertical: {'size': 'outerHeight', 'direction': 'top'}
307		}[settings.effect];
308
309		this.init=function() {
310			actors.fadeOut(0);
311			this.align(0, 0);
312			actors.fadeIn();			
313		}
314		this.next=function() {
315			// $(settings.selector, stage).last().stop(true, true); // to prevent visual contra-direction transition
316			var curr=$(settings.selector, stage).first();
317			var offset=this.align(-curr[x.size]());
318			curr.appendTo(stage);
319		}
320		this.prev=function() {
321			var curr=$(settings.selector, stage).last().prependTo(stage);
322			curr.stop(true, true).css(x.direction, -curr[x.size]());
323			this.align(0);
324		}
325		this.destroy=function() {
326			actors.stop(true, true).css(x.direction, '').css({opacity: '', left: '', top: ''});
327		}
328		this.align=function(offset, speed) {
329			var sacked=false;
330			$(settings.selector, stage).each(function() {
331					var callBack=null;
332					var $this=$(this);
333					if (offset < 0) {
334						callBack=function() {$this.css(x.direction, offset);}
335					}
336					var props={};
337					props[x.direction]=offset;
338					$this.stop(true, true).animate(props, isNaN(speed) ? settings.speed : speed, callBack);
339					offset+=$this[x.size]();
340				});
341			return offset;
342		}
343	}
344
345	effects['3d']=function(stage, actors, settings) {
346		// Override custom/default settings
347		settings.resize=false;
348		
349		var currIndex=0;
350		var pivots=[];
351		var maxWidth;
352		var maxHeight;
353
354		this.init=function() {
355			var thisObj=this;
356			maxWidth=stage.width() * 0.5;
357			maxHeight=stage.height() * 0.8;
358			actors.each(function(pos) {
359					var rad=(2 * Math.PI * pos / actors.length) + Math.PI / 2;
360					var x=Math.cos(rad);
361					var y=Math.sin(rad);
362
363					var margin=10;
364					var sizeMin=0.2;
365					var size=(y + 1) / 2 * (1 - sizeMin) + sizeMin;
366					var x2=x * (stage.width() - margin) / 2 + stage.width() / 2;
367					var y2=y * (stage.height() - margin) / 2 + stage.height() / 2;
368					
369					pivots.push({left: x2, top: y2, x: x, y: y, size: size, rad: rad});
370				});
371			this.animate();
372			//console.log(pivots);
373		}
374		this.next=function() {
375			if (++currIndex > actors.length - 1) currIndex=0;
376			this.animate();
377		}
378		this.prev=function() {
379			if (--currIndex < 0) currIndex=actors.length - 1;
380			this.animate();			
381		}
382		this.destroy=function() {
383			actors.stop(true, true).css({'z-index': '', opacity: '', left: '', top: ''});
384		}
385		this.animate=function() {
386			var thisObj=this;
387			actors.stop();
388			actors.each(function(pos) {
389					var pivot=pivots[(pos - currIndex + actors.length) % actors.length];
390					var dim=thisObj.calcDim($(this), maxWidth, maxHeight, pivot.size);
391					var left=Math.round(pivot.left - pivot.x * dim[0] / 2 - dim[0] / 2);
392					var top=Math.round(pivot.top - pivot.y * dim[1] / 2 - dim[1] / 2);
393					// use transitions where applicable for skew() or scale() http://www.alistapart.com/articles/understanding-css3-transitions/
394					// https://github.com/brandonaaron/jquery-cssHooks/blob/master/boxreflect.js for JQuery 1.4.3
395					$(this).css({'z-index': Math.round(pivot.size * 1000)}).animate({opacity: pivot.size, left: left, top: top, width: dim[0], height: dim[1]}, settings.speed);
396				});
397		}
398		this.calcDim=function(obj, maxWidth, maxHeight, size) {
399			var dim=obj.data('theatre');
400			var w=maxWidth;
401			var h=dim.height / dim.width * w;
402			if (h > maxHeight) {
403				w=maxWidth * (maxHeight / h);
404				h=maxHeight;
405			}
406			return [Math.round(w * size), Math.round(h * size)];
407		}
408	}
409	
410	
411})(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.