Advertisement
Guest User

nihua ne ponyatno blyat

a guest
Nov 13th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.06 KB | None | 0 0
  1. /** video preview */ ! function(a) {
  2. var s = null,
  3. u = null;
  4.  
  5. function r() {
  6. s && (a(s.parentNode).removeClass("preview-loading"), a(s).remove()), u && clearTimeout(u), u = s = null
  7. }
  8. a(document).on("mousemove", function(t) {
  9. if (s) {
  10. var e = a(s).offset(),
  11. n = t.pageX,
  12. o = t.pageY;
  13. (n < e.left || n > e.left + a(s).width() || o < e.top || o > e.top + a(s).height()) && r()
  14. }
  15. }), a(document).mousemove(function(t) {
  16. if (s) {
  17. var e = a(s).offset(),
  18. n = t.pageX,
  19. o = t.pageY;
  20. (n < e.left || n > e.left + a(s).width() || o < e.top || o > e.top + a(s).height()) && r()
  21. }
  22. }), a(window).on("blur", function() {
  23. r()
  24. }), a.fn.videopreview = function() {
  25. return this.each(function() {
  26. var t = this,
  27. e = a(this).attr("data-preview");
  28. if (e) {
  29. var n = function() {
  30. r(), u = setTimeout(function() {
  31. a(t.parentNode).addClass("preview-loading")
  32. }, 100), s = document.createElement("VIDEO"), a(s).css({
  33. position: "absolute",
  34. left: "0",
  35. top: "0",
  36. width: t.offsetWidth + "px",
  37. height: t.offsetHeight + "px",
  38. background: "#000000",
  39. visibility: "hidden"
  40. }), a(s).on("error", function() {
  41. r()
  42. }), a(s).on("loadeddata", function() {
  43. u && clearTimeout(u), a(s.parentNode).removeClass("preview-loading"), a(s).css({
  44. visibility: "visible"
  45. })
  46. }), s.controls = !1, s.autoplay = !0, s.muted = !0, s.loop = !0, s.src = e, s.setAttribute("webkit-playsinline", "true"), s.setAttribute("playsinline", "true"), t.parentNode.appendChild(s)
  47. };
  48. if ("ontouchstart" in document) {
  49. a(this).offsetParent().append(a('<span class="touch-preview"></span>').on("touchstart", function(t) {
  50. t.preventDefault(), n()
  51. }).on("contextmenu", function(t) {
  52. t.preventDefault()
  53. }));
  54. var o = 0,
  55. i = !1;
  56. a(this).on("touchstart", function(t) {
  57. var e = t.originalEvent ? t.originalEvent.touches : t.touches;
  58. e && e.length && (o = e[0].clientX, i = !0)
  59. }), a(this).on("touchmove", function(t) {
  60. var e = t.originalEvent ? t.originalEvent.touches : t.touches;
  61. e && e.length && i && 40 < Math.abs(o - e[0].clientX) && (n(), o = 0, i = !1)
  62. })
  63. } else a(this).mouseover(n)
  64. }
  65. }), this
  66. }
  67. }(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement