+ 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}";
+ }
+ var textarea = new TextArea();
+ textarea.show(opt, inputValue);
+ textarea.okCallback = function(value) {
+ if (value != inputValue) {
+ entry.functionString = value;
+ entry.input.textContent = value ? "defined" : "not defined";
+ palette.onchange();
+ }
+ };
+ };
+ } (opt, palette) // Instantiating this inner function.
+ );
+ } else if (type == "boolean") {
+ input = $("<button>")
+ .click(function(event) {
+ var btn = event.target;
+ if (btn.value == "none") {
+ Palette.populateBooleanButton(btn, "true");
+ } else if (btn.value == "true") {
+ Palette.populateBooleanButton(btn, "false");
+ } else {
+ Palette.populateBooleanButton(btn, "none");
+ }
+ palette.onchange();
+ });
+ } else {
+ input = $("<input>", { type: "text" })
+ .addClass("textInput")
+ .keypress(function(event) {
+ var keycode = event.which;
+ if (keycode == 13 || keycode == 8) {
+ palette.onchange();
+ }
+ });
+ }