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/12 05:52:56 UTC
[myfaces-tobago] branch master updated: make demo.js compatible to
the testing
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 542bae2 make demo.js compatible to the testing
542bae2 is described below
commit 542bae2dbf206dd9c9ee518ad0a348a674c46e34
Author: Udo Schnurpfeil <lo...@apache.org>
AuthorDate: Thu Sep 12 07:52:46 2019 +0200
make demo.js compatible to the testing
issue: TOBAGO-1633: TS refactoring
---
.../src/main/webapp/script/demo.js | 30 ++++++++++++----------
.../tobago-example-demo/src/main/webapp/test.xhtml | 2 +-
2 files changed, 18 insertions(+), 14 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 6698afa..bf4a803 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
@@ -90,18 +90,20 @@ class Demo {
static initGoogleSearch(element) {
const input = document.getElementById("page:search:searchField");
- const search = "+site%3Atobago-vm.apache.org+demo-4";
- input.addEventListener("change", function (event) {
- const input = event.currentTarget;
- const button = document.getElementById("page:search:searchCommand");
- button.setAttribute("href", "https://www.google.com/search?q=" + encodeURI(input.value) + search);
- });
- input.addEventListener("keypress", function (event) {
- if (event.which === 13) {
- console.log("ENTER");
- window.location.href = "https://www.google.com/search?q=" + encodeURI(input.value()) + search;
- }
- });
+ if (input) {
+ const search = "+site%3Atobago-vm.apache.org+demo-4";
+ input.addEventListener("change", function (event) {
+ const input = event.currentTarget;
+ const button = document.getElementById("page:search:searchCommand");
+ button.setAttribute("href", "https://www.google.com/search?q=" + encodeURI(input.value) + search);
+ });
+ input.addEventListener("keypress", function (event) {
+ if (event.which === 13) {
+ console.log("ENTER");
+ window.location.href = "https://www.google.com/search?q=" + encodeURI(input.value()) + search;
+ }
+ });
+ }
};
static initMailTo(element) {
@@ -120,4 +122,6 @@ Listener.register(Demo.init, Phase.DOCUMENT_READY);
Listener.register(Demo.init, Phase.AFTER_UPDATE);
// call highlighting again. (is called for all, not only for the elements, because it's easier to implement.)
-Listener.register(Prism.highlightAll, Phase.AFTER_UPDATE);
+if (window.location.pathname !== "/test.xhtml") { // not in the test framework
+ Listener.register(Prism.highlightAll, Phase.AFTER_UPDATE);
+}
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/test.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/test.xhtml
index eb70ce6..70731a3 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/test.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/test.xhtml
@@ -21,7 +21,7 @@
xmlns:tc="http://myfaces.apache.org/tobago/component"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns="http://www.w3.org/1999/xhtml">
- <tc:script file="#{request.contextPath}/script/demo.js"/>
+ <tc:script file="#{request.contextPath}/script/demo.js" type="module"/>
<tc:script file="#{request.contextPath}/script/qunit-2.9.2.js"/>
<tc:script file="#{request.contextPath}/tobago/test/tobago-test-tool.js" type="module"/>
<tc:script file="#{request.contextPath}/script/tobago-test.js" type="module"/>