Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*<script type="text/javascript" charset="utf-8">*/
- /* * *
- * Auto-slide the Twenty Eleven Featured Posts Slider v3.1
- * with pause on mouse hover over featured content and
- * slide precursor button blinking.
- * By RavanH -- http://4visions.nl/?p=1001 --
- * Special thanks to Tim Down's setTimeout wrapper script
- * http://stackoverflow.com/a/3969760/573224
- *
- * Paste code in a text widget in the Showcase Sidebar.
- * Adapt variables 'slide_speed' and 'slide_delay' to change
- * the slider effect and timeout speed in milliseconds.
- * The variable 'slide_delay_first' is meant for the first
- * timeout during which page elements like images are still
- * loading which usually needs some extra time while
- * slide_effect and slide_easing control more advanced slider
- * behaviour. Change slide_precursor_time/speed to control
- * blinking of the upcoming slide dot (button).
- * Read the instructions next to the available options.
- */
- (function($) {
- /* change these settings to your liking */
- var slide_delay = 5000; /* timeouts in ms */
- var slide_delay_first = 6000; /* first timeout in ms */
- var slide_effect = 'slide'; /* available options are 'slide', 'fade' or '' (default) */
- var slide_easing = 'swing'; /* available options are 'linear' or 'swing' */
- var slide_speed = 300; /* slide effect speed in ms */
- var slide_precursor_time = 1250 ; /* precursor blinking time in ms (0 is OFF) */
- var slide_precursor_speed = 300; /* precursor blink speed in ms */
- /* do not edit below here, unless you know what you're doing */
- var slide_precursor_timer = new Timer(function(){slide_preCursor($('nav.feature-slider a.active').parent().next().children().first());},slide_delay_first-slide_precursor_time);
- var slide_timer = new Timer(function(){slide_goOut($('section.featured-post').filter(':visible'),$('nav.feature-slider a.active').parent().next().children().first());},slide_delay_first);
- $('section.featured-post').hover(function(){slide_precursor_timer.pause();slide_timer.pause();},function(){slide_precursor_timer.resume();slide_timer.resume();}).slice(1).css('display','none');
- $('.feature-slider a').click(function() {
- slide_precursor_timer.clear();
- slide_timer.clear();
- var obj = $(this.hash);
- obj.css('opacity',1);
- var next_link = $(this).parent().next().children().first();
- if (next_link.length == 0) {
- next_link = $('nav.feature-slider a').first();
- }
- if (slide_effect == 'slide') {
- obj.slideDown(slide_speed, slide_easing, function(){slide_precursor_timer.clear();slide_precursor_timer = new Timer(function(){slide_preCursor(next_link);},slide_delay-slide_precursor_time);slide_timer = new Timer(function(){slide_goOut(obj,next_link);},slide_delay);} );
- } else if (slide_effect == 'fade') {
- obj.fadeIn(slide_speed, slide_easing, function(){slide_precursor_timer.clear();slide_precursor_timer = new Timer(function(){slide_preCursor(next_link);},slide_delay-slide_precursor_time);slide_timer = new Timer(function(){slide_goOut(obj,next_link);},slide_delay);} );
- } else {
- obj.show(slide_speed, slide_easing, function(){slide_precursor_timer.clear();slide_precursor_timer = new Timer(function(){slide_preCursor(next_link);},slide_delay-slide_precursor_time);slide_timer = new Timer(function(){slide_goOut(obj,next_link);},slide_delay);} );
- }
- });
- function slide_goOut(obj,link) {
- slide_precursor_timer.clear();
- if (link.length !== 0) {
- if (slide_effect == 'slide') {
- obj.slideUp(slide_speed, slide_easing, function(){link.trigger('click');});
- } else if (slide_effect == 'fade') {
- obj.fadeOut(slide_speed, slide_easing, function(){link.trigger('click');});
- } else {
- obj.hide(slide_speed, slide_easing, function(){link.trigger('click');});
- }
- }
- }
- function slide_preCursor(link) {
- slide_precursor_timer.clear();
- slide_precursor_timer = new Timer(function(){slide_preCursor(link);},slide_precursor_speed);
- link.toggleClass('active');
- }
- function Timer(callback,delay) {
- var timerid, start, remaining = delay;
- this.clear = function() {
- window.clearTimeout(timerid);
- }
- this.pause = function() {
- this.clear();
- remaining -= new Date() - start;
- };
- this.resume = function() {
- this.clear(); /* make sure we are not resuming without having cleared */
- start = new Date();
- timerid = window.setTimeout(callback, remaining);
- };
- this.resume();
- }
- })(jQuery);
- /*</script>*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement