ok
Direktori : /home/pequenacapitolio/www/js/libs/ |
Current File : /home/pequenacapitolio/www/js/libs/jquery.mb-comingsoon.min.js |
/** * COMINGSOON COUNTER 1.2 * https://github.com/magicbruno/mb-comingsoon * Copyright 2014 Bruno Milgiaretti http://www.sisteminterattivi.org * Licensed under MIT http://opensource.org/licenses/MIT */ (function(n) { var t; t = function(t, i) { this.$el = n(t); this.end = i.expiryDate; this.interval = i.interval; this.speed = i.speed; this.timer = 0; this.callBack = jQuery.isFunction(i.callBack) ? i.callBack : null; this.localization = { days: "days", hours: "hours", minutes: "minutes", seconds: "seconds" }; n.extend(this.localization, this.localization, i.localization) }; t.prototype = { getCounterNumbers: function() { var n = { days: { tens: 0, units: 0, hundreds: 0 }, hours: { tens: 0, units: 0 }, minutes: { tens: 0, units: 0 }, seconds: { tens: 0, units: 0 } }, s = 864e5, h = 36e5, c = 6e4, t = 0, l = new Date, i = this.end.getTime() - l.getTime(), r, u, f, e, o; return i <= 0 ? n : (r = Math.min(Math.floor(i / s), 999), t = i % s, n.days.hundreds = Math.floor(r / 100), u = r % 100, n.days.tens = Math.floor(u / 10), n.days.units = u % 10, f = Math.floor(t / h), t = t % h, n.hours.tens = Math.floor(f / 10), n.hours.units = f % 10, e = Math.floor(t / c), t = t % c, n.minutes.tens = Math.floor(e / 10), n.minutes.units = e % 10, o = Math.floor(t / 1e3), n.seconds.tens = Math.floor(o / 10), n.seconds.units = o % 10, n) }, updatePart: function(t) { var r = this.getCounterNumbers(), i = n("." + t, this.$el), u, f; t == "days" && (this.setDayHundreds(r.days.hundreds > 0), i.find(".number.hundreds.show").html() != r[t].hundreds && (u = n(".n1.hundreds", i), f = n(".n2.hundreds", i), this.scrollNumber(u, f, r[t].hundreds))); i.find(".number.tens.show").html() != r[t].tens && (u = n(".n1.tens", i), f = n(".n2.tens", i), this.scrollNumber(u, f, r[t].tens)); i.find(".number.units.show").html() != r[t].units && (u = n(".n1.units", i), f = n(".n2.units", i), this.scrollNumber(u, f, r[t].units)) }, timeOut: function() { var n = new Date, t = this.end.getTime() - n.getTime(); return t <= 0 ? !0 : !1 }, setDayHundreds: function(t) { t ? n(".counter.days", this.$el).addClass("with-hundreds") : n(".counter.days", this.$el).removeClass("with-hundreds") }, updateCounter: function() { this.updatePart("days"); this.updatePart("hours"); this.updatePart("minutes"); this.updatePart("seconds"); this.timeOut() && (this.stop(), this.callBack && this.callBack(this)) }, localize: function(t) { n.isPlainObject(t) && n.extend(this.localization, this.localization, t); n(".days", this.$el).siblings(".counter-caption").text(this.localization.days); n(".hours", this.$el).siblings(".counter-caption").text(this.localization.hours); n(".minutes", this.$el).siblings(".counter-caption").text(this.localization.minutes); n(".seconds", this.$el).siblings(".counter-caption").text(this.localization.seconds) }, start: function() { var n = this; n.stop(); n.timer == 0 && (n.timer = setInterval(function() { n.updateCounter() }, n.interval)); n.updateCounter() }, stop: function() { this.timer > 0 && (clearInterval(this.timer), this.timer = 0) }, scrollNumber: function(n, t, i) { n.hasClass("show") ? (t.removeClass("hidden-down").css("top", "-100%").text(i).stop().animate({ top: 0 }, this.speed, function() { t.addClass("show") }), n.stop().animate({ top: "100%" }, this.speed, function() { n.removeClass("show").addClass("hidden-down") })) : (n.removeClass("hidden-down").css("top", "-100%").text(i).stop().animate({ top: 0 }, this.speed, function() { n.addClass("show") }), t.stop().animate({ top: "100%" }, this.speed, function() { t.removeClass("show").addClass("hidden-down") })) } }; jQuery.fn.mbComingsoon = function(i) { var u = { interval: 1e3, callBack: null, localization: { days: "dias", hours: "horas", minutes: "minutos", seconds: "segundos" }, speed: 500 }, r = {}, f = ' <div class="counter-group" id="myCounter"> <div class="counter-block"> <div class="counter days"> <div class="number show n1 hundreds">0<\/div> <div class="number show n1 tens">0<\/div> <div class="number show n1 units">0<\/div> <div class="number hidden-up n2 hundreds">0<\/div> <div class="number hidden-up n2 tens">0<\/div> <div class="number hidden-up n2 units">0<\/div> <\/div> <div class="counter-caption">days<\/div> <\/div> <div class="counter-block"> <div class="counter hours"> <div class="number show n1 tens">0<\/div> <div class="number show n1 units">0<\/div> <div class="number hidden-up n2 tens">0<\/div> <div class="number hidden-up n2 units">0<\/div> <\/div> <div class="counter-caption">hours<\/div> <\/div> <div class="counter-block"> <div class="counter minutes"> <div class="number show n1 tens">0<\/div> <div class="number show n1 units">0<\/div> <div class="number hidden-up n2 tens">0<\/div> <div class="number hidden-up n2 units">0<\/div> <\/div> <div class="counter-caption">minutes<\/div> <\/div> <div class="counter-block"> <div class="counter seconds"> <div class="number show n1 tens">0<\/div> <div class="number show n1 units">0<\/div> <div class="number hidden-up n2 tens">0<\/div> <div class="number hidden-up n2 units">0<\/div> <\/div> <div class="counter-caption">seconds<\/div> <\/div> <\/div>'; return this.each(function() { var o = n(this), e = o.data("mbComingsoon"); if (typeof e == "undefined") { if (i instanceof Date ? r.expiryDate = i : n.isPlainObject(i) ? n.extend(r, u, i) : typeof i == "string" && (r.expiryDate = new Date(i)), !r.expiryDate) throw new Error("Expiry date is required!"); e = new t(o, r); o.data("mbComingsoon", e); o.html(f); e.localize(); e.start() } else i == "start" ? e.start() : i == "stop" ? e.stop() : n.isPlainObject(i) && (i.expiryDate instanceof Date && (e.end = i.expiryDate), n.isNumeric(i.interval) && (e.interval = i.interval), n.isFunction(i.callBack) && (e.callBack = i.callBack), n.isPlainObject(i.localization) && this.localize(i.localization), e.start()) }) } })(jQuery);