1/** 2 * ------------------------------------------------------------------------ 3 * JA Newsticker Module for J25 & J31 4 * ------------------------------------------------------------------------ 5 * Copyright (C) 2004-2011 J.O.O.M Solutions Co., Ltd. All Rights Reserved. 6 * @license - GNU/GPL, http://www.gnu.org/licenses/gpl.html 7 * Author: J.O.O.M Solutions Co., Ltd 8 * Websites: http://www.joomlart.com - http://www.joomlancers.com 9 * ------------------------------------------------------------------------ 10 */ 11 12/** 13 * JA News Sticker module allows display of article's title from sections or categories. 14 * You can configure the setttings in the right pane. Mutiple options for animations are also added, choose any one. 15 * If you are using this module on Teline III template, * then the default module position is "headlines". 16 **/ 17 18JANewSticker = new Class( { 19 20 initialize: function(_options){ 21 this.options = Object.append( { 22 modes: {horizontal:['left','width'],horizontal_right:['left','width'], verticald:['top','height'], vertical:['top','height']}, 23 size:240, 24 mode: 'horizontal', 25 buttonEvent:'click', 26 handlerEvent:'click', 27 interval: 5000, 28 autoRun:true, 29 previousIndex:null, 30 nextIndex: null, 31 currentIndex:0, 32 startItem: 0, 33 onRunning:null 34 }, _options || {} ); 35 // list action of button using in the slider. 36 this.fx = new Array(); 37 this.fx2 = new Array(); 38 39 $$(this.options.items).each(function(item){ 40 if(item.getStyle('visibility') == 'hidden'){ 41 item.setStyles({ 42 visibility: 'visible', 43 opacity: 0 44 }); 45 } 46 }); 47 48 // if choose horizontal slider. 49 if( this.options.mode == 'horizontal_stripe' ){ 50 51 }else { 52 53 this.onRunning = this.options.onRunning; 54 if( isNaN(this.options.startItem) 55 || (this.options.startItem > this.options.items.length || this.options.startItem < 0 ) ){ 56 this.options.startItem = 0; 57 } 58 59 var maxWidth = 0; 60 this.options.items.each(function(_item, index){ 61 // set z-index for each item in the list. 62 _item.setStyle('z-index', this.options.items.length - index); 63 64 65 _item.setStyle('width', _item.offsetWidth); 66 if( _item.offsetWidth > maxWidth ){ 67 maxWidth = _item.offsetWidth; 68 } 69 this.fx2[index] = new Fx.Tween( _item, _options.fxOptions ); 70 this.fx2[index].offsetWidth= _item.offsetWidth; 71 72 if( this.options.mode != 'opacity' ) { 73 this.fx[index] = new Fx.Tween( _item, _options.fxOptions||{duration:500,wait:false} ); 74 } 75 }.bind(this)); 76 77 if( this.options.box.offsetWidth <= 0 ){ 78 79 this.options.box.setStyle('width', maxWidth); 80 // this.options.size = maxWidth; 81 } 82 if( this.options.mode == 'vertical' || this.options.mode == 'verticald' ){ 83 this.options.size = this.options.box.offsetHeight; 84 } else { 85 this.options.size = this.options.box.offsetWidth; 86 } 87 // define list buttons drivent. 88 this.buttons = {previous: [], next: [], play: [], playback: [], stop: []}; 89 this.options.autoRun = true; 90 // _options.buttons ={ next:} 91 if( _options.buttons ){ 92 for( var action in _options.buttons ) { 93 this.bindingButtonsEvent( action, typeOf(_options.buttons[action])=='array' ? _options.buttons[action] : [_options.buttons[action]] ); 94 } 95 } 96 // if auto run 97 if( this.options.autoRun ) { 98 this.play( this.options.interval,'next',true ); 99 } 100 // process when mouse over and mouse out. 101 var wrapper2 = this.options.wrapper; 102 wrapper2.addEvent("mouseenter", function(){ 103 this.stop(); 104 }.bind(this)); 105 wrapper2.addEvent("mouseleave", function(){ 106 107 this.play(this.options.interval,'next',true); 108 }.bind(this)); 109 } 110 }, 111 /** 112 * previous 113 */ 114 previous: function(manual) { 115 // 116 // this.fx2[this.options.currentIndex].start(1,0); 117 // this.fx[this.options.currentIndex].start( (this.options.size), 0 ); 118 119 this.options.currentIndex += this.options.currentIndex > 0 ? -1 : this.options.items.length-1; 120 this.running( null, manual, 'previous' ); 121 }, 122 /** 123 * next 124 */ 125 next:function(manual){ 126 // display secord element. 127 this.options.currentIndex += (this.options.currentIndex < this.options.items.length-1) ? 1 : (1 - this.options.items.length); 128 this.running( null, manual, 'next' ); 129 }, 130 /** 131 * play 132 */ 133 play: function( delay, direction, wait ){ 134 this.stop(); 135 if(!wait){ 136 this[direction](false); 137 } 138 this.options.autoRun = this[direction].periodical(delay,this,false); 139 }, 140 /** 141 * stop. 142 */ 143 stop:function(){ 144 clearTimeout(this.options.autoRun); 145 }, 146 147 /** 148 * running 149 */ 150 running: function( item, manual, runningMode ){ 151 this.options.previousIndex = this.options.currentIndex + (this.options.currentIndex>0 ? -1 : this.options.items.length-1); 152 153 this.options.nextIndex = this.options.currentIndex + (this.options.currentIndex < this.options.items.length-1 ? 1 : 1-this.options.items.length); 154 // 155 // if next item then hide previous element 156 // 157 // alert( this.fx2[this.options.currentIndex].offsetWidth ); 158 159 if( this.options.mode != 'opacity' ) { 160 var size1; 161 var size2; 162 163 if( this.options.mode == 'horizontal_right' || this.options.mode == 'verticald' ){ 164 size1 = -(this.options.size); 165 size2 = (this.options.size); 166 } else { 167 size1 = (this.options.size); 168 size2 = -(this.options.size); 169 } 170 171 172 173 if( runningMode == 'next' ) { 174 this.fx2[this.options.previousIndex].start('opacity', 1,0); 175 this.fx[this.options.previousIndex].start( this.options.modes[this.options.mode][0], 0, size1 ); 176 this.fx2[this.options.currentIndex].start('opacity', 0,1); 177 178 this.fx[this.options.currentIndex].start( this.options.modes[this.options.mode][0], +size2, 0 ); 179 180 181 182 } else if( runningMode == 'previous') { 183 184 this.fx2[this.options.nextIndex].start('opacity', 1,0); 185 this.fx[this.options.nextIndex].start(this.options.modes[this.options.mode][0], 0, -(this.options.size) ); 186 this.fx2[this.options.currentIndex].start('opacity', 0,1); 187 this.fx[this.options.currentIndex].start(this.options.modes[this.options.mode][0], +(this.options.size), 0 ); 188 189 } 190 } else { 191 if( runningMode == 'next' ) { 192 this.fx2[this.options.previousIndex].start('opacity', 1,0); 193 this.fx2[this.options.currentIndex].start('opacity', 0,1); 194 this.options.items[this.options.previousIndex].setStyle('zIndex', 1); 195 this.options.items[this.options.currentIndex].setStyle('zIndex', this.options.items.length + 10);
196 } else { 197 this.fx2[this.options.nextIndex].start('opacity', 1,0); 198 this.fx2[this.options.currentIndex].start('opacity', 0,1); 199 this.options.items[this.options.nextIndex].setStyle('zIndex', 1); 200 this.options.items[this.options.currentIndex].setStyle('zIndex', this.options.items.length + 10); 201 } 202 } 203 204 if( manual ){ this.stop(); } 205 // if using callback method. 206 if(this.onRunning){ 207 this.onRunning( this.options.items[this.options.currentIndex],(this.buttons ? this.buttons[this.options.currentIndex]:null) ); 208 } 209 210 if( manual && this.options.autoRun ){ 211 this.play( this.options.interval,'next', true ); 212 } 213 }, 214 215 bindingButtonsEvent:function( action, buttons ){ 216 for(var i=0; i<buttons.length; i++){ 217 switch(action){ 218 case 'previous': 219 buttons[i].addEvent(this.options.buttonEvent,this.previous.bind(this,true)); 220 break; 221 case 'next': 222 buttons[i].addEvent(this.options.buttonEvent,this.next.bind(this,true)); 223 break; 224 case 'play': 225 buttons[i].addEvent(this.options.buttonEvent, this.play.bind( this,[this.options.interval,'next',false]) ); 226 break; 227 case 'playback': 228 buttons[i].addEvent( this.options.buttonEvent, 229 this.play.bind(this,[this.options.interval,'previous',false])); 230 break; 231 case 'stop': 232 buttons[i].addEvent(this.options.buttonEvent, this.stop.bind(this) ); break; 233 } 234 this.buttons[action].push(buttons[i]); 235 } 236 237 } 238 239} ); 240 241
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.