| 429 | }; |
| 430 | |
| 431 | function configure(instance, properties, o) { |
| 432 | for (var i in properties) { |
| 433 | var initial = properties[i], |
| 434 | attrValue = instance.input.getAttribute("data-" + i.toLowerCase()); |
| 435 | |
| 436 | if (typeof initial === "number") { |
| 437 | instance[i] = parseInt(attrValue); |
| 438 | } |
| 439 | else if (initial === false) { // Boolean options must be false by default anyway |
| 440 | instance[i] = attrValue !== null; |
| 441 | } |
| 442 | else if (initial instanceof Function) { |
| 443 | instance[i] = null; |
| 444 | } |
| 445 | else { |
| 446 | instance[i] = attrValue; |
| 447 | } |
| 448 | |
| 449 | if (!instance[i] && instance[i] !== 0) { |
| 450 | instance[i] = (i in o)? o[i] : initial; |
| 451 | } |
| 452 | } |
| 453 | } |
| 454 | |
| 455 | // Helpers |
| 456 | |