diff --git a/Gruntfile.js b/Gruntfile.js index 2a87a519..efb15d3e 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -61,6 +61,7 @@ module.exports = function (grunt) { publicPath: "/dist/", path: __dirname + "/dist", filename: "tablefilter.js", + // chunkFilename: "[name]-[chunkhash].js", chunkFilename: "[name].js", libraryTarget: 'umd' }, @@ -83,25 +84,7 @@ module.exports = function (grunt) { compact: false }, loader: 'babel-loader' - } - // , - // { - // // test: /[\/\\]libs[\/\\]sortabletable\.js$/, - // // test: path.join(__dirname, 'libs') + 'sortabletable.js', - // test: /sortabletable\.js$/, - // exclude: /node_modules/, - // loader: "imports?this=>window" - // }, - // { - // test: /sortabletable\.js$/, - // exclude: /node_modules/, - // loader: "expose?SortableTable" - // } - // { - // test: /[\/]sortabletable\.js$/, - // loader: "exports?SortableTable" - // } - ] + }] }, plugins: [ // new webpack.DefinePlugin({ @@ -110,6 +93,12 @@ module.exports = function (grunt) { // "NODE_ENV": JSON.stringify("production") // } // }), + // new webpack.optimize.CommonsChunkPlugin( + // 'main', 1, false), + // new webpack.IgnorePlugin(/adapterSortabletable$/), + // new webpack.optimize.CommonsChunkPlugin( + // "commons.js", + // ["1", "2"]), new webpack.optimize.DedupePlugin() // , // new webpack.optimize.UglifyJsPlugin() diff --git a/dist/1.js b/dist/1.js index 38e96263..b87991fa 100644 --- a/dist/1.js +++ b/dist/1.js @@ -1,4 +1,4 @@ -webpackJsonp([1,2],{ +webpackJsonp([1,2,3],{ /***/ 1: /***/ function(module, exports, __webpack_require__) { @@ -98,8 +98,6 @@ webpackJsonp([1,2],{ __webpack_require__(27); - // var SortableTable = require('sortabletable'); - var AdapterSortableTable = (function () { /** @@ -153,8 +151,6 @@ webpackJsonp([1,2],{ var sortConfig = tf.sortConfig; var adpt = this; - // var SortableTable = require('sortabletable'); - // SortableTable class sanity check (sortabletable.js) if (_Types.Types.isUndef(SortableTable)) { throw new Error('SortableTable class not found.'); @@ -1157,448 +1153,30 @@ webpackJsonp([1,2],{ /***/ 27: /***/ function(module, exports, __webpack_require__) { - /*----------------------------------------------------------------------------\ - | Sortable Table 1.12 | - |-----------------------------------------------------------------------------| - | Created by Erik Arvidsson | - | (http://webfx.eae.net/contact.html#erik) | - | For WebFX (http://webfx.eae.net/) | - |-----------------------------------------------------------------------------| - | A DOM 1 based script that allows an ordinary HTML table to be sortable. | - |-----------------------------------------------------------------------------| - | Copyright (c) 1998 - 2006 Erik Arvidsson | - |-----------------------------------------------------------------------------| - | Licensed under the Apache License, Version 2.0 (the "License"); you may not | - | use this file except in compliance with the License. You may obtain a copy | - | of the License at http://www.apache.org/licenses/LICENSE-2.0 | - | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | - | Unless required by applicable law or agreed to in writing, software | - | distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | - | WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | - | License for the specific language governing permissions and limitations | - | under the License. | - |-----------------------------------------------------------------------------| - | 2003-01-10 | First version | - | 2003-01-19 | Minor changes to the date parsing | - | 2003-01-28 | JScript 5.0 fixes (no support for 'in' operator) | - | 2003-02-01 | Sloppy typo like error fixed in getInnerText | - | 2003-07-04 | Added workaround for IE cellIndex bug. | - | 2003-11-09 | The bDescending argument to sort was not correctly working | - | | Using onclick DOM0 event if no support for addEventListener | - | | or attachEvent | - | 2004-01-13 | Adding addSortType and removeSortType which makes it a lot | - | | easier to add new, custom sort types. | - | 2004-01-27 | Switch to use descending = false as the default sort order. | - | | Change defaultDescending to suit your needs. | - | 2004-03-14 | Improved sort type None look and feel a bit | - | 2004-08-26 | Made the handling of tBody and tHead more flexible. Now you | - | | can use another tHead or no tHead, and you can chose some | - | | other tBody. | - | 2006-04-25 | Changed license to Apache Software License 2.0 | - |-----------------------------------------------------------------------------| - | Created 2003-01-10 | All changes are in the log above. | Updated 2006-04-25 | - \----------------------------------------------------------------------------*/ + __webpack_require__(28)(__webpack_require__(29)) +/***/ }, - function SortableTable(oTable, oSortTypes) { +/***/ 28: +/***/ function(module, exports, __webpack_require__) { - this.sortTypes = oSortTypes || []; - - this.sortColumn = null; - this.descending = null; - - var oThis = this; - this._headerOnclick = function (e) { - oThis.headerOnclick(e); - }; - - if (oTable) { - this.setTable( oTable ); - this.document = oTable.ownerDocument || oTable.document; - } - else { - this.document = document; - } - - - // only IE needs this - var win = this.document.defaultView || this.document.parentWindow; - this._onunload = function () { - oThis.destroy(); - }; - if (win && typeof win.attachEvent != "undefined") { - win.attachEvent("onunload", this._onunload); - } + /* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra + */ + module.exports = function(src) { + if (typeof execScript === "function") + execScript(src); + else + eval.call(null, src); } - SortableTable.gecko = navigator.product == "Gecko"; - SortableTable.msie = /msie/i.test(navigator.userAgent); - // Mozilla is faster when doing the DOM manipulations on - // an orphaned element. MSIE is not - SortableTable.removeBeforeSort = SortableTable.gecko; +/***/ }, - SortableTable.prototype.onsort = function () {}; - - // default sort order. true -> descending, false -> ascending - SortableTable.prototype.defaultDescending = false; - - // shared between all instances. This is intentional to allow external files - // to modify the prototype - SortableTable.prototype._sortTypeInfo = {}; - - SortableTable.prototype.setTable = function (oTable) { - if ( this.tHead ) - this.uninitHeader(); - this.element = oTable; - this.setTHead( oTable.tHead ); - this.setTBody( oTable.tBodies[0] ); - }; - - SortableTable.prototype.setTHead = function (oTHead) { - if (this.tHead && this.tHead != oTHead ) - this.uninitHeader(); - this.tHead = oTHead; - this.initHeader( this.sortTypes ); - }; - - SortableTable.prototype.setTBody = function (oTBody) { - this.tBody = oTBody; - }; - - SortableTable.prototype.setSortTypes = function ( oSortTypes ) { - if ( this.tHead ) - this.uninitHeader(); - this.sortTypes = oSortTypes || []; - if ( this.tHead ) - this.initHeader( this.sortTypes ); - }; - - // adds arrow containers and events - // also binds sort type to the header cells so that reordering columns does - // not break the sort types - SortableTable.prototype.initHeader = function (oSortTypes) { - if (!this.tHead) return; - var cells = this.tHead.rows[0].cells; - var doc = this.tHead.ownerDocument || this.tHead.document; - this.sortTypes = oSortTypes || []; - var l = cells.length; - var img, c; - for (var i = 0; i < l; i++) { - c = cells[i]; - if (this.sortTypes[i] != null && this.sortTypes[i] != "None") { - img = doc.createElement("IMG"); - img.src = "images/blank.png"; - c.appendChild(img); - if (this.sortTypes[i] != null) - c._sortType = this.sortTypes[i]; - if (typeof c.addEventListener != "undefined") - c.addEventListener("click", this._headerOnclick, false); - else if (typeof c.attachEvent != "undefined") - c.attachEvent("onclick", this._headerOnclick); - else - c.onclick = this._headerOnclick; - } - else - { - c.setAttribute( "_sortType", oSortTypes[i] ); - c._sortType = "None"; - } - } - this.updateHeaderArrows(); - }; - - // remove arrows and events - SortableTable.prototype.uninitHeader = function () { - if (!this.tHead) return; - var cells = this.tHead.rows[0].cells; - var l = cells.length; - var c; - for (var i = 0; i < l; i++) { - c = cells[i]; - if (c._sortType != null && c._sortType != "None") { - c.removeChild(c.lastChild); - if (typeof c.removeEventListener != "undefined") - c.removeEventListener("click", this._headerOnclick, false); - else if (typeof c.detachEvent != "undefined") - c.detachEvent("onclick", this._headerOnclick); - c._sortType = null; - c.removeAttribute( "_sortType" ); - } - } - }; - - SortableTable.prototype.updateHeaderArrows = function () { - if (!this.tHead) return; - var cells = this.tHead.rows[0].cells; - var l = cells.length; - var img; - for (var i = 0; i < l; i++) { - if (cells[i]._sortType != null && cells[i]._sortType != "None") { - img = cells[i].lastChild; - if (i == this.sortColumn) - img.className = "sort-arrow " + (this.descending ? "descending" : "ascending"); - else - img.className = "sort-arrow"; - } - } - }; - - SortableTable.prototype.headerOnclick = function (e) { - // find TD element - var el = e.target || e.srcElement; - while (el.tagName != "TD") - el = el.parentNode; - - this.sort(SortableTable.msie ? SortableTable.getCellIndex(el) : el.cellIndex); - }; - - // IE returns wrong cellIndex when columns are hidden - SortableTable.getCellIndex = function (oTd) { - var cells = oTd.parentNode.childNodes - var l = cells.length; - var i; - for (i = 0; cells[i] != oTd && i < l; i++) - ; - return i; - }; - - SortableTable.prototype.getSortType = function (nColumn) { - return this.sortTypes[nColumn] || "String"; - }; - - // only nColumn is required - // if bDescending is left out the old value is taken into account - // if sSortType is left out the sort type is found from the sortTypes array - - SortableTable.prototype.sort = function (nColumn, bDescending, sSortType) { - if (!this.tBody) return; - if (sSortType == null) - sSortType = this.getSortType(nColumn); - - // exit if None - if (sSortType == "None") - return; - - if (bDescending == null) { - if (this.sortColumn != nColumn) - this.descending = this.defaultDescending; - else - this.descending = !this.descending; - } - else - this.descending = bDescending; - - this.sortColumn = nColumn; - - if (typeof this.onbeforesort == "function") - this.onbeforesort(); - - var f = this.getSortFunction(sSortType, nColumn); - var a = this.getCache(sSortType, nColumn); - var tBody = this.tBody; - - a.sort(f); - - if (this.descending) - a.reverse(); - - if (SortableTable.removeBeforeSort) { - // remove from doc - var nextSibling = tBody.nextSibling; - var p = tBody.parentNode; - p.removeChild(tBody); - } - - // insert in the new order - var l = a.length; - for (var i = 0; i < l; i++) - tBody.appendChild(a[i].element); - - if (SortableTable.removeBeforeSort) { - // insert into doc - p.insertBefore(tBody, nextSibling); - } - - this.updateHeaderArrows(); - - this.destroyCache(a); - - if (typeof this.onsort == "function") - this.onsort(); - }; - - SortableTable.prototype.asyncSort = function (nColumn, bDescending, sSortType) { - var oThis = this; - this._asyncsort = function () { - oThis.sort(nColumn, bDescending, sSortType); - }; - window.setTimeout(this._asyncsort, 1); - }; - - SortableTable.prototype.getCache = function (sType, nColumn) { - if (!this.tBody) return []; - var rows = this.tBody.rows; - var l = rows.length; - var a = new Array(l); - var r; - for (var i = 0; i < l; i++) { - r = rows[i]; - a[i] = { - value: this.getRowValue(r, sType, nColumn), - element: r - }; - }; - return a; - }; - - SortableTable.prototype.destroyCache = function (oArray) { - var l = oArray.length; - for (var i = 0; i < l; i++) { - oArray[i].value = null; - oArray[i].element = null; - oArray[i] = null; - } - }; - - SortableTable.prototype.getRowValue = function (oRow, sType, nColumn) { - // if we have defined a custom getRowValue use that - if (this._sortTypeInfo[sType] && this._sortTypeInfo[sType].getRowValue) - return this._sortTypeInfo[sType].getRowValue(oRow, nColumn); - - var s; - var c = oRow.cells[nColumn]; - if (typeof c.innerText != "undefined") - s = c.innerText; - else - s = SortableTable.getInnerText(c); - return this.getValueFromString(s, sType); - }; - - SortableTable.getInnerText = function (oNode) { - var s = ""; - var cs = oNode.childNodes; - var l = cs.length; - for (var i = 0; i < l; i++) { - switch (cs[i].nodeType) { - case 1: //ELEMENT_NODE - s += SortableTable.getInnerText(cs[i]); - break; - case 3: //TEXT_NODE - s += cs[i].nodeValue; - break; - } - } - return s; - }; - - SortableTable.prototype.getValueFromString = function (sText, sType) { - if (this._sortTypeInfo[sType]) - return this._sortTypeInfo[sType].getValueFromString( sText ); - return sText; - /* - switch (sType) { - case "Number": - return Number(sText); - case "CaseInsensitiveString": - return sText.toUpperCase(); - case "Date": - var parts = sText.split("-"); - var d = new Date(0); - d.setFullYear(parts[0]); - d.setDate(parts[2]); - d.setMonth(parts[1] - 1); - return d.valueOf(); - } - return sText; - */ - }; - - SortableTable.prototype.getSortFunction = function (sType, nColumn) { - if (this._sortTypeInfo[sType]) - return this._sortTypeInfo[sType].compare; - return SortableTable.basicCompare; - }; - - SortableTable.prototype.destroy = function () { - this.uninitHeader(); - var win = this.document.parentWindow; - if (win && typeof win.detachEvent != "undefined") { // only IE needs this - win.detachEvent("onunload", this._onunload); - } - this._onunload = null; - this.element = null; - this.tHead = null; - this.tBody = null; - this.document = null; - this._headerOnclick = null; - this.sortTypes = null; - this._asyncsort = null; - this.onsort = null; - }; - - // Adds a sort type to all instance of SortableTable - // sType : String - the identifier of the sort type - // fGetValueFromString : function ( s : string ) : T - A function that takes a - // string and casts it to a desired format. If left out the string is just - // returned - // fCompareFunction : function ( n1 : T, n2 : T ) : Number - A normal JS sort - // compare function. Takes two values and compares them. If left out less than, - // <, compare is used - // fGetRowValue : function( oRow : HTMLTRElement, nColumn : int ) : T - A function - // that takes the row and the column index and returns the value used to compare. - // If left out then the innerText is first taken for the cell and then the - // fGetValueFromString is used to convert that string the desired value and type - - SortableTable.prototype.addSortType = function (sType, fGetValueFromString, fCompareFunction, fGetRowValue) { - this._sortTypeInfo[sType] = { - type: sType, - getValueFromString: fGetValueFromString || SortableTable.idFunction, - compare: fCompareFunction || SortableTable.basicCompare, - getRowValue: fGetRowValue - }; - }; - - // this removes the sort type from all instances of SortableTable - SortableTable.prototype.removeSortType = function (sType) { - delete this._sortTypeInfo[sType]; - }; - - SortableTable.basicCompare = function compare(n1, n2) { - if (n1.value < n2.value) - return -1; - if (n2.value < n1.value) - return 1; - return 0; - }; - - SortableTable.idFunction = function (x) { - return x; - }; - - SortableTable.toUpperCase = function (s) { - return s.toUpperCase(); - }; - - SortableTable.toDate = function (s) { - var parts = s.split("-"); - var d = new Date(0); - d.setFullYear(parts[0]); - d.setDate(parts[2]); - d.setMonth(parts[1] - 1); - return d.valueOf(); - }; - - - // add sort types - SortableTable.prototype.addSortType("Number", Number); - SortableTable.prototype.addSortType("CaseInsensitiveString", SortableTable.toUpperCase); - SortableTable.prototype.addSortType("Date", SortableTable.toDate); - SortableTable.prototype.addSortType("String"); - // None is a special case - - - // module.exports = SortableTable; +/***/ 29: +/***/ function(module, exports, __webpack_require__) { + module.exports = "/*----------------------------------------------------------------------------\\\r\n| Sortable Table 1.12 |\r\n|-----------------------------------------------------------------------------|\r\n| Created by Erik Arvidsson |\r\n| (http://webfx.eae.net/contact.html#erik) |\r\n| For WebFX (http://webfx.eae.net/) |\r\n|-----------------------------------------------------------------------------|\r\n| A DOM 1 based script that allows an ordinary HTML table to be sortable. |\r\n|-----------------------------------------------------------------------------|\r\n| Copyright (c) 1998 - 2006 Erik Arvidsson |\r\n|-----------------------------------------------------------------------------|\r\n| Licensed under the Apache License, Version 2.0 (the \"License\"); you may not |\r\n| use this file except in compliance with the License. You may obtain a copy |\r\n| of the License at http://www.apache.org/licenses/LICENSE-2.0 |\r\n| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |\r\n| Unless required by applicable law or agreed to in writing, software |\r\n| distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT |\r\n| WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |\r\n| License for the specific language governing permissions and limitations |\r\n| under the License. |\r\n|-----------------------------------------------------------------------------|\r\n| 2003-01-10 | First version |\r\n| 2003-01-19 | Minor changes to the date parsing |\r\n| 2003-01-28 | JScript 5.0 fixes (no support for 'in' operator) |\r\n| 2003-02-01 | Sloppy typo like error fixed in getInnerText |\r\n| 2003-07-04 | Added workaround for IE cellIndex bug. |\r\n| 2003-11-09 | The bDescending argument to sort was not correctly working |\r\n| | Using onclick DOM0 event if no support for addEventListener |\r\n| | or attachEvent |\r\n| 2004-01-13 | Adding addSortType and removeSortType which makes it a lot |\r\n| | easier to add new, custom sort types. |\r\n| 2004-01-27 | Switch to use descending = false as the default sort order. |\r\n| | Change defaultDescending to suit your needs. |\r\n| 2004-03-14 | Improved sort type None look and feel a bit |\r\n| 2004-08-26 | Made the handling of tBody and tHead more flexible. Now you |\r\n| | can use another tHead or no tHead, and you can chose some |\r\n| | other tBody. |\r\n| 2006-04-25 | Changed license to Apache Software License 2.0 |\r\n|-----------------------------------------------------------------------------|\r\n| Created 2003-01-10 | All changes are in the log above. | Updated 2006-04-25 |\r\n\\----------------------------------------------------------------------------*/\r\n\r\n\r\nfunction SortableTable(oTable, oSortTypes) {\r\n\r\n\tthis.sortTypes = oSortTypes || [];\r\n\r\n\tthis.sortColumn = null;\r\n\tthis.descending = null;\r\n\r\n\tvar oThis = this;\r\n\tthis._headerOnclick = function (e) {\r\n\t\toThis.headerOnclick(e);\r\n\t};\r\n\r\n\tif (oTable) {\r\n\t\tthis.setTable( oTable );\r\n\t\tthis.document = oTable.ownerDocument || oTable.document;\r\n\t}\r\n\telse {\r\n\t\tthis.document = document;\r\n\t}\r\n\r\n\r\n\t// only IE needs this\r\n\tvar win = this.document.defaultView || this.document.parentWindow;\r\n\tthis._onunload = function () {\r\n\t\toThis.destroy();\r\n\t};\r\n\tif (win && typeof win.attachEvent != \"undefined\") {\r\n\t\twin.attachEvent(\"onunload\", this._onunload);\r\n\t}\r\n}\r\n\r\nSortableTable.gecko = navigator.product == \"Gecko\";\r\nSortableTable.msie = /msie/i.test(navigator.userAgent);\r\n// Mozilla is faster when doing the DOM manipulations on\r\n// an orphaned element. MSIE is not\r\nSortableTable.removeBeforeSort = SortableTable.gecko;\r\n\r\nSortableTable.prototype.onsort = function () {};\r\n\r\n// default sort order. true -> descending, false -> ascending\r\nSortableTable.prototype.defaultDescending = false;\r\n\r\n// shared between all instances. This is intentional to allow external files\r\n// to modify the prototype\r\nSortableTable.prototype._sortTypeInfo = {};\r\n\r\nSortableTable.prototype.setTable = function (oTable) {\r\n\tif ( this.tHead )\r\n\t\tthis.uninitHeader();\r\n\tthis.element = oTable;\r\n\tthis.setTHead( oTable.tHead );\r\n\tthis.setTBody( oTable.tBodies[0] );\r\n};\r\n\r\nSortableTable.prototype.setTHead = function (oTHead) {\r\n\tif (this.tHead && this.tHead != oTHead )\r\n\t\tthis.uninitHeader();\r\n\tthis.tHead = oTHead;\r\n\tthis.initHeader( this.sortTypes );\r\n};\r\n\r\nSortableTable.prototype.setTBody = function (oTBody) {\r\n\tthis.tBody = oTBody;\r\n};\r\n\r\nSortableTable.prototype.setSortTypes = function ( oSortTypes ) {\r\n\tif ( this.tHead )\r\n\t\tthis.uninitHeader();\r\n\tthis.sortTypes = oSortTypes || [];\r\n\tif ( this.tHead )\r\n\t\tthis.initHeader( this.sortTypes );\r\n};\r\n\r\n// adds arrow containers and events\r\n// also binds sort type to the header cells so that reordering columns does\r\n// not break the sort types\r\nSortableTable.prototype.initHeader = function (oSortTypes) {\r\n\tif (!this.tHead) return;\r\n\tvar cells = this.tHead.rows[0].cells;\r\n\tvar doc = this.tHead.ownerDocument || this.tHead.document;\r\n\tthis.sortTypes = oSortTypes || [];\r\n\tvar l = cells.length;\r\n\tvar img, c;\r\n\tfor (var i = 0; i < l; i++) {\r\n\t\tc = cells[i];\r\n\t\tif (this.sortTypes[i] != null && this.sortTypes[i] != \"None\") {\r\n\t\t\timg = doc.createElement(\"IMG\");\r\n\t\t\timg.src = \"images/blank.png\";\r\n\t\t\tc.appendChild(img);\r\n\t\t\tif (this.sortTypes[i] != null)\r\n\t\t\t\tc._sortType = this.sortTypes[i];\r\n\t\t\tif (typeof c.addEventListener != \"undefined\")\r\n\t\t\t\tc.addEventListener(\"click\", this._headerOnclick, false);\r\n\t\t\telse if (typeof c.attachEvent != \"undefined\")\r\n\t\t\t\tc.attachEvent(\"onclick\", this._headerOnclick);\r\n\t\t\telse\r\n\t\t\t\tc.onclick = this._headerOnclick;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tc.setAttribute( \"_sortType\", oSortTypes[i] );\r\n\t\t\tc._sortType = \"None\";\r\n\t\t}\r\n\t}\r\n\tthis.updateHeaderArrows();\r\n};\r\n\r\n// remove arrows and events\r\nSortableTable.prototype.uninitHeader = function () {\r\n\tif (!this.tHead) return;\r\n\tvar cells = this.tHead.rows[0].cells;\r\n\tvar l = cells.length;\r\n\tvar c;\r\n\tfor (var i = 0; i < l; i++) {\r\n\t\tc = cells[i];\r\n\t\tif (c._sortType != null && c._sortType != \"None\") {\r\n\t\t\tc.removeChild(c.lastChild);\r\n\t\t\tif (typeof c.removeEventListener != \"undefined\")\r\n\t\t\t\tc.removeEventListener(\"click\", this._headerOnclick, false);\r\n\t\t\telse if (typeof c.detachEvent != \"undefined\")\r\n\t\t\t\tc.detachEvent(\"onclick\", this._headerOnclick);\r\n\t\t\tc._sortType = null;\r\n\t\t\tc.removeAttribute( \"_sortType\" );\r\n\t\t}\r\n\t}\r\n};\r\n\r\nSortableTable.prototype.updateHeaderArrows = function () {\r\n\tif (!this.tHead) return;\r\n\tvar cells = this.tHead.rows[0].cells;\r\n\tvar l = cells.length;\r\n\tvar img;\r\n\tfor (var i = 0; i < l; i++) {\r\n\t\tif (cells[i]._sortType != null && cells[i]._sortType != \"None\") {\r\n\t\t\timg = cells[i].lastChild;\r\n\t\t\tif (i == this.sortColumn)\r\n\t\t\t\timg.className = \"sort-arrow \" + (this.descending ? \"descending\" : \"ascending\");\r\n\t\t\telse\r\n\t\t\t\timg.className = \"sort-arrow\";\r\n\t\t}\r\n\t}\r\n};\r\n\r\nSortableTable.prototype.headerOnclick = function (e) {\r\n\t// find TD element\r\n\tvar el = e.target || e.srcElement;\r\n\twhile (el.tagName != \"TD\")\r\n\t\tel = el.parentNode;\r\n\r\n\tthis.sort(SortableTable.msie ? SortableTable.getCellIndex(el) : el.cellIndex);\r\n};\r\n\r\n// IE returns wrong cellIndex when columns are hidden\r\nSortableTable.getCellIndex = function (oTd) {\r\n\tvar cells = oTd.parentNode.childNodes\r\n\tvar l = cells.length;\r\n\tvar i;\r\n\tfor (i = 0; cells[i] != oTd && i < l; i++)\r\n\t\t;\r\n\treturn i;\r\n};\r\n\r\nSortableTable.prototype.getSortType = function (nColumn) {\r\n\treturn this.sortTypes[nColumn] || \"String\";\r\n};\r\n\r\n// only nColumn is required\r\n// if bDescending is left out the old value is taken into account\r\n// if sSortType is left out the sort type is found from the sortTypes array\r\n\r\nSortableTable.prototype.sort = function (nColumn, bDescending, sSortType) {\r\n\tif (!this.tBody) return;\r\n\tif (sSortType == null)\r\n\t\tsSortType = this.getSortType(nColumn);\r\n\r\n\t// exit if None\r\n\tif (sSortType == \"None\")\r\n\t\treturn;\r\n\r\n\tif (bDescending == null) {\r\n\t\tif (this.sortColumn != nColumn)\r\n\t\t\tthis.descending = this.defaultDescending;\r\n\t\telse\r\n\t\t\tthis.descending = !this.descending;\r\n\t}\r\n\telse\r\n\t\tthis.descending = bDescending;\r\n\r\n\tthis.sortColumn = nColumn;\r\n\r\n\tif (typeof this.onbeforesort == \"function\")\r\n\t\tthis.onbeforesort();\r\n\r\n\tvar f = this.getSortFunction(sSortType, nColumn);\r\n\tvar a = this.getCache(sSortType, nColumn);\r\n\tvar tBody = this.tBody;\r\n\r\n\ta.sort(f);\r\n\r\n\tif (this.descending)\r\n\t\ta.reverse();\r\n\r\n\tif (SortableTable.removeBeforeSort) {\r\n\t\t// remove from doc\r\n\t\tvar nextSibling = tBody.nextSibling;\r\n\t\tvar p = tBody.parentNode;\r\n\t\tp.removeChild(tBody);\r\n\t}\r\n\r\n\t// insert in the new order\r\n\tvar l = a.length;\r\n\tfor (var i = 0; i < l; i++)\r\n\t\ttBody.appendChild(a[i].element);\r\n\r\n\tif (SortableTable.removeBeforeSort) {\r\n\t\t// insert into doc\r\n\t\tp.insertBefore(tBody, nextSibling);\r\n\t}\r\n\r\n\tthis.updateHeaderArrows();\r\n\r\n\tthis.destroyCache(a);\r\n\r\n\tif (typeof this.onsort == \"function\")\r\n\t\tthis.onsort();\r\n};\r\n\r\nSortableTable.prototype.asyncSort = function (nColumn, bDescending, sSortType) {\r\n\tvar oThis = this;\r\n\tthis._asyncsort = function () {\r\n\t\toThis.sort(nColumn, bDescending, sSortType);\r\n\t};\r\n\twindow.setTimeout(this._asyncsort, 1);\r\n};\r\n\r\nSortableTable.prototype.getCache = function (sType, nColumn) {\r\n\tif (!this.tBody) return [];\r\n\tvar rows = this.tBody.rows;\r\n\tvar l = rows.length;\r\n\tvar a = new Array(l);\r\n\tvar r;\r\n\tfor (var i = 0; i < l; i++) {\r\n\t\tr = rows[i];\r\n\t\ta[i] = {\r\n\t\t\tvalue:\t\tthis.getRowValue(r, sType, nColumn),\r\n\t\t\telement:\tr\r\n\t\t};\r\n\t};\r\n\treturn a;\r\n};\r\n\r\nSortableTable.prototype.destroyCache = function (oArray) {\r\n\tvar l = oArray.length;\r\n\tfor (var i = 0; i < l; i++) {\r\n\t\toArray[i].value = null;\r\n\t\toArray[i].element = null;\r\n\t\toArray[i] = null;\r\n\t}\r\n};\r\n\r\nSortableTable.prototype.getRowValue = function (oRow, sType, nColumn) {\r\n\t// if we have defined a custom getRowValue use that\r\n\tif (this._sortTypeInfo[sType] && this._sortTypeInfo[sType].getRowValue)\r\n\t\treturn this._sortTypeInfo[sType].getRowValue(oRow, nColumn);\r\n\r\n\tvar s;\r\n\tvar c = oRow.cells[nColumn];\r\n\tif (typeof c.innerText != \"undefined\")\r\n\t\ts = c.innerText;\r\n\telse\r\n\t\ts = SortableTable.getInnerText(c);\r\n\treturn this.getValueFromString(s, sType);\r\n};\r\n\r\nSortableTable.getInnerText = function (oNode) {\r\n\tvar s = \"\";\r\n\tvar cs = oNode.childNodes;\r\n\tvar l = cs.length;\r\n\tfor (var i = 0; i < l; i++) {\r\n\t\tswitch (cs[i].nodeType) {\r\n\t\t\tcase 1: //ELEMENT_NODE\r\n\t\t\t\ts += SortableTable.getInnerText(cs[i]);\r\n\t\t\t\tbreak;\r\n\t\t\tcase 3:\t//TEXT_NODE\r\n\t\t\t\ts += cs[i].nodeValue;\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\treturn s;\r\n};\r\n\r\nSortableTable.prototype.getValueFromString = function (sText, sType) {\r\n\tif (this._sortTypeInfo[sType])\r\n\t\treturn this._sortTypeInfo[sType].getValueFromString( sText );\r\n\treturn sText;\r\n\t/*\r\n\tswitch (sType) {\r\n\t\tcase \"Number\":\r\n\t\t\treturn Number(sText);\r\n\t\tcase \"CaseInsensitiveString\":\r\n\t\t\treturn sText.toUpperCase();\r\n\t\tcase \"Date\":\r\n\t\t\tvar parts = sText.split(\"-\");\r\n\t\t\tvar d = new Date(0);\r\n\t\t\td.setFullYear(parts[0]);\r\n\t\t\td.setDate(parts[2]);\r\n\t\t\td.setMonth(parts[1] - 1);\r\n\t\t\treturn d.valueOf();\r\n\t}\r\n\treturn sText;\r\n\t*/\r\n\t};\r\n\r\nSortableTable.prototype.getSortFunction = function (sType, nColumn) {\r\n\tif (this._sortTypeInfo[sType])\r\n\t\treturn this._sortTypeInfo[sType].compare;\r\n\treturn SortableTable.basicCompare;\r\n};\r\n\r\nSortableTable.prototype.destroy = function () {\r\n\tthis.uninitHeader();\r\n\tvar win = this.document.parentWindow;\r\n\tif (win && typeof win.detachEvent != \"undefined\") {\t// only IE needs this\r\n\t\twin.detachEvent(\"onunload\", this._onunload);\r\n\t}\r\n\tthis._onunload = null;\r\n\tthis.element = null;\r\n\tthis.tHead = null;\r\n\tthis.tBody = null;\r\n\tthis.document = null;\r\n\tthis._headerOnclick = null;\r\n\tthis.sortTypes = null;\r\n\tthis._asyncsort = null;\r\n\tthis.onsort = null;\r\n};\r\n\r\n// Adds a sort type to all instance of SortableTable\r\n// sType : String - the identifier of the sort type\r\n// fGetValueFromString : function ( s : string ) : T - A function that takes a\r\n// string and casts it to a desired format. If left out the string is just\r\n// returned\r\n// fCompareFunction : function ( n1 : T, n2 : T ) : Number - A normal JS sort\r\n// compare function. Takes two values and compares them. If left out less than,\r\n// <, compare is used\r\n// fGetRowValue : function( oRow : HTMLTRElement, nColumn : int ) : T - A function\r\n// that takes the row and the column index and returns the value used to compare.\r\n// If left out then the innerText is first taken for the cell and then the\r\n// fGetValueFromString is used to convert that string the desired value and type\r\n\r\nSortableTable.prototype.addSortType = function (sType, fGetValueFromString, fCompareFunction, fGetRowValue) {\r\n\tthis._sortTypeInfo[sType] = {\r\n\t\ttype:\t\t\t\tsType,\r\n\t\tgetValueFromString:\tfGetValueFromString || SortableTable.idFunction,\r\n\t\tcompare:\t\t\tfCompareFunction || SortableTable.basicCompare,\r\n\t\tgetRowValue:\t\tfGetRowValue\r\n\t};\r\n};\r\n\r\n// this removes the sort type from all instances of SortableTable\r\nSortableTable.prototype.removeSortType = function (sType) {\r\n\tdelete this._sortTypeInfo[sType];\r\n};\r\n\r\nSortableTable.basicCompare = function compare(n1, n2) {\r\n\tif (n1.value < n2.value)\r\n\t\treturn -1;\r\n\tif (n2.value < n1.value)\r\n\t\treturn 1;\r\n\treturn 0;\r\n};\r\n\r\nSortableTable.idFunction = function (x) {\r\n\treturn x;\r\n};\r\n\r\nSortableTable.toUpperCase = function (s) {\r\n\treturn s.toUpperCase();\r\n};\r\n\r\nSortableTable.toDate = function (s) {\r\n\tvar parts = s.split(\"-\");\r\n\tvar d = new Date(0);\r\n\td.setFullYear(parts[0]);\r\n\td.setDate(parts[2]);\r\n\td.setMonth(parts[1] - 1);\r\n\treturn d.valueOf();\r\n};\r\n\r\n\r\n// add sort types\r\nSortableTable.prototype.addSortType(\"Number\", Number);\r\nSortableTable.prototype.addSortType(\"CaseInsensitiveString\", SortableTable.toUpperCase);\r\nSortableTable.prototype.addSortType(\"Date\", SortableTable.toDate);\r\nSortableTable.prototype.addSortType(\"String\");\r\n// None is a special case\r\n" /***/ } diff --git a/dist/tablefilter.js b/dist/tablefilter.js index 33e6670f..ddeef009 100644 --- a/dist/tablefilter.js +++ b/dist/tablefilter.js @@ -37,7 +37,8 @@ return /******/ (function(modules) { // webpackBootstrap /******/ // "0" means "already loaded" /******/ // Array means "loading", array contains callbacks /******/ var installedChunks = { -/******/ 0:0 +/******/ 0:0, +/******/ 3:0 /******/ }; /******/ // The require function @@ -174,12 +175,6 @@ return /******/ (function(modules) { // webpackBootstrap var _ColOps = __webpack_require__(24); - // Extensions - // import './extensions/sortabletable/sortabletable'; - // import {AdapterSortableTable} - // from './extensions/sortabletable/adapterSortabletable'; - // import {ColsVisibility} from 'extensions/colsVisibility/colsVisibility'; - var global = window, isValidDate = _dateHelper.DateHelper.isValid, formatDate = _dateHelper.DateHelper.format, @@ -1617,32 +1612,6 @@ return /******/ (function(modules) { // webpackBootstrap value: function setSort() { var _this2 = this; - // require("script!../libs/sortabletable.js"); - // var SortableTable = require('sortabletable'); - // console.log(SortableTable); - // require(['sortabletable'], function(m) { - // console.log(m); - // }); - // var adapterSortabletable = new AdapterSortableTable(this); - // this.ExtRegistry.sort = adapterSortabletable; - // adapterSortabletable.init(); - // require(['sortabletable', - // './extensions/sortabletable/adapterSortabletable'], - // (s, m)=> { - // console.log(s, m); - // var adapterSortabletable = new m.AdapterSortableTable(this); - // this.ExtRegistry.sort = adapterSortabletable; - // adapterSortabletable.init(); - // }); - - // this.includeFile( - // 'sortConfig.name', - // '../libs/sortabletable.js', - // function(){ - // console.log(AdapterSortableTable); - // } - // ); - __webpack_require__.e/* require */(2, function(__webpack_require__) { var __WEBPACK_AMD_REQUIRE_ARRAY__ = [__webpack_require__(25)]; (function (m) { var adapterSortabletable = new m.AdapterSortableTable(_this2); _this2.ExtRegistry.sort = adapterSortabletable; diff --git a/example/index.html b/example/index.html index 0fc658e0..92173138 100644 --- a/example/index.html +++ b/example/index.html @@ -76,7 +76,6 @@ -