Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Anyone used Lof Jslidernews - jquery slider?

  • 01-02-2011 7:50pm
    #1
    Registered Users, Registered Users 2 Posts: 37


    Just wondering if anyone in here has used this
    http://landofcoder.com/our-porfolios/jquery-plugins/item/10-the-lof-jsidernews-plugin.html jquery plugin before? and if they have would they hav any notion of how to add play and pause button to it??

    I've managed to create a new button which can get the slider moving from stopped but only moves 1 place, it doesnt keep going after that. This is the button I have added to it
    playpause:function(delay, direction, wait ){
    			
    			this.play( this.settings.interval,'next', true );
    			return this;
    		},
    



    This is the setup of the code.. any help would be much appreciated! am only gettin to grips with jquery really!

    Thanks for your time
    // JavaScript Document
    /*! Copyright (c) 2009 Brandon Aaron (http://brandonaaron.net)
     * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
     * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
     * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
     * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
     *
     * Version: 3.0.2
     * 
     * Requires: 1.2.2+
     */
    
    (function($) {
    
    var types = ['DOMMouseScroll', 'mousewheel'];
    
    $.event.special.mousewheel = {
    	setup: function() {
    		if ( this.addEventListener )
    			for ( var i=types.length; i; )
    				this.addEventListener( types[--i], handler, false );
    		else
    			this.onmousewheel = handler;
    	},
    	
    	teardown: function() {
    		if ( this.removeEventListener )
    			for ( var i=types.length; i; )
    				this.removeEventListener( types[--i], handler, false );
    		else
    			this.onmousewheel = null;
    	}
    };
    
    $.fn.extend({
    	mousewheel: function(fn) {
    		return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel");
    	},
    	
    	unmousewheel: function(fn) {
    		return this.unbind("mousewheel", fn);
    	}
    });
    
    
    function handler(event) {
    	var args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true;
    	
    	event = $.event.fix(event || window.event);
    	event.type = "mousewheel";
    	
    	if ( event.wheelDelta ) delta = event.wheelDelta/120;
    	if ( event.detail     ) delta = -event.detail/3;
    	
    	// Add events and delta to the front of the arguments
    	args.unshift(event, delta);
    
    	return $.event.handle.apply(this, args);
    }
    
    })(jQuery);
    
    /**
     * @version		$Id:  $Revision
     * @package		jquery
     * @subpackage	lofslidernews
     * @copyright	Copyright (C) JAN 2010 LandOfCoder.com <@emai:landofcoder@gmail.com>. All rights reserved.
     * @website     http://landofcoder.com
     * @license		This plugin is dual-licensed under the GNU General Public License and the MIT License 
     */
    // JavaScript Document
    (function($) {
    	 $.fn.lofJSidernews = function( settings ) {
    	 	return this.each(function() {
    			// get instance of the lofSiderNew.
    			new  $.lofSidernews( this, settings ); 
    		});
     	 }
    	 $.lofSidernews = function( obj, settings ){
    		this.settings = {
    			direction	    	: '',
    			mainItemSelector    : 'li',
    			navInnerSelector	: 'ul',
    			navSelector  		: 'li' ,
    			navigatorEvent		: 'click',
    			wapperSelector: 	'.lof-main-wapper',
    			interval	  	 	: 4000,
    			auto			    : true, // whether to automatic play the slideshow
    			maxItemDisplay	 	: 3,
    			startItem			: 0,
    			navPosition			: 'vertical', 
    			navigatorHeight		: 100,
    			navigatorWidth		: 310,
    			duration			: 600,
    			navItemsSelector    : '.lof-navigator li',
    			navOuterSelector    : '.lof-navigator-outer' ,
    			isPreloaded			: true,
    			easing				: 'easeInOutQuad'
    		}	
    		$.extend( this.settings, settings ||{} );	
    		this.nextNo         = null;
    		this.previousNo     = null;
    		this.playpauseNo     = null;
    		this.maxWidth  = this.settings.mainWidth || 600;
    		this.wrapper = $( obj ).find( this.settings.wapperSelector );	
    		this.slides = this.wrapper.find( this.settings.mainItemSelector );
    		if( !this.wrapper.length || !this.slides.length ) return ;
    		// set width of wapper
    		if( this.settings.maxItemDisplay > this.slides.length ){
    			this.settings.maxItemDisplay = this.slides.length;	
    		}
    		this.currentNo      = isNaN(this.settings.startItem)||this.settings.startItem > this.slides.length?0:this.settings.startItem;
    		this.navigatorOuter = $( obj ).find( this.settings.navOuterSelector );	
    		this.navigatorItems = $( obj ).find( this.settings.navItemsSelector ) ;
    		this.navigatorInner = this.navigatorOuter.find( this.settings.navInnerSelector );
    		
    		if( this.settings.navPosition == 'horizontal' ){ 
    			this.navigatorInner.width( this.slides.length * this.settings.navigatorWidth );
    			this.navigatorOuter.width( this.settings.maxItemDisplay * this.settings.navigatorWidth );
    			this.navigatorOuter.height(	this.settings.navigatorHeight );
    			
    		} else {
    			this.navigatorInner.height( this.slides.length * this.settings.navigatorHeight );	
    			
    			this.navigatorOuter.height( this.settings.maxItemDisplay * this.settings.navigatorHeight );
    			this.navigatorOuter.width(	this.settings.navigatorWidth );
    		}		
    		this.navigratorStep = this.__getPositionMode( this.settings.navPosition );		
    		this.directionMode = this.__getDirectionMode();  
    		
    		
    		if( this.settings.direction == 'opacity') {
    			this.wrapper.addClass( 'lof-opacity' );
    			$(this.slides).css('opacity',0).eq(this.currentNo).css('opacity',1);
    		} else { 
    			this.wrapper.css({'left':'-'+this.currentNo*this.maxSize+'px', 'width':( this.maxWidth ) * this.slides.length } );
    		}
    
    		
    		if( this.settings.isPreloaded ) {
    			this.preLoadImage( this.onComplete );
    		} else {
    			this.onComplete();
    		}
    		
    	 }
         $.lofSidernews.fn =  $.lofSidernews.prototype;
         $.lofSidernews.fn.extend =  $.lofSidernews.extend = $.extend;
    	 
    	 $.lofSidernews.fn.extend({
    							  
    		startUp:function( obj, wrapper ) {
    			seft = this;
    
    			this.navigatorItems.each( function(index, item ){
    				$(item).click( function(){
    					seft.jumping( index, true );
    					seft.setNavActive( index, item );					
    				} );
    				$(item).css( {'height': seft.settings.navigatorHeight, 'width':  seft.settings.navigatorWidth} );
    			})
    			this.registerWheelHandler( this.navigatorOuter, this );
    			this.setNavActive(this.currentNo );
    			
    			if( this.settings.buttons && typeof (this.settings.buttons) == "object" ){
    				this.registerButtonsControl( 'click', this.settings.buttons, this );
    
    			}
    			if( this.settings.auto ) 
    			this.play( this.settings.interval,'next', true );
    			
    			return this;
    		},
    		onComplete:function(){
    			setTimeout( function(){ $('.preload').fadeOut( 900 ); }, 400 );	this.startUp( );
    		},
    		preLoadImage:function(  callback ){
    			var self = this;
    			var images = this.wrapper.find( 'img' );
    	
    			var count = 0;
    			images.each( function(index,image){ 
    				if( !image.complete ){				  
    					image.onload =function(){
    						count++;
    						if( count >= images.length ){
    							self.onComplete();
    						}
    					}
    					image.onerror =function(){ 
    						count++;
    						if( count >= images.length ){
    							self.onComplete();
    						}	
    					}
    				}else {
    					count++;
    					if( count >= images.length ){
    						self.onComplete();
    					}	
    				}
    			} );
    		},
    		navivationAnimate:function( currentIndex ) { 
    			if (currentIndex <= this.settings.startItem 
    				|| currentIndex - this.settings.startItem >= this.settings.maxItemDisplay-1) {
    					this.settings.startItem = currentIndex - this.settings.maxItemDisplay+2;
    					if (this.settings.startItem < 0) this.settings.startItem = 0;
    					if (this.settings.startItem >this.slides.length-this.settings.maxItemDisplay) {
    						this.settings.startItem = this.slides.length-this.settings.maxItemDisplay;
    					}
    			}		
    			this.navigatorInner.stop().animate( eval('({'+this.navigratorStep[0]+':-'+this.settings.startItem*this.navigratorStep[1]+'})'), 
    												{duration:500, easing:'easeInOutQuad'} );	
    		},
    		setNavActive:function( index, item ){
    			if( (this.navigatorItems) ){ 
    				this.navigatorItems.removeClass( 'active' );
    				$(this.navigatorItems.get(index)).addClass( 'active' );	
    				this.navivationAnimate( this.currentNo );	
    			}
    		},
    		__getPositionMode:function( position ){
    			if(	position  == 'horizontal' ){
    				return ['left', this.settings.navigatorWidth];
    			}
    			return ['top', this.settings.navigatorHeight];
    		},
    		__getDirectionMode:function(){
    			switch( this.settings.direction ){
    				case 'opacity': this.maxSize=0; return ['opacity','opacity'];
    				default: this.maxSize=this.maxWidth; return ['left','width'];
    			}
    		},
    		registerWheelHandler:function( element, obj ){ 
    			 element.bind('mousewheel', function(event, delta ) {
    				var dir = delta > 0 ? 'Up' : 'Down',
    					vel = Math.abs(delta);
    				if( delta > 0 ){
    					obj.previous( true );
    				} else {
    					obj.next( true );
    				}
    				return false;
    			});
    		},
    		registerButtonsControl:function( eventHandler, objects, self ){ 
    			for( var action in objects ){ 
    				switch (action.toString() ){
    					case 'next':
    						objects[action].click( function() { self.next( true) } );
    						break;
    					case 'previous':
    						objects[action].click( function() { self.previous( true) } );
    						break;
    					case 'playpause':
    						objects[action].click( function() { self.playpause( true) } );
    						break;
    				}
    			}
    			return this;	
    		},
    		onProcessing:function( manual, start, end ){	 		
    			this.previousNo = this.currentNo + (this.currentNo>0 ? -1 : this.slides.length-1);
    			this.playpauseNo = this.currentNo + (this.currentNo>0 ? -1 : this.slides.length-1);
    			this.nextNo 	= this.currentNo + (this.currentNo < this.slides.length-1 ? 1 : 1- this.slides.length);				
    			return this;
    		},
    		finishFx:function( manual ){
    			if( manual ) this.stop();
    			if( manual && this.settings.auto ){ 
    				this.play( this.settings.interval,'next', true );
    			}		
    			this.setNavActive( this.currentNo );	
    		},
    		getObjectDirection:function( start, end ){
    			return eval("({'"+this.directionMode[0]+"':-"+(this.currentNo*start)+"})");	
    		},
    		fxStart:function( index, obj, currentObj ){
    				if( this.settings.direction == 'opacity' ) { 
    					$(this.slides).stop().animate({opacity:0}, {duration: this.settings.duration, easing:this.settings.easing} );
    					$(this.slides).eq(index).stop().animate( {opacity:1}, {duration: this.settings.duration, easing:this.settings.easing} );
    				}else {
    					this.wrapper.stop().animate( obj, {duration: this.settings.duration, easing:this.settings.easing} );
    				}
    			return this;
    		},
    		jumping:function( no, manual ){
    			this.stop(); 
    			if( this.currentNo == no ) return;		
    			 var obj = eval("({'"+this.directionMode[0]+"':-"+(this.maxSize*no)+"})");
    			this.onProcessing( null, manual, 0, this.maxSize )
    				.fxStart( no, obj, this )
    				.finishFx( manual );	
    				this.currentNo  = no;
    		},
    		next:function( manual , item){
    
    			this.currentNo += (this.currentNo < this.slides.length-1) ? 1 : (1 - this.slides.length);	
    			this.onProcessing( item, manual, 0, this.maxSize )
    				.fxStart( this.currentNo, this.getObjectDirection(this.maxSize ), this )
    				.finishFx( manual );
    		},
    		previous:function( manual, item ){
    			this.currentNo += this.currentNo > 0 ? -1 : this.slides.length - 1;
    			this.onProcessing( item, manual )
    				.fxStart( this.currentNo, this.getObjectDirection(this.maxSize ), this )
    				.finishFx( manual	);			
    		},
    		playpause:function(delay, direction, wait ){
    			//alert("Thanks for visiting!");
    			this.play( this.settings.interval,'next', true );
    			return this;
    		},
    
    
    		play:function( delay, direction, wait ){	
    			this.stop(); 
    			if(!wait){ this[direction](false); }
    			var self  = this;
    			this.isRun = setTimeout(function() { self[direction](true); }, delay);
    		},
    		stop:function(){ 
    			if (this.isRun == null) return;
    			clearTimeout(this.isRun);
                this.isRun = null; 
    		}
    	})
    })(jQuery)
    
    


Comments

  • Registered Users, Registered Users 2 Posts: 37 leapin_lep


    managed to solve it myself.. thanks anyway guys!

    just incase anyone else is ever looking for the same thing.. i set up 2 buttons in the end and used these functions playrotate and playpause.

    probably not the cleanest way of doing it but it does the job!

    cheers anyways
    		playrotate:function( manual, item ){
    			
    			this.play( this.settings.interval,'next', true );
    			this.settings.auto=true;
    			return this;
    		},
    		playpause:function( manual, item ){
    			
    			this.stop( this.settings.interval,'next', false );
    			this.settings.auto=false;
    			return this;
    		},
    
    


Advertisement