PageSourceSearch

https://plenmagazin.ru/modules/mod_lofarticlesslideshow/assets/jscript.js

js plenmagazin.ru collected 2026-10-05 00:32:17 UTC 12,978 bytes, 304 lines download raw bytes

1/**
2 * @version   $Id:  $Revision
3 * @package   mootool
4 * @subpackage  lofslidernews
5 * @copyright Copyright (C) JAN 2010 LandOfCoder.com <@emai:[email protected]>. All rights reserved.
6 * @website     http://landofcoder.com
7 * @license   This plugin is dual-licensed under the GNU General Public License and the MIT License 
8 */
9if( typeof(jQuery) != 'undefined' ){
10	jQuery.noConflict();
11}
12 
13 ////
14if( typeof(LofArticleSlideshow) == 'undefined' ){
15  var LofArticleSlideshow = new Class( {
16    initialize:function( _lofmain, options ){
17      this.setting = Object.append({
18        autoStart     	: true,
19        descStyle       : 'sliding',
20        mainItemSelector: 'div.lof-main-item',
21        navSelector     : 'li' ,
22        navigatorEvent  : 'click',
23        interval        :  2000,
24        auto          	: false,
25        navItemsDisplay : 3,
26        startItem     	: 0,
27        navItemHeight   : 100,
28        navItemWidth    : 310,
29		descOpacity:1
30      }, options || {} );
31      this.descriptions = [];
32      var eMain      = _lofmain.getElement('.lof-main-wapper');
33      var eNavigator = _lofmain.getElement('.lof-navigator-outer .lof-navigator');
34      var eNavOuter  = _lofmain.getElement('.lof-navigator-outer');   
35      this.currentNo  = 0;
36      this.nextNo     = null;
37      this.previousNo = null;
38      this.fxItems  = []; 
39      this.minSize  = 0;
40      this.onClick = false;
41      if((eMain)!=null){
42        this.slides    = eMain.getElements( this.setting.mainItemSelector );
43        this.maxWidth  = eMain.getStyle('width').toInt();
44        this.maxHeight = eMain.getStyle('height').toInt();
45        this.styleMode = this.__getStyleMode();  
46        var fx = Object.append({waiting:false, onComplete:function(){ this.onClick=false;   this.slides.setStyle("z-index",0), this.slides[this.currentNo].setStyle("z-index",3); }.bind(this) }, this.setting.fxObject );
47        this.slides.each( function(item, index) { 
48          item.setStyles( eval('({"'+this.styleMode[0]+'": index * this.maxSize,"'+this.styleMode[1]+'":Math.abs(this.maxSize),"display" : "block"})') );   
49          this.fxItems[index] = new Fx.Morph( item,  fx );
50		  if( item.getElement(".lof-description") ) {
51				this.descriptions[index] = new Fx.Morph(item.getElement(".lof-description"));
52				if(index!=0 && (this.descriptions[index])!=null ){
53					this.descriptions[index].start({"opacity":0});
54				}
55			}
56				
57        }.bind(this) );
58        if( this.styleMode[0] == 'opacity' || this.styleMode[0] =='z-index' ){
59          this.slides[0].setStyle(this.styleMode[0],'1');
60        }
61        eMain.addEvents( { 'mouseenter' : this.stop.bind(this),
62                     'mouseleave' :function(e){ 
63                    if(  this.setting.auto ){
64                    this.play( this.setting.interval,'next', true );
65                  } }.bind(this) } );
66      }
67	  
68	  if(( _lofmain.getElement(".lof-startstop"))!=null ) {
69					_lofmain.getElement(".lof-startstop").addEvent('click', function(){
70						if( _lofmain.getElement(".lof-startstop div").hasClass("lof-stop") ){
71							this.setting.auto =true;
72							this.play( this.setting.interval,'next', true );
73							 _lofmain.getElement(".lof-startstop div").removeClass("lof-stop").addClass("lof-start");
74						}else {
75							this.setting.auto =false;
76							this.stop();
77							 _lofmain.getElement(".lof-startstop div").removeClass("lof-start").addClass("lof-stop");	
78						}
79					}.bind(this) );
80				} 
81         if(  this.setting.auto ){
82        	///  this.registerMousewheelHandler( eNavigator ); // allow to use the srcoll
83         }
84		 // if( this.setting.autoStart ){
85			 this.start( this.setting.autoStart, _lofmain );
86		// }
87		 
88      if((eNavigator)!=null && (eNavOuter)!=null ){
89        var modes = {
90          horizontal : ['margin-left', 'width', 'height', 'navItemWidth', 'navItemHeight'],
91          vertical   : ['top', 'height', 'width', 'navItemHeight', 'navItemWidth']
92        }
93        var mode = ( this.setting.navPos == 'bottom' || this.setting.navPos == 'top' )?'horizontal' : 'vertical'; 
94    
95        this.navigatorItems = eNavigator.getElements( this.setting.navSelector );
96        if( this.setting.navItemsDisplay > this.navigatorItems.length ){
97          this.setting.navItemsDisplay = this.navigatorItems.length;  
98        }
99        
100        if((_lofmain.getElement(".lof-bullets"))!=null){
101          this.setting.navItemHeight = this.navigatorItems[0].offsetHeight;
102          this.setting.navItemWidth  = this.navigatorItems[0].offsetWidth;
103        }
104        
105        this.navigatorSlideSize = this.setting[modes[mode][3]];  
106        eNavOuter.setStyle(modes[mode][1], this.setting.navItemsDisplay * this.navigatorSlideSize);
107                eNavOuter.setStyle(modes[mode][2], this.setting[modes[mode][4]] );
108                
109        this.navigatorMode =  modes[mode][0];   
110        this.navigatorFx = new Fx.Tween( eNavigator,{transition:Fx.Transitions.Sine.easeInOut,duration:900} );
111          
112         
113        this.navigatorItems.each( function(item,index) {
114          item.addEvent( this.setting.navigatorEvent, function(){   
115          if( this.onClick ) return ;
116            this.jumping( index, true );
117            this.setNavActive( index, item ); 
118          }.bind(this) ); 
119  
120            item.setStyles( { 'height' : this.setting.navItemHeight,
121                        'width'  : this.setting.navItemWidth} );    
122        }.bind(this) );
123        // set default setting
124        this.currentNo=this.setting.startItem.toInt()>this.slides.length?this.slides.length:this.setting.startItem.toInt();
125        this.setNavActive( this.currentNo );
126        this.slides.setStyle(this.styleMode[0] ,this.maxSize ).setStyle("z-index",0);
127        this.slides[this.currentNo].setStyle(this.styleMode[0] ,this.minSize ).setStyle("z-index",3);
128      }
129    },
130    navivationAnimate:function( currentIndex ) { 
131      if (currentIndex <= this.setting.startItem 
132        || currentIndex - this.setting.startItem >= this.setting.navItemsDisplay-1) {
133          this.setting.startItem = currentIndex - this.setting.navItemsDisplay+2;
134          if (this.setting.startItem < 0) this.setting.startItem = 0;
135          if (this.setting.startItem >this.slides.length-this.setting.navItemsDisplay) {
136            this.setting.startItem = this.slides.length-this.setting.navItemsDisplay;
137          }
138      }   
139      this.navigatorFx.cancel().start( this.navigatorMode,-this.setting.startItem*this.navigatorSlideSize );  
140    },
141    setNavActive:function( index, item ){
142      if((this.navigatorItems)!=null && ( this.navigatorItems[index] )!=null ){ 
143        this.navigatorItems.removeClass('active');
144        this.navigatorItems[index].addClass('active');  
145        this.navivationAnimate( this.currentNo ); 
146      }
147    },
148    __getStyleMode:function(){
149      switch( this.setting.direction ){
150        case 'opacity': this.maxSize=0; this.minSize=1; return ['opacity','opacity'];
151        case 'replace': this.maxSize=0; this.minSize=1; return ['display','display'];
152        case 'vrup':    this.maxSize=this.maxHeight;    return ['top','height'];
153        case 'vrdown':  this.maxSize=-this.maxHeight;   return ['top','height'];
154        case 'hrright': this.maxSize=-this.maxWidth;    return ['left','width'];
155        case 'hrleft':
156        default: this.maxSize=this.maxWidth; return ['left','width'];
157      }
158    },
159    registerMousewheelHandler:function( element ){ 
160      element.addEvents({
161        'wheelup': function(e) {
162          
163          e = new Event(e).cancel(); 
164            this.previous(true);
165        }.bind(this),
166       
167        'wheeldown': function(e) {
168          e = new Event(e).cancel();
169        
170          this.next(true);
171        }.bind(this)
172      } );
173    },
174    registerButtonsControl:function( eventHandler, objects, isHover ){
175      if((objects)!=null && this.slides.length > 1 ){
176        for( var action in objects ){ 
177          if((this[action.toString()])!=null  && (objects[action])!=null ){
178            objects[action].addEvent( eventHandler, this[action.toString()].bind(this, true) );
179          }
180        }
181      }
182      return this;  
183    },
184    start:function( isStart, _lofmain ){
185      this.setting.auto = isStart;
186      // if use the preload image.
187	 var obj =  _lofmain.getElement('.preload');
188 
189      if( obj ) {
190        this.preloadImages(  obj );
191      } else {
192        if( this.setting.auto && this.slides.length > 1 ){
193            this.play( this.setting.interval,'next', true );} 
194      }
195	  
196		 if(( _lofmain.getElement(".lof-startstop") )!=null ) {
197				if( this.setting.auto ){
198					_lofmain.getElement(".lof-startstop div").addClass("lof-start");	
199				} else {
200					_lofmain.getElement(".lof-startstop div").addClass("lof-stop");		
201				}
202		}
203			
204    },
205    onComplete:function( obj ){  
206      (function(){                                
207        obj.fade('out');    
208      }).delay(500);
209      if( this.setting.auto && this.slides.length > 1 ){
210        this.play( this.setting.interval,'next', true );} 
211      
212    },
213    preloadImages:function( obj ){  
214      var loaded=[];
215      var counter=0;
216      var self = this;
217      var _length = this.slides.getElements('img').length;
218      this.timer = setInterval( function(){
219        if(counter >= _length) {   
220            clearInterval(self.timer);
221            self.onComplete( obj );
222            return true;
223        } 
224      }, 200);
225      this.slides.getElements('img').each( function(img, index){
226        image = new Image();
227        image.src=img.src;
228        if( !image.complete ){          
229          image.onload =function(){
230            counter++;
231          }
232          image.onerror =function(){ 
233            counter++;
234          }
235        }else {
236          counter++;
237        }
238      } );
239    },
240    onProcessing:function( manual, start, end ){  
241      this.onClick = true;
242      this.previousNo = this.currentNo + (this.currentNo>0 ? -1 : this.slides.length-1);
243      this.nextNo   = this.currentNo + (this.currentNo < this.slides.length-1 ? 1 : 1- this.slides.length);       
244      return this;
245    },
246    finishFx:function( manual, currentNo ){
247      if( manual ) this.stop();
248      if( manual && this.setting.auto ){  
249        this.play( this.setting.interval,'next', true );
250      }   
251      this.setNavActive( this.currentNo );  
252	  if( (this.descriptions[currentNo])!=null && (this.descriptions[currentNo].start)!=null){
253			for( i = 0; i < this.descriptions.length;i++ ){
254				this.descriptions[i].start({"opacity":0});
255			} 
256			this.descriptions[currentNo].cancel().start({"opacity":this.setting.descOpacity});
257		}
258		
259    },
260    getObjectDirection:function( start, end ){
261      return eval("({'"+this.styleMode[0]+"':["+start+", "+end+"]})");  
262    },
263    fxStart:function( index, obj ){
264      this.fxItems[index].cancel(true, false).start( obj );
265      return this;
266    },
267    jumping:function( no, manual ){
268      this.stop();
269      if( this.currentNo == no ) return;
270      var object = this.onProcessing( null, manual, 0, this.maxSize );
271      if( this.currentNo < no  ){
272        object.fxStart( no, this.getObjectDirection(this.maxSize , this.minSize) );
273        object.fxStart( this.currentNo, this.getObjectDirection(this.minSize,  -this.maxSize) );
274      } else {
275        object.fxStart( no, this.getObjectDirection(-this.maxSize , this.minSize) );
276        object.fxStart( this.currentNo, this.getObjectDirection(this.minSize,  this.maxSize) ); 
277      }
278      object.finishFx( manual, no );  
279      this.currentNo  = no;
280    },
281    next:function( manual , item){
282      if( this.onClick ) return ;
283      this.currentNo += (this.currentNo < this.slides.length-1) ? 1 : (1 - this.slides.length); 
284      this.onProcessing( item, manual, 0, this.maxSize )
285        .fxStart( this.currentNo, this.getObjectDirection(this.maxSize ,this.minSize) )
286        .fxStart( this.previousNo, this.getObjectDirection(this.minSize, -this.maxSize) )
287        .finishFx( manual,this.currentNo );
288    },
289    previous:function( manual, item ){
290      if( this.onClick ) return ;
291      this.currentNo += this.currentNo > 0 ? -1 : this.slides.length - 1;
292      this.onProcessing( item, manual, -this.maxWidth, this.minSize )
293        .fxStart( this.nextNo, this.getObjectDirection(this.minSize, this.maxSize) )
294        .fxStart( this.currentNo,  this.getObjectDirection(-this.maxSize, this.minSize) )
295        .finishFx( manual,this.currentNo );      
296    },
297    play:function( delay, direction, wait ){
298      this.stop(); 
299      if(!wait){ this[direction](false); }
300      this.isRun = this[direction].periodical(delay,this,true);
301    },stop:function(){  clearTimeout(this.isRun ); clearInterval(this.isRun); }
302  } );
303}
304

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.