Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame^] | 1 | var KorAP = KorAP || {}; |
| 2 | |
| 3 | // TODO: Make this part of util! |
| 4 | // Don't let events bubble up |
| 5 | if (Event.halt === undefined) { |
| 6 | // Don't let events bubble up |
| 7 | Event.prototype.halt = function () { |
| 8 | this.stopPropagation(); |
| 9 | this.preventDefault(); |
| 10 | }; |
| 11 | }; |
| 12 | |
| 13 | // Add toggleClass method similar to jquery |
| 14 | HTMLElement.prototype.toggleClass = function (c1, c2) { |
| 15 | var cl = this.classList; |
| 16 | if (cl.contains(c1)) { |
| 17 | cl.add(c2); |
| 18 | cl.remove(c1); |
| 19 | } |
| 20 | else { |
| 21 | cl.remove(c2); |
| 22 | cl.add(c1); |
| 23 | }; |
| 24 | }; |
| 25 | |
| 26 | |
| 27 | // Utility for removing all children of a node |
| 28 | function _removeChildren (node) { |
| 29 | // Remove everything underneath |
| 30 | while (node.firstChild) |
| 31 | node.removeChild(node.firstChild); |
| 32 | }; |
| 33 | |
| 34 | |
| 35 | define(function () { |
| 36 | KorAP.API = KorAP.API || {}; |
| 37 | KorAP.Locale = KorAP.Locale || {}; |
| 38 | |
| 39 | // Default log message |
| 40 | KorAP.log = KorAP.log || function (type, msg) { |
| 41 | console.log(type + ": " + msg); |
| 42 | }; |
| 43 | |
| 44 | return KorAP; |
| 45 | }); |