2018-09-20 16:08:46 -04:00
|
|
|
{"version":3,"file":"tables.min.js.map","sources":["src/base/sort_tables.js"],"sourcesContent":["const LightTableSorter = (() => {\n\tlet th = null;\n\tlet cellIndex = null;\n\tlet order = '';\n\tconst text = (row) => row.cells.item(cellIndex).textContent.toLowerCase();\n\tconst sort = (a, b) => {\n\t\tlet textA = text(a);\n\t\tlet textB = text(b);\n\t\tconst n = parseInt(textA, 10);\n\t\tif (n) {\n\t\t\ttextA = n;\n\t\t\ttextB = parseInt(textB, 10);\n\t\t}\n\t\tif (textA > textB) {\n\t\t\treturn 1;\n\t\t}\n\t\tif (textA < textB) {\n\t\t\treturn -1;\n\t\t}\n\t\treturn 0;\n\t};\n\tconst toggle = () => {\n\t\tconst c = order !== 'sorting_asc' ? 'sorting_asc' : 'sorting_desc';\n\t\tth.className = (th.className.replace(order, '') + ' ' + c).trim();\n\t\treturn order = c;\n\t};\n\tconst reset = () => {\n\t\tth.classList.remove('sorting_asc', 'sorting_desc');\n\t\tth.classList.add('sorting');\n\t\treturn order = '';\n\t};\n\tconst onClickEvent = (e) => {\n\t\tif (th && (cellIndex !== e.target.cellIndex)) {\n\t\t\treset();\n\t\t}\n\t\tth = e.target;\n\t\tif (th.nodeName.toLowerCase() === 'th') {\n\t\t\tcellIndex = th.cellIndex;\n\t\t\tconst tbody = th.offsetParent.getElementsByTagName('tbody')[0];\n\t\t\tlet rows = Array.from(tbody.rows);\n\t\t\tif (rows) {\n\t\t\t\trows.sort(sort);\n\t\t\t\tif (order === 'sorting_asc') {\n\t\t\t\t\trows.reverse();\n\t\t\t\t}\n\t\t\t\ttoggle();\n\t\t\t\ttbody.innerHtml = '';\n\n\t\t\t\trows.forEach(row => {\n\t\t\t\t\ttbody.appendChild(row);\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t};\n\treturn {\n\t\tinit: () => {\n\t\t\tlet ths = document.getElementsByTagName('th');\n\t\t\tlet results = [];\n\t\t\tfor (let i = 0, len = ths.length; i < len; i++) {\n\t\t\t\tlet th = ths[i];\n\t\t\t\tth.classList.add('sorting');\n\t\t\t\tresults.push(th.onclick = onClickEvent);\n\t\t\t}\n\t\t\treturn results;\n\t\t}\n\t};\n})();\n\nLightTableSorter.init();"],"names":[],"mappings":";;;CAAA,MAAM,gBAAgB,GAAG,CAAC,MAAM;CAChC,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC;CACf,CAAC,IAAI,SAAS,GAAG,IAAI,CAAC;CACtB,CAAC,IAAI,KAAK,GAAG,EAAE,CAAC;CAChB,CAAC,MAAM,IAAI,GAAG,CAAC,GAAG,KAAK,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC;CAC3E,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK;CACxB,EAAE,IAAI,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;CACtB,EAAE,IAAI,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;CACtB,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;CAChC,EAAE,IAAI,CAAC,EAAE;CACT,GAAG,KAAK,GAAG,CAAC,CAAC;CACb,GAAG,KAAK,GAAG,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;CAC/B,GAAG;CACH,EAAE,IAAI,KAAK,GAAG,KAAK,EAAE;CACrB,GAAG,OAAO,CAAC,CAAC;CACZ,GAAG;CACH,EAAE,IAAI,KAAK,GAAG,KAAK,EAAE;CACrB,GAAG,OAAO,CAAC,CAAC,CAAC;CACb,GAAG;CACH,EAAE,OAAO,CAAC,CAAC;CACX,EAAE,CAAC;CACH,CAAC,MAAM,MAAM,GAAG,MAAM;CACtB,EAAE,MAAM,CAAC,GAAG,KAAK,KAAK,aAAa,GAAG,aAAa,GAAG,cAAc,CAAC;CACrE,EAAE,EAAE,CAAC,SAAS,GAAG,CAAC,EAAE,C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