PageSourceSearch

http://www.mariomandzukic.com/modules/mod_news_pro_gk5/interface/scripts/engine.mootools.js

js mariomandzukic.com collected 2026-10-02 10:10:01 UTC 9,964 bytes, 329 lines download raw bytes

1/**
2* Main script file
3* @package News Show Pro GK5
4* @Copyright (C) 2009-2012 Gavick.com
5* @ All rights reserved
6* @ Joomla! is Free Software
7* @ Released under GNU/GPL License : http://www.gnu.org/copyleft/gpl.html
8* @version $Revision: GK5 1.0 $
9**/
10
11var NSP5 = new Class({
12	// class fields
13	animation: true,
14	anim_arts: false,
15	anim_lists: false,
16	arts: null,
17	arts_block_width: 0,
18	arts_current: 0,
19	arts_pages: null,
20	arts_per_page: null,
21	arts_scroller: null,
22	config: null,
23	hover_anim: null,
24	links: null,
25	links_block_width: 0,
26	links_pages: null,
27	links_pages_amount: null,
28	links_scroller: null,
29	links_current: 0,
30	modInterface: null,
31	module: null,
32	// touch events properties
33	swipe_max_time: 500, // in ms
34	swipe_min_move: 30, // in px
35	//
36	initialize: function(module) {
37		// init class fields
38		this.init_fields(module);
39		// init the interface
40		this.init_interface();
41	},
42	init_fields: function(module) {
43		// the most important class field ;)
44		this.module = module;
45		this.module.addClass('activated');
46		// rest of the fields
47		this.config = JSON.decode(this.module.get('data-config'));
48		this.config['animation_function'] = eval(this.config['animation_function']);
49		this.arts = this.module.getElements('.nspArt');
50		this.arts_pages = this.module.getElements('.nspArtPage');
51		this.arts_per_page = this.config['news_column'] * this.config['news_rows'];
52		this.hover_anim = this.module.hasClass('hover');
53		this.links = (this.module.getElement('.nspLinkScroll1')) ? this.module.getElement('.nspLinkScroll1').getElements('li') : [];
54		this.links_pages = this.module.getElements('.nspList');
55		this.links_pages_amount = Math.ceil(Math.ceil(this.links.length / this.config['links_amount']) / this.config['links_columns_amount']);
56		this.modInterface = { 
57			top: this.module.getElement('.nspTopInterface'), 
58			bottom: this.module.getElement('.nspBotInterface')
59		};
60		this.pages_amount = Math.ceil(this.arts.length / this.arts_per_page);
61	},
62	init_interface: function() {
63		var $this = this;
64		// arts
65		if(this.arts.length > 0){
66			this.arts_block_width = 100;
67			
68			this.arts_scroller = new Fx.Tween($this.module.getElement('.nspArtScroll2'), {
69				duration: $this.config['animation_speed'], 
70				wait:false, 
71				property: 'margin-left', 
72				unit: '%',
73				transition: $this.config['animation_function']
74			});
75		}
76		// events
77		this.module.addEvents({
78			'mouseenter': function() {
79				if(!$this.module.hasClass('onhover')) $this.module.addClass('onhover');
80			},
81			'mouseleave': function() {
82				if($this.module.hasClass('onhover')) $this.module.removeClass('onhover');
83			}
84		});
85		// links
86		if(this.links.length > 0){
87			this.links_block_width = 100;
88			
89			this.links_scroller = new Fx.Tween($this.module.getElement('.nspLinkScroll2'), {
90				duration:$this.config['animation_speed'], 
91				wait:false, 
92				property: 'margin-left',
93				unit: '%',
94				transition: $this.config['animation_function']
95			});
96		}
97		// top interface
98		this.nsp_art_list(0, 'top');
99		this.nsp_art_list(0, 'bottom');
100		//
101		if(this.modInterface.top && this.modInterface.top.getElement('.nspPagination')){
102			this.modInterface.top.getElement('.nspPagination').getElements('li').each(function(item,i){
103				item.addEvent($this.hover_anim ? 'mouseenter' : 'click', function(){
104					$this.arts_anim(i);
105				});	
106			});
107		}
108		//
109		if(this.modInterface.top && this.modInterface.top.getElement('.nspPrev')){
110			this.modInterface.top.getElement('.nspPrev').addEvent("click", function(){
111				$this.arts_anim('prev');
112			});
113			
114			this.modInterface.top.getElement('.nspNext').addEvent("click", function(){
115				$this.arts_anim('next');
116			});
117		}
118		// bottom interface
119		if(this.modInterface.bottom && this.modInterface.bottom.getElement('.nspPagination')){
120			this.modInterface.bottom.getElement('.nspPagination').getElements('li').each(function(item,i){
121				item.addEvent($this.hover_anim ? 'mouseenter' : 'click', function(){	
122					$this.lists_anim(i);
123				});	
124			});
125		}
126		//
127		if(this.modInterface.bottom && this.modInterface.bottom.getElement('.nspPrev')){
128			this.modInterface.bottom.getElement('.nspPrev').addEvent("click", function(){
129				$this.lists_anim('prev');
130			});
131			
132			this.modInterface.bottom.getElement('.nspNext').addEvent("click", function(){
133				$this.lists_anim('next');
134			});
135		}
136		//
137		if(this.module.hasClass('autoanim')){
138			(function(){
139				$this.nsp_gk5_autoanim();
140			}).delay($this.config['animation_interval']);
141		}
142		// Touch events for the articles
143		var arts_wrap = this.module.getElement('.nspArts');
144		if(arts_wrap) {		
145			var arts_pos_start_x = 0;
146			var arts_pos_start_y = 0;
147			var arts_time_start = 0;
148			var arts_swipe = false;
149			
150			arts_wrap.addEvent('touchstart', function(e) {
151				arts_swipe = true;
152				
153				if(e.changedTouches.length > 0) {
154					arts_pos_start_x = e.changedTouches[0].pageX;
155					arts_pos_start_y = e.changedTouches[0].pageY;
156					arts_time_start = new Date().getTime();
157				}
158			});
159			
160			arts_wrap.addEvent('touchmove', function(e) {
161				if(e.changedTouches.length > 0 && arts_swipe) {
162					if(
163						Math.abs(e.changedTouches[0].pageX - arts_pos_start_x) > Math.abs(e.changedTouches[0].pageY - arts_pos_start_y)
164					) {
165						e.preventDefault();
166					} else {
167						arts_swipe = false;
168					}
169				}
170			});
171			
172			arts_wrap.addEvent('touchend', function(e) {
173				if(e.changedTouches.length > 0 && arts_swipe) {					
174					if(
175						Math.abs(e.changedTouches[0].pageX - arts_pos_start_x) >= $this.swipe_min_move && 
176						new Date().getTime() - arts_time_start <= $this.swipe_max_time
177					) {
178						if(e.changedTouches[0].pageX - arts_pos_start_x > 0) {
179							$this.arts_anim('prev');
180						} else {
181							$this.arts_anim('next');
182						}
183					}
184				}
185			});
186		}
187		// Touch events for the links
188		var links_wrap = this.module.getElement('.nspLinksWrap');
189		if(links_wrap) {
190			var links_pos_start_x = 0;
191			var links_pos_start_y = 0;
192			var links_time_start = 0;
193			var links_swipe = false;
194			
195			links_wrap.addEvent('touchstart', function(e) {
196				links_swipe = true;
197				
198				if(e.changedTouches.length > 0) {
199					links_pos_start_x = e.changedTouches[0].pageX;
200					links_pos_start_y = e.changedTouches[0].pageY;
201					links_time_start = new Date().getTime();
202				}
203			});
204			
205			links_wrap.addEvent('touchmove', function(e) {
206				if(e.changedTouches.length > 0 && links_swipe) {
207					if(
208						Math.abs(e.changedTouches[0].pageX - links_pos_start_x) > Math.abs(e.changedTouches[0].pageY - links_pos_start_y)
209					) {
210						e.preventDefault();
211					} else {
212						links_swipe = false;
213					}
214				}
215			});
216			
217			links_wrap.addEvent('touchend', function(e) {
218				if(e.changedTouches.length > 0 && links_swipe) {					
219					if(
220						Math.abs(e.changedTouches[0].pageX - links_pos_start_x) >= $this.swipe_min_move && 
221						new Date().getTime() - links_time_start <= $this.swipe_max_time
222					) {
223						if(e.changedTouches[0].pageX - links_pos_start_x > 0) {
224							$this.lists_anim('prev');
225						} else {
226							$this.lists_anim('next');
227						}
228					}
229				}
230			});
231		}
232	},
233	//
234	nsp_art_list: function(i, pos){
235		var num  = (i !== null) ? i : (pos == 'top') ? this.arts_current : this.links_current;
236		
237		if(this.modInterface[pos] && this.modInterface[pos].getElement('.nspPagination')){
238			var pagination = this.modInterface[pos].getElement('.nspPagination');
239			pagination.getElements('li').setProperty('class', '');
240			pagination.getElements('li')[num].setProperty('class', 'active');
241		}
242	},
243	//
244	arts_anim: function(dir) {
245		if(!this.anim_arts) {
246			var $this = this;
247			this.anim_arts = true;
248			this.arts_pages[this.arts_current].removeClass('active');
249			
250			if(dir == 'next') {
251				this.arts_current = (this.arts_current == this.pages_amount - 1) ? 0 : this.arts_current + 1;
252			} else if(dir == 'prev') {
253				this.arts_current = (this.arts_current == 0) ? this.pages_amount - 1 : this.arts_current - 1;
254			} else {
255				this.arts_current = dir;
256			}
257			
258			this.arts_scroller.start(-1 * this.arts_current * this.arts_block_width);
259			
260			(function() {
261				$this.arts_pages[$this.arts_current].addClass('active');
262			}).delay(this.config['animation_speed'] * 0.5);
263			
264			(function() {
265				$this.anim_arts = false;
266			}).delay(this.config['animation_speed']);
267			
268			this.nsp_art_list(this.arts_current, 'top');
269			this.animation = false;
270			(function(){
271				$this.animation = true;
272			}).delay(this.config['animation_interval'] * 0.8);
273		}
274	},
275	//
276	lists_anim: function(dir) {
277		if(!this.anim_lists) {
278			var $this = this;
279			this.anim_lists = true;
280			
281			for(var x = 0; x < this.config['links_columns_amount']; x++) {
282				var item = this.links_pages[this.links_current * this.config['links_columns_amount'] + x];
283				if(item) item.removeClass('active');
284			}
285			
286			if(dir == 'next') {
287				this.links_current = (this.links_current == this.links_pages_amount - 1) ? 0 : this.links_current + 1;
288			} else if(dir == 'prev') {
289				this.links_current = (this.links_current == 0) ? this.links_pages_amount - 1 : this.links_current - 1;
290			} else {
291				$this.links_current = dir;
292			}
293			
294			(function() {
295				$this.anim_lists = false;
296			}).delay(this.config['animation_speed']);
297			
298			(function() {
299				for(var x = 0; x < $this.config['links_columns_amount']; x++) {
300					var item = $this.links_pages[$this.links_current * $this.config['links_columns_amount'] + x]; 
301					if(item) item.addClass('active');
302				}
303			}).delay(this.config['animation_speed'] * 0.5);
304			
305			this.links_scroller.start(-1 * this.links_current * this.links_block_width);
306			this.nsp_art_list(null, 'bottom');
307		}
308	},
309	//
310	nsp_gk5_autoanim: function() {
311		var $this = this;
312		//
313		if(!this.module.hasClass('onhover')) {
314			this.arts_anim('next');
315		}
316		//
317		(function() {
318			$this.nsp_gk5_autoanim();
319		}).delay($this.config['animation_interval']);
320	}
321});
322//
323window.addEvent("load", function(){	
324	$$('.nspMain').each(function(module){	
325		if(!module.hasClass('activated')) {	
326			new NSP5(module);
327		}
328	});
329});

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.