// Generated by CoffeeScript 1.12.8 (function() { require('./snapshot'); require('./snapshot_renderer'); require('./error_renderer'); Turbolinks.View = (function() { function View(delegate) { this.delegate = delegate; this.htmlElement = document.documentElement; } View.prototype.getRootLocation = function() { return this.getSnapshot().getRootLocation(); }; View.prototype.getElementForAnchor = function(anchor) { return this.getSnapshot().getElementForAnchor(anchor); }; View.prototype.getSnapshot = function() { return Turbolinks.Snapshot.fromHTMLElement(this.htmlElement); }; View.prototype.render = function(arg, callback) { var error, isPreview, snapshot; snapshot = arg.snapshot, error = arg.error, isPreview = arg.isPreview; this.markAsPreview(isPreview); if (snapshot != null) { return this.renderSnapshot(snapshot, isPreview, callback); } else { return this.renderError(error, callback); } }; View.prototype.markAsPreview = function(isPreview) { if (isPreview) { return this.htmlElement.setAttribute("data-turbolinks-preview", ""); } else { return this.htmlElement.removeAttribute("data-turbolinks-preview"); } }; View.prototype.renderSnapshot = function(snapshot, isPreview, callback) { return Turbolinks.SnapshotRenderer.render(this.delegate, callback, this.getSnapshot(), Turbolinks.Snapshot.wrap(snapshot), isPreview); }; View.prototype.renderError = function(error, callback) { return Turbolinks.ErrorRenderer.render(this.delegate, callback, error); }; return View; })(); }).call(this);