Bittle icon

Main Page jQuery

Bittle | PRO | 09/11/17 06:59:24 PM UTC | 0 ⭐ | 269 👁️ | Never ⏰ | []
jQuery |

1.37 KB

|

None

|

0 👍

/

0 👎

$(function() {
 
  $(".dropdown-toggle").on("mouseenter", function() {
    $(this).css("cursor", "pointer");
    var menu = $(this).parent().find(".dropdown-menu");
 
    if (!menu.is(":visible")) {
      menu.show();
    }
  });
 
  $(".dropdown-toggle").on("click", function() {
    var menu = $(this).parent().find(".dropdown-menu");
 
    if (menu.is(":visible")) {
      menu.hide();
      $(this).blur();
    } else {
      menu.show();
    }
  });
 
  $(".dropdown").on("mouseleave", function() {
    var menu = $(this).find(".dropdown-menu");
    $(this).blur();
    if (menu.is(":visible")) {
      menu.hide();
    }
  });
 
  var swapTimer = 5000; // must be >= 2500
  var maxImages = 15;
  var current = 2;
 
  // change background-image every swapTimer ms
  function nextBackground() {
    var nextImage = rand(1, maxImages);
 
    if (nextImage == current) {
      // no change
      if (nextImage > 1) {
        nextImage = rand(1, nextImage - 1);
      } else {
        nextImage = rand(nextImage + 1, maxImages);
      }
    }
 
    var image = "../images/bg/" + nextImage + ".jpg";
 
    $(".whole-screen").css("background-image", 'url("' + image + '")').animate({opacity: 1});
 
    current = nextImage;
 
    setTimeout(nextBackground, swapTimer);
  }
 
  setTimeout(nextBackground, swapTimer * 8);
 
  function rand(min, max) {
    return Math.floor(Math.random() * (max - min + 1) + min);
  }
});

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎