/** * tablefilter v0.0.4 by Max Guglielmi * build date: 2015-10-17T08:45:37.398Z * MIT License */ webpackJsonp([1],{23:function(t,e,s){function i(t){return s(l(t))}function l(t){return a[t]||function(){throw new Error("Cannot find module '"+t+"'.")}()}var a={"./array":6,"./array.js":6,"./cookie":4,"./cookie.js":4,"./date":7,"./date.js":7,"./dom":2,"./dom.js":2,"./event":1,"./event.js":1,"./extensions/advancedGrid/adapterEzEditTable":24,"./extensions/advancedGrid/adapterEzEditTable.js":24,"./extensions/advancedGrid/advancedGrid":25,"./extensions/advancedGrid/advancedGrid.js":25,"./extensions/colOps/colOps":26,"./extensions/colOps/colOps.js":26,"./extensions/colsVisibility/colsVisibility":27,"./extensions/colsVisibility/colsVisibility.js":27,"./extensions/filtersVisibility/filtersVisibility":28,"./extensions/filtersVisibility/filtersVisibility.js":28,"./extensions/sort/adapterSortabletable":29,"./extensions/sort/adapterSortabletable.js":29,"./extensions/sort/sort":30,"./extensions/sort/sort.js":30,"./helpers":8,"./helpers.js":8,"./modules/alternateRows":22,"./modules/alternateRows.js":22,"./modules/checkList":16,"./modules/checkList.js":16,"./modules/clearButton":20,"./modules/clearButton.js":20,"./modules/dropdown":14,"./modules/dropdown.js":14,"./modules/gridLayout":10,"./modules/gridLayout.js":10,"./modules/help":21,"./modules/help.js":21,"./modules/highlightKeywords":12,"./modules/highlightKeywords.js":12,"./modules/loader":11,"./modules/loader.js":11,"./modules/paging":19,"./modules/paging.js":19,"./modules/popupFilter":13,"./modules/popupFilter.js":13,"./modules/rowsCounter":17,"./modules/rowsCounter.js":17,"./modules/statusBar":18,"./modules/statusBar.js":18,"./modules/store":9,"./modules/store.js":9,"./sort":15,"./sort.js":15,"./string":3,"./string.js":3,"./types":5,"./types.js":5};i.keys=function(){return Object.keys(a)},i.resolve=l,t.exports=i,i.id=23},24:function(t,e,s){"use strict";function i(t){return t&&t.__esModule?t:{"default":t}}function l(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function t(t,e){for(var s=0;s0&&!s.startRow?void 0:s.startRow||e.refRow,s.base_path=s.base_path||e.basePath+"ezEditTable/";var l=s.editable,a=s.selection;a&&(s.default_selection=s.default_selection||"row"),s.active_cell_css=s.active_cell_css||"ezETSelectedCell";var n=0,o=0;if(a){var d=function(t,s,i){var l=t.Selection,a=function(i){if("row"===t.defaultSelection)l.SelectRowByIndex(i);else{t.ClearSelections();var a=s.cellIndex,n=e.tbl.rows[i];"both"===t.defaultSelection&&l.SelectRowByIndex(i),n&&l.SelectCell(n.cells[a])}if(e.validRowsIndex.length!==e.getRowsNb()){var r=e.tbl.rows[i];r&&r.scrollIntoView(!1),f&&(f.cellIndex===e.getCellsNb()-1&&e.gridLayout?e.tblCont.scrollLeft=1e8:0===f.cellIndex&&e.gridLayout?e.tblCont.scrollLeft=0:f.scrollIntoView(!1))}};if(e.validRowsIndex){var r,d=e.validRowsIndex,u=d.length,c="row"!==t.defaultSelection?s.parentNode:s,f="TD"===s.nodeName?s:null,p=void 0!==i?t.Event.GetKey(i):0,g=h["default"].has(d,c.rowIndex),v=34===p||33===p?e.feature("paging").pagingLength||t.nbRowsPerPage:1;if(g)34!==p&&33!==p?(n=h["default"].indexByValue(d,c.rowIndex),o=c.rowIndex):(r=34===p?u-1>=n+v?d[n+v]:[u-1]:n-v<=d[0]?d[0]:d[n-v],o=r,n=h["default"].indexByValue(d,r),a(r));else{if(c.rowIndex>o)if(c.rowIndex>=d[u-1])r=d[u-1];else{var b=n+v;r=b>u-1?d[u-1]:d[b]}else if(c.rowIndex<=d[0])r=d[0];else{var m=d[n-v];r=m?m:d[0]}o=c.rowIndex,a(r)}}},u=function(t,s){var i="row"!==t.defaultSelection?s.parentNode:s;if(e.paging&&e.feature("paging").nbPages>1){var l=e.feature("paging");t.nbRowsPerPage=l.pagingLength;var a=e.validRowsIndex,n=a.length,r=parseInt(l.startPagingRow,10)+parseInt(l.pagingLength,10),o=i.rowIndex;o===a[n-1]&&l.currentPageNb!==l.nbPages?l.setPage("last"):o==a[0]&&1!==l.currentPageNb?l.setPage("first"):o>a[r-1]&&oa[0]&&l.setPage("previous")}};if(e.paging&&(e.feature("paging").onAfterChangePage=function(t){var e=t.tf.extension("advancedGrid"),s=e._ezEditTable,i=s.Selection,l=i.GetActiveRow();l&&l.scrollIntoView(!1);var a=i.GetActiveCell();a&&a.scrollIntoView(!1)}),"row"===s.default_selection){var c=s.on_before_selected_row;s.on_before_selected_row=function(){u(arguments[0],arguments[1],arguments[2]),c&&c.call(null,arguments[0],arguments[1],arguments[2])};var f=s.on_after_selected_row;s.on_after_selected_row=function(){d(arguments[0],arguments[1],arguments[2]),f&&f.call(null,arguments[0],arguments[1],arguments[2])}}else{var p=s.on_before_selected_cell;s.on_before_selected_cell=function(){u(arguments[0],arguments[1],arguments[2]),p&&p.call(null,arguments[0],arguments[1],arguments[2])};var g=s.on_after_selected_cell;s.on_after_selected_cell=function(){d(arguments[0],arguments[1],arguments[2]),g&&g.call(null,arguments[0],arguments[1],arguments[2])}}}if(l){var v=s.on_added_dom_row;if(s.on_added_dom_row=function(){e.nbFilterableRows++,e.paging?(e.nbRows++,e.nbVisibleRows++,e.nbFilterableRows++,e.paging=!1,e.feature("paging").destroy(),e.feature("paging").reset()):e.feature("rowsCounter").refresh(),e.alternateBgs&&e.feature("alternateRows").init(),v&&v.call(null,arguments[0],arguments[1],arguments[2])},s.actions&&s.actions["delete"]){var b=s.actions["delete"].on_after_submit;s.actions["delete"].on_after_submit=function(){e.nbFilterableRows--,e.paging?(e.nbRows--,e.nbVisibleRows--,e.nbFilterableRows--,e.paging=!1,e.feature("paging").destroy(),e.feature("paging").reset(!1)):e.feature("rowsCounter").refresh(),e.alternateBgs&&e.feature("alternateRows").init(),b&&b.call(null,arguments[0],arguments[1])}}}try{this._ezEditTable=new EditTable(e.id,s,t),this._ezEditTable.Init()}catch(m){throw new Error(this.err)}this.initialized=!0}},{key:"reset",value:function(){var t=this._ezEditTable;t&&(this.cfg.selection&&t.Selection.Set(),this.cfg.editable&&t.Editable.Set())}},{key:"destroy",value:function(){var t=this._ezEditTable;t&&(this.cfg.selection&&(t.Selection.ClearSelections(),t.Selection.Remove()),this.cfg.editable&&t.Editable.Remove()),this.initialized=!1}}]),t}();e["default"]=d,t.exports=e["default"]},25:function(t,e,s){"use strict";function i(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(e,"__esModule",{value:!0});var l=s(24),a=i(l);e["default"]=a["default"],t.exports=e["default"]},26:function(module,exports,__webpack_require__){"use strict";function _interopRequireDefault(t){return t&&t.__esModule?t:{"default":t}}function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function t(t,e){for(var s=0;s=jj;jj++)ucolIndex[jj]===colIndex[ii]&&(saved=1);0===saved&&(ucolMax++,ucolIndex[ucolMax]=colIndex[ii])}if("object"==_string2["default"].lower(typeof labelId)&&"object"==_string2["default"].lower(typeof colIndex)&&"object"==_string2["default"].lower(typeof operation))for(var rows=tf.tbl.rows,colvalues=[],ucol=0;ucolMax>=ucol;ucol++){colvalues.push(tf.getColValues(ucolIndex[ucol],!0,excludeRow));for(var result,nbvalues=0,temp,meanValue=0,sumValue=0,minValue=null,maxValue=null,q1Value=null,medValue=null,q3Value=null,meanFlag=0,sumFlag=0,minFlag=0,maxFlag=0,q1Flag=0,medFlag=0,q3Flag=0,theList=[],opsThisCol=[],decThisCol=[],labThisCol=[],oTypeThisCol=[],mThisCol=-1,k=0;kmaxValue?parseFloat(cvalue):maxValue))}if(1===meanFlag&&(meanValue=sumValue/nbvalues),1===medFlag){var aux=0;nbvalues%2===1?(aux=Math.floor(nbvalues/2),medValue=theList[aux]):medValue=(theList[nbvalues/2]+theList[nbvalues/2-1])/2}var posa;if(1===q1Flag&&(posa=0,posa=Math.floor(nbvalues/4),q1Value=4*posa==nbvalues?(theList[posa-1]+theList[posa])/2:theList[posa]),1===q3Flag){posa=0;var posb=0;posa=Math.floor(nbvalues/4),4*posa===nbvalues?(posb=3*posa,q3Value=(theList[posb]+theList[posb-1])/2):q3Value=theList[nbvalues-posa-1]}for(var i=0;mThisCol>=i;i++){switch(opsThisCol[i]){case"mean":result=meanValue;break;case"sum":result=sumValue;break;case"min":result=minValue;break;case"max":result=maxValue;break;case"median":result=medValue;break;case"q1":result=q1Value;break;case"q3":result=q3Value}var precision=isNaN(decThisCol[i])?2:decThisCol[i];if(oTypeThisCol&&result){if(result=result.toFixed(precision),_dom2["default"].id(labThisCol[i]))switch(_string2["default"].lower(oTypeThisCol)){case"innerhtml":isNaN(result)||!isFinite(result)||0===nbvalues?_dom2["default"].id(labThisCol[i]).innerHTML=".":_dom2["default"].id(labThisCol[i]).innerHTML=result;break;case"setvalue":_dom2["default"].id(labThisCol[i]).value=result;break;case"createtextnode":var oldnode=_dom2["default"].id(labThisCol[i]).firstChild,txtnode=_dom2["default"].text(result);_dom2["default"].id(labThisCol[i]).replaceChild(txtnode,oldnode)}}else try{isNaN(result)||!isFinite(result)||0===nbvalues?_dom2["default"].id(labThisCol[i]).innerHTML=".":_dom2["default"].id(labThisCol[i]).innerHTML=result.toFixed(precision)}catch(e){}}var totRow=totRowIndex&&totRowIndex[ucol]?rows[totRowIndex[ucol]]:null;totRow&&(totRow.style.display="")}this.onAfterOperation&&this.onAfterOperation.call(null,tf)}}},{key:"destroy",value:function(){}}]),ColOps}();exports["default"]=ColOps,module.exports=exports["default"]},27:function(t,e,s){"use strict";function i(t){return t&&t.__esModule?t:{"default":t}}function l(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function t(t,e){for(var s=0;s0,this.onLoaded=h["default"].isFn(s.on_loaded)?s.on_loaded:null,this.onBeforeOpen=h["default"].isFn(s.on_before_open)?s.on_before_open:null,this.onAfterOpen=h["default"].isFn(s.on_after_open)?s.on_after_open:null,this.onBeforeClose=h["default"].isFn(s.on_before_close)?s.on_before_close:null,this.onAfterClose=h["default"].isFn(s.on_after_close)?s.on_after_close:null,this.onBeforeColHidden=h["default"].isFn(s.on_before_col_hidden)?s.on_before_col_hidden:null,this.onAfterColHidden=h["default"].isFn(s.on_after_col_hidden)?s.on_after_col_hidden:null,this.onBeforeColDisplayed=h["default"].isFn(s.on_before_col_displayed)?s.on_before_col_displayed:null,this.onAfterColDisplayed=h["default"].isFn(s.on_after_col_displayed)?s.on_after_col_displayed:null,e.gridLayout&&(this.headersTbl=e.feature("gridLayout").headTbl,this.headersIndex=0,this.onAfterColDisplayed=function(){},this.onAfterColHidden=function(){}),e["import"](s.name+"Style",e.stylePath+this.stylesheet,null,"link"),this.tf=e}return a(t,[{key:"toggle",value:function(){var t=this.contEl.style.display,e=this.onBeforeOpen,s=this.onBeforeClose,i=this.onAfterOpen,l=this.onAfterClose;e&&"inline"!==t&&e.call(null,this),s&&"inline"===t&&s.call(null,this),this.contEl.style.display="inline"===t?"none":"inline",i&&"inline"!==t&&i.call(null,this),l&&"inline"===t&&l.call(null,this)}},{key:"checkItem",value:function(t){var e=t.parentNode;if(e&&t){var s=t.firstChild.checked,i=t.firstChild.getAttribute("id").split("_")[1];i=parseInt(i,10),s?r["default"].addClass(e,this.listSlcItemCssClass):r["default"].removeClass(e,this.listSlcItemCssClass);var l=!1;(this.tickToHide&&s||!this.tickToHide&&!s)&&(l=!0),this.setHidden(i,l)}}},{key:"init",value:function(){this.manager&&(this.buildBtn(),this.buildManager(),this.initialized=!0)}},{key:"buildBtn",value:function(){var t=this;if(!this.btnEl){var e=this.tf,s=r["default"].create("span",["id",this.prfx+e.id]);s.className=this.spanCssClass,this.btnTgtId||e.setToolbar();var i=this.btnTgtId?r["default"].id(this.btnTgtId):e.rDiv;if(this.btnTgtId)i.appendChild(s);else{var l=i.firstChild;l.parentNode.insertBefore(s,l)}if(this.btnHtml){s.innerHTML=this.btnHtml;var a=s.firstChild;this.enableHover?u["default"].add(a,"mouseover",function(e){t.toggle(e)}):u["default"].add(a,"click",function(e){t.toggle(e)})}else{var n=r["default"].create("a",["href","javascript:;"]);n.className=this.btnCssClass,n.title=this.desc,n.innerHTML=this.btnText,s.appendChild(n),this.enableHover?u["default"].add(n,"mouseover",function(e){t.toggle(e)}):u["default"].add(n,"click",function(e){t.toggle(e)})}this.spanEl=s,this.btnEl=this.spanEl.firstChild,this.onLoaded&&this.onLoaded.call(null,this)}}},{key:"buildManager",value:function(){var t=this,e=this.tf,s=this.contElTgtId?r["default"].id(this.contElTgtId):r["default"].create("div",["id",this.prfxCont+e.id]);s.className=this.contCssClass;var i=r["default"].create("p");i.innerHTML=this.text,s.appendChild(i);var l=r["default"].create("ul",["id","ul"+this.name+"_"+e.id]);l.className=this.listCssClass;var a=this.headersTbl?this.headersTbl:e.tbl,n=this.headersTbl?this.headersIndex:e.getHeadersRowIndex(),o=a.rows[n];if(this.enableTickAll){var h=r["default"].createCheckItem("col__"+e.id,this.tickAllText,this.tickAllText);r["default"].addClass(h,this.listItemCssClass),l.appendChild(h),h.check.checked=!this.tickToHide,u["default"].add(h.check,"click",function(){for(var t=0;t',this.icnCollapseHtml='Collapse filters',this.defaultText="Toggle filters",this.targetId=s.target_id||null,this.enableIcon=s.enable_icon===!1?!1:!0,this.btnText=s.btn_text||"",this.collapseBtnHtml=this.enableIcon?this.icnCollapseHtml+this.btnText:this.btnText||this.defaultText,this.expandBtnHtml=this.enableIcon?this.icnExpandHtml+this.btnText:this.btnText||this.defaultText,this.btnHtml=s.btn_html||null,this.btnCssClass=s.btn_css_class||"btnExpClpFlt",this.contCssClass=s.cont_css_class||"expClpFlt",this.filtersRowIndex=h["default"].isUndef(s.filters_row_index)?e.getFiltersRowIndex():s.filters_row_index,this.visibleAtStart=h["default"].isUndef(s.visible_at_start)?!0:Boolean(s.visible_at_start),this.prfx="fltsVis_",this.onBeforeShow=h["default"].isFn(s.on_before_show)?s.on_before_show:null,this.onAfterShow=h["default"].isFn(s.on_after_show)?s.on_after_show:null,this.onBeforeHide=h["default"].isFn(s.on_before_hide)?s.on_before_hide:null,this.onAfterHide=h["default"].isFn(s.on_after_hide)?s.on_after_hide:null,e["import"](s.name+"Style",e.stylePath+this.stylesheet,null,"link"),this.tf=e}return a(t,[{key:"init",value:function(){this.initialized||(this.buildUI(),this.initialized=!0)}},{key:"buildUI",value:function(){var t=this,e=this.tf,s=r["default"].create("span",["id",this.prfx+e.id]);s.className=this.contCssClass,this.targetId||e.setToolbar();var i=this.targetId?r["default"].id(this.targetId):e.rDiv;if(this.targetId)i.appendChild(s);else{var l=i.firstChild;l.parentNode.insertBefore(s,l)}var a=void 0;this.btnHtml?(s.innerHTML=this.btnHtml,a=s.firstChild,u["default"].add(a,"click",function(){return t.toggle()})):(a=r["default"].create("a",["href","javascript:void(0);"]),a.className=this.btnCssClass,a.title=this.btnText||this.defaultText,a.innerHTML=this.collapseBtnHtml,s.appendChild(a),u["default"].add(a,"click",function(){return t.toggle()})),this.contEl=s,this.btnEl=a,this.visibleAtStart||this.toggle()}},{key:"toggle",value:function(){var t=this.tf,e=t.gridLayout?t.feature("gridLayout").headTbl:t.tbl,s=e.rows[this.filtersRowIndex],i=s.style.display;this.onBeforeShow&&""!==i&&this.onBeforeShow.call(this,this),this.onBeforeHide&&""===i&&this.onBeforeHide.call(null,this),s.style.display=""===i?"none":"",this.enableIcon&&!this.btnHtml&&(this.btnEl.innerHTML=""===i?this.expandBtnHtml:this.collapseBtnHtml),this.onAfterShow&&""!==i&&this.onAfterShow.call(null,this),this.onAfterHide&&""===i&&this.onAfterHide.call(null,this)}},{key:"destroy",value:function(){(this.btnEl||this.contEl)&&(this.btnEl.innerHTML="",this.btnEl.parentNode.removeChild(this.btnEl),this.btnEl=null,this.contEl.innerHTML="",this.contEl.parentNode.removeChild(this.contEl),this.contEl=null,this.initialized=!1)}}]),t}();e["default"]=c,t.exports=e["default"]},29:function(t,e,s){"use strict";function i(t){return t&&t.__esModule?t:{"default":t}}function l(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function a(t){return S["default"].removeNbFormat(t,"us")}function n(t){return S["default"].removeNbFormat(t,"eu")}function r(t,e){return x["default"].format(t,e)}function o(t){return r(t,"DMY")}function h(t){return r(t,"MDY")}function d(t){return r(t,"YMD")}function u(t){return r(t,"DDMMMYYYY")}function c(t){var e=t.split(".");for(var s in e){for(var i=e[s];3>i.length;)i="0"+i;e[s]=i}return e.join(".")}function f(t,e){var s=c(t.value.toLowerCase()),i=c(e.value.toLowerCase());return s==i?0:i>s?-1:1}Object.defineProperty(e,"__esModule",{value:!0});var p=function(){function t(t,e){for(var s=0;si;i++);return i},SortableTable.prototype.initHeader=function(s){var i=this;if(!i.tHead){if(!e.gridLayout)return;i.tHead=e.feature("gridLayout").headTbl.tHead}i.headersRow=e.headersRow;var l=i.tHead.rows[i.headersRow].cells;i.sortTypes=s||[];for(var a=l.length,n=void 0,r=void 0,o=0;a>o;o++)r=l[o],null!==i.sortTypes[o]&&"None"!==i.sortTypes[o]?(r.style.cursor="pointer",n=m["default"].create("img",["src",t.imgPath+t.imgBlank]),r.appendChild(n),null!==i.sortTypes[o]&&r.setAttribute("_sortType",i.sortTypes[o]),w["default"].add(r,"click",i._headerOnclick)):(r.setAttribute("_sortType",s[o]),r._sortType="None");i.updateHeaderArrows()},SortableTable.prototype.updateHeaderArrows=function(){var e=this,s=void 0,i=void 0,l=void 0;if(t.asyncSort&&t.triggerIds.length>0){var a=t.triggerIds;s=[],i=a.length;for(var n=0;nr;r++){var o=s[r].getAttribute("_sortType");null!==o&&"None"!==o&&(l=s[r].lastChild||s[r],"img"!==l.nodeName.toLowerCase()&&(l=m["default"].create("img",["src",t.imgPath+t.imgBlank]),s[r].appendChild(l)),r===e.sortColumn?l.className=t.imgClassName+" "+(this.descending?t.imgDescClassName:t.imgAscClassName):l.className=t.imgClassName)}},SortableTable.prototype.getRowValue=function(t,e,s){var i=this,l=i._sortTypeInfo[e];if(l&&l.getRowValue)return l.getRowValue(t,s);var a=t.cells[s],n=SortableTable.getInnerText(a);return i.getValueFromString(n,e)},SortableTable.getInnerText=function(e){return e?e.getAttribute(t.customKey)?e.getAttribute(t.customKey):m["default"].getText(e):void 0}}},{key:"addSortType",value:function(){var t=arguments;SortableTable.prototype.addSortType(t[0],t[1],t[2],t[3])}},{key:"setSortTypes",value:function(){for(var t=this,e=this.tf,s=this.sortTypes,i=[],l=0;l0&&!function(){for(var e=t.triggerIds,s=0;s 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 if ( this.tHead )\r\n this.uninitHeader();\r\n this.element = oTable;\r\n this.setTHead( oTable.tHead );\r\n this.setTBody( oTable.tBodies[0] );\r\n};\r\n\r\nSortableTable.prototype.setTHead = function (oTHead) {\r\n if (this.tHead && this.tHead != oTHead )\r\n this.uninitHeader();\r\n this.tHead = oTHead;\r\n this.initHeader( this.sortTypes );\r\n};\r\n\r\nSortableTable.prototype.setTBody = function (oTBody) {\r\n this.tBody = oTBody;\r\n};\r\n\r\nSortableTable.prototype.setSortTypes = function ( oSortTypes ) {\r\n if ( this.tHead )\r\n this.uninitHeader();\r\n this.sortTypes = oSortTypes || [];\r\n if ( this.tHead )\r\n this.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 if (!this.tHead) return;\r\n var cells = this.tHead.rows[0].cells;\r\n var doc = this.tHead.ownerDocument || this.tHead.document;\r\n this.sortTypes = oSortTypes || [];\r\n var l = cells.length;\r\n var img, c;\r\n for (var i = 0; i < l; i++) {\r\n c = cells[i];\r\n if (this.sortTypes[i] != null && this.sortTypes[i] != "None") {\r\n img = doc.createElement("IMG");\r\n img.src = "images/blank.png";\r\n c.appendChild(img);\r\n if (this.sortTypes[i] != null)\r\n c._sortType = this.sortTypes[i];\r\n if (typeof c.addEventListener != "undefined")\r\n c.addEventListener("click", this._headerOnclick, false);\r\n else if (typeof c.attachEvent != "undefined")\r\n c.attachEvent("onclick", this._headerOnclick);\r\n else\r\n c.onclick = this._headerOnclick;\r\n }\r\n else\r\n {\r\n c.setAttribute( "_sortType", oSortTypes[i] );\r\n c._sortType = "None";\r\n }\r\n }\r\n this.updateHeaderArrows();\r\n};\r\n\r\n// remove arrows and events\r\nSortableTable.prototype.uninitHeader = function () {\r\n if (!this.tHead) return;\r\n var cells = this.tHead.rows[0].cells;\r\n var l = cells.length;\r\n var c;\r\n for (var i = 0; i < l; i++) {\r\n c = cells[i];\r\n if (c._sortType != null && c._sortType != "None") {\r\n c.removeChild(c.lastChild);\r\n if (typeof c.removeEventListener != "undefined")\r\n c.removeEventListener("click", this._headerOnclick, false);\r\n else if (typeof c.detachEvent != "undefined")\r\n c.detachEvent("onclick", this._headerOnclick);\r\n c._sortType = null;\r\n c.removeAttribute( "_sortType" );\r\n }\r\n }\r\n};\r\n\r\nSortableTable.prototype.updateHeaderArrows = function () {\r\n if (!this.tHead) return;\r\n var cells = this.tHead.rows[0].cells;\r\n var l = cells.length;\r\n var img;\r\n for (var i = 0; i < l; i++) {\r\n if (cells[i]._sortType != null && cells[i]._sortType != "None") {\r\n img = cells[i].lastChild;\r\n if (i == this.sortColumn)\r\n img.className = "sort-arrow " + (this.descending ? "descending" : "ascending");\r\n else\r\n img.className = "sort-arrow";\r\n }\r\n }\r\n};\r\n\r\nSortableTable.prototype.headerOnclick = function (e) {\r\n // find TD element\r\n var el = e.target || e.srcElement;\r\n while (el.tagName != "TD")\r\n el = el.parentNode;\r\n\r\n this.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 var cells = oTd.parentNode.childNodes\r\n var l = cells.length;\r\n var i;\r\n for (i = 0; cells[i] != oTd && i < l; i++)\r\n ;\r\n return i;\r\n};\r\n\r\nSortableTable.prototype.getSortType = function (nColumn) {\r\n return 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 if (!this.tBody) return;\r\n if (sSortType == null)\r\n sSortType = this.getSortType(nColumn);\r\n\r\n // exit if None\r\n if (sSortType == "None")\r\n return;\r\n\r\n if (bDescending == null) {\r\n if (this.sortColumn != nColumn)\r\n this.descending = this.defaultDescending;\r\n else\r\n this.descending = !this.descending;\r\n }\r\n else\r\n this.descending = bDescending;\r\n\r\n this.sortColumn = nColumn;\r\n\r\n if (typeof this.onbeforesort == "function")\r\n this.onbeforesort();\r\n\r\n var f = this.getSortFunction(sSortType, nColumn);\r\n var a = this.getCache(sSortType, nColumn);\r\n var tBody = this.tBody;\r\n\r\n a.sort(f);\r\n\r\n if (this.descending)\r\n a.reverse();\r\n\r\n if (SortableTable.removeBeforeSort) {\r\n // remove from doc\r\n var nextSibling = tBody.nextSibling;\r\n var p = tBody.parentNode;\r\n p.removeChild(tBody);\r\n }\r\n\r\n // insert in the new order\r\n var l = a.length;\r\n for (var i = 0; i < l; i++)\r\n tBody.appendChild(a[i].element);\r\n\r\n if (SortableTable.removeBeforeSort) {\r\n // insert into doc\r\n p.insertBefore(tBody, nextSibling);\r\n }\r\n\r\n this.updateHeaderArrows();\r\n\r\n this.destroyCache(a);\r\n\r\n if (typeof this.onsort == "function")\r\n this.onsort();\r\n};\r\n\r\nSortableTable.prototype.asyncSort = function (nColumn, bDescending, sSortType) {\r\n var oThis = this;\r\n this._asyncsort = function () {\r\n oThis.sort(nColumn, bDescending, sSortType);\r\n };\r\n window.setTimeout(this._asyncsort, 1);\r\n};\r\n\r\nSortableTable.prototype.getCache = function (sType, nColumn) {\r\n if (!this.tBody) return [];\r\n var rows = this.tBody.rows;\r\n var l = rows.length;\r\n var a = new Array(l);\r\n var r;\r\n for (var i = 0; i < l; i++) {\r\n r = rows[i];\r\n a[i] = {\r\n value: this.getRowValue(r, sType, nColumn),\r\n element: r\r\n };\r\n };\r\n return a;\r\n};\r\n\r\nSortableTable.prototype.destroyCache = function (oArray) {\r\n var l = oArray.length;\r\n for (var i = 0; i < l; i++) {\r\n oArray[i].value = null;\r\n oArray[i].element = null;\r\n oArray[i] = null;\r\n }\r\n};\r\n\r\nSortableTable.prototype.getRowValue = function (oRow, sType, nColumn) {\r\n // if we have defined a custom getRowValue use that\r\n if (this._sortTypeInfo[sType] && this._sortTypeInfo[sType].getRowValue)\r\n return this._sortTypeInfo[sType].getRowValue(oRow, nColumn);\r\n\r\n var s;\r\n var c = oRow.cells[nColumn];\r\n if (typeof c.innerText != "undefined")\r\n s = c.innerText;\r\n else\r\n s = SortableTable.getInnerText(c);\r\n return this.getValueFromString(s, sType);\r\n};\r\n\r\nSortableTable.getInnerText = function (oNode) {\r\n var s = "";\r\n var cs = oNode.childNodes;\r\n var l = cs.length;\r\n for (var i = 0; i < l; i++) {\r\n switch (cs[i].nodeType) {\r\n case 1: //ELEMENT_NODE\r\n s += SortableTable.getInnerText(cs[i]);\r\n break;\r\n case 3: //TEXT_NODE\r\n s += cs[i].nodeValue;\r\n break;\r\n }\r\n }\r\n return s;\r\n};\r\n\r\nSortableTable.prototype.getValueFromString = function (sText, sType) {\r\n if (this._sortTypeInfo[sType])\r\n return this._sortTypeInfo[sType].getValueFromString( sText );\r\n return sText;\r\n /*\r\n switch (sType) {\r\n case "Number":\r\n return Number(sText);\r\n case "CaseInsensitiveString":\r\n return sText.toUpperCase();\r\n case "Date":\r\n var parts = sText.split("-");\r\n var d = new Date(0);\r\n d.setFullYear(parts[0]);\r\n d.setDate(parts[2]);\r\n d.setMonth(parts[1] - 1);\r\n return d.valueOf();\r\n }\r\n return sText;\r\n */\r\n };\r\n\r\nSortableTable.prototype.getSortFunction = function (sType, nColumn) {\r\n if (this._sortTypeInfo[sType])\r\n return this._sortTypeInfo[sType].compare;\r\n return SortableTable.basicCompare;\r\n};\r\n\r\nSortableTable.prototype.destroy = function () {\r\n this.uninitHeader();\r\n var win = this.document.parentWindow;\r\n if (win && typeof win.detachEvent != "undefined") { // only IE needs this\r\n win.detachEvent("onunload", this._onunload);\r\n }\r\n this._onunload = null;\r\n this.element = null;\r\n this.tHead = null;\r\n this.tBody = null;\r\n this.document = null;\r\n this._headerOnclick = null;\r\n this.sortTypes = null;\r\n this._asyncsort = null;\r\n this.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 this._sortTypeInfo[sType] = {\r\n type: sType,\r\n getValueFromString: fGetValueFromString || SortableTable.idFunction,\r\n compare: fCompareFunction || SortableTable.basicCompare,\r\n getRowValue: fGetRowValue\r\n };\r\n};\r\n\r\n// this removes the sort type from all instances of SortableTable\r\nSortableTable.prototype.removeSortType = function (sType) {\r\n delete this._sortTypeInfo[sType];\r\n};\r\n\r\nSortableTable.basicCompare = function compare(n1, n2) {\r\n if (n1.value < n2.value)\r\n return -1;\r\n if (n2.value < n1.value)\r\n return 1;\r\n return 0;\r\n};\r\n\r\nSortableTable.idFunction = function (x) {\r\n return x;\r\n};\r\n\r\nSortableTable.toUpperCase = function (s) {\r\n return s.toUpperCase();\r\n};\r\n\r\nSortableTable.toDate = function (s) {\r\n var parts = s.split("-");\r\n var d = new Date(0);\r\n d.setFullYear(parts[0]);\r\n d.setDate(parts[2]);\r\n d.setMonth(parts[1] - 1);\r\n return 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'}});