git @ Cat's Eye Technologies yoob.js / 12f998a
Merge pull request #1 from catseye/develop-0.13 Develop 0.13 Chris Pressey authored 4 years ago GitHub committed 4 years ago
5 changed file(s) with 41 addition(s) and 14 deletion(s). Raw diff Collapse all Expand all
00 Changelog
11 =========
22
3 * version 0.13
4
5 Added `populateFromPairs` helper method to `yoob.PresetManager`.
6
7 Fixed `NaN` bugs in element-factory.
8
9 Fixed a bug in `yoob.Playfield.map`.
10
311 * version 0.12
412
513 Fixed a bug in `yoob.Cursor.clone`.
00 yoob.js
11 =======
22
3 *Version 0.12. Everything subject to change.*
3 *Version 0.13. Everything subject to change.*
44 *For version history, see the file [HISTORY.markdown](HISTORY.markdown).*
55
66 yoob.js started out as the HTML5 counterpart to [yoob][], but has since
00 /*
1 * This file is part of yoob.js version 0.12
1 * This file is part of yoob.js version 0.13
22 * Available from https://github.com/catseye/yoob.js/
33 * This file is in the public domain. See http://unlicense.org/ for details.
44 */
209209 };
210210 textInput.onchange = function(e) {
211211 var v = parseInt(textInput.value, 10);
212 if (v !== NaN) {
212 if (!isNaN(v)) {
213213 slider.value = "" + v;
214214 fun(v);
215215 }
257257 };
258258 textInput.onchange = function(e) {
259259 var v = parseInt(textInput.value, 10);
260 if (v !== NaN) {
260 if (!isNaN(v)) {
261261 slider.value = "" + v;
262262 callback(v);
263263 }
267267 if (withButtons) {
268268 decButton = yoob.makeButton(container, "-", function() {
269269 var v = parseInt(textInput.value, 10);
270 if (v !== NaN && v > min_) {
270 if ((!isNaN(v)) && v > min_) {
271271 v--;
272272 textInput.value = "" + v;
273273 slider.value = "" + v;
276276 });
277277 incButton = yoob.makeButton(container, "+", function() {
278278 var v = parseInt(textInput.value, 10);
279 if (v !== NaN && v < max_) {
279 if ((!isNaN(v)) && v < max_) {
280280 v++;
281281 textInput.value = "" + v;
282282 slider.value = "" + v;
302302
303303 yoob.makeSVGElem = function(svg, tag, cfg) {
304304 var elem = document.createElementNS(svg.namespaceURI, tag);
305 for (var key in cfg) {
306 if (cfg.hasOwnProperty(key)) {
307 elem.setAttribute(key, cfg[key]);
308 }
309 }
305 Object.keys(cfg).forEach(function(key) {
306 elem.setAttribute(key, cfg[key]);
307 });
310308 svg.appendChild(elem);
311309 return elem;
312310 };
00 /*
1 * This file is part of yoob.js version 0.12
1 * This file is part of yoob.js version 0.13
22 * Available from https://github.com/catseye/yoob.js/
33 * This file is in the public domain. See http://unlicense.org/ for details.
44 */
273273 if (maxDy === undefined) maxDy = 0;
274274 for (var y = this.minY + minDy; y <= this.maxY + maxDy; y++) {
275275 for (var x = this.minX + minDx; x <= this.maxX + maxDx; x++) {
276 destPf.putDirty(x, y, fun(pf, x, y));
276 destPf.putDirty(x, y, fun(this, x, y));
277277 }
278278 }
279279 destPf.recalculateBounds();
00 /*
1 * This file is part of yoob.js version 0.12
1 * This file is part of yoob.js version 0.13
22 * Available from https://github.com/catseye/yoob.js/
33 * This file is in the public domain. See http://unlicense.org/ for details.
44 */
119119 }
120120 return this;
121121 };
122
123 /*
124 * When called with a yoob.SourceManager and an array of
125 * 2-element arrays of a name and a source text, this preset
126 * manager will be populated with each source text as a
127 * named preset. A callback to load the source text with
128 * the SourceManager will be automatically supplied.
129 */
130 this.populateFromPairs = function(sourceManager, pairs) {
131 function makeCallback(sourceText) {
132 return function(id) {
133 sourceManager.loadSource(sourceText);
134 }
135 }
136
137 for (var i = 0; i < pairs.length; i++) {
138 this.add(pairs[i][0], makeCallback(pairs[i][1]));
139 }
140 this.select(pairs[0][0]);
141 return this;
142 };
122143 };