mirror of
https://github.com/koalyptus/TableFilter.git
synced 2026-03-16 15:45:45 +01:00
branch: master
SHA: d558667586
range SHA: 03aaf7f65019...d558667586d9
build id: 128601660
build number: 301
8 lines
No EOL
46 KiB
JavaScript
8 lines
No EOL
46 KiB
JavaScript
/**
|
|
* tablefilter v0.2.20 by Max Guglielmi
|
|
* build date: 2016-05-08T03:24:51.178Z
|
|
* MIT License
|
|
*/
|
|
|
|
webpackJsonp([1],{29:function(e,t,n){function i(e){return n(s(e))}function s(e){return o[e]||function(){throw new Error("Cannot find module '"+e+"'.")}()}var o={"./array":15,"./array.js":15,"./const":10,"./const.js":10,"./cookie":28,"./cookie.js":28,"./date":5,"./date.js":5,"./dom":2,"./dom.js":2,"./emitter":7,"./emitter.js":7,"./event":1,"./event.js":1,"./extensions/advancedGrid/adapterEzEditTable":30,"./extensions/advancedGrid/adapterEzEditTable.js":30,"./extensions/advancedGrid/advancedGrid":31,"./extensions/advancedGrid/advancedGrid.js":31,"./extensions/colOps/colOps":32,"./extensions/colOps/colOps.js":32,"./extensions/colsVisibility/colsVisibility":33,"./extensions/colsVisibility/colsVisibility.js":33,"./extensions/filtersVisibility/filtersVisibility":34,"./extensions/filtersVisibility/filtersVisibility.js":34,"./extensions/sort/adapterSortabletable":35,"./extensions/sort/adapterSortabletable.js":35,"./extensions/sort/sort":36,"./extensions/sort/sort.js":36,"./helpers":6,"./helpers.js":6,"./modules/alternateRows":23,"./modules/alternateRows.js":23,"./modules/checkList":17,"./modules/checkList.js":17,"./modules/clearButton":21,"./modules/clearButton.js":21,"./modules/dropdown":14,"./modules/dropdown.js":14,"./modules/feature":9,"./modules/feature.js":9,"./modules/gridLayout":8,"./modules/gridLayout.js":8,"./modules/hash":26,"./modules/hash.js":26,"./modules/help":22,"./modules/help.js":22,"./modules/highlightKeywords":12,"./modules/highlightKeywords.js":12,"./modules/loader":11,"./modules/loader.js":11,"./modules/noResults":24,"./modules/noResults.js":24,"./modules/paging":20,"./modules/paging.js":20,"./modules/popupFilter":13,"./modules/popupFilter.js":13,"./modules/rowsCounter":18,"./modules/rowsCounter.js":18,"./modules/state":25,"./modules/state.js":25,"./modules/statusBar":19,"./modules/statusBar.js":19,"./modules/storage":27,"./modules/storage.js":27,"./sort":16,"./sort.js":16,"./string":4,"./string.js":4,"./types":3,"./types.js":3};i.keys=function(){return Object.keys(o)},i.resolve=s,e.exports=i,i.id=29},30:function(e,t,n){"use strict";function i(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 o=n(2),l=i(o),a=n(10),r=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 e.prototype.init=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()})},e.prototype._setAdvancedGrid=function(){var e,t=this.tf,n=this.cfg,i=l["default"].tag(t.tbl,"thead");e=i.length>0&&!n.startRow?void 0:n.startRow||t.refRow,n.base_path=n.base_path||t.basePath+"ezEditTable/";var s=n.editable,o=n.selection;o&&(n.default_selection=n.default_selection||"row"),n.active_cell_css=n.active_cell_css||"ezETSelectedCell";var a=0,r=0;if(o){var d=function(e,n,i){var s=e.Selection,o=function(i){if("row"===e.defaultSelection)s.SelectRowByIndex(i);else{e.ClearSelections();var o=n.cellIndex,l=t.tbl.rows[i];"both"===e.defaultSelection&&s.SelectRowByIndex(i),l&&s.SelectCell(l.cells[o])}if(t.validRowsIndex.length!==t.getRowsNb()){var a=t.tbl.rows[i];a&&a.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 l,d=t.validRowsIndex,c=d.length,u="row"!==e.defaultSelection?n.parentNode:n,h="TD"===n.nodeName?n:null,f=void 0!==i?e.Event.GetKey(i):0,p=-1!==d.indexOf(u.rowIndex),b=t.feature("paging"),m=34===f||33===f?b&&b.pagingLength||e.nbRowsPerPage:1;if(p)34!==f&&33!==f?(a=d.indexOf(u.rowIndex),r=u.rowIndex):(l=34===f?c-1>=a+m?d[a+m]:[c-1]:a-m<=d[0]?d[0]:d[a-m],r=l,a=d.indexOf(l),o(l));else{if(u.rowIndex>r)if(u.rowIndex>=d[c-1])l=d[c-1];else{var y=a+m;l=y>c-1?d[c-1]:d[y]}else if(u.rowIndex<=d[0])l=d[0];else{var g=d[a-m];l=g?g:d[0]}r=u.rowIndex,o(l)}}},c=function(e,n){var i="row"!==e.defaultSelection?n.parentNode:n;if(t.paging&&t.feature("paging").nbPages>1){var s=t.feature("paging");e.nbRowsPerPage=s.pagingLength;var o=t.validRowsIndex,l=o.length,a=parseInt(s.startPagingRow,10)+parseInt(s.pagingLength,10),r=i.rowIndex;r===o[l-1]&&s.currentPageNb!==s.nbPages?s.setPage("last"):r==o[0]&&1!==s.currentPageNb?s.setPage("first"):r>o[a-1]&&r<o[l-1]?s.setPage("next"):r<o[s.startPagingRow]&&r>o[0]&&s.setPage("previous")}};if(t.paging&&(t.feature("paging").onAfterChangePage=function(e){var t=e.tf.extension("advancedGrid"),n=t._ezEditTable,i=n.Selection,s=i.GetActiveRow();s&&s.scrollIntoView(!1);var o=i.GetActiveCell();o&&o.scrollIntoView(!1)}),"row"===n.default_selection){var u=n.on_before_selected_row;n.on_before_selected_row=function(){c(arguments[0],arguments[1],arguments[2]),u&&u.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(){c(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(y){throw new Error(this.err)}this.initialized=!0},e.prototype.reset=function(){var e=this._ezEditTable;e&&(this.cfg.selection&&e.Selection.Set(),this.cfg.editable&&e.Editable.Set())},e.prototype.toggle=function(){var e=this._ezEditTable;e.editable?e.Editable.Remove():e.Editable.Set(),e.selection?e.Selection.Remove():e.Selection.Set()},e.prototype._toggleForInputFilter=function(){var e=this.tf;if(e.getActiveFilterId()){var t=e.getColumnIndexFromFilterId(e.getActiveFilterId()),n=e.getFilterType(t);n===a.INPUT&&this.toggle()}},e.prototype.destroy=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"]=r},31:function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var s=n(30),o=i(s);t["default"]=o["default"]},32: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},_dom=__webpack_require__(2),_dom2=_interopRequireDefault(_dom),_string=__webpack_require__(4),_string2=_interopRequireDefault(_string),_types=__webpack_require__(3),_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 ColOps.prototype.init=function(){var e=this;this.tf.emitter.on(["after-filtering"],function(){return e.calc()}),this.calc()},ColOps.prototype.calc=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)}},ColOps.prototype.destroy=function(){var e=this;this.tf.emitter.off(["after-filtering"],function(){return e.calc()})},ColOps}();exports["default"]=ColOps},33:function(e,t,n){"use strict";function i(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 o=n(2),l=i(o),a=n(3),r=i(a),d=n(1),c=i(d),u=function(){function e(t,n){s(this,e);var i=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,this.manager=n.manager!==!1,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▼",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=i.list_css_class||"cols_checklist",this.listItemCssClass=i.checklist_item_css_class||"cols_checklist_item",this.listSlcItemCssClass=i.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=l["default"].tag(t.tbl,"col").length>0,this.onLoaded=r["default"].isFn(n.on_loaded)?n.on_loaded:null,this.onBeforeOpen=r["default"].isFn(n.on_before_open)?n.on_before_open:null,this.onAfterOpen=r["default"].isFn(n.on_after_open)?n.on_after_open:null,this.onBeforeClose=r["default"].isFn(n.on_before_close)?n.on_before_close:null,this.onAfterClose=r["default"].isFn(n.on_after_close)?n.on_after_close:null,this.onBeforeColHidden=r["default"].isFn(n.on_before_col_hidden)?n.on_before_col_hidden:null,this.onAfterColHidden=r["default"].isFn(n.on_after_col_hidden)?n.on_after_col_hidden:null,this.onBeforeColDisplayed=r["default"].isFn(n.on_before_col_displayed)?n.on_before_col_displayed:null,this.onAfterColDisplayed=r["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,this.emitter=t.emitter}return e.prototype.toggle=function(){var e=this.contEl.style.display,t=this.onBeforeOpen,n=this.onBeforeClose,i=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",i&&"inline"!==e&&i.call(null,this),s&&"inline"===e&&s.call(null,this)},e.prototype.checkItem=function(e){var t=e.parentNode;if(t&&e){var n=e.firstChild.checked,i=e.firstChild.getAttribute("id").split("_")[1];i=parseInt(i,10),n?l["default"].addClass(t,this.listSlcItemCssClass):l["default"].removeClass(t,this.listSlcItemCssClass);var s=!1;(this.tickToHide&&n||!this.tickToHide&&!n)&&(s=!0),this.setHidden(i,s)}},e.prototype.init=function(){var e=this;this.manager&&(this.emitter.on(["hide-column"],function(t,n){return e.hideCol(n)}),this.buildBtn(),this.buildManager(),this.initialized=!0,this.emitter.emit("columns-visibility-initialized",this.tf,this),this._hideAtStart())},e.prototype.buildBtn=function(){var e=this;if(!this.btnEl){var t=this.tf,n=l["default"].create("span",["id",this.prfx+t.id]);n.className=this.spanCssClass,this.btnTgtId||t.setToolbar();var i=this.btnTgtId?l["default"].id(this.btnTgtId):t.rDiv;if(this.btnTgtId)i.appendChild(n);else{var s=i.firstChild;s.parentNode.insertBefore(n,s)}if(this.btnHtml){n.innerHTML=this.btnHtml;var o=n.firstChild;this.enableHover?c["default"].add(o,"mouseover",function(t){return e.toggle(t)}):c["default"].add(o,"click",function(t){return e.toggle(t)})}else{var a=l["default"].create("a",["href","javascript:;"]);a.className=this.btnCssClass,a.title=this.desc,a.innerHTML=this.btnText,n.appendChild(a),this.enableHover?c["default"].add(a,"mouseover",function(t){return e.toggle(t)}):c["default"].add(a,"click",function(t){return e.toggle(t)})}this.spanEl=n,this.btnEl=this.spanEl.firstChild,this.onLoaded&&this.onLoaded.call(null,this)}},e.prototype.buildManager=function(){var e=this,t=this.tf,n=this.contElTgtId?l["default"].id(this.contElTgtId):l["default"].create("div",["id",this.prfxCont+t.id]);n.className=this.contCssClass;var i=l["default"].create("p");i.innerHTML=this.text,n.appendChild(i);var s=l["default"].create("ul",["id","ul"+this.name+"_"+t.id]);s.className=this.listCssClass;var o=this.headersTbl?this.headersTbl:t.tbl,a=this.headersTbl?this.headersIndex:t.getHeadersRowIndex(),r=o.rows[a];this.enableTickAll&&!function(){var n=l["default"].createCheckItem("col__"+t.id,e.tickAllText,e.tickAllText);l["default"].addClass(n,e.listItemCssClass),s.appendChild(n),n.check.checked=!e.tickToHide,c["default"].add(n.check,"click",function(){for(var e=0;e<r.cells.length;e++){var i=l["default"].id("col_"+e+"_"+t.id);i&&n.check.checked!==i.checked&&(i.click(),i.checked=n.check.checked)}})}();for(var d=0;d<r.cells.length;d++){var u=r.cells[d],h=this.headersText&&this.headersText[d]?this.headersText[d]:this._getHeaderText(u),f=l["default"].createCheckItem("col_"+d+"_"+t.id,h,h);l["default"].addClass(f,this.listItemCssClass),this.tickToHide||l["default"].addClass(f,this.listSlcItemCssClass),s.appendChild(f),this.tickToHide||(f.check.checked=!0),c["default"].add(f.check,"click",function(t){var n=c["default"].target(t),i=n.parentNode;e.checkItem(i)})}var p=l["default"].create("p",["align","center"]),b=void 0;this.btnCloseHtml?(p.innerHTML=this.btnCloseHtml,b=p.firstChild,c["default"].add(b,"click",function(t){return e.toggle(t)})):(b=l["default"].create("a",["href","javascript:;"]),b.className=this.btnCloseCssClass,b.innerHTML=this.btnCloseText,c["default"].add(b,"click",function(t){return e.toggle(t)}),p.appendChild(b)),n.appendChild(s),n.appendChild(p),this.btnEl.parentNode.insertBefore(n,this.btnEl),this.contEl=n},e.prototype.setHidden=function(e,t){var n=this.tf,i=n.tbl;this.onBeforeColHidden&&t&&this.onBeforeColHidden.call(null,this,e),this.onBeforeColDisplayed&&!t&&this.onBeforeColDisplayed.call(null,this,e),this._hideCells(i,e,t),this.headersTbl&&this._hideCells(this.headersTbl,e,t);var s=this.hiddenCols,o=s.indexOf(e);t?-1===o&&this.hiddenCols.push(e):-1!==o&&this.hiddenCols.splice(o,1);var l=void 0,a=void 0,r=void 0;if(t){if(n.gridLayout){l=n.feature("gridLayout"),a=l.headTbl,r=l.gridColElms;var d=parseInt(r[e].style.width,10),c=parseInt(a.style.width,10);a.style.width=c-d+"px",i.style.width=a.style.width}this.onAfterColHidden&&this.onAfterColHidden.call(null,this,e),this.emitter.emit("column-hidden",n,this,e,this.hiddenCols)}if(!t){if(n.gridLayout){l=n.feature("gridLayout"),a=l.headTbl,r=l.gridColElms;var u=parseInt(r[e].style.width,10);a.style.width=parseInt(a.style.width,10)+u+"px",n.tbl.style.width=a.style.width}this.onAfterColDisplayed&&this.onAfterColDisplayed.call(null,this,e),this.emitter.emit("column-shown",n,this,e,this.hiddenCols)}},e.prototype.showCol=function(e){if(void 0!==e&&this.isColHidden(e))if(this.manager&&this.contEl){var t=l["default"].id("col_"+e+"_"+this.tf.id);t&&t.click()}else this.setHidden(e,!1)},e.prototype.hideCol=function(e){if(void 0!==e&&!this.isColHidden(e))if(this.manager&&this.contEl){var t=l["default"].id("col_"+e+"_"+this.tf.id);t&&t.click()}else this.setHidden(e,!0)},e.prototype.isColHidden=function(e){return-1!==this.hiddenCols.indexOf(e)},e.prototype.toggleCol=function(e){void 0===e||this.isColHidden(e)?this.showCol(e):this.hideCol(e)},e.prototype.getHiddenCols=function(){return this.hiddenCols},e.prototype.destroy=function(){var e=this;(this.btnEl||this.contEl)&&(l["default"].id(this.contElTgtId)?l["default"].id(this.contElTgtId).innerHTML="":(this.contEl.innerHTML="",l["default"].remove(this.contEl),this.contEl=null),this.btnEl.innerHTML="",l["default"].remove(this.btnEl),this.btnEl=null,this.emitter.off(["hide-column"],function(t,n){return e.hideCol(n)}),this.initialized=!1)},e.prototype._getHeaderText=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 l["default"].getText(n)}}return""},e.prototype._hideCells=function(e,t,n){for(var i=0;i<e.rows.length;i++){var s=e.rows[i],o=s.cells[t];o&&(o.style.display=n?"none":"")}},e.prototype._hideAtStart=function(){var e=this;this.atStart&&this.atStart.forEach(function(t){e.hideCol(t)})},e}();t["default"]=u},34:function(e,t,n){"use strict";function i(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 o=n(2),l=i(o),a=n(3),r=i(a),d=n(1),c=i(d),u=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,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=r["default"].isUndef(n.filters_row_index)?t.getFiltersRowIndex():n.filters_row_index,this.visibleAtStart=r["default"].isUndef(n.visible_at_start)?!0:Boolean(n.visible_at_start),this.prfx="fltsVis_",this.onBeforeShow=r["default"].isFn(n.on_before_show)?n.on_before_show:null,this.onAfterShow=r["default"].isFn(n.on_after_show)?n.on_after_show:null,this.onBeforeHide=r["default"].isFn(n.on_before_hide)?n.on_before_hide:null,this.onAfterHide=r["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,this.emitter=t.emitter}return e.prototype.init=function(){var e=this;this.initialized||(this.buildUI(),this.initialized=!0,this.emitter.on(["show-filters"],function(t,n){return e.show(n)}),this.emitter.emit("filters-visibility-initialized",this.tf,this))},e.prototype.buildUI=function(){var e=this,t=this.tf,n=l["default"].create("span",["id",this.prfx+t.id]);n.className=this.contCssClass,this.targetId||t.setToolbar();var i=this.targetId?l["default"].id(this.targetId):t.rDiv;if(this.targetId)i.appendChild(n);else{var s=i.firstChild;s.parentNode.insertBefore(n,s)}var o=void 0;this.btnHtml?(n.innerHTML=this.btnHtml,o=n.firstChild):(o=l["default"].create("a",["href","javascript:void(0);"]),o.className=this.btnCssClass,o.title=this.btnText||this.defaultText,o.innerHTML=this.collapseBtnHtml,n.appendChild(o)),c["default"].add(o,"click",function(){return e.toggle()}),this.contEl=n,this.btnEl=o,this.visibleAtStart||this.toggle()},e.prototype.toggle=function(){var e=this.tf,t=e.gridLayout?e.feature("gridLayout").headTbl:e.tbl,n=t.rows[this.filtersRowIndex],i=""===n.style.display;this.show(!i)},e.prototype.show=function(){var e=arguments.length<=0||void 0===arguments[0]?!0:arguments[0],t=this.tf,n=t.gridLayout?t.feature("gridLayout").headTbl:t.tbl,i=n.rows[this.filtersRowIndex];this.onBeforeShow&&e&&this.onBeforeShow.call(this,this),this.onBeforeHide&&!e&&this.onBeforeHide.call(null,this),i.style.display=e?"":"none",this.enableIcon&&!this.btnHtml&&(this.btnEl.innerHTML=e?this.collapseBtnHtml:this.expandBtnHtml),this.onAfterShow&&e&&this.onAfterShow.call(null,this),this.onAfterHide&&!e&&this.onAfterHide.call(null,this),this.emitter.emit("filters-toggled",t,this,e)},e.prototype.destroy=function(){var e=this;(this.btnEl||this.contEl)&&(this.emitter.off(["show-filters"],function(t,n){return e.show(n)}),this.btnEl.innerHTML="",l["default"].remove(this.btnEl),this.btnEl=null,this.contEl.innerHTML="",l["default"].remove(this.contEl),this.contEl=null,this.initialized=!1)},e}();t["default"]=u},35:function(e,t,n){"use strict";function i(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 o(e){return w["default"].removeNbFormat(e,"us")}function l(e){return w["default"].removeNbFormat(e,"eu")}function a(e,t){return v["default"].format(e,t)}function r(e){return a(e,"DMY")}function d(e){return a(e,"MDY")}function c(e){return a(e,"YMD")}function u(e){return a(e,"DDMMMYYYY")}function h(e){var t=e.split(".");for(var n in t){for(var i=t[n];3>i.length;)i="0"+i;t[n]=i}return t.join(".")}function f(e,t){var n=h(e.value.toLowerCase()),i=h(t.value.toLowerCase());return n==i?0:i>n?-1:1}Object.defineProperty(t,"__esModule",{value:!0});var p=n(3),b=i(p),m=n(2),y=i(m),g=n(1),T=i(g),_=n(5),v=i(_),C=n(6),w=i(C),S=n(10),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=b["default"].isArray(n.types)?n.types:[],this.sortColAtStart=b["default"].isArray(n.sort_col_at_start)?n.sort_col_at_start:null,this.asyncSort=Boolean(n.async_sort),this.triggerIds=b["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=b["default"].isFn(n.on_sort_loaded)?n.on_sort_loaded:null,this.onBeforeSort=b["default"].isFn(n.on_before_sort)?n.on_before_sort:null,this.onAfterSort=b["default"].isFn(n.on_after_sort)?n.on_after_sort:null,this.tf=t,this.emitter=t.emitter}return e.prototype.init=function(){var e=this,t=this.tf,n=this;if(b["default"].isUndef(SortableTable))throw new Error("SortableTable class not found.");this.overrideSortableTable(),this.setSortTypes();var i=n.sortColAtStart;i&&this.stt.sort(i[0],i[1]),this.onSortLoaded&&this.onSortLoaded.call(null,t,this),this.stt.onbeforesort=function(){n.onBeforeSort&&n.onBeforeSort.call(null,t,n.stt.sortColumn),t.paging&&t.feature("paging").disable()},this.stt.onsort=function(){if(n.sorted=!0,t.paging){var e=t.feature("paging");t.getValidRows(!0),e.enable(),e.setPage(e.getPage())}n.onAfterSort&&n.onAfterSort.call(null,t,n.stt.sortColumn,n.stt.descending),n.emitter.emit("column-sorted",t,n.stt.sortColumn,n.stt.descending)},this.emitter.on(["sort"],function(t,n,i){return e.sortByColumnIndex(n,i)}),this.initialized=!0,this.emitter.emit("sort-initialized",t,this)},e.prototype.sortByColumnIndex=function(e,t){this.stt.sort(e,t)},e.prototype.overrideSortableTable=function(){var e=this,t=this.tf;SortableTable.prototype.headerOnclick=function(t){if(e.initialized){for(var n=t.target||t.srcElement;n.tagName!==S.CELL_TAG&&n.tagName!==S.HEADER_TAG;)n=n.parentNode;this.sort(SortableTable.msie?SortableTable.getCellIndex(n):n.cellIndex)}},SortableTable.getCellIndex=function(e){var t=e.parentNode.cells,n=t.length,i=void 0;for(i=0;t[i]!=e&&n>i;i++);return i},SortableTable.prototype.initHeader=function(n){var i=this;if(!i.tHead){if(!t.gridLayout)return;i.tHead=t.feature("gridLayout").headTbl.tHead}i.headersRow=t.headersRow;var s=i.tHead.rows[i.headersRow].cells;i.sortTypes=n||[];for(var o=s.length,l=void 0,a=void 0,r=0;o>r;r++)a=s[r],null!==i.sortTypes[r]&&"None"!==i.sortTypes[r]?(a.style.cursor="pointer",l=y["default"].create("img",["src",e.imgPath+e.imgBlank]),a.appendChild(l),null!==i.sortTypes[r]&&a.setAttribute("_sortType",i.sortTypes[r]),T["default"].add(a,"click",i._headerOnclick)):(a.setAttribute("_sortType",n[r]),a._sortType="None");i.updateHeaderArrows()},SortableTable.prototype.updateHeaderArrows=function(){var t=this,n=void 0,i=void 0,s=void 0;if(e.asyncSort&&e.triggerIds.length>0){var o=e.triggerIds;n=[],i=o.length;for(var l=0;l<o.length;l++)n.push(y["default"].id(o[l]))}else{if(!this.tHead)return;n=t.tHead.rows[t.headersRow].cells,i=n.length}for(var a=0;i>a;a++){var r=n[a].getAttribute("_sortType");null!==r&&"None"!==r&&(s=n[a].lastChild||n[a],"img"!==s.nodeName.toLowerCase()&&(s=y["default"].create("img",["src",e.imgPath+e.imgBlank]),n[a].appendChild(s)),a===t.sortColumn?s.className=e.imgClassName+" "+(this.descending?e.imgDescClassName:e.imgAscClassName):s.className=e.imgClassName)}},SortableTable.prototype.getRowValue=function(e,t,n){var i=this,s=i._sortTypeInfo[t];if(s&&s.getRowValue)return s.getRowValue(e,n);var o=e.cells[n],l=SortableTable.getInnerText(o);return i.getValueFromString(l,t)},SortableTable.getInnerText=function(t){return t?t.getAttribute(e.customKey)?t.getAttribute(e.customKey):y["default"].getText(t):void 0}},e.prototype.addSortType=function(){var e=arguments;SortableTable.prototype.addSortType(e[0],e[1],e[2],e[3])},e.prototype.setSortTypes=function(){for(var e=this,t=this.tf,n=this.sortTypes,i=[],s=0;s<t.nbCells;s++){var a=void 0;n[s]?(a=n[s].toLowerCase(),a===S.NONE&&(a="None")):a=t.hasColNbFormat&&null!==t.colNbFormat[s]?t.colNbFormat[s].toLowerCase():t.hasColDateType&&null!==t.colDateType[s]?t.colDateType[s].toLowerCase()+"date":"String",i.push(a)}this.addSortType("number",Number),this.addSortType("caseinsensitivestring",SortableTable.toUpperCase),this.addSortType("date",SortableTable.toDate),this.addSortType("string"),this.addSortType("us",o),this.addSortType("eu",l),this.addSortType("dmydate",r),this.addSortType("ymddate",c),this.addSortType("mdydate",d),this.addSortType("ddmmmyyyydate",u),this.addSortType("ipaddress",h,f),this.stt=new SortableTable(t.tbl,i),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 i=n.target;e.tf.sort&&e.stt.asyncSort(t.indexOf(i.id))}),s.setAttribute("_sortType",i[n]))}}()},e.prototype.destroy=function(){var e=this,t=this.tf;this.emitter.off(["sort"],function(t,n,i){return e.sortByColumnIndex(n,i)}),this.sorted=!1,this.initialized=!1,this.stt.destroy();for(var n=t.getFiltersId(),i=0;i<n.length;i++){var s=t.getHeaderElement(i),o=y["default"].tag(s,"img");1===o.length&&s.removeChild(o[0])}},e}();t["default"]=x},36:function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var s=n(35),o=i(s);window.SortableTable||n(37),t["default"]=o["default"]},37:function(e,t,n){n(38)(n(39))},38:function(e,t){e.exports=function(e){"undefined"!=typeof execScript?execScript(e):eval.call(null,e)}},39:function(e,t){e.exports='/*----------------------------------------------------------------------------\\\n| Sortable Table 1.12 |\n|-----------------------------------------------------------------------------|\n| Created by Erik Arvidsson |\n| (http://webfx.eae.net/contact.html#erik) |\n| For WebFX (http://webfx.eae.net/) |\n|-----------------------------------------------------------------------------|\n| A DOM 1 based script that allows an ordinary HTML table to be sortable. |\n|-----------------------------------------------------------------------------|\n| Copyright (c) 1998 - 2006 Erik Arvidsson |\n|-----------------------------------------------------------------------------|\n| Licensed under the Apache License, Version 2.0 (the "License"); you may not |\n| use this file except in compliance with the License. You may obtain a copy |\n| of the License at http://www.apache.org/licenses/LICENSE-2.0 |\n| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |\n| Unless required by applicable law or agreed to in writing, software |\n| distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |\n| WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |\n| License for the specific language governing permissions and limitations |\n| under the License. |\n|-----------------------------------------------------------------------------|\n| 2003-01-10 | First version |\n| 2003-01-19 | Minor changes to the date parsing |\n| 2003-01-28 | JScript 5.0 fixes (no support for \'in\' operator) |\n| 2003-02-01 | Sloppy typo like error fixed in getInnerText |\n| 2003-07-04 | Added workaround for IE cellIndex bug. |\n| 2003-11-09 | The bDescending argument to sort was not correctly working |\n| | Using onclick DOM0 event if no support for addEventListener |\n| | or attachEvent |\n| 2004-01-13 | Adding addSortType and removeSortType which makes it a lot |\n| | easier to add new, custom sort types. |\n| 2004-01-27 | Switch to use descending = false as the default sort order. |\n| | Change defaultDescending to suit your needs. |\n| 2004-03-14 | Improved sort type None look and feel a bit |\n| 2004-08-26 | Made the handling of tBody and tHead more flexible. Now you |\n| | can use another tHead or no tHead, and you can chose some |\n| | other tBody. |\n| 2006-04-25 | Changed license to Apache Software License 2.0 |\n|-----------------------------------------------------------------------------|\n| Created 2003-01-10 | All changes are in the log above. | Updated 2006-04-25 |\n\\----------------------------------------------------------------------------*/\n\n\nfunction SortableTable(oTable, oSortTypes) {\n\n this.sortTypes = oSortTypes || [];\n\n this.sortColumn = null;\n this.descending = null;\n\n var oThis = this;\n this._headerOnclick = function (e) {\n oThis.headerOnclick(e);\n };\n\n if (oTable) {\n this.setTable( oTable );\n this.document = oTable.ownerDocument || oTable.document;\n }\n else {\n this.document = document;\n }\n\n\n // only IE needs this\n var win = this.document.defaultView || this.document.parentWindow;\n this._onunload = function () {\n oThis.destroy();\n };\n if (win && typeof win.attachEvent != "undefined") {\n win.attachEvent("onunload", this._onunload);\n }\n}\n\nSortableTable.gecko = navigator.product == "Gecko";\nSortableTable.msie = /msie/i.test(navigator.userAgent);\n// Mozilla is faster when doing the DOM manipulations on\n// an orphaned element. MSIE is not\nSortableTable.removeBeforeSort = SortableTable.gecko;\n\nSortableTable.prototype.onsort = function () {};\n\n// default sort order. true -> descending, false -> ascending\nSortableTable.prototype.defaultDescending = false;\n\n// shared between all instances. This is intentional to allow external files\n// to modify the prototype\nSortableTable.prototype._sortTypeInfo = {};\n\nSortableTable.prototype.setTable = function (oTable) {\n if ( this.tHead )\n this.uninitHeader();\n this.element = oTable;\n this.setTHead( oTable.tHead );\n this.setTBody( oTable.tBodies[0] );\n};\n\nSortableTable.prototype.setTHead = function (oTHead) {\n if (this.tHead && this.tHead != oTHead )\n this.uninitHeader();\n this.tHead = oTHead;\n this.initHeader( this.sortTypes );\n};\n\nSortableTable.prototype.setTBody = function (oTBody) {\n this.tBody = oTBody;\n};\n\nSortableTable.prototype.setSortTypes = function ( oSortTypes ) {\n if ( this.tHead )\n this.uninitHeader();\n this.sortTypes = oSortTypes || [];\n if ( this.tHead )\n this.initHeader( this.sortTypes );\n};\n\n// adds arrow containers and events\n// also binds sort type to the header cells so that reordering columns does\n// not break the sort types\nSortableTable.prototype.initHeader = function (oSortTypes) {\n if (!this.tHead) return;\n var cells = this.tHead.rows[0].cells;\n var doc = this.tHead.ownerDocument || this.tHead.document;\n this.sortTypes = oSortTypes || [];\n var l = cells.length;\n var img, c;\n for (var i = 0; i < l; i++) {\n c = cells[i];\n if (this.sortTypes[i] != null && this.sortTypes[i] != "None") {\n img = doc.createElement("IMG");\n img.src = "images/blank.png";\n c.appendChild(img);\n if (this.sortTypes[i] != null)\n c._sortType = this.sortTypes[i];\n if (typeof c.addEventListener != "undefined")\n c.addEventListener("click", this._headerOnclick, false);\n else if (typeof c.attachEvent != "undefined")\n c.attachEvent("onclick", this._headerOnclick);\n else\n c.onclick = this._headerOnclick;\n }\n else\n {\n c.setAttribute( "_sortType", oSortTypes[i] );\n c._sortType = "None";\n }\n }\n this.updateHeaderArrows();\n};\n\n// remove arrows and events\nSortableTable.prototype.uninitHeader = function () {\n if (!this.tHead) return;\n var cells = this.tHead.rows[0].cells;\n var l = cells.length;\n var c;\n for (var i = 0; i < l; i++) {\n c = cells[i];\n if (c._sortType != null && c._sortType != "None") {\n c.removeChild(c.lastChild);\n if (typeof c.removeEventListener != "undefined")\n c.removeEventListener("click", this._headerOnclick, false);\n else if (typeof c.detachEvent != "undefined")\n c.detachEvent("onclick", this._headerOnclick);\n c._sortType = null;\n c.removeAttribute( "_sortType" );\n }\n }\n};\n\nSortableTable.prototype.updateHeaderArrows = function () {\n if (!this.tHead) return;\n var cells = this.tHead.rows[0].cells;\n var l = cells.length;\n var img;\n for (var i = 0; i < l; i++) {\n if (cells[i]._sortType != null && cells[i]._sortType != "None") {\n img = cells[i].lastChild;\n if (i == this.sortColumn)\n img.className = "sort-arrow " + (this.descending ? "descending" : "ascending");\n else\n img.className = "sort-arrow";\n }\n }\n};\n\nSortableTable.prototype.headerOnclick = function (e) {\n // find TD element\n var el = e.target || e.srcElement;\n while (el.tagName != "TD")\n el = el.parentNode;\n\n this.sort(SortableTable.msie ? SortableTable.getCellIndex(el) : el.cellIndex);\n};\n\n// IE returns wrong cellIndex when columns are hidden\nSortableTable.getCellIndex = function (oTd) {\n var cells = oTd.parentNode.childNodes\n var l = cells.length;\n var i;\n for (i = 0; cells[i] != oTd && i < l; i++)\n ;\n return i;\n};\n\nSortableTable.prototype.getSortType = function (nColumn) {\n return this.sortTypes[nColumn] || "String";\n};\n\n// only nColumn is required\n// if bDescending is left out the old value is taken into account\n// if sSortType is left out the sort type is found from the sortTypes array\n\nSortableTable.prototype.sort = function (nColumn, bDescending, sSortType) {\n if (!this.tBody) return;\n if (sSortType == null)\n sSortType = this.getSortType(nColumn);\n\n // exit if None\n if (sSortType == "None")\n return;\n\n if (bDescending == null) {\n if (this.sortColumn != nColumn)\n this.descending = this.defaultDescending;\n else\n this.descending = !this.descending;\n }\n else\n this.descending = bDescending;\n\n this.sortColumn = nColumn;\n\n if (typeof this.onbeforesort == "function")\n this.onbeforesort();\n\n var f = this.getSortFunction(sSortType, nColumn);\n var a = this.getCache(sSortType, nColumn);\n var tBody = this.tBody;\n\n a.sort(f);\n\n if (this.descending)\n a.reverse();\n\n if (SortableTable.removeBeforeSort) {\n // remove from doc\n var nextSibling = tBody.nextSibling;\n var p = tBody.parentNode;\n p.removeChild(tBody);\n }\n\n // insert in the new order\n var l = a.length;\n for (var i = 0; i < l; i++)\n tBody.appendChild(a[i].element);\n\n if (SortableTable.removeBeforeSort) {\n // insert into doc\n p.insertBefore(tBody, nextSibling);\n }\n\n this.updateHeaderArrows();\n\n this.destroyCache(a);\n\n if (typeof this.onsort == "function")\n this.onsort();\n};\n\nSortableTable.prototype.asyncSort = function (nColumn, bDescending, sSortType) {\n var oThis = this;\n this._asyncsort = function () {\n oThis.sort(nColumn, bDescending, sSortType);\n };\n window.setTimeout(this._asyncsort, 1);\n};\n\nSortableTable.prototype.getCache = function (sType, nColumn) {\n if (!this.tBody) return [];\n var rows = this.tBody.rows;\n var l = rows.length;\n var a = new Array(l);\n var r;\n for (var i = 0; i < l; i++) {\n r = rows[i];\n a[i] = {\n value: this.getRowValue(r, sType, nColumn),\n element: r\n };\n };\n return a;\n};\n\nSortableTable.prototype.destroyCache = function (oArray) {\n var l = oArray.length;\n for (var i = 0; i < l; i++) {\n oArray[i].value = null;\n oArray[i].element = null;\n oArray[i] = null;\n }\n};\n\nSortableTable.prototype.getRowValue = function (oRow, sType, nColumn) {\n // if we have defined a custom getRowValue use that\n if (this._sortTypeInfo[sType] && this._sortTypeInfo[sType].getRowValue)\n return this._sortTypeInfo[sType].getRowValue(oRow, nColumn);\n\n var s;\n var c = oRow.cells[nColumn];\n if (typeof c.innerText != "undefined")\n s = c.innerText;\n else\n s = SortableTable.getInnerText(c);\n return this.getValueFromString(s, sType);\n};\n\nSortableTable.getInnerText = function (oNode) {\n var s = "";\n var cs = oNode.childNodes;\n var l = cs.length;\n for (var i = 0; i < l; i++) {\n switch (cs[i].nodeType) {\n case 1: //ELEMENT_NODE\n s += SortableTable.getInnerText(cs[i]);\n break;\n case 3: //TEXT_NODE\n s += cs[i].nodeValue;\n break;\n }\n }\n return s;\n};\n\nSortableTable.prototype.getValueFromString = function (sText, sType) {\n if (this._sortTypeInfo[sType])\n return this._sortTypeInfo[sType].getValueFromString( sText );\n return sText;\n /*\n switch (sType) {\n case "Number":\n return Number(sText);\n case "CaseInsensitiveString":\n return sText.toUpperCase();\n case "Date":\n var parts = sText.split("-");\n var d = new Date(0);\n d.setFullYear(parts[0]);\n d.setDate(parts[2]);\n d.setMonth(parts[1] - 1);\n return d.valueOf();\n }\n return sText;\n */\n };\n\nSortableTable.prototype.getSortFunction = function (sType, nColumn) {\n if (this._sortTypeInfo[sType])\n return this._sortTypeInfo[sType].compare;\n return SortableTable.basicCompare;\n};\n\nSortableTable.prototype.destroy = function () {\n this.uninitHeader();\n var win = this.document.parentWindow;\n if (win && typeof win.detachEvent != "undefined") { // only IE needs this\n win.detachEvent("onunload", this._onunload);\n }\n this._onunload = null;\n this.element = null;\n this.tHead = null;\n this.tBody = null;\n this.document = null;\n this._headerOnclick = null;\n this.sortTypes = null;\n this._asyncsort = null;\n this.onsort = null;\n};\n\n// Adds a sort type to all instance of SortableTable\n// sType : String - the identifier of the sort type\n// fGetValueFromString : function ( s : string ) : T - A function that takes a\n// string and casts it to a desired format. If left out the string is just\n// returned\n// fCompareFunction : function ( n1 : T, n2 : T ) : Number - A normal JS sort\n// compare function. Takes two values and compares them. If left out less than,\n// <, compare is used\n// fGetRowValue : function( oRow : HTMLTRElement, nColumn : int ) : T - A function\n// that takes the row and the column index and returns the value used to compare.\n// If left out then the innerText is first taken for the cell and then the\n// fGetValueFromString is used to convert that string the desired value and type\n\nSortableTable.prototype.addSortType = function (sType, fGetValueFromString, fCompareFunction, fGetRowValue) {\n this._sortTypeInfo[sType] = {\n type: sType,\n getValueFromString: fGetValueFromString || SortableTable.idFunction,\n compare: fCompareFunction || SortableTable.basicCompare,\n getRowValue: fGetRowValue\n };\n};\n\n// this removes the sort type from all instances of SortableTable\nSortableTable.prototype.removeSortType = function (sType) {\n delete this._sortTypeInfo[sType];\n};\n\nSortableTable.basicCompare = function compare(n1, n2) {\n if (n1.value < n2.value)\n return -1;\n if (n2.value < n1.value)\n return 1;\n return 0;\n};\n\nSortableTable.idFunction = function (x) {\n return x;\n};\n\nSortableTable.toUpperCase = function (s) {\n return s.toUpperCase();\n};\n\nSortableTable.toDate = function (s) {\n var parts = s.split("-");\n var d = new Date(0);\n d.setFullYear(parts[0]);\n d.setDate(parts[2]);\n d.setMonth(parts[1] - 1);\n return d.valueOf();\n};\n\n\n// add sort types\nSortableTable.prototype.addSortType("Number", Number);\nSortableTable.prototype.addSortType("CaseInsensitiveString", SortableTable.toUpperCase);\nSortableTable.prototype.addSortType("Date", SortableTable.toDate);\nSortableTable.prototype.addSortType("String");\n// None is a special case\n'}}); |