diff --git a/dist/starter.html b/dist/starter.html index f9b14a80..77fd03e1 100644 --- a/dist/starter.html +++ b/dist/starter.html @@ -1,10 +1,10 @@ - tablefilter v0.6.92 - Starter + tablefilter v0.6.93 - Starter -

tablefilter v0.6.92

+

tablefilter v0.6.93

diff --git a/dist/tablefilter/tf-0-65164f6a70f248e3da03.js b/dist/tablefilter/tf-0-65164f6a70f248e3da03.js new file mode 100644 index 00000000..bb2e1785 --- /dev/null +++ b/dist/tablefilter/tf-0-65164f6a70f248e3da03.js @@ -0,0 +1,2 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[0],{440:function(t,e,n){var r={"./array":20,"./array.js":20,"./const":4,"./const.js":4,"./cookie":60,"./cookie.js":60,"./dom":2,"./dom.js":2,"./emitter":93,"./emitter.js":93,"./event":5,"./event.js":5,"./extensions/advancedGrid/adapterEzEditTable":442,"./extensions/advancedGrid/adapterEzEditTable.js":442,"./extensions/advancedGrid/advancedGrid":447,"./extensions/advancedGrid/advancedGrid.js":447,"./extensions/colOps/colOps":446,"./extensions/colOps/colOps.js":446,"./extensions/colsVisibility/colsVisibility":445,"./extensions/colsVisibility/colsVisibility.js":445,"./extensions/filtersVisibility/filtersVisibility":444,"./extensions/filtersVisibility/filtersVisibility.js":444,"./extensions/sort/adapterSortabletable":441,"./extensions/sort/adapterSortabletable.js":441,"./extensions/sort/sort":443,"./extensions/sort/sort.js":443,"./feature":10,"./feature.js":10,"./modules/alternateRows":63,"./modules/alternateRows.js":63,"./modules/baseDropdown":59,"./modules/baseDropdown.js":59,"./modules/checkList":91,"./modules/checkList.js":91,"./modules/clearButton":64,"./modules/clearButton.js":64,"./modules/dateType":74,"./modules/dateType.js":74,"./modules/dropdown":92,"./modules/dropdown.js":92,"./modules/gridLayout":71,"./modules/gridLayout.js":71,"./modules/hash":90,"./modules/hash.js":90,"./modules/help":73,"./modules/help.js":73,"./modules/highlightKeywords":69,"./modules/highlightKeywords.js":69,"./modules/loader":70,"./modules/loader.js":70,"./modules/markActiveColumns":67,"./modules/markActiveColumns.js":67,"./modules/noResults":62,"./modules/noResults.js":62,"./modules/paging":61,"./modules/paging.js":61,"./modules/popupFilter":68,"./modules/popupFilter.js":68,"./modules/rowsCounter":66,"./modules/rowsCounter.js":66,"./modules/state":72,"./modules/state.js":72,"./modules/statusBar":65,"./modules/statusBar.js":65,"./modules/storage":89,"./modules/storage.js":89,"./modules/toolbar":18,"./modules/toolbar.js":18,"./number":22,"./number.js":22,"./root":9,"./root.js":9,"./settings":1,"./settings.js":1,"./sort":36,"./sort.js":36,"./string":8,"./string.js":8,"./tablefilter":127,"./tablefilter.js":127,"./types":3,"./types.js":3};function webpackContext(t){var e=webpackContextResolve(t);return n(e)}function webpackContextResolve(t){var e=r[t];if(e+1)return e;var n=new Error('Cannot find module "'+t+'".');throw n.code="MODULE_NOT_FOUND",n}webpackContext.keys=function webpackContextKeys(){return Object.keys(r)},webpackContext.resolve=webpackContextResolve,(t.exports=webpackContext).id=440},441:function(t,e,n){"use strict";n.r(e),n.d(e,"default",function(){return s});var r=n(10),a=n(3),c=n(2),d=n(5),o=n(22),u=n(4),i=n(1);function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function _typeof(t){return typeof t}:function _typeof(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function _defineProperties(t,e){for(var n=0;nm)if(a.rowIndex>=n[r-1])e=n[r-1];else{var h=y+f;e=r-1o[s-1]&&ao[0]&&r.setPage("previous")}};if(b.paging&&(b.feature("paging").onAfterChangePage=function(t){var e=t.tf.extension("advancedGrid")._ezEditTable.Selection,n=e.GetActiveRow();n&&n.scrollIntoView(!1);var r=e.GetActiveCell();r&&r.scrollIntoView(!1)}),"row"===e.default_selection){var s=e.on_before_selected_row;e.on_before_selected_row=function(){var t=arguments;i(t[0],t[1],t[2]),s&&s.call(null,t[0],t[1],t[2])};var a=e.on_after_selected_row;e.on_after_selected_row=function(){var t=arguments;o(t[0],t[1],t[2]),a&&a.call(null,t[0],t[1],t[2])}}else{var l=e.on_before_selected_cell;e.on_before_selected_cell=function(){var t=arguments;i(t[0],t[1],t[2]),l&&l.call(null,t[0],t[1],t[2])};var c=e.on_after_selected_cell;e.on_after_selected_cell=function(){var t=arguments;o(t[0],t[1],t[2]),c&&c.call(null,t[0],t[1],t[2])}}}if(n){var d=e.on_added_dom_row;if(e.on_added_dom_row=function(){var t=arguments;b.nbFilterableRows++,b.paging?(b.nbFilterableRows++,b.paging=!1,b.feature("paging").destroy(),b.feature("paging").reset()):b.emitter.emit("rows-changed",b,this),b.alternateRows&&b.feature("alternateRows").init(),d&&d.call(null,t[0],t[1],t[2])},e.actions&&e.actions.delete){var u=e.actions.delete.on_after_submit;e.actions.delete.on_after_submit=function(){var t=arguments;b.nbFilterableRows--,b.paging?(b.nbFilterableRows--,b.paging=!1,b.feature("paging").destroy(),b.feature("paging").reset(!1)):b.emitter.emit("rows-changed",b,this),b.alternateRows&&b.feature("alternateRows").init(),u&&u.call(null,t[0],t[1])}}}try{this._ezEditTable=new EditTable(b.id,e,t),this._ezEditTable.Init()}catch(t){throw new Error('Failed to instantiate EditTable object.\n \n"ezEditTable" dependency not found.')}this.initialized=!0}},{key:"reset",value:function reset(){var t=this._ezEditTable;t&&(this.cfg.selection&&t.Selection.Set(),this.cfg.editable&&t.Editable.Set())}},{key:"toggle",value:function toggle(){var t=this._ezEditTable;t.editable?t.Editable.Remove():t.Editable.Set(),t.selection?t.Selection.Remove():t.Selection.Set()}},{key:"_toggleForInputFilter",value:function _toggleForInputFilter(){var t=this.tf;if(t.getActiveFilterId()){var e=t.getColumnIndexFromFilterId(t.getActiveFilterId());t.getFilterType(e)===o.INPUT&&this.toggle()}}},{key:"destroy",value:function destroy(){var t=this;if(this.initialized){var e=this._ezEditTable;e&&(this.cfg.selection&&(e.Selection.ClearSelections(),e.Selection.Remove()),this.cfg.editable&&e.Editable.Remove()),this.emitter.off(["filter-focus","filter-blur"],function(){return t._toggleForInputFilter()}),this.initialized=!1}}}]),AdapterEzEditTable}();a.meta={altName:"advancedGrid"}},443:function(t,e,n){"use strict";n.r(e);var r=n(441);n(9).root.SortableTable||n(450),e.default=r.default},444:function(t,e,n){"use strict";n.r(e),n.d(e,"default",function(){return c});var r=n(10),s=n(2),o=n(3),a=n(5),i=n(1),l=n(18);function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function _typeof(t){return typeof t}:function _typeof(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function _defineProperties(t,e){for(var n=0;n',n.icnCollapseHtml='Collapse filters',n.defaultText="Toggle filters",n.targetId=e.target_id||null,n.enableIcon=Object(i.defaultsBool)(e.enable_icon,!0),n.btnText=Object(i.defaultsStr)(e.btn_text,""),n.collapseBtnHtml=n.enableIcon?n.icnCollapseHtml+n.btnText:n.btnText||n.defaultText,n.expandBtnHtml=n.enableIcon?n.icnExpandHtml+n.btnText:n.btnText||n.defaultText,n.btnHtml=Object(i.defaultsStr)(e.btn_html,null),n.btnCssClass=Object(i.defaultsStr)(e.btn_css_class,"btnExpClpFlt"),n.contCssClass=Object(i.defaultsStr)(e.cont_css_class,"expClpFlt"),n.filtersRowIndex=Object(i.defaultsNb)(e.filters_row_index,t.getFiltersRowIndex()),n.visibleAtStart=Object(i.defaultsNb)(e.visible_at_start,!0),n.toolbarPosition=Object(i.defaultsStr)(e.toolbar_position,l.RIGHT),n.onBeforeShow=Object(i.defaultsFn)(e.on_before_show,o.EMPTY_FN),n.onAfterShow=Object(i.defaultsFn)(e.on_after_show,o.EMPTY_FN),n.onBeforeHide=Object(i.defaultsFn)(e.on_before_hide,o.EMPTY_FN),n.onAfterHide=Object(i.defaultsFn)(e.on_after_hide,o.EMPTY_FN),t.import(e.name+"Style",t.getStylePath()+n.stylesheet,null,"link"),n.enable(),n}return function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&_setPrototypeOf(t,e)}(FiltersVisibility,r["Feature"]),function _createClass(t,e,n){return e&&_defineProperties(t.prototype,e),n&&_defineProperties(t,n),t}(FiltersVisibility,[{key:"init",value:function init(){var n=this;this.initialized||(this.emitter.emit("initializing-extension",this,!Object(o.isNull)(this.targetId)),this.buildUI(),this.initialized=!0,this.emitter.on(["show-filters"],function(t,e){return n.show(e)}),this.emitter.emit("filters-visibility-initialized",this.tf,this),this.emitter.emit("extension-initialized",this))}},{key:"buildUI",value:function buildUI(){var t=this,e=this.tf,n=Object(s.createElm)("span");n.className=this.contCssClass;var r,o=this.targetId?Object(s.elm)(this.targetId):e.feature("toolbar").container(this.toolbarPosition);if(this.targetId)o.appendChild(n);else{var i=o.firstChild;i.parentNode.insertBefore(n,i)}this.btnHtml?(n.innerHTML=this.btnHtml,r=n.firstChild):((r=Object(s.createElm)("a",["href","javascript:void(0);"])).className=this.btnCssClass,r.title=this.btnText||this.defaultText,r.innerHTML=this.collapseBtnHtml,n.appendChild(r)),Object(a.addEvt)(r,"click",function(){return t.toggle()}),this.contEl=n,this.btnEl=r,this.visibleAtStart||this.toggle()}},{key:"toggle",value:function toggle(){var t=this.tf,e=""===(t.gridLayout?t.feature("gridLayout").headTbl:t.dom()).rows[this.filtersRowIndex].style.display;this.show(!e)}},{key:"show",value:function show(){var t=!(0 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'},449:function(t,e){t.exports=function(t){function log(t){"undefined"!=typeof console&&(console.error||console.log)("[Script Loader]",t)}try{"undefined"!=typeof execScript&&function isIE(){return"undefined"!=typeof attachEvent&&"undefined"==typeof addEventListener}()?execScript(t):"undefined"!=typeof eval?eval.call(null,t):log("EvalError: No eval function available")}catch(t){log(t)}}},450:function(t,e,n){n(449)(n(448))},451:function(t,e){function formatter(o){if((o=o||{}).negativeType=o.negativeType||("R"===o.negative?"right":"left"),"string"!=typeof o.negativeLeftSymbol)switch(o.negativeType){case"left":o.negativeLeftSymbol="-";break;case"brackets":o.negativeLeftSymbol="(";break;default:o.negativeLeftSymbol=""}if("string"!=typeof o.negativeRightSymbol)switch(o.negativeType){case"right":o.negativeRightSymbol="-";break;case"brackets":o.negativeRightSymbol=")";break;default:o.negativeRightSymbol=""}function format(t,e){if(e=e||{},!t&&0!==t)return"";var n=[],r="-"===(t=""+t).charAt(0);return t=t.replace(/^\-/g,""),o.negativeLeftOut||e.noUnits||n.push(o.prefix),r&&n.push(o.negativeLeftSymbol),o.negativeLeftOut&&!e.noUnits&&n.push(o.prefix),t=t.split("."),null!=o.round&&function round(t,e){if(t[1]&&0<=e&&t[1].length>e){var n=t[1].slice(0,e);if(5<=+t[1].substr(e,1)){for(var r="";"0"===n.charAt(0);)r+="0",n=n.substr(1);(n=r+(n=+n+1+"")).length>e&&(t[0]=+t[0]+ +n.charAt(0)+"",n=n.substring(1))}t[1]=n}return t}(t,o.round),null!=o.truncate&&(t[1]=function truncate(t,e){t&&(t+="");return t&&t.length>e?t.substr(0,e):t}(t[1],o.truncate)),0 0) {\r\n let triggers = adpt.triggerIds;\r\n cells = [];\r\n l = triggers.length;\r\n for (let j = 0; j < l; j++) {\r\n cells.push(elm(triggers[j]));\r\n }\r\n } else {\r\n if (!this.tHead) {\r\n return;\r\n }\r\n cells = stt.tHead.rows[stt.headersRow].cells;\r\n l = cells.length;\r\n }\r\n for (let i = 0; i < l; i++) {\r\n let cell = cells[i];\r\n if (!cell) {\r\n continue;\r\n }\r\n let cellAttr = cell.getAttribute('_sortType');\r\n if (cellAttr !== null && cellAttr !== 'None') {\r\n img = cell.lastChild || cell;\r\n if (img.nodeName.toLowerCase() !== 'img') {\r\n img = createElm('img',\r\n ['src', adpt.imgPath + adpt.imgBlank]);\r\n cell.appendChild(img);\r\n }\r\n if (i === stt.sortColumn) {\r\n img.className = adpt.imgClassName + ' ' +\r\n (this.descending ?\r\n adpt.imgDescClassName :\r\n adpt.imgAscClassName);\r\n } else {\r\n img.className = adpt.imgClassName;\r\n }\r\n }\r\n }\r\n };\r\n\r\n /**\r\n * Overrides getRowValue for custom key value feature\r\n * @param {Object} oRow Row element\r\n * @param {String} sType\r\n * @param {Number} nColumn\r\n * @return {String}\r\n */\r\n SortableTable.prototype.getRowValue = function (oRow, sType, nColumn) {\r\n let stt = this;\r\n // if we have defined a custom getRowValue use that\r\n let sortTypeInfo = stt._sortTypeInfo[sType];\r\n if (sortTypeInfo && sortTypeInfo.getRowValue) {\r\n return sortTypeInfo.getRowValue(oRow, nColumn);\r\n }\r\n let c = oRow.cells[nColumn];\r\n let s = SortableTable.getInnerText(c);\r\n return stt.getValueFromString(s, sType);\r\n };\r\n\r\n /**\r\n * Overrides getInnerText in order to avoid Firefox unexpected sorting\r\n * behaviour with untrimmed text elements\r\n * @param {Object} cell DOM element\r\n * @return {String} DOM element inner text\r\n */\r\n SortableTable.getInnerText = function (cell) {\r\n if (!cell) {\r\n return;\r\n }\r\n if (cell.getAttribute(adpt.customKey)) {\r\n return cell.getAttribute(adpt.customKey);\r\n } else {\r\n return tf.getCellValue(cell);\r\n }\r\n };\r\n }\r\n\r\n /**\r\n * Adds a sort type\r\n */\r\n addSortType(...args) {\r\n // Extract the arguments\r\n let [id, caster, sorter, getRowValue] = args;\r\n SortableTable.prototype.addSortType(id, caster, sorter, getRowValue);\r\n }\r\n\r\n /**\r\n * Sets the sort types on a column basis\r\n * @private\r\n */\r\n setSortTypes() {\r\n let tf = this.tf,\r\n sortTypes = this.sortTypes,\r\n _sortTypes = [];\r\n\r\n tf.eachCol((i) => {\r\n let colType;\r\n if (sortTypes[i]) {\r\n colType = sortTypes[i];\r\n if (isObj(colType)) {\r\n if (colType.type === DATE) {\r\n colType = this._addDateType(i, sortTypes);\r\n }\r\n else if (colType.type === FORMATTED_NUMBER) {\r\n let decimal = colType.decimal || tf.decimalSeparator;\r\n colType = this._addNumberType(i, decimal);\r\n }\r\n } else {\r\n colType = colType.toLowerCase();\r\n if (colType === DATE) {\r\n colType = this._addDateType(i, sortTypes);\r\n }\r\n else if (colType === FORMATTED_NUMBER ||\r\n colType === NUMBER) {\r\n colType = this._addNumberType(i, tf.decimalSeparator);\r\n }\r\n else if (colType === NONE) {\r\n // TODO: normalise 'none' vs 'None'\r\n colType = 'None';\r\n }\r\n }\r\n } else {\r\n colType = STRING;\r\n }\r\n _sortTypes.push(colType);\r\n });\r\n\r\n //Public TF method to add sort type\r\n\r\n //Custom sort types\r\n this.addSortType('caseinsensitivestring', SortableTable.toUpperCase);\r\n this.addSortType(STRING);\r\n this.addSortType(IP_ADDRESS, ipAddress, sortIP);\r\n\r\n this.stt = new SortableTable(tf.dom(), _sortTypes);\r\n\r\n /*** external table headers adapter ***/\r\n if (this.asyncSort && this.triggerIds.length > 0) {\r\n let triggers = this.triggerIds;\r\n for (let j = 0; j < triggers.length; j++) {\r\n if (triggers[j] === null) {\r\n continue;\r\n }\r\n let trigger = elm(triggers[j]);\r\n if (trigger) {\r\n trigger.style.cursor = 'pointer';\r\n\r\n addEvt(trigger, 'click', (evt) => {\r\n let elm = evt.target;\r\n if (!this.tf.sort) {\r\n return;\r\n }\r\n this.stt.asyncSort(triggers.indexOf(elm.id));\r\n });\r\n trigger.setAttribute('_sortType', _sortTypes[j]);\r\n }\r\n }\r\n }\r\n }\r\n\r\n _addDateType(colIndex, types) {\r\n let tf = this.tf;\r\n let dateType = tf.feature('dateType');\r\n let locale = dateType.getOptions(colIndex, types).locale || tf.locale;\r\n let colType = `${DATE}-${locale}`;\r\n\r\n this.addSortType(colType, (value) => {\r\n let parsedDate = dateType.parse(value, locale);\r\n // Invalid date defaults to Wed Feb 04 -768 11:00:00\r\n return isNaN(+parsedDate) ? new Date(-86400000000000) : parsedDate;\r\n });\r\n return colType;\r\n }\r\n\r\n _addNumberType(colIndex, decimal) {\r\n let colType = `${FORMATTED_NUMBER}${decimal === '.' ? '' : '-custom'}`;\r\n\r\n this.addSortType(colType, (value) => {\r\n return parseNb(value, decimal);\r\n });\r\n return colType;\r\n }\r\n\r\n /**\r\n * Remove extension\r\n */\r\n destroy() {\r\n if (!this.initialized) {\r\n return;\r\n }\r\n let tf = this.tf;\r\n this.emitter.off(['sort'], bound(this.sortByColumnIndexHandler, this));\r\n this.sorted = false;\r\n this.stt.destroy();\r\n\r\n let ids = tf.getFiltersId();\r\n for (let idx = 0; idx < ids.length; idx++) {\r\n let header = tf.getHeaderElement(idx);\r\n let img = tag(header, 'img');\r\n\r\n if (img.length === 1) {\r\n header.removeChild(img[0]);\r\n }\r\n }\r\n this.initialized = false;\r\n }\r\n\r\n}\r\n\r\nAdapterSortableTable.meta = {altName: 'sort'};\r\n\r\n//Converters\r\nfunction ipAddress(value) {\r\n let vals = value.split('.');\r\n for (let x in vals) {\r\n let val = vals[x];\r\n while (3 > val.length) {\r\n val = '0' + val;\r\n }\r\n vals[x] = val;\r\n }\r\n return vals.join('.');\r\n}\r\n\r\nfunction sortIP(a, b) {\r\n let aa = ipAddress(a.value.toLowerCase());\r\n let bb = ipAddress(b.value.toLowerCase());\r\n if (aa === bb) {\r\n return 0;\r\n } else if (aa < bb) {\r\n return -1;\r\n } else {\r\n return 1;\r\n }\r\n}\r\n","import {Feature} from '../../feature';\r\nimport {tag} from '../../dom';\r\nimport {INPUT} from '../../const';\r\nimport {defaultsStr} from '../../settings';\r\nimport {root} from '../../root';\r\n\r\nconst INSTANTIATION_ERROR = `Failed to instantiate EditTable object.\r\n \\n\"ezEditTable\" dependency not found.`;\r\n\r\n/**\r\n * Adapter module for ezEditTable, an external library providing advanced\r\n * grid features (selection and edition):\r\n * http://codecanyon.net/item/ezedittable-enhance-html-tables/2425123?ref=koalyptus\r\n */\r\nexport default class AdapterEzEditTable extends Feature {\r\n\r\n /**\r\n * Creates an instance of AdapterEzEditTable\r\n *\r\n * @param {TableFilter} tf TableFilter instance\r\n * @param {Object} cfg Configuration options for ezEditTable library\r\n */\r\n constructor(tf, cfg) {\r\n super(tf, AdapterEzEditTable);\r\n\r\n /**\r\n * Module description\r\n * @type {String}\r\n */\r\n this.desc = defaultsStr(cfg.description, 'ezEditTable adapter');\r\n\r\n /**\r\n * Filename of ezEditTable library\r\n * @type {String}\r\n */\r\n this.filename = defaultsStr(cfg.filename, 'ezEditTable.js');\r\n\r\n /**\r\n * Path to ezEditTable library\r\n * @type {String}\r\n */\r\n this.vendorPath = cfg.vendor_path;\r\n\r\n /**\r\n * Load ezEditTable stylesheet\r\n * @type {Boolean}\r\n */\r\n this.loadStylesheet = Boolean(cfg.load_stylesheet);\r\n\r\n /**\r\n * Path to ezEditTable stylesheet\r\n * @type {String}\r\n */\r\n this.stylesheet = defaultsStr(cfg.stylesheet,\r\n this.vendorPath + 'ezEditTable.css');\r\n\r\n /**\r\n * Name of ezEditTable stylesheet\r\n * @type {String}\r\n */\r\n this.stylesheetName = defaultsStr(cfg.stylesheet_name,\r\n 'ezEditTableCss');\r\n\r\n // Enable the ezEditTable's scroll into view behaviour if grid layout on\r\n cfg.scroll_into_view = cfg.scroll_into_view === false ?\r\n false : tf.gridLayout;\r\n\r\n /**\r\n * ezEditTable instance\r\n * @type {EditTable}\r\n * @private\r\n */\r\n this._ezEditTable = null;\r\n\r\n /**\r\n * ezEditTable configuration\r\n * @private\r\n */\r\n this.cfg = cfg;\r\n\r\n this.enable();\r\n }\r\n\r\n /**\r\n * Conditionally load ezEditTable library and set advanced grid\r\n */\r\n init() {\r\n if (this.initialized) {\r\n return;\r\n }\r\n let tf = this.tf;\r\n if (root.EditTable) {\r\n this._setAdvancedGrid();\r\n } else {\r\n let path = this.vendorPath + this.filename;\r\n tf.import(this.filename, path, () => this._setAdvancedGrid());\r\n }\r\n if (this.loadStylesheet && !tf.isImported(this.stylesheet, 'link')) {\r\n tf.import(this.stylesheetName, this.stylesheet, null, 'link');\r\n }\r\n\r\n // TODO: hack to prevent ezEditTable enter key event hijaking.\r\n // Needs to be fixed in the vendor's library\r\n this.emitter.on(['filter-focus', 'filter-blur'],\r\n () => this._toggleForInputFilter());\r\n\r\n /**\r\n * @inherited\r\n */\r\n this.initialized = true;\r\n }\r\n\r\n /**\r\n * Instantiate ezEditTable component for advanced grid features\r\n * @private\r\n */\r\n _setAdvancedGrid() {\r\n let tf = this.tf;\r\n\r\n //start row for EditTable constructor needs to be calculated\r\n let startRow,\r\n cfg = this.cfg,\r\n thead = tag(tf.dom(), 'thead');\r\n\r\n //if thead exists and startRow not specified, startRow is calculated\r\n //automatically by EditTable\r\n if (thead.length > 0 && !cfg.startRow) {\r\n startRow = undefined;\r\n }\r\n //otherwise startRow config property if any or TableFilter refRow\r\n else {\r\n startRow = cfg.startRow || tf.refRow;\r\n }\r\n\r\n cfg.base_path = cfg.base_path || tf.basePath + 'ezEditTable/';\r\n let editable = cfg.editable;\r\n let selectable = cfg.selection;\r\n\r\n if (selectable) {\r\n cfg.default_selection = cfg.default_selection || 'row';\r\n }\r\n //CSS Styles\r\n cfg.active_cell_css = cfg.active_cell_css || 'ezETSelectedCell';\r\n\r\n let _lastValidRowIndex = 0;\r\n let _lastRowIndex = 0;\r\n\r\n if (selectable) {\r\n //Row navigation needs to be calculated according to TableFilter's\r\n //validRowsIndex array\r\n let onAfterSelection = function (et, selectedElm, e) {\r\n let slc = et.Selection;\r\n //Next valid filtered row needs to be selected\r\n let doSelect = function (nextRowIndex) {\r\n if (et.defaultSelection === 'row') {\r\n /* eslint-disable */\r\n slc.SelectRowByIndex(nextRowIndex);\r\n /* eslint-enable */\r\n } else {\r\n /* eslint-disable */\r\n et.ClearSelections();\r\n /* eslint-enable */\r\n let cellIndex = selectedElm.cellIndex,\r\n row = tf.dom().rows[nextRowIndex];\r\n if (et.defaultSelection === 'both') {\r\n /* eslint-disable */\r\n slc.SelectRowByIndex(nextRowIndex);\r\n /* eslint-enable */\r\n }\r\n if (row) {\r\n /* eslint-disable */\r\n slc.SelectCell(row.cells[cellIndex]);\r\n /* eslint-enable */\r\n }\r\n }\r\n //Table is filtered\r\n if (tf.validRowsIndex.length !== tf.getRowsNb()) {\r\n let r = tf.dom().rows[nextRowIndex];\r\n if (r) {\r\n r.scrollIntoView(false);\r\n }\r\n if (cell) {\r\n if (cell.cellIndex === (tf.getCellsNb() - 1) &&\r\n tf.gridLayout) {\r\n tf.tblCont.scrollLeft = 100000000;\r\n }\r\n else if (cell.cellIndex === 0 && tf.gridLayout) {\r\n tf.tblCont.scrollLeft = 0;\r\n } else {\r\n cell.scrollIntoView(false);\r\n }\r\n }\r\n }\r\n };\r\n\r\n //table is not filtered\r\n if (!tf.validRowsIndex) {\r\n return;\r\n }\r\n let validIndexes = tf.validRowsIndex,\r\n validIdxLen = validIndexes.length,\r\n row = et.defaultSelection !== 'row' ?\r\n selectedElm.parentNode : selectedElm,\r\n //cell for default_selection = 'both' or 'cell'\r\n cell = selectedElm.nodeName === 'TD' ? selectedElm : null,\r\n /* eslint-disable */\r\n keyCode = e !== undefined ? et.Event.GetKey(e) : 0,\r\n /* eslint-enable */\r\n isRowValid = validIndexes.indexOf(row.rowIndex) !== -1,\r\n nextRowIndex,\r\n paging = tf.feature('paging'),\r\n //pgup/pgdown keys\r\n d = keyCode === 34 || keyCode === 33 ?\r\n (paging && paging.pageLength || et.nbRowsPerPage) :\r\n 1;\r\n\r\n //If next row is not valid, next valid filtered row needs to be\r\n //calculated\r\n if (!isRowValid) {\r\n //Selection direction up/down\r\n if (row.rowIndex > _lastRowIndex) {\r\n //last row\r\n if (row.rowIndex >= validIndexes[validIdxLen - 1]) {\r\n nextRowIndex = validIndexes[validIdxLen - 1];\r\n } else {\r\n let calcRowIndex = (_lastValidRowIndex + d);\r\n if (calcRowIndex > (validIdxLen - 1)) {\r\n nextRowIndex = validIndexes[validIdxLen - 1];\r\n } else {\r\n nextRowIndex = validIndexes[calcRowIndex];\r\n }\r\n }\r\n } else {\r\n //first row\r\n if (row.rowIndex <= validIndexes[0]) {\r\n nextRowIndex = validIndexes[0];\r\n } else {\r\n let v = validIndexes[_lastValidRowIndex - d];\r\n nextRowIndex = v ? v : validIndexes[0];\r\n }\r\n }\r\n _lastRowIndex = row.rowIndex;\r\n doSelect(nextRowIndex);\r\n } else {\r\n //If filtered row is valid, special calculation for\r\n //pgup/pgdown keys\r\n if (keyCode !== 34 && keyCode !== 33) {\r\n _lastValidRowIndex = validIndexes.indexOf(row.rowIndex);\r\n _lastRowIndex = row.rowIndex;\r\n } else {\r\n if (keyCode === 34) { //pgdown\r\n //last row\r\n if ((_lastValidRowIndex + d) <= (validIdxLen - 1)) {\r\n nextRowIndex = validIndexes[\r\n _lastValidRowIndex + d];\r\n } else {\r\n nextRowIndex = [validIdxLen - 1];\r\n }\r\n } else { //pgup\r\n //first row\r\n if ((_lastValidRowIndex - d) <= validIndexes[0]) {\r\n nextRowIndex = validIndexes[0];\r\n } else {\r\n nextRowIndex = validIndexes[\r\n _lastValidRowIndex - d];\r\n }\r\n }\r\n _lastRowIndex = nextRowIndex;\r\n _lastValidRowIndex = validIndexes.indexOf(nextRowIndex);\r\n doSelect(nextRowIndex);\r\n }\r\n }\r\n };\r\n\r\n //Page navigation has to be enforced whenever selected row is out of\r\n //the current page range\r\n let onBeforeSelection = function (et, selectedElm) {\r\n let row = et.defaultSelection !== 'row' ?\r\n selectedElm.parentNode : selectedElm;\r\n if (tf.paging) {\r\n if (tf.feature('paging').nbPages > 1) {\r\n let paging = tf.feature('paging');\r\n //page length is re-assigned in case it has changed\r\n et.nbRowsPerPage = paging.pageLength;\r\n let validIndexes = tf.validRowsIndex,\r\n validIdxLen = validIndexes.length,\r\n pagingEndRow = parseInt(paging.startPagingRow, 10) +\r\n parseInt(paging.pageLength, 10);\r\n let rowIndex = row.rowIndex;\r\n\r\n if ((rowIndex === validIndexes[validIdxLen - 1]) &&\r\n paging.currentPageNb !== paging.nbPages) {\r\n paging.setPage('last');\r\n }\r\n else if ((rowIndex === validIndexes[0]) &&\r\n paging.currentPageNb !== 1) {\r\n paging.setPage('first');\r\n }\r\n else if (rowIndex > validIndexes[pagingEndRow - 1] &&\r\n rowIndex < validIndexes[validIdxLen - 1]) {\r\n paging.setPage('next');\r\n }\r\n else if (\r\n rowIndex < validIndexes[paging.startPagingRow] &&\r\n rowIndex > validIndexes[0]) {\r\n paging.setPage('previous');\r\n }\r\n }\r\n }\r\n };\r\n\r\n //Selected row needs to be visible when paging is activated\r\n if (tf.paging) {\r\n tf.feature('paging').onAfterChangePage = function (paging) {\r\n let advGrid = paging.tf.extension('advancedGrid');\r\n let et = advGrid._ezEditTable;\r\n let slc = et.Selection;\r\n /* eslint-disable */\r\n let row = slc.GetActiveRow();\r\n /* eslint-enable */\r\n if (row) {\r\n row.scrollIntoView(false);\r\n }\r\n /* eslint-disable */\r\n let cell = slc.GetActiveCell();\r\n /* eslint-enable */\r\n if (cell) {\r\n cell.scrollIntoView(false);\r\n }\r\n };\r\n }\r\n\r\n //Rows navigation when rows are filtered is performed with the\r\n //EditTable row selection callback events\r\n if (cfg.default_selection === 'row') {\r\n let fnB = cfg.on_before_selected_row;\r\n cfg.on_before_selected_row = function () {\r\n var args = arguments;\r\n onBeforeSelection(args[0], args[1], args[2]);\r\n if (fnB) {\r\n fnB.call(null, args[0], args[1], args[2]);\r\n }\r\n };\r\n let fnA = cfg.on_after_selected_row;\r\n cfg.on_after_selected_row = function () {\r\n var args = arguments;\r\n onAfterSelection(args[0], args[1], args[2]);\r\n if (fnA) {\r\n fnA.call(null, args[0], args[1], args[2]);\r\n }\r\n };\r\n } else {\r\n let fnD = cfg.on_before_selected_cell;\r\n cfg.on_before_selected_cell = function () {\r\n var args = arguments;\r\n onBeforeSelection(args[0], args[1], args[2]);\r\n if (fnD) {\r\n fnD.call(null, args[0], args[1], args[2]);\r\n }\r\n };\r\n let fnC = cfg.on_after_selected_cell;\r\n cfg.on_after_selected_cell = function () {\r\n var args = arguments;\r\n onAfterSelection(args[0], args[1], args[2]);\r\n if (fnC) {\r\n fnC.call(null, args[0], args[1], args[2]);\r\n }\r\n };\r\n }\r\n }\r\n if (editable) {\r\n //Added or removed rows, TF rows number needs to be re-calculated\r\n let fnE = cfg.on_added_dom_row;\r\n cfg.on_added_dom_row = function () {\r\n var args = arguments;\r\n tf.nbFilterableRows++;\r\n if (!tf.paging) {\r\n tf.emitter.emit('rows-changed', tf, this);\r\n } else {\r\n tf.nbFilterableRows++;\r\n tf.paging = false;\r\n tf.feature('paging').destroy();\r\n tf.feature('paging').reset();\r\n }\r\n if (tf.alternateRows) {\r\n tf.feature('alternateRows').init();\r\n }\r\n if (fnE) {\r\n fnE.call(null, args[0], args[1], args[2]);\r\n }\r\n };\r\n if (cfg.actions && cfg.actions['delete']) {\r\n let fnF = cfg.actions['delete'].on_after_submit;\r\n cfg.actions['delete'].on_after_submit = function () {\r\n var args = arguments;\r\n tf.nbFilterableRows--;\r\n if (!tf.paging) {\r\n tf.emitter.emit('rows-changed', tf, this);\r\n } else {\r\n tf.nbFilterableRows--;\r\n tf.paging = false;\r\n tf.feature('paging').destroy();\r\n tf.feature('paging').reset(false);\r\n }\r\n if (tf.alternateRows) {\r\n tf.feature('alternateRows').init();\r\n }\r\n if (fnF) {\r\n fnF.call(null, args[0], args[1]);\r\n }\r\n };\r\n }\r\n }\r\n\r\n try {\r\n /* eslint-disable */\r\n this._ezEditTable = new EditTable(tf.id, cfg, startRow);\r\n this._ezEditTable.Init();\r\n /* eslint-enable */\r\n } catch (e) { throw new Error(INSTANTIATION_ERROR); }\r\n\r\n this.initialized = true;\r\n }\r\n\r\n /**\r\n * Reset advanced grid when previously removed\r\n */\r\n reset() {\r\n let ezEditTable = this._ezEditTable;\r\n if (ezEditTable) {\r\n if (this.cfg.selection) {\r\n /* eslint-disable */\r\n ezEditTable.Selection.Set();\r\n /* eslint-enable */\r\n }\r\n if (this.cfg.editable) {\r\n /* eslint-disable */\r\n ezEditTable.Editable.Set();\r\n /* eslint-enable */\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Toggle behaviour\r\n */\r\n toggle() {\r\n let ezEditTable = this._ezEditTable;\r\n if (ezEditTable.editable) {\r\n /* eslint-disable */\r\n ezEditTable.Editable.Remove();\r\n /* eslint-enable */\r\n } else {\r\n /* eslint-disable */\r\n ezEditTable.Editable.Set();\r\n /* eslint-enable */\r\n }\r\n if (ezEditTable.selection) {\r\n /* eslint-disable */\r\n ezEditTable.Selection.Remove();\r\n /* eslint-enable */\r\n } else {\r\n /* eslint-disable */\r\n ezEditTable.Selection.Set();\r\n /* eslint-enable */\r\n }\r\n }\r\n\r\n _toggleForInputFilter() {\r\n let tf = this.tf;\r\n if (!tf.getActiveFilterId()) {\r\n return;\r\n }\r\n let colIndex = tf.getColumnIndexFromFilterId(tf.getActiveFilterId());\r\n let filterType = tf.getFilterType(colIndex);\r\n if (filterType === INPUT) {\r\n this.toggle();\r\n }\r\n }\r\n\r\n /**\r\n * Remove advanced grid\r\n */\r\n destroy() {\r\n if (!this.initialized) {\r\n return;\r\n }\r\n let ezEditTable = this._ezEditTable;\r\n if (ezEditTable) {\r\n if (this.cfg.selection) {\r\n /* eslint-disable */\r\n ezEditTable.Selection.ClearSelections();\r\n ezEditTable.Selection.Remove();\r\n /* eslint-enable */\r\n }\r\n if (this.cfg.editable) {\r\n /* eslint-disable */\r\n ezEditTable.Editable.Remove();\r\n /* eslint-enable */\r\n }\r\n }\r\n\r\n this.emitter.off(['filter-focus', 'filter-blur'],\r\n () => this._toggleForInputFilter());\r\n this.initialized = false;\r\n }\r\n}\r\n\r\nAdapterEzEditTable.meta = {altName: 'advancedGrid'};\r\n","import AdapterSortableTable from './adapterSortabletable';\r\nimport {root} from '../../root';\r\n\r\nif (!root.SortableTable) {\r\n require('script-loader!sortabletable');\r\n}\r\n\r\nexport default AdapterSortableTable;\r\n","import {Feature} from '../../feature';\r\nimport {createElm, removeElm, elm} from '../../dom';\r\nimport {EMPTY_FN, isNull} from '../../types';\r\nimport {addEvt} from '../../event';\r\nimport {\r\n defaultsBool, defaultsStr, defaultsFn, defaultsNb,\r\n} from '../../settings';\r\nimport {RIGHT} from '../../modules/toolbar';\r\n\r\n/**\r\n * Filters Visibility extension\r\n */\r\nexport default class FiltersVisibility extends Feature {\r\n\r\n /**\r\n * Creates an instance of FiltersVisibility\r\n * @param {TableFilter} tf TableFilter instance\r\n * @param {Object} Configuration object\r\n */\r\n constructor(tf, f) {\r\n super(tf, FiltersVisibility);\r\n\r\n /**\r\n * Module name\r\n * @type {String}\r\n */\r\n this.name = f.name;\r\n\r\n /**\r\n * Module description\r\n * @type {String}\r\n */\r\n this.desc = defaultsStr(f.description,\r\n 'Filters row visibility manager');\r\n\r\n /**\r\n * Extension's stylesheet filename\r\n * @type {String}\r\n */\r\n this.stylesheet = defaultsStr(f.stylesheet , 'filtersVisibility.css');\r\n\r\n /**\r\n * Expand icon filename\r\n * @type {String}\r\n */\r\n this.icnExpand = defaultsStr(f.expand_icon_name, 'icn_exp.png');\r\n\r\n /**\r\n * Collapse icon filename\r\n * @type {String}\r\n */\r\n this.icnCollapse = defaultsStr(f.collapse_icon_name, 'icn_clp.png');\r\n\r\n /**\r\n * Main container element\r\n * @private\r\n */\r\n this.contEl = null;\r\n\r\n /**\r\n * Button element\r\n * @private\r\n */\r\n this.btnEl = null;\r\n\r\n /**\r\n * Expand icon HTML\r\n * @private\r\n */\r\n this.icnExpandHtml = '\"Expand';\r\n\r\n /**\r\n * Collapse icon HTML\r\n * @private\r\n */\r\n this.icnCollapseHtml = '\"Collapse';\r\n\r\n /**\r\n * Default text\r\n * @private\r\n */\r\n this.defaultText = 'Toggle filters';\r\n\r\n /**\r\n * ID of main container element\r\n * @type {String}\r\n */\r\n this.targetId = f.target_id || null;\r\n\r\n /**\r\n * Enable expand/collapse icon, defaults to true\r\n * @type {Boolean}\r\n */\r\n this.enableIcon = defaultsBool(f.enable_icon, true);\r\n\r\n /**\r\n * Custom text for button\r\n * @type {String}\r\n */\r\n this.btnText = defaultsStr(f.btn_text, '');\r\n\r\n /**\r\n * Collapse button HTML\r\n * @private\r\n */\r\n this.collapseBtnHtml = this.enableIcon ?\r\n this.icnCollapseHtml + this.btnText :\r\n this.btnText || this.defaultText;\r\n\r\n /**\r\n * Expand button HTML\r\n * @private\r\n */\r\n this.expandBtnHtml = this.enableIcon ?\r\n this.icnExpandHtml + this.btnText :\r\n this.btnText || this.defaultText;\r\n\r\n /**\r\n * Button's custom HTML\r\n * @type {String}\r\n */\r\n this.btnHtml = defaultsStr(f.btn_html, null);\r\n\r\n /**\r\n * Css class for expand/collapse filters button\r\n * @type {String}\r\n */\r\n this.btnCssClass = defaultsStr(f.btn_css_class, 'btnExpClpFlt');\r\n\r\n /**\r\n * Css class for main container\r\n * @type {String}\r\n */\r\n this.contCssClass = defaultsStr(f.cont_css_class, 'expClpFlt');\r\n\r\n /**\r\n * Filters row index\r\n * @type {Number}\r\n */\r\n this.filtersRowIndex = defaultsNb(f.filters_row_index,\r\n tf.getFiltersRowIndex());\r\n\r\n /**\r\n * Make filters visible at initialization, defaults to true\r\n * @type {Boolean}\r\n */\r\n this.visibleAtStart = defaultsNb(f.visible_at_start, true);\r\n\r\n /**\r\n * Default position in toolbar ('left'|'center'|'right')\r\n * @type {String}\r\n */\r\n this.toolbarPosition = defaultsStr(f.toolbar_position, RIGHT);\r\n\r\n /**\r\n * Callback fired before filters row is shown\r\n * @type {Function}\r\n */\r\n this.onBeforeShow = defaultsFn(f.on_before_show, EMPTY_FN);\r\n\r\n /**\r\n * Callback fired after filters row is shown\r\n * @type {Function}\r\n */\r\n this.onAfterShow = defaultsFn(f.on_after_show, EMPTY_FN);\r\n\r\n /**\r\n * Callback fired before filters row is hidden\r\n * @type {Function}\r\n */\r\n this.onBeforeHide = defaultsFn(f.on_before_hide, EMPTY_FN);\r\n\r\n /**\r\n * Callback fired after filters row is hidden\r\n * @type {Function}\r\n */\r\n this.onAfterHide = defaultsFn(f.on_after_hide, EMPTY_FN);\r\n\r\n //Import extension's stylesheet\r\n tf.import(f.name + 'Style', tf.getStylePath() + this.stylesheet, null,\r\n 'link');\r\n\r\n this.enable();\r\n }\r\n\r\n /**\r\n * Initialise extension\r\n */\r\n init() {\r\n if (this.initialized) {\r\n return;\r\n }\r\n\r\n this.emitter.emit('initializing-extension', this,\r\n !isNull(this.targetId));\r\n\r\n this.buildUI();\r\n\r\n /** @inherited */\r\n this.initialized = true;\r\n\r\n this.emitter.on(['show-filters'], (tf, visible) => this.show(visible));\r\n this.emitter.emit('filters-visibility-initialized', this.tf, this);\r\n this.emitter.emit('extension-initialized', this);\r\n }\r\n\r\n /**\r\n * Build UI elements\r\n */\r\n buildUI() {\r\n let tf = this.tf;\r\n let span = createElm('span');\r\n span.className = this.contCssClass;\r\n\r\n // Container element (rdiv or custom element)\r\n let targetEl = !this.targetId ?\r\n tf.feature('toolbar').container(this.toolbarPosition) :\r\n elm(this.targetId);\r\n\r\n if (!this.targetId) {\r\n let firstChild = targetEl.firstChild;\r\n firstChild.parentNode.insertBefore(span, firstChild);\r\n } else {\r\n targetEl.appendChild(span);\r\n }\r\n\r\n let btn;\r\n if (!this.btnHtml) {\r\n btn = createElm('a', ['href', 'javascript:void(0);']);\r\n btn.className = this.btnCssClass;\r\n btn.title = this.btnText || this.defaultText;\r\n btn.innerHTML = this.collapseBtnHtml;\r\n span.appendChild(btn);\r\n } else { // Custom html\r\n span.innerHTML = this.btnHtml;\r\n btn = span.firstChild;\r\n }\r\n\r\n addEvt(btn, 'click', () => this.toggle());\r\n\r\n this.contEl = span;\r\n this.btnEl = btn;\r\n\r\n if (!this.visibleAtStart) {\r\n this.toggle();\r\n }\r\n }\r\n\r\n /**\r\n * Toggle filters visibility\r\n */\r\n toggle() {\r\n let tf = this.tf;\r\n let tbl = tf.gridLayout ? tf.feature('gridLayout').headTbl : tf.dom();\r\n let fltRow = tbl.rows[this.filtersRowIndex];\r\n let isDisplayed = fltRow.style.display === '';\r\n\r\n this.show(!isDisplayed);\r\n }\r\n\r\n /**\r\n * Show or hide filters\r\n *\r\n * @param {boolean} [visible=true] Visibility flag\r\n */\r\n show(visible = true) {\r\n let tf = this.tf;\r\n let tbl = tf.gridLayout ? tf.feature('gridLayout').headTbl : tf.dom();\r\n let fltRow = tbl.rows[this.filtersRowIndex];\r\n\r\n if (visible) {\r\n this.onBeforeShow(this);\r\n }\r\n if (!visible) {\r\n this.onBeforeHide(this);\r\n }\r\n\r\n fltRow.style.display = visible ? '' : 'none';\r\n if (this.enableIcon && !this.btnHtml) {\r\n this.btnEl.innerHTML = visible ?\r\n this.collapseBtnHtml : this.expandBtnHtml;\r\n }\r\n\r\n if (visible) {\r\n this.onAfterShow(this);\r\n }\r\n if (!visible) {\r\n this.onAfterHide(this);\r\n }\r\n\r\n this.emitter.emit('filters-toggled', tf, this, visible);\r\n }\r\n\r\n /**\r\n * Destroy the UI\r\n */\r\n destroy() {\r\n if (!this.initialized) {\r\n return;\r\n }\r\n\r\n this.emitter.off(['show-filters'], (tf, visible) => this.show(visible));\r\n\r\n this.btnEl.innerHTML = '';\r\n removeElm(this.btnEl);\r\n this.btnEl = null;\r\n\r\n this.contEl.innerHTML = '';\r\n removeElm(this.contEl);\r\n this.contEl = null;\r\n this.initialized = false;\r\n }\r\n\r\n}\r\n","import {Feature} from '../../feature';\r\nimport {\r\n addClass, removeClass, createCheckItem, createElm, elm, removeElm,\r\n getText, tag\r\n} from '../../dom';\r\nimport {isUndef, EMPTY_FN, isNull} from '../../types';\r\nimport {addEvt, targetEvt, removeEvt} from '../../event';\r\nimport {root} from '../../root';\r\nimport {NONE} from '../../const';\r\nimport {\r\n defaultsBool, defaultsStr, defaultsFn, defaultsNb, defaultsArr\r\n} from '../../settings';\r\nimport {RIGHT} from '../../modules/toolbar';\r\n\r\n/**\r\n * Columns Visibility extension\r\n */\r\nexport default class ColsVisibility extends Feature {\r\n\r\n /**\r\n * Creates an instance of ColsVisibility\r\n * @param {TableFilter} tf TableFilter instance\r\n * @param {Object} Configuration object\r\n */\r\n constructor(tf, f) {\r\n super(tf, ColsVisibility);\r\n\r\n // Configuration object\r\n let cfg = this.config;\r\n\r\n /**\r\n * Module name\r\n * @type {String}\r\n */\r\n this.name = f.name;\r\n\r\n /**\r\n * Module description\r\n * @type {String}\r\n */\r\n this.desc = defaultsStr(f.description, 'Columns visibility manager');\r\n\r\n /**\r\n * show/hide columns container element\r\n * @private\r\n */\r\n this.spanEl = null;\r\n\r\n /**\r\n * show/hide columns button element\r\n * @private\r\n */\r\n this.btnEl = null;\r\n\r\n /**\r\n * show/hide columns main container element\r\n * @private\r\n */\r\n this.contEl = null;\r\n\r\n /**\r\n * Enable tick to hide a column, defaults to true\r\n * @type {Boolean}\r\n */\r\n this.tickToHide = defaultsBool(f.tick_to_hide, true);\r\n\r\n /**\r\n * Enable columns manager UI, defaults to true\r\n * @type {Boolean}\r\n */\r\n this.manager = defaultsBool(f.manager, true);\r\n\r\n /**\r\n * Headers HTML table reference only if headers are external\r\n * @type {DOMElement}\r\n */\r\n this.headersTbl = f.headers_table || null;\r\n\r\n /**\r\n * Headers row index only if headers are external\r\n * @type {Number}\r\n */\r\n this.headersIndex = defaultsNb(f.headers_index, 1);\r\n\r\n /**\r\n * ID of main container element\r\n * @type {String}\r\n */\r\n this.contElTgtId = defaultsStr(f.container_target_id, null);\r\n\r\n /**\r\n * Alternative text for column headers in column manager UI\r\n * @type {Array}\r\n */\r\n this.headersText = defaultsArr(f.headers_text, []);\r\n\r\n /**\r\n * ID of button's container element\r\n * @type {String}\r\n */\r\n this.btnTgtId = defaultsStr(f.btn_target_id, null);\r\n\r\n /**\r\n * Button's text, defaults to Columns▼\r\n * @type {String}\r\n */\r\n this.btnText = defaultsStr(f.btn_text, 'Columns▼');\r\n\r\n /**\r\n * Button's inner HTML\r\n * @type {String}\r\n */\r\n this.btnHtml = defaultsStr(f.btn_html, null);\r\n\r\n /**\r\n * Css class for button\r\n * @type {String}\r\n */\r\n this.btnCssClass = defaultsStr(f.btn_css_class, 'colVis');\r\n\r\n /**\r\n * Columns manager UI close link text, defaults to 'Close'\r\n * @type {String}\r\n */\r\n this.btnCloseText = defaultsStr(f.btn_close_text, 'Close');\r\n\r\n /**\r\n * Columns manager UI close link HTML\r\n * @type {String}\r\n */\r\n this.btnCloseHtml = defaultsStr(f.btn_close_html, null);\r\n\r\n /**\r\n * Css for columns manager UI close link\r\n * @type {String}\r\n */\r\n this.btnCloseCssClass = defaultsStr(f.btn_close_css_class,\r\n this.btnCssClass);\r\n\r\n /**\r\n * Extension's stylesheet filename\r\n * @type {String}\r\n */\r\n this.stylesheet = defaultsStr(f.stylesheet, 'colsVisibility.css');\r\n\r\n /**\r\n * Css for columns manager UI span\r\n * @type {String}\r\n */\r\n this.spanCssClass = defaultsStr(f.span_css_class, 'colVisSpan');\r\n\r\n /**\r\n * Css for columns manager UI main container\r\n * @type {String}\r\n */\r\n this.contCssClass = defaultsStr(f.cont_css_class, 'colVisCont');\r\n\r\n /**\r\n * Css for columns manager UI checklist (ul)\r\n * @type {String}\r\n */\r\n this.listCssClass = defaultsStr(cfg.list_css_class, 'cols_checklist');\r\n\r\n /**\r\n * Css for columns manager UI checklist item (li)\r\n * @type {String}\r\n */\r\n this.listItemCssClass = defaultsStr(cfg.checklist_item_css_class,\r\n 'cols_checklist_item');\r\n\r\n /**\r\n * Css for columns manager UI checklist item selected state (li)\r\n * @type {String}\r\n */\r\n this.listSlcItemCssClass = defaultsStr(\r\n cfg.checklist_selected_item_css_class,\r\n 'cols_checklist_slc_item'\r\n );\r\n\r\n /**\r\n * Text preceding the columns list, defaults to 'Hide' or 'Show'\r\n * depending on tick mode (tick_to_hide option)\r\n * @type {String}\r\n */\r\n this.text = defaultsStr(f.text, this.tickToHide ? 'Hide: ' : 'Show: ');\r\n\r\n /**\r\n * List of columns indexes to be hidden at initialization\r\n * @type {Array}\r\n */\r\n this.atStart = defaultsArr(f.at_start, []);\r\n\r\n /**\r\n * Enable hover behaviour on columns manager button/link\r\n * @type {Boolean}\r\n */\r\n this.enableHover = Boolean(f.enable_hover);\r\n\r\n /**\r\n * Enable select all option, disabled by default\r\n * @type {Boolean}\r\n */\r\n this.enableTickAll = Boolean(f.enable_tick_all);\r\n\r\n /**\r\n * Text for select all option, defaults to 'Select all:'\r\n * @type {String}\r\n */\r\n this.tickAllText = defaultsStr(f.tick_all_text, 'Select all:');\r\n\r\n /**\r\n * Default position in toolbar ('left'|'center'|'right')\r\n * @type {String}\r\n */\r\n this.toolbarPosition = defaultsStr(f.toolbar_position, RIGHT);\r\n\r\n /**\r\n * List of indexes of hidden columns\r\n * @private\r\n */\r\n this.hiddenCols = [];\r\n\r\n /**\r\n * Bound mouseup wrapper\r\n * @private\r\n */\r\n this.boundMouseup = null;\r\n\r\n /**\r\n * Callback fired when the extension is initialized\r\n * @type {Function}\r\n */\r\n this.onLoaded = defaultsFn(f.on_loaded, EMPTY_FN);\r\n\r\n /**\r\n * Callback fired before the columns manager is opened\r\n * @type {Function}\r\n */\r\n this.onBeforeOpen = defaultsFn(f.on_before_open, EMPTY_FN);\r\n\r\n /**\r\n * Callback fired after the columns manager is opened\r\n * @type {Function}\r\n */\r\n this.onAfterOpen = defaultsFn(f.on_after_open, EMPTY_FN);\r\n\r\n /**\r\n * Callback fired before the columns manager is closed\r\n * @type {Function}\r\n */\r\n this.onBeforeClose = defaultsFn(f.on_before_close, EMPTY_FN);\r\n\r\n /**\r\n * Callback fired after the columns manager is closed\r\n * @type {Function}\r\n */\r\n this.onAfterClose = defaultsFn(f.on_after_close, EMPTY_FN);\r\n\r\n /**\r\n * Callback fired before a column is hidden\r\n * @type {Function}\r\n */\r\n this.onBeforeColHidden = defaultsFn(f.on_before_col_hidden, EMPTY_FN);\r\n\r\n /**\r\n * Callback fired after a column is hidden\r\n * @type {Function}\r\n */\r\n this.onAfterColHidden = defaultsFn(f.on_after_col_hidden, EMPTY_FN);\r\n\r\n /**\r\n * Callback fired before a column is displayed\r\n * @type {Function}\r\n */\r\n this.onBeforeColDisplayed = defaultsFn(f.on_before_col_displayed,\r\n EMPTY_FN);\r\n\r\n /**\r\n * Callback fired after a column is displayed\r\n * @type {Function}\r\n */\r\n this.onAfterColDisplayed = defaultsFn(f.on_after_col_displayed,\r\n EMPTY_FN);\r\n\r\n //Grid layout support\r\n if (tf.gridLayout) {\r\n this.headersTbl = tf.feature('gridLayout').headTbl; //headers table\r\n this.headersIndex = 0; //headers index\r\n }\r\n\r\n //Loads extension stylesheet\r\n tf.import(f.name + 'Style', tf.getStylePath() + this.stylesheet, null,\r\n 'link');\r\n\r\n this.enable();\r\n }\r\n\r\n /**\r\n * Mouse-up event handler handling popup auto-close behaviour\r\n * @private\r\n */\r\n onMouseup(evt) {\r\n let targetElm = targetEvt(evt);\r\n\r\n while (targetElm && targetElm !== this.contEl\r\n && targetElm !== this.btnEl) {\r\n targetElm = targetElm.parentNode;\r\n }\r\n\r\n if (targetElm !== this.contEl && targetElm !== this.btnEl) {\r\n this.toggle();\r\n }\r\n\r\n return;\r\n }\r\n\r\n /**\r\n * Toggle columns manager UI\r\n */\r\n toggle() {\r\n // ensure mouseup event handler is removed\r\n removeEvt(root, 'mouseup', this.boundMouseup);\r\n\r\n let contDisplay = this.contEl.style.display;\r\n\r\n if (contDisplay !== 'inline') {\r\n this.onBeforeOpen(this);\r\n }\r\n if (contDisplay === 'inline') {\r\n this.onBeforeClose(this);\r\n }\r\n\r\n this.contEl.style.display = contDisplay === 'inline' ?\r\n NONE : 'inline';\r\n\r\n if (contDisplay !== 'inline') {\r\n this.onAfterOpen(this);\r\n addEvt(root, 'mouseup', this.boundMouseup);\r\n }\r\n if (contDisplay === 'inline') {\r\n this.onAfterClose(this);\r\n }\r\n }\r\n\r\n /**\r\n * Check an item in columns manager UI\r\n * @private\r\n */\r\n checkItem(lbl) {\r\n let li = lbl.parentNode;\r\n if (!li || !lbl) {\r\n return;\r\n }\r\n let isChecked = lbl.firstChild.checked;\r\n let colIndex = lbl.firstChild.getAttribute('id').split('_')[1];\r\n colIndex = parseInt(colIndex, 10);\r\n if (isChecked) {\r\n addClass(li, this.listSlcItemCssClass);\r\n } else {\r\n removeClass(li, this.listSlcItemCssClass);\r\n }\r\n\r\n let hide = false;\r\n if ((this.tickToHide && isChecked) ||\r\n (!this.tickToHide && !isChecked)) {\r\n hide = true;\r\n }\r\n this.setHidden(colIndex, hide);\r\n }\r\n\r\n /**\r\n * Initializes ColsVisibility instance\r\n */\r\n init() {\r\n if (this.initialized || !this.manager) {\r\n return;\r\n }\r\n\r\n this.emitter.emit('initializing-extension', this,\r\n !isNull(this.btnTgtId));\r\n\r\n this.emitter.on(['hide-column'],\r\n (tf, colIndex) => this.hideCol(colIndex));\r\n\r\n this.buildBtn();\r\n this.buildManager();\r\n\r\n /** @inherited */\r\n this.initialized = true;\r\n\r\n this.boundMouseup = this.onMouseup.bind(this);\r\n\r\n this.emitter.emit('columns-visibility-initialized', this.tf, this);\r\n this.emitter.emit('extension-initialized', this);\r\n\r\n // Hide columns at start at very end of initialization, do not move\r\n // as order is important\r\n this._hideAtStart();\r\n }\r\n\r\n /**\r\n * Build main button UI\r\n */\r\n buildBtn() {\r\n if (this.btnEl) {\r\n return;\r\n }\r\n let tf = this.tf;\r\n let span = createElm('span');\r\n span.className = this.spanCssClass;\r\n\r\n // Container element (rdiv or custom element)\r\n let targetEl = !this.btnTgtId ?\r\n tf.feature('toolbar').container(this.toolbarPosition) :\r\n elm(this.btnTgtId);\r\n\r\n if (!this.btnTgtId) {\r\n let firstChild = targetEl.firstChild;\r\n firstChild.parentNode.insertBefore(span, firstChild);\r\n } else {\r\n targetEl.appendChild(span);\r\n }\r\n\r\n if (!this.btnHtml) {\r\n let btn = createElm('a', ['href', 'javascript:;']);\r\n btn.className = this.btnCssClass;\r\n btn.title = this.desc;\r\n\r\n btn.innerHTML = this.btnText;\r\n span.appendChild(btn);\r\n if (!this.enableHover) {\r\n addEvt(btn, 'click', (evt) => this.toggle(evt));\r\n } else {\r\n addEvt(btn, 'mouseover', (evt) => this.toggle(evt));\r\n }\r\n } else { // Custom html\r\n span.innerHTML = this.btnHtml;\r\n let colVisEl = span.firstChild;\r\n if (!this.enableHover) {\r\n addEvt(colVisEl, 'click', (evt) => this.toggle(evt));\r\n } else {\r\n addEvt(colVisEl, 'mouseover', (evt) => this.toggle(evt));\r\n }\r\n }\r\n\r\n this.spanEl = span;\r\n this.btnEl = this.spanEl.firstChild;\r\n\r\n this.onLoaded(this);\r\n }\r\n\r\n /**\r\n * Build columns manager UI\r\n */\r\n buildManager() {\r\n let tf = this.tf;\r\n\r\n let container = !this.contElTgtId ?\r\n createElm('div') :\r\n elm(this.contElTgtId);\r\n container.className = this.contCssClass;\r\n\r\n //Extension description\r\n let extNameLabel = createElm('p');\r\n extNameLabel.innerHTML = this.text;\r\n container.appendChild(extNameLabel);\r\n\r\n //Headers list\r\n let ul = createElm('ul');\r\n ul.className = this.listCssClass;\r\n\r\n let tbl = this.headersTbl || tf.dom();\r\n let headerIndex = this.headersTbl ?\r\n this.headersIndex : tf.getHeadersRowIndex();\r\n let headerRow = tbl.rows[headerIndex];\r\n\r\n //Tick all option\r\n if (this.enableTickAll) {\r\n let li = createCheckItem('col__' + tf.id, this.tickAllText,\r\n this.tickAllText);\r\n addClass(li, this.listItemCssClass);\r\n ul.appendChild(li);\r\n li.check.checked = !this.tickToHide;\r\n\r\n addEvt(li.check, 'click', () => {\r\n for (let h = 0; h < headerRow.cells.length; h++) {\r\n let itm = elm('col_' + h + '_' + tf.id);\r\n if (itm && li.check.checked !== itm.checked) {\r\n itm.click();\r\n itm.checked = li.check.checked;\r\n }\r\n }\r\n });\r\n }\r\n\r\n for (let i = 0; i < headerRow.cells.length; i++) {\r\n let cell = headerRow.cells[i];\r\n let cellText = this.headersText[i] || this._getHeaderText(cell);\r\n let liElm = createCheckItem('col_' + i + '_' + tf.id, cellText,\r\n cellText);\r\n addClass(liElm, this.listItemCssClass);\r\n if (!this.tickToHide) {\r\n addClass(liElm, this.listSlcItemCssClass);\r\n }\r\n ul.appendChild(liElm);\r\n if (!this.tickToHide) {\r\n liElm.check.checked = true;\r\n }\r\n\r\n addEvt(liElm.check, 'click', (evt) => {\r\n let elm = targetEvt(evt);\r\n let lbl = elm.parentNode;\r\n this.checkItem(lbl);\r\n });\r\n }\r\n\r\n //separator\r\n let p = createElm('p', ['align', 'center']);\r\n let btn;\r\n //Close link\r\n if (!this.btnCloseHtml) {\r\n btn = createElm('a', ['href', 'javascript:;']);\r\n btn.className = this.btnCloseCssClass;\r\n btn.innerHTML = this.btnCloseText;\r\n addEvt(btn, 'click', (evt) => this.toggle(evt));\r\n p.appendChild(btn);\r\n } else {\r\n p.innerHTML = this.btnCloseHtml;\r\n btn = p.firstChild;\r\n addEvt(btn, 'click', (evt) => this.toggle(evt));\r\n }\r\n\r\n container.appendChild(ul);\r\n container.appendChild(p);\r\n\r\n this.btnEl.parentNode.insertBefore(container, this.btnEl);\r\n this.contEl = container;\r\n }\r\n\r\n /**\r\n * Hide or show specified columns\r\n * @param {Number} colIndex Column index\r\n * @param {Boolean} hide Hide column if true or show if false\r\n */\r\n setHidden(colIndex, hide) {\r\n let tf = this.tf;\r\n let tbl = tf.dom();\r\n\r\n if (hide) {\r\n this.onBeforeColHidden(this, colIndex);\r\n } else {\r\n this.onBeforeColDisplayed(this, colIndex);\r\n }\r\n\r\n this._hideElements(tbl, colIndex, hide);\r\n if (this.headersTbl) {\r\n this._hideElements(this.headersTbl, colIndex, hide);\r\n }\r\n\r\n let hiddenCols = this.hiddenCols;\r\n let itemIndex = hiddenCols.indexOf(colIndex);\r\n if (hide) {\r\n if (itemIndex === -1) {\r\n this.hiddenCols.push(colIndex);\r\n }\r\n } else {\r\n if (itemIndex !== -1) {\r\n this.hiddenCols.splice(itemIndex, 1);\r\n }\r\n }\r\n\r\n if (hide) {\r\n this.onAfterColHidden(this, colIndex);\r\n this.emitter.emit('column-hidden', tf, this, colIndex,\r\n this.hiddenCols);\r\n } else {\r\n this.onAfterColDisplayed(this, colIndex);\r\n this.emitter.emit('column-shown', tf, this, colIndex,\r\n this.hiddenCols);\r\n }\r\n }\r\n\r\n /**\r\n * Show specified column\r\n * @param {Number} colIndex Column index\r\n */\r\n showCol(colIndex) {\r\n if (isUndef(colIndex) || !this.isColHidden(colIndex)) {\r\n return;\r\n }\r\n if (this.manager && this.contEl) {\r\n let itm = elm('col_' + colIndex + '_' + this.tf.id);\r\n if (itm) {\r\n itm.click();\r\n }\r\n } else {\r\n this.setHidden(colIndex, false);\r\n }\r\n }\r\n\r\n /**\r\n * Hide specified column\r\n * @param {Number} colIndex Column index\r\n */\r\n hideCol(colIndex) {\r\n if (isUndef(colIndex) || this.isColHidden(colIndex)) {\r\n return;\r\n }\r\n if (this.manager && this.contEl) {\r\n let itm = elm('col_' + colIndex + '_' + this.tf.id);\r\n if (itm) {\r\n itm.click();\r\n }\r\n } else {\r\n this.setHidden(colIndex, true);\r\n }\r\n }\r\n\r\n /**\r\n * Determine if specified column is hidden\r\n * @param {Number} colIndex Column index\r\n */\r\n isColHidden(colIndex) {\r\n if (this.hiddenCols.indexOf(colIndex) !== -1) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n /**\r\n * Toggle visibility of specified column\r\n * @param {Number} colIndex Column index\r\n */\r\n toggleCol(colIndex) {\r\n if (isUndef(colIndex) || this.isColHidden(colIndex)) {\r\n this.showCol(colIndex);\r\n } else {\r\n this.hideCol(colIndex);\r\n }\r\n }\r\n\r\n /**\r\n * Return the indexes of the columns currently hidden\r\n * @return {Array} column indexes\r\n */\r\n getHiddenCols() {\r\n return this.hiddenCols;\r\n }\r\n\r\n /**\r\n * Remove the columns manager\r\n */\r\n destroy() {\r\n if (!this.initialized) {\r\n return;\r\n }\r\n if (elm(this.contElTgtId)) {\r\n elm(this.contElTgtId).innerHTML = '';\r\n } else {\r\n this.contEl.innerHTML = '';\r\n removeElm(this.contEl);\r\n this.contEl = null;\r\n }\r\n this.btnEl.innerHTML = '';\r\n removeElm(this.btnEl);\r\n this.btnEl = null;\r\n\r\n this.emitter.off(['hide-column'],\r\n (tf, colIndex) => this.hideCol(colIndex));\r\n\r\n this.boundMouseup = null;\r\n\r\n this.initialized = false;\r\n }\r\n\r\n _getHeaderText(cell) {\r\n if (!cell.hasChildNodes) {\r\n return '';\r\n }\r\n\r\n for (let i = 0; i < cell.childNodes.length; i++) {\r\n let n = cell.childNodes[i];\r\n if (n.nodeType === 3) {\r\n return n.nodeValue;\r\n } else if (n.nodeType === 1) {\r\n if (n.id && n.id.indexOf('popUp') !== -1) {\r\n continue;\r\n } else {\r\n return getText(n);\r\n }\r\n }\r\n continue;\r\n }\r\n return '';\r\n }\r\n\r\n _hideElements(tbl, colIdx, hide) {\r\n this._hideCells(tbl, colIdx, hide);\r\n this._hideCol(tbl, colIdx, hide);\r\n }\r\n\r\n _hideCells(tbl, colIdx, hide) {\r\n for (let i = 0; i < tbl.rows.length; i++) {\r\n let row = tbl.rows[i];\r\n let cell = row.cells[colIdx];\r\n if (cell) {\r\n cell.style.display = hide ? NONE : '';\r\n }\r\n }\r\n }\r\n\r\n _hideCol(tbl, colIdx, hide) {\r\n let colElms = tag(tbl, 'col');\r\n if (colElms.length === 0) {\r\n return;\r\n }\r\n colElms[colIdx].style.display = hide ? NONE : '';\r\n }\r\n\r\n _hideAtStart() {\r\n this.atStart.forEach((colIdx) => {\r\n this.hideCol(colIdx);\r\n });\r\n }\r\n}\r\n","import {Feature} from '../../feature';\r\nimport {createText, elm} from '../../dom';\r\nimport {isArray, isEmpty, EMPTY_FN} from '../../types';\r\nimport {numSortAsc} from '../../sort';\r\nimport {FORMATTED_NUMBER} from '../../const';\r\nimport formatNumber from 'format-number';\r\nimport {defaultsFn, defaultsArr} from '../../settings';\r\nimport {bound} from '../../event';\r\n\r\nconst EVENTS = [\r\n 'after-filtering',\r\n 'after-page-change',\r\n 'after-page-length-change'\r\n];\r\n\r\nconst SUM = 'sum';\r\nconst MEAN = 'mean';\r\nconst MIN = 'min';\r\nconst MAX = 'max';\r\nconst MEDIAN = 'median';\r\nconst Q1 = 'q1';\r\nconst Q3 = 'q3';\r\n\r\n/**\r\n * Column calculations extension\r\n */\r\nexport default class ColOps extends Feature {\r\n\r\n /**\r\n * Creates an instance of ColOps\r\n *\r\n * @param {TableFilter} tf TableFilter instance\r\n * @param {Object} opts Configuration object\r\n */\r\n constructor(tf, opts) {\r\n super(tf, ColOps);\r\n\r\n /**\r\n * Callback fired before columns operations start\r\n * @type {Function}\r\n */\r\n this.onBeforeOperation = defaultsFn(opts.on_before_operation, EMPTY_FN);\r\n\r\n /**\r\n * Callback fired after columns operations are completed\r\n * @type {Function}\r\n */\r\n this.onAfterOperation = defaultsFn(opts.on_after_operation, EMPTY_FN);\r\n\r\n /**\r\n * Configuration options\r\n * @type {Object}\r\n */\r\n this.opts = opts;\r\n\r\n /**\r\n * List of DOM element IDs containing column's calculation result\r\n * @type {Array}\r\n */\r\n this.labelIds = defaultsArr(opts.id, []);\r\n\r\n /**\r\n * List of columns' indexes for calculations\r\n * @type {Array}\r\n */\r\n this.colIndexes = defaultsArr(opts.col, []);\r\n\r\n /**\r\n * List of operations - possible values: 'sum', 'mean', 'min', 'max',\r\n * 'median', 'q1', 'q3'\r\n * @type {Array}\r\n */\r\n this.operations = defaultsArr(opts.operation, []);\r\n\r\n /**\r\n * List of write methods used to write the result - possible values:\r\n * 'innerHTML', 'setValue', 'createTextNode'\r\n * @type {Array}\r\n */\r\n this.outputTypes = defaultsArr(opts.write_method, []);\r\n\r\n /**\r\n * List of format objects used for formatting the result -\r\n * refer to https://github.com/componitable/format-number to check\r\n * configuration options\r\n * @type {Array}\r\n */\r\n this.formatResults = defaultsArr(opts.format_result, []);\r\n\r\n /**\r\n * List of row indexes displaying the results\r\n * @type {Array}\r\n */\r\n this.totRowIndexes = defaultsArr(opts.tot_row_index, []);\r\n\r\n /**\r\n * List of row indexes excluded from calculations\r\n * @type {Array}\r\n */\r\n this.excludeRows = defaultsArr(opts.exclude_row, []);\r\n\r\n /**\r\n * List of decimal precision for calculation results\r\n * @type {Array}\r\n */\r\n this.decimalPrecisions = defaultsArr(opts.decimal_precision, 2);\r\n\r\n this.enable();\r\n }\r\n\r\n /**\r\n * Initializes ColOps instance\r\n */\r\n init() {\r\n if (this.initialized) {\r\n return;\r\n }\r\n // subscribe to events\r\n this.emitter.on(EVENTS, bound(this.calcAll, this));\r\n\r\n this.calcAll();\r\n\r\n /** @inherited */\r\n this.initialized = true;\r\n }\r\n\r\n /**\r\n * Calculates columns' values\r\n * Configuration options are stored in 'opts' property\r\n * - 'id' contains ids of elements showing result (array)\r\n * - 'col' contains the columns' indexes (array)\r\n * - 'operation' contains operation type (array, values: 'sum', 'mean',\r\n * 'min', 'max', 'median', 'q1', 'q3')\r\n * - 'write_method' array defines which method to use for displaying the\r\n * result (innerHTML, setValue, createTextNode) - default: 'innerHTML'\r\n * - 'tot_row_index' defines in which row results are displayed\r\n * (integers array)\r\n *\r\n * - changes made by Nuovella:\r\n * (1) optimized the routine (now it will only process each column once),\r\n * (2) added calculations for the median, lower and upper quartile.\r\n */\r\n calcAll() {\r\n let tf = this.tf;\r\n if (!tf.isInitialized()) {\r\n return;\r\n }\r\n\r\n this.onBeforeOperation(tf, this);\r\n this.emitter.emit('before-column-operation', tf, this);\r\n\r\n let { colIndexes, operations: colOperations, outputTypes,\r\n totRowIndexes, excludeRows, formatResults,\r\n decimalPrecisions } = this;\r\n\r\n //nuovella: determine unique list of columns to operate on\r\n let uIndexes = [];\r\n colIndexes.forEach((val) => {\r\n if (uIndexes.indexOf(val) === -1) {\r\n uIndexes.push(val);\r\n }\r\n });\r\n\r\n let nbCols = uIndexes.length,\r\n rows = tf.dom().rows,\r\n colValues = [];\r\n\r\n for (let u = 0; u < nbCols; u++) {\r\n //this retrieves col values\r\n //use uIndexes because we only want to pass through this loop\r\n //once for each column get the values in this unique column\r\n colValues.push(\r\n tf.getVisibleColumnData(uIndexes[u], false, excludeRows)\r\n );\r\n\r\n let curValues = colValues[u];\r\n\r\n //next: calculate all operations for this column\r\n let result = 0,\r\n operations = [],\r\n precisions = [],\r\n labels = [],\r\n writeType,\r\n formatResult = [],\r\n idx = 0;\r\n\r\n for (let k = 0; k < colIndexes.length; k++) {\r\n if (colIndexes[k] !== uIndexes[u]) {\r\n continue;\r\n }\r\n operations[idx] = (colOperations[k] || 'sum').toLowerCase();\r\n precisions[idx] = decimalPrecisions[k];\r\n labels[idx] = this.labelIds[k];\r\n writeType = isArray(outputTypes) ? outputTypes[k] : null;\r\n formatResult[idx] =\r\n this.configureFormat(uIndexes[u], formatResults[k]);\r\n idx++;\r\n }\r\n\r\n for (let i = 0; i < idx; i++) {\r\n // emit values before column calculation\r\n this.emitter.emit(\r\n 'before-column-calc',\r\n tf,\r\n this,\r\n uIndexes[u],\r\n curValues,\r\n operations[i],\r\n precisions[i]\r\n );\r\n\r\n result = Number(this.calc(curValues, operations[i], null));\r\n\r\n // emit column calculation result\r\n this.emitter.emit(\r\n 'column-calc',\r\n tf,\r\n this,\r\n uIndexes[u],\r\n result,\r\n operations[i],\r\n precisions[i]\r\n );\r\n\r\n // write result in expected DOM element\r\n this.writeResult(\r\n result,\r\n labels[i],\r\n writeType,\r\n precisions[i],\r\n formatResult[i]\r\n );\r\n\r\n }//for i\r\n\r\n // row(s) with result are always visible\r\n let totRow = totRowIndexes && totRowIndexes[u] ?\r\n rows[totRowIndexes[u]] : null;\r\n if (totRow) {\r\n totRow.style.display = '';\r\n }\r\n }//for u\r\n\r\n this.onAfterOperation(tf, this);\r\n this.emitter.emit('after-column-operation', tf, this);\r\n }\r\n\r\n /**\r\n * Make desired calculation on specified column.\r\n * @param {Number} colIndex Column index\r\n * @param {String} [operation=SUM] Operation type\r\n * @param {Number} precision Decimal precision\r\n * @returns {Number}\r\n */\r\n columnCalc(colIndex, operation = SUM, precision) {\r\n let excludeRows = this.excludeRows || [];\r\n let colValues = tf.getVisibleColumnData(colIndex, false, excludeRows);\r\n\r\n return Number(this.calc(colValues, operation, precision));\r\n }\r\n\r\n /**\r\n * Make calculation on passed values.\r\n * @param {Array} values List of values\r\n * @param {String} [operation=SUM] Optional operation type\r\n * @param {Number} precision Optional result precision\r\n * @returns {Number}\r\n * @private\r\n */\r\n calc(colValues, operation = SUM, precision) {\r\n let result = 0;\r\n\r\n if (operation === Q1 || operation === Q3 || operation === MEDIAN) {\r\n colValues = this.sortColumnValues(colValues, numSortAsc);\r\n }\r\n\r\n switch (operation) {\r\n case MEAN:\r\n result = this.calcMean(colValues);\r\n break;\r\n case SUM:\r\n result = this.calcSum(colValues);\r\n break;\r\n case MIN:\r\n result = this.calcMin(colValues);\r\n break;\r\n case MAX:\r\n result = this.calcMax(colValues);\r\n break;\r\n case MEDIAN:\r\n result = this.calcMedian(colValues);\r\n break;\r\n case Q1:\r\n result = this.calcQ1(colValues);\r\n break;\r\n case Q3:\r\n result = this.calcQ3(colValues);\r\n break;\r\n }\r\n\r\n return isEmpty(precision) ? result : result.toFixed(precision);\r\n }\r\n\r\n /**\r\n * Calculate the sum of passed values.\r\n * @param {Array} [values=[]] List of values\r\n * @returns {Number}\r\n */\r\n calcSum(values = []) {\r\n if (isEmpty(values)) {\r\n return 0;\r\n }\r\n let result = values.reduce((x, y) => Number(x) + Number(y));\r\n return result;\r\n }\r\n\r\n /**\r\n * Calculate the mean of passed values.\r\n * @param {Array} [values=[]] List of values\r\n * @returns {Number}\r\n */\r\n calcMean(values = []) {\r\n let result = this.calcSum(values) / values.length;\r\n return Number(result);\r\n }\r\n\r\n /**\r\n * Calculate the max value of passed values.\r\n * @param {Array} [values=[]] List of values\r\n * @returns {Number}\r\n */\r\n calcMax(values = []) {\r\n return Math.max.apply(null, values);\r\n }\r\n\r\n /**\r\n * Calculate the min value of passed values.\r\n * @param {Array} [values=[]] List of values\r\n * @returns {Number}\r\n */\r\n calcMin(values = []) {\r\n return Math.min.apply(null, values);\r\n }\r\n\r\n /**\r\n * Calculate the median of passed values.\r\n * @param {Array} [values=[]] List of values\r\n * @returns {Number}\r\n */\r\n calcMedian(values = []) {\r\n let nbValues = values.length;\r\n let aux = 0;\r\n if (nbValues % 2 === 1) {\r\n aux = Math.floor(nbValues / 2);\r\n return Number(values[aux]);\r\n }\r\n return (Number(values[nbValues / 2]) +\r\n Number(values[((nbValues / 2) - 1)])) / 2;\r\n }\r\n\r\n /**\r\n * Calculate the lower quartile of passed values.\r\n * @param {Array} [values=[]] List of values\r\n * @returns {Number}\r\n */\r\n calcQ1(values = []) {\r\n let nbValues = values.length;\r\n let posa = 0.0;\r\n posa = Math.floor(nbValues / 4);\r\n if (4 * posa === nbValues) {\r\n return (Number(values[posa - 1]) +\r\n Number(values[posa])) / 2;\r\n }\r\n return Number(values[posa]);\r\n }\r\n\r\n /**\r\n * Calculate the upper quartile of passed values.\r\n * @param {Array} [values=[]] List of values\r\n * @returns {Number}\r\n */\r\n calcQ3(values = []) {\r\n let nbValues = values.length;\r\n let posa = 0.0;\r\n let posb = 0.0;\r\n posa = Math.floor(nbValues / 4);\r\n if (4 * posa === nbValues) {\r\n posb = 3 * posa;\r\n return (Number(values[posb]) +\r\n Number(values[posb - 1])) / 2;\r\n }\r\n return Number(values[nbValues - posa - 1]);\r\n }\r\n\r\n /**\r\n * Sort passed values with supplied sorter function.\r\n * @param {Array} [values=[]] List of values to be sorted\r\n * @param {Function} sorter Sorter function\r\n * @returns {Array}\r\n */\r\n sortColumnValues(values = [], sorter) {\r\n return values.sort(sorter);\r\n }\r\n\r\n /**\r\n * Write calculation result in passed DOM element with supplied write method\r\n * and decimal precision.\r\n * @param {Number} [result=0] Calculation result\r\n * @param {DOMElement} label DOM element\r\n * @param {String} [writeType='innerhtml'] Write method\r\n * @param {Number} [precision=2] Applied decimal precision\r\n * @private\r\n */\r\n writeResult(result = 0, label, writeType = 'innerhtml',\r\n precision = 2, format = {}) {\r\n let labelElm = elm(label);\r\n\r\n if (!labelElm) {\r\n return;\r\n }\r\n\r\n result = result.toFixed(precision);\r\n if (isNaN(result) || !isFinite(result)) {\r\n result = '';\r\n } else {\r\n result = formatNumber(format)(result);\r\n }\r\n\r\n switch (writeType.toLowerCase()) {\r\n case 'innerhtml':\r\n labelElm.innerHTML = result;\r\n break;\r\n case 'setvalue':\r\n labelElm.value = result;\r\n break;\r\n case 'createtextnode':\r\n let oldNode = labelElm.firstChild;\r\n let txtNode = createText(result);\r\n labelElm.replaceChild(txtNode, oldNode);\r\n break;\r\n }\r\n }\r\n\r\n /**\r\n * Configure the format options used to format the operation result based\r\n * on column type.\r\n * @param {Number} colIndex Column index\r\n * @param {Object} [format={}] Format object\r\n * @returns {Object}\r\n * @private\r\n */\r\n configureFormat(colIndex, format = {}) {\r\n let tf = this.tf;\r\n if (tf.hasType(colIndex, [FORMATTED_NUMBER])) {\r\n let colType = tf.colTypes[colIndex];\r\n if (colType.decimal && !format.decimal) {\r\n format.decimal = colType.decimal;\r\n }\r\n if (colType.thousands && !format.integerSeparator) {\r\n format.integerSeparator = colType.thousands;\r\n }\r\n } else {\r\n format.decimal = format.decimal || '';\r\n format.integerSeparator = format.integerSeparator || '';\r\n }\r\n return format;\r\n }\r\n\r\n /** Remove extension */\r\n destroy() {\r\n if (!this.initialized) {\r\n return;\r\n }\r\n // unsubscribe to events\r\n this.emitter.off(EVENTS, bound(this.calcAll, this));\r\n\r\n this.initialized = false;\r\n }\r\n\r\n}\r\n","import AdapterEzEditTable from './adapterEzEditTable';\r\n\r\nexport default AdapterEzEditTable;","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\"","/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra\n*/\nmodule.exports = function(src) {\n\tfunction log(error) {\n\t\t(typeof console !== \"undefined\")\n\t\t&& (console.error || console.log)(\"[Script Loader]\", error);\n\t}\n\n\t// Check for IE =< 8\n\tfunction isIE() {\n\t\treturn typeof attachEvent !== \"undefined\" && typeof addEventListener === \"undefined\";\n\t}\n\n\ttry {\n\t\tif (typeof execScript !== \"undefined\" && isIE()) {\n\t\t\texecScript(src);\n\t\t} else if (typeof eval !== \"undefined\") {\n\t\t\teval.call(null, src);\n\t\t} else {\n\t\t\tlog(\"EvalError: No eval function available\");\n\t\t}\n\t} catch (error) {\n\t\tlog(error);\n\t}\n}\n","require(\"!!C:\\\\projects\\\\dev\\\\github\\\\TableFilter\\\\node_modules\\\\script-loader\\\\addScript.js\")(require(\"!!C:\\\\projects\\\\dev\\\\github\\\\TableFilter\\\\node_modules\\\\raw-loader\\\\index.js!C:\\\\projects\\\\dev\\\\github\\\\TableFilter\\\\libs\\\\sortabletable.js\"))","\nmodule.exports = formatter;\nmodule.exports.default = formatter;\n\nfunction formatter(options) {\n options = options || {};\n\n\n // *********************************************************************************************\n // Set defaults for negatives\n // options.negative, options.negativeOut, options.separator retained for backward compatibility\n // *********************************************************************************************\n\n // type of negative; default left\n options.negativeType = options.negativeType || (options.negative === 'R' ? 'right' : 'left')\n\n // negative symbols '-' or '()'\n if (typeof options.negativeLeftSymbol !== 'string') {\n switch (options.negativeType) {\n case 'left':\n options.negativeLeftSymbol = '-';\n break;\n case 'brackets':\n options.negativeLeftSymbol = '(';\n break;\n default:\n options.negativeLeftSymbol = '';\n }\n }\n if (typeof options.negativeRightSymbol !== 'string') {\n switch (options.negativeType) {\n case 'right':\n options.negativeRightSymbol = '-';\n break;\n case 'brackets':\n options.negativeRightSymbol = ')';\n break;\n default:\n options.negativeRightSymbol = '';\n }\n }\n\n // whether negative symbol should be inside/outside prefix and suffix\n\n if (typeof options.negativeLeftOut !== \"boolean\") {\n options.negativeLeftOut = (options.negativeOut === false ? false : true);\n }\n if (typeof options.negativeRightOut !== \"boolean\") {\n options.negativeRightOut = (options.negativeOut === false ? false : true);\n }\n\n //prefix and suffix\n options.prefix = options.prefix || '';\n options.suffix = options.suffix || '';\n\n //separators\n if (typeof options.integerSeparator !== 'string') {\n options.integerSeparator = (typeof options.separator === 'string' ? options.separator : ',');\n }\n options.decimalsSeparator = typeof options.decimalsSeparator === 'string' ? options.decimalsSeparator : '';\n options.decimal = options.decimal || '.';\n\n //padders\n options.padLeft = options.padLeft || -1 //default no padding\n options.padRight = options.padRight || -1 //default no padding\n\n function format(number, overrideOptions) {\n overrideOptions = overrideOptions || {};\n\n if (number || number === 0) {\n number = '' + number;//convert number to string if it isn't already\n } else {\n return '';\n }\n\n //identify a negative number and make it absolute\n var output = [];\n var negative = number.charAt(0) === '-';\n number = number.replace(/^\\-/g, '');\n\n //Prepare output with left hand negative and/or prefix\n if (!options.negativeLeftOut && !overrideOptions.noUnits) {\n output.push(options.prefix);\n }\n if (negative) {\n output.push(options.negativeLeftSymbol);\n }\n if (options.negativeLeftOut && !overrideOptions.noUnits) {\n output.push(options.prefix);\n }\n\n //Format core number\n number = number.split('.');\n if (options.round != null) round(number, options.round);\n if (options.truncate != null) number[1] = truncate(number[1], options.truncate);\n if (options.padLeft > 0) number[0] = padLeft(number[0], options.padLeft);\n if (options.padRight > 0) number[1] = padRight(number[1], options.padRight);\n if (!overrideOptions.noSeparator && number[1]) number[1] = addDecimalSeparators(number[1], options.decimalsSeparator);\n if (!overrideOptions.noSeparator && number[0]) number[0] = addIntegerSeparators(number[0], options.integerSeparator);\n output.push(number[0]);\n if (number[1]) {\n output.push(options.decimal);\n output.push(number[1]);\n }\n\n //Prepare output with right hand negative and/or prefix\n if (options.negativeRightOut && !overrideOptions.noUnits) {\n output.push(options.suffix);\n }\n if (negative) {\n output.push(options.negativeRightSymbol);\n }\n if (!options.negativeRightOut && !overrideOptions.noUnits) {\n output.push(options.suffix);\n }\n\n //join output and return\n return output.join('');\n }\n\n format.negative = options.negative;\n format.negativeOut = options.negativeOut;\n format.negativeType = options.negativeType;\n format.negativeLeftOut = options.negativeLeftOut;\n format.negativeLeftSymbol = options.negativeLeftSymbol;\n format.negativeRightOut = options.negativeRightOut;\n format.negativeRightSymbol = options.negativeRightSymbol;\n format.prefix = options.prefix;\n format.suffix = options.suffix;\n format.separate = options.separate;\n format.integerSeparator = options.integerSeparator;\n format.decimalsSeparator = options.decimalsSeparator;\n format.decimal = options.decimal;\n format.padLeft = options.padLeft;\n format.padRight = options.padRight;\n format.truncate = options.truncate;\n format.round = options.round;\n\n function unformat(number, allowedSeparators) {\n allowedSeparators = allowedSeparators || [];\n if (options.allowedSeparators) {\n options.allowedSeparators.forEach(function (s) { allowedSeparators.push (s); });\n }\n allowedSeparators.push(options.integerSeparator);\n allowedSeparators.push(options.decimalsSeparator);\n number = number.replace(options.prefix, '');\n number = number.replace(options.suffix, '');\n var newNumber = number;\n do {\n number = newNumber;\n for (var i = 0; i < allowedSeparators.length; i++) {\n newNumber = newNumber.replace(allowedSeparators[i], '');\n }\n } while (newNumber != number);\n return number;\n }\n format.unformat = unformat;\n\n function validate(number, allowedSeparators) {\n number = unformat(number, allowedSeparators);\n number = number.split(options.decimal);\n if (number.length > 2) {\n return false;\n } else if (options.truncate != null && number[1] && number[1].length > options.truncate) {\n return false;\n } else if (options.round != null && number[1] && number[1].length > options.round) {\n return false;\n } else {\n return /^-?\\d+\\.?\\d*$/.test(number);\n }\n }\n return format;\n}\n\n//where x is already the integer part of the number\nfunction addIntegerSeparators(x, separator) {\n x += '';\n if (!separator) return x;\n var rgx = /(\\d+)(\\d{3})/;\n while (rgx.test(x)) {\n x = x.replace(rgx, '$1' + separator + '$2');\n }\n return x;\n}\n\n//where x is already the decimal part of the number\nfunction addDecimalSeparators(x, separator) {\n x += '';\n if (!separator) return x;\n var rgx = /(\\d{3})(\\d+)/;\n while (rgx.test(x)) {\n x = x.replace(rgx, '$1' + separator + '$2');\n }\n return x;\n}\n\n//where x is the integer part of the number\nfunction padLeft(x, padding) {\n x = x + '';\n var buf = [];\n while (buf.length + x.length < padding) {\n buf.push('0');\n }\n return buf.join('') + x;\n}\n\n//where x is the decimals part of the number\nfunction padRight(x, padding) {\n if (x) {\n x += '';\n } else {\n x = '';\n }\n var buf = [];\n while (buf.length + x.length < padding) {\n buf.push('0');\n }\n return x + buf.join('');\n}\nfunction truncate(x, length) {\n if (x) {\n x += '';\n }\n if (x && x.length > length) {\n return x.substr(0, length);\n } else {\n return x;\n }\n}\n\n//where number is an array with 0th item as integer string and 1st item as decimal string (no negatives)\nfunction round(number, places) {\n if (number[1] && places >= 0 && number[1].length > places) {\n //truncate to correct number of decimal places\n var decim = number[1].slice(0, places);\n //if next digit was >= 5 we need to round up\n if (+(number[1].substr(places, 1)) >= 5) {\n //But first count leading zeros as converting to a number will loose them\n var leadingzeros = \"\";\n while (decim.charAt(0)===\"0\") {\n leadingzeros = leadingzeros + \"0\";\n decim = decim.substr(1);\n }\n //Then we can change decim to a number and add 1 before replacing leading zeros\n decim = (+decim + 1) + '';\n decim = leadingzeros + decim;\n if (decim.length > places) {\n //adding one has made it longer\n number[0] = (+number[0]+ +decim.charAt(0)) + ''; //add value of firstchar to the integer part\n decim = decim.substring(1); //ignore the 1st char at the beginning which is the carry to the integer part\n }\n }\n number[1] = decim;\n }\n return number;\n}\n"],"sourceRoot":""} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 888bb069..7b4fad03 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "tablefilter", - "version": "0.6.92", + "version": "0.6.93", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -2298,9 +2298,9 @@ "integrity": "sha512-1Bh06cbWJUHMC97acuD6UMG29nMt0Aqz1vF3guLfG+kHHJhy3AyohZFFxYk2f7Q1SQIrNwvncxAE0N/9s70F2w==", "dev": true, "requires": { - "@types/events": "*", - "@types/minimatch": "*", - "@types/node": "*" + "@types/events": "3.0.0", + "@types/minimatch": "3.0.3", + "@types/node": "10.0.4" } }, "@types/minimatch": { @@ -2327,7 +2327,7 @@ "integrity": "sha512-SudIN9TRJ+v8g5pTG8RRCqfqTMNqgWCKKd3vtynhGzkIIjxaicNAMuY5TRadJ6tzDu3Dotf3ngaMILtmOdmWEQ==", "dev": true, "requires": { - "source-map": "^0.6.1" + "source-map": "0.6.1" }, "dependencies": { "source-map": { @@ -2344,11 +2344,11 @@ "integrity": "sha512-mNARoaSJTzbiHxtZbf9NULFilu2frqD+g9Iyl9V2jPYJWXi+AC3Hz8lQWPZ5LLtgUm7iF4SDDMB/1bPrbRQgFw==", "dev": true, "requires": { - "@types/anymatch": "*", - "@types/node": "*", - "@types/tapable": "*", - "@types/uglify-js": "*", - "source-map": "^0.6.0" + "@types/anymatch": "1.3.1", + "@types/node": "10.0.4", + "@types/tapable": "1.0.4", + "@types/uglify-js": "3.0.4", + "source-map": "0.6.1" }, "dependencies": { "source-map": { @@ -4057,8 +4057,8 @@ "integrity": "sha512-MciirUH5r+cYLGCOL5JX/ZLzOZbVr1ot3Fw+KcvbhUb6PM+yycqd9ZhIlcigQ5gl+XhppNmw3bEFuaaMNyLj3A==", "dev": true, "requires": { - "@types/webpack": "^4.4.31", - "del": "^4.1.1" + "@types/webpack": "4.4.32", + "del": "4.1.1" } }, "cli-cursor": { @@ -4712,13 +4712,13 @@ "integrity": "sha512-QwGuEUouP2kVwQenAsOof5Fv8K9t3D8Ca8NxcXKrIpEHjTXK5J2nXLdP+ALI1cgv8wj7KuwBhTwBkOZSJKM5XQ==", "dev": true, "requires": { - "@types/glob": "^7.1.1", - "globby": "^6.1.0", - "is-path-cwd": "^2.0.0", - "is-path-in-cwd": "^2.0.0", - "p-map": "^2.0.0", - "pify": "^4.0.1", - "rimraf": "^2.6.3" + "@types/glob": "7.1.1", + "globby": "6.1.0", + "is-path-cwd": "2.1.0", + "is-path-in-cwd": "2.1.0", + "p-map": "2.1.0", + "pify": "4.0.1", + "rimraf": "2.6.3" }, "dependencies": { "glob": { @@ -4727,12 +4727,12 @@ "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", "dev": true, "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" } }, "is-path-cwd": { @@ -4747,7 +4747,7 @@ "integrity": "sha512-rNocXHgipO+rvnP6dk3zI20RpOtrAM/kzbB258Uw5BWr3TpXi861yzjo16Dn4hUox07iw5AyeMLHWsujkjzvRQ==", "dev": true, "requires": { - "is-path-inside": "^2.1.0" + "is-path-inside": "2.1.0" } }, "is-path-inside": { @@ -4756,7 +4756,7 @@ "integrity": "sha512-wiyhTzfDWsvwAW53OBWF5zuvaOGlZ6PwYxAbPVDhpm+gM09xKQGjBq/8uYN12aDvMxnAnq3dxTyoSoRNmg5YFg==", "dev": true, "requires": { - "path-is-inside": "^1.0.2" + "path-is-inside": "1.0.2" } }, "p-map": { @@ -4777,7 +4777,7 @@ "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", "dev": true, "requires": { - "glob": "^7.1.3" + "glob": "7.1.4" } } } @@ -7162,11 +7162,11 @@ "integrity": "sha1-9abXDoOV4hyFj7BInWTfAkJNUGw=", "dev": true, "requires": { - "array-union": "^1.0.1", - "glob": "^7.0.3", - "object-assign": "^4.0.1", - "pify": "^2.0.0", - "pinkie-promise": "^2.0.0" + "array-union": "1.0.2", + "glob": "7.1.2", + "object-assign": "4.1.1", + "pify": "2.3.0", + "pinkie-promise": "2.0.1" }, "dependencies": { "pify": { @@ -12394,7 +12394,7 @@ "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", "dev": true, "requires": { - "locate-path": "^3.0.0" + "locate-path": "3.0.0" } }, "json-schema-traverse": { @@ -12409,8 +12409,8 @@ "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", "dev": true, "requires": { - "p-locate": "^3.0.0", - "path-exists": "^3.0.0" + "p-locate": "3.0.0", + "path-exists": "3.0.0" } }, "make-dir": { @@ -12438,7 +12438,7 @@ "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", "dev": true, "requires": { - "p-limit": "^2.0.0" + "p-limit": "2.2.0" } }, "p-try": { @@ -12459,7 +12459,7 @@ "integrity": "sha512-/E57AYkoeQ25qkxMj5PBOVgF8Kiu/h7cYS30Z5+R7WaiCCBfLq58ZI/dSeaEKb9WVJV5n/03QwrN3IeWIFllvw==", "dev": true, "requires": { - "find-up": "^3.0.0" + "find-up": "3.0.0" } }, "schema-utils": { @@ -12468,9 +12468,9 @@ "integrity": "sha512-i27Mic4KovM/lnGsy8whRCHhc7VicJajAjTrYg11K9zfZXnYIt4k5F+kZkwjnrhKzLic/HLU4j11mjsz2G/75g==", "dev": true, "requires": { - "ajv": "^6.1.0", - "ajv-errors": "^1.0.0", - "ajv-keywords": "^3.1.0" + "ajv": "6.10.0", + "ajv-errors": "1.0.1", + "ajv-keywords": "3.1.0" } }, "semver": { diff --git a/webpack.config.js b/webpack.config.js index 35698274..993002a4 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,6 +1,6 @@ const webpack = require('webpack'); const path = require('path'); -const Clean = require('clean-webpack-plugin'); +const {CleanWebpackPlugin} = require('clean-webpack-plugin'); const StringReplacePlugin = require('string-replace-webpack-plugin'); const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); const fs = require('fs'); @@ -67,7 +67,7 @@ module.exports = { ] }, plugins: [ - new Clean({ + new CleanWebpackPlugin({ cleanOnceBeforeBuildPatterns: [path.join(process.cwd(), 'dist')] }), new webpack.optimize.AggressiveMergingPlugin(), diff --git a/webpack.test.config.js b/webpack.test.config.js index f75f1207..a1194cb2 100644 --- a/webpack.test.config.js +++ b/webpack.test.config.js @@ -1,7 +1,7 @@ const webpack = require('webpack'); const webpackConfig = require('./webpack.config.js'); const path = require('path'); -const Clean = require('clean-webpack-plugin'); +const {CleanWebpackPlugin} = require('clean-webpack-plugin'); module.exports = { mode: 'development', @@ -23,7 +23,7 @@ module.exports = { }, devtool: 'source-map', plugins: [ - new Clean({ + new CleanWebpackPlugin({ cleanOnceBeforeBuildPatterns: [path.join(process.cwd(), 'dist')] }), new webpack.LoaderOptionsPlugin({