2020-07-22 15:00:22 +00:00
|
|
|
// Copyright 2020 the V8 project authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
2020-11-02 09:27:28 +00:00
|
|
|
import { V8CustomElement, DOM} from "../helper.mjs";
|
2020-08-13 12:55:19 +00:00
|
|
|
import { FocusEvent } from "../events.mjs";
|
2020-07-22 15:00:22 +00:00
|
|
|
|
2020-11-02 09:27:28 +00:00
|
|
|
DOM.defineCustomElement(
|
2020-08-13 12:55:19 +00:00
|
|
|
"./map-panel/map-details",
|
|
|
|
(templateText) =>
|
|
|
|
class MapDetails extends V8CustomElement {
|
|
|
|
constructor() {
|
|
|
|
super(templateText);
|
2020-10-19 10:45:42 +00:00
|
|
|
this._filePositionNode.addEventListener("click", e =>
|
2020-08-28 14:41:56 +00:00
|
|
|
this.handleFilePositionClick(e)
|
2020-08-13 12:55:19 +00:00
|
|
|
);
|
|
|
|
this.selectedMap = undefined;
|
|
|
|
}
|
|
|
|
get mapDetails() {
|
|
|
|
return this.$("#mapDetails");
|
|
|
|
}
|
2020-07-22 15:00:22 +00:00
|
|
|
|
2020-10-19 10:45:42 +00:00
|
|
|
get _filePositionNode() {
|
2020-08-28 14:41:56 +00:00
|
|
|
return this.$("#filePositionNode");
|
|
|
|
}
|
|
|
|
|
2020-08-13 12:55:19 +00:00
|
|
|
setSelectedMap(value) {
|
|
|
|
this.selectedMap = value;
|
|
|
|
}
|
2020-07-22 15:00:22 +00:00
|
|
|
|
2020-08-13 12:55:19 +00:00
|
|
|
set mapDetails(map) {
|
|
|
|
let details = "";
|
2020-08-28 14:41:56 +00:00
|
|
|
let clickableDetails = "";
|
2020-08-13 12:55:19 +00:00
|
|
|
if (map) {
|
2020-08-28 14:41:56 +00:00
|
|
|
clickableDetails += "ID: " + map.id;
|
|
|
|
clickableDetails += "\nSource location: " + map.filePosition;
|
2020-08-13 12:55:19 +00:00
|
|
|
details += "\n" + map.description;
|
|
|
|
this.setSelectedMap(map);
|
|
|
|
}
|
2020-10-19 10:45:42 +00:00
|
|
|
this._filePositionNode.innerText = clickableDetails;
|
|
|
|
this._filePositionNode.classList.add("clickable");
|
2020-08-13 12:55:19 +00:00
|
|
|
this.mapDetails.innerText = details;
|
|
|
|
}
|
2020-07-22 15:00:22 +00:00
|
|
|
|
2020-08-28 14:41:56 +00:00
|
|
|
handleFilePositionClick() {
|
2020-09-23 10:30:17 +00:00
|
|
|
this.dispatchEvent(new FocusEvent(this.selectedMap.sourcePosition));
|
2020-08-13 12:55:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|