[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-web-common] branch master updated: move handling sty
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-web-common] branch master updated: move handling stylesheets into extension |
Date: |
Wed, 26 Apr 2017 03:17:31 +0200 |
This is an automated email from the git hooks/post-receive script.
dold pushed a commit to branch master
in repository web-common.
The following commit(s) were added to refs/heads/master by this push:
new 43278f1 move handling stylesheets into extension
43278f1 is described below
commit 43278f112f1b3e3f9bbf35574c09413527e40294
Author: Florian Dold <address@hidden>
AuthorDate: Wed Apr 26 03:17:28 2017 +0200
move handling stylesheets into extension
---
taler-wallet-lib.js | 94 ++--------------------------------------------------
taler-wallet-lib.ts | 95 ++---------------------------------------------------
2 files changed, 4 insertions(+), 185 deletions(-)
diff --git a/taler-wallet-lib.js b/taler-wallet-lib.js
index fd2845f..09dc239 100644
--- a/taler-wallet-lib.js
+++ b/taler-wallet-lib.js
@@ -46,7 +46,6 @@ var taler;
var probeExecuted = false;
var pageLoaded = false;
var errorHandler = undefined;
- var sheet;
function onError(handler) {
if (errorHandler) {
console.warn("Overriding error handler");
@@ -296,7 +295,7 @@ var taler;
probeTaler();
}
/**
- * Announce presence/absence and update stylesheets.
+ * Announce presence/absence
*
* Only called after document.readyState is at least "interactive".
*/
@@ -305,7 +304,6 @@ var taler;
logVerbose && console.log("page not loaded yet, announcing
later");
return;
}
- setStyles();
if (installed) {
logVerbose && console.log("announcing installed");
for (var i = 0; i < presentHandlers.length; i++) {
@@ -324,69 +322,8 @@ var taler;
}
}
}
- function setStyles() {
- if (!sheet || !sheet.cssRules) {
- return;
- }
- while (sheet.cssRules.length > 0) {
- sheet.deleteRule(0);
- }
- if (installed) {
- sheet.insertRule(".taler-installed-hide { display: none; }",
0);
- sheet.insertRule(".taler-probed-hide { display: none; }", 0);
- }
- else {
- sheet.insertRule(".taler-installed-show { display: none; }",
0);
- if (firstTimeoutCalled) {
- sheet.insertRule(".taler-probed-hide { display: none; }",
0);
- }
- else {
- // We're still doing the detection
- sheet.insertRule(".taler-installed-hide { display: none;
}", 0);
- }
- }
- }
- function initStyle() {
- logVerbose && console.log("taking over styles");
- var name = "taler-presence-stylesheet";
- var content = "/* Taler stylesheet controlled by JS */";
- var style = document.getElementById(name);
- if (!style) {
- style = document.createElement("style");
- // Needed by WebKit
- style.appendChild(document.createTextNode(content));
- style.id = name;
- document.head.appendChild(style);
- sheet = style.sheet;
- }
- else {
- // We've taken over the stylesheet now,
- // make it clear by clearing all the rules in it
- // and making it obvious in the DOM.
- if (style.tagName.toLowerCase() === "style") {
- style.innerText = content;
- }
- if (!style.sheet) {
- throw Error("taler-presence-stylesheet should be a style
sheet (<link> or <style>)");
- }
- sheet = style.sheet;
- while (sheet.cssRules.length > 0) {
- sheet.deleteRule(0);
- }
- }
- }
function onPageLoad() {
pageLoaded = true;
- if (document.readyState == "complete") {
- initStyle();
- }
- else {
- var listener = function () {
- initStyle();
- setStyles();
- };
- window.addEventListener("load", listener);
- }
// We only start the timeout after the page is interactive.
window.setInterval(onProbeTimeout, 300);
announce();
@@ -403,33 +340,6 @@ var taler;
onPageLoad();
}
}
- function onPageLoadInExtension() {
- if (document.documentElement.getAttribute("data-taler-nojs")) {
- logVerbose && console.log("doing taler initialization from
extension (nojs)");
- initTaler();
- }
- }
- var caught = false;
- try {
- chrome.runtime.sendMessage({ type: "ping" });
- }
- catch (e) {
- caught = true;
- }
- if (caught) {
- logVerbose && console.log("running taler-wallet-lib from page");
- initTaler();
- }
- else {
- logVerbose && console.log("running taler-wallet-lib from extension");
- runningInExtension = true;
- // Wait for even style sheets to load
- if (document.readyState != "complete") {
- window.addEventListener("load", function () { return
onPageLoadInExtension(); });
- }
- else {
- onPageLoadInExtension();
- }
- }
+ logVerbose && console.log("running taler-wallet-lib from page");
})(taler || (taler = {}));
// @license-end
diff --git a/taler-wallet-lib.ts b/taler-wallet-lib.ts
index 1a56e95..7ef6b4f 100644
--- a/taler-wallet-lib.ts
+++ b/taler-wallet-lib.ts
@@ -53,8 +53,6 @@ namespace taler {
let errorHandler: any = undefined;
- let sheet: CSSStyleSheet;
-
export function onError(handler: any) {
if (errorHandler) {
console.warn("Overriding error handler");
@@ -348,7 +346,7 @@ namespace taler {
}
/**
- * Announce presence/absence and update stylesheets.
+ * Announce presence/absence
*
* Only called after document.readyState is at least "interactive".
*/
@@ -357,7 +355,6 @@ namespace taler {
logVerbose && console.log("page not loaded yet, announcing later");
return;
}
- setStyles();
if (installed) {
logVerbose && console.log("announcing installed");
for (var i = 0; i < presentHandlers.length; i++) {
@@ -375,72 +372,10 @@ namespace taler {
}
}
- function setStyles() {
- if (!sheet || !sheet.cssRules) {
- return;
- }
- while (sheet.cssRules.length > 0) {
- sheet.deleteRule(0);
- }
- if (installed) {
- sheet.insertRule(".taler-installed-hide { display: none; }", 0);
- sheet.insertRule(".taler-probed-hide { display: none; }", 0);
- } else {
- sheet.insertRule(".taler-installed-show { display: none; }", 0);
-
- if (firstTimeoutCalled) {
- sheet.insertRule(".taler-probed-hide { display: none; }", 0);
- } else {
- // We're still doing the detection
- sheet.insertRule(".taler-installed-hide { display: none; }", 0);
- }
- }
- }
-
- function initStyle() {
- logVerbose && console.log("taking over styles");
- const name = "taler-presence-stylesheet";
- const content = "/* Taler stylesheet controlled by JS */";
- let style = document.getElementById(name) as HTMLStyleElement|null;
- if (!style) {
- style = document.createElement("style");
- // Needed by WebKit
- style.appendChild(document.createTextNode(content));
- style.id = name;
- document.head.appendChild(style);
- sheet = style.sheet as CSSStyleSheet;
- } else {
- // We've taken over the stylesheet now,
- // make it clear by clearing all the rules in it
- // and making it obvious in the DOM.
- if (style.tagName.toLowerCase() === "style") {
- style.innerText = content;
- }
- if (!style.sheet) {
- throw Error("taler-presence-stylesheet should be a style sheet
(<link> or <style>)");
- }
- sheet = style.sheet as CSSStyleSheet;
- while (sheet.cssRules.length > 0) {
- sheet.deleteRule(0);
- }
- }
- }
-
function onPageLoad() {
pageLoaded = true;
- if (document.readyState == "complete") {
- initStyle();
- } else {
- let listener = () => {
- initStyle();
- setStyles();
- };
- window.addEventListener("load", listener);
- }
-
// We only start the timeout after the page is interactive.
window.setInterval(onProbeTimeout, 300);
-
announce();
}
@@ -456,32 +391,6 @@ namespace taler {
}
}
- function onPageLoadInExtension() {
- if (document.documentElement.getAttribute("data-taler-nojs")) {
- logVerbose && console.log("doing taler initialization from extension
(nojs)");
- initTaler();
- }
- }
-
- let caught = false;
- try {
- (chrome as any).runtime.sendMessage({type: "ping"});
- } catch (e) {
- caught = true;
- }
-
- if (caught) {
- logVerbose && console.log("running taler-wallet-lib from page");
- initTaler();
- } else {
- logVerbose && console.log("running taler-wallet-lib from extension");
- runningInExtension = true;
- // Wait for even style sheets to load
- if (document.readyState != "complete") {
- window.addEventListener("load", () => onPageLoadInExtension());
- } else {
- onPageLoadInExtension();
- }
- }
+ logVerbose && console.log("running taler-wallet-lib from page");
}
// @license-end
--
To stop receiving notification emails like this one, please contact
address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] [taler-web-common] branch master updated: move handling stylesheets into extension,
gnunet <=