Make ExampleManager slightly less lame.
Cat's Eye Technologies
11 years ago
12 | 12 |
<h1>yoob.ExampleManager Demo</h1>
|
13 | 13 |
|
14 | 14 |
<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>
|
15 | 20 |
|
16 | 21 |
<div id="program_one" class="example_program">Good
|
17 | 22 |
cheese
|
24 | 24 |
this.exampleClass = cfg.exampleClass || null;
|
25 | 25 |
this.controller = cfg.controller || null;
|
26 | 26 |
this.clear();
|
27 | |
this.reactTo = {};
|
28 | 27 |
var $this = this;
|
29 | 28 |
this.selectElem.onchange = function() {
|
30 | 29 |
$this.select(this.options[this.selectedIndex].value);
|
|
32 | 31 |
return this;
|
33 | 32 |
};
|
34 | 33 |
|
|
34 |
/*
|
|
35 |
* Removes all options from the selectElem, and their associated data.
|
|
36 |
*/
|
35 | 37 |
this.clear = function() {
|
|
38 |
this.reactTo = {};
|
36 | 39 |
while (this.selectElem.firstChild) {
|
37 | 40 |
this.selectElem.removeChild(this.selectElem.firstChild);
|
38 | 41 |
}
|
|
42 |
this.add('(select one...)', function() {});
|
39 | 43 |
return this;
|
40 | 44 |
};
|
41 | 45 |
|
|
58 | 62 |
return this;
|
59 | 63 |
};
|
60 | 64 |
|
|
65 |
/*
|
|
66 |
* Called by the selectElem's onchange event. For sanity, you should
|
|
67 |
* probably not call this yourself.
|
|
68 |
*/
|
61 | 69 |
this.select = function(id) {
|
62 | 70 |
this.reactTo[id](id);
|
|
71 |
if (this.onselect) {
|
|
72 |
this.onselect(id);
|
|
73 |
}
|
63 | 74 |
};
|
64 | 75 |
|
65 | 76 |
/*
|