You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2019/09/26 07:55:36 UTC
[myfaces-tobago] branch master updated: code style:
dataset["fooBar"] -> dataset.fooBar issue: TOBAGO-1633: TS refactoring
This is an automated email from the ASF dual-hosted git repository.
lofwyr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git
The following commit(s) were added to refs/heads/master by this push:
new 29fc056 code style: dataset["fooBar"] -> dataset.fooBar issue: TOBAGO-1633: TS refactoring
29fc056 is described below
commit 29fc056a09af6bc228703fdf0b7d249c61de63f5
Author: Udo Schnurpfeil <ud...@irian.eu>
AuthorDate: Thu Sep 26 09:55:15 2019 +0200
code style: dataset["fooBar"] -> dataset.fooBar
issue: TOBAGO-1633: TS refactoring
---
.../src/main/webapp/script/demo.js | 2 +-
.../src/main/npm/ts/tobago-file.ts | 2 +-
.../src/main/npm/ts/tobago-in.ts | 2 +-
.../src/main/npm/ts/tobago-reload.ts | 2 +-
.../src/main/npm/ts/tobago-select-one-listbox.ts | 8 +++----
.../src/main/npm/ts/tobago-select-one-radio.ts | 10 ++++----
.../src/main/npm/ts/tobago-sheet.ts | 28 +++++++++++-----------
.../src/main/npm/ts/tobago-split-layout.ts | 6 ++---
.../src/main/npm/ts/tobago-suggest.ts | 10 ++++----
.../src/main/npm/ts/tobago-tree-listbox.ts | 2 +-
10 files changed, 36 insertions(+), 36 deletions(-)
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/script/demo.js b/tobago-example/tobago-example-demo/src/main/webapp/script/demo.js
index bf4a803..9c87813 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/script/demo.js
+++ b/tobago-example/tobago-example-demo/src/main/webapp/script/demo.js
@@ -31,7 +31,7 @@ class Demo {
static initAlert(element) {
for (const e of element.querySelectorAll("[data-alert-text]")) {
e.addEventListener("click", function (event) {
- alert(event.currentTarget.dataset["alertText"]);
+ alert(event.currentTarget.dataset.alertText);
});
}
}
diff --git a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-file.ts b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-file.ts
index a3a0287..a890973 100644
--- a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-file.ts
+++ b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-file.ts
@@ -44,7 +44,7 @@ export class File extends HTMLElement {
let text: string;
if (this.input.multiple) {
- const format: string = this.input.dataset["tobagoFileMultiFormat"];
+ const format: string = this.input.dataset.tobagoFileMultiFormat;
text = format.replace("{}", String(this.input.files.length));
} else {
text = this.input.value;
diff --git a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-in.ts b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-in.ts
index 81374fc..1c9f316 100644
--- a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-in.ts
+++ b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-in.ts
@@ -33,7 +33,7 @@ class RegExpTest {
constructor(element: HTMLInputElement) {
this.element = element;
- this.regexp = new RegExp(this.element.dataset["regexp"]);
+ this.regexp = new RegExp(this.element.dataset.regexp);
console.debug("constructor: '%s'", element.id);
diff --git a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-reload.ts b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-reload.ts
index 9ab43df..8fcffab 100644
--- a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-reload.ts
+++ b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-reload.ts
@@ -29,7 +29,7 @@ export class ReloadManager {
static init = function (element: HTMLElement): void {
for (const reload of DomUtils.selfOrQuerySelectorAll(element, "[data-tobago-reload]")) {
- ReloadManager.instance.schedule(reload.id, Number(reload.dataset["tobagoReload"]));
+ ReloadManager.instance.schedule(reload.id, Number(reload.dataset.tobagoReload));
}
};
diff --git a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-select-one-listbox.ts b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-select-one-listbox.ts
index 2429e13..8387958 100644
--- a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-select-one-listbox.ts
+++ b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-select-one-listbox.ts
@@ -24,16 +24,16 @@ class SelectOneListbox {
for (const listbox of DomUtils.selfOrQuerySelectorAll(element, ".tobago-selectOneListbox:not(:required)")) {
listbox.addEventListener("change", (event: Event) => {
const target = event.currentTarget as HTMLSelectElement;
- if (!target.dataset["tobagoOldValue"]) {
- target.dataset["tobagoOldValue"] = "-1";
+ if (!target.dataset.tobagoOldValue) {
+ target.dataset.tobagoOldValue = "-1";
}
});
listbox.addEventListener("click", (event: Event) => {
const target = event.currentTarget as HTMLSelectElement;
- if (!target.dataset["tobagoOldValue"] || parseInt(target.dataset["tobagoOldValue"]) === target.selectedIndex) {
+ if (!target.dataset.tobagoOldValue || parseInt(target.dataset.tobagoOldValue) === target.selectedIndex) {
target.selectedIndex = -1;
}
- target.dataset["tobagoOldValue"] = String(target.selectedIndex);
+ target.dataset.tobagoOldValue = String(target.selectedIndex);
});
}
};
diff --git a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-select-one-radio.ts b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-select-one-radio.ts
index 21c6edb..4a7c99b 100644
--- a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-select-one-radio.ts
+++ b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-select-one-radio.ts
@@ -26,26 +26,26 @@ class SelectOneRadio {
const quotedId = id.replace(/([:.])/g, "\\$1");
const allConnected = document.querySelectorAll("input[name=" + quotedId + "]") as NodeListOf<HTMLInputElement>;
for (const connectedRadio of allConnected) {
- connectedRadio.dataset["tobagoOldValue"] = String(connectedRadio.checked);
+ connectedRadio.dataset.tobagoOldValue = String(connectedRadio.checked);
connectedRadio.addEventListener("click", (event: Event) => {
const target = event.currentTarget as HTMLInputElement;
const readOnly = target.readOnly;
const required = target.required;
if (!required && !readOnly) {
- if (target.dataset["tobagoOldValue"] === String(target.checked)) {
+ if (target.dataset.tobagoOldValue === String(target.checked)) {
target.checked = false;
}
- target.dataset["tobagoOldValue"] = String(target.checked);
+ target.dataset.tobagoOldValue = String(target.checked);
}
if (readOnly) {
for (const connectedRadio of allConnected) {
- connectedRadio.checked = connectedRadio.dataset["tobagoOldValue"] === "true";
+ connectedRadio.checked = connectedRadio.dataset.tobagoOldValue === "true";
}
} else {
for (const connectedRadio of allConnected) {
if (target.id != connectedRadio.id) {
connectedRadio.checked = false;
- connectedRadio.dataset["tobagoOldValue"] = String(connectedRadio.checked);
+ connectedRadio.dataset.tobagoOldValue = String(connectedRadio.checked);
}
}
}
diff --git a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-sheet.ts b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-sheet.ts
index d1401f3..ce6e700 100644
--- a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-sheet.ts
+++ b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-sheet.ts
@@ -69,8 +69,8 @@ class Sheet {
constructor(element: HTMLElement) {
this.id = element.id;
- const commands = element.dataset["tobagoRowAction"];
- const behavior = element.dataset["tobagoBehaviorCommands"];
+ const commands = element.dataset.tobagoRowAction;
+ const behavior = element.dataset.tobagoBehaviorCommands;
this.clickActionId = null;//todo commands.click.action;
this.clickReloadComponentId = null;//todo commands.click.partially; // fixme: partially no longer used?
this.dblClickActionId = null;//todo commands.dblclick.action;
@@ -91,7 +91,7 @@ class Sheet {
console.info("columnWidths: " + columnWidths);
if (columnWidths && columnWidths.length === 0) { // active, but empty
// otherwise use the layout definition
- const tokens = JSON.parse(element.dataset["tobagoLayout"]).columns;
+ const tokens = JSON.parse(element.dataset.tobagoLayout).columns;
const columnRendered = this.isColumnRendered();
const headerCols = this.getHeaderCols();
@@ -171,7 +171,7 @@ class Sheet {
sheetBody.addEventListener("scroll", this.scroll.bind(this));
// add selection listeners ------------------------------------------------------------------------------------ //
- const selectionMode = element.dataset["tobagoSelectionMode"];
+ const selectionMode = element.dataset.tobagoSelectionMode;
if (selectionMode === "single" || selectionMode === "singleOrNone" || selectionMode === "multi") {
for (const row of this.getRows()) {
@@ -260,13 +260,13 @@ class Sheet {
mousedown(event: MouseEvent): void {
- Page.page().dataset["SheetMousedownData"] = this.id;
+ Page.page().dataset.SheetMousedownData = this.id;
// begin resizing
console.debug("down");
const resizeElement = event.currentTarget as HTMLElement;
- const columnIndex = parseInt(resizeElement.dataset["tobagoColumnIndex"]);
+ const columnIndex = parseInt(resizeElement.dataset.tobagoColumnIndex);
const headerColumn = this.getHeaderCols().item(columnIndex);
const mousemoveListener = this.mousemove.bind(this);
const mouseupListener = this.mouseup.bind(this);
@@ -302,7 +302,7 @@ class Sheet {
document.removeEventListener("mousemove", this.mousemoveData.mousemoveListener);
document.removeEventListener("mouseup", this.mousemoveData.mouseupListener);
// copy the width values from the header to the body, (and build a list of it)
- const tokens = JSON.parse(this.getElement().dataset["tobagoLayout"]).columns;
+ const tokens = JSON.parse(this.getElement().dataset.tobagoLayout).columns;
const columnRendered = this.isColumnRendered();
const columnWidths = this.loadColumnWidths();
@@ -395,7 +395,7 @@ class Sheet {
const rows = this.getRows();
const selector = this.getSelectorCheckbox(row);
- const selectionMode = this.getElement().dataset["tobagoSelectionMode"];
+ const selectionMode = this.getElement().dataset.tobagoSelectionMode;
if ((!event.ctrlKey && !event.metaKey && !selector)
|| selectionMode === "single" || selectionMode === "singleOrNone") {
@@ -403,7 +403,7 @@ class Sheet {
this.resetSelected();
}
- const lastClickedRowIndex = parseInt(sheet.dataset["tobagoLastClickedRowIndex"]);
+ const lastClickedRowIndex = parseInt(sheet.dataset.tobagoLastClickedRowIndex);
if (event.shiftKey && selectionMode === "multi" && lastClickedRowIndex > -1) {
if (lastClickedRowIndex <= row.sectionRowIndex) {
this.selectRange(rows, lastClickedRowIndex, row.sectionRowIndex, true, false);
@@ -413,7 +413,7 @@ class Sheet {
} else if (selectionMode !== "singleOrNone" || !this.isRowSelected(row)) {
this.toggleSelection(row, selector);
}
- const rowAction = sheet.dataset["tobagoRowAction"];
+ const rowAction = sheet.dataset.tobagoRowAction;
const commands = rowAction ? JSON.parse(rowAction) : undefined;
const click = commands ? commands.click : undefined;
const clickActionId = click ? click.action : undefined;
@@ -557,11 +557,11 @@ class Sheet {
}
getFirst(): number {
- return parseInt(this.getElement().dataset["tobagoFirst"]);
+ return parseInt(this.getElement().dataset.tobagoFirst);
}
isRowSelected(row: HTMLTableRowElement): boolean {
- let rowIndex = +row.dataset["tobagoRowIndex"];
+ let rowIndex = +row.dataset.tobagoRowIndex;
if (!rowIndex) {
rowIndex = row.sectionRowIndex + this.getFirst();
}
@@ -578,7 +578,7 @@ class Sheet {
}
toggleSelection(row: HTMLTableRowElement, checkbox: HTMLInputElement): void {
- this.getElement().dataset["tobagoLastClickedRowIndex"] = String(row.sectionRowIndex);
+ this.getElement().dataset.tobagoLastClickedRowIndex = String(row.sectionRowIndex);
if (checkbox && !checkbox.disabled) {
const selected = this.getHiddenSelected();
const rowIndex = this.getDataIndex(row);
@@ -626,7 +626,7 @@ class Sheet {
}
getDataIndex(row: HTMLTableRowElement): number {
- const rowIndex = parseInt(row.dataset["tobagoRowIndex"]);
+ const rowIndex = parseInt(row.dataset.tobagoRowIndex);
if (rowIndex) {
return rowIndex;
} else {
diff --git a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-split-layout.ts b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-split-layout.ts
index 2da4fcf..5343ddc 100644
--- a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-split-layout.ts
+++ b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-split-layout.ts
@@ -117,16 +117,16 @@ class SplitLayoutMousedown {
horizontal: horizontal,
splitterIndex: this.indexOfSplitter(splitter, horizontal)
};
- Page.page().dataset["SplitLayoutMousedownData"] = JSON.stringify(data);
+ Page.page().dataset.SplitLayoutMousedownData = JSON.stringify(data);
return new SplitLayoutMousedown(data);
}
static load(): SplitLayoutMousedown {
- return new SplitLayoutMousedown(Page.page().dataset["SplitLayoutMousedownData"]);
+ return new SplitLayoutMousedown(Page.page().dataset.SplitLayoutMousedownData);
}
static remove(): void {
- Page.page().dataset["SplitLayoutMousedownData"] = null;
+ Page.page().dataset.SplitLayoutMousedownData = null;
}
private static indexOfSplitter(splitter: HTMLElement, horizontal: boolean): number {
diff --git a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-suggest.ts b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-suggest.ts
index b83efaf..31ceeea 100644
--- a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-suggest.ts
+++ b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-suggest.ts
@@ -30,7 +30,7 @@ class Suggest extends HTMLElement {
return function findMatches(query, syncResults, asyncResults): void {
const root = input.getRootNode() as ShadowRoot | Document;
- let suggest = root.getElementById(input.dataset["tobagoSuggestFor"]) as Suggest;
+ let suggest = root.getElementById(input.dataset.tobagoSuggestFor) as Suggest;
// todo: suggest.hiddenInput.value should contain the last query value
if (suggest.hiddenInput.value !== query) {
@@ -44,7 +44,7 @@ class Suggest extends HTMLElement {
timeout = setTimeout(function (): void {
suggest.hiddenInput.value = query;
Suggest.asyncResults = asyncResults;
- delete suggest.dataset["tobagoSuggestData"];
+ delete suggest.dataset.tobagoSuggestData;
console.info("query: '" + query + "'");
jsf.ajax.request(
@@ -164,7 +164,7 @@ class Suggest extends HTMLElement {
Suggest.asyncResults = null;
}
} else { // new
- input.dataset["tobagoSuggestFor"] = this.id;
+ input.dataset.tobagoSuggestFor = this.id;
input.autocomplete = "off";
let source;
@@ -209,7 +209,7 @@ class Suggest extends HTMLElement {
// old with jQuery:
$input.on("typeahead:open", function (event: JQuery.Event): void {
const input = this;
- const suggestPopup = root.getElementById(input.dataset["tobagoSuggestFor"] + "::popup");
+ const suggestPopup = root.getElementById(input.dataset.tobagoSuggestFor + "::popup");
suggestPopup.style.top = DomUtils.offset(input).top + input.offsetHeight + "px";
suggestPopup.style.left = DomUtils.offset(input).left + "px";
suggestPopup.style.minWidth = input.offsetWidth + "px";
@@ -218,7 +218,7 @@ class Suggest extends HTMLElement {
// new without jQuery:
// input.addEventListener("typeahead:open", (event: Event) => {
// const input = event.currentTarget as HTMLInputElement;
- // const suggestPopup = document.getElementById(input.dataset["tobagoSuggestFor"] + "::popup");
+ // const suggestPopup = document.getElementById(input.dataset.tobagoSuggestFor + "::popup");
// suggestPopup.style.top = DomUtils.offset(input).top + input.offsetHeight + "px";
// suggestPopup.style.left = DomUtils.offset(input).left + "px";
// suggestPopup.style.minWidth = input.offsetWidth + "px";
diff --git a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-tree-listbox.ts b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-tree-listbox.ts
index 4c7b458..4513241 100644
--- a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-tree-listbox.ts
+++ b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-tree-listbox.ts
@@ -94,7 +94,7 @@ class TreeListbox {
if (hidden) {
let value = <number[]>JSON.parse(hidden.value);
value = []; // todo: multi-select
- value.push(parseInt(option.dataset["tobagoRowIndex"]));
+ value.push(parseInt(option.dataset.tobagoRowIndex));
hidden.value = JSON.stringify(value);
}
}