PageSourceSearch

https://halkidikivoice.gr/modules/mod_news_pro_gk5/interface/scripts/engine.jquery.js

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

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.