diff --git a/README.md b/README.md index bbe8fde..d8ca08a 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ A lightweight, dependency-free javascript HTML table plugin. Similar to jQuery D * moment.js integration for sorting columns with datetime strings (experimental, v1.2.3 and above) -[Documentation](https://github.com/Mobius1/Vanilla-DataTables/wiki) | [Latest Stable Version](https://github.com/Mobius1/Vanilla-DataTables/releases/tag/1.3.5) | [Latest Version](https://github.com/Mobius1/Vanilla-DataTables/releases/tag/1.4.2) +[Documentation](https://github.com/Mobius1/Vanilla-DataTables/wiki) | [Latest Stable Version](https://github.com/Mobius1/Vanilla-DataTables/releases/tag/1.3.5) | [Latest Version](https://github.com/Mobius1/Vanilla-DataTables/releases/tag/1.4.3) --- diff --git a/bower.json b/bower.json index d00ea8b..9d397d0 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "vanilla-datatables", - "version": "1.4.2", + "version": "1.4.3", "main": "src/vanilla-dataTables.js", "ignore": [ ".gitattributes", diff --git a/dist/vanilla-dataTables.min.css b/dist/vanilla-dataTables.min.css index a46f316..4a4fb8b 100644 --- a/dist/vanilla-dataTables.min.css +++ b/dist/vanilla-dataTables.min.css @@ -4,7 +4,7 @@ * Copyright (c) 2015-2017 Karl Saunders (http://mobius.ovh) * Licensed under MIT (http://www.opensource.org/licenses/mit-license.php) * - * Version: 1.4.2 + * Version: 1.4.3 * */ .dataTable-wrapper.no-header .dataTable-container{border-top:1px solid #d9d9d9}.dataTable-wrapper.no-footer .dataTable-container{border-bottom:1px solid #d9d9d9}.dataTable-top,.dataTable-bottom{padding:8px 10px}.dataTable-top > div:first-child,.dataTable-bottom > div:first-child{float:left}.dataTable-top > div:last-child,.dataTable-bottom > div:last-child{float:right}.dataTable-selector{padding:6px}.dataTable-input{padding:6px 12px}.dataTable-info{margin:7px 0}.dataTable-pagination ul{margin:0;padding-left:0}.dataTable-pagination li{list-style:none;float:left}.dataTable-pagination a{border:1px solid transparent;float:left;margin-left:2px;padding:6px 12px;position:relative;text-decoration:none;color:#333}.dataTable-pagination a:hover{background-color:#d9d9d9}.dataTable-pagination .active a,.dataTable-pagination .active a:focus,.dataTable-pagination .active a:hover{background-color:#d9d9d9;cursor:default}.dataTable-pagination .ellipsis a,.dataTable-pagination .disabled a,.dataTable-pagination .disabled a:focus,.dataTable-pagination .disabled a:hover{cursor:not-allowed}.dataTable-pagination .disabled a,.dataTable-pagination .disabled a:focus,.dataTable-pagination .disabled a:hover{cursor:not-allowed;opacity:.4}.dataTable-pagination .pager a{font-weight:700}.dataTable-table{max-width:100%;width:100%;border-spacing:0}.dataTable-table > tbody > tr > td,.dataTable-table > tbody > tr > th,.dataTable-table > tfoot > tr > td,.dataTable-table > tfoot > tr > th,.dataTable-table > thead > tr > td,.dataTable-table > thead > tr > th{vertical-align:top;padding:8px 10px}.dataTable-table > thead > tr > th{vertical-align:bottom;text-align:left;border-bottom:1px solid #d9d9d9}.dataTable-table > tfoot > tr > th{vertical-align:bottom;text-align:left;border-top:1px solid #d9d9d9}.dataTable-table th{vertical-align:bottom;text-align:left}.dataTable-table th a{text-decoration:none;color:inherit}.dataTable-sorter{display:inline-block;height:100%;position:relative;width:100%}.dataTable-sorter::before,.dataTable-sorter::after{content:"";height:0;width:0;position:absolute;right:4px;border-left:4px solid transparent;border-right:4px solid transparent;opacity:0}.dataTable-sorter::before{border-top:4px solid #000;bottom:8px}.dataTable-sorter::after{border-bottom:4px solid #000;border-top:4px solid transparent;top:8px}.asc .dataTable-sorter::after,.desc .dataTable-sorter::before{opacity:.6}.dataTables-empty{text-align:center}.dataTable-top::after,.dataTable-bottom::after{clear:both;content:" ";display:table} \ No newline at end of file diff --git a/dist/vanilla-dataTables.min.js b/dist/vanilla-dataTables.min.js index c6692f2..cca33f3 100644 --- a/dist/vanilla-dataTables.min.js +++ b/dist/vanilla-dataTables.min.js @@ -4,7 +4,7 @@ * Copyright (c) 2015-2017 Karl Saunders (http://mobius.ovh) * Licensed under MIT (http://www.opensource.org/licenses/mit-license.php) * - * Version: 1.4.2 + * Version: 1.4.3 * */ -!function(t,e){var i="DataTable";"function"==typeof define&&define.amd?define([],e(i)):"object"==typeof exports?module.exports=e(i):t[i]=e(i)}(this,function(t){"use strict";var e=window,i=document,a=i.body,s={perPage:10,perPageSelect:[5,10,15,20,25],sortable:!0,searchable:!0,nextPrev:!0,firstLast:!1,prevText:"‹",nextText:"›",firstText:"«",lastText:"»",ellipsisText:"…",ascText:"▴",descText:"▾",truncatePager:!0,pagerDelta:2,fixedColumns:!0,fixedHeight:!1,header:!0,footer:!1,labels:{placeholder:"Search...",perPage:"{select} entries per page",noRows:"No entries found",info:"Showing {start} to {end} of {rows} entries"},layout:{top:"{select}{search}",bottom:"{info}{pager}"}},n=function(t){return"[object Object]"===Object.prototype.toString.call(t)},r=function(t){return Array.isArray(t)},o=function(t){var e=!1;try{e=JSON.parse(t)}catch(t){return!1}return!(null===e||!r(e)&&!n(e))&&e},h=function(t,e){for(var i in e)if(e.hasOwnProperty(i)){var a=e[i];a&&n(a)?(t[i]=t[i]||{},h(t[i],a)):t[i]=a}return t},l=function(t,e,i){if(n(t))for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&e.call(i,a,t[a]);else for(var s=0,r=t.length;s'+i+""})},f={add:function(t,e){t.classList?t.classList.add(e):f.contains(t,e)||(t.className=t.className.trim()+" "+e)},remove:function(t,e){t.classList?t.classList.remove(e):f.contains(t,e)&&(t.className=t.className.replace(new RegExp("(^|\\s)"+e.split(" ").join("|")+"(\\s|$)","gi")," "))},contains:function(t,e){if(t)return t.classList?t.classList.contains(e):!!t.className&&!!t.className.match(new RegExp("(\\s|^)"+e+"(\\s|$)"))}},g=function(t,e){var i,a;1===e?(i=0,a=t.length):-1===e&&(i=t.length-1,a=-1);for(var s=!0;s;){s=!1;for(var n=i;n!=a;n+=e)if(t[n+e]&&t[n].value>t[n+e].value){var r=t[n],o=t[n+e],h=r;t[n]=o,t[n+e]=h,s=!0}}return t},b=function(t,e,i,a,s){var n,r=2*(a=a||2),o=e-a,h=e+a,d=[],p=[];e<4-a+r?h=3+r:e>i-(3-a+r)&&(o=i-(2+r));for(var u=1;u<=i;u++)if(1==u||u==i||u>=o&&u<=h){var g=t[u-1];f.remove(g,"active"),d.push(g)}return l(d,function(e,i){var a=i.children[0].getAttribute("data-page");if(n){var r=n.children[0].getAttribute("data-page");if(a-r==2)p.push(t[r]);else if(a-r!=1){var o=c("li",{class:"ellipsis",html:''+s+""});p.push(o)}}p.push(i),n=i}),p},m=function(t){var e=!1,i=!1;if((t=t||this.options.data).headings){e=c("thead");var a=c("tr");l(t.headings,function(t,e){var i=c("th",{html:e});a.appendChild(i)}),e.appendChild(a)}t.rows&&(i=c("tbody"),l(t.rows,function(e,a){if(t.headings&&t.headings.length!==a.length)throw new Error("The number of rows do not match the number of headings.");var s=c("tr");l(a,function(t,e){var i=c("td",{html:e});s.appendChild(i)}),i.appendChild(s)})),e&&(null!==this.table.tHead&&this.table.removeChild(this.table.tHead),this.table.appendChild(e)),i&&(this.table.tBodies.length&&this.table.removeChild(this.table.tBodies[0]),this.table.appendChild(i))},v=function(t,e){var i=!1;if(e)switch(e){case"ISO_8601":i=moment(t,moment.ISO_8601).format("YYYYMMDD");break;case"RFC_2822":i=moment(t,"ddd, MM MMM YYYY HH:mm:ss ZZ").format("YYYYMMDD");break;case"MYSQL":i=moment(t,"YYYY-MM-DD hh:mm:ss").format("YYYYMMDD");break;case"UNIX":i=moment(t).unix();break;default:i=moment(t,e).format("YYYYMMDD")}return i},x=function(t,e){return this.dt=t,this.columns=e,this};x.prototype.select=function(){var t=this.columns;return r(t)||(t=[]).push(this.columns),t},x.prototype.swap=function(){if(this.columns.length&&2===this.columns.length){var t=[];l(this.dt.headings,function(e,i){t.push(e)},this);var e=this.columns[0],i=this.columns[1],a=t[i];t[i]=t[e],t[e]=a,this.order(t)}},x.prototype.order=function(t){var e,i,a,s,n,r,o=[],h=[],d=[],c=[];l(t,function(t,a){n=this.dt.headings[a],r="false"!==n.getAttribute("data-sortable"),(e=n.cloneNode(!0)).originalCellIndex=t,e.sortable=r,o.push(e),this.dt.hiddenColumns.indexOf(a)<0&&((i=n.cloneNode(!0)).originalCellIndex=t,i.sortable=r,h.push(i))},this),l(this.dt.data,function(e,i){a=i.cloneNode(),s=i.cloneNode(),a.dataIndex=e,s.dataIndex=e,null!==i.searchIndex&&void 0!==i.searchIndex&&(a.searchIndex=i.searchIndex,s.searchIndex=i.searchIndex),l(t,function(t,e){a.appendChild(i.cells[e].cloneNode(!0)),this.dt.hiddenColumns.indexOf(e)<0&&s.appendChild(i.cells[e].cloneNode(!0))},this),d.push(a),c.push(s)},this),this.dt.headings=o,this.dt.activeHeadings=h,this.dt.data=d,this.dt.activeRows=c,this.dt.update()},x.prototype.hide=function(){var t=this.select();t.length&&(l(t,function(t,e){this.dt.hiddenColumns.indexOf(e)<0&&this.dt.hiddenColumns.push(e)},this),this.rebuild())},x.prototype.show=function(){var t=this.select();if(t.length){var e;l(t,function(t,i){(e=this.dt.hiddenColumns.indexOf(i))>-1&&this.dt.hiddenColumns.splice(e,1)},this),this.rebuild()}},x.prototype.visible=function(){var t;return isNaN(this.columns)?r(this.columns)&&(t=[],l(this.columns,function(e,i){t.push(this.dt.hiddenColumns.indexOf(i)<0)},this)):t=this.dt.hiddenColumns.indexOf(this.columns)<0,t},x.prototype.hidden=function(){var t;return isNaN(this.columns)?r(this.columns)&&(t=[],l(this.columns,function(e,i){t.push(this.dt.hiddenColumns.indexOf(i)>-1)},this)):t=this.dt.hiddenColumns.indexOf(this.columns)>-1,t},x.prototype.add=function(t){var e,i=document.createElement("th");t.heading.nodeName?i.appendChild(t.heading):i.innerHTML=t.heading,this.dt.headings.push(i),l(this.dt.data,function(i,a){t.rows[i]&&(e=document.createElement("td"),t.rows[i].nodeName?e.appendChild(t.rows[i]):e.innerHTML=t.rows[i],a.appendChild(e))}),t.type&&i.setAttribute("data-type",t.type),t.format&&i.setAttribute("data-format",t.format),t.hasOwnProperty("sortable")&&(i.sortable=t.sortable,i.setAttribute("data-sortable",!0===t.sortable?"true":"false")),this.rebuild()},x.prototype.remove=function(t){r(t)?(t.sort(function(t,e){return e-t}),l(t,function(t,e){this.remove(e)},this)):(this.dt.headings.splice(t,1),l(this.dt.data,function(e,i){i.removeChild(i.cells[t])})),this.rebuild()},x.prototype.rebuild=function(){var t,e,i=[];this.dt.activeRows=[],this.dt.activeHeadings=[],l(this.dt.headings,function(t,e){e.originalCellIndex=t,e.sortable="false"!==e.getAttribute("data-sortable"),this.dt.hiddenColumns.indexOf(t)<0&&this.dt.activeHeadings.push(e)},this),l(this.dt.data,function(a,s){t=s.cloneNode(),e=s.cloneNode(),t.dataIndex=a,e.dataIndex=a,null!==s.searchIndex&&void 0!==s.searchIndex&&(t.searchIndex=s.searchIndex,e.searchIndex=s.searchIndex),l(s.cells,function(i,a){t.appendChild(a.cloneNode(!0)),this.dt.hiddenColumns.indexOf(a.cellIndex)<0&&e.appendChild(a.cloneNode(!0))},this),i.push(t),this.dt.activeRows.push(e)},this),this.dt.data=i,this.dt.renderHeader(),this.dt.update()};var w=function(t,e){return this.dt=t,this.rows=e,this};w.prototype.build=function(t){var e,i=c("tr");return l(this.dt.headings,function(a,s){e=c("td",{html:t[a]}),i.appendChild(e)},this),i},w.prototype.add=function(t){r(t)&&this.dt.data.push(this.build(t)),this.update(),this.dt.columns().rebuild()},w.prototype.remove=function(t){r(t)?(t.sort(function(t,e){return e-t}),l(t,function(t,e){this.dt.data.splice(e,1)},this)):this.dt.data.splice(t,1),this.update(),this.dt.columns().rebuild()},w.prototype.update=function(){l(this.dt.data,function(t,e){e.dataIndex=t})};var C=function(t,e){if(this.initialized=!1,this.options=h(s,e),"string"==typeof t){var i=t;if(!(t=document.querySelector(t)))throw new Error("The element '"+i+"' can not be found.")}if("table"!==t.tagName.toLowerCase())throw new Error("The selected element is not a table.");if(this.initialLayout=t.innerHTML,this.initialSortable=this.options.sortable,this.options.header||(this.options.sortable=!1),null===t.tHead&&(!this.options.data||this.options.data&&!this.options.data.headings)&&(this.options.sortable=!1),t.tBodies.length&&!t.tBodies[0].rows.length&&this.options.data&&!this.options.data.rows)throw new Error("You seem to be using the data option, but you've not defined any rows.");this.table=t,this.init()},y=C.prototype;return C.extend=function(t,e){"function"==typeof e?C.prototype[t]=e:C[t]=e},y.init=function(t){if(this.initialized||f.contains(this.table,"dataTable-table"))return!1;var e=this;this.options=h(this.options,t||{}),this.isIE=!!/(msie|trident)/i.test(navigator.userAgent),this.currentPage=1,this.onFirstPage=!0,this.hiddenColumns=[],this.render(),this.options.plugins&&l(this.options.plugins,function(t,e){this[t](e)},this),setTimeout(function(){e.emit("datatable.init"),e.initialized=!0},10)},y.render=function(t){if(t){switch(t){case"page":this.renderPage();break;case"pager":this.renderPager();break;case"header":this.renderHeader()}return!1}var e=this,i=e.options,a="";if(i.data&&m.call(e),i.ajax){var s=i.ajax,n=new XMLHttpRequest;d(n,"progress",function(t){e.emit("datatable.ajax.progress",t,n)}),d(n,"load",function(t){if(4===n.readyState)if(e.emit("datatable.ajax.loaded",t,n),200===n.status){var i=s.load?s.load.call(e,n):n.responseText,a=!!o(i)&&"json";e.import({type:a,data:i}),e.setColumns(),e.emit("datatable.ajax.success",t,n)}else e.emit("datatable.ajax.error",t,n)}),d(n,"error",function(t){e.emit("datatable.ajax.error",t,n)}),d(n,"abort",function(t){e.emit("datatable.ajax.abort",t,n)}),e.emit("datatable.ajax.loading",n),n.open("GET","string"==typeof s?i.ajax:i.ajax.url),n.send()}if(e.body=e.table.tBodies[0],e.head=e.table.tHead,e.foot=e.table.tFoot,e.body||(e.body=c("tbody"),e.table.appendChild(e.body)),e.hasRows=e.body.rows.length>0,!e.head){var r=c("thead"),h=c("tr");e.hasRows&&(l(e.body.rows[0].cells,function(t,e){h.appendChild(c("th"))}),r.appendChild(h)),e.head=r,e.table.insertBefore(e.head,e.body)}if(e.headings=[],e.hasHeadings=e.head.rows.length>0,e.hasHeadings&&(e.header=e.head.rows[0],e.headings=[].slice.call(e.header.cells)),i.header||e.head&&e.table.removeChild(e.table.tHead),i.footer?e.head&&!e.foot&&(e.foot=c("tfoot",{html:e.head.innerHTML}),e.table.appendChild(e.foot)):e.foot&&e.table.removeChild(e.table.tFoot),i.ajax||e.setColumns(),e.wrapper=c("div",{class:"dataTable-wrapper dataTable-loading"}),a+="
",a+=i.layout.top,a+="
",a+="
",a+="
",a+=i.layout.bottom,a+="
",a=a.replace("{info}","
"),i.perPageSelect){var p="
";var u=c("select",{class:"dataTable-selector"});l(i.perPageSelect,function(t,e){var a=e===i.perPage,s=new Option(e,e,a,a);u.add(s)}),p=p.replace("{select}",u.outerHTML),a=a.replace("{select}",p)}else a=a.replace("{select}","");if(i.searchable){var g="";a=a.replace("{search}",g)}else a=a.replace("{search}","");e.hasHeadings&&this.render("header"),f.add(e.table,"dataTable-table");var b=c("div",{class:"dataTable-pagination"}),v=c("ul");b.appendChild(v),a=a.replace(/\{pager\}/g,b.outerHTML),e.wrapper.innerHTML=a,e.container=e.wrapper.querySelector(".dataTable-container"),e.pagers=e.wrapper.querySelectorAll(".dataTable-pagination"),e.label=e.wrapper.querySelector(".dataTable-info"),e.table.parentNode.replaceChild(e.wrapper,e.table),e.container.appendChild(e.table),e.rect=e.table.getBoundingClientRect(),e.data=[].slice.call(e.body.rows),e.activeRows=e.data.slice(),e.activeHeadings=e.headings.slice(),e.update(),i.fixedHeight&&this.fixHeight(),i.fixedColumns&&e.activeHeadings.length&&e.fixColumns(),i.header||f.add(e.wrapper,"no-header"),i.footer||f.add(e.wrapper,"no-footer"),i.sortable&&f.add(e.wrapper,"sortable"),i.searchable&&f.add(e.wrapper,"searchable"),i.fixedHeight&&f.add(e.wrapper,"fixed-height"),i.fixedColumns&&f.add(e.wrapper,"fixed-columns"),e.bindEvents()},y.renderPage=function(){if(this.hasRows&&this.totalPages){this.currentPage>this.totalPages&&(this.currentPage=1);var t=this.currentPage-1,e=i.createDocumentFragment();p(this.header,this.isIE),l(this.activeHeadings,function(t,e){this.header.appendChild(e)},this),l(this.pages[t],function(t,i){e.appendChild(i)},this),this.clear(e),this.onFirstPage=1===this.currentPage,this.onLastPage=this.currentPage===this.lastPage}else this.clear();var a,s=0,n=0,r=0;if(this.totalPages&&(r=(n=(s=this.currentPage-1)*this.options.perPage)+this.pages[s].length,n+=1,a=this.searching?this.searchData.length:this.data.length),this.label&&this.options.labels.info.length){var o=this.options.labels.info.replace("{start}",n).replace("{end}",r).replace("{page}",this.currentPage).replace("{pages}",this.totalPages).replace("{rows}",a);this.label.innerHTML=a?o:""}this.options.fixedHeight&&1==this.currentPage&&this.fixHeight()},y.renderPager=function(){if(p(this.pagers,this.isIE),this.totalPages>1){var t="pager",e=i.createDocumentFragment(),a=this.onFirstPage?1:this.currentPage-1,s=this.onlastPage?this.totalPages:this.currentPage+1;this.options.firstLast&&e.appendChild(u(t,1,this.options.firstText)),this.options.nextPrev&&e.appendChild(u(t,a,this.options.prevText));var n=this.links;this.options.truncatePager&&(n=b(this.links,this.currentPage,this.pages.length,this.options.pagerDelta,this.options.ellipsisText)),f.add(this.links[this.currentPage-1],"active"),l(n,function(t,i){f.remove(i,"active"),e.appendChild(i)}),f.add(this.links[this.currentPage-1],"active"),this.options.nextPrev&&e.appendChild(u(t,s,this.options.nextText)),this.options.firstLast&&e.appendChild(u(t,this.totalPages,this.options.lastText)),l(this.pagers,function(t,i){i.appendChild(e.cloneNode(!0))})}},y.renderHeader=function(){var t=this;t.headings&&t.headings.length&&l(t.headings,function(e,i){if(f.contains(i.firstElementChild,"dataTable-sorter")&&(i.innerHTML=i.firstElementChild.innerHTML),i.sortable="false"!==i.getAttribute("data-sortable"),i.originalCellIndex=e,t.options.sortable&&i.sortable){var a=c("a",{href:"#",class:"dataTable-sorter",html:i.innerHTML});i.innerHTML="",i.setAttribute("data-sortable",""),i.appendChild(a)}})},y.bindEvents=function(){var t=this,e=t.options;if(e.perPageSelect){var i=t.wrapper.querySelector(".dataTable-selector");i&&d(i,"change",function(i){e.perPage=parseInt(this.value,10),t.update(),e.fixedHeight&&this.fixHeight(),t.emit("datatable.perpage")})}e.searchable&&(t.input=t.wrapper.querySelector(".dataTable-input"),t.input&&d(t.input,"keyup",function(e){t.search(this.value)})),d(t.wrapper,"click",function(i){var a=i.target;"a"===a.nodeName.toLowerCase()&&(a.hasAttribute("data-page")?(t.page(a.getAttribute("data-page")),i.preventDefault()):e.sortable&&f.contains(a,"dataTable-sorter")&&"false"!=a.parentNode.getAttribute("data-sortable")&&(t.sortColumn(t.activeHeadings.indexOf(a.parentNode)+1),i.preventDefault()))})},y.setColumns=function(){this.options.columns&&l(this.options.columns,function(t,e){e.select&&(r(e.select)||(e.select=[e.select]),l(e.select,function(t,i){var a=this.headings[i];e.type&&a.setAttribute("data-type",e.type),e.format&&a.setAttribute("data-format",e.format),e.hasOwnProperty("sortable")&&a.setAttribute("data-sortable",e.sortable),e.hasOwnProperty("hidden")&&!1!==e.hidden&&this.columns(i).hide()},this))},this),this.render("header")},y.destroy=function(){this.table.innerHTML=this.initialLayout,f.remove(this.table,"dataTable-table"),this.wrapper.parentNode.replaceChild(this.table,this.wrapper),this.initialized=!1},y.on=function(t,e){this.events=this.events||{},this.events[t]=this.events[t]||[],this.events[t].push(e)},y.off=function(t,e){this.events=this.events||{},t in this.events!=!1&&this.events[t].splice(this.events[t].indexOf(e),1)},y.emit=function(t){if(this.events=this.events||{},t in this.events!=!1)for(var e=0;e-1;t.split(" ").reduce(function(t,i){for(var s=!1,n=0;n-1&&e.columns(a.cells[n].cellIndex).visible()){s=!0;break}return t&&s},!0)&&!s?(a.searchIndex=i,this.searchData.push(i)):a.searchIndex=null},this),f.add(this.wrapper,"search-results"),this.searchData.length||(f.remove(this.wrapper,"search-results"),this.setMessage(this.options.labels.noRows)),this.update(),this.emit("datatable.search",t,this.searchData)},y.page=function(t){return t!=this.currentPage&&(isNaN(t)||(this.currentPage=parseInt(t,10)),!(t>this.pages.length||t<0)&&(this.render("page"),this.render("pager"),void this.emit("datatable.page",t)))},y.sortColumn=function(t,i){if(t<1||t>this.activeHeadings.length)return!1;this.sorting=!0,t-=1;var a,s=this.data,n=[],r=[],o=0,h=0,d=this.activeHeadings[t];t=d.originalCellIndex,l(s,function(i,a){var s=a.cells[t].textContent,l=s.replace(/(\$|\,|\s|%)/g,"");if("date"===d.getAttribute("data-type")&&e.moment){var c=!1;d.hasAttribute("data-format")&&(c=d.getAttribute("data-format")),l=v(s,c)}parseFloat(l)==l?r[h++]={value:Number(l),row:a}:n[o++]={value:s,row:a}});var c,p;f.contains(d,"asc")||"asc"==i?(c=g(n,-1),p=g(r,-1),a="descending",f.remove(d,"asc"),f.add(d,"desc")):(c=g(r,1),p=g(n,1),a="ascending",f.remove(d,"desc"),f.add(d,"asc")),this.lastTh&&d!=this.lastTh&&(f.remove(this.lastTh,"desc"),f.remove(this.lastTh,"asc")),this.lastTh=d,s=c.concat(p),this.data=[];var u=[];l(s,function(t,e){this.data.push(e.row),null!==e.row.searchIndex&&void 0!==e.row.searchIndex&&u.push(t)},this),this.searchData=u,this.columns().rebuild(),this.update(),this.emit("datatable.sort",t,a)},y.insert=function(t){if(!n(t))throw new Error("Method insert requires an object.");if(!t.rows)throw new Error("Method insert requires the 'rows' property.");if(t.headings&&!this.hasHeadings&&!this.hasRows){var e,i=c("tr");l(t.headings,function(t,a){e=c("th",{html:a}),i.appendChild(e)}),this.head.appendChild(i),this.header=i,this.headings=[].slice.call(i.cells),this.hasHeadings=!0,this.options.sortable=this.initialSortable,this.render("header")}l(t.rows,function(t,e){this.rows().add(e)},this),this.hasRows=!0,this.update(),this.options.fixedColumns&&this.fixColumns()},y.refresh=function(){this.options.searchable&&(this.input.value="",this.searching=!1),this.currentPage=1,this.onFirstPage=!0,this.update(),this.emit("datatable.refresh")},y.clear=function(t){this.body&&p(this.body,this.isIE);var e=this.body;this.body||(e=this.table),t&&("string"==typeof t?e.innerHTML=t:e.appendChild(t))},y.export=function(t){if(!this.hasHeadings&&!this.hasRows)return!1;var e,i,s,o,l=this.activeHeadings,d=[],c=[],p={download:!0,skipColumn:[],lineDelimiter:"\n",columnDelimiter:",",tableName:"myTable",replacer:null,space:4};if(!n(t))return!1;var u=h(p,t);if(u.type){if("txt"!==u.type&&"csv"!==u.type||(d[0]=this.header),u.selection)if(isNaN(u.selection)){if(r(u.selection))for(e=0;e'+t+""}))},y.columns=function(t){return new x(this,t)},y.rows=function(t){return new w(this,t)},C}); \ No newline at end of file +!function(t,e){var i="DataTable";"function"==typeof define&&define.amd?define([],e(i)):"object"==typeof exports?module.exports=e(i):t[i]=e(i)}(this,function(t){"use strict";var e=window,i=document,a=i.body,s={perPage:10,perPageSelect:[5,10,15,20,25],sortable:!0,searchable:!0,nextPrev:!0,firstLast:!1,prevText:"‹",nextText:"›",firstText:"«",lastText:"»",ellipsisText:"…",ascText:"▴",descText:"▾",truncatePager:!0,pagerDelta:2,fixedColumns:!0,fixedHeight:!1,header:!0,footer:!1,labels:{placeholder:"Search...",perPage:"{select} entries per page",noRows:"No entries found",info:"Showing {start} to {end} of {rows} entries"},layout:{top:"{select}{search}",bottom:"{info}{pager}"}},n=function(t){return"[object Object]"===Object.prototype.toString.call(t)},r=function(t){return Array.isArray(t)},o=function(t){var e=!1;try{e=JSON.parse(t)}catch(t){return!1}return!(null===e||!r(e)&&!n(e))&&e},h=function(t,e){for(var i in e)if(e.hasOwnProperty(i)){var a=e[i];a&&n(a)?(t[i]=t[i]||{},h(t[i],a)):t[i]=a}return t},l=function(t,e,i){if(n(t))for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&e.call(i,a,t[a]);else for(var s=0,r=t.length;s'+i+""})},f={add:function(t,e){t.classList?t.classList.add(e):f.contains(t,e)||(t.className=t.className.trim()+" "+e)},remove:function(t,e){t.classList?t.classList.remove(e):f.contains(t,e)&&(t.className=t.className.replace(new RegExp("(^|\\s)"+e.split(" ").join("|")+"(\\s|$)","gi")," "))},contains:function(t,e){if(t)return t.classList?t.classList.contains(e):!!t.className&&!!t.className.match(new RegExp("(\\s|^)"+e+"(\\s|$)"))}},g=function(t,e){var i,a;1===e?(i=0,a=t.length):-1===e&&(i=t.length-1,a=-1);for(var s=!0;s;){s=!1;for(var n=i;n!=a;n+=e)if(t[n+e]&&t[n].value>t[n+e].value){var r=t[n],o=t[n+e],h=r;t[n]=o,t[n+e]=h,s=!0}}return t},b=function(t,e,i,a,s){var n,r=2*(a=a||2),o=e-a,h=e+a,d=[],p=[];e<4-a+r?h=3+r:e>i-(3-a+r)&&(o=i-(2+r));for(var u=1;u<=i;u++)if(1==u||u==i||u>=o&&u<=h){var g=t[u-1];f.remove(g,"active"),d.push(g)}return l(d,function(e,i){var a=i.children[0].getAttribute("data-page");if(n){var r=n.children[0].getAttribute("data-page");if(a-r==2)p.push(t[r]);else if(a-r!=1){var o=c("li",{class:"ellipsis",html:''+s+""});p.push(o)}}p.push(i),n=i}),p},m=function(t){var e=!1,i=!1;if((t=t||this.options.data).headings){e=c("thead");var a=c("tr");l(t.headings,function(t,e){var i=c("th",{html:e});a.appendChild(i)}),e.appendChild(a)}t.rows&&(i=c("tbody"),l(t.rows,function(e,a){if(t.headings&&t.headings.length!==a.length)throw new Error("The number of rows do not match the number of headings.");var s=c("tr");l(a,function(t,e){var i=c("td",{html:e});s.appendChild(i)}),i.appendChild(s)})),e&&(null!==this.table.tHead&&this.table.removeChild(this.table.tHead),this.table.appendChild(e)),i&&(this.table.tBodies.length&&this.table.removeChild(this.table.tBodies[0]),this.table.appendChild(i))},v=function(t,e){var i=!1;if(e)switch(e){case"ISO_8601":i=moment(t,moment.ISO_8601).format("YYYYMMDD");break;case"RFC_2822":i=moment(t,"ddd, MM MMM YYYY HH:mm:ss ZZ").format("YYYYMMDD");break;case"MYSQL":i=moment(t,"YYYY-MM-DD hh:mm:ss").format("YYYYMMDD");break;case"UNIX":i=moment(t).unix();break;default:i=moment(t,e).format("YYYYMMDD")}return i},x=function(t,e){return this.dt=t,this.columns=e,this};x.prototype.select=function(){var t=this.columns;return r(t)||(t=[]).push(this.columns),t},x.prototype.swap=function(){if(this.columns.length&&2===this.columns.length){var t=[];l(this.dt.headings,function(e,i){t.push(e)},this);var e=this.columns[0],i=this.columns[1],a=t[i];t[i]=t[e],t[e]=a,this.order(t)}},x.prototype.order=function(t){var e,i,a,s,n,r,o=[],h=[],d=[],c=[];l(t,function(t,a){n=this.dt.headings[a],r="false"!==n.getAttribute("data-sortable"),(e=n.cloneNode(!0)).originalCellIndex=t,e.sortable=r,o.push(e),this.dt.hiddenColumns.indexOf(a)<0&&((i=n.cloneNode(!0)).originalCellIndex=t,i.sortable=r,h.push(i))},this),l(this.dt.data,function(e,i){a=i.cloneNode(),s=i.cloneNode(),a.dataIndex=e,s.dataIndex=e,null!==i.searchIndex&&void 0!==i.searchIndex&&(a.searchIndex=i.searchIndex,s.searchIndex=i.searchIndex),l(t,function(t,e){a.appendChild(i.cells[e].cloneNode(!0)),this.dt.hiddenColumns.indexOf(e)<0&&s.appendChild(i.cells[e].cloneNode(!0))},this),d.push(a),c.push(s)},this),this.dt.headings=o,this.dt.activeHeadings=h,this.dt.data=d,this.dt.activeRows=c,this.dt.update()},x.prototype.hide=function(){var t=this.select();t.length&&(l(t,function(t,e){this.dt.hiddenColumns.indexOf(e)<0&&this.dt.hiddenColumns.push(e)},this),this.rebuild())},x.prototype.show=function(){var t=this.select();if(t.length){var e;l(t,function(t,i){(e=this.dt.hiddenColumns.indexOf(i))>-1&&this.dt.hiddenColumns.splice(e,1)},this),this.rebuild()}},x.prototype.visible=function(){var t;return isNaN(this.columns)?r(this.columns)&&(t=[],l(this.columns,function(e,i){t.push(this.dt.hiddenColumns.indexOf(i)<0)},this)):t=this.dt.hiddenColumns.indexOf(this.columns)<0,t},x.prototype.hidden=function(){var t;return isNaN(this.columns)?r(this.columns)&&(t=[],l(this.columns,function(e,i){t.push(this.dt.hiddenColumns.indexOf(i)>-1)},this)):t=this.dt.hiddenColumns.indexOf(this.columns)>-1,t},x.prototype.add=function(t){var e,i=document.createElement("th");t.heading.nodeName?i.appendChild(t.heading):i.innerHTML=t.heading,this.dt.headings.push(i),l(this.dt.data,function(i,a){t.data[i]&&(e=document.createElement("td"),t.data[i].nodeName?e.appendChild(t.data[i]):e.innerHTML=t.data[i],a.appendChild(e))}),t.type&&i.setAttribute("data-type",t.type),t.format&&i.setAttribute("data-format",t.format),t.hasOwnProperty("sortable")&&(i.sortable=t.sortable,i.setAttribute("data-sortable",!0===t.sortable?"true":"false")),this.rebuild()},x.prototype.remove=function(t){r(t)?(t.sort(function(t,e){return e-t}),l(t,function(t,e){this.remove(e)},this)):(this.dt.headings.splice(t,1),l(this.dt.data,function(e,i){i.removeChild(i.cells[t])})),this.rebuild()},x.prototype.rebuild=function(){var t,e,i=[];this.dt.activeRows=[],this.dt.activeHeadings=[],l(this.dt.headings,function(t,e){e.originalCellIndex=t,e.sortable="false"!==e.getAttribute("data-sortable"),this.dt.hiddenColumns.indexOf(t)<0&&this.dt.activeHeadings.push(e)},this),l(this.dt.data,function(a,s){t=s.cloneNode(),e=s.cloneNode(),t.dataIndex=a,e.dataIndex=a,null!==s.searchIndex&&void 0!==s.searchIndex&&(t.searchIndex=s.searchIndex,e.searchIndex=s.searchIndex),l(s.cells,function(i,a){t.appendChild(a.cloneNode(!0)),this.dt.hiddenColumns.indexOf(a.cellIndex)<0&&e.appendChild(a.cloneNode(!0))},this),i.push(t),this.dt.activeRows.push(e)},this),this.dt.data=i,this.dt.renderHeader(),this.dt.update()};var w=function(t,e){return this.dt=t,this.rows=e,this};w.prototype.build=function(t){var e,i=c("tr");return l(this.dt.headings,function(a,s){e=c("td",{html:t[a]}),i.appendChild(e)},this),i},w.prototype.add=function(t){r(t)&&this.dt.data.push(this.build(t)),this.update(),this.dt.columns().rebuild()},w.prototype.remove=function(t){r(t)?(t.sort(function(t,e){return e-t}),l(t,function(t,e){this.dt.data.splice(e,1)},this)):this.dt.data.splice(t,1),this.update(),this.dt.columns().rebuild()},w.prototype.update=function(){l(this.dt.data,function(t,e){e.dataIndex=t})};var C=function(t,e){if(this.initialized=!1,this.options=h(s,e),"string"==typeof t){var i=t;if(!(t=document.querySelector(t)))throw new Error("The element '"+i+"' can not be found.")}if("table"!==t.tagName.toLowerCase())throw new Error("The selected element is not a table.");if(this.initialLayout=t.innerHTML,this.initialSortable=this.options.sortable,this.options.header||(this.options.sortable=!1),null===t.tHead&&(!this.options.data||this.options.data&&!this.options.data.headings)&&(this.options.sortable=!1),t.tBodies.length&&!t.tBodies[0].rows.length&&this.options.data&&!this.options.data.rows)throw new Error("You seem to be using the data option, but you've not defined any rows.");this.table=t,this.init()},y=C.prototype;return C.extend=function(t,e){"function"==typeof e?C.prototype[t]=e:C[t]=e},y.init=function(t){if(this.initialized||f.contains(this.table,"dataTable-table"))return!1;var e=this;this.options=h(this.options,t||{}),this.isIE=!!/(msie|trident)/i.test(navigator.userAgent),this.currentPage=1,this.onFirstPage=!0,this.hiddenColumns=[],this.render(),this.options.plugins&&l(this.options.plugins,function(t,e){this[t](e)},this),setTimeout(function(){e.emit("datatable.init"),e.initialized=!0},10)},y.render=function(t){if(t){switch(t){case"page":this.renderPage();break;case"pager":this.renderPager();break;case"header":this.renderHeader()}return!1}var e=this,i=e.options,a="";if(i.data&&m.call(e),i.ajax){var s=i.ajax,n=new XMLHttpRequest;d(n,"progress",function(t){e.emit("datatable.ajax.progress",t,n)}),d(n,"load",function(t){if(4===n.readyState)if(e.emit("datatable.ajax.loaded",t,n),200===n.status){var i=s.load?s.load.call(e,n):n.responseText,a=!!o(i)&&"json";e.import({type:a,data:i}),e.setColumns(),e.emit("datatable.ajax.success",t,n)}else e.emit("datatable.ajax.error",t,n)}),d(n,"error",function(t){e.emit("datatable.ajax.error",t,n)}),d(n,"abort",function(t){e.emit("datatable.ajax.abort",t,n)}),e.emit("datatable.ajax.loading",n),n.open("GET","string"==typeof s?i.ajax:i.ajax.url),n.send()}if(e.body=e.table.tBodies[0],e.head=e.table.tHead,e.foot=e.table.tFoot,e.body||(e.body=c("tbody"),e.table.appendChild(e.body)),e.hasRows=e.body.rows.length>0,!e.head){var r=c("thead"),h=c("tr");e.hasRows&&(l(e.body.rows[0].cells,function(t,e){h.appendChild(c("th"))}),r.appendChild(h)),e.head=r,e.table.insertBefore(e.head,e.body)}if(e.headings=[],e.hasHeadings=e.head.rows.length>0,e.hasHeadings&&(e.header=e.head.rows[0],e.headings=[].slice.call(e.header.cells)),i.header||e.head&&e.table.removeChild(e.table.tHead),i.footer?e.head&&!e.foot&&(e.foot=c("tfoot",{html:e.head.innerHTML}),e.table.appendChild(e.foot)):e.foot&&e.table.removeChild(e.table.tFoot),i.ajax||e.setColumns(),e.wrapper=c("div",{class:"dataTable-wrapper dataTable-loading"}),a+="
",a+=i.layout.top,a+="
",a+="
",a+="
",a+=i.layout.bottom,a+="
",a=a.replace("{info}","
"),i.perPageSelect){var p="
";var u=c("select",{class:"dataTable-selector"});l(i.perPageSelect,function(t,e){var a=e===i.perPage,s=new Option(e,e,a,a);u.add(s)}),p=p.replace("{select}",u.outerHTML),a=a.replace("{select}",p)}else a=a.replace("{select}","");if(i.searchable){var g="";a=a.replace("{search}",g)}else a=a.replace("{search}","");e.hasHeadings&&this.render("header"),f.add(e.table,"dataTable-table");var b=c("div",{class:"dataTable-pagination"}),v=c("ul");b.appendChild(v),a=a.replace(/\{pager\}/g,b.outerHTML),e.wrapper.innerHTML=a,e.container=e.wrapper.querySelector(".dataTable-container"),e.pagers=e.wrapper.querySelectorAll(".dataTable-pagination"),e.label=e.wrapper.querySelector(".dataTable-info"),e.table.parentNode.replaceChild(e.wrapper,e.table),e.container.appendChild(e.table),e.rect=e.table.getBoundingClientRect(),e.data=[].slice.call(e.body.rows),e.activeRows=e.data.slice(),e.activeHeadings=e.headings.slice(),e.update(),i.fixedHeight&&this.fixHeight(),i.fixedColumns&&e.activeHeadings.length&&e.fixColumns(),i.header||f.add(e.wrapper,"no-header"),i.footer||f.add(e.wrapper,"no-footer"),i.sortable&&f.add(e.wrapper,"sortable"),i.searchable&&f.add(e.wrapper,"searchable"),i.fixedHeight&&f.add(e.wrapper,"fixed-height"),i.fixedColumns&&f.add(e.wrapper,"fixed-columns"),e.bindEvents()},y.renderPage=function(){if(this.hasRows&&this.totalPages){this.currentPage>this.totalPages&&(this.currentPage=1);var t=this.currentPage-1,e=i.createDocumentFragment();p(this.header,this.isIE),l(this.activeHeadings,function(t,e){this.header.appendChild(e)},this),l(this.pages[t],function(t,i){e.appendChild(i)},this),this.clear(e),this.onFirstPage=1===this.currentPage,this.onLastPage=this.currentPage===this.lastPage}else this.clear();var a,s=0,n=0,r=0;if(this.totalPages&&(r=(n=(s=this.currentPage-1)*this.options.perPage)+this.pages[s].length,n+=1,a=this.searching?this.searchData.length:this.data.length),this.label&&this.options.labels.info.length){var o=this.options.labels.info.replace("{start}",n).replace("{end}",r).replace("{page}",this.currentPage).replace("{pages}",this.totalPages).replace("{rows}",a);this.label.innerHTML=a?o:""}this.options.fixedHeight&&1==this.currentPage&&this.fixHeight()},y.renderPager=function(){if(p(this.pagers,this.isIE),this.totalPages>1){var t="pager",e=i.createDocumentFragment(),a=this.onFirstPage?1:this.currentPage-1,s=this.onlastPage?this.totalPages:this.currentPage+1;this.options.firstLast&&e.appendChild(u(t,1,this.options.firstText)),this.options.nextPrev&&e.appendChild(u(t,a,this.options.prevText));var n=this.links;this.options.truncatePager&&(n=b(this.links,this.currentPage,this.pages.length,this.options.pagerDelta,this.options.ellipsisText)),f.add(this.links[this.currentPage-1],"active"),l(n,function(t,i){f.remove(i,"active"),e.appendChild(i)}),f.add(this.links[this.currentPage-1],"active"),this.options.nextPrev&&e.appendChild(u(t,s,this.options.nextText)),this.options.firstLast&&e.appendChild(u(t,this.totalPages,this.options.lastText)),l(this.pagers,function(t,i){i.appendChild(e.cloneNode(!0))})}},y.renderHeader=function(){var t=this;t.headings&&t.headings.length&&l(t.headings,function(e,i){if(f.contains(i.firstElementChild,"dataTable-sorter")&&(i.innerHTML=i.firstElementChild.innerHTML),i.sortable="false"!==i.getAttribute("data-sortable"),i.originalCellIndex=e,t.options.sortable&&i.sortable){var a=c("a",{href:"#",class:"dataTable-sorter",html:i.innerHTML});i.innerHTML="",i.setAttribute("data-sortable",""),i.appendChild(a)}})},y.bindEvents=function(){var t=this,e=t.options;if(e.perPageSelect){var i=t.wrapper.querySelector(".dataTable-selector");i&&d(i,"change",function(i){e.perPage=parseInt(this.value,10),t.update(),e.fixedHeight&&this.fixHeight(),t.emit("datatable.perpage")})}e.searchable&&(t.input=t.wrapper.querySelector(".dataTable-input"),t.input&&d(t.input,"keyup",function(e){t.search(this.value)})),d(t.wrapper,"click",function(i){var a=i.target;"a"===a.nodeName.toLowerCase()&&(a.hasAttribute("data-page")?(t.page(a.getAttribute("data-page")),i.preventDefault()):e.sortable&&f.contains(a,"dataTable-sorter")&&"false"!=a.parentNode.getAttribute("data-sortable")&&(t.sortColumn(t.activeHeadings.indexOf(a.parentNode)+1),i.preventDefault()))})},y.setColumns=function(){this.options.columns&&l(this.options.columns,function(t,e){e.select&&(r(e.select)||(e.select=[e.select]),l(e.select,function(t,i){var a=this.headings[i];e.type&&a.setAttribute("data-type",e.type),e.format&&a.setAttribute("data-format",e.format),e.hasOwnProperty("sortable")&&a.setAttribute("data-sortable",e.sortable),e.hasOwnProperty("hidden")&&!1!==e.hidden&&this.columns(i).hide()},this))},this),this.render("header")},y.destroy=function(){this.table.innerHTML=this.initialLayout,f.remove(this.table,"dataTable-table"),this.wrapper.parentNode.replaceChild(this.table,this.wrapper),this.initialized=!1},y.on=function(t,e){this.events=this.events||{},this.events[t]=this.events[t]||[],this.events[t].push(e)},y.off=function(t,e){this.events=this.events||{},t in this.events!=!1&&this.events[t].splice(this.events[t].indexOf(e),1)},y.emit=function(t){if(this.events=this.events||{},t in this.events!=!1)for(var e=0;e-1;t.split(" ").reduce(function(t,i){for(var s=!1,n=0;n-1&&e.columns(a.cells[n].cellIndex).visible()){s=!0;break}return t&&s},!0)&&!s?(a.searchIndex=i,this.searchData.push(i)):a.searchIndex=null},this),f.add(this.wrapper,"search-results"),this.searchData.length||(f.remove(this.wrapper,"search-results"),this.setMessage(this.options.labels.noRows)),this.update(),this.emit("datatable.search",t,this.searchData)},y.page=function(t){return t!=this.currentPage&&(isNaN(t)||(this.currentPage=parseInt(t,10)),!(t>this.pages.length||t<0)&&(this.render("page"),this.render("pager"),void this.emit("datatable.page",t)))},y.sortColumn=function(t,i){if(t<1||t>this.activeHeadings.length)return!1;this.sorting=!0,t-=1;var a,s=this.data,n=[],r=[],o=0,h=0,d=this.activeHeadings[t];t=d.originalCellIndex,l(s,function(i,a){var s=a.cells[t].textContent,l=s.replace(/(\$|\,|\s|%)/g,"");if("date"===d.getAttribute("data-type")&&e.moment){var c=!1;d.hasAttribute("data-format")&&(c=d.getAttribute("data-format")),l=v(s,c)}parseFloat(l)==l?r[h++]={value:Number(l),row:a}:n[o++]={value:s,row:a}});var c,p;f.contains(d,"asc")||"asc"==i?(c=g(n,-1),p=g(r,-1),a="descending",f.remove(d,"asc"),f.add(d,"desc")):(c=g(r,1),p=g(n,1),a="ascending",f.remove(d,"desc"),f.add(d,"asc")),this.lastTh&&d!=this.lastTh&&(f.remove(this.lastTh,"desc"),f.remove(this.lastTh,"asc")),this.lastTh=d,s=c.concat(p),this.data=[];var u=[];l(s,function(t,e){this.data.push(e.row),null!==e.row.searchIndex&&void 0!==e.row.searchIndex&&u.push(t)},this),this.searchData=u,this.columns().rebuild(),this.update(),this.emit("datatable.sort",t,a)},y.insert=function(t){if(!n(t))throw new Error("Method insert requires an object.");if(!t.rows)throw new Error("Method insert requires the 'rows' property.");if(t.headings&&!this.hasHeadings&&!this.hasRows){var e,i=c("tr");l(t.headings,function(t,a){e=c("th",{html:a}),i.appendChild(e)}),this.head.appendChild(i),this.header=i,this.headings=[].slice.call(i.cells),this.hasHeadings=!0,this.options.sortable=this.initialSortable,this.render("header")}l(t.rows,function(t,e){this.rows().add(e)},this),this.hasRows=!0,this.update(),this.options.fixedColumns&&this.fixColumns()},y.refresh=function(){this.options.searchable&&(this.input.value="",this.searching=!1),this.currentPage=1,this.onFirstPage=!0,this.update(),this.emit("datatable.refresh")},y.clear=function(t){this.body&&p(this.body,this.isIE);var e=this.body;this.body||(e=this.table),t&&("string"==typeof t?e.innerHTML=t:e.appendChild(t))},y.export=function(t){if(!this.hasHeadings&&!this.hasRows)return!1;var e,i,s,o,l=this.activeHeadings,d=[],c=[],p={download:!0,skipColumn:[],lineDelimiter:"\n",columnDelimiter:",",tableName:"myTable",replacer:null,space:4};if(!n(t))return!1;var u=h(p,t);if(u.type){if("txt"!==u.type&&"csv"!==u.type||(d[0]=this.header),u.selection)if(isNaN(u.selection)){if(r(u.selection))for(e=0;e'+t+""}))},y.columns=function(t){return new x(this,t)},y.rows=function(t){return new w(this,t)},C}); \ No newline at end of file diff --git a/package.json b/package.json index 3b62041..0fdceb0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vanilla-datatables", - "version": "1.4.2", + "version": "1.4.3", "description": "A lightweight, dependency-free javascript HTML table plugin.", "main": "src/vanilla-dataTables.js", "scripts": { diff --git a/src/vanilla-dataTables.css b/src/vanilla-dataTables.css index 3aadb5c..9bc3602 100644 --- a/src/vanilla-dataTables.css +++ b/src/vanilla-dataTables.css @@ -4,7 +4,7 @@ * Copyright (c) 2015-2017 Karl Saunders (http://mobius.ovh) * Licensed under MIT (http://www.opensource.org/licenses/mit-license.php) * - * Version: 1.4.2 + * Version: 1.4.3 * */ diff --git a/src/vanilla-dataTables.js b/src/vanilla-dataTables.js index 912cafd..b17c9d2 100644 --- a/src/vanilla-dataTables.js +++ b/src/vanilla-dataTables.js @@ -4,7 +4,7 @@ * Copyright (c) 2015-2017 Karl Saunders (http://mobius.ovh) * Licensed under MIT (http://www.opensource.org/licenses/mit-license.php) * - * Version: 1.4.2 + * Version: 1.4.3 * */ (function(root, factory) { @@ -619,13 +619,13 @@ this.dt.headings.push(th); each(this.dt.data, function(i, row) { - if (data.rows[i]) { + if (data.data[i]) { td = document.createElement("td"); - if (data.rows[i].nodeName) { - td.appendChild(data.rows[i]); + if (data.data[i].nodeName) { + td.appendChild(data.data[i]); } else { - td.innerHTML = data.rows[i]; + td.innerHTML = data.data[i]; } row.appendChild(td);