All files / src/ui form.js

1.86% Statements 8/430
0% Branches 0/129
1.29% Functions 1/77
1.86% Lines 8/428

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913        18x           18x                                                                                                                                                                                                                                                                                           18x                                                                                                                                                                                                                         18x                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             18x                                                                                                   18x                                                                                                                                                             18x                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   18x  
/**
 * This is a colection of contructor to make different input element
 * @function $3Dmol.UI#Form
 */
$3Dmol.UI.Form = (function () {
    /**
     * Create Color input
     * @function $3Dmol.UI#Form.Color
     * @param {Object} outerControl Reference object to store the value
     */
    Form.Color = function (outerControl) {
        var redDot = $('<div></div>');
        redDot.height(10);
        redDot.width(10);
        redDot.css('border-radius', '50%');
        redDot.css('background', 'red');
        redDot.css('margin-right', '3px');
 
        var blueDot = redDot.clone();
        blueDot.css('background', 'blue');
 
        var greenDot = redDot.clone();
        greenDot.css('background', 'green');
 
        var control = this.control = {
            R: {
                value: 0,
                min: 0,
                max: 255,
                label: redDot
            },
            G: {
                value: 0,
                min: 0,
                max: 255,
                label: greenDot
            },
            B: {
                value: 0,
                min: 0,
                max: 255,
                label: blueDot
            },
        };
 
        var surroundingBox = this.ui = $('<div></div>')
        var boundingBox = $('<div></div>');
 
        surroundingBox.append(boundingBox);
 
        var spectrumControl = {
            key: 'Spectrum',
            value: null
        }
 
        var spectrum = new Form.Checkbox(spectrumControl);
 
        boundingBox.append(spectrum.ui);
 
        spectrum.ui.css({
            'margin-left': '2px'
        })
 
 
        var RValue = new Form.Slider(control.R);
        var GValue = new Form.Slider(control.G);
        var BValue = new Form.Slider(control.B);
 
        var sliders = $('<div></div>');
        sliders.append(RValue.ui, GValue.ui, BValue.ui);
 
        var color = $('<div></div>');
 
        boundingBox.append(sliders);
        boundingBox.append(color);
 
 
        // CSS
 
        RValue.slide.css('color', 'red');
 
        // GValue.ui.css('display', 'block');
        GValue.slide.css('color', 'green');
 
        // BValue.ui.css('display', 'block');
        BValue.slide.css('color', 'blue');
 
        color.height(15);
        // color.width(50);
        color.css('margin-top', '6px');
        color.css('margin-bottom', '6px');
        color.css('border', '1px solid grey');
        color.css('border-radius', '500px');
 
        this.update = function () {};
        var self = this;
        // Functionality
        function updatePreview() {
            var c = `rgb(${control.R.value}, ${control.G.value}, ${control.B.value})`;
            color.css('background', c);
            outerControl.value = c;
            self.update(control);
        }
 
        RValue.update = GValue.update = BValue.update = updatePreview;
        updatePreview();
 
        spectrum.update = function (v) {
            sliders.toggle();
 
            if (v.value) {
                color.css({
                    'background': 'linear-gradient(to right, red, orange, yellow, green, blue, indigo, violet)'
                });
                outerControl.value = 'spectrum';
            } else {
                updatePreview();
            }
        }
 
        this.getValue = function () {
            return outerControl;
        }
 
        this.validate = function () {
            return true;
        }
 
        this.setValue = function (colorValue) {
 
I            if (colorValue == 'spectrum') {
                spectrum.setValue(true);
                spectrum.update(spectrumControl);
                sliders.hide();
 
                outerControl.value = 'spectrum';
            }
        }
 
        spectrum.ui.hide();
 
        this.enableSpectrum = function () {
            spectrum.ui.show();
        }
    }
 
    /**
     * Create ListInput input
     * @function $3Dmol.UI#Form.ListInput
     * @param {Object} control Reference object to store the value
     * @param {Array} listElements list of the elements through which options are generated
     */
    Form.ListInput = function (control, listElements) {
        // var label = $('<div></div>');
        // label.text(control.key);
 
        var surroundingBox = this.ui = $('<div></div>');
        var boundingBox = $('<div></div>');
        var itemList = listElements;
        // surroundingBox.append(label);
        surroundingBox.append(boundingBox);
 
        var select = $('<select></select>');
        select.css($3Dmol.defaultCSS.ListInput.select);
 
        boundingBox.append(select);
 
        this.showAlertBox = true;
        var failMessage = $('<div></div>');
        failMessage.text('Please select some value');
        failMessage.css({
            'color': 'crimson',
            'font-family': 'Arial',
            'font-weight': 'bold',
            'font-size': '10px'
        });
        failMessage.hide();
        boundingBox.append(failMessage);
 
        this.update = function () {}
 
        select.on('click', {
            parent: this
        }, (event) => {
            control.value = select.children('option:selected').val();
            event.data.parent.update(control);
        });
 
        this.getValue = () => {
            return control;
        }
 
        // this.preventAlertBox = function(){
        //     show
        // }
 
        this.validate = function () {
            if (control.value == 'select' || control.value == null) {
                (this.showAlertBox) ? failMessage.show(): null;
                select.css({
                    'box-shadow': '0px 0px 2px red'
                });
                return false;
            } else {
                failMessage.hide();
                boundingBox.css({
                    'box-shadow': 'none'
                });
                return true;
            }
        }
 
        this.setValue = function (val) {
            if (listElements.indexOf(val) != -1) {
                select.empty();
                var defaultOption = $('<option></option>');
                defaultOption.text('select');
 
                itemList.forEach((item) => {
                    var option = $('<option></option>');
                    option.text(item);
                    option.attr('value', item);
                    select.append(option);
 
I                    if (val == item) {
                        option.prop('selected', true);
                    }
                });
 
                control.value = select.children('option:selected').val();
            } else {
                console.error('UI::Form::ListInput:incorrect value', val);
            }
        }
 
        this.updateList = function (newList) {
            select.empty();
 
            var defaultOption = $('<option></option>');
            defaultOption.text('select');
            defaultOption.attr('value', 'select');
 
            select.append(defaultOption);
 
            itemList = newList;
            itemList.forEach((item) => {
                var option = $('<option></option>');
                option.text(item);
                option.attr('value', item);
                select.append(option);
            });
        }
 
        this.updateList(itemList);
    }
 
    /**
     * Create text, numeric or range Input
     * @function $3Dmol.UI#Form.Input
     * @param {Object} control Reference object to store the value
     */
    Form.Input = function (control) {
        var surroundingBox = this.ui = $('<div></div>');
        var boundingBox = $('<div></div>');
        // surroundingBox.append(label);
        surroundingBox.append(boundingBox);
 
        var validationType = this.validationType = 'text';
 
        surroundingBox.css({
            'width': '100%',
            'box-sizing': 'border-box'
        })
 
        var input = this.domElement = $('<input type="text">');
        boundingBox.append(input);
 
        var alertBox = $('<div></div>');
        alertBox.css({
            'border': '1px solid darkred',
            'border-radius': '3px',
            'font-family': 'Arial',
            'font-size': '10px',
            'font-weight': 'bold',
            'margin': '2px',
            'margin-left': '4px',
            'padding': '2px',
            'color': 'darkred',
            'background': 'lightcoral'
        });
 
        var alertMessage = {
            'invalid-input': 'Invalid input please check the value entered',
        }
 
        boundingBox.append(alertBox);
        alertBox.hide();
 
        this.setWidth = function (width) {
            input.width(width - 6);
        }
 
        this.setWidth(75);
 
        input.css({
            // 'margin-left': '4px'
        });
 
        this.update = function () {
 
        }
 
        input.on('change', {
            parent: this,
            control: control
        }, (event) => {
            let inputString = input.val();
 
I            if (inputString[inputString.length - 1] == ',') {
                inputString = inputString.slice(0, -1);
            }
 
            if (validationType == 'range') {
                control.value = inputString.split(',');
            } else {
                control.value = inputString;
            }
 
            // calling update function 
            event.data.parent.update(control);
        });
 
        input.on('select', () => {
           // selectedText = input.val().substring(e.target.selectionStart, e.target.selectionEnd);
        });
 
 
        this.getValue = () => {
            return control;
        }
 
        var error = this.error = function (msg) {
            alertBox.show();
            alertBox.text(msg)
        }
 
        this.setValue = function (val) {
 
            if (validationType == 'range') {
                var text = val.join(',');
                input.val(text);
            } else {
                input.val(val);
            }
 
            control.value = val;
        }
 
 
 
        function checkInputFloat() {
            var inputString = input.val();
 
            var dots = inputString.match(/\./g) || [];
            var checkString = inputString.replaceAll(/\./g, '').replaceAll(/[0-9]/g, '');
 
I            if (dots.length > 1) {
                return false
            }
 
I            if (checkString != '') return false;
 
            if (isNaN(parseFloat(inputString))) {
                return false;
            } else {
                return true;
            }
        }
 
        function checkInputNumber() {
            var inputString = input.val();
 
            var checkString = inputString.replaceAll(/[0-9]/g, '');
 
I            if (checkString != '') return false;
 
            if (isNaN(parseInt(inputString))) {
                return false;
            } else {
                return true;
            }
        }
 
        // Parse Input Range Functions
 
        // Checks only number, comma and hyphen present
        function checkRangeTokens(inputString) {
            var finalString = inputString.replaceAll(',', '').replaceAll('-', '').replaceAll(/[0-9]/g, '').replaceAll(' ', '');
 
            if (finalString == '')
                return true;
            else
                return false;
        }
 
        function checkList(inputString) {
            inputString = inputString.replaceAll(' ', '');
 
I            if (inputString[inputString.length - 1] == ',') {
                inputString = inputString.slice(0, -1);
            }
 
 
            var rangeList = inputString.split(',');
 
            // If dublicate comma return false;
I            if (/,,/g.exec(inputString)) return false;
 
            // If first element not a number return false;
I            if (isNaN(parseInt(rangeList[0]))) return false;
 
            var validRangeList = rangeList.map((rangeInput) => {
                return checkRangeInput(rangeInput);
            });
 
            return validRangeList.find((e) => {
                return e == false
            }) == undefined ? true : false;
        }
 
        function checkRangeInput(inputString) {
            var rangeInputs = inputString.split('-');
            if (rangeInputs.length > 2) {
                return false;
            } else {
                if (rangeInputs.length == 0) {
                    return true;
                } else if (rangeInputs.length == 1) {
                    if (isNaN(parseInt(rangeInputs[0])))
                        return false;
                    else
                        return true;
                } else if (rangeInputs.length == 2) {
                    if (isNaN(parseInt(rangeInputs[0])) || isNaN(parseInt(rangeInputs[1])))
                        return false;
                    else
                        return true;
                } else
                    return false;
            }
        }
 
        var checkInput = this.checkInput = function () {
            var inputString = input.val();
 
            if (validationType == 'number') {
                if (checkInputNumber()) {
                    alertBox.hide();
                    return true;
                } else {
                    error(alertMessage['invalid-input']);
                    return false;
                }
            } else if (validationType == 'float') {
                if (checkInputFloat()) {
                    alertBox.hide();
                    return true;
                } else {
                    error(alertMessage['invalid-input']);
                    return false;
                }
            } else if (validationType == 'range') {
                if (checkRangeTokens(inputString)) {
                    if (checkList(inputString)) {
                        alertBox.hide();
                        return true;
                    } else {
                        error(alertMessage['invalid-input']);
                        return false;
                    }
                } else {
                    error(alertMessage['invalid-input']);
                    return false;
                }
 
            } else {
                return true;
            }
        }
 
        this.validateOnlyNumber = function (floatType = false) {
            if (floatType) {
                validationType = 'float';
            } else {
                validationType = 'number';
            }
 
            input.on('keydown keyup paste cut', function () {
                checkInput();
            });
        }
 
 
        this.validateInputRange = function () {
            validationType = 'range';
 
            input.on('keydown keyup paste cut', () => {
                checkInput();
            });
 
        }
 
        this.isEmpty = function () {
I            if (control.value == "") {
                return true;
            }
        }
 
        this.validate = function () {
            if ((control.active == true && control.value != null && control.value != "" && checkInput()) || (control.active == false)) {
                input.css('box-shadow', 'none');
                return true
            } else {
                input.css('box-shadow', '0px 0px 2px red');
                return false;
            }
        }
 
        // CSS 
 
        input.css($3Dmol.defaultCSS.Input.input);
        boundingBox.css($3Dmol.defaultCSS.Input.boundingBox);
 
    }
 
    /**
     * Create Checkbox input for boolean values
     * @function $3Dmol.UI#Form.Checkbox
     * @param {Object} control Reference object to store the value
     */
    Form.Checkbox = function (control) {
        var label = $('<div></div>');
        label.text(control.key);
        label.css($3Dmol.defaultCSS.TextDefault);
 
        var surroundingBox = this.ui = $('<div></div>');
        var boundingBox = $('<div></div>');
        surroundingBox.append(boundingBox);
        surroundingBox.append(label);
 
        var checkbox = $('<input type="checkbox" />');
        boundingBox.append(checkbox);
 
        this.click = () => {};
 
        this.update = function () {
 
        }
 
        this.getValue = () => {
            return control;
        }
 
        checkbox.on('click', {
            parent: this
        }, (event) => {
            control.value = checkbox.prop('checked');
            event.data.parent.update(control);
        });
 
        // CSS
        label.css('display', 'inline-block');
        boundingBox.css('display', 'inline-block')
 
        this.validate = function () {
            return true;
        }
 
        this.setValue = function (val) {
            checkbox.prop('checked', val);
            this.update(control);
            control.value = val;
        }
    }
 
    /**
     * Create input for values between two numbers
     * @function $3Dmol.UI#Form.Slider
     * @param {Object} control Reference object to store the value
     */
    Form.Slider = function (control) {
        var surroundingBox = this.ui = $('<div></div>');
 
        var boundingBox = $('<div></div>');
        surroundingBox.append(boundingBox);
 
        boundingBox.css('display', 'flex');
        var slide = this.slide = $('<input type="range">');
        slide.css('width', '100%');
 
        var min = control.min || 0;
        var max = control.max || 100;
        var step = control.step || 1;
        var defaultValue = control.default || min;
        var labelContent = control.label || '';
 
        var label = $('<div></div>');
        label.append(labelContent);
        boundingBox.append(label);
 
        slide.attr('min', min);
        slide.attr('max', max);
        slide.attr('step', step);
        slide.attr('value', defaultValue);
        control.value = defaultValue;
        boundingBox.append(slide);
 
        var setValue = false;
 
        this.update = function () {
 
        };
 
        this.getValue = () => {
            return control;
        }
 
        slide.on('mousedown', () => {
            setValue = true;
        });
 
        slide.on('mousemove', {
            parent: this
        }, (event) => {
I            if (setValue) {
                control.value = slide.val();
                event.data.parent.update(control);
            }
        });
 
        slide.on('mouseup', () => {
            setValue = false;
        });
 
        // CSS
        boundingBox.css('align-items', 'center');
        boundingBox.height('21px');
        // boundingBox.css('border-radius', '2px');
        // label.css('line-height', '21px');
        slide.css('padding', '0px');
        slide.css('margin', '0px');
 
        this.validate = function () {
            return true;
        }
 
        this.setValue = function (val) {
            slide.val(val);
            control.value = slide.val();
        }
 
 
    }
 
    /**
     * Create empty element used for property that whose input cannot be taken
     * @function $3Dmol.UI#Form.EmptyElement
     * @param {Object} control Reference object to store the value
     */
    Form.EmptyElement = function (control) {
        this.ui = $('<div></div>');
 
        this.onUpdate = () => {
        }
 
        this.getValue = () => {
            return control;
        }
 
        this.validate = function () {
            return true;
        }
    }
 
    // mainControl param will be used to take in specName
    // in the form of key 
    // type will be 'form'
    // active will be used to activate deactivate form if more than one form
    /**
     * Creates Form input that takes input from different input element 
     * 
     * @function $3Dmol.UI#Form
     * @param {validSelectionSpec|validStyleSpec|validAtomSpec} specs the defination of spec is used as an input to generate the form
     * @param {Object} mainControl Reference of variable to store the value from the form
     */
    function Form(specs, mainControl) {
        specs = specs || {};
        var boundingBox = this.ui = $('<div></div>');
 
        var heading = $('<div></div>');
        heading.text(mainControl.key);
 
        // Styling heading 
        heading.css({
            'border-bottom': '1px solid black',
            'font-family': 'Arial',
            'font-size': '14px',
            'font-weight': 'bold',
            'padding-top': '2px',
            'padding-bottom': '4px'
        });
 
        boundingBox.append(heading);
        boundingBox.addClass('form');
 
        var inputs = this.inputs = [];
        // body.append(boundingBox);
 
        var keys = Object.keys(specs);
        keys.forEach((key) => {
I            if (specs[key].gui) {
                var prop = new Property(key, specs[key].type);
                inputs.push(prop);
                boundingBox.append(prop.ui);
            }
 
        });
 
        this.update = function () {}
 
        var update = () => {
        };
 
 
        inputs.forEach((input) => {
            input.update = update;
        })
 
        this.getValue = function () {
            mainControl.value = {};
 
            inputs.forEach((input) => {
                var inputValue = input.getValue();
 
I                if (inputValue.active) {
                    mainControl.value[inputValue.key] = inputValue.value;
                }
            });
 
            return mainControl;
        }
 
        var updateValues = function (inputControl) {
            mainControl.value[inputControl.key] = mainControl.value; //control =?
            update(mainControl);
        }
 
        this.validate = function () {
            var validations = inputs.map((i) => {
 
                if (i.active.getValue().value) {
                    return i.placeholder.validate();
                } else {
                    return true;
                }
            });
 
 
            if (validations.find(e => e == false) == undefined)
                return true;
            else {
                return false;
            }
 
        }
 
        this.setValue = function (val) {
            var keys = Object.keys(val);
            for (var i = 0; i < keys.length; i++) {
                var input = inputs.find((e) => {
I                    if (e.control.key == keys[i])
                        return e;
                });
 
 
 
                input.placeholder.setValue(val[keys[i]]);
                input.active.setValue(true);
                input.placeholder.ui.show();
                input.control.active = true;
            }
 
            // mainControl.value = val;
            this.update(mainControl);
            this.getValue();
        }
 
        this.getInputs = function () {
            return inputs;
        }
 
        function Property(key, type) {
            var control = this.control = {
                value: null,
                type: type,
                key: key,
                active: false
            };
            var boundingBox = this.ui = $('<div></div>');
            this.placeholder = {
                ui: $('<div></div>')
            }; // default value for ui element 
            this.active = new Form.Checkbox({
                value: false,
                key: key
            });
 
 
            if (specs[key].type == 'string' || specs[key].type == 'element') {
                this.placeholder = new Form.Input(control);
                this.placeholder.ui.attr('type', 'text');
            } else if (specs[key].type == 'number') {
 
                var slider = false;
 
I                if (specs[key].min != undefined && specs[key].max != undefined && specs[key].default != undefined) {
                    slider = true;
                }
 
                if (slider) {
                    // if( specs[key].min && spec[key].max){
                    control.min = specs[key].min;
                    control.max = specs[key].max;
                    control.default = specs[key].default;
                    control.step = specs[key].step || ((control.max - control.max) / 1000);
                    this.placeholder = new Form.Slider(control);
                } else {
                    this.placeholder = new Form.Input(control);
                    this.placeholder.ui.attr('type', 'text');
                    this.placeholder.validateOnlyNumber(specs[key].floatType);
                }
            } else if (specs[key].type == 'array_range') {
                this.placeholder = new Form.Input(control);
                this.placeholder.ui.attr('type', 'text');
                this.placeholder.validateInputRange();
            } else if (specs[key].type == 'color') {
                this.placeholder = new Form.Color(control);
I                if (specs[key].spectrum) {
                    this.placeholder.enableSpectrum();
                }
 
            } else if (specs[key].type == 'boolean') {
                this.placeholder = new Form.Checkbox(control);
 
            } else if (specs[key].type == 'properties') {
                this.placeholder = new Form.Input(control);
                this.placeholder.ui.attr('type', 'text');
 
            } else if (specs[key].type == 'colorscheme') {
                this.placeholder = new Form.ListInput(control, Object.keys($3Dmol.builtinColorSchemes));
                this.placeholder.ui.attr('type', 'text');
 
            } else if (specs[key].type == undefined) {
I                if (specs[key].validItems) {
                    this.placeholder = new Form.ListInput(control, specs[key].validItems);
                }
 
            } else if (specs[key].type == 'form') {
                this.placeholder = new Form(specs[key].validItems, control);
                this.placeholder.ui.append($('<div></div>').css($3Dmol.defaultCSS.LinkBreak));
            } else {
                this.placeholder = new Form.EmptyElement(control);
                // return new Form.EmptyElement(control);
            }
 
            this.getValue = function () {
 
                if (this.placeholder.getValue)
                    return this.placeholder.getValue();
                else
                    return null;
            }
 
 
            // Adding active control for the property
            var placeholder = this.placeholder;
 
            if (type != 'boolean') {
                placeholder.ui.hide();
                boundingBox.append(this.active.ui);
                this.active.update = function (c) {
                    (c.value) ? placeholder.ui.show(): placeholder.ui.hide();
                    control.active = c.value;
                }
            } else {
                this.placeholder.update = function (c) {
                    control.active = c.value;
                }
            }
 
            boundingBox.append(this.placeholder.ui);
 
I            if (this.placeholder.onUpdate)
                this.placeholder.onUpdate(updateValues);
        }
 
 
    }
 
 
 
    return Form;
})();