You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
devdocs/assets/javascripts/views/layout/path.js

64 lines
1.4 KiB

// TODO: This file was created by bulk-decaffeinate.
// Sanity-check the conversion and remove this comment.
/*
* decaffeinate suggestions:
* DS002: Fix invalid constructor
* DS101: Remove unnecessary use of Array.from
* DS206: Consider reworking classes to avoid initClass
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
*/
app.views.Path = class Path extends app.View {
static initClass() {
1 year ago
this.className = "_path";
this.attributes = { role: "complementary" };
this.events = { click: "onClick" };
this.routes = { after: "afterRoute" };
}
render(...args) {
1 year ago
this.html(this.tmpl("path", ...Array.from(args)));
this.show();
}
show() {
1 year ago
if (!this.el.parentNode) {
this.prependTo(app.el);
}
}
hide() {
1 year ago
if (this.el.parentNode) {
$.remove(this.el);
}
}
onClick(event) {
let link;
1 year ago
if ((link = $.closestLink(event.target, this.el))) {
this.clicked = true;
}
}
afterRoute(route, context) {
if (context.type) {
this.render(context.doc, context.type);
} else if (context.entry) {
if (context.entry.isIndex()) {
this.render(context.doc);
} else {
this.render(context.doc, context.entry.getType(), context.entry);
}
} else {
this.hide();
}
if (this.clicked) {
this.clicked = null;
app.document.sidebar.reset();
}
}
};
app.views.Path.initClass();