git @ Cat's Eye Technologies yoob.js / 2113c30
Make ExampleManager slightly less lame. Cat's Eye Technologies 11 years ago
2 changed file(s) with 17 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
1212 <h1>yoob.ExampleManager Demo</h1>
1313
1414 <p>Example program: <select id="example_selector"></select></p>
15
16 <p>
17 <button onclick="e.clear();">Clear Example Selector</button>
18 <button onclick="e.populateFromClass('example_program');">Populate Example Selector</button>
19 </p>
1520
1621 <div id="program_one" class="example_program">Good
1722 cheese
2424 this.exampleClass = cfg.exampleClass || null;
2525 this.controller = cfg.controller || null;
2626 this.clear();
27 this.reactTo = {};
2827 var $this = this;
2928 this.selectElem.onchange = function() {
3029 $this.select(this.options[this.selectedIndex].value);
3231 return this;
3332 };
3433
34 /*
35 * Removes all options from the selectElem, and their associated data.
36 */
3537 this.clear = function() {
38 this.reactTo = {};
3639 while (this.selectElem.firstChild) {
3740 this.selectElem.removeChild(this.selectElem.firstChild);
3841 }
42 this.add('(select one...)', function() {});
3943 return this;
4044 };
4145
5862 return this;
5963 };
6064
65 /*
66 * Called by the selectElem's onchange event. For sanity, you should
67 * probably not call this yourself.
68 */
6169 this.select = function(id) {
6270 this.reactTo[id](id);
71 if (this.onselect) {
72 this.onselect(id);
73 }
6374 };
6475
6576 /*