Advertisement
Guest User

Untitled

a guest
Jul 24th, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. /**
  2. * jQuery mousehold plugin - fires an event while the mouse is clicked down.
  3. * Additionally, the function, when executed, is passed a single
  4. * argument representing the count of times the event has been fired during
  5. * this session of the mouse hold.
  6. *
  7. * @author Remy Sharp (leftlogic.com)
  8. * @date 2006-12-15
  9. * @example $("img").mousehold(200, function(i){ })
  10. * @desc Repeats firing the passed function while the mouse is clicked down
  11. *
  12. * @name mousehold
  13. * @type jQuery
  14. * @param Number timeout The frequency to repeat the event in milliseconds
  15. * @param Function fn A function to execute
  16. * @cat Plugin
  17. */
  18.  
  19. jQuery.fn.mousehold = function(timeout, f) {
  20. if (timeout && typeof timeout == 'function') {
  21. f = timeout;
  22. timeout = 100;
  23. }
  24. if (f && typeof f == 'function') {
  25. var timer = 0;
  26. var fireStep = 0;
  27. return this.each(function() {
  28. jQuery(this).mousedown(function() {
  29. fireStep = 1;
  30. var ctr = 0;
  31. timer = setInterval(function() {
  32. ctr++;
  33. f.call(this, ctr);
  34. fireStep = 2;
  35. }, timeout);
  36. })
  37.  
  38. clearMousehold = function() {
  39. clearInterval(timer);
  40. if (fireStep == 1) f.call(this, 1);
  41. fireStep = 0;
  42. }
  43.  
  44. jQuery(this).mouseout(clearMousehold);
  45. jQuery(this).mouseup(clearMousehold);
  46. })
  47. }
  48. }
  49.  
  50. /*
  51. FILE ARCHIVED ON 19:26:43 Mar 22, 2007 AND RETRIEVED FROM THE
  52. INTERNET ARCHIVE ON 12:09:59 Jul 12, 2019.
  53. JAVASCRIPT APPENDED BY WAYBACK MACHINE, COPYRIGHT INTERNET ARCHIVE.
  54.  
  55. ALL OTHER CONTENT MAY ALSO BE PROTECTED BY COPYRIGHT (17 U.S.C.
  56. SECTION 108(a)(3)).
  57. */
  58. /*
  59. playback timings (ms):
  60. LoadShardBlock: 89.01 (3)
  61. esindex: 0.005
  62. captures_list: 259.465
  63. CDXLines.iter: 13.582 (3)
  64. PetaboxLoader3.datanode: 96.816 (4)
  65. exclusion.robots: 129.595
  66. xauthn.chkprivs: 0.055
  67. exclusion.robots.policy: 129.58
  68. RedisCDXSource: 2.629
  69. PetaboxLoader3.resolve: 38.856
  70. xauthn.identify: 129.271
  71. load_resource: 49.372
  72. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement