From 147f8fa5f5ecd0b18c30f3490ff92518061b17f7 Mon Sep 17 00:00:00 2001 From: Adam Schwartz Date: Mon, 13 Jul 2015 20:17:55 -0400 Subject: [PATCH] v0.7.13 --- README.md | 2 +- bower.json | 2 +- docs/welcome/index.html | 2 +- offline.js | 76 ++++++++++++++++++++--------------------- offline.min.js | 2 +- package.json | 2 +- 6 files changed, 43 insertions(+), 43 deletions(-) diff --git a/README.md b/README.md index 0428e57..88b00da 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Click Install to see a live preview of Offline on your website. Manual Installation ------------------- -Include [the javascript](https://raw.github.com/HubSpot/offline/v0.7.11/offline.min.js), one of [the themes](http://github.hubspot.com/offline/docs/welcome/), and one of [the +Include [the javascript](https://raw.github.com/HubSpot/offline/v0.7.13/offline.min.js), one of [the themes](http://github.hubspot.com/offline/docs/welcome/), and one of [the languages](https://github.com/HubSpot/offline/tree/master/themes) on your site. You're done! To use only the JavaScript API without a UI indicator, simply leave out the CSS file. diff --git a/bower.json b/bower.json index 1c400b0..cb139a3 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "offline", - "version": "0.7.12", + "version": "0.7.13", "homepage": "http://github.hubspot.com/offline/docs/welcome", "authors": [ "Zack Bloom ", diff --git a/docs/welcome/index.html b/docs/welcome/index.html index 6e4b089..c7eb9f9 100644 --- a/docs/welcome/index.html +++ b/docs/welcome/index.html @@ -355,7 +355,7 @@

Install



Download

-

Offline.js

+

Offline.js


Pick a Theme

diff --git a/offline.js b/offline.js index 623d6b8..bd95c44 100644 --- a/offline.js +++ b/offline.js @@ -1,4 +1,4 @@ -/*! offline-js 0.7.12 */ +/*! offline-js 0.7.13 */ (function() { var Offline, checkXHR, defaultOptions, extendNative, grab, handlers, init; extendNative = function(to, from) { @@ -30,22 +30,22 @@ reconnect:!0 }, grab = function(obj, key) { var cur, i, j, len, part, parts; - for (cur = obj, parts = key.split("."), i = j = 0, len = parts.length; len > j && (part = parts[i], + for (cur = obj, parts = key.split("."), i = j = 0, len = parts.length; len > j && (part = parts[i], cur = cur[part], "object" == typeof cur); i = ++j) ; return i === parts.length - 1 ? cur :void 0; }, Offline.getOption = function(key) { var ref, val; - return val = null != (ref = grab(Offline.options, key)) ? ref :grab(defaultOptions, key), + return val = null != (ref = grab(Offline.options, key)) ? ref :grab(defaultOptions, key), "function" == typeof val ? val() :val; }, "function" == typeof window.addEventListener && window.addEventListener("online", function() { return setTimeout(Offline.confirmUp, 100); }, !1), "function" == typeof window.addEventListener && window.addEventListener("offline", function() { return Offline.confirmDown(); }, !1), Offline.state = "up", Offline.markUp = function() { - return Offline.trigger("confirmed-up"), "up" !== Offline.state ? (Offline.state = "up", + return Offline.trigger("confirmed-up"), "up" !== Offline.state ? (Offline.state = "up", Offline.trigger("up")) :void 0; }, Offline.markDown = function() { - return Offline.trigger("confirmed-down"), "down" !== Offline.state ? (Offline.state = "down", + return Offline.trigger("confirmed-down"), "down" !== Offline.state ? (Offline.state = "down", Offline.trigger("down")) :void 0; }, handlers = {}, Offline.on = function(event, handler, ctx) { var e, events, j, len, results; @@ -58,7 +58,7 @@ var _handler, ctx, i, ref, results; if (null != handlers[event]) { if (handler) { - for (i = 0, results = []; i < handlers[event].length; ) ref = handlers[event][i], + for (i = 0, results = []; i < handlers[event].length; ) ref = handlers[event][i], ctx = ref[0], _handler = ref[1], _handler === handler ? results.push(handlers[event].splice(i, 1)) :results.push(i++); return results; } @@ -67,7 +67,7 @@ }, Offline.trigger = function(event) { var ctx, handler, j, len, ref, ref1, results; if (null != handlers[event]) { - for (ref = handlers[event], results = [], j = 0, len = ref.length; len > j; j++) ref1 = ref[j], + for (ref = handlers[event], results = [], j = 0, len = ref.length; len > j; j++) ref1 = ref[j], ctx = ref1[0], handler = ref1[1], results.push(handler.call(ctx)); return results; } @@ -86,8 +86,8 @@ }); }, Offline.checks = {}, Offline.checks.xhr = function() { var e, xhr; - xhr = new XMLHttpRequest(), xhr.offline = !1, xhr.open("HEAD", Offline.getOption("checks.xhr.url"), !0), - null != xhr.timeout && (xhr.timeout = Offline.getOption("checks.xhr.timeout")), + xhr = new XMLHttpRequest(), xhr.offline = !1, xhr.open("HEAD", Offline.getOption("checks.xhr.url"), !0), + null != xhr.timeout && (xhr.timeout = Offline.getOption("checks.xhr.timeout")), checkXHR(xhr, Offline.markUp, Offline.markDown); try { xhr.send(); @@ -97,7 +97,7 @@ return xhr; }, Offline.checks.image = function() { var img; - return img = document.createElement("img"), img.onerror = Offline.markDown, img.onload = Offline.markUp, + return img = document.createElement("img"), img.onerror = Offline.markDown, img.onload = Offline.markUp, void (img.src = Offline.getOption("checks.image.url")); }, Offline.checks.down = Offline.markDown, Offline.checks.up = Offline.markUp, Offline.check = function() { return Offline.trigger("checking"), Offline.checks[Offline.getOption("checks.active")](); @@ -118,13 +118,13 @@ }; }, _XMLHttpRequest = window.XMLHttpRequest, window.XMLHttpRequest = function(flags) { var _overrideMimeType, _setRequestHeader, req; - return req = new _XMLHttpRequest(flags), monitorXHR(req, flags), _setRequestHeader = req.setRequestHeader, + return req = new _XMLHttpRequest(flags), monitorXHR(req, flags), _setRequestHeader = req.setRequestHeader, req.headers = {}, req.setRequestHeader = function(name, value) { return req.headers[name] = value, _setRequestHeader.call(req, name, value); }, _overrideMimeType = req.overrideMimeType, req.overrideMimeType = function(type) { return req.mimeType = type, _overrideMimeType.call(req, type); }, req; - }, extendNative(window.XMLHttpRequest, _XMLHttpRequest), null != window.XDomainRequest ? (_XDomainRequest = window.XDomainRequest, + }, extendNative(window.XMLHttpRequest, _XMLHttpRequest), null != window.XDomainRequest ? (_XDomainRequest = window.XDomainRequest, window.XDomainRequest = function() { var req; return req = new _XDomainRequest(), monitorXHR(req), req; @@ -140,37 +140,37 @@ if (!window.Offline) throw new Error("Offline Reconnect brought in without offline.js"); rc = Offline.reconnect = {}, retryIntv = null, reset = function() { var ref; - return null != rc.state && "inactive" !== rc.state && Offline.trigger("reconnect:stopped"), + return null != rc.state && "inactive" !== rc.state && Offline.trigger("reconnect:stopped"), rc.state = "inactive", rc.remaining = rc.delay = null != (ref = Offline.getOption("reconnect.initialDelay")) ? ref :3; }, next = function() { var delay, ref; - return delay = null != (ref = Offline.getOption("reconnect.delay")) ? ref :Math.min(Math.ceil(1.5 * rc.delay), 3600), + return delay = null != (ref = Offline.getOption("reconnect.delay")) ? ref :Math.min(Math.ceil(1.5 * rc.delay), 3600), rc.remaining = rc.delay = delay; }, tick = function() { - return "connecting" !== rc.state ? (rc.remaining -= 1, Offline.trigger("reconnect:tick"), + return "connecting" !== rc.state ? (rc.remaining -= 1, Offline.trigger("reconnect:tick"), 0 === rc.remaining ? tryNow() :void 0) :void 0; }, tryNow = function() { - return "waiting" === rc.state ? (Offline.trigger("reconnect:connecting"), rc.state = "connecting", + return "waiting" === rc.state ? (Offline.trigger("reconnect:connecting"), rc.state = "connecting", Offline.check()) :void 0; }, down = function() { - return Offline.getOption("reconnect") ? (reset(), rc.state = "waiting", Offline.trigger("reconnect:started"), + return Offline.getOption("reconnect") ? (reset(), rc.state = "waiting", Offline.trigger("reconnect:started"), retryIntv = setInterval(tick, 1e3)) :void 0; }, up = function() { return null != retryIntv && clearInterval(retryIntv), reset(); }, nope = function() { - return Offline.getOption("reconnect") && "connecting" === rc.state ? (Offline.trigger("reconnect:failure"), + return Offline.getOption("reconnect") && "connecting" === rc.state ? (Offline.trigger("reconnect:failure"), rc.state = "waiting", next()) :void 0; - }, rc.tryNow = tryNow, reset(), Offline.on("down", down), Offline.on("confirmed-down", nope), + }, rc.tryNow = tryNow, reset(), Offline.on("down", down), Offline.on("confirmed-down", nope), Offline.on("up", up); }.call(this), function() { var clear, flush, held, holdRequest, makeRequest, waitingOnConfirm; if (!window.Offline) throw new Error("Requests module brought in without offline.js"); held = [], waitingOnConfirm = !1, holdRequest = function(req) { - return Offline.trigger("requests:capture"), "down" !== Offline.state && (waitingOnConfirm = !0), + return Offline.trigger("requests:capture"), "down" !== Offline.state && (waitingOnConfirm = !0), held.push(req); }, makeRequest = function(arg) { var body, name, password, ref, type, url, user, val, xhr; - xhr = arg.xhr, url = arg.url, type = arg.type, user = arg.user, password = arg.password, + xhr = arg.xhr, url = arg.url, type = arg.type, user = arg.user, password = arg.password, body = arg.body, xhr.abort(), xhr.open(type, url, !0, user, password), ref = xhr.headers; for (name in ref) val = ref[name], xhr.setRequestHeader(name, val); return xhr.mimeType && xhr.overrideMimeType(xhr.mimeType), xhr.send(body); @@ -178,7 +178,7 @@ return held = []; }, flush = function() { var i, key, len, request, requests, url; - for (Offline.trigger("requests:flush"), requests = {}, i = 0, len = held.length; len > i; i++) request = held[i], + for (Offline.trigger("requests:flush"), requests = {}, i = 0, len = held.length; len > i; i++) request = held[i], url = request.url.replace(/(\?|&)_=[0-9]+/, function(match, char) { return "?" === char ? char :""; }), requests[request.type.toUpperCase() + " - " + url] = request; @@ -195,10 +195,10 @@ return holdRequest(request); }, _send = xhr.send, xhr.send = function(body) { return request.body = body, _send.apply(xhr, arguments); - }, async) ? null === xhr.onprogress ? (xhr.addEventListener("error", hold, !1), - xhr.addEventListener("timeout", hold, !1)) :(_onreadystatechange = xhr.onreadystatechange, + }, async) ? null === xhr.onprogress ? (xhr.addEventListener("error", hold, !1), + xhr.addEventListener("timeout", hold, !1)) :(_onreadystatechange = xhr.onreadystatechange, xhr.onreadystatechange = function() { - return 0 === xhr.readyState ? hold() :4 === xhr.readyState && (0 === xhr.status || xhr.status >= 12e3) && hold(), + return 0 === xhr.readyState ? hold() :4 === xhr.readyState && (0 === xhr.status || xhr.status >= 12e3) && hold(), "function" == typeof _onreadystatechange ? _onreadystatechange.apply(null, arguments) :void 0; }) :void 0; }), Offline.requests = { @@ -209,13 +209,13 @@ }.call(this), function() { var base, i, len, ref, state; if (!Offline) throw new Error("Offline simulate brought in without offline.js"); - for (ref = [ "up", "down" ], i = 0, len = ref.length; len > i; i++) state = ref[i], - (document.querySelector("script[data-simulate='" + state + "']") || localStorage.OFFLINE_SIMULATE === state) && (null == Offline.options && (Offline.options = {}), + for (ref = [ "up", "down" ], i = 0, len = ref.length; len > i; i++) state = ref[i], + (document.querySelector("script[data-simulate='" + state + "']") || localStorage.OFFLINE_SIMULATE === state) && (null == Offline.options && (Offline.options = {}), null == (base = Offline.options).checks && (base.checks = {}), Offline.options.checks.active = state); }.call(this), function() { var RETRY_TEMPLATE, TEMPLATE, _onreadystatechange, addClass, content, createFromHTML, el, flashClass, flashTimeouts, init, removeClass, render, roundTime; if (!window.Offline) throw new Error("Offline UI brought in without offline.js"); - TEMPLATE = '
', + TEMPLATE = '
', RETRY_TEMPLATE = '', createFromHTML = function(html) { var el; return el = document.createElement("div"), el.innerHTML = html, el.children[0]; @@ -224,7 +224,7 @@ }, removeClass = function(name) { return el.className = el.className.replace(new RegExp("(^| )" + name.split(" ").join("|") + "( |$)", "gi"), " "); }, flashTimeouts = {}, flashClass = function(name, time) { - return addClass(name), null != flashTimeouts[name] && clearTimeout(flashTimeouts[name]), + return addClass(name), null != flashTimeouts[name] && clearTimeout(flashTimeouts[name]), flashTimeouts[name] = setTimeout(function() { return removeClass(name), delete flashTimeouts[name]; }, 1e3 * time); @@ -236,39 +236,39 @@ minute:60, second:1 }; - for (unit in units) if (mult = units[unit], sec >= mult) return val = Math.floor(sec / mult), + for (unit in units) if (mult = units[unit], sec >= mult) return val = Math.floor(sec / mult), [ val, unit ]; return [ "now", "" ]; }, render = function() { var button, handler; - return el = createFromHTML(TEMPLATE), document.body.appendChild(el), null != Offline.reconnect && Offline.getOption("reconnect") && (el.appendChild(createFromHTML(RETRY_TEMPLATE)), + return el = createFromHTML(TEMPLATE), document.body.appendChild(el), null != Offline.reconnect && Offline.getOption("reconnect") && (el.appendChild(createFromHTML(RETRY_TEMPLATE)), button = el.querySelector(".offline-ui-retry"), handler = function(e) { return e.preventDefault(), Offline.reconnect.tryNow(); - }, null != button.addEventListener ? button.addEventListener("click", handler, !1) :button.attachEvent("click", handler)), + }, null != button.addEventListener ? button.addEventListener("click", handler, !1) :button.attachEvent("click", handler)), addClass("offline-ui-" + Offline.state), content = el.querySelector(".offline-ui-content"); }, init = function() { return render(), Offline.on("up", function() { - return removeClass("offline-ui-down"), addClass("offline-ui-up"), flashClass("offline-ui-up-2s", 2), + return removeClass("offline-ui-down"), addClass("offline-ui-up"), flashClass("offline-ui-up-2s", 2), flashClass("offline-ui-up-5s", 5); }), Offline.on("down", function() { - return removeClass("offline-ui-up"), addClass("offline-ui-down"), flashClass("offline-ui-down-2s", 2), + return removeClass("offline-ui-up"), addClass("offline-ui-down"), flashClass("offline-ui-down-2s", 2), flashClass("offline-ui-down-5s", 5); }), Offline.on("reconnect:connecting", function() { return addClass("offline-ui-connecting"), removeClass("offline-ui-waiting"); }), Offline.on("reconnect:tick", function() { var ref, time, unit; - return addClass("offline-ui-waiting"), removeClass("offline-ui-connecting"), ref = roundTime(Offline.reconnect.remaining), - time = ref[0], unit = ref[1], content.setAttribute("data-retry-in-value", time), + return addClass("offline-ui-waiting"), removeClass("offline-ui-connecting"), ref = roundTime(Offline.reconnect.remaining), + time = ref[0], unit = ref[1], content.setAttribute("data-retry-in-value", time), content.setAttribute("data-retry-in-unit", unit); }), Offline.on("reconnect:stopped", function() { - return removeClass("offline-ui-connecting offline-ui-waiting"), content.setAttribute("data-retry-in-value", null), + return removeClass("offline-ui-connecting offline-ui-waiting"), content.setAttribute("data-retry-in-value", null), content.setAttribute("data-retry-in-unit", null); }), Offline.on("reconnect:failure", function() { return flashClass("offline-ui-reconnect-failed-2s", 2), flashClass("offline-ui-reconnect-failed-5s", 5); }), Offline.on("reconnect:success", function() { return flashClass("offline-ui-reconnect-succeeded-2s", 2), flashClass("offline-ui-reconnect-succeeded-5s", 5); }); - }, "complete" === document.readyState ? init() :null != document.addEventListener ? document.addEventListener("DOMContentLoaded", init, !1) :(_onreadystatechange = document.onreadystatechange, + }, "complete" === document.readyState ? init() :null != document.addEventListener ? document.addEventListener("DOMContentLoaded", init, !1) :(_onreadystatechange = document.onreadystatechange, document.onreadystatechange = function() { return "complete" === document.readyState && init(), "function" == typeof _onreadystatechange ? _onreadystatechange.apply(null, arguments) :void 0; }); diff --git a/offline.min.js b/offline.min.js index 71eabf6..d46b5cf 100644 --- a/offline.min.js +++ b/offline.min.js @@ -1,2 +1,2 @@ -/*! offline-js 0.7.12 */ +/*! offline-js 0.7.13 */ (function(){var a,b,c,d,e,f,g;d=function(a,b){var c,d,e,f;e=[];for(d in b.prototype)try{f=b.prototype[d],null==a[d]&&"function"!=typeof f?e.push(a[d]=f):e.push(void 0)}catch(g){c=g}return e},a={},null==a.options&&(a.options={}),c={checks:{xhr:{url:function(){return"/favicon.ico?_="+Math.floor(1e9*Math.random())},timeout:5e3},image:{url:function(){return"/favicon.ico?_="+Math.floor(1e9*Math.random())}},active:"xhr"},checkOnLoad:!1,interceptRequests:!0,reconnect:!0},e=function(a,b){var c,d,e,f,g,h;for(c=a,h=b.split("."),d=e=0,f=h.length;f>e&&(g=h[d],c=c[g],"object"==typeof c);d=++e);return d===h.length-1?c:void 0},a.getOption=function(b){var d,f;return f=null!=(d=e(a.options,b))?d:e(c,b),"function"==typeof f?f():f},"function"==typeof window.addEventListener&&window.addEventListener("online",function(){return setTimeout(a.confirmUp,100)},!1),"function"==typeof window.addEventListener&&window.addEventListener("offline",function(){return a.confirmDown()},!1),a.state="up",a.markUp=function(){return a.trigger("confirmed-up"),"up"!==a.state?(a.state="up",a.trigger("up")):void 0},a.markDown=function(){return a.trigger("confirmed-down"),"down"!==a.state?(a.state="down",a.trigger("down")):void 0},f={},a.on=function(b,c,d){var e,g,h,i,j;if(g=b.split(" "),g.length>1){for(j=[],h=0,i=g.length;i>h;h++)e=g[h],j.push(a.on(e,c,d));return j}return null==f[b]&&(f[b]=[]),f[b].push([d,c])},a.off=function(a,b){var c,d,e,g,h;if(null!=f[a]){if(b){for(e=0,h=[];ed;d++)h=g[d],b=h[0],c=h[1],i.push(c.call(b));return i}},b=function(a,b,c){var d,e,f,g,h;return h=function(){return a.status&&a.status<12e3?b():c()},null===a.onprogress?(d=a.onerror,a.onerror=function(){return c(),"function"==typeof d?d.apply(null,arguments):void 0},g=a.ontimeout,a.ontimeout=function(){return c(),"function"==typeof g?g.apply(null,arguments):void 0},e=a.onload,a.onload=function(){return h(),"function"==typeof e?e.apply(null,arguments):void 0}):(f=a.onreadystatechange,a.onreadystatechange=function(){return 4===a.readyState?h():0===a.readyState&&c(),"function"==typeof f?f.apply(null,arguments):void 0})},a.checks={},a.checks.xhr=function(){var c,d;d=new XMLHttpRequest,d.offline=!1,d.open("HEAD",a.getOption("checks.xhr.url"),!0),null!=d.timeout&&(d.timeout=a.getOption("checks.xhr.timeout")),b(d,a.markUp,a.markDown);try{d.send()}catch(e){c=e,a.markDown()}return d},a.checks.image=function(){var b;return b=document.createElement("img"),b.onerror=a.markDown,b.onload=a.markUp,void(b.src=a.getOption("checks.image.url"))},a.checks.down=a.markDown,a.checks.up=a.markUp,a.check=function(){return a.trigger("checking"),a.checks[a.getOption("checks.active")]()},a.confirmUp=a.confirmDown=a.check,a.onXHR=function(a){var b,c,e;return e=function(b,c){var d;return d=b.open,b.open=function(e,f,g,h,i){return a({type:e,url:f,async:g,flags:c,user:h,password:i,xhr:b}),d.apply(b,arguments)}},c=window.XMLHttpRequest,window.XMLHttpRequest=function(a){var b,d,f;return f=new c(a),e(f,a),d=f.setRequestHeader,f.headers={},f.setRequestHeader=function(a,b){return f.headers[a]=b,d.call(f,a,b)},b=f.overrideMimeType,f.overrideMimeType=function(a){return f.mimeType=a,b.call(f,a)},f},d(window.XMLHttpRequest,c),null!=window.XDomainRequest?(b=window.XDomainRequest,window.XDomainRequest=function(){var a;return a=new b,e(a),a},d(window.XDomainRequest,b)):void 0},g=function(){return a.getOption("interceptRequests")&&a.onXHR(function(c){var d;return d=c.xhr,d.offline!==!1?b(d,a.markUp,a.confirmDown):void 0}),a.getOption("checkOnLoad")?a.check():void 0},setTimeout(g,0),window.Offline=a}).call(this),function(){var a,b,c,d,e,f,g,h,i;if(!window.Offline)throw new Error("Offline Reconnect brought in without offline.js");d=Offline.reconnect={},f=null,e=function(){var a;return null!=d.state&&"inactive"!==d.state&&Offline.trigger("reconnect:stopped"),d.state="inactive",d.remaining=d.delay=null!=(a=Offline.getOption("reconnect.initialDelay"))?a:3},b=function(){var a,b;return a=null!=(b=Offline.getOption("reconnect.delay"))?b:Math.min(Math.ceil(1.5*d.delay),3600),d.remaining=d.delay=a},g=function(){return"connecting"!==d.state?(d.remaining-=1,Offline.trigger("reconnect:tick"),0===d.remaining?h():void 0):void 0},h=function(){return"waiting"===d.state?(Offline.trigger("reconnect:connecting"),d.state="connecting",Offline.check()):void 0},a=function(){return Offline.getOption("reconnect")?(e(),d.state="waiting",Offline.trigger("reconnect:started"),f=setInterval(g,1e3)):void 0},i=function(){return null!=f&&clearInterval(f),e()},c=function(){return Offline.getOption("reconnect")&&"connecting"===d.state?(Offline.trigger("reconnect:failure"),d.state="waiting",b()):void 0},d.tryNow=h,e(),Offline.on("down",a),Offline.on("confirmed-down",c),Offline.on("up",i)}.call(this),function(){var a,b,c,d,e,f;if(!window.Offline)throw new Error("Requests module brought in without offline.js");c=[],f=!1,d=function(a){return Offline.trigger("requests:capture"),"down"!==Offline.state&&(f=!0),c.push(a)},e=function(a){var b,c,d,e,f,g,h,i,j;j=a.xhr,g=a.url,f=a.type,h=a.user,d=a.password,b=a.body,j.abort(),j.open(f,g,!0,h,d),e=j.headers;for(c in e)i=e[c],j.setRequestHeader(c,i);return j.mimeType&&j.overrideMimeType(j.mimeType),j.send(b)},a=function(){return c=[]},b=function(){var b,d,f,g,h,i;for(Offline.trigger("requests:flush"),h={},b=0,f=c.length;f>b;b++)g=c[b],i=g.url.replace(/(\?|&)_=[0-9]+/,function(a,b){return"?"===b?b:""}),h[g.type.toUpperCase()+" - "+i]=g;for(d in h)g=h[d],e(g);return a()},setTimeout(function(){return Offline.getOption("requests")!==!1?(Offline.on("confirmed-up",function(){return f?(f=!1,a()):void 0}),Offline.on("up",b),Offline.on("down",function(){return f=!1}),Offline.onXHR(function(a){var b,c,e,f,g;return g=a.xhr,e=a.async,g.offline!==!1&&(f=function(){return d(a)},c=g.send,g.send=function(b){return a.body=b,c.apply(g,arguments)},e)?null===g.onprogress?(g.addEventListener("error",f,!1),g.addEventListener("timeout",f,!1)):(b=g.onreadystatechange,g.onreadystatechange=function(){return 0===g.readyState?f():4===g.readyState&&(0===g.status||g.status>=12e3)&&f(),"function"==typeof b?b.apply(null,arguments):void 0}):void 0}),Offline.requests={flush:b,clear:a}):void 0},0)}.call(this),function(){var a,b,c,d,e;if(!Offline)throw new Error("Offline simulate brought in without offline.js");for(d=["up","down"],b=0,c=d.length;c>b;b++)e=d[b],(document.querySelector("script[data-simulate='"+e+"']")||localStorage.OFFLINE_SIMULATE===e)&&(null==Offline.options&&(Offline.options={}),null==(a=Offline.options).checks&&(a.checks={}),Offline.options.checks.active=e)}.call(this),function(){var a,b,c,d,e,f,g,h,i,j,k,l,m;if(!window.Offline)throw new Error("Offline UI brought in without offline.js");b='
',a='',f=function(a){var b;return b=document.createElement("div"),b.innerHTML=a,b.children[0]},g=e=null,d=function(a){return k(a),g.className+=" "+a},k=function(a){return g.className=g.className.replace(new RegExp("(^| )"+a.split(" ").join("|")+"( |$)","gi")," ")},i={},h=function(a,b){return d(a),null!=i[a]&&clearTimeout(i[a]),i[a]=setTimeout(function(){return k(a),delete i[a]},1e3*b)},m=function(a){var b,c,d,e;d={day:86400,hour:3600,minute:60,second:1};for(c in d)if(b=d[c],a>=b)return e=Math.floor(a/b),[e,c];return["now",""]},l=function(){var c,h;return g=f(b),document.body.appendChild(g),null!=Offline.reconnect&&Offline.getOption("reconnect")&&(g.appendChild(f(a)),c=g.querySelector(".offline-ui-retry"),h=function(a){return a.preventDefault(),Offline.reconnect.tryNow()},null!=c.addEventListener?c.addEventListener("click",h,!1):c.attachEvent("click",h)),d("offline-ui-"+Offline.state),e=g.querySelector(".offline-ui-content")},j=function(){return l(),Offline.on("up",function(){return k("offline-ui-down"),d("offline-ui-up"),h("offline-ui-up-2s",2),h("offline-ui-up-5s",5)}),Offline.on("down",function(){return k("offline-ui-up"),d("offline-ui-down"),h("offline-ui-down-2s",2),h("offline-ui-down-5s",5)}),Offline.on("reconnect:connecting",function(){return d("offline-ui-connecting"),k("offline-ui-waiting")}),Offline.on("reconnect:tick",function(){var a,b,c;return d("offline-ui-waiting"),k("offline-ui-connecting"),a=m(Offline.reconnect.remaining),b=a[0],c=a[1],e.setAttribute("data-retry-in-value",b),e.setAttribute("data-retry-in-unit",c)}),Offline.on("reconnect:stopped",function(){return k("offline-ui-connecting offline-ui-waiting"),e.setAttribute("data-retry-in-value",null),e.setAttribute("data-retry-in-unit",null)}),Offline.on("reconnect:failure",function(){return h("offline-ui-reconnect-failed-2s",2),h("offline-ui-reconnect-failed-5s",5)}),Offline.on("reconnect:success",function(){return h("offline-ui-reconnect-succeeded-2s",2),h("offline-ui-reconnect-succeeded-5s",5)})},"complete"===document.readyState?j():null!=document.addEventListener?document.addEventListener("DOMContentLoaded",j,!1):(c=document.onreadystatechange,document.onreadystatechange=function(){return"complete"===document.readyState&&j(),"function"==typeof c?c.apply(null,arguments):void 0})}.call(this); \ No newline at end of file diff --git a/package.json b/package.json index cc3ff99..2c75fcb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "offline-js", - "version": "0.7.12", + "version": "0.7.13", "description": "Automatically detect when a browser is offline", "authors": [ "Adam Schwartz ",