Browse Source

New fix for the height + "active" class now uses the settings.namespace. Fixes #1

pull/2/merge
Viljami S 13 years ago
parent
commit
e3dea2df16
  1. 69
      responsiveslides.js
  2. 4
      responsiveslides.pack.js

69
responsiveslides.js

@ -1,4 +1,4 @@
/*! ResponsiveSlides.js v1.0. (c) 2011 Viljami Salminen. MIT License. http://responsive-slides.viljamis.com */
/*! ResponsiveSlides.js v1.01. (c) 2011 Viljami Salminen. MIT License. http://responsive-slides.viljamis.com */
(function ($) {
$.fn.responsiveSlides = function (options) {
@ -19,8 +19,17 @@
}
var slideshow = function () {
var $slide = $this.find('img'),
$pagination = $('<ul class="' + settings.namespace + '_tabs" />');
$pagination = $('<ul class="' + settings.namespace + '_tabs" />'),
visible = {
'position': 'relative',
'float': 'left'
},
hidden = {
'position': 'absolute',
'float': 'none'
};
// Don't run if there's only one slide
if ($this.find($slide).length <= 1) {
@ -35,41 +44,34 @@
});
$slide.css({
top: 0,
left: 0,
width: '100%',
height: 'inherit',
position: 'absolute'
'top': 0,
'left': 0,
'width': '100%',
'height': 'inherit',
'position': 'absolute'
});
$this.find(':first-child').addClass(settings.namespace + '_visible');
$this.find(':first-child')
.addClass(settings.namespace + '_visible')
.css(visible);
$this.css({
'max-width': parseFloat(settings.maxwidth),
width: '100%',
overflow: 'hidden',
position: 'relative'
'width': '100%',
'overflow': 'hidden',
'position': 'relative'
});
// Dirty fix for the height
heightFix = [
'<style>',
'.' + settings.namespace + '_visible {',
'position: relative !important;',
'float: left !important;',
'}',
'</style>'
].join('');
$('head').append(heightFix);
$this.find($slide + ':gt(0)').hide();
// Auto: true
if (settings.auto === true) {
setInterval(function () {
$this.find(':first-child').fadeOut(parseFloat(settings.fade))
.next($slide).fadeIn(parseFloat(settings.fade))
.addClass(settings.namespace + '_visible').end().appendTo($this)
$this.find(':first-child').fadeOut(parseFloat(settings.fade), function () {
$(this).css(hidden);
}).next($slide).fadeIn(parseFloat(settings.fade), function () {
$(this).css(visible);
}).addClass(settings.namespace + '_visible').end().appendTo($this)
.removeClass(settings.namespace + '_visible');
}, parseFloat(settings.speed));
@ -87,8 +89,7 @@
});
$this.after($pagination);
$('.' + settings.namespace + '_slide1').parent().addClass('active');
$('.' + settings.namespace + '_slide1').parent().addClass(settings.namespace + '_active');
$('.' + settings.namespace + '_tabs a').each(function (i) {
var $el = $(this);
@ -100,20 +101,24 @@
return false;
}
if (!($el.parent().hasClass('active'))) {
$('.' + settings.namespace + '_tabs li').removeClass('active');
if (!($el.parent().hasClass(settings.namespace + '_active'))) {
$('.' + settings.namespace + '_tabs li').removeClass(settings.namespace + '_active');
$('.' + settings.namespace + '_visible').stop()
.fadeOut(parseFloat(settings.fade), function () {
$(this).removeClass(settings.namespace + '_visible');
$(this)
.removeClass(settings.namespace + '_visible')
.css(hidden);
}).end();
$('#' + settings.namespace + '_slide' + i).stop()
.fadeIn(parseFloat(settings.fade), function () {
$(this).addClass(settings.namespace + '_visible');
$(this)
.addClass(settings.namespace + '_visible')
.css(visible);
}).end();
$el.parent().addClass('active');
$el.parent().addClass(settings.namespace + '_active');
}
});

4
responsiveslides.pack.js

@ -1,2 +1,2 @@
/*! ResponsiveSlides.js v1.0. (c) 2011 Viljami Salminen. MIT License. http://responsive-slides.viljamis.com */
(function(a){a.fn.responsiveSlides=function(b){var c={speed:4e3,fade:1e3,auto:true,maxwidth:"none",namespace:"responsiveSlides"};return this.each(function(){var d=a(this);if(b){a.extend(c,b)}var e=function(){var b=d.find("img"),e=a('<ul class="'+c.namespace+'_tabs" />');if(d.find(b).length<=1){return}b.each(function(b){var d=a(this);d.attr({id:c.namespace+"_slide"+b})});b.css({top:0,left:0,width:"100%",height:"inherit",position:"absolute"});d.find(":first-child").addClass(c.namespace+"_visible");d.css({"max-width":parseFloat(c.maxwidth),width:"100%",overflow:"hidden",position:"relative"});heightFix=["<style>","."+c.namespace+"_visible {","position: relative !important;","float: left !important;","}","</style>"].join("");a("head").append(heightFix);d.find(b+":gt(0)").hide();if(c.auto===true){setInterval(function(){d.find(":first-child").fadeOut(parseFloat(c.fade)).next(b).fadeIn(parseFloat(c.fade)).addClass(c.namespace+"_visible").end().appendTo(d).removeClass(c.namespace+"_visible")},parseFloat(c.speed))}else{b.each(function(a){var b=a+1;tabMarkup=["<li>",'<a href="#'+c.namespace+"_slide"+b+'"','class="'+c.namespace+"_slide"+b+'">'+b+"</a>","</li>"].join("");e.append(tabMarkup)});d.after(e);a("."+c.namespace+"_slide1").parent().addClass("active");a("."+c.namespace+"_tabs a").each(function(b){var d=a(this);d.click(function(e){e.preventDefault();if(a("."+c.namespace+"_visible:animated").length){return false}if(!d.parent().hasClass("active")){a("."+c.namespace+"_tabs li").removeClass("active");a("."+c.namespace+"_visible").stop().fadeOut(parseFloat(c.fade),function(){a(this).removeClass(c.namespace+"_visible")}).end();a("#"+c.namespace+"_slide"+b).stop().fadeIn(parseFloat(c.fade),function(){a(this).addClass(c.namespace+"_visible")}).end();d.parent().addClass("active")}})})}};var f=function(){if(b.maxwidth){if(typeof document.body.style.maxHeight!=="undefined"&&typeof document.body.style.minHeight!=="undefined"){return false}else{d.each(function(){d.css("width","100%");if(d.width()>parseFloat(c.maxwidth)){d.css("width",parseFloat(c.maxwidth))}else if(d.width()<parseFloat(c.maxwidth)){d.css("width","100%")}})}}};e();f();a(window).resize(function(){f()})})}})(jQuery)
/*! ResponsiveSlides.js v1.01. (c) 2011 Viljami Salminen. MIT License. http://responsive-slides.viljamis.com */
(function(a){a.fn.responsiveSlides=function(b){var c={speed:4e3,fade:1e3,auto:true,maxwidth:"none",namespace:"responsiveSlides"};return this.each(function(){var d=a(this);if(b){a.extend(c,b)}var e=function(){var b=d.find("img"),e=a('<ul class="'+c.namespace+'_tabs" />'),f={position:"relative","float":"left"},g={position:"absolute","float":"none"};if(d.find(b).length<=1){return}b.each(function(b){var d=a(this);d.attr({id:c.namespace+"_slide"+b})});b.css({top:0,left:0,width:"100%",height:"inherit",position:"absolute"});d.find(":first-child").addClass(c.namespace+"_visible").css(f);d.css({"max-width":parseFloat(c.maxwidth),width:"100%",overflow:"hidden",position:"relative"});d.find(b+":gt(0)").hide();if(c.auto===true){setInterval(function(){d.find(":first-child").fadeOut(parseFloat(c.fade),function(){a(this).css(g)}).next(b).fadeIn(parseFloat(c.fade),function(){a(this).css(f)}).addClass(c.namespace+"_visible").end().appendTo(d).removeClass(c.namespace+"_visible")},parseFloat(c.speed))}else{b.each(function(a){var b=a+1;tabMarkup=["<li>",'<a href="#'+c.namespace+"_slide"+b+'"','class="'+c.namespace+"_slide"+b+'">'+b+"</a>","</li>"].join("");e.append(tabMarkup)});d.after(e);a("."+c.namespace+"_slide1").parent().addClass(c.namespace+"_active");a("."+c.namespace+"_tabs a").each(function(b){var d=a(this);d.click(function(e){e.preventDefault();if(a("."+c.namespace+"_visible:animated").length){return false}if(!d.parent().hasClass(c.namespace+"_active")){a("."+c.namespace+"_tabs li").removeClass(c.namespace+"_active");a("."+c.namespace+"_visible").stop().fadeOut(parseFloat(c.fade),function(){a(this).removeClass(c.namespace+"_visible").css(g)}).end();a("#"+c.namespace+"_slide"+b).stop().fadeIn(parseFloat(c.fade),function(){a(this).addClass(c.namespace+"_visible").css(f)}).end();d.parent().addClass(c.namespace+"_active")}})})}};var f=function(){if(b.maxwidth){if(typeof document.body.style.maxHeight!=="undefined"&&typeof document.body.style.minHeight!=="undefined"){return false}else{d.each(function(){d.css("width","100%");if(d.width()>parseFloat(c.maxwidth)){d.css("width",parseFloat(c.maxwidth))}else if(d.width()<parseFloat(c.maxwidth)){d.css("width","100%")}})}}};e();f();a(window).resize(function(){f()})})}})(jQuery);
Loading…
Cancel
Save