Browse Source

Adds callback events, 'namespace' option and better classes for next/prev buttons

pull/25/merge
Viljami S 13 years ago
parent
commit
efc7457097
  1. 15
      responsiveslides.js
  2. 12
      responsiveslides.min.js

15
responsiveslides.js

@ -1,4 +1,4 @@
/*! http://responsive-slides.viljamis.com v1.21 by @viljamis */
/*! http://responsive-slides.viljamis.com v1.22 by @viljamis */
(function ($, window, i) {
$.fn.responsiveSlides = function (options) {
@ -11,7 +11,8 @@
"nextText": "Next", // String: Text for the "next" button
"fade": 1000, // Integer: Crossfade time, in milliseconds
"maxwidth": "none", // Integer: Max-width of the Slideshow, in pixels
"speed": 4000 // Integer: How long image shows before fading to next, in milliseconds
"speed": 4000, // Integer: How long image shows before fading to next, in milliseconds
"namespace": "rslides" // String: change the default namespace
}, options);
return this.each(function () {
@ -27,7 +28,7 @@
fadetime = parseFloat(settings.fade),
// Namespacing
namespace = "rslides",
namespace = settings.namespace,
namespaceIndex = namespace + i,
// Classes
@ -46,6 +47,7 @@
// Fading animation
var slideTo = function (idx) {
$this.trigger(namespace + "-before");
$slide
.stop()
.fadeOut(fadetime, function () {
@ -57,7 +59,8 @@
.fadeIn(fadetime, function () {
$(this)
.addClass(visibleClass)
.css(visible);
.css(visible)
.trigger(namespace + "-after");
index = idx;
});
};
@ -182,10 +185,10 @@
// Build navigation
var navMarkup =
"<a href=\"#\" title=\"" + settings.prevText + "\" class=\"" + namespaceIndex + "_nav prev\">" +
"<a href=\"#\" title=\"" + settings.prevText + "\" class=\"" + namespace + "_nav " + namespaceIndex + "_nav prev\">" +
settings.prevText +
"</a>" +
"<a href=\"#\" title=\"" + settings.nextText + "\" class=\"" + namespaceIndex + "_nav next\">" +
"<a href=\"#\" title=\"" + settings.nextText + "\" class=\"" + namespace + "_nav " + namespaceIndex + "_nav next\">" +
settings.nextText +
"</a>";

12
responsiveslides.min.js vendored

@ -1,6 +1,6 @@
/*! http://responsive-slides.viljamis.com v1.21 by @viljamis */
(function(c,y,r){c.fn.responsiveSlides=function(l){var b=c.extend({auto:!0,pagination:!1,nav:!1,prevText:"Previous",nextText:"Next",fade:1E3,maxwidth:"none",speed:4E3},l);return this.each(function(){r++;var g=c(this),h=0,e=g.children(),s=e.size(),t=parseFloat(b.fade),d="rslides"+r,m="rslides "+d,f=d+"_on",u=d+"_s",n=c('<ul class="rslides_tabs '+(d+"_tabs")+'" />'),v={"float":"left",position:"relative"},z={"float":"none",position:"absolute"},i=function(a){e.stop().fadeOut(t,function(){c(this).removeClass(f).css(z)}).eq(a).fadeIn(t,
function(){c(this).addClass(f).css(v);h=a})};if(1<e.size()){e.each(function(a){this.id=u+a});g.css("max-width",b.maxwidth).addClass(m);e.hide().eq(0).addClass(f).css(v).show();if(!0===b.pagination){var j=[];e.each(function(a){a+=1;j.push("<li>");j.push('<a href="#" class="'+u+a+'">'+a+"</a>");j.push("</li>")});n.append(j.join(""));var o=n.find("a");g.after(n)}var k=function(a){o.closest("li").removeClass("rslides_here").eq(a).addClass("rslides_here")};if(!0===b.auto){var p,w;p=function(){w=setInterval(function(){var a=
h+1<s?h+1:0;!0===b.pagination&&k(a);i(a)},parseFloat(b.speed))};p()}var q=function(){!0===b.auto&&(clearInterval(w),p())};!0===b.pagination&&o.on("click",function(a){a.preventDefault();q();a=o.index(this);if(h!==a){if(c("."+f+":animated").length)return!1;k(a);i(a)}}).eq(0).closest("li").addClass("rslides_here")}!0===b.nav&&(g.after('<a href="#" title="'+b.prevText+'" class="'+d+'_nav prev">'+b.prevText+'</a><a href="#" title="'+b.nextText+'" class="'+d+'_nav next">'+b.nextText+"</a>"),m=c("."+d+"_nav.prev"),
d=c("."+d+"_nav.next"),m.on("click",function(a){a.preventDefault();a=e.index(c("."+f))-1;if(c("."+f+":animated").length)return!1;q();i(a);!0===b.pagination&&k(a)}),d.on("click",function(a){a.preventDefault();a=e.index(c("."+f))+1<s?h+1:0;if(c("."+f+":animated").length)return!1;q();i(a);!0===b.pagination&&k(a)}));if("undefined"===typeof document.body.style.maxWidth&&l&&l.maxwidth){var x=function(){g.css("width","100%");g.width()>b.maxwidth&&g.css("width",b.maxwidth)};x();c(y).on("resize",function(){x()})}})}})(jQuery,
this,0);
/*! http://responsive-slides.viljamis.com v1.22 by @viljamis */
(function(c,A,t){c.fn.responsiveSlides=function(m){var b=c.extend({auto:!0,pagination:!1,nav:!1,prevText:"Previous",nextText:"Next",fade:1E3,maxwidth:"none",speed:4E3,namespace:"rslides"},m);return this.each(function(){t++;var e=c(this),i=0,f=e.children(),u=f.size(),v=parseFloat(b.fade),g=b.namespace,d=g+t,n=g+" "+d,o=g+"_here",h=d+"_on",w=d+"_s",p=c('<ul class="'+g+"_tabs "+(d+"_tabs")+'" />'),x={"float":"left",position:"relative"},B={"float":"none",position:"absolute"},j=function(a){e.trigger(g+
"-before");f.stop().fadeOut(v,function(){c(this).removeClass(h).css(B)}).eq(a).fadeIn(v,function(){c(this).addClass(h).css(x).trigger(g+"-after");i=a})};if(1<f.size()){f.each(function(a){this.id=w+a});e.css("max-width",b.maxwidth).addClass(n);f.hide().eq(0).addClass(h).css(x).show();if(!0===b.pagination){var k=[];f.each(function(a){a+=1;k.push("<li>");k.push('<a href="#" class="'+w+a+'">'+a+"</a>");k.push("</li>")});p.append(k.join(""));var q=p.find("a");e.after(p)}var l=function(a){q.closest("li").removeClass(o).eq(a).addClass(o)};
if(!0===b.auto){var r,y;r=function(){y=setInterval(function(){var a=i+1<u?i+1:0;!0===b.pagination&&l(a);j(a)},parseFloat(b.speed))};r()}var s=function(){!0===b.auto&&(clearInterval(y),r())};!0===b.pagination&&q.on("click",function(a){a.preventDefault();s();a=q.index(this);if(i!==a){if(c("."+h+":animated").length)return!1;l(a);j(a)}}).eq(0).closest("li").addClass(o)}!0===b.nav&&(e.after('<a href="#" title="'+b.prevText+'" class="'+g+"_nav "+d+'_nav prev">'+b.prevText+'</a><a href="#" title="'+b.nextText+
'" class="'+g+"_nav "+d+'_nav next">'+b.nextText+"</a>"),n=c("."+d+"_nav.prev"),d=c("."+d+"_nav.next"),n.on("click",function(a){a.preventDefault();a=f.index(c("."+h))-1;if(c("."+h+":animated").length)return!1;s();j(a);!0===b.pagination&&l(a)}),d.on("click",function(a){a.preventDefault();a=f.index(c("."+h))+1<u?i+1:0;if(c("."+h+":animated").length)return!1;s();j(a);!0===b.pagination&&l(a)}));if("undefined"===typeof document.body.style.maxWidth&&m&&m.maxwidth){var z=function(){e.css("width","100%");
e.width()>b.maxwidth&&e.css("width",b.maxwidth)};z();c(A).on("resize",function(){z()})}})}})(jQuery,this,0);
Loading…
Cancel
Save