X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=experimental%2Fpalette%2Ftooltip.js;h=a1d88567c27a6a65577a95d45cc3b324cb9c30c4;hb=9390f62431dfa8174b52d0aef45df7b4c7da138e;hp=6ceb16eff61e08f119f23b5934fd3cf9c4e3a753;hpb=44885208a48a23f1e1a9e3bb867efdc94f1e5933;p=dygraphs.git diff --git a/experimental/palette/tooltip.js b/experimental/palette/tooltip.js index 6ceb16e..a1d8856 100644 --- a/experimental/palette/tooltip.js +++ b/experimental/palette/tooltip.js @@ -29,21 +29,30 @@ function Tooltip(parent) { if (!parent) { parent = document.getElementsByTagName("body")[0]; } - this.elem = Palette.createChild("div", parent); - this.title = Palette.createChild("div", this.elem); + this.elem = Tooltip.createChild("div", parent); + this.title = Tooltip.createChild("div", this.elem); this.elem.className = "tooltip"; this.title.className = "title"; - this.type = Palette.createChild("div", this.elem); + this.type = Tooltip.createChild("div", this.elem); this.type.className = "type"; - this.body = Palette.createChild("div", this.elem); + this.body = Tooltip.createChild("div", this.elem); this.body.className = "body"; this.hide(); } -Tooltip.prototype.show = function(source, event, title, type, body) { +Tooltip.createChild = function(type, parentElement, className) { + var element = document.createElement(type); + parentElement.appendChild(element); + if (className) { + element.className = className; + } + return element; +}; + +Tooltip.prototype.show = function(source, title, type, body) { this.title.innerHTML = title; this.body.innerHTML = body; - this.type.innerText = type; // innerText for arrays. + this.type.textContent = type; // textContent for arrays. var getTopLeft = function(element) { var x = element.offsetLeft;