git @ Cat's Eye Technologies yoob.js / 0ace86f
Add .click_start(), .click_stop(), for better button management. Cat's Eye Technologies 11 years ago
2 changed file(s) with 26 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
5656 this.controls[key] = value;
5757 }
5858 }
59 if (this.controls.stop) {
60 this.controls.stop.disabled = true;
61 }
5962
6063 var keys = ["source", "display"];
6164 for (var i in keys) {
6467 if (typeof value === 'string') {
6568 value = document.getElementById(value);
6669 }
67 if (value !== undefined) {
70 if (value) {
6871 this[key] = value;
6972 }
7073 }
7376 if (typeof speed === 'string') {
7477 speed = document.getElementById(speed);
7578 }
76 if (speed !== undefined) {
79 if (speed) {
7780 this.speed = speed;
7881 speed.value = this.delay;
7982 var $this = this;
97100 };
98101
99102 this.click_load = function(e) {
100 this.stop();
103 this.click_stop();
101104 this.load(this.source.value);
102105 if (this.controls.edit) this.controls.edit.style.display = "inline";
103106 if (this.controls.load) this.controls.load.style.display = "none";
104107 if (this.controls.start) this.controls.start.disabled = false;
105108 if (this.controls.step) this.controls.step.disabled = false;
106 if (this.controls.stop) this.controls.stop.disabled = false;
109 if (this.controls.stop) this.controls.stop.disabled = true;
107110 if (this.display) this.display.style.display = "block";
108111 if (this.source) this.source.style.display = "none";
109112 };
134137 };
135138
136139 this.click_edit = function(e) {
137 this.stop();
140 this.click_stop();
138141 if (this.controls.edit) this.controls.edit.style.display = "none";
139142 if (this.controls.load) this.controls.load.style.display = "inline";
140143 if (this.controls.start) this.controls.start.disabled = true;
142145 if (this.controls.stop) this.controls.stop.disabled = true;
143146 if (this.display) this.display.style.display = "none";
144147 if (this.source) this.source.style.display = "block";
148 };
149
150 this.click_start = function(e) {
151 this.start();
152 if (this.controls.start) this.controls.start.disabled = true;
153 if (this.controls.step) this.controls.step.disabled = false;
154 if (this.controls.stop) this.controls.stop.disabled = false;
145155 };
146156
147157 this.start = function() {
152162 this.intervalId = setInterval(function() { $this.step(); }, this.delay);
153163 };
154164
165 this.click_stop = function(e) {
166 this.stop();
167 if (this.controls.stop && this.controls.stop.disabled) {
168 return;
169 }
170 if (this.controls.start) this.controls.start.disabled = false;
171 if (this.controls.step) this.controls.step.disabled = false;
172 if (this.controls.stop) this.controls.stop.disabled = true;
173 };
174
155175 this.stop = function() {
156176 if (this.intervalId === undefined)
157177 return;
5757 this.selectElem.options.add(opt);
5858 var $this = this;
5959 this.reactTo[id] = callback || function(id) {
60 $this.controller.stop(); // in case it is currently running
60 $this.controller.click_stop(); // in case it is currently running
6161 $this.controller.loadSourceFromHTML(
6262 document.getElementById(id).innerHTML
6363 );