Merge pull request #1 from catseye/develop-0.13
Develop 0.13
Chris Pressey authored 4 years ago
GitHub committed 4 years ago
0 | 0 | Changelog |
1 | 1 | ========= |
2 | 2 | |
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 | ||
3 | 11 | * version 0.12 |
4 | 12 | |
5 | 13 | Fixed a bug in `yoob.Cursor.clone`. |
0 | 0 | yoob.js |
1 | 1 | ======= |
2 | 2 | |
3 | *Version 0.12. Everything subject to change.* | |
3 | *Version 0.13. Everything subject to change.* | |
4 | 4 | *For version history, see the file [HISTORY.markdown](HISTORY.markdown).* |
5 | 5 | |
6 | 6 | yoob.js started out as the HTML5 counterpart to [yoob][], but has since |
0 | 0 | /* |
1 | * This file is part of yoob.js version 0.12 | |
1 | * This file is part of yoob.js version 0.13 | |
2 | 2 | * Available from https://github.com/catseye/yoob.js/ |
3 | 3 | * This file is in the public domain. See http://unlicense.org/ for details. |
4 | 4 | */ |
209 | 209 | }; |
210 | 210 | textInput.onchange = function(e) { |
211 | 211 | var v = parseInt(textInput.value, 10); |
212 | if (v !== NaN) { | |
212 | if (!isNaN(v)) { | |
213 | 213 | slider.value = "" + v; |
214 | 214 | fun(v); |
215 | 215 | } |
257 | 257 | }; |
258 | 258 | textInput.onchange = function(e) { |
259 | 259 | var v = parseInt(textInput.value, 10); |
260 | if (v !== NaN) { | |
260 | if (!isNaN(v)) { | |
261 | 261 | slider.value = "" + v; |
262 | 262 | callback(v); |
263 | 263 | } |
267 | 267 | if (withButtons) { |
268 | 268 | decButton = yoob.makeButton(container, "-", function() { |
269 | 269 | var v = parseInt(textInput.value, 10); |
270 | if (v !== NaN && v > min_) { | |
270 | if ((!isNaN(v)) && v > min_) { | |
271 | 271 | v--; |
272 | 272 | textInput.value = "" + v; |
273 | 273 | slider.value = "" + v; |
276 | 276 | }); |
277 | 277 | incButton = yoob.makeButton(container, "+", function() { |
278 | 278 | var v = parseInt(textInput.value, 10); |
279 | if (v !== NaN && v < max_) { | |
279 | if ((!isNaN(v)) && v < max_) { | |
280 | 280 | v++; |
281 | 281 | textInput.value = "" + v; |
282 | 282 | slider.value = "" + v; |
302 | 302 | |
303 | 303 | yoob.makeSVGElem = function(svg, tag, cfg) { |
304 | 304 | 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 | }); | |
310 | 308 | svg.appendChild(elem); |
311 | 309 | return elem; |
312 | 310 | }; |
0 | 0 | /* |
1 | * This file is part of yoob.js version 0.12 | |
1 | * This file is part of yoob.js version 0.13 | |
2 | 2 | * Available from https://github.com/catseye/yoob.js/ |
3 | 3 | * This file is in the public domain. See http://unlicense.org/ for details. |
4 | 4 | */ |
273 | 273 | if (maxDy === undefined) maxDy = 0; |
274 | 274 | for (var y = this.minY + minDy; y <= this.maxY + maxDy; y++) { |
275 | 275 | 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)); | |
277 | 277 | } |
278 | 278 | } |
279 | 279 | destPf.recalculateBounds(); |
0 | 0 | /* |
1 | * This file is part of yoob.js version 0.12 | |
1 | * This file is part of yoob.js version 0.13 | |
2 | 2 | * Available from https://github.com/catseye/yoob.js/ |
3 | 3 | * This file is in the public domain. See http://unlicense.org/ for details. |
4 | 4 | */ |
119 | 119 | } |
120 | 120 | return this; |
121 | 121 | }; |
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 | }; | |
122 | 143 | }; |