X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=experimental%2Fpalette%2Fpalette.js;h=d98ab15fd18ecb2179f0bbd02b9adc61562e69a1;hb=03d2998b741f48e9d92ecbadfd62201886a19fda;hp=65ef612749a55c7ef1b716b2071d12ed29e5a6c4;hpb=7754081a7dc2bd2f399fe6f029b581451123bd83;p=dygraphs.git diff --git a/experimental/palette/palette.js b/experimental/palette/palette.js index 65ef612..d98ab15 100644 --- a/experimental/palette/palette.js +++ b/experimental/palette/palette.js @@ -38,103 +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"; - // 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 = $("