Team:UANL Mty-Mexico/slidorion/min

From 2013.igem.org

Revision as of 18:46, 26 September 2013 by Quintero (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

/*

  • Slidorion, An Image Slider and Accordion Combined
  • Intructions: http://www.slidorion.com
  • Created by Ben Holland - http://www.ben-holland.co.uk
  • Version: 1.0
  • Copyright 2011 Ben Holland <benholland99@gmail.com>
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at
  • http://www.apache.org/licenses/LICENSE-2.0
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.
  • /

(function(a){a.fn.extend({slidorion:function(b){var c={autoPlay:true,easing:"",effect:"fade",first:1,interval:5e3,hoverPause:true,speed:1e3};var b=a.extend(c,b);return this.each(function(){function G(){for(var b=m;b>0;b--){a("#slider > div:eq("+(b-1)+")",r).css("z-index",l);l++}}function F(a){if(a==m){a=0;return a}else{return a}}function E(){clearInterval(r.data("interval"));y=setInterval(function(){B(d,g,f,h)},i);r.data("interval",y)}function D(){clearInterval(r.data("interval"))}function C(){y=setInterval(function(){B(d,g,f,h)},i);r.data("interval",y)}function B(b,c,d,e){var f=F(b);a("#accordion .link-header:eq("+f+")",r).trigger("click",A)}function A(){if(p==false){$objHeader=a(this,r);var b=$objHeader.index()/2+1;if(b==d){return false}else{a(".link-header.active",r).removeClass("active").next(".link-content").slideUp();$objHeader.addClass("active").next(".link-content").slideDown();z(d,b,g,f,h)}l++;d=b;return false}}function z(b,c,d,e,f){if(!p){p=true;if(k==true&&o==false){E()}$current=a("#slider > div:eq("+(b-1)+")",r);$new=a("#slider > div:eq("+(c-1)+")",r);var g=$current.outerWidth();var h=$current.outerHeight();if(d=="random"){var i=Math.floor(Math.random()*s.length);d=s[i];while(d==q){var i=Math.floor(Math.random()*s.length);d=s[i]}}else if(d=="slideRandom"){var i=Math.floor(Math.random()*t.length);d=t[i];while(d==q){var i=Math.floor(Math.random()*t.length);d=t[i]}}else if(d=="overRandom"){var i=Math.floor(Math.random()*u.length);d=u[i];while(d==q){var i=Math.floor(Math.random()*u.length);d=u[i]}}q=d;switch(d){case"fade":$new.css({"z-index":l,top:"0",left:"0",display:"none"}).fadeIn(e);break;case"slideLeft":$new.css({left:g,top:"0",opacity:"1","z-index":l});$current.animate({left:"-="+g,top:"0",opacity:"1"},{queue:true,duration:e,easing:f});$new.animate({left:"-="+g,top:"0",opacity:"1"},{queue:true,duration:e,easing:f});break;case"slideRight":$new.css({left:"-"+g+"px",top:"0",opacity:"1","z-index":l});$current.animate({left:"+="+g,top:"0",opacity:"1"},{queue:true,duration:e,easing:f});$new.animate({left:"+="+g,top:"0",opacity:"1"},{queue:true,duration:e,easing:f});break;case"slideUp":$new.css({top:h,left:"0",opacity:"1","z-index":l});$current.animate({top:"-="+h,left:"0",opacity:"1"},{queue:true,duration:e,easing:f});$new.animate({top:"-="+h,left:"0",opacity:"1"},{queue:true,duration:e,easing:f});break;case"slideDown":$new.css({top:"-"+h+"px",left:"0",opacity:"1","z-index":l});$current.animate({top:"+="+h,left:"0",opacity:"1"},{queue:true,duration:e,easing:f});$new.animate({top:"+="+h,left:"0",opacity:"1"},{queue:true,duration:e,easing:f});break;case"overLeft":$new.css({left:g,top:"0",opacity:"1","z-index":l});$new.animate({left:"-="+g,top:"0",opacity:"1"},{queue:true,duration:e,easing:f});break;case"overRight":$new.css({left:"-"+g+"px",top:"0",opacity:"1","z-index":l});$new.animate({left:"+="+g,top:"0",opacity:"1"},{queue:true,duration:e,easing:f});break;case"overUp":$new.css({top:h,left:"0",opacity:"1","z-index":l});$new.animate({top:"-="+h,left:"0",opacity:"1"},{queue:true,duration:e,easing:f});break;case"overDown":$new.css({top:"-"+h+"px",left:"0",opacity:"1","z-index":l});$new.animate({top:"+="+h,left:"0",opacity:"1"},{queue:true,duration:e,easing:f});break;case"none":$new.css({"z-index":l});break}setTimeout(function(){p=false},e)}}var c=b;var d=c.first;var e=c.first+1;var f=c.speed;var g=c.effect;var h=c.easing;var i=c.interval;var j=c.hoverPause;var k=c.autoPlay;var l=1;var m=0;var n=0;var o=false;var p=false;var q="";var r=a(this);var s=new Array("fade","slideLeft","slideUp","slideRight","slideDown","overLeft","overRight","overUp","overDown");var t=new Array("slideLeft","slideUp","slideRight","slideDown");var u=new Array("overLeft","overRight","overUp","overDown");var v=new Array("wipeDown","wipeUp");var w=new Array("wipeDownFade","wipeUpFade");var x=new Array("wipeDown","wipeUp","wipeDownFade","wipeUpFade");m=a("#slider > div",r).size();r.data("slideCount",m);n=a("#accordion > .link-header",r).size();r.data("accordCount",n);if(m==n){if(k==true){var y=setInterval(function(){B(d,g,f,h)},i);r.data("interval",y)}if(j==true&&k==true){r.hover(function(){o=true;D()},function(){o=false;E()})}G();a("#slider > div:eq("+(d-1)+")",r).css("z-index",l);l++;if(g!="fade"||g!="none"){a("#slider > div",r).css({top:"0",left:"-600px"});a("#slider > div:eq("+(d-1)+")",r).css({top:"0",left:"0"})}a(".link-content",r).hide();a("#accordion .link-header:eq("+(d-1)+")",r).addClass("active").next().show();a(".link-header",r).click(A)}else{alert("The number of slider images does not match the number of accordion sections.");console.log("The number of slider images does not match the number of accordion sections.")}})}})})(jQuery)