/*! responsiveslides.js v1.54
* http://responsiveslides.com
* http://viljamis.com
*
* copyright (c) 2011-2012 @viljamis
* available under the mit license
*/
/*jslint browser: true, sloppy: true, vars: true, plusplus: true, indent: 4 */
(function ($, window, i) {
if($.fn.responsiveslides){
return;
}
$.fn.responsiveslides = function (options) {
options.manualcontrols = options.manualcontrols && $(this).find(options.manualcontrols);
options.navcontainer = options.navcontainer && $(this).find(options.navcontainer);
options.prevtext = options.prevtext || '«';
options.nexttext = options.nexttext || '»';
return $(this).find('ul.rslides-inner')._responsiveslides(options);
};
$.fn._responsiveslides = function (options) {
// default settings
var settings = $.extend({
"auto" : true, // boolean: animate automatically, true or false
"speed" : 500, // integer: speed of the transition, in milliseconds
"timeout" : 4000, // integer: time between slide transitions, in milliseconds
"pager" : false, // boolean: show pager, true or false
"nav" : false, // boolean: show navigation, true or false
"random" : false, // boolean: randomize the order of the slides, true or false
"pause" : false, // boolean: pause on hover, true or false
"pausecontrols" : true, // boolean: pause when hovering controls, true or false
"prevtext" : "previous", // string: text for the "previous" button
"nexttext" : "next", // string: text for the "next" button
"maxwidth" : "", // integer: max-width of the slideshow, in pixels
"maxheight" : "", // integer: max-height of the slideshow, in pixels
"navcontainer" : "", // selector: where auto generated controls should be appended to, default is after the
"manualcontrols" : "", // selector: declare custom pager navigation
"namespace" : "rslides", // string: change the default namespace used
"before" : $.noop, // function: before callback
"after" : $.noop // function: after callback
}, options);
return this.each(function () {
// index for namespacing
i++;
var $this = $(this),
// local variables
vendor,
selecttab,
startcycle,
restartcycle,
rotate,
$tabs,
// helpers
index = 0,
$slide = $this.children(),
length = $slide.size(),
fadetime = parsefloat(settings.speed),
waittime = parsefloat(settings.timeout),
maxw = parsefloat(settings.maxwidth),
maxh = parsefloat(settings.maxheight),
// namespacing
namespace = settings.namespace,
namespaceidx = namespace + i,
// classes
navclass = namespace + "-nav " + namespaceidx + "-nav",
activeclass = namespace + "-here",
visibleclass = namespaceidx + "-on",
slideclassprefix = namespaceidx + "-s",
// pager
$pager = $(""),
// styles for visible and hidden slides
visible = {
"float" : "left",
"position" : "relative",
"opacity" : 1,
"zindex" : 2
},
hidden = {
"float" : "none",
"position" : "absolute",
"opacity" : 0,
"zindex" : 1
},
// detect transition support
supportstransitions = (function () {
var docbody = document.body || document.documentelement;
var styles = docbody.style;
var prop = "transition";
if (typeof styles[prop] === "string") {
return true;
}
// tests for vendor specific prop
vendor = ["moz", "webkit", "khtml", "o", "ms"];
prop = prop.charat(0).touppercase() + prop.substr(1);
var i;
for (i = 0; i < vendor.length; i++) {
if (typeof styles[vendor[i] + prop] === "string") {
return true;
}
}
return false;
})(),
// fading animation
slideto = function (idx) {
// if css3 transitions are supported
if (supportstransitions) {
$slide
.removeclass(visibleclass)
.css(hidden)
.eq(idx)
.addclass(visibleclass)
.css(visible);
index = idx;
settimeout(function () {
settings.after(idx);
}, fadetime);
// if not, use jquery fallback
} else {
$slide
.stop()
.fadeout(fadetime, function () {
$(this)
.removeclass(visibleclass)
.css(hidden)
.css("opacity", 1);
})
.eq(idx)
.fadein(fadetime, function () {
$(this)
.addclass(visibleclass)
.css(visible);
settings.after(idx);
index = idx;
});
}
};
// random order
if (settings.random) {
$slide.sort(function () {
return (math.round(math.random()) - 0.5);
});
$this
.empty()
.append($slide);
}
// add id's to each slide
$slide.each(function (i) {
this.id = slideclassprefix + i;
});
// add max-width and classes
$this.addclass(namespace + " " + namespaceidx);
if (options && options.maxwidth) {
$this.parent().css("max-width", maxw);
}
// add max-height and classes
if (options && options.maxheight) {
$this.parent().css("max-height", maxh);
$this.css("max-height", maxh);
}
// hide all slides, then show first one
$slide
.hide()
.css(hidden)
.eq(0)
.addclass(visibleclass)
.css(visible)
.show();
// css transitions
if (supportstransitions) {
$slide
.show()
.css({
// -ms prefix isn't needed as ie10 uses prefix free version
"-webkit-transition" : "opacity " + fadetime + "ms ease-in-out",
"-moz-transition" : "opacity " + fadetime + "ms ease-in-out",
"-o-transition" : "opacity " + fadetime + "ms ease-in-out",
"transition" : "opacity " + fadetime + "ms ease-in-out"
});
}
// only run if there's more than one slide
if ($slide.size() > 1) {
// make sure the timeout is at least 100ms longer than the fade
if (waittime < fadetime + 100) {
return;
}
// pager
if (settings.pager && !settings.manualcontrols) {
var tabmarkup = [];
$slide.each(function (i) {
var n = i + 1;
tabmarkup +=
"- " +
"" + n + "" +
"
";
});
$pager.append(tabmarkup);
// inject pager
if (options.navcontainer) {
$(settings.navcontainer).append($pager);
} else {
$this.after($pager);
}
}
// manual pager controls
if (settings.manualcontrols) {
$pager = $(settings.manualcontrols);
$pager.addclass(namespace + "-tabs " + namespaceidx + "-tabs");
}
// add pager slide class prefixes
if (settings.pager || settings.manualcontrols) {
$pager.find('li').each(function (i) {
$(this).addclass(slideclassprefix + (i + 1));
});
}
// if we have a pager, we need to set up the selecttab function
if (settings.pager || settings.manualcontrols) {
$tabs = $pager.find('a');
// select pager item
selecttab = function (idx) {
$tabs
.closest("li")
.removeclass(activeclass)
.eq(idx)
.addclass(activeclass);
};
}
// auto cycle
if (settings.auto) {
startcycle = function () {
rotate = setinterval(function () {
// clear the event queue
$slide.stop(true, true);
var idx = index + 1 < length ? index + 1 : 0;
// remove active state and set new if pager is set
if (settings.pager || settings.manualcontrols) {
selecttab(idx);
}
slideto(idx);
}, waittime);
};
// init cycle
startcycle();
}
// restarting cycle
restartcycle = function () {
if (settings.auto) {
// stop
clearinterval(rotate);
// restart
startcycle();
}
};
// pause on hover
if (settings.pause) {
$this.hover(function () {
clearinterval(rotate);
}, function () {
restartcycle();
});
}
// pager click event handler
if (settings.pager || settings.manualcontrols) {
$tabs.bind("click", function (e) {
e.preventdefault();
if (!settings.pausecontrols) {
restartcycle();
}
// get index of clicked tab
var idx = $tabs.index(this);
// break if element is already active or currently animated
if (index === idx || $("." + visibleclass).queue('fx').length) {
return;
}
// remove active state from old tab and set new one
selecttab(idx);
// do the animation
slideto(idx);
})
.eq(0)
.closest("li")
.addclass(activeclass);
// pause when hovering pager
if (settings.pausecontrols) {
$tabs.hover(function () {
clearinterval(rotate);
}, function () {
restartcycle();
});
}
}
// navigation
if (settings.nav) {
var navmarkup =
"" + settings.prevtext + "" +
"" + settings.nexttext + "";
// inject navigation
if (options.navcontainer) {
$(settings.navcontainer).append(navmarkup);
} else {
$this.after(navmarkup);
}
var $trigger = $("." + namespaceidx + "-nav"),
$prev = $trigger.filter(".prev");
// click event handler
$trigger.bind("click", function (e) {
e.preventdefault();
var $visibleclass = $("." + visibleclass);
// prevent clicking if currently animated
if ($visibleclass.queue('fx').length) {
return;
}
// adds active class during slide animation
// $(this)
// .addclass(namespace + "-active")
// .delay(fadetime)
// .queue(function (next) {
// $(this).removeclass(namespace + "-active");
// next();
// });
// determine where to slide
var idx = $slide.index($visibleclass),
previdx = idx - 1,
nextidx = idx + 1 < length ? index + 1 : 0;
// go to slide
slideto($(this)[0] === $prev[0] ? previdx : nextidx);
if (settings.pager || settings.manualcontrols) {
selecttab($(this)[0] === $prev[0] ? previdx : nextidx);
}
if (!settings.pausecontrols) {
restartcycle();
}
});
// pause when hovering navigation
if (settings.pausecontrols) {
$trigger.hover(function () {
clearinterval(rotate);
}, function () {
restartcycle();
});
}
}
}
// max-width fallback
if (typeof document.body.style.maxwidth === "undefined" && options.maxwidth) {
var widthsupport = function () {
$this.parent().css("width", "100%");
if ($this.parent().width() > maxw) {
$this.parent().css("width", maxw);
}
};
// init fallback
widthsupport();
$(window).bind("resize", function () {
widthsupport();
});
}
// max-height fallback
if (typeof document.body.style.maxheight === "undefined" && options.maxheight) {
var heightsupport = function () {
$this.parent().css("height", "100%");
if ($this.parent().height() > maxh) {
$this.parent().css("height", maxh);
}
};
// init fallback
heightsupport();
$(window).bind("resize", function () {
heightsupport();
});
}
if ( options.fillheight) {
var heightsupport = function () {
var $row = $this.parent().parent().parent();
if($row.prop('classname').indexof('row')!=-1){
$this.parent().css("height",'100%');
$this.parent().css("height", $row.height());
}
};
heightsupport();
$(window).bind("resize", function () {
heightsupport();
});
}
$this.parent().addclass(namespace+"-loaded");
});
};
})(jquery, this, 0);
$(function () {
$(".rslides").not(".rslides-loaded,.rslides-inner").each(function () {
var s = $(this);
var m = s.attr("maxwidth");
var h = s.attr("maxheight");
if (s.hasclass("rslides-14")) {
s.responsiveslides({
manualcontrols : 'ul.rslides-tabs',
maxwidth : m,
maxheight : h
});
return;
}
if (s.hasclass("rslides-8") || s.hasclass("rslides-9") || s.hasclass("rslides-10") || s.hasclass("rslides-13") || s.hasclass("rslides-14")) {
s.responsiveslides({
manualcontrols : 'ul.rslides-tabs',
maxwidth : m
});
return;
}
if (s.hasclass("rslides-1") || s.hasclass("rslides-5") || s.hasclass("rslides-6")) {
s.responsiveslides({
pager : true,
maxwidth : m
});
return;
}
if (s.hasclass("rslides-12") || s.hasclass("rslides-2") || s.hasclass("rslides-3") || s.hasclass("rslides-7")) {
s.responsiveslides({
nav : true,
maxwidth : m
});
return;
}
if (s.hasclass("rslides-4")) {
s.responsiveslides({
nav : true,
pager : true,
maxwidth : m
});
return;
}
if (s.hasclass("rslides-11")) {
s.responsiveslides({
nav : true,
pager : true,
fillheight : true,
maxwidth : m
});
return;
}
});
});