PageSourceSearch

https://www.fcufa.pro/components/com_roksprocket/layouts/strips/assets/js/strips.js

js fcufa.pro collected 2026-10-02 16:45:48 UTC 19,727 bytes, 632 lines download raw bytes

1/*!
2 * @version   $Id: strips.js 10889 2013-05-30 07:48:35Z btowles $
3 * @author    RocketTheme http://www.rockettheme.com
4 * @copyright Copyright (C) 2007 - 2018 RocketTheme, LLC
5 * @license   http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
6 */
7((function(){
8	if (typeof this.RokSprocket == 'undefined') this.RokSprocket = {};
9	else Object.merge(this.RokSprocket, {Strips: null});
10
11	var Strips = new Class({
12
13		Implements: [Options, Events],
14
15		options: {
16			settings: {}
17		},
18
19		initialize: function(options){
20			this.setOptions(options);
21
22			this.strips = document.getElements('[data-strips]');
23			this.settings = {};
24			this.timers = {};
25			this.statuses = {};
26			this.curve = Browser.opera ? {equation: 'ease-in-out'} : {curve: 'cubic-bezier(0.37,0.61,0.59,0.87)'};
27
28		},
29
30		attach: function(list, settings){
31			list = typeOf(list) == 'number' ?
32					document.getElements('[data-strips=' + this.getID(list) + ']')
33					:
34					list;
35			settings = typeOf(settings) == 'string' ? JSON.decode(settings) : settings;
36
37			var containers = (list ? new Elements([list]).flatten() : this.strips);
38
39			containers.each(function(container){
40				container.store('roksprocket:strips:attached', true);
41
42				this.setSettings(container, settings, 'restore');
43
44				var relay = {
45					mouseenter: container.retrieve('roksprocket:strips:mouseenter', function(event){
46						this.stopTimer.call(this, container);
47						this.pause.call(this, container);
48					}.bind(this)),
49
50					mouseleave: container.retrieve('roksprocket:strips:mouseleave', function(event){
51						this.resume.call(this, container);
52						this.startTimer.call(this, container);
53					}.bind(this)),
54
55					page: container.retrieve('roksprocket:strips:relay', function(event, page){
56						if (event) event.preventDefault();
57						this.toPage.call(this, container, page);
58					}.bind(this)),
59
60					next: container.retrieve('roksprocket:strips:next', function(event, element){
61						this.direction.call(this, event, container, element, 'next');
62					}.bind(this)),
63
64					previous: container.retrieve('roksprocket:strips:previous', function(event, element){
65						this.direction.call(this, event, container, element, 'previous');
66					}.bind(this)),
67
68					swipe: container.retrieve('roksprocket:strips:swipe', function(event, element){
69						event.preventDefault();
70						this.direction.call(this, event, container, element, (event.direction == 'right' ? 'previous' : 'next'));
71					}.bind(this))
72				};
73
74				['mouseenter', 'mouseleave'].each(function(type){
75					container.addEvent(type, relay[type]);
76				});
77
78				['page', 'next', 'previous'].each(function(dir, i){
79					var query = '[data-strips-' + dir + ']';
80					if (i > 0) query += ', [data-' + dir + ']';
81
82					container.addEvent('click:relay(' + query + ')', relay[dir]);
83				}, this);
84
85				container.retrieve('roksprocket:strips:ajax', new RokSprocket.Request({
86					model: 'strips',
87					model_action: 'getPage',
88					onRequest: this.onRequest.bind(this, container),
89					onSuccess: function(response){
90						this.onSuccess(response, container, container.retrieve('roksprocket:strips:ajax'));
91					}.bind(this)
92				}));
93
94				if (Browser.Features.Touch) container.addEvent('swipe', relay['swipe']);
95
96				var active = container.getElement('[data-strips-page].active');
97				if (!active) this.toPage(container, 0);
98				else {
99					if (this.getSettings(container).autoplay && this.getSettings(container).autoplay.toInt())
100						this.startTimer(container);
101				}
102
103			}, this);
104		},
105
106		detach: function(list){
107			list = typeOf(list) == 'number' ?
108					document.getElements('[data-strips=' + this.getID(list) + ']')
109					:
110					list;
111
112			var containers = (list ? new Elements([list]).flatten() : this.strips);
113
114			containers.each(function(container){
115				container.store('roksprocket:strips:attached', false);
116				var relay = {
117					mouseenter: container.retrieve('roksprocket:strips:mouseenter'),
118					mouseleave: container.retrieve('roksprocket:strips:mouseleave'),
119					page: container.retrieve('roksprocket:strips:relay'),
120					next: container.retrieve('roksprocket:strips:next'),
121					previous: container.retrieve('roksprocket:strips:previous')
122				};
123
124				['mouseenter', 'mouseleave'].each(function(type){
125					container.removeEvent(type, relay[type]);
126				});
127
128				['page', 'next', 'previous'].each(function(dir, i){
129					var query = '[data-strips-' + dir + ']';
130					if (i > 0) query += ', [data-' + dir + ']';
131
132					container.removeEvent('click:relay(' + query + ')', relay[dir]);
133				}, this);
134
135				if (Browser.Features.Touch) container.removeEvent('swipe', relay['swipe']);
136
137			}, this);
138		},
139
140		setSettings: function(container, settings, restore){
141			var id = this.getID(container),
142				options = Object.clone(this.options.settings);
143
144			if (!restore || !this.settings['id-' + id]){
145				this.settings['id-' + id] = Object.merge(options, settings || options);
146			}
147		},
148
149		getSettings: function(container){
150			var id = this.getID(container);
151
152			return this.settings['id-' + id];
153		},
154
155		getContainer: function(container){
156			if (!container) container = document.getElements('[data-strips]');
157			if (typeOf(container) == 'number') container = document.getElement('[data-strips='+container+']');
158			if (typeOf(container) == 'string') container = document.getElement(container);
159
160			return container;
161		},
162
163		getID: function(id){
164			if (typeOf(id) == 'number') id = document.getElement('[data-strips='+id+']');
165			if (typeOf(id) == 'string') id = document.getElement(id);
166			return !id ? id : id.get('data-strips');
167		},
168
169		toPage: function(container, page){
170			container = this.getContainer(container);
171			page = (typeOf(page) == 'element') ? page.get('data-strips-page') : page;
172			if (!container.retrieve('roksprocket:strips:attached')) return;
173
174			var strips = container.getElements('[data-strips-page]'),
175				ajax = container.retrieve('roksprocket:strips:ajax');
176
177			if (!strips.length) return;
178
179			if (page > strips.length) page = 1;
180			if (page < 1) page = strips.length;
181
182			if (strips[page - 1].hasClass('active')) return;
183
184			if (!ajax.isRunning()){
185				ajax.cancel().setParams({
186					moduleid: container.get('data-strips'),
187					page: page
188				}).send();
189			}
190		},
191
192		direction: function(event, container, element, dir){
193			if (event) event.preventDefault();
194
195			dir = dir || 'next';
196			this[dir](container, element);
197		},
198
199		next: function(container, element){
200			container = this.getContainer(container);
201			if (!container.retrieve('roksprocket:strips:attached')) return;
202			if (typeOf(container) == 'elements') return this.nextAll(container, element);
203
204			var strips = container.getElements('[data-strips-page]');
205			if (!strips.length) return;
206
207			var	current = container.getElement('[data-strips-page].active').get('data-strips-page'),
208				next = current.toInt() + 1;
209
210			if (next > strips.length) next = 1;
211			this.dir = 'right';
212			this.toPage(container, next);
213		},
214
215		nextAll: function(containers, element){
216			containers = this.getContainer(containers);
217			if (typeOf(containers) == 'element') return this.next(containers, element);
218
219			containers.each(function(container){
220				this.next(container, element);
221			}, this);
222		},
223
224		previous: function(container, element){
225			container = this.getContainer(container);
226			if (!container.retrieve('roksprocket:strips:attached')) return;
227			if (typeOf(container) == 'elements') return this.nextAll(container, element);
228
229			var strips = container.getElements('[data-strips-page]');
230			if (!strips.length) return;
231
232			var	current = container.getElement('[data-strips-page].active').get('data-strips-page'),
233				previous = current.toInt() - 1;
234
235			if (previous < 1) previous = strips.length;
236			this.dir = 'left';
237			this.toPage(container, previous);
238		},
239
240		previousAll: function(containers, element){
241			containers = this.getContainer(containers);
242			if (typeOf(containers) == 'element') return this.previous(containers, element);
243
244			containers.each(function(container){
245				this.previous(container, element);
246			}, this);
247		},
248
249		startTimer: function(container){
250			container = this.getContainer(container);
251			if (!container.retrieve('roksprocket:strips:attached')) return;
252
253			var settings = this.getSettings(container),
254				id = this.getID(container),
255				status = this.statuses['id-' + id],
256				autoplay = settings.autoplay.toInt(),
257				delay = (settings.delay.toInt()) * 1000;
258
259			clearTimeout(this.timers['id-' + id]);
260			if (autoplay && status != 'pause') this.timers['id-' + id] = this.next.delay(delay, this, container);
261		},
262
263		stopTimer: function(container){
264			container = this.getContainer(container);
265
266			var id = this.getID(container);
267			clearTimeout(this.timers['id-' + id]);
268		},
269
270		pause: function(container){
271			container = this.getContainer(container);
272
273			var id = this.getID(container);
274			this.statuses['id-' + id] = 'pause';
275		},
276
277		resume: function(container){
278			container = this.getContainer(container);
279
280			var id = this.getID(container);
281			this.statuses['id-' + id] = 'play';
282		},
283
284		onRequest: function(container){
285			container.addClass('loading');
286		},
287
288		onSuccess: function(response, container){
289			var items = container.getElement('[data-strips-items]'),
290				itemList = container.getElements('[data-strips-item]'),
291				html = response.getPath('payload.html'),
292				page = response.getPath('payload.page'),
293				settings = this.getSettings(container),
294				animation = settings.animation || 'fadeDelay';
295
296			container.removeClass('loading');
297
298			var dummy = new Element('div', {html: html}),
299				elements = dummy.getChildren(), rand, anims;
300
301			if (animation == 'random'){
302				animation = Object.keys(Object.merge({}, this.Animations)).getRandom();
303			}
304
305			if (!this.Animations[animation]) animation = 'fadeDelay';
306
307			settings.callback = function(){
308				if (settings.autoplay && settings.autoplay.toInt()) this.startTimer(container);
309			}.bind(this);
310
311			this.Animations[animation].call(this, items, itemList, elements, settings);
312
313			this._switchPage(container, page);
314		},
315
316		_switchPage: function(container, page){
317			var strips = container.getElements('[data-strips-page]');
318
319			strips.removeClass('active');
320			strips[page - 1].addClass('active');
321		}
322
323	});
324
325	var Animations = {
326		fade: function(){
327			var items = arguments[0],
328				itemList = arguments[1],
329				elements = arguments[2],
330				settings = arguments[3],
331				options = {
332					duration: this.AnimationsSpeed.fade.duration,
333					curve: this.curve,
334					callback: function(){
335						items.empty().adopt(elements);
336						options.callback = settings.callback || function(){};
337						moofx(items).animate({opacity: 1}, options);
338					}
339				};
340
341			moofx(items).animate({opacity: 0}, options);
342		},
343
344		fadeDelay: function(){
345			var items = arguments[0],
346				itemList = arguments[1],
347				elements = arguments[2],
348				settings = arguments[3],
349				options = {duration: this.AnimationsSpeed.fadeDelay.duration, curve: this.curve};
350
351			if (this.dir == 'left') itemList.reverse();
352
353			itemList.forEach(function(item, i){
354				(function(){
355					if (i == itemList.length - 1){
356						options.callback = function(){
357							moofx(elements).style({opacity: 0});
358							items.empty().adopt(elements);
359							options.callback = settings.callback || function(){};
360							if (this.dir == 'left') elements.reverse();
361
362							elements.forEach(function(element, j){
363								(function(){
364									moofx(elements[j]).animate({'opacity': 1}, options);
365								}).delay(j * this.AnimationsSpeed.fadeDelay.delay);
366							}, this);
367						}.bind(this);
368					}
369
370
371					moofx(item).animate({opacity: 0}, options);
372
373				}).delay(i * this.AnimationsSpeed.fadeDelay.delay, this);
374			}, this);
375		},
376
377		slide: function(){
378			var items = arguments[0],
379				itemList = arguments[1],
380				elements = arguments[2],
381				settings = arguments[3],
382				options = {
383					duration: this.AnimationsSpeed.slide.duration,
384					curve: this.curve,
385					callback: function(){
386						items.empty().adopt(elements);
387						options.callback = settings.callback || function(){};
388						distance = items.getSize().x + 25;
389
390						if (this.dir == 'left'){
391							moofx(elements).style({right: distance, position: 'relative', left: 'inherit'});
392							moofx(elements).animate({right: 0}, options);
393						} else {
394							moofx(elements).style({left: distance, position: 'relative', right: 'inherit'});
395							moofx(elements).animate({left: 0}, options);
396						}
397
398					}.bind(this)
399				},
400				distance = 0;
401
402			moofx(itemList).style({position: 'relative'});
403			distance = items.getSize().x + 25;
404
405			if (this.dir == 'left') moofx(itemList).animate({left: distance, right: 'inherit'}, options);
406			else moofx(itemList).animate({right: distance, left: 'inherit'}, options);
407
408		},
409
410		flyIn: function(){
411			var items = arguments[0],
412				itemList = arguments[1],
413				elements = arguments[2],
414				settings = arguments[3],
415				options = {duration: this.AnimationsSpeed.flyIn.duration, curve: this.curve},
416				distance = 0;
417
418			if (this.dir == 'left') itemList.reverse();
419
420			itemList.forEach(function(item, i){
421				(function(){
422					if (i == itemList.length - 1){
423						options.callback = function(){
424							items.empty().adopt(elements);
425							options.callback = null;
426							if (this.dir == 'left') elements.reverse();
427
428							elements.forEach(function(element, j){
429								distance = items.getSize().x + (elements[j].getSize().x / (j + 1)) + 25;
430								if (this.dir == 'left') moofx(elements).style({right: distance, position: 'relative', left: 'inherit'});
431								else moofx(elements).style({left: distance, position: 'relative', right: 'inherit'});
432
433
434								(function(){
435									if (j == elements.length - 1){
436										options.callback = settings.callback || function(){};
437									}
438
439									if (this.dir == 'left') moofx(elements[j]).animate({right: 0}, options);
440									else moofx(elements[j]).animate({left: 0}, options);
441								}).delay(j * this.AnimationsSpeed.flyIn.delay, this);
442							}, this);
443						}.bind(this)
444					}
445
446					moofx(item).style({position: 'relative'});
447					distance = items.getSize().x + (item.getSize().x / (i + 1)) + 25;
448
449					if (this.dir == 'left') moofx(item).animate({left: distance, right: 'inherit'}, options);
450					else moofx(item).animate({right: distance, left: 'inherit'}, options);
451
452				}).delay(i * this.AnimationsSpeed.flyIn.delay, this);
453			}, this);
454		},
455
456		fallDown: function(){
457			var items = arguments[0],
458				itemList = arguments[1],
459				elements = arguments[2],
460				settings = arguments[3],
461				options = {duration: this.AnimationsSpeed.fallDown.duration, curve: this.curve},
462				distance = 0;
463
464			if (this.dir == 'left') itemList.reverse();
465
466			itemList.forEach(function(item, i){
467				(function(){
468					if (i == itemList.length - 1){
469						options.callback = function(){
470							items.empty().adopt(elements);
471							options.callback = null;
472							if (this.dir == 'left') elements.reverse();
473
474							elements.forEach(function(element, j){
475								distance = items.getSize().y + (elements[j].getSize().y / (j + 1)) + 25;
476								moofx(elements).style({bottom: distance, position: 'relative', top: 'inherit'});
477
478								(function(){
479									if (j == elements.length - 1){
480										options.callback = function(){
481											elements.set('style', null);
482											settings.callback.call(this);
483										}
484									}
485
486									moofx(elements[j]).animate({bottom: 0}, options);
487								}).delay(j * this.AnimationsSpeed.fallDown.delay, this);
488							}, this);
489						}.bind(this)
490					}
491
492					moofx(item).style({position: 'relative'});
493					distance = items.getSize().y + (item.getSize().y / (i + 1)) + 25;
494
495					moofx(item).animate({top: distance, bottom: 'inherit'}, options);
496
497				}).delay(i * this.AnimationsSpeed.fallDown.delay, this);
498			}, this);
499		},
500
501		floatUp: function(){
502			var items = arguments[0],
503				itemList = arguments[1],
504				elements = arguments[2],
505				settings = arguments[3],
506				options = {duration: this.AnimationsSpeed.floatUp.duration, curve: this.curve},
507				distance = 0;
508
509			if (this.dir == 'left') itemList.reverse();
510
511			itemList.forEach(function(item, i){
512				(function(){
513					if (i == itemList.length - 1){
514						options.callback = function(){
515							items.empty().adopt(elements);
516							options.callback = null;
517							if (this.dir == 'left') elements.reverse();
518
519							elements.forEach(function(element, j){
520								distance = items.getSize().y + (elements[j].getSize().y / (j + 1)) + 25;
521								moofx(elements).style({top: distance, position: 'relative', bottom: 'inherit'});
522
523								(function(){
524									if (j == elements.length - 1){
525										options.callback = function(){
526											elements.set('style', null);
527											settings.callback.call(this);
528										}
529									}
530									moofx(elements[j]).animate({top: 0}, options);
531								}).delay(j * this.AnimationsSpeed.floatUp.delay, this);
532							}, this);
533						}.bind(this)
534					}
535
536					moofx(item).style({position: 'relative'});
537					distance = items.getSize().y + (item.getSize().y / (i + 1)) + 25;
538
539					moofx(item).animate({bottom: distance, top: 'inherit'}, options);
540
541				}).delay(i * this.AnimationsSpeed.floatUp.delay, this);
542			}, this);
543		},
544
545		scaleOut: function(){
546			var items = arguments[0],
547				itemList = arguments[1],
548				elements = arguments[2],
549				settings = arguments[3],
550				options = {duration: this.AnimationsSpeed.scaleOut.duration, curve: this.curve};
551
552			if (this.dir == 'left') itemList.reverse();
553
554			itemList.forEach(function(item, i){
555				(function(){
556					if (i == itemList.length - 1){
557						options.callback = function(){
558							items.empty().adopt(elements);
559							options.callback = null;
560							if (this.dir == 'left') elements.reverse();
561
562							elements.forEach(function(element, j){
563								moofx(elements).style({transform: 'scale(0)', opacity: 0});
564
565								if (j == elements.length - 1){
566									options.callback = settings.callback || function(){};
567								}
568
569								(function(){
570									moofx(elements[j]).animate({transform: 'scale(1)', opacity: 1}, options);
571								}).delay(j * this.AnimationsSpeed.scaleOut.delay, this);
572							}, this);
573						}.bind(this)
574					}
575
576					moofx(item).style({'transform-origin': 'center'});
577					moofx(item).animate({transform: 'scale(0)', opacity: 0}, options);
578
579				}).delay(i * this.AnimationsSpeed.scaleOut.delay, this);
580			}, this);
581		},
582
583		scaleIn: function(){
584			var items = arguments[0],
585				itemList = arguments[1],
586				elements = arguments[2],
587				settings = arguments[3],
588				options = {duration: this.AnimationsSpeed.scaleIn.duration, curve: this.curve};
589
590			if (this.dir == 'left') itemList.reverse();
591			items.store('overflow', items.getStyle('overflow'));
592			items.setStyle('overflow', 'visible');
593
594			itemList.forEach(function(item, i){
595				(function(){
596					if (i == itemList.length - 1){
597						options.callback = function(){
598							items.empty().adopt(elements);
599							options.callback = null;
600							if (this.dir == 'left') elements.reverse();
601
602							elements.forEach(function(element, j){
603								moofx(elements).style({transform: 'scale(1.5)', opacity: 0});
604
605								if (j == elements.length - 1){
606									options.callback = function(){
607										items.setStyle('overflow', null);
608										settings.callback.call(this);
609									}
610								}
611
612								(function(){
613									moofx(elements[j]).animate({transform: 'scale(1)', opacity: 1}, options);
614								}).delay(j * this.AnimationsSpeed.scaleIn.delay, this);
615							}, this);
616						}.bind(this)
617					}
618
619					moofx(item).style({'transform-origin': 'center'});
620					moofx(item).animate({transform: 'scale(1.5)', opacity: 0}, options);
621
622				}).delay(i * this.AnimationsSpeed.scaleIn.delay, this);
623			}, this);
624		}
625	};
626
627
628	Strips.prototype.Animations = Animations;
629
630	this.RokSprocket.Strips = Strips;
631
632})());

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.