Skip to content

Commit 915511a

Browse files
committed
fix unique class for copyright anchor style
1 parent cf076bc commit 915511a

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

src/js/pocket.gl.js

+10-6
Original file line numberDiff line numberDiff line change
@@ -463,18 +463,22 @@ define([
463463
PocketGL.prototype.addCopyright = function(domElement) {
464464
if(this.params.copyright == "") return;
465465

466+
var className = "pocketgl-copyright-";
467+
if(this.domContainer.id != "") className += this.domContainer.id;
468+
else className += Utils.guid();
469+
466470
var copyright = document.createElement("div");
467471
copyright.innerHTML = this.params.copyright;
468-
copyright.className = "pocketgl-copyright pocketgl";
472+
copyright.className = className + " pocketgl-copyright pocketgl";
469473
copyright.style.color = this.params.copyrightColor;
470474

471475
var style = document.createElement("style");
472476
style.innerHTML = [
473-
".pocketgl-copyright a,",
474-
".pocketgl-copyright a:hover,",
475-
".pocketgl-copyright a:active,",
476-
".pocketgl-copyright a:visited,",
477-
".pocketgl-copyright a:focus { color: " + this.params.copyrightLinkColor + "; }"].join("\n");
477+
"." + className + " a,",
478+
"." + className + " a:hover,",
479+
"." + className + " a:active,",
480+
"." + className + " a:visited,",
481+
"." + className + " a:focus { color: " + this.params.copyrightLinkColor + "; }"].join("\n");
478482

479483
domElement.appendChild(copyright);
480484
domElement.appendChild(style);

src/js/utils.js

+11
Original file line numberDiff line numberDiff line change
@@ -109,5 +109,16 @@ define(function() {
109109
return JSON.parse(JSON.stringify(obj));
110110
}
111111

112+
// http://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript
113+
Utils.prototype.guid = function() {
114+
function s4() {
115+
return Math.floor((1 + Math.random()) * 0x10000)
116+
.toString(16)
117+
.substring(1);
118+
}
119+
120+
return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
121+
}
122+
112123
return new Utils();
113124
});

0 commit comments

Comments
 (0)