Move all scripts to assets/js

This commit is contained in:
Vincevrp
2018-11-07 18:30:35 +01:00
parent 144f3ef1a7
commit fd95550c4e
5 changed files with 0 additions and 0 deletions

6
assets/js/bootstrap.min.js vendored Normal file

File diff suppressed because one or more lines are too long

2
assets/js/jquery-3.3.1.min.js vendored Normal file

File diff suppressed because one or more lines are too long

4
assets/js/popper.min.js vendored Normal file

File diff suppressed because one or more lines are too long

145
assets/js/sortable.js Normal file
View File

@ -0,0 +1,145 @@
(function() {
var SELECTOR, clickEvent, numberRegExp, sortable, touchDevice, trimRegExp;
SELECTOR = 'table[data-sortable]';
numberRegExp = /^-?[£$¤]?[\d,.]+%?$/;
trimRegExp = /^\s+|\s+$/g;
touchDevice = 'ontouchstart' in document.documentElement;
clickEvent = touchDevice ? 'touchstart' : 'click';
sortable = {
init: function() {
var table, tables, _i, _len, _results;
tables = document.querySelectorAll(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;
if (table.tHead.rows.length !== 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 type;
type = sortable.getColumnType(table, i);
return th.addEventListener(clickEvent, function(e) {
var newSortedDirection, row, rowArray, rowArrayObject, sorted, sortedDirection, tBody, ths, _i, _j, _k, _len, _len1, _len2, _ref, _results;
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);
tBody = table.tBodies[0];
rowArray = [];
_ref = tBody.rows;
for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) {
row = _ref[_j];
rowArray.push([sortable.getNodeValue(row.cells[i]), row]);
}
if (sorted) {
rowArray.reverse();
} else {
rowArray.sort(type.compare);
}
_results = [];
for (_k = 0, _len2 = rowArray.length; _k < _len2; _k++) {
rowArrayObject = rowArray[_k];
_results.push(tBody.appendChild(rowArrayObject[1]));
}
return _results;
});
},
getColumnType: function(table, i) {
var row, text, _i, _len, _ref;
_ref = table.tBodies[0].rows;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
row = _ref[_i];
text = sortable.getNodeValue(row.cells[i]);
if (text !== '' && text.match(numberRegExp)) {
return sortable.types.numeric;
}
}
return sortable.types.alpha;
},
getNodeValue: function(node) {
if (!node) {
return '';
}
if (node.getAttribute('data-value') !== null) {
return node.getAttribute('data-value');
}
if (typeof node.innerText !== 'undefined') {
return node.innerText.replace(trimRegExp, '');
}
return node.textContent.replace(trimRegExp, '');
},
types: {
numeric: {
defaultSortDirection: 'descending',
compare: function(a, b) {
var aa, bb;
aa = parseFloat(a[0].replace(/[^0-9.-]/g, ''));
bb = parseFloat(b[0].replace(/[^0-9.-]/g, ''));
if (isNaN(aa)) {
aa = 0;
}
if (isNaN(bb)) {
bb = 0;
}
return bb - aa;
}
},
alpha: {
defaultSortDirection: 'ascending',
compare: function(a, b) {
var aa, bb;
aa = a[0].toLowerCase();
bb = b[0].toLowerCase();
if (aa === bb) {
return 0;
}
if (aa < bb) {
return -1;
}
return 1;
}
}
}
};
setTimeout(sortable.init, 0);
window.Sortable = sortable;
}).call(this);

2
assets/js/sortable.min.js vendored Normal file
View File

@ -0,0 +1,2 @@
/*! sortable.js 0.5.0 */
(function(){var a,b,c,d,e,f;a="table[data-sortable]",c=/^-?[£$¤]?[\d,.]+%?$/,f=/^\s+|\s+$/g,e="ontouchstart"in document.documentElement,b=e?"touchstart":"click",d={init:function(){var b,c,e,f,g;for(c=document.querySelectorAll(a),g=[],e=0,f=c.length;f>e;e++)b=c[e],g.push(d.initTable(b));return g},initTable:function(a){var b,c,e,f,g;if(1===a.tHead.rows.length&&"true"!==a.getAttribute("data-sortable-initialized")){for(a.setAttribute("data-sortable-initialized","true"),e=a.querySelectorAll("th"),b=f=0,g=e.length;g>f;b=++f)c=e[b],"false"!==c.getAttribute("data-sortable")&&d.setupClickableTH(a,c,b);return a}},setupClickableTH:function(a,c,e){var f;return f=d.getColumnType(a,e),c.addEventListener(b,function(){var b,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u;for(j="true"===this.getAttribute("data-sorted"),k=this.getAttribute("data-sorted-direction"),b=j?"ascending"===k?"descending":"ascending":f.defaultSortDirection,m=this.parentNode.querySelectorAll("th"),n=0,q=m.length;q>n;n++)c=m[n],c.setAttribute("data-sorted","false"),c.removeAttribute("data-sorted-direction");for(this.setAttribute("data-sorted","true"),this.setAttribute("data-sorted-direction",b),l=a.tBodies[0],h=[],t=l.rows,o=0,r=t.length;r>o;o++)g=t[o],h.push([d.getNodeValue(g.cells[e]),g]);for(j?h.reverse():h.sort(f.compare),u=[],p=0,s=h.length;s>p;p++)i=h[p],u.push(l.appendChild(i[1]));return u})},getColumnType:function(a,b){var e,f,g,h,i;for(i=a.tBodies[0].rows,g=0,h=i.length;h>g;g++)if(e=i[g],f=d.getNodeValue(e.cells[b]),""!==f&&f.match(c))return d.types.numeric;return d.types.alpha},getNodeValue:function(a){return a?null!==a.getAttribute("data-value")?a.getAttribute("data-value"):"undefined"!=typeof a.innerText?a.innerText.replace(f,""):a.textContent.replace(f,""):""},types:{numeric:{defaultSortDirection:"descending",compare:function(a,b){var c,d;return c=parseFloat(a[0].replace(/[^0-9.-]/g,"")),d=parseFloat(b[0].replace(/[^0-9.-]/g,"")),isNaN(c)&&(c=0),isNaN(d)&&(d=0),d-c}},alpha:{defaultSortDirection:"ascending",compare:function(a,b){var c,d;return c=a[0].toLowerCase(),d=b[0].toLowerCase(),c===d?0:d>c?-1:1}}}},setTimeout(d.init,0),window.Sortable=d}).call(this);