1(function($){ 2 $.exitIntent = function(el, callback, options){ 3 var base = this; 4 base.delayTimer = null; 5 base.$el = $(el); 6 base.el = el; 7 base.disabled = false; 8 9 base.$el.data("exitIntent", base); 10 11 base.init = function(){ 12 base.options = $.extend({},$.exitIntent.defaultOptions, options); 13 14 base.$el.mouseleave(function(e) { 15 if (e.clientY > 0 || Math.abs(e.clientY) < base.options.minexitspeed || (base.disabled && !base.options.repeat)) return; 16 17 base.delayTimer = setTimeout(base.runCallback, base.options.delay); 18 }).mouseenter(function(event) { 19 if (base.delayTimer) { 20 clearTimeout(base.delayTimer); 21 base.delayTimer = null; 22 } 23 }); 24 if (base.options.keyboard) { 25 base.$el.keydown(function(e) { 26 if (base.disabled && !base.options.repeat) return; 27 else if (e.keyCode !== 8 && (!e.metaKey || e.keyCode !== 76)) return; 28 29 base.runCallback(); 30 }); 31 } 32 }; 33 base.runCallback = function() { 34 if (typeof callback == 'function') { 35 callback.call(this); 36 } 37 base.disabled = true; 38 }; 39 40 base.init(); 41 }; 42 43 $.exitIntent.defaultOptions = { 44 minexitspeed: 0, 45 delay: 0, 46 repeat: false, 47 keyboard: true // capture ctrl + L 48 }; 49 50 $.fn.exitIntent = function(callback, options){ 51 return this.each(function(){ 52 (new $.exitIntent(this, callback, options)); 53 }); 54 }; 55 56})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.