git @ Cat's Eye Technologies HTML5-Gewgaws / a34b0fb
Small addition to the element factory: collapsible panels. Chris Pressey 10 years ago
1 changed file(s) with 20 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
66
77 /*
88 * Functions for creating elements.
9 *
10 * I dunno -- maybe just setting innerHTML would be better.
119 */
1210
1311 yoob.makeCanvas = function(container, width, height) {
9896 return div;
9997 };
10098
99 yoob.makePanel = function(container, title, isOpen) {
100 isOpen = !!isOpen;
101 var panelContainer = document.createElement('div');
102 var button = document.createElement('button');
103 var innerContainer = document.createElement('div');
104 innerContainer.style.display = isOpen ? "block" : "none";
105
106 button.innerHTML = (isOpen ? "∇" : "⊳") + " " + title;
107 button.onclick = function(e) {
108 isOpen = !isOpen;
109 button.innerHTML = (isOpen ? "∇" : "⊳") + " " + title;
110 innerContainer.style.display = isOpen ? "block" : "none";
111 };
112
113 panelContainer.appendChild(button);
114 panelContainer.appendChild(innerContainer);
115 container.appendChild(panelContainer);
116 return innerContainer;
117 };
118
101119 yoob.makeTextArea = function(container, cols, rows, initial) {
102120 var textarea = document.createElement('textarea');
103121 textarea.rows = "" + rows;