Small addition to the element factory: collapsible panels.
Chris Pressey
10 years ago
6 | 6 | |
7 | 7 | /* |
8 | 8 | * Functions for creating elements. |
9 | * | |
10 | * I dunno -- maybe just setting innerHTML would be better. | |
11 | 9 | */ |
12 | 10 | |
13 | 11 | yoob.makeCanvas = function(container, width, height) { |
98 | 96 | return div; |
99 | 97 | }; |
100 | 98 | |
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 | ||
101 | 119 | yoob.makeTextArea = function(container, cols, rows, initial) { |
102 | 120 | var textarea = document.createElement('textarea'); |
103 | 121 | textarea.rows = "" + rows; |