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(e){ 104 e.preventDefault(); 105 $this.arts_anim(i); 106 }); 107 }); 108 } 109 // 110 if(this.modInterface.top && this.modInterface.top.getElement('.nspPrev')){ 111 this.modInterface.top.getElement('.nspPrev').addEvent("click", function(e){ 112 e.preventDefault(); 113 $this.arts_anim('prev'); 114 }); 115 116 this.modInterface.top.getElement('.nspNext').addEvent("click", function(e){ 117 e.preventDefault(); 118 $this.arts_anim('next'); 119 }); 120 } 121 // bottom interface 122 if(this.modInterface.bottom && this.modInterface.bottom.getElement('.nspPagination')){ 123 this.modInterface.bottom.getElement('.nspPagination').getElements('li').each(function(item,i){ 124 item.addEvent($this.hover_anim ? 'mouseenter' : 'click', function(e){ 125 e.preventDefault(); 126 $this.lists_anim(i); 127 }); 128 }); 129 } 130 // 131 if(this.modInterface.bottom && this.modInterface.bottom.getElement('.nspPrev')){ 132 this.modInterface.bottom.getElement('.nspPrev').addEvent("click", function(e){ 133 e.preventDefault(); 134 $this.lists_anim('prev'); 135 }); 136 137 this.modInterface.bottom.getElement('.nspNext').addEvent("click", function(e){ 138 e.preventDefault(); 139 $this.lists_anim('next'); 140 }); 141 } 142 // 143 if(this.module.hasClass('autoanim')){ 144 (function(){ 145 $this.nsp_gk5_autoanim(); 146 }).delay($this.config['animation_interval']); 147 } 148 // Touch events for the articles 149 var arts_wrap = this.module.getElement('.nspArts'); 150 if(arts_wrap) { 151 var arts_pos_start_x = 0; 152 var arts_pos_start_y = 0; 153 var arts_time_start = 0; 154 var arts_swipe = false;
155 156 arts_wrap.addEvent('touchstart', function(e) { 157 arts_swipe = true; 158 159 if(e.changedTouches.length > 0) { 160 arts_pos_start_x = e.changedTouches[0].pageX; 161 arts_pos_start_y = e.changedTouches[0].pageY; 162 arts_time_start = new Date().getTime(); 163 } 164 }); 165 166 arts_wrap.addEvent('touchmove', function(e) { 167 if(e.changedTouches.length > 0 && arts_swipe) { 168 if( 169 Math.abs(e.changedTouches[0].pageX - arts_pos_start_x) > Math.abs(e.changedTouches[0].pageY - arts_pos_start_y) 170 ) { 171 e.preventDefault(); 172 } else { 173 arts_swipe = false; 174 } 175 } 176 }); 177 178 arts_wrap.addEvent('touchend', function(e) { 179 if(e.changedTouches.length > 0 && arts_swipe) { 180 if( 181 Math.abs(e.changedTouches[0].pageX - arts_pos_start_x) >= $this.swipe_min_move && 182 new Date().getTime() - arts_time_start <= $this.swipe_max_time 183 ) { 184 if(e.changedTouches[0].pageX - arts_pos_start_x > 0) { 185 $this.arts_anim('prev'); 186 } else { 187 $this.arts_anim('next'); 188 } 189 } 190 } 191 }); 192 } 193 // Touch events for the links 194 var links_wrap = this.module.getElement('.nspLinksWrap'); 195 if(links_wrap) { 196 var links_pos_start_x = 0; 197 var links_pos_start_y = 0; 198 var links_time_start = 0; 199 var links_swipe = false; 200 201 links_wrap.addEvent('touchstart', function(e) { 202 links_swipe = true; 203 204 if(e.changedTouches.length > 0) { 205 links_pos_start_x = e.changedTouches[0].pageX; 206 links_pos_start_y = e.changedTouches[0].pageY; 207 links_time_start = new Date().getTime(); 208 } 209 }); 210 211 links_wrap.addEvent('touchmove', function(e) { 212 if(e.changedTouches.length > 0 && links_swipe) { 213 if( 214 Math.abs(e.changedTouches[0].pageX - links_pos_start_x) > Math.abs(e.changedTouches[0].pageY - links_pos_start_y) 215 ) { 216 e.preventDefault(); 217 } else { 218 links_swipe = false; 219 } 220 } 221 }); 222 223 links_wrap.addEvent('touchend', function(e) { 224 if(e.changedTouches.length > 0 && links_swipe) { 225 if( 226 Math.abs(e.changedTouches[0].pageX - links_pos_start_x) >= $this.swipe_min_move && 227 new Date().getTime() - links_time_start <= $this.swipe_max_time 228 ) { 229 if(e.changedTouches[0].pageX - links_pos_start_x > 0) { 230 $this.lists_anim('prev'); 231 } else { 232 $this.lists_anim('next'); 233 } 234 } 235 } 236 }); 237 } 238 }, 239 // 240 nsp_art_list: function(i, pos){ 241 var num = (i !== null) ? i : (pos == 'top') ? this.arts_current : this.links_current; 242 243 if(this.modInterface[pos] && this.modInterface[pos].getElement('.nspPagination')){ 244 var pagination = this.modInterface[pos].getElement('.nspPagination'); 245 pagination.getElements('li').setProperty('class', ''); 246 pagination.getElements('li')[num].setProperty('class', 'active'); 247 } 248 }, 249 // 250 arts_anim: function(dir) { 251 if(!this.anim_arts) { 252 var $this = this; 253 this.anim_arts = true; 254 this.arts_pages[this.arts_current].removeClass('active'); 255 256 if(dir == 'next') { 257 this.arts_current = (this.arts_current == this.pages_amount - 1) ? 0 : this.arts_current + 1; 258 } else if(dir == 'prev') { 259 this.arts_current = (this.arts_current == 0) ? this.pages_amount - 1 : this.arts_current - 1; 260 } else { 261 this.arts_current = dir; 262 } 263 264 this.arts_scroller.start(-1 * this.arts_current * this.arts_block_width); 265 266 (function() { 267 $this.arts_pages[$this.arts_current].addClass('active'); 268 }).delay(this.config['animation_speed'] * 0.5); 269 270 (function() { 271 $this.anim_arts = false; 272 }).delay(this.config['animation_speed']); 273 274 this.nsp_art_list(this.arts_current, 'top'); 275 this.animation = false; 276 (function(){ 277 $this.animation = true; 278 }).delay(this.config['animation_interval'] * 0.8); 279 } 280 }, 281 // 282 lists_anim: function(dir) { 283 if(!this.anim_lists) { 284 var $this = this; 285 this.anim_lists = true; 286 287 for(var x = 0; x < this.config['links_columns_amount']; x++) { 288 var item = this.links_pages[this.links_current * this.config['links_columns_amount'] + x]; 289 if(item) item.removeClass('active'); 290 } 291 292 if(dir == 'next') { 293 this.links_current = (this.links_current == this.links_pages_amount - 1) ? 0 : this.links_current + 1; 294 } else if(dir == 'prev') { 295 this.links_current = (this.links_current == 0) ? this.links_pages_amount - 1 : this.links_current - 1; 296 } else { 297 $this.links_current = dir; 298 } 299 300 (function() { 301 $this.anim_lists = false;
302 }).delay(this.config['animation_speed']); 303 304 (function() { 305 for(var x = 0; x < $this.config['links_columns_amount']; x++) { 306 var item = $this.links_pages[$this.links_current * $this.config['links_columns_amount'] + x]; 307 if(item) item.addClass('active'); 308 } 309 }).delay(this.config['animation_speed'] * 0.5); 310 311 this.links_scroller.start(-1 * this.links_current * this.links_block_width); 312 this.nsp_art_list(null, 'bottom'); 313 } 314 }, 315 // 316 nsp_gk5_autoanim: function() { 317 var $this = this; 318 // 319 if(!this.module.hasClass('onhover')) { 320 this.arts_anim('next'); 321 } 322 // 323 (function() { 324 $this.nsp_gk5_autoanim(); 325 }).delay($this.config['animation_interval']); 326 } 327}); 328// 329window.addEvent("load", function(){ 330 $$('.nspMain').each(function(module){ 331 if(!module.hasClass('activated')) { 332 new NSP5(module); 333 } 334 }); 335});
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.