Skip to content
This repository has been archived by the owner on Jul 10, 2024. It is now read-only.

Commit

Permalink
v0.7.13
Browse files Browse the repository at this point in the history
  • Loading branch information
adamschwartz committed Jul 14, 2015
1 parent f22efb1 commit 147f8fa
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 43 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>",
Expand Down
2 changes: 1 addition & 1 deletion docs/welcome/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ <h2>Install</h2>
<br/>
<br/>
<h2>Download</h2>
<p><a class="button" href="https://raw.github.com/HubSpot/offline/v0.7.11/offline.min.js">Offline.js</a></p>
<p><a class="button" href="https://raw.github.com/HubSpot/offline/v0.7.13/offline.min.js">Offline.js</a></p>
<br/>
<h2>Pick a Theme</h2>
<div class="themes full-themes"></div>
Expand Down
76 changes: 38 additions & 38 deletions offline.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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();
Expand All @@ -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")]();
Expand All @@ -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;
Expand All @@ -140,45 +140,45 @@
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);
}, clear = function() {
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;
Expand All @@ -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 = {
Expand All @@ -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 = '<div class="offline-ui"><div class="offline-ui-content"></div></div>',
TEMPLATE = '<div class="offline-ui"><div class="offline-ui-content"></div></div>',
RETRY_TEMPLATE = '<a href class="offline-ui-retry"></a>', createFromHTML = function(html) {
var el;
return el = document.createElement("div"), el.innerHTML = html, el.children[0];
Expand All @@ -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);
Expand All @@ -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;
});
Expand Down
Loading

0 comments on commit 147f8fa

Please sign in to comment.