/* * easy slider 1.7 - jquery plugin * written by alen grakalic * http://cssglobe.com/post/4004/easy-slider-15-the-easiest-jquery-plugin-for-sliding * * copyright (c) 2009 alen grakalic (http://cssglobe.com) * dual licensed under the mit (mit-license.txt) * and gpl (gpl-license.txt) licenses. * * built for jquery library * http://jquery.com * */ /* * markup example for $("#slider").easyslider(); * *
* *
* */ (function($) { $.fn.easyslider = function(options){ // default configuration properties var defaults = { previd: 'prevbtn', prevtext: 'previous', nextid: 'nextbtn', nexttext: 'next', controlsshow: true, controlsbefore: '', controlsafter: '', controlsfade: true, firstid: 'firstbtn', firsttext: 'first', firstshow: false, lastid: 'lastbtn', lasttext: 'last', lastshow: false, vertical: false, speed: 800, auto: false, pause: 2000, continuous: false, numeric: false, numericid: 'controls' }; var options = $.extend(defaults, options); this.each(function() { var obj = $(this); var s = $("li", obj).length; var w = $("li", obj).width(); var h = $("li", obj).height(); var clickable = true; obj.width(w); obj.height(h); obj.css("overflow","hidden"); var ts = s-1; var t = 0; $("ul", obj).css('width',s*w); if(options.continuous){ $("ul", obj).prepend($("ul li:last-child", obj).clone().css("margin-left","-"+ w +"px")); $("ul", obj).append($("ul li:nth-child(2)", obj).clone()); $("ul", obj).css('width',(s+1)*w); }; if(!options.vertical) $("li", obj).css('float','left'); if(options.controlsshow){ var html = options.controlsbefore; //if(options.numeric){ html += '
    '; //} else { if(options.firstshow) html += ''+ options.firsttext +''; html += ' '+ options.prevtext +''; html += ' '+ options.nexttext +''; if(options.lastshow) html += ' '+ options.lasttext +''; //}; html += options.controlsafter; $(obj).after(html); }; //if(options.numeric){ for(var i=0;i'+ (i+1) +'') .appendto($("#"+ options.numericid)) .click(function(){ animate($("a",$(this)).attr('rel'),true); }); }; //} else { $("a","#"+options.nextid).click(function(){ animate("next",true); }); $("a","#"+options.previd).click(function(){ animate("prev",true); }); $("a","#"+options.firstid).click(function(){ animate("first",true); }); $("a","#"+options.lastid).click(function(){ animate("last",true); }); //}; function setcurrent(i){ i = parseint(i)+1; $("li", "#" + options.numericid).removeclass("current"); $("li#" + options.numericid + i).addclass("current"); }; function adjust(){ if(t>ts) t=0; if(t<0) t=ts; if(!options.vertical) { $("ul",obj).css("margin-left",(t*w*-1)); } else { $("ul",obj).css("margin-left",(t*h*-1)); } clickable = true; if(options.numeric) setcurrent(t); }; function animate(dir,clicked){ if (clickable){ clickable = false; var ot = t; switch(dir){ case "next": t = (ot>=ts) ? (options.continuous ? t+1 : ts) : t+1; break; case "prev": t = (t<=0) ? (options.continuous ? t-1 : 0) : t-1; break; case "first": t = 0; break; case "last": t = ts; break; default: t = dir; break; }; var diff = math.abs(ot-t); var speed = diff*options.speed; if(!options.vertical) { p = (t*w*-1); $("ul",obj).animate( { marginleft: p }, { queue:false, duration:speed, complete:adjust } ); } else { p = (t*h*-1); $("ul",obj).animate( { margintop: p }, { queue:false, duration:speed, complete:adjust } ); }; if(!options.continuous && options.controlsfade){ if(t==ts){ $("a","#"+options.nextid).hide(); $("a","#"+options.lastid).hide(); } else { $("a","#"+options.nextid).show(); $("a","#"+options.lastid).show(); }; if(t==0){ $("a","#"+options.previd).hide(); $("a","#"+options.firstid).hide(); } else { $("a","#"+options.previd).show(); $("a","#"+options.firstid).show(); }; }; if(clicked) cleartimeout(timeout); if(options.auto && dir=="next" && !clicked){; timeout = settimeout(function(){ animate("next",false); },diff*options.speed+options.pause); }; }; }; // init var timeout; if(options.auto){; timeout = settimeout(function(){ animate("next",false); },options.pause); }; if(options.numeric) setcurrent(0); if(!options.continuous && options.controlsfade){ $("a","#"+options.previd).hide(); $("a","#"+options.firstid).hide(); }; }); }; })(jquery); $(document).ready(function() { $(".case_seek img").mouseenter(function(){ $(this).siblings("input").animate({width:200},600).select(); }); $(".case_search").click(function(e){ $(this).find(".text").animate({width:0},300); }); $(".case_seek").click(function(e){ e.stoppropagation(); }); //cases $('.thumbnail_a').hover( function() { $(this).children('.projectinfo').fadein('fast', function(){ $(this).children('.meta').animate({ bottom: 0 + "px" }); }); }, function() { $(this).children('.projectinfo').fadeout('fast', function(){ $(this).children('.meta').animate({ bottom: - 60 + "px" }, 1); }); } ); $(".c_back img").click(function() { $('html,body').stop().animate({scrolltop: 0}, 500); }); //enter搜索 $('#k').bind('keypress', function(event) { if (event.keycode == "13") { search_cases(); } }); //手机版切换 $("#slider").easyslider({ auto: true, continuous: true, numeric: true, prevtext:'', nexttext:'', nextid: "slider1next", previd: "slider1prev" }); }); //search function search_cases() { var k = $("#k").val(); document.location = "/cases/search?k=" + encodeuri(k)+"#case"; }