mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 01:05:42 +00:00
New expert mode
This commit is contained in:
parent
9a1efbe5f3
commit
514baf0f5e
@ -128,9 +128,10 @@ RessourceList.options = {
|
|||||||
class ResultsList extends List {
|
class ResultsList extends List {
|
||||||
constructor(idOrElement, options={}) {
|
constructor(idOrElement, options={}) {
|
||||||
super(idOrElement, options);
|
super(idOrElement, options);
|
||||||
this.tooltipElements = []; // TODO: wieso sind hier dann nicht alle sachen zum löschen drinn?
|
this.eventTokens = []; // all span tokens which are holdeing events if expert mode is on
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// get display options from display options form element
|
// get display options from display options form element
|
||||||
static getDisplayOptions(displayOptionsFormElement) {
|
static getDisplayOptions(displayOptionsFormElement) {
|
||||||
// gets display options parameters
|
// gets display options parameters
|
||||||
@ -228,7 +229,7 @@ class ResultsList extends List {
|
|||||||
}
|
}
|
||||||
if (expertModeSwitchElement.checked) {
|
if (expertModeSwitchElement.checked) {
|
||||||
tokenElements = partElement.getElementsByClassName("token");
|
tokenElements = partElement.getElementsByClassName("token");
|
||||||
this.expertModeOn(tokenElements, contextData);
|
this.expertModeOn();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,11 +239,16 @@ class ResultsList extends List {
|
|||||||
// Just alters the resultsList.page property
|
// Just alters the resultsList.page property
|
||||||
changeHitsPerPage(event) {
|
changeHitsPerPage(event) {
|
||||||
try {
|
try {
|
||||||
resultsList.page = event.target.value;
|
// console.log(this);
|
||||||
resultsList.update();
|
this.page = event.target.value;
|
||||||
|
this.update();
|
||||||
|
if (expertModeSwitchElement.checked) {
|
||||||
|
this.expertModeOn(); // page holds new result rows, so add new tooltips
|
||||||
|
}
|
||||||
nopaque.flash("Updated matches per page.")
|
nopaque.flash("Updated matches per page.")
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log("resultsList has no results right now.");
|
// console.log(e);
|
||||||
|
// console.log("resultsList has no results right now.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -298,23 +304,31 @@ class ResultsList extends List {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// function to apply extra information and animation to every token
|
// function to create a tooltip for the current hovered token
|
||||||
|
tooltipEventCreate(event) {
|
||||||
tooltipEvent(event) {
|
// console.log("Create Tooltip on mouseover.");
|
||||||
let token;
|
let token;
|
||||||
token = results.resultsJSON.cpos_lookup[event.target.dataset.cpos];
|
token = results.resultsJSON.cpos_lookup[event.target.dataset.cpos];
|
||||||
this.addToolTipToTokenElement(event.target, token);
|
this.addToolTipToTokenElement(event.target, token);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Function to destroy the current Tooltip for the current hovered tooltip
|
||||||
|
// on mouse leave
|
||||||
|
tooltipEventDestroy(event) {
|
||||||
|
// console.log("Tooltip destroy on leave.");
|
||||||
|
this.currentTooltipElement.destroy();
|
||||||
|
}
|
||||||
|
|
||||||
expertModeOn() {
|
expertModeOn() {
|
||||||
console.log("Expert mode is on.");
|
// console.log("Expert mode is on.");
|
||||||
this.eventTokens = [];
|
|
||||||
let token;
|
let token;
|
||||||
this.currentExpertTokenElements = document.getElementsByClassName("token");
|
this.currentExpertTokenElements = document.getElementsByClassName("token");
|
||||||
this.tooltipEventBind = this.tooltipEvent.bind(this);
|
this.tooltipEventCreateBind = this.tooltipEventCreate.bind(this);
|
||||||
|
this.tooltipEventDestroyBind = this.tooltipEventDestroy.bind(this);
|
||||||
for (let tokenElement of this.currentExpertTokenElements) {
|
for (let tokenElement of this.currentExpertTokenElements) {
|
||||||
tokenElement.classList.add("chip", "hoverable", "expert-view");
|
tokenElement.classList.add("chip", "hoverable", "expert-view");
|
||||||
tokenElement.addEventListener("mouseover", this.tooltipEventBind);
|
tokenElement.onmouseover = this.tooltipEventCreateBind;
|
||||||
|
tokenElement.onmouseout = this.tooltipEventDestroyBind;
|
||||||
this.eventTokens.push(tokenElement);
|
this.eventTokens.push(tokenElement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -322,7 +336,8 @@ class ResultsList extends List {
|
|||||||
// fuction that creates Tooltip for one token and extracts the corresponding
|
// fuction that creates Tooltip for one token and extracts the corresponding
|
||||||
// infos from the result JSON
|
// infos from the result JSON
|
||||||
addToolTipToTokenElement(tokenElement, token) {
|
addToolTipToTokenElement(tokenElement, token) {
|
||||||
this.tooltipElements.push(M.Tooltip.init(tokenElement,
|
this.currentTooltipElement;
|
||||||
|
this.currentTooltipElement = M.Tooltip.init(tokenElement,
|
||||||
{"html": `<table>
|
{"html": `<table>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Token information</th>
|
<th>Token information</th>
|
||||||
@ -345,22 +360,20 @@ class ResultsList extends List {
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>`}
|
</table>`}
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// function to remove extra informations and animations from tokens
|
// function to remove extra informations and animations from tokens
|
||||||
expertModeOff() {
|
expertModeOff() {
|
||||||
console.log("Expert mode is off.");
|
// console.log("Expert mode is off.");
|
||||||
for (let tokenElement of this.currentExpertTokenElements) {
|
for (let tokenElement of this.currentExpertTokenElements) {
|
||||||
tokenElement.classList.remove("chip", "hoverable", "expert-view");
|
tokenElement.classList.remove("chip", "hoverable", "expert-view");
|
||||||
}
|
}
|
||||||
for (let eventToken of this.eventTokens) {
|
for (let eventToken of this.eventTokens) {
|
||||||
eventToken.removeEventListener("mouseover", this.tooltipEventBind);
|
eventToken.onmouseover = "";
|
||||||
}
|
eventToken.onmouseout = "";
|
||||||
for (let tooltipElement of this.tooltipElements) {
|
|
||||||
tooltipElement.destroy();
|
|
||||||
}
|
}
|
||||||
|
this.eventTokens = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
createResultRowElement(item, chunk) {
|
createResultRowElement(item, chunk) {
|
||||||
|
@ -346,7 +346,8 @@
|
|||||||
|
|
||||||
// live update of hits per page if hits per page value is changed
|
// live update of hits per page if hits per page value is changed
|
||||||
hitsPerPageInputElement = document.getElementById("display-options-form-results_per_page");
|
hitsPerPageInputElement = document.getElementById("display-options-form-results_per_page");
|
||||||
hitsPerPageInputElement.onchange = results.resultsList.changeHitsPerPage;
|
let changeHitsPerPageBind = results.resultsList.changeHitsPerPage.bind(results.resultsList);
|
||||||
|
hitsPerPageInputElement.onchange = changeHitsPerPageBind;
|
||||||
|
|
||||||
// live update of lr context per item if context value is changed
|
// live update of lr context per item if context value is changed
|
||||||
contextPerItemElement = document.getElementById("display-options-form-result_context");
|
contextPerItemElement = document.getElementById("display-options-form-result_context");
|
||||||
@ -361,7 +362,8 @@
|
|||||||
|
|
||||||
// epxert mode table view
|
// epxert mode table view
|
||||||
// TODO: Redo this
|
// TODO: Redo this
|
||||||
// TODO: This replicates itself on expertModeSwitchElement use
|
// - This replicates itself on expertModeSwitchElement use
|
||||||
|
// - Replication should be fixed
|
||||||
expertModeSwitchElement.addEventListener("change", (event) => {
|
expertModeSwitchElement.addEventListener("change", (event) => {
|
||||||
if (event.target.checked) {
|
if (event.target.checked) {
|
||||||
results.resultsList.expertModeOn();
|
results.resultsList.expertModeOn();
|
||||||
|
Loading…
Reference in New Issue
Block a user