JezK
Edit File: browser_adapter.js
// Generated by CoffeeScript 2.7.0 (function() { require('./http_request'); require('./progress_bar'); Turbolinks.BrowserAdapter = (function() { var NETWORK_FAILURE, TIMEOUT_FAILURE; class BrowserAdapter { constructor(controller) { this.showProgressBar = this.showProgressBar.bind(this); this.controller = controller; this.progressBar = new Turbolinks.ProgressBar(); } visitProposedToLocationWithAction(location, action) { return this.controller.startVisitToLocationWithAction(location, action); } visitStarted(visit) { visit.issueRequest(); visit.changeHistory(); return visit.loadCachedSnapshot(); } visitRequestStarted(visit) { this.progressBar.setValue(0); if (visit.hasCachedSnapshot() || visit.action !== "restore") { return this.showProgressBarAfterDelay(); } else { return this.showProgressBar(); } } visitRequestProgressed(visit) { return this.progressBar.setValue(visit.progress); } visitRequestCompleted(visit) { return visit.loadResponse(); } visitRequestFailedWithStatusCode(visit, statusCode) { switch (statusCode) { case NETWORK_FAILURE: case TIMEOUT_FAILURE: return this.reload(); default: return visit.loadResponse(); } } visitRequestFinished(visit) { return this.hideProgressBar(); } visitCompleted(visit) { return visit.followRedirect(); } pageInvalidated() { return this.reload(); } // Private showProgressBarAfterDelay() { return this.progressBarTimeout = setTimeout(this.showProgressBar, this.controller.progressBarDelay); } showProgressBar() { return this.progressBar.show(); } hideProgressBar() { this.progressBar.hide(); return clearTimeout(this.progressBarTimeout); } reload() { return window.location.reload(); } }; ({NETWORK_FAILURE, TIMEOUT_FAILURE} = Turbolinks.HttpRequest); return BrowserAdapter; }).call(this); }).call(this);