Plugin Directory

Changeset 1936346


Ignore:
Timestamp:
09/05/2018 04:23:38 PM (7 years ago)
Author:
Patabugen
Message:

Fixed JavaScript - which wasn't running at all. Also made the slidehosw delay be random rather than always 7 seconds.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • image-links/trunk/image-links.js

    r1935450 r1936346  
    99            $('.mha-image-link-slideshow').each(function(index, item){
    1010                $item = $(item);
    11                 setInterval(ImageLinks._imageLinkBackgroundSlideshowNextImage, 7000, $item);
     11                setTimeout(ImageLinks._imageLinkBackgroundSlideshowNextImage, ImageLinks.getRandomDelay(), $item);
    1212            });
     13        },
     14        getRandomDelay: function(min, max) {
     15            // From: https://stackoverflow.com/questions/1527803/generating-random-whole-numbers-in-javascript-in-a-specific-range#1527820
     16            var min = 2000;
     17            var max = 8000;
     18            return Math.floor(Math.random() * (max - min + 1)) + min;
    1319        },
    1420        _imageLinkBackgroundSlideshowNextImage: function($item){
     
    1723            // increment the current item.
    1824            if ( undefined === nextBackgroundIndex ) {
    19                 nextBackgroundIndex = 0;
     25                nextBackgroundIndex = 1;
    2026            }
    2127
     
    3945              return $item.animate({opacity: 1}, 750, 'linear');
    4046            });
     47            setTimeout(ImageLinks._imageLinkBackgroundSlideshowNextImage, ImageLinks.getRandomDelay(2000,8000), $item);
    4148        },
    4249    }
     50    ImageLinks.enableImageLinkBackgroundSlideshows();
    4351})(jQuery); // Fully reference jQuery after this point.
Note: See TracChangeset for help on using the changeset viewer.