-
Notifications
You must be signed in to change notification settings - Fork 0
/
jSlider.min.js
13 lines (12 loc) · 2.28 KB
/
jSlider.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
/*
* Plugin Name: A Simple jQuery Slider, jSlider
* Plugin Version: 1.0.3
* Plugin URL:
* Author: Bappi D Great
* Author E-mail: [email protected]
* Author Web: http://bappi.d.great.com
*
* Free to use and abuse under the MIT license.
* http://www.opensource.org/licenses/mit-license.php
*/
;(function(e){var t={width:618,startTime:500,intervalTime:5e3,images:[],captionPos:"left",controlPos:"tr"};e.fn.jSlider=function(n){function u(t){var n=e('<ul class="jSliderGallery"/>').appendTo(e('<div class="jSliderWrap"/>').appendTo(t));var s;for(s=0;s<i;s++){e("<li/>",{html:"<img id='jImg-"+s+"' src='"+r.images[0][s]+"'/><div class='jScaption "+r.captionPos+"'><h2>"+r.images[1][s]+"</h2><p>"+r.images[2][s]+"</p></div>"}).attr("data-url",r.images[3][s]).appendTo(n)}t.addClass("jSlider").css({width:r.width});e(".jSliderGallery li").on("click",function(){var t=e(this).data("url");if(t!="#"&&t!=""&&t!=null)window.location.href=e(this).data("url")})}function a(e,t){t.find(".jSactive").removeClass("jSactive");t.find(".jSliderNav li").eq(e).find("a").addClass("jSactive")}function f(e){if(s>=i){e.find(".jSliderWrap").animate({marginLeft:"0"});s=1}else{e.find(".jSliderWrap").animate({marginLeft:"-="+r.width+"px"});s++}a(s-1,e)}function l(e){slideTimeout=setTimeout(function(){slideInterval=setInterval(function(){f(e)},r.intervalTime)},r.startTime)}function c(t){var n=e('<ul class="jSliderNav" />').addClass(r.controlPos).appendTo(t.find(".jSliderWrap"));var s;for(s=1;s<=i;s++){e("<a />",{text:s,href:"#"}).appendTo(e("<li/>").appendTo(n))}n.find("li:first-child a").addClass("jSactive")}function h(t){t.find("ul.jSliderNav a").on("click",function(n){n.preventDefault();var i=e(this).parent().index();t.find(".jSliderWrap").animate({marginLeft:-i*r.width+"px"});s=i+1;a(i,t);p();l(t)})}function p(){clearInterval(slideInterval);clearTimeout(slideTimeout)}var r=e.extend({},t,n);switch(r.captionPos){case"right":r.captionPos="jSright";break;default:r.captionPos="jSleft"}switch(r.controlPos){case"tr":r.controlPos="jStr";break;case"br":r.controlPos="jSbr";break;case"tl":r.controlPos="jStl";break;default:r.controlPos="jSbl"}var i=r.images[0].length;var s=1;var o;return this.each(function(){u(e(this));c(e(this));l(e(this));h(e(this))})}})(jQuery,window,document)