- if (opts.hasOwnProperty(opt)) {
- var type = opts[opt].type;
- var isFunction = type.indexOf("function(") == 0;
- var row = Palette.createChild("div", table);
- row.onmouseover = function(source, title, type, body, e) {
- return function(e) {
- palette.tooltip.show(source, e, title, type, body);
- };
- } (row, opt, type, Dygraph.OPTIONS_REFERENCE[opt].description);
- row.onmouseout = function() { palette.tooltip.hide(); };
-
- var div = Palette.createChild("span", row);
- div.innerText = opt;
- div.className = "name";
-
- var value = Palette.createChild("span", row);
- value.className = "option";
-
- if (isFunction) {
- var input = Palette.createChild("button", value);
- input.onclick = function(opt, palette) {
- return function(event) {
- var entry = palette.model[opt];
- var inputValue = entry.functionString;
- if (inputValue == null || inputValue.length == 0) {
- inputValue = opts[opt].type + "{\n\n}";
- }
- var textarea = new TextArea();
- textarea.show("Function for " + opt, inputValue);
- textarea.okCallback = function(value) {
- if (value != inputValue) {
- entry.functionString = value;
- entry.input.innerText = value ? "defined" : "not defined";
- palette.onchange();
+ 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 type = optEntry.type;
+ var isFunction = type.indexOf("function(") == 0;
+
+ var input;
+ if (isFunction) {
+ input = $("<button>")
+ .click(function(opt, palette) {
+ return function(event) {
+ var entry = palette.model[opt];
+ var inputValue = entry.functionString;
+ var type = opts[opt].type;
+ if (inputValue == null || inputValue.length == 0) {
+ inputValue = type + "{\n\n}";