Browse files

Added a sweet PLAY button!

  • Loading branch information...
1 parent 42182a5 commit 19b015dd9b1349147a57055d44669d7712e16574 unknown committed with Aug 26, 2010
Showing with 28 additions and 9 deletions.
  1. +28 −9 jquery.fadeAble.js
View
37 jquery.fadeAble.js
@@ -5,14 +5,17 @@
prevText: 'Previous',
nextId: 'nextButton',
nextText: 'Next',
- controlsShow: true,
+ playId: 'playButton',
+ playText: 'Play/Pause',
+ controlsShow: false,
controlsFade: true,
speed: 800,
- autoPlay: false,
+ autoPlay: true,
pause: 2000,
- loop: false,
+ loop: true,
images: [],
- current: 0
+ current: 0,
+ timeoutToggle:true
};
// Set the options.
@@ -54,17 +57,20 @@
if (options.controlsShow) {
$(this).append(
- '<span class="button" style="z-index:2" id="'+options.prevId+'">' +
- '<a href=\"javascript:void(0);\">'+options.prevText +'</a></span>' +
- '<span class="button" style="z-index:2" id="'+options.nextId+'">' +
- '<a href=\"javascript:void(0);\">'+ options.nextText +'</a></span>'
+ '<div id="controls-container">'+
+ '<a class="button" id="'+options.prevId+'" href=\"javascript:void(0);\">'+options.prevText +'</a>'+
+ '<a class="button pause" id="'+options.playId+'" href=\"javascript:void(0);\">'+options.playText +'</a>'+
+ '<a class="button" id="'+options.nextId+'" href=\"javascript:void(0);\">'+ options.nextText +'</a>'+
+ '</div>'
);
$("#"+options.nextId).click(function(){ fade("next", container); });
+ $("#"+options.playId).click(function(){ toggle(container); });
$("#"+options.prevId).click(function(){ fade("prev", container); });
}
- if (options.loop) {
+ if (options.loop && options.autoplay) {
+ options.timeoutToggle = true;
options.timeout = setTimeout(function(){
fade("next", container);
}, options.pause);
@@ -99,5 +105,18 @@
}, options.pause);
}
}
+
+ function toggle (container) {
+ if (options.timeoutToggle && options.timeout) {
+ clearTimeout(options.timeout);
+ options.timeoutToggle = false;
+ } else if (!options.timeoutToggle){
+ options.timeoutToggle = true;
+ options.timeout = setTimeout(function(){
+ fade("next", container);
+ }, options.pause);
+ };
+ $('#playButton').toggleClass("play").toggleClass("pause")
+ }
};
})(jQuery);

0 comments on commit 19b015d

Please sign in to comment.