Browse Source

optimizations for minification

pull/2/head
Tuomas Salo 13 years ago
parent
commit
52a16fa4d6
  1. 69
      responsiveslides.js

69
responsiveslides.js

@ -21,7 +21,13 @@
var slideshow = function () { var slideshow = function () {
var $slide = $this.find('img'), var $slide = $this.find('img'),
$pagination = $('<ul class="' + settings.namespace + '_tabs" />'),
// just for minification:
namespace_prefix = settings.namespace,
maxwidth = parseFloat(settings.maxwidth),
fade = parseFloat(settings.fade),
$pagination = $('<ul class="' + namespace_prefix + '_tabs"/>'),
visible = { visible = {
'position': 'relative', 'position': 'relative',
'float': 'left' 'float': 'left'
@ -37,10 +43,7 @@
} }
$slide.each(function (i) { $slide.each(function (i) {
var $el = $(this); this.id = namespace_prefix + '_slide' + i;
$el.attr({
id : settings.namespace + '_slide' + i
});
}); });
$slide.css({ $slide.css({
@ -52,7 +55,7 @@
}); });
$this.find(':first-child') $this.find(':first-child')
.addClass(settings.namespace + '_visible') .addClass(namespace_prefix + '_visible')
.css(visible); .css(visible);
$this.css({ $this.css({
@ -67,58 +70,58 @@
// Auto: true // Auto: true
if (settings.auto === true) { if (settings.auto === true) {
setInterval(function () { setInterval(function () {
$this.find(':first-child').fadeOut(parseFloat(settings.fade), function () { $this.find(':first-child').fadeOut(fade, function () {
$(this).css(hidden); $(this).css(hidden);
}).next($slide).fadeIn(parseFloat(settings.fade), function () { }).next($slide).fadeIn(fade, function () {
$(this).css(visible); $(this).css(visible);
}).addClass(settings.namespace + '_visible').end().appendTo($this) }).addClass(namespace_prefix + '_visible').end().appendTo($this)
.removeClass(settings.namespace + '_visible'); .removeClass(namespace_prefix + '_visible');
}, parseFloat(settings.speed)); }, parseFloat(settings.speed));
// Auto: false // Auto: false
} else { } else {
$slide.each(function (i) { $slide.each(function (i) {
var whichSlide = i + 1; var whichSlide = i + 1,
tabMarkup = [ tabMarkup =
'<li>', '<li>' +
'<a href="#' + settings.namespace + '_slide' + whichSlide + '"', '<a href="#' + namespace_prefix + '_slide' + whichSlide + '"' +
'class="' + settings.namespace + '_slide' + whichSlide + '">' + whichSlide + '</a>', 'class="' + namespace_prefix + '_slide' + whichSlide + '">' + whichSlide + '</a>' +
'</li>' '</li>'
].join(''); ;
$pagination.append(tabMarkup); $pagination.append(tabMarkup);
}); });
$this.after($pagination); $this.after($pagination);
$('.' + settings.namespace + '_slide1').parent().addClass(settings.namespace + '_active'); $('.' + namespace_prefix + '_slide1').parent().addClass(namespace_prefix + '_active');
$('.' + settings.namespace + '_tabs a').each(function (i) { $('.' + namespace_prefix + '_tabs a').each(function (i) {
var $el = $(this); var $el = $(this);
$el.click(function (e) { $el.click(function (e) {
e.preventDefault(); e.preventDefault();
// Prevent clicking if animated // Prevent clicking if animated
if ($('.' + settings.namespace + '_visible:animated').length) { if ($('.' + namespace_prefix + '_visible:animated').length) {
return false; return false;
} }
if (!($el.parent().hasClass(settings.namespace + '_active'))) { if (!($el.parent().hasClass(namespace_prefix + '_active'))) {
$('.' + settings.namespace + '_tabs li').removeClass(settings.namespace + '_active'); $('.' + namespace_prefix + '_tabs li').removeClass(namespace_prefix + '_active');
$('.' + settings.namespace + '_visible').stop() $('.' + namespace_prefix + '_visible').stop()
.fadeOut(parseFloat(settings.fade), function () { .fadeOut(fade, function () {
$(this) $(this)
.removeClass(settings.namespace + '_visible') .removeClass(namespace_prefix + '_visible')
.css(hidden); .css(hidden);
}).end(); }).end();
$('#' + settings.namespace + '_slide' + i).stop() $('#' + namespace_prefix + '_slide' + i).stop()
.fadeIn(parseFloat(settings.fade), function () { .fadeIn(fade, function () {
$(this) $(this)
.addClass(settings.namespace + '_visible') .addClass(namespace_prefix + '_visible')
.css(visible); .css(visible);
}).end(); }).end();
$el.parent().addClass(settings.namespace + '_active'); $el.parent().addClass(namespace_prefix + '_active');
} }
}); });
@ -129,14 +132,12 @@
// Fallback to make IE6 support CSS max-width // Fallback to make IE6 support CSS max-width
var widthSupport = function () { var widthSupport = function () {
if (options.maxwidth) { if (options.maxwidth) {
if (typeof document.body.style.maxHeight !== 'undefined' && typeof document.body.style.minHeight !== 'undefined') { if (typeof document.body.style.maxHeight === 'undefined' || typeof document.body.style.minHeight === 'undefined') {
return false;
} else {
$this.each(function () { $this.each(function () {
$this.css('width', '100%'); $this.css('width', '100%');
if ($this.width() > parseFloat(settings.maxwidth)) { if ($this.width() > maxwidth) {
$this.css('width', parseFloat(settings.maxwidth)); $this.css('width', maxwidth);
} else if ($this.width() < parseFloat(settings.maxwidth)) { } else if ($this.width() < maxwidth) {
$this.css('width', '100%'); $this.css('width', '100%');
} }
}); });

Loading…
Cancel
Save