/** * jquery.scrollable 0.11. Making HTML elements scroll. * * http://flowplayer.org/tools/scrollable.html * * Copyright (c) 2008 Tero Piirainen (tero@flowplayer.org) * * Released under the MIT License: * http://www.opensource.org/licenses/mit-license.php * * >> Basically you can do anything you want but leave this header as is << * * Since : 0.01 - 03/01/2008 * Version: 0.11 - 05/20/2008 */ (function($){$.fn.extend({scrollable:function(arg1,arg2,arg3){return this.each(function(){if(typeof arg1=="string"){var el=$.data(this,"scrollable");el[arg1].apply(el,[arg2,arg3]);}else{new $.scrollable(this,arg1,arg2);}});}});$.scrollable=function(el,opts){$.data(el,"scrollable",this);this.init(el,opts);};$.extend($.scrollable.prototype,{init:function(el,config){var self=this;var opts={size:5,horizontal:false,activeClass:'active',speed:300,onSeek:null,items:'.items',prev:'.prev',next:'.next',navi:'.navi',naviItem:'span'};this.opts=$.extend(opts,config);var root=this.root=$(el);var itemRoot=$(opts.items,root);if(!itemRoot.length)itemRoot=root;itemRoot.css({position:'relative',overflow:'hidden',visibility:'visible'});itemRoot.children().wrapAll('
');this.wrap=itemRoot.children(":first");this.wrap.css(opts.horizontal?"width":"height","200000em").after('
');this.items=this.wrap.children();this.index=0;if(opts.horizontal){itemRoot.width(opts.size*(this.items.eq(1).offset().left-this.items.eq(0).offset().left)-2);}else{itemRoot.height(opts.size*(this.items.eq(1).offset().top-this.items.eq(0).offset().top)-2);} if($.isFunction($.fn.mousewheel)){root.bind("mousewheel.scrollable",function(event,delta){self.move(-delta,50);return false;});} $(window).bind("keypress.scrollable",function(evt){if($(evt.target).parents(".__scrollable").length){if(opts.horizontal&&(evt.keyCode==37||evt.keyCode==39)){self.move(evt.keyCode==37?-1:1);return false;} if(!opts.horizontal&&(evt.keyCode==38||evt.keyCode==40)){self.move(evt.keyCode==38?-1:1);return false;}} return true;});this.items.each(function(index,arg){$(this).bind("click.scrollable",function(){self.click(index);});});this.activeIndex=0;$(opts.prev,root).click(function(){self.prev()});$(opts.next,root).click(function(){self.next()});$(opts.navi,root).each(function(){var navi=$(this);var status=self.getStatus();if(navi.is(":empty")){for(var i=0;i").attr("page",i).click(function(){var el=$(this);el.parent().children().removeClass(opts.activeClass);el.addClass(opts.activeClass);self.setPage(el.attr("page"));});if(i==0)item.addClass(opts.activeClass);navi.append(item);}}else{navi.children().each(function(i){var item=$(this);item.attr("page",i);if(i==0)item.addClass(opts.activeClass);item.click(function(){item.parent().children().removeClass(opts.activeClass);item.addClass(opts.activeClass);self.setPage(item.attr("page"));});});}});},click:function(index){var item=this.items.eq(index);var klass=this.opts.activeClass;if(!item.hasClass(klass)&&(index>=0||index