/* * * YCodaSlider 3.0 * @requires jQuery v1.3.2 * * Copyright (c) 2008 Massimiliano Balestrieri * Examples and docs at: http://maxb.net/blog/ * Licensed GPL licenses: * http://www.gnu.org/licenses/gpl.html * * Based on Gian Carlo Mingati's slideViewer * http://www.gcmingati.net/wordpress/wp-content/lab/jquery/imagestrip/imageslide-plugin.html * Based on Niall Doherty's coda-slider * http://www.ndoherty.com/coda-slider * Inspired by the clever folks at http://www.panic.com/coda */ ;(function($){YCodaSlider={};YCodaSlider.Init=function(options,data){if(typeof options=="string"){return YCodaSlider.Api[options](this,data);}else{return this.each(function(){new YCodaSlider.Core(this,options);});}};YCodaSlider.Api={current:function(el){return $(el).data("current");},width:function(el){return $(el).data("width");},count:function(el){return $(el).data("count");},left:function(el){return $(el).trigger("left");},right:function(el){return $(el).trigger("right");},go:function(el,nr){return $(el).trigger("go",nr);}};YCodaSlider.Core=function(el,options){var _metadata={};if($.metadata)_metadata=$(el).metadata();var _options=$.extend({height:false,width:false,shortcut:[37,39],id:false,scroll:false,history:false,arrows:true,navigator:true,easeFunc:false,easeTime:false,after:false,tracking:false,tracking_pre:false,debug:false},_metadata,options);var that=el;if(!$.ajaxHistory)_options.history=false;var _pw=false;var _pc=false;var _vw=false;var _current=1;_data("width",0);_data("current",_current);$(that).bind("left",_left);$(that).bind("right",_right);$(that).bind("go",_go);$(that).bind("after",_after);_html();_set_options();_set_panel_width();_set_container_width();_set_current_panel();_check_arrows();_arrows();_keyword();_navigator();_move();_debug();function _left(){var _goto=0;var _position=_current-1;if(_current==1){_goto=_pc-1;}else{_goto=_position-1;};$(that).trigger("go",[_goto]);var _history=_goto+1;if(_options.history)location.hash=_history;}function _right(){var _goto=0;var _position=_current-1;if(_current==_pc){_goto=0;}else{_goto=_position+1;};$(that).trigger("go",[_goto]);if(_options.history)location.hash=_current;}function _go(ev,nr){var _x=-(_pw*nr);_current=_data("current",nr+1);$("div.yslider-viewer",that).animate({scrollTop:0},_options.easeTime,_options.easeFunc);$("div.yslider-container",that).animate({left:_x},_options.easeTime,_options.easeFunc);$(that).trigger("after");}function _after(){if(_options.after)_after();}function _is_valid_current(){return _options.history&&location.hash&&parseInt(location.hash.slice(1))<=_pc;}function _move(){$(that).trigger("go",[(_current-1)]);if(_options.history)location.hash=_current;}function _debug(){if(_options.debug){$('div.yslider-viewer',that).css({width:10653,overflow:'auto'});}}function _keyword(){var sc=_options.shortcut;if(sc&&sc[0]&&sc[1]){$(document).keydown(function(e){if(e==null){keycode=event.keyCode;}else{keycode=e.which;}if(!($(that).css("display")==="none")){if(keycode==sc[0]){$(that).ycodaslider("left");}else if(keycode==sc[1]){$(that).ycodaslider("right");}}});}}function _arrows(){if(_options.arrows)new YCodaSlider.Arrows(that,_options);}function _navigator(){if(_options.navigator){new YCodaSlider.Navigator(that,_options);}}function _check_arrows(){if(_pc<=1)_options.arrows=false;}function _set_current_panel(){if(_is_valid_current()){_current=parseInt(location.hash.slice(1))||1;}}function _set_container_width(){var _container=$("div.yslider-container",that);_container.css("width",_vw);}function _set_panel_width(){var _panels=$(that).find("div.yslider-panel");_pw=_options.width||_panels.width();_pc=_panels.size();_vw=_pw*_pc;_data("width",_pw);}function _set_options(){if(_options.width){_set_width(_options.width);}if(_options.height){_set_height(_options.height);}if(_options.scroll){_set_scroll();}}function _html(){var _html='