X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=experimental%2Fpalette%2Fpalette.js;h=514463f554c45d374cb8ec6497c0b672c9133a12;hb=4c10c8d21b6858ea9029bdb789f487d9103d72f9;hp=9e4139f9225f428a2bf1b732b903273e3bc8ffe9;hpb=9ccb0d6e22effd68675bf310da9e601df0fa00a3;p=dygraphs.git diff --git a/experimental/palette/palette.js b/experimental/palette/palette.js index 9e4139f..514463f 100644 --- a/experimental/palette/palette.js +++ b/experimental/palette/palette.js @@ -38,112 +38,96 @@ function Palette(scope) { this.root = null; } -Palette.createChild = function(type, parentElement, className) { - var element = document.createElement(type); - parentElement.appendChild(element); - if (className) { - element.className = className; - } - return element; -}; - Palette.prototype.create = function(parentElement) { var palette = this; - var table = Palette.createChild("div", parentElement[0], "palette"); - this.root = table; - table.width="300px"; + var table = $("
") + .addClass("palette") + .width(300) + .appendTo(parentElement); + this.root = table; this.tooltip = new Tooltip(); - // Build the header - var header = Palette.createChild("div", table, "header"); - header.style.visibility = "visible"; - - // CURRENTLY HIDDEN. - var tmp = Palette.createChild("button", Palette.createChild("span", header)); - tmp.textContent = "Copy" - tmp.onclick = function() { - var textarea = new TextArea(); - textarea.show("header", "Now is the time for all good men\nto come to the aid of their country"); - }; - tmp.style.display = "none"; - // One row per option. - for (var opt in opts) { + $.each(opts, function(opt, optEntry) { try { - if (opts.hasOwnProperty(opt)) { - var type = opts[opt].type; + var scope = optEntry.scope || [ "global" ]; // Scope can be empty, infer "global" only. + var valid = scope[0] == "*" || $.inArray(palette.scope, scope) >= 0; + if (!valid) { + return; + } - var scope = opts[opt].scope || [ "global" ]; // Scope can be empty, infer "global" only. - var valid = scope[0] == "*" || $.inArray(this.scope, scope) >= 0; - if (!valid) { - continue; - } + var type = optEntry.type; + var isFunction = type.indexOf("function(") == 0; + + var input; + if (isFunction) { + input = $("