Advertisement
Guest User

Untitled

a guest
May 23rd, 2014
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*!
  2.  * jQuery-runner - v2.3.0 - 2014-03-04
  3.  * https://github.com/jylauril/jquery-runner/
  4.  * Copyright (c) 2014 Jyrki Laurila <https://github.com/jylauril>
  5.  */
  6. (function () {
  7.     var a, b, c, d, e, f, g, h;
  8.     if (c = {
  9.         version: "2.3.0",
  10.         name: "jQuery-runner"
  11.     }, e = {}, h = 1, d = function (a) {
  12.         return (10 > a ? "0" : "") + a
  13.     }, f = function () {
  14.         return "runner" + h++
  15.     }, g = function (a, b) {
  16.         return a["webkitR" + b] || a["r" + b] || a["mozR" + b] || a["msR" + b] || function (a) {
  17.             return setTimeout(a, 30)
  18.         }
  19.     }(this, "equestAnimationFrame"), b = function (a, b) {
  20.         var c, e, f, g, h, i, j, k, l, m, n;
  21.         for (b = b || {}, k = [36e5, 6e4, 1e3, 10], i = ["", ":", ":", "."], h = "", g = "", f = b.milliseconds, e = k.length, l = 0, 0 > a && (a = Math.abs(a), h = "-"), c = m = 0, n = k.length; n > m; c = ++m) j = k[c], l = 0, a >= j && (l = Math.floor(a / j), a -= l * j), (l || c > 1 || g) && (c !== e - 1 || f) && (g += (g ? i[c] : "") + d(l));
  22.         return h + g
  23.     }, a = function () {
  24.         function a(b, c, d) {
  25.             var g;
  26.             return this instanceof a ? (this.items = b, g = this.id = f(), this.settings = $.extend({}, this.settings, c), e[g] = this, b.each(function (a, b) {
  27.                 $(b).data("runner", g)
  28.             }), this.value(this.settings.startAt), void((d || this.settings.autostart) && this.start())) : new a(b, c, d)
  29.         }
  30.         return a.prototype.running = !1, a.prototype.updating = !1, a.prototype.finished = !1, a.prototype.interval = null, a.prototype.total = 0, a.prototype.lastTime = 0, a.prototype.startTime = 0, a.prototype.lastLap = 0, a.prototype.lapTime = 0, a.prototype.settings = {
  31.             autostart: !1,
  32.             countdown: !1,
  33.             stopAt: null,
  34.             startAt: 0,
  35.             milliseconds: !0,
  36.             format: null
  37.         }, a.prototype.value = function (a) {
  38.             this.items.each(function (b) {
  39.                 return function (c, d) {
  40.                     var e;
  41.                     c = $(d), e = c.is("input") ? "val" : "text", c[e](b.format(a))
  42.                 }
  43.             }(this))
  44.         }, a.prototype.format = function (a) {
  45.             var c;
  46.             return c = this.settings.format, (c = $.isFunction(c) ? c : b)(a, this.settings)
  47.         }, a.prototype.update = function () {
  48.             var a, b, c, d, e;
  49.             this.updating || (this.updating = !0, c = this.settings, e = $.now(), d = c.stopAt, a = c.countdown, b = e - this.lastTime, this.lastTime = e, a ? this.total -= b : this.total += b, null !== d && (a && this.total <= d || !a && this.total >= d) && (this.total = d, this.finished = !0, this.stop(), this.fire("runnerFinish")), this.value(this.total), this.updating = !1)
  50.         }, a.prototype.fire = function (a) {
  51.             this.items.trigger(a, this.info())
  52.         }, a.prototype.start = function () {
  53.             var a;
  54.             this.running || (this.running = !0, (!this.startTime || this.finished) && this.reset(), this.lastTime = $.now(), a = function (b) {
  55.                 return function () {
  56.                     b.running && (b.update(), g(a))
  57.                 }
  58.             }(this), g(a), this.fire("runnerStart"))
  59.         }, a.prototype.stop = function () {
  60.             this.running && (this.running = !1, this.update(), this.fire("runnerStop"))
  61.         }, a.prototype.toggle = function () {
  62.             this.running ? this.stop() : this.start()
  63.         }, a.prototype.lap = function () {
  64.             var a, b;
  65.             return b = this.lastTime, a = b - this.lapTime, this.settings.countdown && (a = -a), (this.running || a) && (this.lastLap = a, this.lapTime = b), b = this.format(this.lastLap), this.fire("runnerLap"), b
  66.         }, a.prototype.reset = function (a) {
  67.             var b;
  68.             a && this.stop(), b = $.now(), "number" != typeof this.settings.startAt || this.settings.countdown || (b -= this.settings.startAt), this.startTime = this.lapTime = this.lastTime = b, this.total = this.settings.startAt, this.value(this.total), this.finished = !1, this.fire("runnerReset")
  69.         }, a.prototype.info = function () {
  70.             var a;
  71.             return a = this.lastLap || 0, {
  72.                 running: this.running,
  73.                 finished: this.finished,
  74.                 time: this.total,
  75.                 formattedTime: this.format(this.total),
  76.                 startTime: this.startTime,
  77.                 lapTime: a,
  78.                 formattedLapTime: this.format(a),
  79.                 settings: this.settings
  80.             }
  81.         }, a
  82.     }(), !this.$) throw new Error("[" + c.name + "] jQuery library is required for this plugin to work");
  83.     this.$.fn.runner = function (b, d, f) {
  84.         var g, h;
  85.         switch (b || (b = "init"), "object" == typeof b && (f = d, d = b, b = "init"), g = this.data("runner"), h = g ? e[g] : !1, b) {
  86.             case "init":
  87.                 new a(this, d, f);
  88.                 break;
  89.             case "info":
  90.                 if (h) return h.info();
  91.                 break;
  92.             case "reset":
  93.                 h && h.reset(d);
  94.                 break;
  95.             case "lap":
  96.                 if (h) return h.lap();
  97.                 break;
  98.             case "start":
  99.             case "stop":
  100.             case "toggle":
  101.                 if (h) return h[b]();
  102.                 break;
  103.             case "version":
  104.                 return c.version;
  105.             default:
  106.                 $.error("[" + c.name + "] Method " + b + " does not exist")
  107.         }
  108.         return this
  109.     }, this.$.fn.runner.format = b
  110. }).call(this);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement