1
0
Fork 0
mirror of https://github.com/koalyptus/TableFilter.git synced 2024-04-26 12:10:45 +02:00
TableFilter/dist/tablefilter/tf-1.js

8 lines
47 KiB
JavaScript

/**
* tablefilter v0.2.0 by Max Guglielmi
* build date: 2016-03-16T07:04:47.758Z
* MIT License
*/
webpackJsonp([1],{27:function(e,t,n){function r(e){return n(s(e))}function s(e){return i[e]||function(){throw new Error("Cannot find module '"+e+"'.")}()}var i={"./array":16,"./array.js":16,"./cookie":9,"./cookie.js":9,"./date":5,"./date.js":5,"./dom":2,"./dom.js":2,"./emitter":7,"./emitter.js":7,"./event":1,"./event.js":1,"./extensions/advancedGrid/adapterEzEditTable":28,"./extensions/advancedGrid/adapterEzEditTable.js":28,"./extensions/advancedGrid/advancedGrid":29,"./extensions/advancedGrid/advancedGrid.js":29,"./extensions/colOps/colOps":30,"./extensions/colOps/colOps.js":30,"./extensions/colsVisibility/colsVisibility":31,"./extensions/colsVisibility/colsVisibility.js":31,"./extensions/filtersVisibility/filtersVisibility":32,"./extensions/filtersVisibility/filtersVisibility.js":32,"./extensions/sort/adapterSortabletable":33,"./extensions/sort/adapterSortabletable.js":33,"./extensions/sort/sort":34,"./extensions/sort/sort.js":34,"./helpers":6,"./helpers.js":6,"./modules/alternateRows":24,"./modules/alternateRows.js":24,"./modules/checkList":18,"./modules/checkList.js":18,"./modules/clearButton":22,"./modules/clearButton.js":22,"./modules/dropdown":15,"./modules/dropdown.js":15,"./modules/feature":11,"./modules/feature.js":11,"./modules/gridLayout":10,"./modules/gridLayout.js":10,"./modules/help":23,"./modules/help.js":23,"./modules/highlightKeywords":13,"./modules/highlightKeywords.js":13,"./modules/loader":12,"./modules/loader.js":12,"./modules/noResults":25,"./modules/noResults.js":25,"./modules/paging":21,"./modules/paging.js":21,"./modules/popupFilter":14,"./modules/popupFilter.js":14,"./modules/rowsCounter":19,"./modules/rowsCounter.js":19,"./modules/stateful":26,"./modules/stateful.js":26,"./modules/statusBar":20,"./modules/statusBar.js":20,"./modules/store":8,"./modules/store.js":8,"./sort":17,"./sort.js":17,"./string":3,"./string.js":3,"./types":4,"./types.js":4};r.keys=function(){return Object.keys(i)},r.resolve=s,e.exports=r,r.id=27},28:function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),l=n(2),o=r(l),a=function(){function e(t,n){s(this,e),this.initialized=!1,this.desc=n.description||"ezEditTable adapter",this.filename=n.filename||"ezEditTable.js",this.vendorPath=n.vendor_path,this.loadStylesheet=Boolean(n.load_stylesheet),this.stylesheet=n.stylesheet||this.vendorPath+"ezEditTable.css",this.stylesheetName=n.stylesheet_name||"ezEditTableCss",this.err='Failed to instantiate EditTable object.\n"ezEditTable" dependency not found.',n.scroll_into_view=n.scroll_into_view===!1?!1:t.gridLayout,this._ezEditTable=null,this.cfg=n,this.tf=t,this.emitter=t.emitter}return i(e,[{key:"init",value:function(){var e=this,t=this.tf;if(window.EditTable)this._setAdvancedGrid();else{var n=this.vendorPath+this.filename;t["import"](this.filename,n,function(){e._setAdvancedGrid()})}this.loadStylesheet&&!t.isImported(this.stylesheet,"link")&&t["import"](this.stylesheetName,this.stylesheet,null,"link"),this.emitter.on(["filter-focus","filter-blur"],function(){return e._toggleForInputFilter()})}},{key:"_setAdvancedGrid",value:function(){var e,t=this.tf,n=this.cfg,r=o["default"].tag(t.tbl,"thead");e=r.length>0&&!n.startRow?void 0:n.startRow||t.refRow,n.base_path=n.base_path||t.basePath+"ezEditTable/";var s=n.editable,i=n.selection;i&&(n.default_selection=n.default_selection||"row"),n.active_cell_css=n.active_cell_css||"ezETSelectedCell";var l=0,a=0;if(i){var d=function(e,n,r){var s=e.Selection,i=function(r){if("row"===e.defaultSelection)s.SelectRowByIndex(r);else{e.ClearSelections();var i=n.cellIndex,l=t.tbl.rows[r];"both"===e.defaultSelection&&s.SelectRowByIndex(r),l&&s.SelectCell(l.cells[i])}if(t.validRowsIndex.length!==t.getRowsNb()){var o=t.tbl.rows[r];o&&o.scrollIntoView(!1),h&&(h.cellIndex===t.getCellsNb()-1&&t.gridLayout?t.tblCont.scrollLeft=1e8:0===h.cellIndex&&t.gridLayout?t.tblCont.scrollLeft=0:h.scrollIntoView(!1))}};if(t.validRowsIndex){var o,d=t.validRowsIndex,u=d.length,c="row"!==e.defaultSelection?n.parentNode:n,h="TD"===n.nodeName?n:null,f=void 0!==r?e.Event.GetKey(r):0,p=-1!==d.indexOf(c.rowIndex),b=t.feature("paging"),m=34===f||33===f?b&&b.pagingLength||e.nbRowsPerPage:1;if(p)34!==f&&33!==f?(l=d.indexOf(c.rowIndex),a=c.rowIndex):(o=34===f?u-1>=l+m?d[l+m]:[u-1]:l-m<=d[0]?d[0]:d[l-m],a=o,l=d.indexOf(o),i(o));else{if(c.rowIndex>a)if(c.rowIndex>=d[u-1])o=d[u-1];else{var g=l+m;o=g>u-1?d[u-1]:d[g]}else if(c.rowIndex<=d[0])o=d[0];else{var y=d[l-m];o=y?y:d[0]}a=c.rowIndex,i(o)}}},u=function(e,n){var r="row"!==e.defaultSelection?n.parentNode:n;if(t.paging&&t.feature("paging").nbPages>1){var s=t.feature("paging");e.nbRowsPerPage=s.pagingLength;var i=t.validRowsIndex,l=i.length,o=parseInt(s.startPagingRow,10)+parseInt(s.pagingLength,10),a=r.rowIndex;a===i[l-1]&&s.currentPageNb!==s.nbPages?s.setPage("last"):a==i[0]&&1!==s.currentPageNb?s.setPage("first"):a>i[o-1]&&a<i[l-1]?s.setPage("next"):a<i[s.startPagingRow]&&a>i[0]&&s.setPage("previous")}};if(t.paging&&(t.feature("paging").onAfterChangePage=function(e){var t=e.tf.extension("advancedGrid"),n=t._ezEditTable,r=n.Selection,s=r.GetActiveRow();s&&s.scrollIntoView(!1);var i=r.GetActiveCell();i&&i.scrollIntoView(!1)}),"row"===n.default_selection){var c=n.on_before_selected_row;n.on_before_selected_row=function(){u(arguments[0],arguments[1],arguments[2]),c&&c.call(null,arguments[0],arguments[1],arguments[2])};var h=n.on_after_selected_row;n.on_after_selected_row=function(){d(arguments[0],arguments[1],arguments[2]),h&&h.call(null,arguments[0],arguments[1],arguments[2])}}else{var f=n.on_before_selected_cell;n.on_before_selected_cell=function(){u(arguments[0],arguments[1],arguments[2]),f&&f.call(null,arguments[0],arguments[1],arguments[2])};var p=n.on_after_selected_cell;n.on_after_selected_cell=function(){d(arguments[0],arguments[1],arguments[2]),p&&p.call(null,arguments[0],arguments[1],arguments[2])}}}if(s){var b=n.on_added_dom_row;if(n.on_added_dom_row=function(){t.nbFilterableRows++,t.paging?(t.nbRows++,t.nbVisibleRows++,t.nbFilterableRows++,t.paging=!1,t.feature("paging").destroy(),t.feature("paging").reset()):t.emitter.emit("rows-changed",t,this),t.alternateRows&&t.feature("alternateRows").init(),b&&b.call(null,arguments[0],arguments[1],arguments[2])},n.actions&&n.actions["delete"]){var m=n.actions["delete"].on_after_submit;n.actions["delete"].on_after_submit=function(){t.nbFilterableRows--,t.paging?(t.nbRows--,t.nbVisibleRows--,t.nbFilterableRows--,t.paging=!1,t.feature("paging").destroy(),t.feature("paging").reset(!1)):t.emitter.emit("rows-changed",t,this),t.alternateRows&&t.feature("alternateRows").init(),m&&m.call(null,arguments[0],arguments[1])}}}try{this._ezEditTable=new EditTable(t.id,n,e),this._ezEditTable.Init()}catch(g){throw new Error(this.err)}this.initialized=!0}},{key:"reset",value:function(){var e=this._ezEditTable;e&&(this.cfg.selection&&e.Selection.Set(),this.cfg.editable&&e.Editable.Set())}},{key:"toggle",value:function(){var e=this._ezEditTable;e.editable?e.Editable.Remove():e.Editable.Set(),e.selection?e.Selection.Remove():e.Selection.Set()}},{key:"_toggleForInputFilter",value:function(){var e=this.tf;if(e.activeFlt){var t=e.activeFlt.getAttribute("ct"),n=e.getFilterType(t);n===e.fltTypeInp&&this.toggle()}}},{key:"destroy",value:function(){var e=this,t=this._ezEditTable;t&&(this.cfg.selection&&(t.Selection.ClearSelections(),t.Selection.Remove()),this.cfg.editable&&t.Editable.Remove()),this.emitter.off(["filter-focus","filter-blur"],function(){return e._toggleForInputFilter()}),this.initialized=!1}}]),e}();t["default"]=a},29:function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var s=n(28),i=r(s);t["default"]=i["default"]},30:function(module,exports,__webpack_require__){"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(exports,"__esModule",{value:!0});var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},_createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),_dom=__webpack_require__(2),_dom2=_interopRequireDefault(_dom),_string=__webpack_require__(3),_string2=_interopRequireDefault(_string),_types=__webpack_require__(4),_types2=_interopRequireDefault(_types),ColOps=function(){function ColOps(e,t){_classCallCheck(this,ColOps),this.onBeforeOperation=_types2["default"].isFn(t.on_before_operation)?t.on_before_operation:null,this.onAfterOperation=_types2["default"].isFn(t.on_after_operation)?t.on_after_operation:null,this.opts=t,this.tf=e}return _createClass(ColOps,[{key:"init",value:function(){var e=this;this.tf.emitter.on(["after-filtering"],function(){return e.calc()}),this.calc()}},{key:"calc",value:function calc(){var tf=this.tf;if(tf.hasGrid()){this.onBeforeOperation&&this.onBeforeOperation.call(null,tf);var opts=this.opts,labelId=opts.id,colIndex=opts.col,operation=opts.operation,outputType=opts.write_method,totRowIndex=opts.tot_row_index,excludeRow=opts.exclude_row,decimalPrecision=_types2["default"].isUndef(opts.decimal_precision)?2:opts.decimal_precision,ucolIndex=[],ucolMax=0;ucolIndex[ucolMax]=colIndex[0];for(var ii=1;ii<colIndex.length;ii++){for(var saved=0,jj=0;ucolMax>=jj;jj++)ucolIndex[jj]===colIndex[ii]&&(saved=1);0===saved&&(ucolMax++,ucolIndex[ucolMax]=colIndex[ii])}if("object"==_string2["default"].lower("undefined"==typeof labelId?"undefined":_typeof(labelId))&&"object"==_string2["default"].lower("undefined"==typeof colIndex?"undefined":_typeof(colIndex))&&"object"==_string2["default"].lower("undefined"==typeof operation?"undefined":_typeof(operation)))for(var rows=tf.tbl.rows,colvalues=[],ucol=0;ucolMax>=ucol;ucol++){colvalues.push(tf.getColValues(ucolIndex[ucol],!1,!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;k<colIndex.length;k++)if(colIndex[k]===ucolIndex[ucol])switch(mThisCol++,opsThisCol[mThisCol]=_string2["default"].lower(operation[k]),decThisCol[mThisCol]=decimalPrecision[k],labThisCol[mThisCol]=labelId[k],oTypeThisCol=void 0!==outputType&&"object"===_string2["default"].lower("undefined"==typeof outputType?"undefined":_typeof(outputType))?outputType[k]:null,opsThisCol[mThisCol]){case"mean":meanFlag=1;break;case"sum":sumFlag=1;break;case"min":minFlag=1;break;case"max":maxFlag=1;break;case"median":medFlag=1;break;case"q1":q1Flag=1;break;case"q3":q3Flag=1}for(var j=0;j<colvalues[ucol].length;j++){if((1==q1Flag||1==q3Flag||1==medFlag)&&j<colvalues[ucol].length-1)for(k=j+1;k<colvalues[ucol].length;k++)eval(colvalues[ucol][k])<eval(colvalues[ucol][j])&&(temp=colvalues[ucol][j],colvalues[ucol][j]=colvalues[ucol][k],colvalues[ucol][k]=temp);var cvalue=parseFloat(colvalues[ucol][j]);theList[j]=parseFloat(cvalue),isNaN(cvalue)||(nbvalues++,(1===sumFlag||1===meanFlag)&&(sumValue+=parseFloat(cvalue)),1===minFlag&&(minValue=null===minValue?parseFloat(cvalue):parseFloat(cvalue)<minValue?parseFloat(cvalue):minValue),1===maxFlag&&(maxValue=null===maxValue?parseFloat(cvalue):parseFloat(cvalue)>maxValue?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(){var e=this;this.tf.emitter.off(["after-filtering"],function(){return e.calc()})}}]),ColOps}();exports["default"]=ColOps},31:function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),l=n(2),o=r(l),a=n(4),d=r(a),u=n(1),c=r(u),h=function(){function e(t,n){s(this,e);var r=t.config();this.initialized=!1,this.name=n.name,this.desc=n.description||"Columns visibility manager",this.spanEl=null,this.btnEl=null,this.contEl=null,this.tickToHide=n.tick_to_hide===!1?!1:!0,this.manager=n.manager===!1?!1:!0,this.headersTbl=n.headers_table||!1,this.headersIndex=n.headers_index||1,this.contElTgtId=n.container_target_id||null,this.headersText=n.headers_text||null,this.btnTgtId=n.btn_target_id||null,this.btnText=n.btn_text||"Columns&#9660;",this.btnHtml=n.btn_html||null,this.btnCssClass=n.btn_css_class||"colVis",this.btnCloseText=n.btn_close_text||"Close",this.btnCloseHtml=n.btn_close_html||null,this.btnCloseCssClass=n.btn_close_css_class||this.btnCssClass,this.stylesheet=n.stylesheet||"colsVisibility.css",this.prfx="colVis_",this.spanCssClass=n.span_css_class||"colVisSpan",this.prfxCont=this.prfx+"Cont_",this.contCssClass=n.cont_css_class||"colVisCont",this.listCssClass=r.list_css_class||"cols_checklist",this.listItemCssClass=r.checklist_item_css_class||"cols_checklist_item",this.listSlcItemCssClass=r.checklist_selected_item_css_class||"cols_checklist_slc_item",this.text=n.text||(this.tickToHide?"Hide: ":"Show: "),this.atStart=n.at_start||null,this.enableHover=Boolean(n.enable_hover),this.enableTickAll=Boolean(n.enable_tick_all),this.tickAllText=n.tick_all_text||"Select all:",this.hiddenCols=[],this.tblHasColTag=o["default"].tag(t.tbl,"col").length>0,this.onLoaded=d["default"].isFn(n.on_loaded)?n.on_loaded:null,this.onBeforeOpen=d["default"].isFn(n.on_before_open)?n.on_before_open:null,this.onAfterOpen=d["default"].isFn(n.on_after_open)?n.on_after_open:null,this.onBeforeClose=d["default"].isFn(n.on_before_close)?n.on_before_close:null,this.onAfterClose=d["default"].isFn(n.on_after_close)?n.on_after_close:null,this.onBeforeColHidden=d["default"].isFn(n.on_before_col_hidden)?n.on_before_col_hidden:null,this.onAfterColHidden=d["default"].isFn(n.on_after_col_hidden)?n.on_after_col_hidden:null,this.onBeforeColDisplayed=d["default"].isFn(n.on_before_col_displayed)?n.on_before_col_displayed:null,this.onAfterColDisplayed=d["default"].isFn(n.on_after_col_displayed)?n.on_after_col_displayed:null,t.gridLayout&&(this.headersTbl=t.feature("gridLayout").headTbl,this.headersIndex=0,this.onAfterColDisplayed=function(){},this.onAfterColHidden=function(){}),t["import"](n.name+"Style",t.stylePath+this.stylesheet,null,"link"),this.tf=t}return i(e,[{key:"toggle",value:function(){var e=this.contEl.style.display,t=this.onBeforeOpen,n=this.onBeforeClose,r=this.onAfterOpen,s=this.onAfterClose;t&&"inline"!==e&&t.call(null,this),n&&"inline"===e&&n.call(null,this),this.contEl.style.display="inline"===e?"none":"inline",r&&"inline"!==e&&r.call(null,this),s&&"inline"===e&&s.call(null,this)}},{key:"checkItem",value:function(e){var t=e.parentNode;if(t&&e){var n=e.firstChild.checked,r=e.firstChild.getAttribute("id").split("_")[1];r=parseInt(r,10),n?o["default"].addClass(t,this.listSlcItemCssClass):o["default"].removeClass(t,this.listSlcItemCssClass);var s=!1;(this.tickToHide&&n||!this.tickToHide&&!n)&&(s=!0),this.setHidden(r,s)}}},{key:"init",value:function(){this.manager&&(this.buildBtn(),this.buildManager(),this.initialized=!0)}},{key:"buildBtn",value:function(){var e=this;if(!this.btnEl){var t=this.tf,n=o["default"].create("span",["id",this.prfx+t.id]);n.className=this.spanCssClass,this.btnTgtId||t.setToolbar();var r=this.btnTgtId?o["default"].id(this.btnTgtId):t.rDiv;if(this.btnTgtId)r.appendChild(n);else{var s=r.firstChild;s.parentNode.insertBefore(n,s)}if(this.btnHtml){n.innerHTML=this.btnHtml;var i=n.firstChild;this.enableHover?c["default"].add(i,"mouseover",function(t){e.toggle(t)}):c["default"].add(i,"click",function(t){e.toggle(t)})}else{var l=o["default"].create("a",["href","javascript:;"]);l.className=this.btnCssClass,l.title=this.desc,l.innerHTML=this.btnText,n.appendChild(l),this.enableHover?c["default"].add(l,"mouseover",function(t){e.toggle(t)}):c["default"].add(l,"click",function(t){e.toggle(t)})}this.spanEl=n,this.btnEl=this.spanEl.firstChild,this.onLoaded&&this.onLoaded.call(null,this)}}},{key:"buildManager",value:function(){var e=this,t=this.tf,n=this.contElTgtId?o["default"].id(this.contElTgtId):o["default"].create("div",["id",this.prfxCont+t.id]);n.className=this.contCssClass;var r=o["default"].create("p");r.innerHTML=this.text,n.appendChild(r);var s=o["default"].create("ul",["id","ul"+this.name+"_"+t.id]);s.className=this.listCssClass;var i=this.headersTbl?this.headersTbl:t.tbl,l=this.headersTbl?this.headersIndex:t.getHeadersRowIndex(),a=i.rows[l];if(this.enableTickAll){var d=o["default"].createCheckItem("col__"+t.id,this.tickAllText,this.tickAllText);o["default"].addClass(d,this.listItemCssClass),s.appendChild(d),d.check.checked=!this.tickToHide,c["default"].add(d.check,"click",function(){for(var e=0;e<a.cells.length;e++){var n=o["default"].id("col_"+e+"_"+t.id);n&&d.check.checked!==n.checked&&(n.click(),n.checked=d.check.checked)}})}for(var u=0;u<a.cells.length;u++){var h=a.cells[u],f=this.headersText&&this.headersText[u]?this.headersText[u]:this._getHeaderText(h),p=o["default"].createCheckItem("col_"+u+"_"+t.id,f,f);o["default"].addClass(p,this.listItemCssClass),this.tickToHide||o["default"].addClass(p,this.listSlcItemCssClass),s.appendChild(p),this.tickToHide||(p.check.checked=!0),c["default"].add(p.check,"click",function(t){var n=c["default"].target(t),r=n.parentNode;e.checkItem(r)})}var b,m=o["default"].create("p",["align","center"]);if(this.btnCloseHtml?(m.innerHTML=this.btnCloseHtml,b=m.firstChild,c["default"].add(b,"click",function(t){e.toggle(t)})):(b=o["default"].create("a",["href","javascript:;"]),b.className=this.btnCloseCssClass,b.innerHTML=this.btnCloseText,c["default"].add(b,"click",function(t){e.toggle(t)}),m.appendChild(b)),n.appendChild(s),n.appendChild(m),this.btnEl.parentNode.insertBefore(n,this.btnEl),this.contEl=n,this.atStart)for(var g=this.atStart,y=0;y<g.length;y++){var v=o["default"].id("col_"+g[y]+"_"+t.id);v&&v.click()}}},{key:"setHidden",value:function(e,t){var n=this.tf,r=n.tbl;this.onBeforeColHidden&&t&&this.onBeforeColHidden.call(null,this,e),this.onBeforeColDisplayed&&!t&&this.onBeforeColDisplayed.call(null,this,e),this._hideCells(r,e,t),this.headersTbl&&this._hideCells(this.headersTbl,e,t);var s=this.hiddenCols,i=s.indexOf(e);t?-1===i&&this.hiddenCols.push(e):-1!==i&&this.hiddenCols.splice(i,1);var l,o,a;if(this.onAfterColHidden&&t){if(n.gridLayout){l=n.feature("gridLayout"),o=l.headTbl,a=l.gridColElms;var d=parseInt(a[e].style.width,10),u=parseInt(o.style.width,10);o.style.width=u-d+"px",r.style.width=o.style.width}this.onAfterColHidden.call(null,this,e)}if(this.onAfterColDisplayed&&!t){if(n.gridLayout){l=n.feature("gridLayout"),o=l.headTbl,a=l.gridColElms;var c=parseInt(a[e].style.width,10);o.style.width=parseInt(o.style.width,10)+c+"px",n.tbl.style.width=o.style.width}this.onAfterColDisplayed.call(null,this,e)}}},{key:"showCol",value:function(e){if(void 0!==e&&this.isColHidden(e))if(this.manager&&this.contEl){var t=o["default"].id("col_"+e+"_"+this.tf.id);t&&t.click()}else this.setHidden(e,!1)}},{key:"hideCol",value:function(e){if(void 0!==e&&!this.isColHidden(e))if(this.manager&&this.contEl){var t=o["default"].id("col_"+e+"_"+this.tf.id);t&&t.click()}else this.setHidden(e,!0)}},{key:"isColHidden",value:function(e){return-1!==this.hiddenCols.indexOf(e)?!0:!1}},{key:"toggleCol",value:function(e){void 0===e||this.isColHidden(e)?this.showCol(e):this.hideCol(e)}},{key:"getHiddenCols",value:function(){return this.hiddenCols}},{key:"destroy",value:function(){(this.btnEl||this.contEl)&&(o["default"].id(this.contElTgtId)?o["default"].id(this.contElTgtId).innerHTML="":(this.contEl.innerHTML="",o["default"].remove(this.contEl),this.contEl=null),this.btnEl.innerHTML="",o["default"].remove(this.btnEl),this.btnEl=null,this.initialized=!1)}},{key:"_getHeaderText",value:function(e){if(!e.hasChildNodes)return"";for(var t=0;t<e.childNodes.length;t++){var n=e.childNodes[t];if(3===n.nodeType)return n.nodeValue;if(1===n.nodeType){if(n.id&&-1!==n.id.indexOf("popUp"))continue;return o["default"].getText(n)}}return""}},{key:"_hideCells",value:function(e,t,n){for(var r=0;r<e.rows.length;r++){var s=e.rows[r],i=s.cells[t];i&&(i.style.display=n?"none":"")}}}]),e}();t["default"]=h},32:function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),l=n(2),o=r(l),a=n(4),d=r(a),u=n(1),c=r(u),h=function(){function e(t,n){s(this,e),this.initialized=!1,this.name=n.name,this.desc=n.description||"Filters row visibility manager",this.stylesheet=n.stylesheet||"filtersVisibility.css",this.icnExpand=n.expand_icon_name||"icn_exp.png",this.icnCollapse=n.collapse_icon_name||"icn_clp.png",this.contEl=null,this.btnEl=null,this.icnExpandHtml='<img src="'+t.themesPath+this.icnExpand+'" alt="Expand filters" >',this.icnCollapseHtml='<img src="'+t.themesPath+this.icnCollapse+'" alt="Collapse filters" >',this.defaultText="Toggle filters",this.targetId=n.target_id||null,this.enableIcon=n.enable_icon===!1?!1:!0,this.btnText=n.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=n.btn_html||null,this.btnCssClass=n.btn_css_class||"btnExpClpFlt",this.contCssClass=n.cont_css_class||"expClpFlt",this.filtersRowIndex=d["default"].isUndef(n.filters_row_index)?t.getFiltersRowIndex():n.filters_row_index,this.visibleAtStart=d["default"].isUndef(n.visible_at_start)?!0:Boolean(n.visible_at_start),this.prfx="fltsVis_",this.onBeforeShow=d["default"].isFn(n.on_before_show)?n.on_before_show:null,this.onAfterShow=d["default"].isFn(n.on_after_show)?n.on_after_show:null,this.onBeforeHide=d["default"].isFn(n.on_before_hide)?n.on_before_hide:null,this.onAfterHide=d["default"].isFn(n.on_after_hide)?n.on_after_hide:null,t["import"](n.name+"Style",t.stylePath+this.stylesheet,null,"link"),this.tf=t}return i(e,[{key:"init",value:function(){this.initialized||(this.buildUI(),this.initialized=!0)}},{key:"buildUI",value:function(){var e=this,t=this.tf,n=o["default"].create("span",["id",this.prfx+t.id]);n.className=this.contCssClass,this.targetId||t.setToolbar();var r=this.targetId?o["default"].id(this.targetId):t.rDiv;if(this.targetId)r.appendChild(n);else{var s=r.firstChild;s.parentNode.insertBefore(n,s)}var i=void 0;this.btnHtml?(n.innerHTML=this.btnHtml,i=n.firstChild):(i=o["default"].create("a",["href","javascript:void(0);"]),i.className=this.btnCssClass,i.title=this.btnText||this.defaultText,i.innerHTML=this.collapseBtnHtml,n.appendChild(i)),c["default"].add(i,"click",function(){return e.toggle()}),this.contEl=n,this.btnEl=i,this.visibleAtStart||this.toggle()}},{key:"toggle",value:function(){var e=this.tf,t=e.gridLayout?e.feature("gridLayout").headTbl:e.tbl,n=t.rows[this.filtersRowIndex],r=n.style.display;this.onBeforeShow&&""!==r&&this.onBeforeShow.call(this,this),this.onBeforeHide&&""===r&&this.onBeforeHide.call(null,this),n.style.display=""===r?"none":"",this.enableIcon&&!this.btnHtml&&(this.btnEl.innerHTML=""===r?this.expandBtnHtml:this.collapseBtnHtml),this.onAfterShow&&""!==r&&this.onAfterShow.call(null,this),this.onAfterHide&&""===r&&this.onAfterHide.call(null,this)}},{key:"destroy",value:function(){(this.btnEl||this.contEl)&&(this.btnEl.innerHTML="",o["default"].remove(this.btnEl),this.btnEl=null,this.contEl.innerHTML="",o["default"].remove(this.contEl),this.contEl=null,this.initialized=!1)}}]),e}();t["default"]=h},33:function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e){return S["default"].removeNbFormat(e,"us")}function l(e){return S["default"].removeNbFormat(e,"eu")}function o(e,t){return C["default"].format(e,t)}function a(e){return o(e,"DMY")}function d(e){return o(e,"MDY")}function u(e){return o(e,"YMD")}function c(e){return o(e,"DDMMMYYYY")}function h(e){var t=e.split(".");for(var n in t){for(var r=t[n];3>r.length;)r="0"+r;t[n]=r}return t.join(".")}function f(e,t){var n=h(e.value.toLowerCase()),r=h(t.value.toLowerCase());return n==r?0:r>n?-1:1}Object.defineProperty(t,"__esModule",{value:!0});var p=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),b=n(4),m=r(b),g=n(2),y=r(g),v=n(1),T=r(v),_=n(5),C=r(_),w=n(6),S=r(w),x=function(){function e(t,n){s(this,e),this.initialized=!1,this.name=n.name,this.desc=n.description||"Sortable table",this.sorted=!1,this.sortTypes=m["default"].isArray(n.types)?n.types:[],this.sortColAtStart=m["default"].isArray(n.sort_col_at_start)?n.sort_col_at_start:null,this.asyncSort=Boolean(n.async_sort),this.triggerIds=m["default"].isArray(n.trigger_ids)?n.trigger_ids:[],this.imgPath=n.images_path||t.themesPath,this.imgBlank=n.image_blank||"blank.png",this.imgClassName=n.image_class_name||"sort-arrow",this.imgAscClassName=n.image_asc_class_name||"ascending",this.imgDescClassName=n.image_desc_class_name||"descending",this.customKey=n.custom_key||"data-tf-sortKey",this.onSortLoaded=m["default"].isFn(n.on_sort_loaded)?n.on_sort_loaded:null,this.onBeforeSort=m["default"].isFn(n.on_before_sort)?n.on_before_sort:null,this.onAfterSort=m["default"].isFn(n.on_after_sort)?n.on_after_sort:null,this.tf=t,this.emitter=t.emitter}return p(e,[{key:"init",value:function(){var e=this.tf,t=this;if(m["default"].isUndef(SortableTable))throw new Error("SortableTable class not found.");this.overrideSortableTable(),this.setSortTypes();var n=t.sortColAtStart;n&&this.stt.sort(n[0],n[1]),this.onSortLoaded&&this.onSortLoaded.call(null,e,this),this.stt.onbeforesort=function(){t.onBeforeSort&&t.onBeforeSort.call(null,e,t.stt.sortColumn),e.paging&&e.feature("paging").disable()},this.stt.onsort=function(){if(t.sorted=!0,e.paging){var n=e.feature("paging");e.getValidRows(!0),n.enable(),n.setPage(n.getPage())}t.onAfterSort&&t.onAfterSort.call(null,e,t.stt.sortColumn),t.emitter.emit("column-sorted",e,t.stt.sortColumn)},this.initialized=!0}},{key:"sortByColumnIndex",value:function(e,t){this.stt.sort(e,t)}},{key:"overrideSortableTable",value:function(){var e=this,t=this.tf;SortableTable.prototype.headerOnclick=function(t){if(e.initialized){for(var n=t.target||t.srcElement;"TD"!==n.tagName&&"TH"!==n.tagName;)n=n.parentNode;this.sort(SortableTable.msie?SortableTable.getCellIndex(n):n.cellIndex)}},SortableTable.getCellIndex=function(e){var t=e.parentNode.cells,n=t.length,r=void 0;for(r=0;t[r]!=e&&n>r;r++);return r},SortableTable.prototype.initHeader=function(n){var r=this;if(!r.tHead){if(!t.gridLayout)return;r.tHead=t.feature("gridLayout").headTbl.tHead}r.headersRow=t.headersRow;var s=r.tHead.rows[r.headersRow].cells;r.sortTypes=n||[];for(var i=s.length,l=void 0,o=void 0,a=0;i>a;a++)o=s[a],null!==r.sortTypes[a]&&"None"!==r.sortTypes[a]?(o.style.cursor="pointer",l=y["default"].create("img",["src",e.imgPath+e.imgBlank]),o.appendChild(l),null!==r.sortTypes[a]&&o.setAttribute("_sortType",r.sortTypes[a]),T["default"].add(o,"click",r._headerOnclick)):(o.setAttribute("_sortType",n[a]),o._sortType="None");r.updateHeaderArrows()},SortableTable.prototype.updateHeaderArrows=function(){var t=this,n=void 0,r=void 0,s=void 0;if(e.asyncSort&&e.triggerIds.length>0){var i=e.triggerIds;n=[],r=i.length;for(var l=0;l<i.length;l++)n.push(y["default"].id(i[l]))}else{if(!this.tHead)return;n=t.tHead.rows[t.headersRow].cells,r=n.length}for(var o=0;r>o;o++){var a=n[o].getAttribute("_sortType");null!==a&&"None"!==a&&(s=n[o].lastChild||n[o],"img"!==s.nodeName.toLowerCase()&&(s=y["default"].create("img",["src",e.imgPath+e.imgBlank]),n[o].appendChild(s)),o===t.sortColumn?s.className=e.imgClassName+" "+(this.descending?e.imgDescClassName:e.imgAscClassName):s.className=e.imgClassName)}},SortableTable.prototype.getRowValue=function(e,t,n){var r=this,s=r._sortTypeInfo[t];if(s&&s.getRowValue)return s.getRowValue(e,n);var i=e.cells[n],l=SortableTable.getInnerText(i);return r.getValueFromString(l,t)},SortableTable.getInnerText=function(t){return t?t.getAttribute(e.customKey)?t.getAttribute(e.customKey):y["default"].getText(t):void 0}}},{key:"addSortType",value:function(){var e=arguments;SortableTable.prototype.addSortType(e[0],e[1],e[2],e[3])}},{key:"setSortTypes",value:function(){for(var e=this,t=this.tf,n=this.sortTypes,r=[],s=0;s<t.nbCells;s++){var o=void 0;n[s]?(o=n[s].toLowerCase(),"none"===o&&(o="None")):o=t.hasColNbFormat&&null!==t.colNbFormat[s]?t.colNbFormat[s].toLowerCase():t.hasColDateType&&null!==t.colDateType[s]?t.colDateType[s].toLowerCase()+"date":"String",r.push(o)}this.addSortType("number",Number),this.addSortType("caseinsensitivestring",SortableTable.toUpperCase),this.addSortType("date",SortableTable.toDate),this.addSortType("string"),this.addSortType("us",i),this.addSortType("eu",l),this.addSortType("dmydate",a),this.addSortType("ymddate",u),this.addSortType("mdydate",d),this.addSortType("ddmmmyyyydate",c),this.addSortType("ipaddress",h,f),
this.stt=new SortableTable(t.tbl,r),this.asyncSort&&this.triggerIds.length>0&&!function(){for(var t=e.triggerIds,n=0;n<t.length;n++)if(null!==t[n]){var s=y["default"].id(t[n]);s&&(s.style.cursor="pointer",T["default"].add(s,"click",function(n){var r=n.target;e.tf.sort&&e.stt.asyncSort(t.indexOf(r.id))}),s.setAttribute("_sortType",r[n]))}}()}},{key:"destroy",value:function(){var e=this.tf;this.sorted=!1,this.initialized=!1,this.stt.destroy();for(var t=e.getFiltersId(),n=0;n<t.length;n++){var r=e.getHeaderElement(n),s=y["default"].tag(r,"img");1===s.length&&r.removeChild(s[0])}}}]),e}();t["default"]=x},34:function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var s=n(33),i=r(s);window.SortableTable||n(35),t["default"]=i["default"]},35:function(e,t,n){n(36)(n(37))},36:function(e,t){e.exports=function(e){"function"==typeof execScript?execScript(e):eval.call(null,e)}},37:function(e,t){e.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 this.sortTypes = oSortTypes || [];\r\n\r\n this.sortColumn = null;\r\n this.descending = null;\r\n\r\n var oThis = this;\r\n this._headerOnclick = function (e) {\r\n oThis.headerOnclick(e);\r\n };\r\n\r\n if (oTable) {\r\n this.setTable( oTable );\r\n this.document = oTable.ownerDocument || oTable.document;\r\n }\r\n else {\r\n this.document = document;\r\n }\r\n\r\n\r\n // only IE needs this\r\n var win = this.document.defaultView || this.document.parentWindow;\r\n this._onunload = function () {\r\n oThis.destroy();\r\n };\r\n if (win && typeof win.attachEvent != "undefined") {\r\n win.attachEvent("onunload", this._onunload);\r\n }\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 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'}});