PageSourceSearch

https://hrvatska-dubica.hr/components/com_roksprocket/layouts/features/assets/js/features.js

js hrvatska-dubica.hr collected 2026-10-02 20:40:26 UTC 12,217 bytes, 386 lines download raw bytes

1/*!
2 * @version   $Id: features.js 30547 2017-03-08 21:14:11Z reggie $
3 * @author    RocketTheme http://www.rockettheme.com
4 * @copyright Copyright (C) 2007 - 2017 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, {Features: null});
10
11	Element.implement({
12		'styles': function(){
13			var mu = moofx(this), result = mu.style.apply(mu, arguments);
14			if (arguments.length == 1 && typeof arguments[0] == 'string') return result;
15			return this;
16		},
17		'moofx': function(){
18			var mu = moofx(this);
19			mu.animate.apply(mu, arguments);
20			return this;
21		}
22	});
23
24	var Features = new Class({
25
26		Implements: [Options, Events],
27
28		animations: {},
29
30		options: {
31			data: 'features',
32			settings: {}
33		},
34
35		initialize: function(options){
36			this.setOptions(options);
37			this.data = this.options.data;
38
39			this.features = document.getElements('[data-' + this.data + ']');
40			this.settings = {};
41			this.timers = {};
42			this.statuses = {};
43		},
44
45		attach: function(feature, settings){
46			feature = typeOf(feature) == 'number' ?
47						document.getElements('[data-' + this.data + '=' + this.getID(feature) + ']')
48						:
49						feature;
50			settings = typeOf(settings) == 'string' ? JSON.decode(settings) : settings;
51
52			var containers = (feature ? new Elements([feature]).flatten() : this.features);
53
54			containers.each(function(container){
55				container.store('roksprocket:' + this.data + ':attached', true);
56
57				this.setSettings(container, settings, 'restore');
58
59				var relay = {
60					mouseenter: container.retrieve('roksprocket:' + this.data + ':mouseenter', function(event){
61						this.stopTimer.call(this, container);
62						this.pause.call(this, container);
63					}.bind(this)),
64
65					mouseleave: container.retrieve('roksprocket:' + this.data + ':mouseleave', function(event){
66						this.resume.call(this, container);
67						this.startTimer.call(this, container);
68					}.bind(this)),
69
70					pagination: container.retrieve('roksprocket:' + this.data + ':relay', function(event, pane){
71						this.toPane.call(this, event, container, pane);
72					}.bind(this)),
73
74					next: container.retrieve('roksprocket:' + this.data + ':next', function(event, element){
75						this.direction.call(this, event, container, element, 'next');
76					}.bind(this)),
77
78					previous: container.retrieve('roksprocket:' + this.data + ':previous', function(event, element){
79						this.direction.call(this, event, container, element, 'previous');
80					}.bind(this)),
81
82					swipe: container.retrieve('roksprocket:' + this.data + ':swipe', function(event, element){
83						event.preventDefault();
84						this.direction.call(this, event, container, element, (event.direction == 'right' ? 'previous' : 'next'));
85					}.bind(this))
86				};
87
88				['mouseenter', 'mouseleave'].each(function(type){
89					container.addEvent(type, relay[type]);
90				});
91
92				['pagination', 'next', 'previous'].each(function(dir, i){
93					var query = '[data-' + this.data + '-' + dir + ']';
94					if (i > 0) query += ', [data-' + dir + ']';
95
96					container.addEvent('click:relay(' + query + ')', relay[dir]);
97				}, this);
98
99				if (Browser.Features.Touch) container.addEvent('swipe', relay['swipe']);
100
101				if (this.getSettings(container).autoplay && this.getSettings(container).autoplay.toInt()) this.startTimer(container);
102
103				//this.toPosition(container, 0);
104			}, this);
105		},
106
107		detach: function(feature){
108			feature = typeOf(feature) == 'number' ?
109						document.getElements('[data-' + this.data + '=' + this.getID(feature) + ']')
110						:
111						feature;
112
113			var containers = (feature ? new Elements([feature]).flatten() : this.features);
114
115			containers.each(function(container){
116				container.store('roksprocket:' + this.data + ':attached', false);
117				var relay = {
118					mouseenter: container.retrieve('roksprocket:' + this.data + ':mouseenter'),
119					mouseleave: container.retrieve('roksprocket:' + this.data + ':mouseleave'),
120					pagination: container.retrieve('roksprocket:' + this.data + ':relay'),
121					next: container.retrieve('roksprocket:' + this.data + ':next'),
122					previous: container.retrieve('roksprocket:' + this.data + ':previous')
123				};
124
125				['mouseenter', 'mouseleave'].each(function(type){
126					container.removeEvent(type, relay[type]);
127				});
128
129				['pagination', 'next', 'previous'].each(function(dir, i){
130					var query = '[data-' + this.data + '-' + dir + ']';
131					if (i > 0) query += ', [data-' + dir + ']';
132
133					container.removeEvent('click:relay(' + query + ')', relay[dir]);
134				}, this);
135
136				if (Browser.Features.Touch) container.removeEvent('swipe', relay['swipe']);
137
138			}, this);
139		},
140
141		setSettings: function(container, settings, restore){
142			var id = this.getID(container),
143				options = Object.clone(this.options.settings);
144
145			if (!restore || !this.settings['id-' + id]){
146				this.settings['id-' + id] = Object.merge(options, settings || options);
147			}
148		},
149
150		getSettings: function(container){
151			var id = this.getID(container);
152
153			return this.settings['id-' + id];
154		},
155
156		getContainer: function(container){
157			if (!container) container = document.getElements('[data-' + this.data + ']');
158			if (typeOf(container) == 'number') container = document.getElement('[data-' + this.data + '='+container+']');
159			if (typeOf(container) == 'string') container = document.getElement(container);
160
161			return container;
162		},
163
164		getID: function(id){
165			if (typeOf(id) == 'number') id = document.getElement('[data-' + this.data + '='+id+']');
166			if (typeOf(id) == 'string') id = document.getElement(id);
167			return !id ? id : id.get('data-' + this.data);
168		},
169
170		getRandom: function(){
171			var random = Number.random(0, Object.getLength(this.animations) - 1),
172				keys = Object.keys(this.animations);
173
174			return this.animations[keys[random]];
175		},
176
177		toPosition: function(container, position){
178			container = this.getContainer(container);
179			if (!container.retrieve('roksprocket:' + this.data + ':attached')) return;
180
181			this.stopTimer(container);
182
183			var features = container.getElements('[data-' + this.data + '-pagination]'),
184				current = container.getElement('[data-' + this.data + '-pagination][class=active]');
185
186			if (!features.length) return;
187
188			if (features[position] && features[position].hasClass('active')) return;
189
190			if (position > features.length - 1) position = 0;
191			if (position < 0) position = features.length - 1;
192
193			if (features.length){
194				features.removeClass('active');
195				features[position].addClass('active');
196			}
197
198			this.animate(container, current.get('data-' + this.data + '-pagination') - 1, position);
199		},
200
201		toPane: function(event, container, pane){
202			if (event) event.preventDefault();
203			container = this.getContainer(container);
204			if (!container.retrieve('roksprocket:' + this.data + ':attached')) return;
205
206			var features = container.getElements('[data-' + this.data + '-pagination]'),
207				position = pane.get('data-' + this.data + '-pagination') - 1;
208
209			if (position == -1) throw new Error('RokSprocket Feature [' + this.data + ']: Instance ID "' + container.get('data-' + this.data) + '", index not found.');
210
211			this.toPosition(container, position);
212		},
213
214		direction: function(event, container, element, dir){
215			if (event) event.preventDefault();
216
217			dir = dir || 'next';
218			this[dir](container, element);
219		},
220
221		next: function(container, element){
222			container = this.getContainer(container);
223			if (!container.retrieve('roksprocket:' + this.data + ':attached')) return;
224			if (typeOf(container) == 'elements') return this.nextAll(container, element);
225
226			var pages = container.getElements('[data-' + this.data + '-pagination]');
227			if (!pages.length) return;
228
229			var active = pages.filter(function(page){ return page.hasClass('active'); }),
230				position = pages.indexOf(active.length ? active[0] : '') || 0,
231				next = position + 1;
232
233			if (next > pages.length - 1) next = 0;
234			this.toPosition(container, next);
235		},
236
237		nextAll: function(containers, element){
238			containers = this.getContainer(containers);
239			if (typeOf(containers) == 'element') return this.next(containers, element);
240
241			containers.each(function(container){
242				this.next(container, element);
243			}, this);
244		},
245
246		previous: function(container, element){
247			container = this.getContainer(container);
248			if (!container.retrieve('roksprocket:' + this.data + ':attached')) return;
249
250			if (typeOf(container) == 'elements') return this.previousAll(container, element);
251
252			var pages = container.getElements('[data-' + this.data + '-pagination]');
253			if (!pages.length) return;
254
255			var active = pages.filter(function(page){ return page.hasClass('active'); }),
256				position = pages.indexOf(active.length ? active[0] : '') || 0,
257				previous = position - 1;
258
259			if (previous < 0) previous = pages.length - 1;
260			this.toPosition(container, previous);
261		},
262
263		previousAll: function(containers, element){
264			containers = this.getContainer(containers);
265			if (typeOf(containers) == 'element') return this.previous(containers, element);
266
267			containers.each(function(container){
268				this.previous(container, element);
269			}, this);
270		},
271
272		startTimer: function(container){
273			container = this.getContainer(container);
274			if (!container.retrieve('roksprocket:' + this.data + ':attached')) return;
275
276			var settings = this.getSettings(container),
277				id = this.getID(container),
278				status = this.statuses['id-' + id],
279				autoplay = settings.autoplay.toInt(),
280				delay = (settings.delay.toInt()) * 1000;
281
282			clearTimeout(this.timers['id-' + id]);
283			if (autoplay && status != 'pause') this.timers['id-' + id] = this.next.delay(delay, this, container);
284		},
285
286		stopTimer: function(container){
287			container = this.getContainer(container);
288
289			var id = this.getID(container);
290			clearTimeout(this.timers['id-' + id]);
291		},
292
293		pause: function(container){
294			container = this.getContainer(container);
295
296			var id = this.getID(container);
297			this.statuses['id-' + id] = 'pause';
298		},
299
300		resume: function(container){
301			container = this.getContainer(container);
302
303			var id = this.getID(container);
304			this.statuses['id-' + id] = 'play';
305		},
306
307		animate: function(container, from, to){
308			var contents = container.getElements('[data-' + this.data + '-content]'),
309				images = container.getElements('[data-' + this.data + '-image]'),
310				settings = this.getSettings(container),
311				styles = {
312					content: {
313						show: {display: 'block', 'z-index': 2},
314						hide: {display: 'none', 'z-index': 1}
315					},
316					image: {
317						show: {display: 'block', position: 'relative', 'z-index': 2},
318						hide: {display: 'none', position: 'absolute', 'z-index': 1}
319					}
320				},
321				current = {
322					content: contents[from],
323					image: images[from]
324				},
325				next = {
326					content: contents[to],
327					image: images[to]
328				};
329
330			Object.each(current, function(value, key){
331				current[key].style(styles[key].hide);
332				next[key].style(styles[key].show);
333			}, this);
334
335			if (settings.autoplay && settings.autoplay.toInt()) this.startTimer(container);
336
337		},
338
339		addAnimations: function(animations){
340			Object.merge(this.animations, animations);
341		}
342
343	});
344
345	Features.prototype.addAnimations({
346		crossfade: {
347			from: {opacity: 0},
348			to: {opacity: 1}
349		},
350		fromTop: {
351			from: {opacity: 0, top: '-50%'},
352			to: {opacity: 1, top: '0%'}
353		},
354		fromTopLeft: {
355			from: {opacity: 0,top: '-50%',left: '-50%'},
356			to: {opacity: 1, top: '0%', left: '0%'}
357		},
358		fromTopRight: {
359			from: {opacity: 0, top: '-50%', right: '-50%'},
360			to: {opacity: 1, top: '0%', right: '0%'}
361		},
362		fromBottom: {
363			from: {opacity: 0, top: '50%'},
364			to: {opacity: 1, top: '0%'}
365		},
366		fromBottomLeft: {
367			from: {opacity: 0, top: '75%', left: '-75%'},
368			to: {opacity: 1, top: '0%', left: '0%'}
369		},
370		fromBottomRight: {
371			from: {opacity: 0, right: '-50%', top: '50%'},
372			to: {opacity: 1, right: '0%', top: '0%'}
373		},
374		fromLeft: {
375			from: {opacity: 0, transform: 'translate3d(-50%, 0, 0)'},
376			to: {opacity: 1, transform: 'translate3d(0, 0, 0)'}
377		},
378		fromRight: {
379			from: {opacity: 0, transform: 'translate3d(50%, 0, 0)'},
380			to: {opacity: 1, transform: 'translate3d(0, 0, 0)'}
381		}
382	});
383
384	this.RokSprocket.Features = Features;
385
386})());

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.