all2aller

Wanker Responsive Show

Aug 11th, 2014
545
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 1.82 KB | None | 0 0
  1. jQuery(function () {
  2.         jQuery('.responsive-takeover').wanker({
  3.             delay: 1000,
  4.             duration: 2000,
  5. });
  6. });
  7.  
  8. (function () {
  9.     (function ($) {
  10.         return $.fn.wanker = function (options) {
  11.             var settings;
  12.             settings = $.extend({
  13.                 delay: 1000,
  14.                 duration: 1500
  15.             }, options);
  16.             return this.each(function () {
  17.                 var $message, elapsed, fired, mobile, reset, start, timer;
  18.                 $message = $(this);
  19.                 mobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
  20.                 if (!mobile) {
  21.                     fired = false;
  22.                     start = null;
  23.                     elapsed = null;
  24.                     timer = null;
  25.                     reset = function () {
  26.                         fired = false;
  27.                         return elapsed = null;
  28.                     };
  29.                     return $(window).resize(function () {
  30.                         if (fired) {
  31.                             elapsed = Math.abs(new Date() - start);
  32.                         } else {
  33.                             start = new Date();
  34.                             fired = true;
  35.                         }
  36.                         if (elapsed > settings.delay) {
  37.                             $message.fadeIn();
  38.                         }
  39.                         if (timer) {
  40.                             clearTimeout(timer);
  41.                         }
  42.                         return timer = setTimeout(function () {
  43.                             $message.fadeOut();
  44.                             return reset();
  45.                         }, settings.duration);
  46.                     });
  47.                 }
  48.             });
  49.         };
  50.     })(jQuery);
  51. }).call(this);;
Advertisement
Add Comment
Please, Sign In to add comment