Skip to content

Commit

Permalink
Fixed none shown hint labels by CSP headers #531.
Browse files Browse the repository at this point in the history
The styling by elements style attribute might be forbidden by
Content-Security-Policy restrictions. But positioning of the elements by
the elements style object seems to work.
  • Loading branch information
fanglingsu committed Nov 21, 2018
1 parent 3195dd1 commit 76bbf87
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/scripts/hints.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,10 @@ var hints = Object.freeze((function(){
/* create the hint label with number/letters */
rect = e.getClientRects()[0];
label = labelTmpl.cloneNode(false);
label.setAttribute(
"style", [
"display:none;",
"left:", rect.left, "px;",
"top:", rect.top, "px;"
].join("")
);

label.style.display = "none";
label.style.left = rect.left + "px";
label.style.top = rect.top + "px";

/* if hinted element is an image - show title or alt of the image in hint label */
/* this allows to see how to filter for the image */
Expand Down Expand Up @@ -226,7 +223,10 @@ var hints = Object.freeze((function(){
/* append the fragment to the document */
var hDiv = doc.createElement("div");
hDiv.setAttribute(attr, "container");
hDiv.setAttribute("style", "position:fixed;top:0;left:0;z-index:225000;");
hDiv.style.position = "fixed";
hDiv.style.top = "0";
hDiv.style.left = "0";
hDiv.style.zIndex = "225000";
hDiv.appendChild(fragment);
if (doc.body) {
doc.body.appendChild(hDiv);
Expand Down

0 comments on commit 76bbf87

Please sign in to comment.