Browse Source

Remove couple unnecessary things and uses $slide instead of 'img' now everywhere. Also combines $pagination with the previous 'var' statement.

pull/2/merge
Viljami S 13 years ago
parent
commit
5b0e6037e0
  1. 30
      responsiveslides.js

30
responsiveslides.js

@ -18,22 +18,23 @@
$.extend(settings, options); $.extend(settings, options);
} }
// Don't run if there's only one image
if ($this.find('img').length <= 1) {
return;
}
var slideshow = function () { var slideshow = function () {
var $slides = $this.find('img'); var $slide = $this.find('img'),
$pagination = $('<ul class="' + settings.namespace + '_tabs" />');
// Don't run if there's only one slide
if ($this.find($slide).length <= 1) {
return;
}
$slides.each(function (i) { $slide.each(function (i) {
var $el = $(this); var $el = $(this);
$el.attr({ $el.attr({
id : settings.namespace + '_slide' + i id : settings.namespace + '_slide' + i
}); });
}); });
$slides.css({ $slide.css({
top: 0, top: 0,
left: 0, left: 0,
width: '100%', width: '100%',
@ -50,7 +51,7 @@
position: 'relative' position: 'relative'
}); });
// Dirty attempt to fix the height // Dirty fix for the height
heightFix = [ heightFix = [
'<style>', '<style>',
'.' + settings.namespace + '_visible {', '.' + settings.namespace + '_visible {',
@ -61,23 +62,20 @@
].join(''); ].join('');
$('head').append(heightFix); $('head').append(heightFix);
$this.find($slide + ':gt(0)').hide();
// Auto: true // Auto: true
if (settings.auto === true) { if (settings.auto === true) {
$this.find('img:gt(0)').hide();
setInterval(function () { setInterval(function () {
$this.find(':first-child').fadeOut(parseFloat(settings.fade)) $this.find(':first-child').fadeOut(parseFloat(settings.fade))
.next('img').fadeIn(parseFloat(settings.fade)) .next($slide).fadeIn(parseFloat(settings.fade))
.addClass(settings.namespace + '_visible').end().appendTo($this) .addClass(settings.namespace + '_visible').end().appendTo($this)
.removeClass(settings.namespace + '_visible'); .removeClass(settings.namespace + '_visible');
}, parseFloat(settings.speed)); }, parseFloat(settings.speed));
// Auto: false // Auto: false
} else { } else {
var $pagination = $('<ul class="' + settings.namespace + '_tabs" />'); $slide.each(function (i) {
$this.find('img:gt(0)').hide();
$slides.each(function (i) {
var whichSlide = i + 1; var whichSlide = i + 1;
tabMarkup = [ tabMarkup = [
'<li>', '<li>',

Loading…
Cancel
Save