opds-web-client
Version:
64 lines (63 loc) • 2.39 kB
JavaScript
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var React = require("react");
require("../stylesheets/breadcrumbs.scss");
var CatalogLink_1 = require("./CatalogLink");
var Breadcrumbs = (function (_super) {
__extends(Breadcrumbs, _super);
function Breadcrumbs() {
_super.apply(this, arguments);
}
Breadcrumbs.prototype.render = function () {
var _this = this;
return (React.createElement("ol", {className: "breadcrumb", "aria-label": "breadcrumbs", role: "navigation"}, this.props.links && this.props.links.map(function (link, i) {
return React.createElement("li", {key: link.url}, React.createElement(CatalogLink_1.default, {collectionUrl: link.url, bookUrl: null}, i === _this.props.links.length - 1 ? React.createElement("strong", null, link.text) : link.text));
})));
};
return Breadcrumbs;
}(React.Component));
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = Breadcrumbs;
function defaultComputeBreadcrumbs(collection, history) {
var links = history ? history.slice(0) : [];
if (collection) {
links.push({
url: collection.url,
text: collection.title
});
}
return links;
}
exports.defaultComputeBreadcrumbs = defaultComputeBreadcrumbs;
function hierarchyComputeBreadcrumbs(collection, history) {
var links = [];
if (!collection) {
return [];
}
var catalogRootLink = collection.catalogRootLink, parentLink = collection.parentLink;
if (catalogRootLink && catalogRootLink.url !== collection.url) {
links.push({
text: catalogRootLink.text || "Catalog",
url: catalogRootLink.url
});
}
if (parentLink && parentLink.url && parentLink.text &&
(!catalogRootLink || parentLink.url !== catalogRootLink.url) &&
parentLink.url !== collection.url) {
links.push({
text: parentLink.text,
url: parentLink.url
});
}
links.push({
url: collection.url,
text: collection.title
});
return links;
}
exports.hierarchyComputeBreadcrumbs = hierarchyComputeBreadcrumbs;
;
;