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 2020/09/11 06:30:19 UTC
[myfaces-tobago] branch master updated: Demo: modernise example
(with custom elements)
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 3f06032 Demo: modernise example (with custom elements)
3f06032 is described below
commit 3f0603215e29d498453badbc2800a3be42c4b8ec
Author: Udo Schnurpfeil <ud...@irian.eu>
AuthorDate: Fri Sep 11 08:30:05 2020 +0200
Demo: modernise example (with custom elements)
---
.../webapp/content/10-intro/20-docker/Docker.xhtml | 6 +-
.../webapp/content/10-intro/20-docker/docker.js | 79 ++++++++++------------
.../content/10-intro/20-docker/docker.js.map | 2 +-
.../webapp/content/10-intro/20-docker/docker.ts | 79 ++++++++++------------
.../content/10-intro/20-docker/tsconfig.json | 2 +-
5 files changed, 78 insertions(+), 90 deletions(-)
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/10-intro/20-docker/Docker.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/10-intro/20-docker/Docker.xhtml
index 5e6d2c4..3e33357 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/10-intro/20-docker/Docker.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/10-intro/20-docker/Docker.xhtml
@@ -63,9 +63,9 @@
<pre><code class="language-bash" id="commandLine"><tc:out
keepLineBreaks="false" value="#{dockerController.commandLine}"/></code></pre>
- <tc:button id="toClipboardButton" label="Copy Commands" omit="true">
- <tc:dataAttribute name="copy-clipboard-from" value="commandLine"/>
- </tc:button>
+ <demo-copy-to-clipboard source="commandLine">
+ <tc:button id="toClipboardButton" label="Copy Commands" omit="true"/>
+ </demo-copy-to-clipboard>
<tc:button label="Browse via HTTP" link="#{dockerController.url}"/>
<tc:button label="Browse via HTTPS" link="#{dockerController.sslUrl}" disabled="#{not dockerController.server.ssl}"/>
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/10-intro/20-docker/docker.js b/tobago-example/tobago-example-demo/src/main/webapp/content/10-intro/20-docker/docker.js
index f4bc7be..c92cd9f 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/10-intro/20-docker/docker.js
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/10-intro/20-docker/docker.js
@@ -1,4 +1,3 @@
-"use strict";
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -15,46 +14,40 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-exports.__esModule = true;
-// fixme: better don't use Listener and Phase?
-// import {Listener, Phase} from "../tobago/standard/5.0.0-SNAPSHOT/js/bundle";
-var tobago_listener_1 = require("../tobago/standard/5.0.0-SNAPSHOT/js/tobago-listener");
-var Demo;
-(function (Demo) {
- var ToClipboardButton;
- (function (ToClipboardButton_1) {
- var ToClipboardButton = /** @class */ (function () {
- function ToClipboardButton(element) {
- /* Copy the command lines to the clipboard.
- */
- element.addEventListener("click", function (event) {
- var from = element.getAttribute("data-copy-clipboard-from");
- var commandLine = document.getElementById(from);
- if (window.getSelection) {
- var selection = window.getSelection();
- var range = document.createRange();
- range.selectNodeContents(commandLine);
- selection.removeAllRanges();
- selection.addRange(range);
- }
- else {
- console.warn("Text select not possible: Unsupported browser.");
- }
- try {
- var result = document.execCommand("copy");
- console.debug("result: " + result);
- }
- catch (error) {
- console.error("Copying text not possible");
- }
- });
+class DemoCopyToClipboard extends HTMLElement {
+ constructor() {
+ super();
+ }
+ connectedCallback() {
+ this.addEventListener("click", (event) => {
+ const sourceElement = document.getElementById(this.source);
+ if (window.getSelection) {
+ const selection = window.getSelection();
+ const range = document.createRange();
+ range.selectNodeContents(sourceElement);
+ selection.removeAllRanges();
+ selection.addRange(range);
}
- return ToClipboardButton;
- }());
- var init = function () {
- document.querySelectorAll("[data-copy-clipboard-from]").forEach(function (value) { return new ToClipboardButton(value); });
- };
- tobago_listener_1.Listener.register(init, tobago_listener_1.Phase.DOCUMENT_READY);
- tobago_listener_1.Listener.register(init, tobago_listener_1.Phase.AFTER_UPDATE);
- })(ToClipboardButton = Demo.ToClipboardButton || (Demo.ToClipboardButton = {}));
-})(Demo || (Demo = {}));
+ else {
+ console.warn("Text select not possible: Unsupported browser.");
+ }
+ try {
+ const result = document.execCommand("copy");
+ console.debug("result: " + result);
+ }
+ catch (error) {
+ console.error("Copying text not possible");
+ }
+ });
+ }
+ get source() {
+ return this.getAttribute("source");
+ }
+ set source(name) {
+ this.setAttribute("source", name);
+ }
+}
+document.addEventListener("DOMContentLoaded", function (event) {
+ window.customElements.define("demo-copy-to-clipboard", DemoCopyToClipboard);
+});
+//# sourceMappingURL=docker.js.map
\ No newline at end of file
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/10-intro/20-docker/docker.js.map b/tobago-example/tobago-example-demo/src/main/webapp/content/10-intro/20-docker/docker.js.map
index a611c32..e2b5206 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/10-intro/20-docker/docker.js.map
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/10-intro/20-docker/docker.js.map
@@ -1 +1 @@
-{"version":3,"file":"docker.js","sourceRoot":"","sources":["docker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,IAAO,IAAI,CAyCV;AAzCD,WAAO,IAAI;IAAC,IAAA,iBAAiB,CAyC5B;IAzCW,WAAA,mBAAiB;QAE3B;YAEE,2BAAY,OAAoB;gBAE9B;mBACG;gBACH,OAAO,CAAC,gBAAgB,CACpB,OAAO,EACP,UAAC,KAAiB;oBAChB,IAAM,IAAI,GAAG,OAAO,CAAC,YAAY,CAAC,0BAA0B,CAAC,CAAC;oBAC9D,IAAM,WAAW,GAAG,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;oBAElD,IAAI,MAAM,CAAC,YAAY,EAAE;wBACvB,IAAM,SAAS,GAAG,MAAM,CAAC,YAAY,EAAE,CAAC;wBACxC,IAAM,K [...]
\ No newline at end of file
+{"version":3,"file":"docker.js","sourceRoot":"","sources":["docker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,MAAM,mBAAoB,SAAQ,WAAW;IAE3C;QACE,KAAK,EAAE,CAAC;IACV,CAAC;IAED,iBAAiB;QACf,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,KAAiB,EAAE,EAAE;YACnD,MAAM,aAAa,GAAG,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAE3D,IAAI,MAAM,CAAC,YAAY,EAAE;gBACvB,MAAM,SAAS,GAAG,MAAM,CAAC,YAAY,EAAE,CAAC;gBACxC,MAAM,KAAK,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;gBACrC,KAAK,CAAC,kBAAkB,CAAC,aAAa,CAAC,CAAC;gBACx [...]
\ No newline at end of file
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/10-intro/20-docker/docker.ts b/tobago-example/tobago-example-demo/src/main/webapp/content/10-intro/20-docker/docker.ts
index 87e6fa8..23c9de5 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/10-intro/20-docker/docker.ts
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/10-intro/20-docker/docker.ts
@@ -15,49 +15,44 @@
* limitations under the License.
*/
-// fixme: better don't use Listener and Phase?
-// import {Listener, Phase} from "../tobago/standard/5.0.0-SNAPSHOT/js/bundle";
-import {Listener, Phase} from "../tobago/standard/5.0.0-SNAPSHOT/js/tobago-listener";
-
-module Demo.ToClipboardButton {
-
- class ToClipboardButton {
-
- constructor(element: HTMLElement) {
-
- /* Copy the command lines to the clipboard.
- */
- element.addEventListener(
- "click",
- (event: MouseEvent) => {
- const from = element.getAttribute("data-copy-clipboard-from");
- const commandLine = document.getElementById(from);
-
- if (window.getSelection) {
- const selection = window.getSelection();
- const range = document.createRange();
- range.selectNodeContents(commandLine);
- selection.removeAllRanges();
- selection.addRange(range);
- } else {
- console.warn("Text select not possible: Unsupported browser.");
- }
- try {
- const result = document.execCommand("copy");
- console.debug("result: " + result);
- } catch (error) {
- console.error("Copying text not possible");
- }
- });
- }
+class DemoCopyToClipboard extends HTMLElement {
+
+ constructor() {
+ super();
+ }
+
+ connectedCallback(): void {
+ this.addEventListener("click", (event: MouseEvent) => {
+ const sourceElement = document.getElementById(this.source);
+
+ if (window.getSelection) {
+ const selection = window.getSelection();
+ const range = document.createRange();
+ range.selectNodeContents(sourceElement);
+ selection.removeAllRanges();
+ selection.addRange(range);
+ } else {
+ console.warn("Text select not possible: Unsupported browser.");
+ }
+ try {
+ const result = document.execCommand("copy");
+ console.debug("result: " + result);
+ } catch (error) {
+ console.error("Copying text not possible");
+ }
+ });
}
- const init = function () {
- document.querySelectorAll<HTMLElement>("[data-copy-clipboard-from]").forEach(
- (value) => new ToClipboardButton(value)
- )
- };
+ get source(): string {
+ return this.getAttribute("source");
+ }
+
+ set source(name: string) {
+ this.setAttribute("source", name);
+ }
- Listener.register(init, Phase.DOCUMENT_READY);
- Listener.register(init, Phase.AFTER_UPDATE);
}
+
+document.addEventListener("DOMContentLoaded", function (event: Event): void {
+ window.customElements.define("demo-copy-to-clipboard", DemoCopyToClipboard);
+});
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/10-intro/20-docker/tsconfig.json b/tobago-example/tobago-example-demo/src/main/webapp/content/10-intro/20-docker/tsconfig.json
index 297718a..af44995 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/10-intro/20-docker/tsconfig.json
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/10-intro/20-docker/tsconfig.json
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"module": "commonjs",
- "target": "es5",
+ "target": "ES2015",
"noImplicitAny": false,
"rootDir": ".",
"outDir": ".",