- if (opts.hasOwnProperty(opt)) {
- var type = opts[opt].type;
- var isFunction = type.indexOf("function(") == 0;
- var row = createChild("tr", table);
- var div = createChild("div", createChild("td", row));
- var a = createChild("a", div);
- a.innerText = opt;
- a.href = "http://dygraphs.com/options.html#" + opt;
- a.title = Dygraph.OPTIONS_REFERENCE[opt].description;
- a.target="_blank";
-
- if (isFunction) {
- var input = createChild("button", createChild("td", row));
- 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 + "{ }";
- }
- var value = prompt("enter function", inputValue);
- if (value != null) {
- if (value.length == 0) {
- value = null;
- }
- 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}";