git @ Cat's Eye Technologies yoob.js / f0327a9
Add more functions to element-factory.js. Chris Pressey 10 years ago
1 changed file(s) with 42 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
2222 return canvas;
2323 };
2424
25 yoob.makeButton = function(container, label) {
25 yoob.makeButton = function(container, labelText) {
2626 var button = document.createElement('button');
27 button.innerHTML = label;
27 button.innerHTML = labelText;
2828 container.appendChild(button);
2929 return button;
3030 };
6767 container.appendChild(p);
6868 return p;
6969 };
70
71 yoob.makeTextArea = function(container, cols, rows, initial) {
72 var textarea = document.createElement('textarea');
73 textarea.rows = "" + rows;
74 textarea.cols = "" + cols;
75 if (initial) {
76 container.value = initial;
77 }
78 container.appendChild(textarea);
79 return textarea;
80 };
81
82 yoob.makeLineBreak = function(container) {
83 var br = document.createElement('br');
84 container.appendChild(br);
85 return br;
86 };
87
88 yoob.makeSelect = function(container, labelText, optionsArray) {
89 var label = document.createElement('label');
90 label.innerHTML = labelText;
91 container.appendChild(label);
92
93 var select = document.createElement("select");
94
95 for (var i = 0; i < optionsArray.length; i++) {
96 var op = document.createElement("option");
97 op.value = optionsArray[i][0];
98 op.text = optionsArray[i][1];
99 if (optionsArray[i].length > 2) {
100 op.selected = optionsArray[i][2];
101 } else {
102 op.selected = false;
103 }
104 select.options.add(op);
105 }
106
107 container.appendChild(select);
108 return select;
109 };