From 30f8dbd5341ceb6a045c8b52fba1675b7ffde346 Mon Sep 17 00:00:00 2001 From: dzsoft-ru Date: Fri, 21 Apr 2017 22:22:30 +0300 Subject: [PATCH] method #sort# added. --- .vs/config/applicationhost.config | 1039 +++++++++++++++++++++++++++++ .vs/slnx.sqlite | Bin 0 -> 69632 bytes .vs/sortable/v15/.suo | Bin 0 -> 14848 bytes docs/api/1-Options.md | 9 + js/sortable.js | 456 +++++++------ js/sortable.min.js | 2 +- 6 files changed, 1285 insertions(+), 221 deletions(-) create mode 100644 .vs/config/applicationhost.config create mode 100644 .vs/slnx.sqlite create mode 100644 .vs/sortable/v15/.suo diff --git a/.vs/config/applicationhost.config b/.vs/config/applicationhost.config new file mode 100644 index 0000000..8cf5a72 --- /dev/null +++ b/.vs/config/applicationhost.config @@ -0,0 +1,1039 @@ + + + + + + + +
+
+
+
+
+
+
+
+ + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+ +
+
+ +
+
+ +
+
+
+ + +
+
+
+
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite new file mode 100644 index 0000000000000000000000000000000000000000..09982f51774bbffb278e88055458dbad49f83d22 GIT binary patch literal 69632 zcmeHw33MCDd1f~oH_%-GB@QG~0-GW!5)zxjeT*z?C=iq|Ly;5@9V0Vx1Kp4)lK_VR zHIkimA}Dh>K4SYlXV;k=o|oh~@s7Q_v7KW#`^KB`Y~E%k+1T-WV`mc2?#l5vb{u?ikH7i=x*MQK&Uk#hDd-8+UG@Ke{q@!VSM^`$DlVLxUa8A`xw^3?*7-Q)r)Zjb zfafWS8iW4<_^*FBxUlIrkkW?htuDtX;r~2h$HeGWOcOw_`fhkPJfC;{jqAMgDZ9(I z!Td3GmwIU{0k0$9!8sJ}$F8!@U_4I$>}FjouF6v@tMbCFT3ue7m&@{oTq$+R;&Su( ziN!p>IB{w^&tLAqw9I-&Sq~4NPNn%ueWiY@AT9HSnZ^9+{5(H5UpPB4e~Eu6e~F)1 zTAVG+Kow{6GmHGpEc{=Zo*v^hd2<`p8!M8$VPw~d`1$-)em*~w%P;Vkbwaha<meldSh?J+(#J3Wn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zdRI*5rzV!B7x~iWhB5)vbWyfia}8BKZBCBcboBj58SR zqi^@CkAHF<&RD%_7}pon9GlkX`g3R-UDH7|hOH*5@LZQ82*=@FQcSJ(2s}^7S8DPj zn>g~b+%hIZvlNb2V5S`d&hYIsv@-~YI5w^-GBpLXq{}4ZvaVe#TGVoWaHgporraqS zf!@IJzumD!q3hi9-k03h;F5d@0t5kq06~Bt@Y)b~+>e|+g5Y}Zg&QmKqj-G)ubU~) zb}Mqtdauow=L`7@ytRxMYpmx&Vet$s{Nh;Nk@)OP>sHmW zb&oZl8}Fc=nPh5VeD~_MiBQ!4$)Ds$-ZsKRGB@6ACbYxY>iV@7ui8FKS7Pe97ENJh z1{S&>gr)5^BrxUF0<1*0sG%_(dg+8wAN+i)!;T+TJbLdgj2{`Z=v`|X2J5+(vO7@{ zRNYFq_C5jwJp(K9osESrEGS{>&#ZGw)c2k~OT;rN*2NYK_zsyLAkBpxV;#)(8XqTH z(si8M*P?z1i|%@0X>3(905gUwI-#ol?tcNvccV?{MUIFY^x#>f&{43BvMA+mFxhUjHA%B%{v& literal 0 HcmV?d00001 diff --git a/.vs/sortable/v15/.suo b/.vs/sortable/v15/.suo new file mode 100644 index 0000000000000000000000000000000000000000..6a19488b7ded70e4a24ecfd1f2c469e0f51fb63e GIT binary patch literal 14848 zcmeHNTZ|i589vU1=F$|>l+c!vZbJyAT^rBZ>y1N_#_P*2O}5#_n>1}VO2+nhGwa#) zcE+Yzk|4nYMXe$f`p^ml64wV*iYnj%!~=v!B!a>NQjt)3?MuZIFLcBA&CJ;yd+qVq zZb{PYKRTB=bI$qC`Oo<;=Rfn;Yun%X;ad;>OEkeDv0g0Q*epKgDGzz_;uFID#!DAx-gc+* zBrsORtoSmpmyyeg^BsC={Jc}FTgFeaH-2sXmPRqQuMNjU9kVus4*U!=B9C_!L9@p) z<$uzU^$G3x{~@>CMx^9_ zS>I{37T;_NNc(NQyEa@W?j^314AcYE6Wj~U>reSE*HzZ1{Fix|Qs>J&(}z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W4d<@@X8_G?W$b&Mi7^Z(OIh2vm6urG{7<+x?IH+0>iA`A_QdU#`BPlaOB0F~6F) z9ZJH=z5o5?+uz*y?u8fr9((V|>m91EeQu%v<$!w>X!;WHm5sS_vXc$W{5zCiv})R1 zBwaNOtyt5m^HyX`o7YUe7|G~%fod+E9eVzGw_?6#>hm*$19MifY8rZBaNwk7T4;AL z9*Oc997xxVTHVwR&TI9WsTzX=ll6k37msL*Q`L$#f3Pqzq7D~_6G}1`*P{E9rw3){ z-cgLJ*14KmFtiUA*J)lt-Q|vXQ@T30pqiSwiP-Y`S2g@ix9K~6L~)6eeW9)zdTmj5 za8~(HDRkOa!<$`QBsMT}D-ILGvTvZ7ey||7Z9lzA@_GB{r_9^Whn)}g$NkH8RIlSC z{dphXj~eO~H{12Q{`?P)p;w^%mF>N<_yo#1w(+QFe8S7`{<+3h{8geQHKUEOu`C*Lo<`P#1c_!C7N;JwcT3{&le)5C6i5BfbES!VvsCS^NnQN36ixFly&x$SHU-m}D5W_$`GTCzC=*izMQl z{iN~F$0bju5Bk@>R zQ8LkRDyyWz(P%1~PDXRNTsn5?;(-a>D&}-UvkqO%?w@{EoiAzUGrCoo9@A^%^}@7O zHElgJJ!>uJBeT}Uix-r5Mj1&alyELPtc2r)V(N;-rka)10_2{m$stt{(i9$52#p1)^_|U$6;bfvz4i9T;IhKrTS}c)_ zM59U~p19b&N?y*WHI+R)a)5R7 zTCE17)Z&*zl{05XF;2Yabj>JnDa98471tk}y5>XM0A25av{bPVbsQ#enY!nnzx}THHl9U#)r`_|?1D&%Ju(war^j z%q;C)_eNX1HgZJee(S2l literal 0 HcmV?d00001 diff --git a/docs/api/1-Options.md b/docs/api/1-Options.md index e910d57..c128b9d 100644 --- a/docs/api/1-Options.md +++ b/docs/api/1-Options.md @@ -31,6 +31,15 @@ exampleTable = document.querySelector('#exampleTable') Sortable.initTable(exampleTable) ``` +##### `sort` + +To re-sort table after rows adding, call `sort`. + +```coffeescript +exampleTable = document.querySelector('#exampleTable') +Sortable.sort(exampleTable) +``` + #### Events An `CustomEvent` called `Sortable.sorted` is fired whenever a sort is completed. diff --git a/js/sortable.js b/js/sortable.js index cb3e293..576896a 100644 --- a/js/sortable.js +++ b/js/sortable.js @@ -1,236 +1,252 @@ -(function() { - var SELECTOR, addEventListener, clickEvents, numberRegExp, sortable, touchDevice, trimRegExp; +(function () { + var SELECTOR, addEventListener, clickEvents, numberRegExp, sortable, touchDevice, trimRegExp; - SELECTOR = 'table[data-sortable]'; + SELECTOR = 'table[data-sortable]'; - numberRegExp = /^-?[£$¤]?[\d,.]+%?$/; + numberRegExp = /^-?[£$¤]?[\d,.]+%?$/; - trimRegExp = /^\s+|\s+$/g; + trimRegExp = /^\s+|\s+$/g; - clickEvents = ['click']; + clickEvents = ['click']; - touchDevice = 'ontouchstart' in document.documentElement; + touchDevice = 'ontouchstart' in document.documentElement; - if (touchDevice) { - clickEvents.push('touchstart'); - } - - addEventListener = function(el, event, handler) { - if (el.addEventListener != null) { - return el.addEventListener(event, handler, false); - } else { - return el.attachEvent("on" + event, handler); + if (touchDevice) { + clickEvents.push('touchstart'); } - }; - - sortable = { - init: function(options) { - var table, tables, _i, _len, _results; - if (options == null) { - options = {}; - } - if (options.selector == null) { - options.selector = SELECTOR; - } - tables = document.querySelectorAll(options.selector); - _results = []; - for (_i = 0, _len = tables.length; _i < _len; _i++) { - table = tables[_i]; - _results.push(sortable.initTable(table)); - } - return _results; - }, - initTable: function(table) { - var i, th, ths, _i, _len, _ref; - if (((_ref = table.tHead) != null ? _ref.rows.length : void 0) !== 1) { - return; - } - if (table.getAttribute('data-sortable-initialized') === 'true') { - return; - } - table.setAttribute('data-sortable-initialized', 'true'); - ths = table.querySelectorAll('th'); - for (i = _i = 0, _len = ths.length; _i < _len; i = ++_i) { - th = ths[i]; - if (th.getAttribute('data-sortable') !== 'false') { - sortable.setupClickableTH(table, th, i); - } - } - return table; - }, - setupClickableTH: function(table, th, i) { - var eventName, onClick, type, _i, _len, _results; - type = sortable.getColumnType(table, i); - onClick = function(e) { - var compare, item, newSortedDirection, position, row, rowArray, sorted, sortedDirection, tBody, ths, value, _compare, _i, _j, _k, _l, _len, _len1, _len2, _len3, _len4, _m, _ref, _ref1; - if (e.handled !== true) { - e.handled = true; - } else { - return false; - } - sorted = this.getAttribute('data-sorted') === 'true'; - sortedDirection = this.getAttribute('data-sorted-direction'); - if (sorted) { - newSortedDirection = sortedDirection === 'ascending' ? 'descending' : 'ascending'; + + addEventListener = function (el, event, handler) { + if (el.addEventListener != null) { + return el.addEventListener(event, handler, false); } else { - newSortedDirection = type.defaultSortDirection; + return el.attachEvent("on" + event, handler); } - ths = this.parentNode.querySelectorAll('th'); - for (_i = 0, _len = ths.length; _i < _len; _i++) { - th = ths[_i]; - th.setAttribute('data-sorted', 'false'); - th.removeAttribute('data-sorted-direction'); - } - this.setAttribute('data-sorted', 'true'); - this.setAttribute('data-sorted-direction', newSortedDirection); - tBody = table.tBodies[0]; - rowArray = []; - if (!sorted) { - if (type.compare != null) { - _compare = type.compare; - } else { - _compare = function(a, b) { - return b - a; - }; - } - compare = function(a, b) { - if (a[0] === b[0]) { - return a[2] - b[2]; + }; + + sortable = { + init: function (options) { + var table, tables, _i, _len, _results; + if (options == null) { + options = {}; + } + if (options.selector == null) { + options.selector = SELECTOR; + } + tables = document.querySelectorAll(options.selector); + _results = []; + for (_i = 0, _len = tables.length; _i < _len; _i++) { + table = tables[_i]; + _results.push(sortable.initTable(table)); + } + return _results; + }, + initTable: function (table) { + var i, th, ths, _i, _len, _ref; + if (((_ref = table.tHead) != null ? _ref.rows.length : void 0) !== 1) { + return; } - if (type.reverse) { - return _compare(b[0], a[0]); + if (table.getAttribute('data-sortable-initialized') === 'true') { + return; + } + table.setAttribute('data-sortable-initialized', 'true'); + ths = table.querySelectorAll('th'); + for (i = _i = 0, _len = ths.length; _i < _len; i = ++_i) { + th = ths[i]; + if (th.getAttribute('data-sortable') !== 'false') { + sortable.setupClickableTH(table, th, i); + } + } + return table; + }, + sort: function (table) { + + var compare, position, row, rowArray, tBody, value, _compare, _i, _j, _k, _len1, _len2, _ref; + var ths, type, sortedDirection, cellIndex; + + ths = table.querySelectorAll('th'); + for (i = _i = 0, _len = ths.length; _i < _len; i = ++_i) { + th = ths[i]; + if (th.getAttribute('data-sorted') === 'true') { + type = sortable.getColumnType(table, i); + sortedDirection = th.getAttribute('data-sorted-direction'); + cellIndex = i; + } + } + + if (typeof type == 'undefined') { + return; + } + + tBody = table.tBodies[0]; + rowArray = []; + + if (type.compare != null) { + _compare = type.compare; } else { - return _compare(a[0], b[0]); - } - }; - _ref = tBody.rows; - for (position = _j = 0, _len1 = _ref.length; _j < _len1; position = ++_j) { - row = _ref[position]; - value = sortable.getNodeValue(row.cells[i]); - if (type.comparator != null) { - value = type.comparator(value); - } - rowArray.push([value, row, position]); - } - rowArray.sort(compare); - for (_k = 0, _len2 = rowArray.length; _k < _len2; _k++) { - row = rowArray[_k]; - tBody.appendChild(row[1]); - } - } else { - _ref1 = tBody.rows; - for (_l = 0, _len3 = _ref1.length; _l < _len3; _l++) { - item = _ref1[_l]; - rowArray.push(item); - } - rowArray.reverse(); - for (_m = 0, _len4 = rowArray.length; _m < _len4; _m++) { - row = rowArray[_m]; - tBody.appendChild(row); - } - } - if (typeof window['CustomEvent'] === 'function') { - return typeof table.dispatchEvent === "function" ? table.dispatchEvent(new CustomEvent('Sortable.sorted', { - bubbles: true - })) : void 0; + _compare = function (a, b) { + return a - b; + }; + } + compare = function (a, b) { + if (a[0] === b[0]) { + return a[2] - b[2]; + } + if (type.reverse) { + return _compare(b[0], a[0]); + } else { + return _compare(a[0], b[0]); + } + }; + _ref = tBody.rows; + for (position = _j = 0, _len1 = _ref.length; _j < _len1; position = ++_j) { + row = _ref[position]; + value = sortable.getNodeValue(row.cells[cellIndex]); + if (type.comparator != null) { + value = type.comparator(value); + } + rowArray.push([value, row, position]); + } + + rowArray.sort(compare); + + if (sortedDirection === 'descending') + rowArray.reverse(); + + for (_k = 0, _len2 = rowArray.length; _k < _len2; _k++) { + row = rowArray[_k]; + tBody.appendChild(row[1]); + } + }, + setupClickableTH: function (table, th, i) { + var eventName, onClick, type, _i, _len, _results; + type = sortable.getColumnType(table, i); + onClick = function (e) { + var newSortedDirection, sorted, sortedDirection, ths, _i, _len; + if (e.handled !== true) { + e.handled = true; + } else { + return false; + } + sorted = this.getAttribute('data-sorted') === 'true'; + sortedDirection = this.getAttribute('data-sorted-direction'); + if (sorted) { + newSortedDirection = sortedDirection === 'ascending' ? 'descending' : 'ascending'; + } else { + newSortedDirection = type.defaultSortDirection; + } + ths = this.parentNode.querySelectorAll('th'); + for (_i = 0, _len = ths.length; _i < _len; _i++) { + th = ths[_i]; + th.setAttribute('data-sorted', 'false'); + th.removeAttribute('data-sorted-direction'); + } + this.setAttribute('data-sorted', 'true'); + this.setAttribute('data-sorted-direction', newSortedDirection); + + sortable.sort(table); + + if (typeof window['CustomEvent'] === 'function') { + return typeof table.dispatchEvent === "function" ? table.dispatchEvent(new CustomEvent('Sortable.sorted', { + bubbles: true + })) : void 0; + } + }; + _results = []; + for (_i = 0, _len = clickEvents.length; _i < _len; _i++) { + eventName = clickEvents[_i]; + _results.push(addEventListener(th, eventName, onClick)); + } + return _results; + }, + getColumnType: function (table, i) { + var row, specified, text, type, _i, _j, _len, _len1, _ref, _ref1, _ref2; + specified = (_ref = table.querySelectorAll('th')[i]) != null ? _ref.getAttribute('data-sortable-type') : void 0; + if (specified != null) { + return sortable.typesObject[specified]; + } + _ref1 = table.tBodies[0].rows; + for (_i = 0, _len = _ref1.length; _i < _len; _i++) { + row = _ref1[_i]; + text = sortable.getNodeValue(row.cells[i]); + _ref2 = sortable.types; + for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) { + type = _ref2[_j]; + if (type.match(text)) { + return type; + } + } + } + return sortable.typesObject.alpha; + }, + getNodeValue: function (node) { + var dataValue; + if (!node) { + return ''; + } + dataValue = node.getAttribute('data-value'); + if (dataValue !== null) { + return dataValue; + } + if (typeof node.innerText !== 'undefined') { + return node.innerText.replace(trimRegExp, ''); + } + return node.textContent.replace(trimRegExp, ''); + }, + setupTypes: function (types) { + var type, _i, _len, _results; + sortable.types = types; + sortable.typesObject = {}; + _results = []; + for (_i = 0, _len = types.length; _i < _len; _i++) { + type = types[_i]; + _results.push(sortable.typesObject[type.name] = type); + } + return _results; } - }; - _results = []; - for (_i = 0, _len = clickEvents.length; _i < _len; _i++) { - eventName = clickEvents[_i]; - _results.push(addEventListener(th, eventName, onClick)); - } - return _results; - }, - getColumnType: function(table, i) { - var row, specified, text, type, _i, _j, _len, _len1, _ref, _ref1, _ref2; - specified = (_ref = table.querySelectorAll('th')[i]) != null ? _ref.getAttribute('data-sortable-type') : void 0; - if (specified != null) { - return sortable.typesObject[specified]; - } - _ref1 = table.tBodies[0].rows; - for (_i = 0, _len = _ref1.length; _i < _len; _i++) { - row = _ref1[_i]; - text = sortable.getNodeValue(row.cells[i]); - _ref2 = sortable.types; - for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) { - type = _ref2[_j]; - if (type.match(text)) { - return type; - } + }; + + sortable.setupTypes([ + { + name: 'numeric', + defaultSortDirection: 'descending', + match: function (a) { + return a.match(numberRegExp); + }, + comparator: function (a) { + return parseFloat(a.replace(/[^0-9.-]/g, ''), 10) || 0; + } + }, { + name: 'date', + defaultSortDirection: 'ascending', + reverse: true, + match: function (a) { + return !isNaN(Date.parse(a)); + }, + comparator: function (a) { + return Date.parse(a) || 0; + } + }, { + name: 'alpha', + defaultSortDirection: 'ascending', + match: function () { + return true; + }, + compare: function (a, b) { + return a.localeCompare(b); + } } - } - return sortable.typesObject.alpha; - }, - getNodeValue: function(node) { - var dataValue; - if (!node) { - return ''; - } - dataValue = node.getAttribute('data-value'); - if (dataValue !== null) { - return dataValue; - } - if (typeof node.innerText !== 'undefined') { - return node.innerText.replace(trimRegExp, ''); - } - return node.textContent.replace(trimRegExp, ''); - }, - setupTypes: function(types) { - var type, _i, _len, _results; - sortable.types = types; - sortable.typesObject = {}; - _results = []; - for (_i = 0, _len = types.length; _i < _len; _i++) { - type = types[_i]; - _results.push(sortable.typesObject[type.name] = type); - } - return _results; - } - }; - - sortable.setupTypes([ - { - name: 'numeric', - defaultSortDirection: 'descending', - match: function(a) { - return a.match(numberRegExp); - }, - comparator: function(a) { - return parseFloat(a.replace(/[^0-9.-]/g, ''), 10) || 0; - } - }, { - name: 'date', - defaultSortDirection: 'ascending', - reverse: true, - match: function(a) { - return !isNaN(Date.parse(a)); - }, - comparator: function(a) { - return Date.parse(a) || 0; - } - }, { - name: 'alpha', - defaultSortDirection: 'ascending', - match: function() { - return true; - }, - compare: function(a, b) { - return a.localeCompare(b); - } + ]); + + setTimeout(sortable.init, 0); + + if (typeof define === 'function' && define.amd) { + define(function () { + return sortable; + }); + } else if (typeof exports !== 'undefined') { + module.exports = sortable; + } else { + window.Sortable = sortable; } - ]); - - setTimeout(sortable.init, 0); - - if (typeof define === 'function' && define.amd) { - define(function() { - return sortable; - }); - } else if (typeof exports !== 'undefined') { - module.exports = sortable; - } else { - window.Sortable = sortable; - } }).call(this); diff --git a/js/sortable.min.js b/js/sortable.min.js index 8278f50..3e91053 100644 --- a/js/sortable.min.js +++ b/js/sortable.min.js @@ -1,2 +1,2 @@ /*! sortable.js 0.8.0 */ -(function(){var a,b,c,d,e,f,g;a="table[data-sortable]",d=/^-?[£$¤]?[\d,.]+%?$/,g=/^\s+|\s+$/g,c=["click"],f="ontouchstart"in document.documentElement,f&&c.push("touchstart"),b=function(a,b,c){return null!=a.addEventListener?a.addEventListener(b,c,!1):a.attachEvent("on"+b,c)},e={init:function(b){var c,d,f,g,h;for(null==b&&(b={}),null==b.selector&&(b.selector=a),d=document.querySelectorAll(b.selector),h=[],f=0,g=d.length;g>f;f++)c=d[f],h.push(e.initTable(c));return h},initTable:function(a){var b,c,d,f,g,h;if(1===(null!=(h=a.tHead)?h.rows.length:void 0)&&"true"!==a.getAttribute("data-sortable-initialized")){for(a.setAttribute("data-sortable-initialized","true"),d=a.querySelectorAll("th"),b=f=0,g=d.length;g>f;b=++f)c=d[b],"false"!==c.getAttribute("data-sortable")&&e.setupClickableTH(a,c,b);return a}},setupClickableTH:function(a,d,f){var g,h,i,j,k,l;for(i=e.getColumnType(a,f),h=function(b){var c,g,h,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D;if(b.handled===!0)return!1;for(b.handled=!0,m="true"===this.getAttribute("data-sorted"),n=this.getAttribute("data-sorted-direction"),h=m?"ascending"===n?"descending":"ascending":i.defaultSortDirection,p=this.parentNode.querySelectorAll("th"),s=0,w=p.length;w>s;s++)d=p[s],d.setAttribute("data-sorted","false"),d.removeAttribute("data-sorted-direction");if(this.setAttribute("data-sorted","true"),this.setAttribute("data-sorted-direction",h),o=a.tBodies[0],l=[],m){for(D=o.rows,v=0,z=D.length;z>v;v++)g=D[v],l.push(g);for(l.reverse(),B=0,A=l.length;A>B;B++)k=l[B],o.appendChild(k)}else{for(r=null!=i.compare?i.compare:function(a,b){return b-a},c=function(a,b){return a[0]===b[0]?a[2]-b[2]:i.reverse?r(b[0],a[0]):r(a[0],b[0])},C=o.rows,j=t=0,x=C.length;x>t;j=++t)k=C[j],q=e.getNodeValue(k.cells[f]),null!=i.comparator&&(q=i.comparator(q)),l.push([q,k,j]);for(l.sort(c),u=0,y=l.length;y>u;u++)k=l[u],o.appendChild(k[1])}return"function"==typeof window.CustomEvent&&"function"==typeof a.dispatchEvent?a.dispatchEvent(new CustomEvent("Sortable.sorted",{bubbles:!0})):void 0},l=[],j=0,k=c.length;k>j;j++)g=c[j],l.push(b(d,g,h));return l},getColumnType:function(a,b){var c,d,f,g,h,i,j,k,l,m,n;if(d=null!=(l=a.querySelectorAll("th")[b])?l.getAttribute("data-sortable-type"):void 0,null!=d)return e.typesObject[d];for(m=a.tBodies[0].rows,h=0,j=m.length;j>h;h++)for(c=m[h],f=e.getNodeValue(c.cells[b]),n=e.types,i=0,k=n.length;k>i;i++)if(g=n[i],g.match(f))return g;return e.typesObject.alpha},getNodeValue:function(a){var b;return a?(b=a.getAttribute("data-value"),null!==b?b:"undefined"!=typeof a.innerText?a.innerText.replace(g,""):a.textContent.replace(g,"")):""},setupTypes:function(a){var b,c,d,f;for(e.types=a,e.typesObject={},f=[],c=0,d=a.length;d>c;c++)b=a[c],f.push(e.typesObject[b.name]=b);return f}},e.setupTypes([{name:"numeric",defaultSortDirection:"descending",match:function(a){return a.match(d)},comparator:function(a){return parseFloat(a.replace(/[^0-9.-]/g,""),10)||0}},{name:"date",defaultSortDirection:"ascending",reverse:!0,match:function(a){return!isNaN(Date.parse(a))},comparator:function(a){return Date.parse(a)||0}},{name:"alpha",defaultSortDirection:"ascending",match:function(){return!0},compare:function(a,b){return a.localeCompare(b)}}]),setTimeout(e.init,0),"function"==typeof define&&define.amd?define(function(){return e}):"undefined"!=typeof exports?module.exports=e:window.Sortable=e}).call(this); \ No newline at end of file +(function () { var a, b, c, d, e, f, g; a = "table[data-sortable]", d = /^-?[£$¤]?[\d,.]+%?$/, g = /^\s+|\s+$/g, c = ["click"], f = "ontouchstart" in document.documentElement, f && c.push("touchstart"), b = function (a, b, c) { return null != a.addEventListener ? a.addEventListener(b, c, !1) : a.attachEvent("on" + b, c) }, e = { init: function (b) { var c, d, f, g, h; for (null == b && (b = {}), null == b.selector && (b.selector = a), d = document.querySelectorAll(b.selector), h = [], f = 0, g = d.length; f < g; f++)c = d[f], h.push(e.initTable(c)); return h }, initTable: function (a) { var b, c, d, f, g, h; if (1 === (null != (h = a.tHead) ? h.rows.length : void 0) && "true" !== a.getAttribute("data-sortable-initialized")) { for (a.setAttribute("data-sortable-initialized", "true"), d = a.querySelectorAll("th"), b = f = 0, g = d.length; f < g; b = ++f)c = d[b], "false" !== c.getAttribute("data-sortable") && e.setupClickableTH(a, c, b); return a } }, sort: function (a) { var b, c, d, f, g, h, j, k, l, m, n, o, p, q, r, s, t; for (q = a.querySelectorAll("th"), i = k = 0, _len = q.length; k < _len; i = ++k)th = q[i], "true" === th.getAttribute("data-sorted") && (r = e.getColumnType(a, i), s = th.getAttribute("data-sorted-direction"), t = i); if (void 0 !== r) { for (g = a.tBodies[0], f = [], j = null != r.compare ? r.compare : function (a, b) { return a - b }, b = function (a, b) { return a[0] === b[0] ? a[2] - b[2] : r.reverse ? j(b[0], a[0]) : j(a[0], b[0]) }, p = g.rows, c = l = 0, n = p.length; l < n; c = ++l)d = p[c], h = e.getNodeValue(d.cells[t]), null != r.comparator && (h = r.comparator(h)), f.push([h, d, c]); for (f.sort(b), "descending" === s && f.reverse(), m = 0, o = f.length; m < o; m++)d = f[m], g.appendChild(d[1]) } }, setupClickableTH: function (a, d, f) { var g, h, i, j, k, l; for (i = e.getColumnType(a, f), h = function (b) { var c, f, g, h, j, k; if (!0 === b.handled) return !1; for (b.handled = !0, f = "true" === this.getAttribute("data-sorted"), g = this.getAttribute("data-sorted-direction"), c = f ? "ascending" === g ? "descending" : "ascending" : i.defaultSortDirection, h = this.parentNode.querySelectorAll("th"), j = 0, k = h.length; j < k; j++)d = h[j], d.setAttribute("data-sorted", "false"), d.removeAttribute("data-sorted-direction"); return this.setAttribute("data-sorted", "true"), this.setAttribute("data-sorted-direction", c), e.sort(a), "function" == typeof window.CustomEvent && "function" == typeof a.dispatchEvent ? a.dispatchEvent(new CustomEvent("Sortable.sorted", { bubbles: !0 })) : void 0 }, l = [], j = 0, k = c.length; j < k; j++)g = c[j], l.push(b(d, g, h)); return l }, getColumnType: function (a, b) { var c, d, f, g, h, i, j, k, l, m, n; if (null != (d = null != (l = a.querySelectorAll("th")[b]) ? l.getAttribute("data-sortable-type") : void 0)) return e.typesObject[d]; for (m = a.tBodies[0].rows, h = 0, j = m.length; h < j; h++)for (c = m[h], f = e.getNodeValue(c.cells[b]), n = e.types, i = 0, k = n.length; i < k; i++)if (g = n[i], g.match(f)) return g; return e.typesObject.alpha }, getNodeValue: function (a) { var b; return a ? (b = a.getAttribute("data-value"), null !== b ? b : void 0 !== a.innerText ? a.innerText.replace(g, "") : a.textContent.replace(g, "")) : "" }, setupTypes: function (a) { var b, c, d, f; for (e.types = a, e.typesObject = {}, f = [], c = 0, d = a.length; c < d; c++)b = a[c], f.push(e.typesObject[b.name] = b); return f } }, e.setupTypes([{ name: "numeric", defaultSortDirection: "descending", match: function (a) { return a.match(d) }, comparator: function (a) { return parseFloat(a.replace(/[^0-9.-]/g, ""), 10) || 0 } }, { name: "date", defaultSortDirection: "ascending", reverse: !0, match: function (a) { return !isNaN(Date.parse(a)) }, comparator: function (a) { return Date.parse(a) || 0 } }, { name: "alpha", defaultSortDirection: "ascending", match: function () { return !0 }, compare: function (a, b) { return a.localeCompare(b) } }]), setTimeout(e.init, 0), "function" == typeof define && define.amd ? define(function () { return e }) : "undefined" != typeof exports ? module.exports = e : window.Sortable = e }).call(this); \ No newline at end of file