Guest User

Untitled

a guest
Jan 21st, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. /*
  2. * jquery.vslb.js
  3. * とてもシンプルなLightBoxプラグイン
  4. * Version : 0.1.1 rev1
  5. * Copyright : ww24
  6. * License : MIT License
  7. */
  8. (function ($) {
  9. var count = 0;
  10. $.fn.vslb = function (options) {
  11. options = options ? options : {};
  12. var $target = $(this);
  13. if ($target.parent().attr("class") !== "slightbox-lb") {
  14. var zIndex = options.zIndex ? options.zIndex : 0 + count++,
  15. $win = $(window),
  16. $lb = $target.wrap('<div class="slightbox-lb" />').parent();
  17. $("body").append('<div class="slightbox-bg" title="close" />')
  18. .find(".slightbox-bg:last-child").click(function () {
  19. count--;
  20. $(this).remove();
  21. $target.unwrap();
  22. if (options.close) {
  23. options.close();
  24. }
  25. }).css({
  26. zIndex: zIndex++,
  27. opacity: 0
  28. }).animate({opacity: 0.8});
  29. $lb.css({
  30. width: $lb.width(),
  31. height: $lb.height(),
  32. left: $win.width() / 2 - $lb.outerWidth() / 2 + $win.scrollLeft(),
  33. top: $win.height() / 2 - $lb.outerHeight() / 2 + $win.scrollTop(),
  34. zIndex: zIndex,
  35. display: "none"
  36. }).fadeIn("normal", function () {
  37. if (options.open) {
  38. options.open();
  39. }
  40. });
  41. }
  42. return this;
  43. };
  44. })(jQuery);
Add Comment
Please, Sign In to add comment