diff --git a/Gruntfile.js b/Gruntfile.js index 5da2368f..ec6a5631 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -34,6 +34,10 @@ module.exports = function (grunt) { tasks: ['dev'] }, + qunit: { + files: ['test/**/*.html'] + }, + requirejs: { compile: { options: { @@ -134,10 +138,12 @@ module.exports = function (grunt) { grunt.loadNpmTasks('grunt-contrib-cssmin'); grunt.loadNpmTasks('grunt-contrib-copy'); grunt.loadNpmTasks('grunt-contrib-watch'); + grunt.loadNpmTasks('grunt-contrib-qunit'); grunt.loadNpmTasks('grunt-contrib-requirejs'); // This is the default task being executed if Grunt // is called without any further parameter. - grunt.registerTask('default', ['jshint', 'requirejs', 'concat', 'uglify', 'cssmin', 'copy']); + grunt.registerTask('default', ['jshint', 'requirejs', 'concat', 'uglify', 'cssmin', 'copy', 'qunit']); grunt.registerTask('dev', ['jshint', 'concat', 'cssmin', 'copy']); + grunt.registerTask('test', ['qunit']); }; \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..413c0e16 --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2009-2014 Max Guglielmi + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/dist/filtergrid.css b/dist/filtergrid.css index c2f0a3b8..8ee27ef2 100644 --- a/dist/filtergrid.css +++ b/dist/filtergrid.css @@ -1,6 +1,6 @@ /*------------------------------------------------------------------------ - TableFilter stylesheet by Max Guglielmi - - (build date: Sun Nov 02 2014 01:26:16) + - (build date: Sat Nov 08 2014 23:36:20) - Edit below for your projects' needs ------------------------------------------------------------------------*/ diff --git a/dist/tablefilter.js b/dist/tablefilter.js index 76e97704..741f5ad0 100644 --- a/dist/tablefilter.js +++ b/dist/tablefilter.js @@ -1,10 +1,10 @@ /*------------------------------------------------------------------------ - TableFilter v3.0.0 by Max Guglielmi - - build date: Sun Nov 02 2014 01:26:15 + - build date: Sat Nov 08 2014 23:36:19 - http://tablefilter.free.fr - Copyright (c) 2014, Licensed under the MIT License ------------------------------------------------------------------------*/ -!function(a,b){"function"==typeof define&&define.amd?define(b):"object"==typeof exports?module.exports=b:a.TableFilter=b()}(this,function(){var requirejs,require,define;return function(a){function b(a,b){return r.call(a,b)}function c(a,b){var c,d,e,f,g,h,i,j,k,l,m,n=b&&b.split("/"),o=p.map,q=o&&o["*"]||{};if(a&&"."===a.charAt(0))if(b){for(n=n.slice(0,n.length-1),a=a.split("/"),g=a.length-1,p.nodeIdCompat&&t.test(a[g])&&(a[g]=a[g].replace(t,"")),a=n.concat(a),k=0;k0&&(a.splice(k-1,2),k-=2)}a=a.join("/")}else 0===a.indexOf("./")&&(a=a.substring(2));if((n||q)&&o){for(c=a.split("/"),k=c.length;k>0;k-=1){if(d=c.slice(0,k).join("/"),n)for(l=n.length;l>0;l-=1)if(e=o[n.slice(0,l).join("/")],e&&(e=e[d])){f=e,h=k;break}if(f)break;!i&&q&&q[d]&&(i=q[d],j=k)}!f&&i&&(f=i,h=j),f&&(c.splice(0,h,f),a=c.join("/"))}return a}function d(b,c){return function(){var d=s.call(arguments,0);return"string"!=typeof d[0]&&1===d.length&&d.push(null),k.apply(a,d.concat([b,c]))}}function e(a){return function(b){return c(b,a)}}function f(a){return function(b){n[a]=b}}function g(c){if(b(o,c)){var d=o[c];delete o[c],q[c]=!0,j.apply(a,d)}if(!b(n,c)&&!b(q,c))throw new Error("No "+c);return n[c]}function h(a){var b,c=a?a.indexOf("!"):-1;return c>-1&&(b=a.substring(0,c),a=a.substring(c+1,a.length)),[b,a]}function i(a){return function(){return p&&p.config&&p.config[a]||{}}}var j,k,l,m,n={},o={},p={},q={},r=Object.prototype.hasOwnProperty,s=[].slice,t=/\.js$/;l=function(a,b){var d,f=h(a),i=f[0];return a=f[1],i&&(i=c(i,b),d=g(i)),i?a=d&&d.normalize?d.normalize(a,e(b)):c(a,b):(a=c(a,b),f=h(a),i=f[0],a=f[1],i&&(d=g(i))),{f:i?i+"!"+a:a,n:a,pr:i,p:d}},m={require:function(a){return d(a)},exports:function(a){var b=n[a];return"undefined"!=typeof b?b:n[a]={}},module:function(a){return{id:a,uri:"",exports:n[a],config:i(a)}}},j=function(c,e,h,i){var j,k,p,r,s,t,u=[],v=typeof h;if(i=i||c,"undefined"===v||"function"===v){for(e=!e.length&&h.length?["require","exports","module"]:e,s=0;s]+>/g,"");return b=b.replace(/^\s+/,"").replace(/\s+$/,"")},b.create=function(a){if(a&&""!==a){var b=document.createElement(a),c=arguments;if(c.length>1)for(var d=0;d0){var d=document.cookie,e=d.indexOf(c);if(-1!==e){e+=c.length;var f=d.indexOf(";",e);-1===f&&(f=d.length),b=unescape(d.substring(e,f))}}return b},a.remove=function(a){this.write(a,"",-1)},a.valueToArray=function(a,b){b||(b=",");var c=this.read(a),d=c.split(b);return d},a.getValueByIndex=function(a,b,c){c||(c=",");var d=this.valueToArray(a,c);return d[b]},a}),define("types",[],function(){var a={},b=void 0;return a.isObj=function(a){var b=!1;return"string"==typeof a?window[a]&&"object"==typeof window[a]&&(b=!0):a&&"object"==typeof a&&(b=!0),b},a.isFn=function(a){return a&&a.constructor==Function},a.isArray=function(a){return a&&a.constructor==Array},a.isUndef=function(a){return a===b},a}),define("array",["require","./string"],function(a){var b=a("./string"),c={has:function(a,c,d){for(var e=void 0===d?!1:d,f=0;f2)return a;var b;return 99>=a&&a>50&&(b="19"+a),(50>a||"00"===a)&&(b="20"+a),b}function d(a){if(void 0===a)return 0;for(var b,c=["january","february","march","april","may","june","july","august","september","october","november","december","jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"],d=0;d11||23>b)&&(b-=12),1>b||b>12?0:b}if(b||(b="DMY"),!a||""===a)return new Date(1001,0,1);var e,f;switch(b.toUpperCase()){case"DDMMMYYYY":f=a.replace(/[- \/.]/g," ").split(" "),e=new Date(c(f[2]),d(f[1])-1,f[0]);break;case"DMY":f=a.replace(/^(0?[1-9]|[12][0-9]|3[01])([- \/.])(0?[1-9]|1[012])([- \/.])((\d\d)?\d\d)$/,"$1 $3 $5").split(" "),e=new Date(c(f[2]),f[1]-1,f[0]);break;case"MDY":f=a.replace(/^(0?[1-9]|1[012])([- \/.])(0?[1-9]|[12][0-9]|3[01])([- \/.])((\d\d)?\d\d)$/,"$1 $3 $5").split(" "),e=new Date(c(f[2]),f[0]-1,f[1]);break;case"YMD":f=a.replace(/^((\d\d)?\d\d)([- \/.])(0?[1-9]|1[012])([- \/.])(0?[1-9]|[12][0-9]|3[01])$/,"$1 $4 $6").split(" "),e=new Date(c(f[0]),f[1]-1,f[2]);break;default:f=a.replace(/^(0?[1-9]|[12][0-9]|3[01])([- \/.])(0?[1-9]|1[012])([- \/.])((\d\d)?\d\d)$/,"$1 $3 $5").split(" "),e=new Date(c(f[2]),f[1]-1,f[0])}return e}};return a}),define("modules/loader",["../dom","../types"],function(a,b){function c(c){var d=c.fObj;c.loaderTgtId=d.loader_target_id||null,c.loaderDiv=null,c.loaderText=d.loader_text||"Loading...",c.loaderHtml=d.loader_html||null,c.loaderCssClass=d.loader_css_class||"loader",c.loaderCloseDelay=200,c.onShowLoader=b.isFn(d.on_show_loader)?d.on_show_loader:null,c.onHideLoader=b.isFn(d.on_hide_loader)?d.on_hide_loader:null,this.tf=c;var e=a.create("div",["id",c.prfxLoader+c.id]);e.className=c.loaderCssClass;var f=c.loaderTgtId?a.id(c.loaderTgtId):c.gridLayout?c.tblCont:c.tbl.parentNode;c.loaderTgtId?f.appendChild(e):f.insertBefore(e,c.tbl),c.loaderDiv=a.id(c.prfxLoader+c.id),c.loaderHtml?c.loaderDiv.innerHTML=c.loaderHtml:c.loaderDiv.appendChild(a.text(c.loaderText))}var d=window;return c.prototype.show=function(a){function b(){c.loaderDiv&&(c.onShowLoader&&"none"!==a&&c.onShowLoader.call(null,c),c.loaderDiv.style.display=a,c.onHideLoader&&"none"===a&&c.onHideLoader.call(null,c))}if(this.tf.loader&&this.tf.loaderDiv&&this.tf.loaderDiv.style.display!==a){var c=this.tf,e="none"===a?this.tf.loaderCloseDelay:1;d.setTimeout(b,e)}},c.prototype.remove=function(){if(this.tf.loaderDiv){var b=this.tf.loaderTgtId?a.id(this.tf.loaderTgtId):this.tf.gridLayout?this.tf.tblCont:this.tf.tbl.parentNode;b.removeChild(this.tf.loaderDiv),this.tf.loaderDiv=null}},c}),define("core",["require","event","dom","string","cookie","types","array","helpers","date","date","modules/loader"],function(require){function TableFilter(a){if(0!==arguments.length){if(this.id=a,this.version="3.0",this.year=(new Date).getFullYear(),this.tbl=dom.id(a),this.startRow=null,this.refRow=null,this.headersRow=null,this.fObj=null,this.nbFilterableRows=null,this.nbRows=null,this.nbCells=null,this.hasGrid=!1,this.enableModules=!1,!this.tbl||"table"!==str.lower(this.tbl.nodeName)||0===this.GetRowsNb())throw new Error("Could not instantiate TF object: table not found.");if(arguments.length>1)for(var b=0;b1?this.filtersRowIndex=this.headersRow+1:(this.filtersRowIndex=1,this.headersRow=0)),this.fltCellTag="th"!==e.filters_cell_tag||"td"!==e.filters_cell_tag?"td":e.filters_cell_tag,this.fltIds=[],this.fltElms=[],this.searchArgs=null,this.tblData=[],this.validRowsIndex=null,this.fltGridEl=null,this.isFirstLoad=!0,this.infDiv=null,this.lDiv=null,this.rDiv=null,this.mDiv=null,this.contDiv=null,this.infDivCssClass=e.inf_div_css_class||"inf",this.lDivCssClass=e.left_div_css_class||"ldiv",this.rDivCssClass=e.right_div_css_class||"rdiv",this.mDivCssClass=e.middle_div_css_class||"mdiv",this.contDivCssClass=e.content_div_css_class||"cont",this.stylesheet=e.stylesheet||this.basePath+"filtergrid.css",this.stylesheetId=this.id+"_style",this.fltsRowCssClass=e.flts_row_css_class||"fltrow",this.enableIcons=e.enable_icons===!1?!1:!0,this.alternateBgs=e.alternate_rows===!0?!0:!1,this.hasColWidth=e.col_width===!0?!0:!1,this.colWidth=this.hasColWidth?e.col_width:null,this.fixedHeaders=e.fixed_headers===!0?!0:!1,this.tBodyH=isNaN(e.tbody_height)?200:e.tbody_height,this.fltCssClass=e.flt_css_class||"flt",this.fltMultiCssClass=e.flt_multi_css_class||"flt_multi",this.fltSmallCssClass=e.flt_small_css_class||"flt_s",this.singleFltCssClass=e.single_flt_css_class||"single_flt",this.isStartBgAlternate=!0,this.rowBgEvenCssClass=e.even_row_css_class||"even",this.rowBgOddCssClass=e.odd_row_css_class||"odd",this.enterKey=e.enter_key===!1?!1:!0,this.isModFilterFn=e.mod_filter_fn===!0?!0:!1,this.modFilterFn=this.isModFilterFn?e.mod_filter_fn:null,this.onBeforeFilter=types.isFn(e.on_before_filter)?e.on_before_filter:null,this.onAfterFilter=types.isFn(e.on_after_filter)?e.on_after_filter:null,this.matchCase=e.match_case===!0?!0:!1,this.exactMatch=e.exact_match===!0?!0:!1,this.refreshFilters=e.refresh_filters===!0?!0:!1,this.disableExcludedOptions=e.disable_excluded_options===!0?!0:!1,this.activeFlt=null,this.activeFilterId=null,this.hasColOperation=e.col_operation===!0?!0:!1,this.colOperation=null,this.hasVisibleRows=e.rows_always_visible===!0?!0:!1,this.visibleRows=this.hasVisibleRows?e.rows_always_visible:[],this.searchType=e.search_type||"include",this.isExternalFlt=e.external_flt_grid===!0?!0:!1,this.externalFltTgtIds=e.external_flt_grid_ids||null,this.externalFltEls=[],this.execDelay=isNaN(e.exec_delay)?100:parseInt(e.exec_delay,10),this.status=e.status===!0?!0:!1,this.onFiltersLoaded=types.isFn(e.on_filters_loaded)?e.on_filters_loaded:null,this.singleSearchFlt=e.single_search_filter===!0?!0:!1,this.onRowValidated=types.isFn(e.on_row_validated)?e.on_row_validated:null,this.customCellDataCols=e.custom_cell_data_cols?e.custom_cell_data_cols:[],this.customCellData=types.isFn(e.custom_cell_data)?e.custom_cell_data:null,this.inpWatermark=e.input_watermark||"",this.inpWatermarkCssClass=e.input_watermark_css_class||"fltWatermark",this.isInpWatermarkArray=types.isArray(e.input_watermark),this.toolBarTgtId=e.toolbar_target_id||null,this.helpInstructions=e.help_instructions||null,this.popUpFilters=e.popup_filters===!0?!0:!1,this.markActiveColumns=e.mark_active_columns===!0?!0:!1,this.activeColumnsCssClass=e.active_columns_css_class||"activeHeader",this.onBeforeActiveColumn=types.isFn(e.on_before_active_column)?e.on_before_active_column:null,this.onAfterActiveColumn=types.isFn(e.on_after_active_column)?e.on_after_active_column:null,this.displayAllText=e.display_all_text||"",this.enableSlcResetFilter=e.enable_slc_reset_filter===!1?!1:!0,this.enableEmptyOption=e.enable_empty_option===!0?!0:!1,this.emptyText=e.empty_text||"(Empty)",this.enableNonEmptyOption=e.enable_non_empty_option===!0?!0:!1,this.nonEmptyText=e.non_empty_text||"(Non empty)",this.onSlcChange=e.on_change===!1?!1:!0,this.sortSlc=e.sort_select===!1?!1:!0,this.isSortNumAsc=e.sort_num_asc===!0?!0:!1,this.sortNumAsc=this.isSortNumAsc?e.sort_num_asc:null,this.isSortNumDesc=e.sort_num_desc===!0?!0:!1,this.sortNumDesc=this.isSortNumDesc?e.sort_num_desc:null,this.slcFillingMethod=e.slc_filling_method||"createElement",this.fillSlcOnDemand=e.fill_slc_on_demand===!0?!0:!1,this.activateSlcTooltip=e.activate_slc_tooltip||"Click to activate",this.multipleSlcTooltip=e.multiple_slc_tooltip||"Use Ctrl key for multiple selections",this.hasCustomSlcOptions=types.isObj(e.custom_slc_options)?!0:!1,this.customSlcOptions=types.isArray(e.custom_slc_options)?e.custom_slc_options:null,this.onBeforeOperation=types.isFn(e.on_before_operation)?e.on_before_operation:null,this.onAfterOperation=types.isFn(e.on_after_operation)?e.on_after_operation:null,this.checkListDiv=[],this.checkListDivCssClass=e.div_checklist_css_class||"div_checklist",this.checkListCssClass=e.checklist_css_class||"flt_checklist",this.checkListItemCssClass=e.checklist_item_css_class||"flt_checklist_item",this.checkListSlcItemCssClass=e.checklist_selected_item_css_class||"flt_checklist_slc_item",this.activateCheckListTxt=e.activate_checklist_text||"Click to load filter data",this.checkListItemDisabledCssClass=e.checklist_item_disabled_css_class||"flt_checklist_item_disabled",this.enableCheckListResetFilter=e.enable_checklist_reset_filter===!1?!1:!0,this.rgxOperator=e.regexp_operator||"rgx:",this.emOperator=e.empty_operator||"[empty]",this.nmOperator=e.nonempty_operator||"[nonempty]",this.orOperator=e.or_operator||"||",this.anOperator=e.and_operator||"&&",this.grOperator=e.greater_operator||">",this.lwOperator=e.lower_operator||"<",this.leOperator=e.lower_equal_operator||"<=",this.geOperator=e.greater_equal_operator||">=",this.dfOperator=e.different_operator||"!",this.lkOperator=e.like_operator||"*",this.eqOperator=e.equal_operator||"=",this.stOperator=e.start_with_operator||"{",this.enOperator=e.end_with_operator||"}",this.curExp=e.cur_exp||"^[¥£€$]",this.separator=e.separator||",",this.rowsCounter=e.rows_counter===!0?!0:!1,this.statusBar=e.status_bar===!0?!0:!1,this.loader=e.loader===!0?!0:!1,this.displayBtn=e.btn===!0?!0:!1,this.btnText=e.btn_text||(this.enableIcons?"":"Go"),this.btnCssClass=e.btn_css_class||(this.enableIcons?"btnflt_icon":"btnflt"),this.btnReset=e.btn_reset===!0?!0:!1,this.btnResetCssClass=e.btn_reset_css_class||"reset",this.onBeforeReset=types.isFn(e.on_before_reset)?e.on_before_reset:null,this.onAfterReset=types.isFn(e.on_after_reset)?e.on_after_reset:null,this.paging=e.paging===!0?!0:!1,this.hasResultsPerPage=e.results_per_page===!0?!0:!1,this.btnPageCssClass=e.paging_btn_css_class||"pgInp",this.pagingSlc=null,this.resultsPerPage=null,this.resultsPerPageSlc=null,this.isPagingRemoved=!1,this.nbVisibleRows=0,this.nbHiddenRows=0,this.startPagingRow=0,this.nbPages=0,this.currentPageNb=1,this.sort=e.sort===!0?!0:!1,this.isSortEnabled=!1,this.sorted=!1,this.sortConfig=e.sort_config||{},this.sortConfig.name=void 0!==this.sortConfig.name?e.sort_config.name:"sortabletable",this.sortConfig.src=void 0!==this.sortConfig.src?e.sort_config.src:this.basePath+"sortabletable.js",this.sortConfig.adapterSrc=void 0!==this.sortConfig.adapter_src?e.sort_config.adapter_src:this.basePath+"tfAdapter.sortabletable.js",this.sortConfig.initialize=void 0!==this.sortConfig.initialize?e.sort_config.initialize:function(a){a.SetSortTable&&a.SetSortTable()},this.sortConfig.sortTypes=types.isArray(this.sortConfig.sort_types)?e.sort_config.sort_types:[],this.sortConfig.sortCol=void 0!==this.sortConfig.sort_col?e.sort_config.sort_col:null,this.sortConfig.asyncSort=this.sortConfig.async_sort===!0?!0:!1,this.sortConfig.triggerIds=types.isArray(this.sortConfig.sort_trigger_ids)?e.sort_config.sort_trigger_ids:[],this.selectable=e.selectable===!0?!0:!1,this.editable=e.editable===!0?!0:!1,this.ezEditTableConfig=e.ezEditTable_config||{},this.ezEditTableConfig.name=void 0!==this.ezEditTableConfig.name?e.ezEditTable_config.name:"ezedittable",this.ezEditTableConfig.src=void 0!==this.ezEditTableConfig.src?e.ezEditTable_config.src:this.basePath+"ezEditTable/ezEditTable.js",this.ezEditTableConfig.loadStylesheet=this.ezEditTableConfig.loadStylesheet===!0?!0:!1,this.ezEditTableConfig.stylesheet=this.ezEditTableConfig.stylesheet||this.basePath+"ezEditTable/ezEditTable.css",this.ezEditTableConfig.stylesheetName=void 0!==this.ezEditTableConfig.stylesheetName?e.ezEditTable_config.stylesheetName:"ezEditTableCss",this.ezEditTableConfig.err='Failed to instantiate EditTable object.\n"ezEditTable" module may not be available.',this.onKeyUp=e.on_keyup===!0?!0:!1,this.onKeyUpDelay=isNaN(e.on_keyup_delay)?900:e.on_keyup_delay,this.isUserTyping=null,this.onKeyUpTimer=void 0,this.highlightKeywords=e.highlight_keywords===!0?!0:!1,this.highlightCssClass=e.highlight_css_class||"keyword",this.highlightedNodes=[],this.defaultDateType=e.default_date_type||"DMY",this.thousandsSeparator=e.thousands_separator||",",this.decimalSeparator=e.decimal_separator||".",this.hasColNbFormat=e.col_number_format===!0?!0:!1,this.colNbFormat=types.isArray(this.hasColNbFormat)?e.col_number_format:null,this.hasColDateType=e.col_date_type===!0?!0:!1,this.colDateType=types.isArray(this.hasColDateType)?e.col_date_type:null,this.msgFilter=e.msg_filter||"Filtering data...",this.msgPopulate=e.msg_populate||"Populating filter...",this.msgPopulateCheckList=e.msg_populate_checklist||"Populating list...",this.msgChangePage=e.msg_change_page||"Collecting paging data...",this.msgClear=e.msg_clear||"Clearing filters...",this.msgChangeResults=e.msg_change_results||"Changing results per page...",this.msgResetValues=e.msg_reset_grid_values||"Re-setting filters values...",this.msgResetPage=e.msg_reset_page||"Re-setting page...",this.msgResetPageLength=e.msg_reset_page_length||"Re-setting page length...",this.msgSort=e.msg_sort||"Sorting data...",this.msgLoadExtensions=e.msg_load_extensions||"Loading extensions...",this.msgLoadThemes=e.msg_load_themes||"Loading theme(s)...",this.prfxTf="TF",this.prfxFlt="flt",this.prfxValButton="btn",this.prfxInfDiv="inf_",this.prfxLDiv="ldiv_",this.prfxRDiv="rdiv_",this.prfxMDiv="mdiv_",this.prfxContentDiv="cont_",this.prfxCheckListDiv="chkdiv_",this.prfxSlcPages="slcPages_",this.prfxSlcResults="slcResults_",this.prfxSlcResultsTxt="slcResultsTxt_",this.prfxBtnNextSpan="btnNextSpan_",this.prfxBtnPrevSpan="btnPrevSpan_",this.prfxBtnLastSpan="btnLastSpan_",this.prfxBtnFirstSpan="btnFirstSpan_",this.prfxBtnNext="btnNext_",this.prfxBtnPrev="btnPrev_",this.prfxBtnLast="btnLast_",this.prfxBtnFirst="btnFirst_",this.prfxPgSpan="pgspan_",this.prfxPgBeforeSpan="pgbeforespan_",this.prfxPgAfterSpan="pgafterspan_",this.prfxCounter="counter_",this.prfxTotRows="totrows_span_",this.prfxTotRowsTxt="totRowsTextSpan_",this.prfxResetSpan="resetspan_",this.prfxLoader="load_",this.prfxStatus="status_",this.prfxStatusSpan="statusSpan_",this.prfxStatusTxt="statusText_",this.prfxCookieFltsValues="tf_flts_",this.prfxCookiePageNb="tf_pgnb_",this.prfxCookiePageLen="tf_pglen_",this.prfxMainTblCont="gridCont_",this.prfxTblCont="tblCont_",this.prfxHeadTblCont="tblHeadCont_",this.prfxHeadTbl="tblHead_",this.prfxGridFltTd="_td_",this.prfxGridTh="tblHeadTh_",this.prfxHelpSpan="helpSpan_",this.prfxHelpDiv="helpDiv_",this.prfxPopUpSpan="popUpSpan_",this.prfxPopUpDiv="popUpDiv_",this.hasStoredValues=!1,this.rememberGridValues=e.remember_grid_values===!0?!0:!1,this.fltsValuesCookie=this.prfxCookieFltsValues+this.id,this.rememberPageNb=this.paging&&e.remember_page_number?!0:!1,this.pgNbCookie=this.prfxCookiePageNb+this.id,this.rememberPageLen=this.paging&&e.remember_page_length?!0:!1,this.pgLenCookie=this.prfxCookiePageLen+this.id,this.cookieDuration=isNaN(e.set_cookie_duration)?1e5:parseInt(e.set_cookie_duration,10),this.hasExtensions=e.extensions===!0?!0:!1,this.extensions=this.hasExtensions?e.extensions:null,this.enableDefaultTheme=e.enable_default_theme===!0?!0:!1,this.hasThemes=e.enable_default_theme||e.themes&&types.isObj(e.themes)?!0:!1,this.themes=this.hasThemes?e.themes:null,this.themesPath=e.themes_path||this.basePath+"TF_Themes/",this.loaderCpt=null;var j=this;this.Evt={name:{filter:"Filter",populateselect:"Populate",populatechecklist:"PopulateCheckList",changepage:"ChangePage",clear:"Clear",changeresultsperpage:"ChangeResults",resetvalues:"ResetValues",resetpage:"ResetPage",resetpagelength:"ResetPageLength",sort:"Sort",loadextensions:"LoadExtensions",loadthemes:"LoadThemes"},getKeyCode:function(a){return a.charCode?a.charCode:a.keyCode?a.keyCode:a.which?a.which:0},_DetectKey:function(a){if(j.enterKey){var b=a||global.event;if(b){var c=j.Evt.getKeyCode(b);13===c?(j._Filter(),evt.cancel(b),evt.stop(b)):(j.isUserTyping=!0,global.clearInterval(j.onKeyUpTimer),j.onKeyUpTimer=void 0)}}},_OnKeyUp:function(a){function b(){global.clearInterval(j.onKeyUpTimer),j.onKeyUpTimer=void 0,j.isUserTyping||(j.Filter(),j.isUserTyping=null)}if(j.onKeyUp){var c=a||global.event,d=j.Evt.getKeyCode(c);j.isUserTyping=!1,13!==d&&9!==d&&27!==d&&38!==d&&40!==d?void 0===j.onKeyUpTimer&&(j.onKeyUpTimer=global.setInterval(b,j.onKeyUpDelay)):(global.clearInterval(j.onKeyUpTimer),j.onKeyUpTimer=void 0)}},_OnKeyDown:function(){j.onKeyUp&&(j.isUserTyping=!0)},_OnInpBlur:function(){j.onKeyUp&&(j.isUserTyping=!1,global.clearInterval(j.onKeyUpTimer)),""===this.value&&""!==j.inpWatermark&&(this.value=j.isInpWatermarkArray?j.inpWatermark[this.getAttribute("ct")]:j.inpWatermark,dom.addClass(this,j.inpWatermarkCssClass)),j.ezEditTable&&(j.editable&&j.ezEditTable.Editable.Set(),j.selectable&&j.ezEditTable.Selection.Set())},_OnInpFocus:function(a){var b=a||global.event;if(j.activeFilterId=this.getAttribute("id"),j.activeFlt=dom.id(j.activeFilterId),j.isInpWatermarkArray){var c=j.inpWatermark[this.getAttribute("ct")];this.value===c&&""!==c&&(this.value="",dom.removeClass(this,j.inpWatermarkCssClass))}else this.value===j.inpWatermark&&""!==j.inpWatermark&&(this.value="",dom.removeClass(this,j.inpWatermarkCssClass));j.popUpFilters&&(evt.cancel(b),evt.stop(b)),j.ezEditTable&&(j.editable&&j.ezEditTable.Editable.Remove(),j.selectable&&j.ezEditTable.Selection.Remove())},_OnSlcFocus:function(a){var b=a||global.event;if(j.activeFilterId=this.getAttribute("id"),j.activeFlt=dom.id(j.activeFilterId),j.fillSlcOnDemand&&"0"===this.getAttribute("filled")){var c=this.getAttribute("ct");j.PopulateSelect(c),hlp.isIE()||this.setAttribute("filled","1")}j.popUpFilters&&(evt.cancel(b),evt.stop(b))},_OnSlcChange:function(a){var b=j.activeFlt.getAttribute("colIndex");if(!j.activeFlt||!b||j["col"+b]!==j.fltTypeCheckList||j.Evt._OnSlcChange.caller){var c=a||global.event;j.popUpFilters&&evt.stop(c),j.onSlcChange&&j.Filter()}},_OnSlcBlur:function(){},_OnCheckListChange:function(a){j.Evt._OnCheckListChange.caller&&j.Evt._OnSlcChange(a)},_OnCheckListClick:function(){if(j.fillSlcOnDemand&&"0"===this.getAttribute("filled")){var a=this.getAttribute("ct");j.PopulateCheckList(a),j.checkListDiv[a].onclick=null,j.checkListDiv[a].title=""}},_OnCheckListFocus:function(){j.activeFilterId=this.firstChild.getAttribute("id"),j.activeFlt=dom.id(j.activeFilterId)},_OnCheckListBlur:function(){},_OnBtnClick:function(){j.Filter()},_OnSlcPagesChangeEvt:null,_EnableSlc:function(){this.firstChild.disabled=!1,this.firstChild.focus(),this.onclick=null},_Clear:function(){j.ClearFilters()},_OnHelpBtnClick:function(){j._ToggleHelp()},_Paging:{nextEvt:null,prevEvt:null,lastEvt:null,firstEvt:null}}}}function numSortAsc(a,b){return a-b}function numSortDesc(a,b){return b-a}function ignoreCaseSort(a,b){var c=str.lower(a),d=str.lower(b);return d>c?-1:c>d?1:0}function removeNbFormat(a,b){if(a){b||(b="us");var c=a;return c="us"===str.lower(b)?+c.replace(/[^\d\.-]/g,""):+c.replace(/[^\d\,-]/g,"").replace(",",".")}}function isImported(a,b){for(var c=!1,d=b?b:"script",e="script"==d?"src":"href",f=dom.tag(doc,d),g=0;g0?f[0].insertRow(this.filtersRowIndex):this.tbl.insertRow(this.filtersRowIndex),this.headersRow>1&&this.filtersRowIndex<=this.headersRow&&!this.popUpFilters&&this.headersRow++,this.popUpFilters&&this.headersRow++,this.fixedHeaders&&this.SetFixedHeaders(),e.className=this.fltsRowCssClass,this.isExternalFlt&&(!this.gridLayout||this.popUpFilters)&&(e.style.display="none")}this.nbFilterableRows=this.GetRowsNb(),this.nbVisibleRows=this.nbFilterableRows,this.nbRows=this.tbl.rows.length;for(var g=0;c>g;g++){var h=dom.create(this.fltCellTag),i=this["col"+g],j=this.isExternalFlt&&this.externalFltTgtIds?this.externalFltTgtIds[g]:null;if(this.singleSearchFlt&&(h.colSpan=this.nbCells),this.gridLayout||e.appendChild(h),a=g==c-1&&this.displayBtn?this.fltSmallCssClass:this.fltCssClass,this.popUpFilters&&this.SetPopupFilter(g),void 0===i&&(i=void 0===b["col_"+g]?this.fltTypeInp:str.lower(b["col_"+g])),this.singleSearchFlt&&(i=this.fltTypeInp,a=this.singleFltCssClass),i===this.fltTypeSlc||i===this.fltTypeMulti){var k=dom.create(this.fltTypeSlc,["id",this.prfxFlt+g+"_"+this.id],["ct",g],["filled","0"]);if(i===this.fltTypeMulti&&(k.multiple=this.fltTypeMulti,k.title=this.multipleSlcTooltip),k.className=str.lower(i)===this.fltTypeSlc?a:this.fltMultiCssClass,j?(dom.id(j).appendChild(k),this.externalFltEls.push(k)):h.appendChild(k),this.fltIds.push(this.prfxFlt+g+"_"+this.id),this.fillSlcOnDemand||this._PopulateSelect(g),k.onkeypress=this.Evt._DetectKey,k.onchange=this.Evt._OnSlcChange,k.onfocus=this.Evt._OnSlcFocus,k.onblur=this.Evt._OnSlcBlur,this.fillSlcOnDemand){var l=dom.createOpt(this.displayAllText,"");k.appendChild(l)}this.fillSlcOnDemand&&hlp.isIE()&&(k.disabled=!0,k.title=this.activateSlcTooltip,k.parentNode.onclick=this.Evt._EnableSlc,i===this.fltTypeMulti&&this.__deferMultipleSelection(k,0))}else if(i===this.fltTypeCheckList){var m=dom.create("div",["id",this.prfxCheckListDiv+g+"_"+this.id],["ct",g],["filled","0"]);m.className=this.checkListDivCssClass,j?(dom.id(j).appendChild(m),this.externalFltEls.push(m)):h.appendChild(m),this.checkListDiv[g]=m,this.fltIds.push(this.prfxFlt+g+"_"+this.id),this.fillSlcOnDemand||this._PopulateCheckList(g),m.onclick=this.Evt._OnCheckListFocus,this.fillSlcOnDemand&&(m.onclick=this.Evt._OnCheckListClick,m.appendChild(dom.text(this.activateCheckListTxt))) +!function(a,b){"function"==typeof define&&define.amd?define(b):"object"==typeof exports?module.exports=b:a.TableFilter=b()}(this,function(){var requirejs,require,define;return function(a){function b(a,b){return r.call(a,b)}function c(a,b){var c,d,e,f,g,h,i,j,k,l,m,n=b&&b.split("/"),o=p.map,q=o&&o["*"]||{};if(a&&"."===a.charAt(0))if(b){for(n=n.slice(0,n.length-1),a=a.split("/"),g=a.length-1,p.nodeIdCompat&&t.test(a[g])&&(a[g]=a[g].replace(t,"")),a=n.concat(a),k=0;k0&&(a.splice(k-1,2),k-=2)}a=a.join("/")}else 0===a.indexOf("./")&&(a=a.substring(2));if((n||q)&&o){for(c=a.split("/"),k=c.length;k>0;k-=1){if(d=c.slice(0,k).join("/"),n)for(l=n.length;l>0;l-=1)if(e=o[n.slice(0,l).join("/")],e&&(e=e[d])){f=e,h=k;break}if(f)break;!i&&q&&q[d]&&(i=q[d],j=k)}!f&&i&&(f=i,h=j),f&&(c.splice(0,h,f),a=c.join("/"))}return a}function d(b,c){return function(){var d=s.call(arguments,0);return"string"!=typeof d[0]&&1===d.length&&d.push(null),k.apply(a,d.concat([b,c]))}}function e(a){return function(b){return c(b,a)}}function f(a){return function(b){n[a]=b}}function g(c){if(b(o,c)){var d=o[c];delete o[c],q[c]=!0,j.apply(a,d)}if(!b(n,c)&&!b(q,c))throw new Error("No "+c);return n[c]}function h(a){var b,c=a?a.indexOf("!"):-1;return c>-1&&(b=a.substring(0,c),a=a.substring(c+1,a.length)),[b,a]}function i(a){return function(){return p&&p.config&&p.config[a]||{}}}var j,k,l,m,n={},o={},p={},q={},r=Object.prototype.hasOwnProperty,s=[].slice,t=/\.js$/;l=function(a,b){var d,f=h(a),i=f[0];return a=f[1],i&&(i=c(i,b),d=g(i)),i?a=d&&d.normalize?d.normalize(a,e(b)):c(a,b):(a=c(a,b),f=h(a),i=f[0],a=f[1],i&&(d=g(i))),{f:i?i+"!"+a:a,n:a,pr:i,p:d}},m={require:function(a){return d(a)},exports:function(a){var b=n[a];return"undefined"!=typeof b?b:n[a]={}},module:function(a){return{id:a,uri:"",exports:n[a],config:i(a)}}},j=function(c,e,h,i){var j,k,p,r,s,t,u=[],v=typeof h;if(i=i||c,"undefined"===v||"function"===v){for(e=!e.length&&h.length?["require","exports","module"]:e,s=0;s]+>/g,"");return b=b.replace(/^\s+/,"").replace(/\s+$/,"")},b.create=function(a){if(a&&""!==a){var b=document.createElement(a),c=arguments;if(c.length>1)for(var d=0;d0){var d=document.cookie,e=d.indexOf(c);if(-1!==e){e+=c.length;var f=d.indexOf(";",e);-1===f&&(f=d.length),b=unescape(d.substring(e,f))}}return b},a.remove=function(a){this.write(a,"",-1)},a.valueToArray=function(a,b){b||(b=",");var c=this.read(a),d=c.split(b);return d},a.getValueByIndex=function(a,b,c){c||(c=",");var d=this.valueToArray(a,c);return d[b]},a}),define("types",[],function(){var a={},b=void 0;return a.isObj=function(a){var b=!1;return"string"==typeof a?window[a]&&"object"==typeof window[a]&&(b=!0):a&&"object"==typeof a&&(b=!0),b},a.isFn=function(a){return a&&a.constructor==Function},a.isArray=function(a){return a&&a.constructor==Array},a.isUndef=function(a){return a===b},a}),define("array",["require","./string"],function(a){var b=a("./string"),c={has:function(a,c,d){for(var e=void 0===d?!1:d,f=0;f2)return a;var b;return 99>=a&&a>50&&(b="19"+a),(50>a||"00"===a)&&(b="20"+a),b}function d(a){if(void 0===a)return 0;for(var b,c=["january","february","march","april","may","june","july","august","september","october","november","december","jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"],d=0;d11||23>b)&&(b-=12),1>b||b>12?0:b}if(b||(b="DMY"),!a||""===a)return new Date(1001,0,1);var e,f;switch(b.toUpperCase()){case"DDMMMYYYY":f=a.replace(/[- \/.]/g," ").split(" "),e=new Date(c(f[2]),d(f[1])-1,f[0]);break;case"DMY":f=a.replace(/^(0?[1-9]|[12][0-9]|3[01])([- \/.])(0?[1-9]|1[012])([- \/.])((\d\d)?\d\d)$/,"$1 $3 $5").split(" "),e=new Date(c(f[2]),f[1]-1,f[0]);break;case"MDY":f=a.replace(/^(0?[1-9]|1[012])([- \/.])(0?[1-9]|[12][0-9]|3[01])([- \/.])((\d\d)?\d\d)$/,"$1 $3 $5").split(" "),e=new Date(c(f[2]),f[0]-1,f[1]);break;case"YMD":f=a.replace(/^((\d\d)?\d\d)([- \/.])(0?[1-9]|1[012])([- \/.])(0?[1-9]|[12][0-9]|3[01])$/,"$1 $4 $6").split(" "),e=new Date(c(f[0]),f[1]-1,f[2]);break;default:f=a.replace(/^(0?[1-9]|[12][0-9]|3[01])([- \/.])(0?[1-9]|1[012])([- \/.])((\d\d)?\d\d)$/,"$1 $3 $5").split(" "),e=new Date(c(f[2]),f[1]-1,f[0])}return e}};return a}),define("modules/loader",["../dom","../types"],function(a,b){function c(c){var d=c.fObj;c.loaderTgtId=d.loader_target_id||null,c.loaderDiv=null,c.loaderText=d.loader_text||"Loading...",c.loaderHtml=d.loader_html||null,c.loaderCssClass=d.loader_css_class||"loader",c.loaderCloseDelay=200,c.onShowLoader=b.isFn(d.on_show_loader)?d.on_show_loader:null,c.onHideLoader=b.isFn(d.on_hide_loader)?d.on_hide_loader:null,this.tf=c;var e=a.create("div",["id",c.prfxLoader+c.id]);e.className=c.loaderCssClass;var f=c.loaderTgtId?a.id(c.loaderTgtId):c.gridLayout?c.tblCont:c.tbl.parentNode;c.loaderTgtId?f.appendChild(e):f.insertBefore(e,c.tbl),c.loaderDiv=a.id(c.prfxLoader+c.id),c.loaderHtml?c.loaderDiv.innerHTML=c.loaderHtml:c.loaderDiv.appendChild(a.text(c.loaderText))}var d=window;return c.prototype.show=function(a){function b(){c.loaderDiv&&(c.onShowLoader&&"none"!==a&&c.onShowLoader.call(null,c),c.loaderDiv.style.display=a,c.onHideLoader&&"none"===a&&c.onHideLoader.call(null,c))}if(this.tf.loader&&this.tf.loaderDiv&&this.tf.loaderDiv.style.display!==a){var c=this.tf,e="none"===a?this.tf.loaderCloseDelay:1;d.setTimeout(b,e)}},c.prototype.remove=function(){if(this.tf.loaderDiv){var b=this.tf.loaderTgtId?a.id(this.tf.loaderTgtId):this.tf.gridLayout?this.tf.tblCont:this.tf.tbl.parentNode;b.removeChild(this.tf.loaderDiv),this.tf.loaderDiv=null}},c}),define("core",["require","event","dom","string","cookie","types","array","helpers","date","date","modules/loader"],function(require){function TableFilter(a){if(0!==arguments.length){if(this.id=a,this.version="3.0",this.year=(new Date).getFullYear(),this.tbl=dom.id(a),this.startRow=null,this.refRow=null,this.headersRow=null,this.fObj=null,this.nbFilterableRows=null,this.nbRows=null,this.nbCells=null,this.hasGrid=!1,this.enableModules=!1,!this.tbl||"table"!==str.lower(this.tbl.nodeName)||0===this.GetRowsNb())throw new Error("Could not instantiate TF object: HTML table not found.");if(arguments.length>1)for(var b=0;b1?this.filtersRowIndex=this.headersRow+1:(this.filtersRowIndex=1,this.headersRow=0)),this.fltCellTag="th"!==e.filters_cell_tag||"td"!==e.filters_cell_tag?"td":e.filters_cell_tag,this.fltIds=[],this.fltElms=[],this.searchArgs=null,this.tblData=[],this.validRowsIndex=null,this.fltGridEl=null,this.isFirstLoad=!0,this.infDiv=null,this.lDiv=null,this.rDiv=null,this.mDiv=null,this.contDiv=null,this.infDivCssClass=e.inf_div_css_class||"inf",this.lDivCssClass=e.left_div_css_class||"ldiv",this.rDivCssClass=e.right_div_css_class||"rdiv",this.mDivCssClass=e.middle_div_css_class||"mdiv",this.contDivCssClass=e.content_div_css_class||"cont",this.stylesheet=e.stylesheet||this.basePath+"filtergrid.css",this.stylesheetId=this.id+"_style",this.fltsRowCssClass=e.flts_row_css_class||"fltrow",this.enableIcons=e.enable_icons===!1?!1:!0,this.alternateBgs=e.alternate_rows===!0?!0:!1,this.hasColWidth=e.col_width===!0?!0:!1,this.colWidth=this.hasColWidth?e.col_width:null,this.fixedHeaders=e.fixed_headers===!0?!0:!1,this.tBodyH=isNaN(e.tbody_height)?200:e.tbody_height,this.fltCssClass=e.flt_css_class||"flt",this.fltMultiCssClass=e.flt_multi_css_class||"flt_multi",this.fltSmallCssClass=e.flt_small_css_class||"flt_s",this.singleFltCssClass=e.single_flt_css_class||"single_flt",this.isStartBgAlternate=!0,this.rowBgEvenCssClass=e.even_row_css_class||"even",this.rowBgOddCssClass=e.odd_row_css_class||"odd",this.enterKey=e.enter_key===!1?!1:!0,this.isModFilterFn=e.mod_filter_fn===!0?!0:!1,this.modFilterFn=this.isModFilterFn?e.mod_filter_fn:null,this.onBeforeFilter=types.isFn(e.on_before_filter)?e.on_before_filter:null,this.onAfterFilter=types.isFn(e.on_after_filter)?e.on_after_filter:null,this.matchCase=e.match_case===!0?!0:!1,this.exactMatch=e.exact_match===!0?!0:!1,this.refreshFilters=e.refresh_filters===!0?!0:!1,this.disableExcludedOptions=e.disable_excluded_options===!0?!0:!1,this.activeFlt=null,this.activeFilterId=null,this.hasColOperation=e.col_operation===!0?!0:!1,this.colOperation=null,this.hasVisibleRows=e.rows_always_visible===!0?!0:!1,this.visibleRows=this.hasVisibleRows?e.rows_always_visible:[],this.searchType=e.search_type||"include",this.isExternalFlt=e.external_flt_grid===!0?!0:!1,this.externalFltTgtIds=e.external_flt_grid_ids||null,this.externalFltEls=[],this.execDelay=isNaN(e.exec_delay)?100:parseInt(e.exec_delay,10),this.status=e.status===!0?!0:!1,this.onFiltersLoaded=types.isFn(e.on_filters_loaded)?e.on_filters_loaded:null,this.singleSearchFlt=e.single_search_filter===!0?!0:!1,this.onRowValidated=types.isFn(e.on_row_validated)?e.on_row_validated:null,this.customCellDataCols=e.custom_cell_data_cols?e.custom_cell_data_cols:[],this.customCellData=types.isFn(e.custom_cell_data)?e.custom_cell_data:null,this.inpWatermark=e.input_watermark||"",this.inpWatermarkCssClass=e.input_watermark_css_class||"fltWatermark",this.isInpWatermarkArray=types.isArray(e.input_watermark),this.toolBarTgtId=e.toolbar_target_id||null,this.helpInstructions=e.help_instructions||null,this.popUpFilters=e.popup_filters===!0?!0:!1,this.markActiveColumns=e.mark_active_columns===!0?!0:!1,this.activeColumnsCssClass=e.active_columns_css_class||"activeHeader",this.onBeforeActiveColumn=types.isFn(e.on_before_active_column)?e.on_before_active_column:null,this.onAfterActiveColumn=types.isFn(e.on_after_active_column)?e.on_after_active_column:null,this.displayAllText=e.display_all_text||"",this.enableSlcResetFilter=e.enable_slc_reset_filter===!1?!1:!0,this.enableEmptyOption=e.enable_empty_option===!0?!0:!1,this.emptyText=e.empty_text||"(Empty)",this.enableNonEmptyOption=e.enable_non_empty_option===!0?!0:!1,this.nonEmptyText=e.non_empty_text||"(Non empty)",this.onSlcChange=e.on_change===!1?!1:!0,this.sortSlc=e.sort_select===!1?!1:!0,this.isSortNumAsc=e.sort_num_asc===!0?!0:!1,this.sortNumAsc=this.isSortNumAsc?e.sort_num_asc:null,this.isSortNumDesc=e.sort_num_desc===!0?!0:!1,this.sortNumDesc=this.isSortNumDesc?e.sort_num_desc:null,this.slcFillingMethod=e.slc_filling_method||"createElement",this.fillSlcOnDemand=e.fill_slc_on_demand===!0?!0:!1,this.activateSlcTooltip=e.activate_slc_tooltip||"Click to activate",this.multipleSlcTooltip=e.multiple_slc_tooltip||"Use Ctrl key for multiple selections",this.hasCustomSlcOptions=types.isObj(e.custom_slc_options)?!0:!1,this.customSlcOptions=types.isArray(e.custom_slc_options)?e.custom_slc_options:null,this.onBeforeOperation=types.isFn(e.on_before_operation)?e.on_before_operation:null,this.onAfterOperation=types.isFn(e.on_after_operation)?e.on_after_operation:null,this.checkListDiv=[],this.checkListDivCssClass=e.div_checklist_css_class||"div_checklist",this.checkListCssClass=e.checklist_css_class||"flt_checklist",this.checkListItemCssClass=e.checklist_item_css_class||"flt_checklist_item",this.checkListSlcItemCssClass=e.checklist_selected_item_css_class||"flt_checklist_slc_item",this.activateCheckListTxt=e.activate_checklist_text||"Click to load filter data",this.checkListItemDisabledCssClass=e.checklist_item_disabled_css_class||"flt_checklist_item_disabled",this.enableCheckListResetFilter=e.enable_checklist_reset_filter===!1?!1:!0,this.rgxOperator=e.regexp_operator||"rgx:",this.emOperator=e.empty_operator||"[empty]",this.nmOperator=e.nonempty_operator||"[nonempty]",this.orOperator=e.or_operator||"||",this.anOperator=e.and_operator||"&&",this.grOperator=e.greater_operator||">",this.lwOperator=e.lower_operator||"<",this.leOperator=e.lower_equal_operator||"<=",this.geOperator=e.greater_equal_operator||">=",this.dfOperator=e.different_operator||"!",this.lkOperator=e.like_operator||"*",this.eqOperator=e.equal_operator||"=",this.stOperator=e.start_with_operator||"{",this.enOperator=e.end_with_operator||"}",this.curExp=e.cur_exp||"^[¥£€$]",this.separator=e.separator||",",this.rowsCounter=e.rows_counter===!0?!0:!1,this.statusBar=e.status_bar===!0?!0:!1,this.loader=e.loader===!0?!0:!1,this.displayBtn=e.btn===!0?!0:!1,this.btnText=e.btn_text||(this.enableIcons?"":"Go"),this.btnCssClass=e.btn_css_class||(this.enableIcons?"btnflt_icon":"btnflt"),this.btnReset=e.btn_reset===!0?!0:!1,this.btnResetCssClass=e.btn_reset_css_class||"reset",this.onBeforeReset=types.isFn(e.on_before_reset)?e.on_before_reset:null,this.onAfterReset=types.isFn(e.on_after_reset)?e.on_after_reset:null,this.paging=e.paging===!0?!0:!1,this.hasResultsPerPage=e.results_per_page===!0?!0:!1,this.btnPageCssClass=e.paging_btn_css_class||"pgInp",this.pagingSlc=null,this.resultsPerPage=null,this.resultsPerPageSlc=null,this.isPagingRemoved=!1,this.nbVisibleRows=0,this.nbHiddenRows=0,this.startPagingRow=0,this.nbPages=0,this.currentPageNb=1,this.sort=e.sort===!0?!0:!1,this.isSortEnabled=!1,this.sorted=!1,this.sortConfig=e.sort_config||{},this.sortConfig.name=void 0!==this.sortConfig.name?e.sort_config.name:"sortabletable",this.sortConfig.src=void 0!==this.sortConfig.src?e.sort_config.src:this.basePath+"sortabletable.js",this.sortConfig.adapterSrc=void 0!==this.sortConfig.adapter_src?e.sort_config.adapter_src:this.basePath+"tfAdapter.sortabletable.js",this.sortConfig.initialize=void 0!==this.sortConfig.initialize?e.sort_config.initialize:function(a){a.SetSortTable&&a.SetSortTable()},this.sortConfig.sortTypes=types.isArray(this.sortConfig.sort_types)?e.sort_config.sort_types:[],this.sortConfig.sortCol=void 0!==this.sortConfig.sort_col?e.sort_config.sort_col:null,this.sortConfig.asyncSort=this.sortConfig.async_sort===!0?!0:!1,this.sortConfig.triggerIds=types.isArray(this.sortConfig.sort_trigger_ids)?e.sort_config.sort_trigger_ids:[],this.selectable=e.selectable===!0?!0:!1,this.editable=e.editable===!0?!0:!1,this.ezEditTableConfig=e.ezEditTable_config||{},this.ezEditTableConfig.name=void 0!==this.ezEditTableConfig.name?e.ezEditTable_config.name:"ezedittable",this.ezEditTableConfig.src=void 0!==this.ezEditTableConfig.src?e.ezEditTable_config.src:this.basePath+"ezEditTable/ezEditTable.js",this.ezEditTableConfig.loadStylesheet=this.ezEditTableConfig.loadStylesheet===!0?!0:!1,this.ezEditTableConfig.stylesheet=this.ezEditTableConfig.stylesheet||this.basePath+"ezEditTable/ezEditTable.css",this.ezEditTableConfig.stylesheetName=void 0!==this.ezEditTableConfig.stylesheetName?e.ezEditTable_config.stylesheetName:"ezEditTableCss",this.ezEditTableConfig.err='Failed to instantiate EditTable object.\n"ezEditTable" module may not be available.',this.onKeyUp=e.on_keyup===!0?!0:!1,this.onKeyUpDelay=isNaN(e.on_keyup_delay)?900:e.on_keyup_delay,this.isUserTyping=null,this.onKeyUpTimer=void 0,this.highlightKeywords=e.highlight_keywords===!0?!0:!1,this.highlightCssClass=e.highlight_css_class||"keyword",this.highlightedNodes=[],this.defaultDateType=e.default_date_type||"DMY",this.thousandsSeparator=e.thousands_separator||",",this.decimalSeparator=e.decimal_separator||".",this.hasColNbFormat=e.col_number_format===!0?!0:!1,this.colNbFormat=types.isArray(this.hasColNbFormat)?e.col_number_format:null,this.hasColDateType=e.col_date_type===!0?!0:!1,this.colDateType=types.isArray(this.hasColDateType)?e.col_date_type:null,this.msgFilter=e.msg_filter||"Filtering data...",this.msgPopulate=e.msg_populate||"Populating filter...",this.msgPopulateCheckList=e.msg_populate_checklist||"Populating list...",this.msgChangePage=e.msg_change_page||"Collecting paging data...",this.msgClear=e.msg_clear||"Clearing filters...",this.msgChangeResults=e.msg_change_results||"Changing results per page...",this.msgResetValues=e.msg_reset_grid_values||"Re-setting filters values...",this.msgResetPage=e.msg_reset_page||"Re-setting page...",this.msgResetPageLength=e.msg_reset_page_length||"Re-setting page length...",this.msgSort=e.msg_sort||"Sorting data...",this.msgLoadExtensions=e.msg_load_extensions||"Loading extensions...",this.msgLoadThemes=e.msg_load_themes||"Loading theme(s)...",this.prfxTf="TF",this.prfxFlt="flt",this.prfxValButton="btn",this.prfxInfDiv="inf_",this.prfxLDiv="ldiv_",this.prfxRDiv="rdiv_",this.prfxMDiv="mdiv_",this.prfxContentDiv="cont_",this.prfxCheckListDiv="chkdiv_",this.prfxSlcPages="slcPages_",this.prfxSlcResults="slcResults_",this.prfxSlcResultsTxt="slcResultsTxt_",this.prfxBtnNextSpan="btnNextSpan_",this.prfxBtnPrevSpan="btnPrevSpan_",this.prfxBtnLastSpan="btnLastSpan_",this.prfxBtnFirstSpan="btnFirstSpan_",this.prfxBtnNext="btnNext_",this.prfxBtnPrev="btnPrev_",this.prfxBtnLast="btnLast_",this.prfxBtnFirst="btnFirst_",this.prfxPgSpan="pgspan_",this.prfxPgBeforeSpan="pgbeforespan_",this.prfxPgAfterSpan="pgafterspan_",this.prfxCounter="counter_",this.prfxTotRows="totrows_span_",this.prfxTotRowsTxt="totRowsTextSpan_",this.prfxResetSpan="resetspan_",this.prfxLoader="load_",this.prfxStatus="status_",this.prfxStatusSpan="statusSpan_",this.prfxStatusTxt="statusText_",this.prfxCookieFltsValues="tf_flts_",this.prfxCookiePageNb="tf_pgnb_",this.prfxCookiePageLen="tf_pglen_",this.prfxMainTblCont="gridCont_",this.prfxTblCont="tblCont_",this.prfxHeadTblCont="tblHeadCont_",this.prfxHeadTbl="tblHead_",this.prfxGridFltTd="_td_",this.prfxGridTh="tblHeadTh_",this.prfxHelpSpan="helpSpan_",this.prfxHelpDiv="helpDiv_",this.prfxPopUpSpan="popUpSpan_",this.prfxPopUpDiv="popUpDiv_",this.hasStoredValues=!1,this.rememberGridValues=e.remember_grid_values===!0?!0:!1,this.fltsValuesCookie=this.prfxCookieFltsValues+this.id,this.rememberPageNb=this.paging&&e.remember_page_number?!0:!1,this.pgNbCookie=this.prfxCookiePageNb+this.id,this.rememberPageLen=this.paging&&e.remember_page_length?!0:!1,this.pgLenCookie=this.prfxCookiePageLen+this.id,this.cookieDuration=isNaN(e.set_cookie_duration)?1e5:parseInt(e.set_cookie_duration,10),this.hasExtensions=e.extensions===!0?!0:!1,this.extensions=this.hasExtensions?e.extensions:null,this.enableDefaultTheme=e.enable_default_theme===!0?!0:!1,this.hasThemes=e.enable_default_theme||e.themes&&types.isObj(e.themes)?!0:!1,this.themes=this.hasThemes?e.themes:null,this.themesPath=e.themes_path||this.basePath+"TF_Themes/",this.loaderCpt=null;var j=this;this.Evt={name:{filter:"Filter",populateselect:"Populate",populatechecklist:"PopulateCheckList",changepage:"ChangePage",clear:"Clear",changeresultsperpage:"ChangeResults",resetvalues:"ResetValues",resetpage:"ResetPage",resetpagelength:"ResetPageLength",sort:"Sort",loadextensions:"LoadExtensions",loadthemes:"LoadThemes"},getKeyCode:function(a){return a.charCode?a.charCode:a.keyCode?a.keyCode:a.which?a.which:0},_DetectKey:function(a){if(j.enterKey){var b=a||global.event;if(b){var c=j.Evt.getKeyCode(b);13===c?(j._Filter(),evt.cancel(b),evt.stop(b)):(j.isUserTyping=!0,global.clearInterval(j.onKeyUpTimer),j.onKeyUpTimer=void 0)}}},_OnKeyUp:function(a){function b(){global.clearInterval(j.onKeyUpTimer),j.onKeyUpTimer=void 0,j.isUserTyping||(j.Filter(),j.isUserTyping=null)}if(j.onKeyUp){var c=a||global.event,d=j.Evt.getKeyCode(c);j.isUserTyping=!1,13!==d&&9!==d&&27!==d&&38!==d&&40!==d?void 0===j.onKeyUpTimer&&(j.onKeyUpTimer=global.setInterval(b,j.onKeyUpDelay)):(global.clearInterval(j.onKeyUpTimer),j.onKeyUpTimer=void 0)}},_OnKeyDown:function(){j.onKeyUp&&(j.isUserTyping=!0)},_OnInpBlur:function(){j.onKeyUp&&(j.isUserTyping=!1,global.clearInterval(j.onKeyUpTimer)),""===this.value&&""!==j.inpWatermark&&(this.value=j.isInpWatermarkArray?j.inpWatermark[this.getAttribute("ct")]:j.inpWatermark,dom.addClass(this,j.inpWatermarkCssClass)),j.ezEditTable&&(j.editable&&j.ezEditTable.Editable.Set(),j.selectable&&j.ezEditTable.Selection.Set())},_OnInpFocus:function(a){var b=a||global.event;if(j.activeFilterId=this.getAttribute("id"),j.activeFlt=dom.id(j.activeFilterId),j.isInpWatermarkArray){var c=j.inpWatermark[this.getAttribute("ct")];this.value===c&&""!==c&&(this.value="",dom.removeClass(this,j.inpWatermarkCssClass))}else this.value===j.inpWatermark&&""!==j.inpWatermark&&(this.value="",dom.removeClass(this,j.inpWatermarkCssClass));j.popUpFilters&&(evt.cancel(b),evt.stop(b)),j.ezEditTable&&(j.editable&&j.ezEditTable.Editable.Remove(),j.selectable&&j.ezEditTable.Selection.Remove())},_OnSlcFocus:function(a){var b=a||global.event;if(j.activeFilterId=this.getAttribute("id"),j.activeFlt=dom.id(j.activeFilterId),j.fillSlcOnDemand&&"0"===this.getAttribute("filled")){var c=this.getAttribute("ct");j.PopulateSelect(c),hlp.isIE()||this.setAttribute("filled","1")}j.popUpFilters&&(evt.cancel(b),evt.stop(b))},_OnSlcChange:function(a){var b=j.activeFlt.getAttribute("colIndex");if(!j.activeFlt||!b||j["col"+b]!==j.fltTypeCheckList||j.Evt._OnSlcChange.caller){var c=a||global.event;j.popUpFilters&&evt.stop(c),j.onSlcChange&&j.Filter()}},_OnSlcBlur:function(){},_OnCheckListChange:function(a){j.Evt._OnCheckListChange.caller&&j.Evt._OnSlcChange(a)},_OnCheckListClick:function(){if(j.fillSlcOnDemand&&"0"===this.getAttribute("filled")){var a=this.getAttribute("ct");j.PopulateCheckList(a),j.checkListDiv[a].onclick=null,j.checkListDiv[a].title=""}},_OnCheckListFocus:function(){j.activeFilterId=this.firstChild.getAttribute("id"),j.activeFlt=dom.id(j.activeFilterId)},_OnCheckListBlur:function(){},_OnBtnClick:function(){j.Filter()},_OnSlcPagesChangeEvt:null,_EnableSlc:function(){this.firstChild.disabled=!1,this.firstChild.focus(),this.onclick=null},_Clear:function(){j.ClearFilters()},_OnHelpBtnClick:function(){j._ToggleHelp()},_Paging:{nextEvt:null,prevEvt:null,lastEvt:null,firstEvt:null}}}}function numSortAsc(a,b){return a-b}function numSortDesc(a,b){return b-a}function ignoreCaseSort(a,b){var c=str.lower(a),d=str.lower(b);return d>c?-1:c>d?1:0}function removeNbFormat(a,b){if(a){b||(b="us");var c=a;return c="us"===str.lower(b)?+c.replace(/[^\d\.-]/g,""):+c.replace(/[^\d\,-]/g,"").replace(",",".")}}function isImported(a,b){for(var c=!1,d=b?b:"script",e="script"==d?"src":"href",f=dom.tag(doc,d),g=0;g0?f[0].insertRow(this.filtersRowIndex):this.tbl.insertRow(this.filtersRowIndex),this.headersRow>1&&this.filtersRowIndex<=this.headersRow&&!this.popUpFilters&&this.headersRow++,this.popUpFilters&&this.headersRow++,this.fixedHeaders&&this.SetFixedHeaders(),e.className=this.fltsRowCssClass,this.isExternalFlt&&(!this.gridLayout||this.popUpFilters)&&(e.style.display="none")}this.nbFilterableRows=this.GetRowsNb(),this.nbVisibleRows=this.nbFilterableRows,this.nbRows=this.tbl.rows.length;for(var g=0;c>g;g++){var h=dom.create(this.fltCellTag),i=this["col"+g],j=this.isExternalFlt&&this.externalFltTgtIds?this.externalFltTgtIds[g]:null;if(this.singleSearchFlt&&(h.colSpan=this.nbCells),this.gridLayout||e.appendChild(h),a=g==c-1&&this.displayBtn?this.fltSmallCssClass:this.fltCssClass,this.popUpFilters&&this.SetPopupFilter(g),void 0===i&&(i=void 0===b["col_"+g]?this.fltTypeInp:str.lower(b["col_"+g])),this.singleSearchFlt&&(i=this.fltTypeInp,a=this.singleFltCssClass),i===this.fltTypeSlc||i===this.fltTypeMulti){var k=dom.create(this.fltTypeSlc,["id",this.prfxFlt+g+"_"+this.id],["ct",g],["filled","0"]);if(i===this.fltTypeMulti&&(k.multiple=this.fltTypeMulti,k.title=this.multipleSlcTooltip),k.className=str.lower(i)===this.fltTypeSlc?a:this.fltMultiCssClass,j?(dom.id(j).appendChild(k),this.externalFltEls.push(k)):h.appendChild(k),this.fltIds.push(this.prfxFlt+g+"_"+this.id),this.fillSlcOnDemand||this._PopulateSelect(g),k.onkeypress=this.Evt._DetectKey,k.onchange=this.Evt._OnSlcChange,k.onfocus=this.Evt._OnSlcFocus,k.onblur=this.Evt._OnSlcBlur,this.fillSlcOnDemand){var l=dom.createOpt(this.displayAllText,"");k.appendChild(l)}this.fillSlcOnDemand&&hlp.isIE()&&(k.disabled=!0,k.title=this.activateSlcTooltip,k.parentNode.onclick=this.Evt._EnableSlc,i===this.fltTypeMulti&&this.__deferMultipleSelection(k,0))}else if(i===this.fltTypeCheckList){var m=dom.create("div",["id",this.prfxCheckListDiv+g+"_"+this.id],["ct",g],["filled","0"]);m.className=this.checkListDivCssClass,j?(dom.id(j).appendChild(m),this.externalFltEls.push(m)):h.appendChild(m),this.checkListDiv[g]=m,this.fltIds.push(this.prfxFlt+g+"_"+this.id),this.fillSlcOnDemand||this._PopulateCheckList(g),m.onclick=this.Evt._OnCheckListFocus,this.fillSlcOnDemand&&(m.onclick=this.Evt._OnCheckListClick,m.appendChild(dom.text(this.activateCheckListTxt))) }else{var n=i===this.fltTypeInp?"text":"hidden",o=dom.create(this.fltTypeInp,["id",this.prfxFlt+g+"_"+this.id],["type",n],["ct",g]);if("hidden"!=n&&(o.value=this.isInpWatermarkArray?this.inpWatermark[g]:this.inpWatermark),o.className=a,""!==this.inpWatermark&&dom.addClass(o,this.inpWatermarkCssClass),o.onfocus=this.Evt._OnInpFocus,j?(dom.id(j).appendChild(o),this.externalFltEls.push(o)):h.appendChild(o),this.fltIds.push(this.prfxFlt+g+"_"+this.id),o.onkeypress=this.Evt._DetectKey,o.onkeydown=this.Evt._OnKeyDown,o.onkeyup=this.Evt._OnKeyUp,o.onblur=this.Evt._OnInpBlur,this.rememberGridValues){var p=cookie.read(this.fltsValuesCookie),q=new RegExp(this.separator,"g"),r=p.split(q);" "!=r[g]&&this.SetFilterValue(g,r[g],!1)}}if(g==c-1&&this.displayBtn){var s=dom.create(this.fltTypeInp,["id",this.prfxValButton+g+"_"+this.id],["type","button"],["value",this.btnText]);s.className=this.btnCssClass,j?dom.id(j).appendChild(s):h.appendChild(s),s.onclick=this.Evt._OnBtnClick}}}else this.__resetGrid();else this.refRow=this.refRow-1,this.gridLayout&&(this.refRow=0),this.nbFilterableRows=this.GetRowsNb(),this.nbVisibleRows=this.nbFilterableRows,this.nbRows=this.nbFilterableRows+this.refRow;this.rowsCounter&&this.SetRowsCounter(),this.statusBar&&this.SetStatusBar(),this.fixedHeaders&&!this.isFirstLoad&&this.SetFixedHeaders(),this.paging&&this.SetPaging(),this.hasResultsPerPage&&this.paging&&this.SetResultsPerPage(),this.btnReset&&this.SetResetBtn(),this.helpInstructions&&this.SetHelpInstructions(),this.hasColWidth&&!this.gridLayout&&this.SetColWidths(),this.alternateBgs&&this.isStartBgAlternate&&this.SetAlternateRows(),this.hasColOperation&&this.fltGrid&&(this.colOperation=b.col_operation,this.SetColOperation()),(this.sort||this.gridLayout)&&this.SetSort(),(this.selectable||this.editable)&&this.SetEditable(),this.isFirstLoad=!1,this.hasGrid=!0,(this.rememberGridValues||this.rememberPageLen||this.rememberPageNb)&&this.ResetValues(),this.gridLayout||dom.addClass(this.tbl,this.prfxTf),this.loader&&this.loaderCpt.show("none"),this.hasExtensions&&this.LoadExtensions(),this.onFiltersLoaded&&this.onFiltersLoaded.call(null,this)}},EvtManager:function(a,b){function c(){if(a){switch(a){case d.Evt.name.filter:d.isModFilterFn?d.modFilterFn.call(null,d):d._Filter();break;case d.Evt.name.populateselect:d.refreshFilters?d._PopulateSelect(e,!0):d._PopulateSelect(e,!1,f,g);break;case d.Evt.name.populatechecklist:d._PopulateCheckList(e,f,g);break;case d.Evt.name.changepage:d._ChangePage(h);break;case d.Evt.name.clear:d._ClearFilters(),d._Filter();break;case d.Evt.name.changeresultsperpage:d._ChangeResultsPerPage();break;case d.Evt.name.resetvalues:d._ResetValues(),d._Filter();break;case d.Evt.name.resetpage:d._ResetPage(d.pgNbCookie);break;case d.Evt.name.resetpagelength:d._ResetPageLength(d.pgLenCookie);break;case d.Evt.name.sort:break;case d.Evt.name.loadextensions:d._LoadExtensions();break;case d.Evt.name.loadthemes:d._LoadThemes();break;default:d["_"+a].call(null,d,b)}(d.status||d.statusBar)&&d.StatusMsg(""),d.loader&&d.loaderCpt.show("none")}}var d=this,e=b&&void 0!==b.slcIndex?b.slcIndex:null,f=b&&void 0!==b.slcExternal?b.slcExternal:!1,g=b&&void 0!==b.slcId?b.slcId:null,h=b&&void 0!==b.pgIndex?b.pgIndex:null;if(this.loader||this.status||this.statusBar){try{this.loaderCpt.show(""),this.StatusMsg(d["msg"+a])}catch(i){}global.setTimeout(c,this.execDelay)}else c()},ImportModule:function(a){a.path&&a.name&&this.IncludeFile(a.name,a.path,a.init)},LoadExtensions:function(){if(!this.Ext){var a=this;this.Ext={list:{},add:function(b,c,d,e){var f=d.split("/")[d.split("/").length-1],g=new RegExp(f),h=d.replace(g,"");a.Ext.list[b]={name:b,description:c,file:f,path:h,callback:e}}}}this.EvtManager(this.Evt.name.loadextensions)},_LoadExtensions:function(){if(this.hasExtensions&&types.isArray(this.extensions.name)&&types.isArray(this.extensions.src))for(var a=this.extensions,b=0;b',this.btnPrevPageHtml='',this.btnNextPageHtml='',this.btnFirstPageHtml='',this.btnLastPageHtml='',this.loader=!0,this.loaderHtml='
',this.loaderText=null}},RemoveGrid:function(){if(this.fltGrid&&this.hasGrid){var a=this.tbl.rows;this.paging&&this.RemovePaging(),this.statusBar&&this.RemoveStatusBar(),this.rowsCounter&&this.RemoveRowsCounter(),this.btnReset&&this.RemoveResetBtn(),(this.helpInstructions||!this.helpInstructions)&&this.RemoveHelpInstructions(),this.paging&&this.RemoveResultsPerPage(),this.isExternalFlt&&!this.popUpFilters&&this.RemoveExternalFlts(),this.fixedHeaders&&this.RemoveFixedHeaders(),this.infDiv&&this.RemoveTopDiv(),this.highlightKeywords&&this.UnhighlightAll(),this.sort&&this.RemoveSort(),this.loader&&this.loaderCpt.remove(),this.popUpFilters&&this.RemovePopupFilters(),this.markActiveColumns&&this.ClearActiveColumns(),(this.editable||this.selectable)&&this.RemoveEditable();for(var b=this.refRow;b0&&!c.startRow?void 0:c.startRow||a.refRow,c.scroll_into_view=c.scroll_into_view===!1?!1:!0,c.base_path=c.base_path||a.basePath+"ezEditTable/",c.editable=a.editable=a.fObj.editable,c.selection=a.selectable=a.fObj.selectable,a.selectable&&(c.default_selection=c.default_selection||"row"),c.active_cell_css=c.active_cell_css||"ezETSelectedCell",a._lastValidRowIndex=0,a._lastRowIndex=0,a.selectable){var e=function(b,c,d){if(a.validRowsIndex){var e,f=a.validRowsIndex,g=f.length,h="row"!==b.defaultSelection?c.parentNode:c,i="TD"===c.nodeName?c:null,j=void 0!==d?b.Event.GetKey(d):0,k=array.has(f,h.rowIndex),l=34===j||33===j?a.pagingLength||b.nbRowsPerPage:1;if(k)34!==j&&33!==j?(a._lastValidRowIndex=array.indexByValue(f,h.rowIndex),a._lastRowIndex=h.rowIndex):(e=34===j?a._lastValidRowIndex+l<=g-1?f[a._lastValidRowIndex+l]:[g-1]:a._lastValidRowIndex-l<=f[0]?f[0]:f[a._lastValidRowIndex-l],a._lastRowIndex=e,a._lastValidRowIndex=array.indexByValue(f,e),o(e));else{if(h.rowIndex>a._lastRowIndex)if(h.rowIndex>=f[g-1])e=f[g-1];else{var m=a._lastValidRowIndex+l;e=m>g-1?f[g-1]:f[m]}else if(h.rowIndex<=f[0])e=f[0];else{var n=f[a._lastValidRowIndex-l];e=n?n:f[0]}a._lastRowIndex=h.rowIndex,o(e)}var o=function(d){if("row"===b.defaultSelection)b.Selection.SelectRowByIndex(d);else{b.ClearSelections();var e=c.cellIndex,f=a.tbl.rows[d];"both"===b.defaultSelection&&b.Selection.SelectRowByIndex(d),f&&b.Selection.SelectCell(f.cells[e])}if(a.validRowsIndex.length!==a.GetRowsNb()){var g=a.tbl.rows[d];g&&g.scrollIntoView(!1),i&&(i.cellIndex===a.GetCellsNb()-1&&a.gridLayout?a.tblCont.scrollLeft=1e8:0===i.cellIndex&&a.gridLayout?a.tblCont.scrollLeft=0:i.scrollIntoView(!1))}}}},f=function(b,c){var d="row"!==b.defaultSelection?c.parentNode:c;if(a.paging&&a.nbPages>1){b.nbRowsPerPage=a.pagingLength;var e=a.validRowsIndex,f=e.length,g=parseInt(a.startPagingRow,10)+parseInt(a.pagingLength,10),h=d.rowIndex;h===e[f-1]&&a.currentPageNb!=a.nbPages?a.SetPage("last"):h==e[0]&&1!==a.currentPageNb?a.SetPage("first"):h>e[g-1]&&he[0]&&a.SetPage("previous")}};if(a.paging&&(a.onAfterChangePage=function(a){var b=a.ezEditTable,c=b.Selection.GetActiveRow();c&&c.scrollIntoView(!1);var d=b.Selection.GetActiveCell();d&&d.scrollIntoView(!1)}),"row"===c.default_selection){var g=c.on_before_selected_row;c.on_before_selected_row=function(){f(arguments[0],arguments[1],arguments[2]),g&&g.call(null,arguments[0],arguments[1],arguments[2])};var h=c.on_after_selected_row;c.on_after_selected_row=function(){e(arguments[0],arguments[1],arguments[2]),h&&h.call(null,arguments[0],arguments[1],arguments[2])}}else{var i=c.on_before_selected_cell;c.on_before_selected_cell=function(){f(arguments[0],arguments[1],arguments[2]),i&&i.call(null,arguments[0],arguments[1],arguments[2])};var j=c.on_after_selected_cell;c.on_after_selected_cell=function(){e(arguments[0],arguments[1],arguments[2]),j&&j.call(null,arguments[0],arguments[1],arguments[2])}}}if(a.editable){var k=c.on_added_dom_row;if(c.on_added_dom_row=function(){a.nbFilterableRows++,a.paging?(a.nbRows++,a.nbVisibleRows++,a.nbFilterableRows++,a.paging=!1,a.RemovePaging(),a.AddPaging(!1)):a.RefreshNbRows(),a.alternateBgs&&a.SetAlternateRows(),k&&k.call(null,arguments[0],arguments[1],arguments[2])},c.actions&&c.actions["delete"]){var l=c.actions["delete"].on_after_submit;c.actions["delete"].on_after_submit=function(){a.nbFilterableRows--,a.paging?(a.nbRows--,a.nbVisibleRows--,a.nbFilterableRows--,a.paging=!1,a.RemovePaging(),a.AddPaging(!1)):a.RefreshNbRows(),a.alternateBgs&&a.SetAlternateRows(),l&&l.call(null,arguments[0],arguments[1])}}}try{a.ezEditTable=new EditTable(a.id,c,b),a.ezEditTable.Init()}catch(m){console.log(c.err)}},SetPaging:function(){if((this.hasGrid||this.isFirstLoad)&&this.paging&&(this.isPagingRemoved||this.isFirstLoad)){var a=this.fObj;this.pagingTgtId=a.paging_target_id||null,this.pagingLength=isNaN(a.paging_length)?10:a.paging_length,this.resultsPerPageTgtId=a.results_per_page_target_id||null,this.pgSlcCssClass=a.paging_slc_css_class||"pgSlc",this.pgInpCssClass=a.paging_inp_css_class||"pgNbInp",this.resultsSlcCssClass=a.results_slc_css_class||"rspg",this.resultsSpanCssClass=a.results_span_css_class||"rspgSpan",this.nbVisibleRows=0,this.nbHiddenRows=0,this.startPagingRow=0,this.nbPages=0,this.btnNextPageText=a.btn_next_page_text||">",this.btnPrevPageText=a.btn_prev_page_text||"<",this.btnLastPageText=a.btn_last_page_text||">|",this.btnFirstPageText=a.btn_first_page_text||"|<",this.btnNextPageHtml=a.btn_next_page_html||(this.enableIcons?'':null),this.btnPrevPageHtml=a.btn_prev_page_html||(this.enableIcons?'':null),this.btnFirstPageHtml=a.btn_first_page_html||(this.enableIcons?'':null),this.btnLastPageHtml=a.btn_last_page_html||(this.enableIcons?'':null),this.pageText=a.page_text||" Page ",this.ofText=a.of_text||" of ",this.nbPgSpanCssClass=a.nb_pages_css_class||"nbpg",this.hasPagingBtns=a.paging_btns===!1?!1:!0,this.pagingBtnEvents=null,this.pageSelectorType=a.page_selector_type||this.fltTypeSlc,this.onBeforeChangePage=types.isFn(a.on_before_change_page)?a.on_before_change_page:null,this.onAfterChangePage=types.isFn(a.on_after_change_page)?a.on_after_change_page:null;var b=this.refRow,c=this.nbRows;if(this.nbPages=Math.ceil((c-b)/this.pagingLength),!this.Evt._Paging.next){var d=this;this.Evt._Paging={slcIndex:function(){return d.pageSelectorType===d.fltTypeSlc?d.pagingSlc.options.selectedIndex:parseInt(d.pagingSlc.value,10)-1},nbOpts:function(){return d.pageSelectorType===d.fltTypeSlc?parseInt(d.pagingSlc.options.length,10)-1:d.nbPages-1},next:function(){d.Evt._Paging.nextEvt&&d.Evt._Paging.nextEvt();var a=d.Evt._Paging.slcIndex()0?d.Evt._Paging.slcIndex()-1:d.Evt._Paging.nbOpts();d.ChangePage(a)},last:function(){d.Evt._Paging.lastEvt&&d.Evt._Paging.lastEvt(),d.ChangePage(d.Evt._Paging.nbOpts())},first:function(){d.Evt._Paging.firstEvt&&d.Evt._Paging.firstEvt(),d.ChangePage(0)},_detectKey:function(a){var b=a||global.event;if(b){var c=d.Evt.getKeyCode(a);13===c&&(d.sorted?(d.Filter(),d.ChangePage(d.Evt._Paging.slcIndex())):d.ChangePage(),this.blur())}},nextEvt:null,prevEvt:null,lastEvt:null,firstEvt:null}}this.Evt._OnSlcPagesChange||(this.Evt._OnSlcPagesChange=function(){d.Evt._Paging._OnSlcPagesChangeEvt&&d.Evt._Paging._OnSlcPagesChangeEvt(),d.ChangePage(),this.blur(),this.parentNode&&hlp.isIE()&&this.parentNode.focus()});var e;this.pageSelectorType===this.fltTypeSlc&&(e=dom.create(this.fltTypeSlc,["id",this.prfxSlcPages+this.id]),e.className=this.pgSlcCssClass,e.onchange=this.Evt._OnSlcPagesChange),this.pageSelectorType===this.fltTypeInp&&(e=dom.create(this.fltTypeInp,["id",this.prfxSlcPages+this.id],["value",this.currentPageNb]),e.className=this.pgInpCssClass,e.onkeypress=this.Evt._Paging._detectKey);var f=dom.create("span",["id",this.prfxBtnNextSpan+this.id]),g=dom.create("span",["id",this.prfxBtnPrevSpan+this.id]),h=dom.create("span",["id",this.prfxBtnLastSpan+this.id]),i=dom.create("span",["id",this.prfxBtnFirstSpan+this.id]);if(this.hasPagingBtns){if(this.btnNextPageHtml)f.innerHTML=this.btnNextPageHtml,f.onclick=this.Evt._Paging.next;else{var j=dom.create(this.fltTypeInp,["id",this.prfxBtnNext+this.id],["type","button"],["value",this.btnNextPageText],["title","Next"]);j.className=this.btnPageCssClass,j.onclick=this.Evt._Paging.next,f.appendChild(j)}if(this.btnPrevPageHtml)g.innerHTML=this.btnPrevPageHtml,g.onclick=this.Evt._Paging.prev;else{var k=dom.create(this.fltTypeInp,["id",this.prfxBtnPrev+this.id],["type","button"],["value",this.btnPrevPageText],["title","Previous"]);k.className=this.btnPageCssClass,k.onclick=this.Evt._Paging.prev,g.appendChild(k)}if(this.btnLastPageHtml)h.innerHTML=this.btnLastPageHtml,h.onclick=this.Evt._Paging.last;else{var l=dom.create(this.fltTypeInp,["id",this.prfxBtnLast+this.id],["type","button"],["value",this.btnLastPageText],["title","Last"]);l.className=this.btnPageCssClass,l.onclick=this.Evt._Paging.last,h.appendChild(l)}if(this.btnFirstPageHtml)i.innerHTML=this.btnFirstPageHtml,i.onclick=this.Evt._Paging.first;else{var m=dom.create(this.fltTypeInp,["id",this.prfxBtnFirst+this.id],["type","button"],["value",this.btnFirstPageText],["title","First"]);m.className=this.btnPageCssClass,m.onclick=this.Evt._Paging.first,i.appendChild(m)}}this.pagingTgtId||this.SetTopDiv();var n=this.pagingTgtId?dom.id(this.pagingTgtId):this.mDiv;""!==n.innerHTML&&(n.innerHTML=""),n.appendChild(i),n.appendChild(g);var o=dom.create("span",["id",this.prfxPgBeforeSpan+this.id]);o.appendChild(dom.text(this.pageText)),o.className=this.nbPgSpanCssClass,n.appendChild(o),n.appendChild(e);var p=dom.create("span",["id",this.prfxPgAfterSpan+this.id]);p.appendChild(dom.text(this.ofText)),p.className=this.nbPgSpanCssClass,n.appendChild(p);var q=dom.create("span",["id",this.prfxPgSpan+this.id]);q.className=this.nbPgSpanCssClass,q.appendChild(dom.text(" "+this.nbPages+" ")),n.appendChild(q),n.appendChild(f),n.appendChild(h),this.pagingSlc=dom.id(this.prfxSlcPages+this.id),(!this.rememberGridValues||this.isPagingRemoved)&&this.SetPagingInfo(),this.fltGrid||(this.ValidateAllRows(),this.SetPagingInfo(this.validRowsIndex)),this.pagingBtnEvents=this.Evt._Paging,this.isPagingRemoved=!1}},RemovePaging:function(){if(this.hasGrid&&this.pagingSlc){var a,b,c,d,e,f,g;a=dom.id(this.prfxBtnNextSpan+this.id),b=dom.id(this.prfxBtnPrevSpan+this.id),c=dom.id(this.prfxBtnLastSpan+this.id),d=dom.id(this.prfxBtnFirstSpan+this.id),e=dom.id(this.prfxPgBeforeSpan+this.id),f=dom.id(this.prfxPgAfterSpan+this.id),g=dom.id(this.prfxPgSpan+this.id),this.pagingSlc.parentNode.removeChild(this.pagingSlc),a&&a.parentNode.removeChild(a),b&&b.parentNode.removeChild(b),c&&c.parentNode.removeChild(c),d&&d.parentNode.removeChild(d),e&&e.parentNode.removeChild(e),f&&f.parentNode.removeChild(f),g&&g.parentNode.removeChild(g),this.pagingBtnEvents=null,this.pagingSlc=null,this.isPagingRemoved=!0}},SetPagingInfo:function(a){var b=this.tbl.rows,c=this.pagingTgtId?dom.id(this.pagingTgtId):this.mDiv,d=dom.id(this.prfxPgSpan+this.id);if(a&&a.length>0)this.validRowsIndex=a;else{this.validRowsIndex=[];for(var e=this.refRow;e0)if(c.style.visibility="visible",this.pageSelectorType===this.fltTypeSlc)for(var h=0;h=this.startPagingRow&&c>d?("true"!==e.getAttribute("validRow")&&e.getAttribute("validRow")||(e.style.display=""),this.alternateBgs&&this.SetRowBg(this.validRowsIndex[d],d)):(e.style.display="none",this.alternateBgs&&this.RemoveRowBg(this.validRowsIndex[d]))}this.nbVisibleRows=this.validRowsIndex.length,this.isStartBgAlternate=!1,this.ApplyGridProps()},SetPage:function(a){if(this.hasGrid&&this.paging){var b=this.pagingBtnEvents,c=typeof a;if("string"===c)switch(str.lower(a)){case"next":b.next();break;case"previous":b.prev();break;case"last":b.last();break;case"first":b.first();break;default:b.next()}"number"===c&&this.ChangePage(a-1)}},SetResultsPerPage:function(){if((this.hasGrid||this.isFirstLoad)&&!this.resultsPerPageSlc&&this.resultsPerPage){if(!this.Evt._OnSlcResultsChange){var a=this;this.Evt._OnSlcResultsChange=function(){a.ChangeResultsPerPage(),this.blur(),this.parentNode&&hlp.isIE()&&this.parentNode.focus()}}var b=dom.create(this.fltTypeSlc,["id",this.prfxSlcResults+this.id]);b.className=this.resultsSlcCssClass;var c=this.resultsPerPage[0],d=this.resultsPerPage[1],e=dom.create("span",["id",this.prfxSlcResultsTxt+this.id]);e.className=this.resultsSpanCssClass,this.resultsPerPageTgtId||this.SetTopDiv();var f=this.resultsPerPageTgtId?dom.id(this.resultsPerPageTgtId):this.rDiv;e.appendChild(dom.text(c)),f.appendChild(e),f.appendChild(b),this.resultsPerPageSlc=dom.id(this.prfxSlcResults+this.id);for(var g=0;g<, <=, >, >=, =, *, !, {, }, ||,&&, [empty], [nonempty], rgx:
These operators are described here:
http://tablefilter.free.fr/#operators
',this.helpInstrHtml=a.help_instructions_html||null,this.helpInstrBtnText=a.help_instructions_btn_text||"?",this.helpInstrBtnHtml=a.help_instructions_btn_html||null,this.helpInstrBtnCssClass=a.help_instructions_btn_css_class||"helpBtn",this.helpInstrContCssClass=a.help_instructions_container_css_class||"helpCont",this.helpInstrBtnEl=null,this.helpInstrContEl=null,this.helpInstrDefaultHtml='

HTML Table Filter Generator v. '+this.version+'

http://tablefilter.free.fr
©2009-'+this.year+' Max Guglielmi.
";var b=dom.create("span",["id",this.prfxHelpSpan+this.id]),c=dom.create("div",["id",this.prfxHelpDiv+this.id]);this.helpInstrTgtId||this.SetTopDiv();var d=this.helpInstrTgtId?dom.id(this.helpInstrTgtId):this.rDiv;d.appendChild(b);var e=this.helpInstrContTgtId?dom.id(this.helpInstrContTgtId):b;if(this.helpInstrBtnHtml){b.innerHTML=this.helpInstrBtnHtml;var f=b.firstChild;f.onclick=this.Evt._OnHelpBtnClick,e.appendChild(c)}else{e.appendChild(c);var g=dom.create("a",["href","javascript:void(0);"]);g.className=this.helpInstrBtnCssClass,g.appendChild(dom.text(this.helpInstrBtnText)),b.appendChild(g),g.onclick=this.Evt._OnHelpBtnClick}this.helpInstrHtml?(this.helpInstrContTgtId&&e.appendChild(c),c.innerHTML=this.helpInstrHtml,this.helpInstrContTgtId||(c.className=this.helpInstrContCssClass,c.ondblclick=this.Evt._OnHelpBtnClick)):(c.innerHTML=this.helpInstrText,c.className=this.helpInstrContCssClass,c.ondblclick=this.Evt._OnHelpBtnClick),c.innerHTML+=this.helpInstrDefaultHtml,this.helpInstrContEl=c,this.helpInstrBtnEl=b}},RemoveHelpInstructions:function(){this.helpInstrBtnEl&&(this.helpInstrBtnEl.parentNode.removeChild(this.helpInstrBtnEl),this.helpInstrBtnEl=null,this.helpInstrContEl&&(this.helpInstrContEl.parentNode.removeChild(this.helpInstrContEl),this.helpInstrContEl=null))},_ToggleHelp:function(){if(this.helpInstrContEl){var a=this.helpInstrContEl.style.display;if(""===a||"none"===a){this.helpInstrContEl.style.display="block";var b=dom.position(this.helpInstrBtnEl).left;this.helpInstrContTgtId||(this.helpInstrContEl.style.left=b-this.helpInstrContEl.clientWidth+25+"px")}else this.helpInstrContEl.style.display="none"}},ChangePage:function(a){this.EvtManager(this.Evt.name.changepage,{pgIndex:a})},_ChangePage:function(a){this.paging&&(a||(a=this.pageSelectorType===this.fltTypeSlc?this.pagingSlc.options.selectedIndex:this.pagingSlc.value-1),a>=0&&a<=this.nbPages-1&&(this.onBeforeChangePage&&this.onBeforeChangePage.call(null,this,a),this.currentPageNb=parseInt(a,10)+1,this.pageSelectorType===this.fltTypeSlc?this.pagingSlc.options[a].selected=!0:this.pagingSlc.value=this.currentPageNb,this.rememberPageNb&&this.RememberPageNb(this.pgNbCookie),this.startPagingRow=this.pageSelectorType===this.fltTypeSlc?this.pagingSlc.value:a*this.pagingLength,this.GroupByPage(),this.onAfterChangePage&&this.onAfterChangePage.call(null,this,a)))},ChangeResultsPerPage:function(){this.EvtManager(this.Evt.name.changeresultsperpage)},_ChangeResultsPerPage:function(){if(this.paging){var a=this.resultsPerPageSlc,b=this.pageSelectorType==this.fltTypeSlc?this.pagingSlc.selectedIndex:parseInt(this.pagingSlc.value-1,10);if(this.pagingLength=parseInt(a.options[a.selectedIndex].value,10),this.startPagingRow=this.pagingLength*b,!isNaN(this.pagingLength)){if(this.startPagingRow>=this.nbFilterableRows&&(this.startPagingRow=this.nbFilterableRows-this.pagingLength),this.SetPagingInfo(),this.pageSelectorType===this.fltTypeSlc){var c=this.pagingSlc.options.length-1<=b?this.pagingSlc.options.length-1:b;this.pagingSlc.options[c].selected=!0}this.rememberPageLen&&this.RememberPageLength(this.pgLenCookie)}}},ResetPage:function(){this.EvtManager(this.Evt.name.resetpage)},_ResetPage:function(a){var b=cookie.read(a);""!==b&&this.ChangePage(b-1)},ResetPageLength:function(){this.EvtManager(this.Evt.name.resetpagelength)},_ResetPageLength:function(a){if(this.paging){var b=cookie.read(a);""!==b&&(this.resultsPerPageSlc.options[b].selected=!0,this.ChangeResultsPerPage())}},AddPaging:function(a){this.hasGrid&&!this.paging&&(this.paging=!0,this.isPagingRemoved=!0,this.SetPaging(),this.ResetValues(),a&&this.Filter())},PopulateSelect:function(a,b,c){this.EvtManager(this.Evt.name.populateselect,{slcIndex:a,slcExternal:b,slcId:c})},_PopulateSelect:function(a,b,c,d){function e(){if("innerhtml"===m)o+='";else{var a=dom.createOpt(j.enableSlcResetFilter?j.displayAllText:"","");if(j.enableSlcResetFilter||(a.style.display="none"),i.appendChild(a),j.enableEmptyOption){var b=dom.createOpt(j.emptyText,j.emOperator);i.appendChild(b)}if(j.enableNonEmptyOption){var c=dom.createOpt(j.nonEmptyText,j.nmOperator);i.appendChild(c)}}}function f(){var c=i.value;i.innerHTML="",e();for(var d=0;d"+g+""}else{var l;l=j.fillSlcOnDemand&&c==n[d]&&j["col"+a]===j.fltTypeSlc?dom.createOpt(g,f,!0):j["col"+a]!=j.fltTypeMulti?dom.createOpt(g,f," "!==r[a]&&f==r[a]?!0:!1):dom.createOpt(g,f,array.has(s,str.matchCase(n[d],j.matchCase),j.matchCase)||-1!==s.toString().indexOf(f)?!0:!1),h&&(l.disabled=!0),i.appendChild(l)}}"innerhtml"===m&&(i.innerHTML+=o),i.setAttribute("filled","1")}c=void 0===c?!1:c;var g=this.fltIds[a];if((dom.id(g)||c)&&(dom.id(d)||!c)){var h,i=dom.id(c?d:g),j=this,k=this.tbl.rows,l=this.matchCase,m=str.lower(this.slcFillingMethod),n=[],o="",p=this.hasCustomSlcOptions&&array.has(this.customSlcOptions.cols,a),q=[];b&&this.activeFilterId&&(h=this.activeFilterId.split("_")[0],h=h.split(this.prfxFlt)[1]);var r=[],s=[];this.rememberGridValues&&(r=cookie.valueToArray(this.fltsValuesCookie,this.separator),r&&!str.isEmpty(r.toString())&&(p?s.push(r[a]):s=r[a].split(" "+j.orOperator+" ")));var t=null,u=null;b&&this.disableExcludedOptions&&(t=[],u=[]);for(var v=this.refRow;vy;y++)if(a===y&&(!b||b&&this.disableExcludedOptions)||a==y&&b&&(""===k[v].style.display&&!this.paging||this.paging&&(!this.validRowsIndex||this.validRowsIndex&&array.has(this.validRowsIndex,v))&&(void 0===h||h==a||h!=a&&array.has(this.validRowsIndex,v)))){var z=this.GetCellData(y,w[y]),A=str.matchCase(z,l);if(array.has(n,A,l)||n.push(z),b&&this.disableExcludedOptions){var B=u[y];B||(B=this.GetFilteredDataCol(y)),!array.has(B,A,l)&&!array.has(t,A,l)&&!this.isFirstLoad&&t.push(z)}}}if(p){var C=this.__getCustomValues(a);n=C[0],q=C[1]}if(this.sortSlc&&!p&&(l?(n.sort(),t&&t.sort()):(n.sort(ignoreCaseSort),t&&t.sort(ignoreCaseSort))),this.sortNumAsc&&array.has(this.sortNumAsc,a))try{n.sort(numSortAsc),t&&t.sort(numSortAsc),p&&q.sort(numSortAsc)}catch(D){n.sort(),t&&t.sort(),p&&q.sort()}if(this.sortNumDesc&&array.has(this.sortNumDesc,a))try{n.sort(numSortDesc),t&&t.sort(numSortDesc),p&&q.sort(numSortDesc)}catch(D){n.sort(),t&&t.sort(),p&&q.sort()}f()}},__deferMultipleSelection:function(a,b,c){if("select"===str.lower(a.nodeName)){var d=void 0===c?!1:c,e=this;global.setTimeout(function(){a.options[0].selected=!1,a.options[b].selected=""===a.options[b].value?!1:!0,d&&e.Filter()},.1)}},__getCustomValues:function(a){if(a){var b=this.hasCustomSlcOptions&&array.has(this.customSlcOptions.cols,a);if(b){for(var c=[],d=[],e=array.indexByValue(this.customSlcOptions.cols,a),f=this.customSlcOptions.values[e],g=this.customSlcOptions.texts[e],h=this.customSlcOptions.sorts[e],i=0;i0&&(j.hasCustomSlcOptions&&array.has(j.customSlcOptions.cols,a)?g.push(i):g=i.split(" "+j.orOperator+" "));for(var k=0;kt;t++)if(a===t&&(!this.refreshFilters||this.refreshFilters&&this.disableExcludedOptions)||a===t&&this.refreshFilters&&(""===k[q].style.display&&!this.paging||this.paging&&(!i||i===a||i!=a&&array.has(this.validRowsIndex,q)))){var u=this.GetCellData(t,r[t]),v=str.matchCase(u,this.matchCase);array.has(l,v,this.matchCase)||l.push(u);var w=p[t];this.refreshFilters&&this.disableExcludedOptions&&(w||(p[t]=this.GetFilteredDataCol(t)),!array.has(w,v,this.matchCase)&&!array.has(o,v,this.matchCase)&&!this.isFirstLoad&&o.push(u))}}if(m){var x=this.__getCustomValues(a);l=x[0],n=x[1]}if(this.sortSlc&&!m&&(this.matchCase?(l.sort(),o&&o.sort()):(l.sort(ignoreCaseSort),o&&o.sort(ignoreCaseSort))),this.sortNumAsc&&array.has(this.sortNumAsc,a))try{l.sort(numSortAsc),o&&o.sort(numSortAsc),m&&n.sort(numSortAsc)}catch(y){l.sort(),o&&o.sort(),m&&n.sort()}if(this.sortNumDesc&&array.has(this.sortNumDesc,a))try{l.sort(numSortDesc),o&&o.sort(numSortDesc),m&&n.sort(numSortDesc)}catch(y){l.sort(),o&&o.sort(),m&&n.sort()}if(e(this.separator),this.fillSlcOnDemand&&(g.innerHTML=""),g.appendChild(h),g.setAttribute("filled","1"),j.rememberGridValues&&hlp.isIE()){var z=h.getAttribute("indexes");if(z)for(var A=z.split(","),B=0;B':null);var b=dom.create("span",["id",this.prfxResetSpan+this.id]);this.btnResetTgtId||this.SetTopDiv();var c=this.btnResetTgtId?dom.id(this.btnResetTgtId):this.rDiv;if(c.appendChild(b),this.btnResetHtml){b.innerHTML=this.btnResetHtml;var d=b.firstChild;d.onclick=this.Evt._Clear}else{var e=dom.create("a",["href","javascript:void(0);"]);e.className=this.btnResetCssClass,e.appendChild(dom.text(this.btnResetText)),b.appendChild(e),e.onclick=this.Evt._Clear}this.btnResetEl=dom.id(this.prfxResetSpan+this.id).firstChild}},RemoveResetBtn:function(){if(this.hasGrid&&this.btnResetEl){var a=dom.id(this.prfxResetSpan+this.id);a&&a.parentNode.removeChild(a),this.btnResetEl=null}},SetStatusBar:function(){if(this.hasGrid||this.isFirstLoad){var a=this.fObj;this.statusBarTgtId=a.status_bar_target_id||null,this.statusBarDiv=null,this.statusBarSpan=null,this.statusBarSpanText=null,this.statusBarText=a.status_bar_text||"",this.statusBarCssClass=a.status_bar_css_class||"status",this.statusBarCloseDelay=250;var b=dom.create("div",["id",this.prfxStatus+this.id]);b.className=this.statusBarCssClass;var c=dom.create("span",["id",this.prfxStatusSpan+this.id]),d=dom.create("span",["id",this.prfxStatusTxt+this.id]);d.appendChild(dom.text(this.statusBarText)),this.onBeforeShowMsg=types.isFn(a.on_before_show_msg)?a.on_before_show_msg:null,this.onAfterShowMsg=types.isFn(a.on_after_show_msg)?a.on_after_show_msg:null,this.statusBarTgtId||this.SetTopDiv();var e=this.statusBarTgtId?dom.id(this.statusBarTgtId):this.lDiv;this.statusBarDiv&&hlp.isIE()&&(this.statusBarDiv.outerHTML=""),this.statusBarTgtId?(e.appendChild(d),e.appendChild(c)):(b.appendChild(d),b.appendChild(c),e.appendChild(b)),this.statusBarDiv=dom.id(this.prfxStatus+this.id),this.statusBarSpan=dom.id(this.prfxStatusSpan+this.id),this.statusBarSpanText=dom.id(this.prfxStatusTxt+this.id)}},RemoveStatusBar:function(){(this.hasGrid||this.statusBarDiv)&&(this.statusBarDiv.innerHTML="",this.statusBarDiv.parentNode.removeChild(this.statusBarDiv),this.statusBarSpan=null,this.statusBarSpanText=null,this.statusBarDiv=null)},StatusMsg:function(a){a||this.StatusMsg(""),this.status&&this.WinStatusMsg(a),this.statusBar&&this.StatusBarMsg(a)},WinStatusMsg:function(a){this.status&&(this.onBeforeShowMsg&&this.onBeforeShowMsg.call(null,this,a),global.status=a,this.onAfterShowMsg&&this.onAfterShowMsg.call(null,this,a))},StatusBarMsg:function(a){function b(){c.statusBarSpan.innerHTML=a,c.onAfterShowMsg&&c.onAfterShowMsg.call(null,c,a)}if(this.statusBar&&this.statusBarSpan){this.onBeforeShowMsg&&this.onBeforeShowMsg.call(null,this,a);var c=this,d=""===a?this.statusBarCloseDelay:1;global.setTimeout(b,d)}},SetRowsCounter:function(){if((this.hasGrid||this.isFirstLoad)&&!this.rowsCounterSpan){var a=this.fObj;this.rowsCounterTgtId=a.rows_counter_target_id||null,this.rowsCounterDiv=null,this.rowsCounterSpan=null,this.rowsCounterText=a.rows_counter_text||"Rows: ",this.fromToTextSeparator=a.from_to_text_separator||"-",this.overText=a.over_text||" / ",this.totRowsCssClass=a.tot_rows_css_class||"tot",this.onBeforeRefreshCounter=types.isFn(a.on_before_refresh_counter)?a.on_before_refresh_counter:null,this.onAfterRefreshCounter=types.isFn(a.on_after_refresh_counter)?a.on_after_refresh_counter:null;var b=dom.create("div",["id",this.prfxCounter+this.id]);b.className=this.totRowsCssClass;var c=dom.create("span",["id",this.prfxTotRows+this.id]),d=dom.create("span",["id",this.prfxTotRowsTxt+this.id]);d.appendChild(dom.text(this.rowsCounterText)),this.rowsCounterTgtId||this.SetTopDiv();var e=this.rowsCounterTgtId?dom.id(this.rowsCounterTgtId):this.lDiv;this.rowsCounterDiv&&hlp.isIE()&&(this.rowsCounterDiv.outerHTML=""),this.rowsCounterTgtId?(e.appendChild(d),e.appendChild(c)):(b.appendChild(d),b.appendChild(c),e.appendChild(b)),this.rowsCounterDiv=dom.id(this.prfxCounter+this.id),this.rowsCounterSpan=dom.id(this.prfxTotRows+this.id),this.RefreshNbRows()}},RemoveRowsCounter:function(){this.hasGrid&&this.rowsCounterSpan&&(!this.rowsCounterTgtId&&this.rowsCounterDiv?hlp.isIE()?this.rowsCounterDiv.outerHTML="":this.rowsCounterDiv.parentNode.removeChild(this.rowsCounterDiv):dom.id(this.rowsCounterTgtId).innerHTML="",this.rowsCounterSpan=null,this.rowsCounterDiv=null)},RefreshNbRows:function(a){if(this.rowsCounterSpan){this.onBeforeRefreshCounter&&this.onBeforeRefreshCounter.call(null,this,this.rowsCounterSpan);var b;if(this.paging){var c=parseInt(this.startPagingRow,10)+(this.nbVisibleRows>0?1:0),d=c+this.pagingLength-1<=this.nbVisibleRows?c+this.pagingLength-1:this.nbVisibleRows;b=c+this.fromToTextSeparator+d+this.overText+this.nbVisibleRows}else b=a&&""!==a?a:this.nbFilterableRows-this.nbHiddenRows-(this.hasVisibleRows?this.visibleRows.length:0);this.rowsCounterSpan.innerHTML=b,this.onAfterRefreshCounter&&this.onAfterRefreshCounter.call(null,this,this.rowsCounterSpan,b)}},SetWatermark:function(a){if(this.fltGrid||""!==this.inpWatermark){a=void 0===a?!0:a;for(var b=0;b0&&this.tbl.removeChild(t[0]),this.headTbl.style.width=this.tbl.style.width,this.headTbl.style.tableLayout="fixed",this.tbl.style.tableLayout="fixed",this.headTbl.cellPadding=this.tbl.cellPadding,this.headTbl.cellSpacing=this.tbl.cellSpacing,this.headTblCont.style.width=this.tblCont.clientWidth+"px",this.SetColWidths(),this.tbl.style.width="",hlp.isIE()&&(this.headTbl.style.width="");var u=this;if(this.tblCont.onscroll=function(){u.headTblCont.scrollLeft=this.scrollLeft;var a=this;if(!u.isPointerXOverwritten)try{TF.Evt.pointerX=function(b){b=b||global.event;var c=tf_StandardBody().scrollLeft+a.scrollLeft;return b.pageX+a.scrollLeft||b.clientX+c},u.isPointerXOverwritten=!0}catch(b){u.isPointerXOverwritten=!1}},a.sort!==!1&&(this.sort=!0,this.sortConfig.asyncSort=!0,this.sortConfig.triggerIds=j),this.gridEnableColResizer&&(this.hasExtensions?this.__containsStr("colsresizer",str.lower(this.extensions.src.toString()))||(this.extensions.name.push("ColumnsResizer_"+this.id),this.extensions.src.push(this.gridColResizerPath),this.extensions.description.push("Columns Resizing"),this.extensions.initialize.push(function(a){a.SetColsResizer("ColumnsResizer_"+a.id)})):(this.extensions={name:["ColumnsResizer_"+this.id],src:[this.gridColResizerPath],description:["Columns Resizing"],initialize:[function(a){a.SetColsResizer("ColumnsResizer_"+a.id)}]},this.hasExtensions=!0)),a.col_resizer_cols_headers_table=this.headTbl.getAttribute("id"),a.col_resizer_cols_headers_index=this.gridHeadRowIndex,a.col_resizer_width_adjustment=0,a.col_enable_text_ellipsis=!1,u.tblHasColTag=dom.tag(u.tbl,"col").length>0?!0:!1,!hlp.isIE()){var v=function(a){if(a){for(var b=a.nbCells-1;b>=0;b--){var c=dom.create("col",["id",a.id+"_col_"+b]);a.tbl.firstChild.parentNode.insertBefore(c,a.tbl.firstChild),c.style.width=a.colWidth[b],a.gridColElms[b]=c}a.tblHasColTag=!0}};if(u.tblHasColTag)for(var w=dom.tag(u.tbl,"col"),x=0;x0?z[0].insertRow(0):u.tbl.insertRow(0),y.style.height="0px";for(var A=0;A0?z[0].moveRow(a.leadColWidthsRow.rowIndex,0):a.tbl.moveRow(a.leadColWidthsRow.rowIndex,0)}D&&D.call(null,a,b)}}var E=types.isFn(a.on_after_col_resized)?a.on_after_col_resized:null;a.on_after_col_resized=function(a,b){if(b){var c=a.crWColsRow.cells[b].style.width,d=a.gridColElms[b];d.style.width=c;var e=a.crWColsRow.cells[b].clientWidth,f=a.crWRowDataTbl.cells[b].clientWidth;hlp.isIE()&&(a.tbl.style.width=a.headTbl.clientWidth+"px"),e!=f&&!hlp.isIE()&&(a.headTbl.style.width=a.tbl.clientWidth+"px"),E&&E.call(null,a,b)}},this.tbl.clientWidth!==this.headTbl.clientWidth&&(this.tbl.style.width=this.headTbl.clientWidth+"px")}},RemoveGridLayout:function(){if(this.gridLayout){var a=this.tbl.parentNode.removeChild(this.tbl);this.tblMainCont.parentNode.insertBefore(a,this.tblMainCont),this.tblMainCont.parentNode.removeChild(this.tblMainCont),this.tblMainCont=null,this.headTblCont=null,this.headTbl=null,this.tblCont=null,this.tbl.outerHTML=this.sourceTblHtml,this.tbl=dom.id(this.id)}},SetPopupFilterIcons:function(){function a(a){var b=a||global.event,d=parseInt(this.getAttribute("ci"),10);if(c.CloseAllPopupFilters(d),c.TogglePopupFilter(d),c.popUpFltAdjustToContainer){var e=c.popUpFltElms[d],f=c.GetHeaderElement(d),g=.95*f.clientWidth;if(hlp.isIE()){var h=dom.position(f).left;e.style.left=h+"px"}e.style.width=parseInt(g,10)+"px"}b.cancel(b),b.stop(b)}if(this.popUpFilters){this.isExternalFlt=!0;var b=this.fObj;this.popUpImgFlt=b.popup_filters_image||this.themesPath+"icn_filter.gif",this.popUpImgFltActive=b.popup_filters_image_active||this.themesPath+"icn_filterActive.gif",this.popUpImgFltHtml=b.popup_filters_image_html||'Column filter',this.popUpDivCssClass=b.popup_div_css_class||"popUpFilter",this.onBeforePopUpOpen=types.isFn(b.on_before_popup_filter_open)?b.on_before_popup_filter_open:null,this.onAfterPopUpOpen=types.isFn(b.on_after_popup_filter_open)?b.on_after_popup_filter_open:null,this.onBeforePopUpClose=types.isFn(b.on_before_popup_filter_close)?b.on_before_popup_filter_close:null,this.onAfterPopUpClose=types.isFn(b.on_after_popup_filter_close)?b.on_after_popup_filter_close:null,this.externalFltTgtIds=[],this.popUpFltSpans=[],this.popUpFltImgs=[],this.popUpFltElms=this.popUpFltElmCache||[],this.popUpFltAdjustToContainer=!0;for(var c=this,d=0;de;e++){var f=a?e:this.validRowsIndex[e];this.SetRowBg(f,d),d++}},RemoveAlternateRows:function(){if(this.hasGrid){for(var a=(this.tbl.rows,this.refRow);a= offsetParent.offsetHeight ? 0 - parentNode.parentNode.offsetHeight + offsetParent.offsetHeight + offsetParent.scrollTop : 0);"}}}},RemoveFixedHeaders:function(){if(this.hasGrid&&this.fixedHeaders)if(this.contDiv){this.contDiv.parentNode.insertBefore(this.tbl,this.contDiv),this.contDiv.parentNode.removeChild(this.contDiv),this.contDiv=null;var a=dom.tag(this.tbl,"thead");if(0===a.length)return;var b=dom.tag(a[0],"tr");if(0===b.length)return;for(var c=0;cv):L?(w=formatDate(a.replace(i,""),D),e=w>=v):N?(w=formatDate(a.replace(j,""),D),e=v>=w):M?(w=formatDate(a.replace(l,""),D),e=v>w):O?(w=formatDate(a.replace(m,""),D),e=v.toString()!=w.toString()):P?(w=formatDate(a.replace(o,""),D),e=v.toString()==w.toString()):n.test(a)?e=f.__containsStr(a.replace(n,""),b,null,!1):isValidDate(a,D)?(w=formatDate(a,D),e=v.toString()==w.toString()):H?e=str.isEmpty(b):I&&(e=!str.isEmpty(b));else if(f.hasColNbFormat&&f.colNbFormat[c]?(g=removeNbFormat(b,f.colNbFormat[c]),h=f.colNbFormat[c]):","===f.thousandsSeparator&&"."===f.decimalSeparator?(g=removeNbFormat(b,"us"),h="us"):(g=removeNbFormat(b,"eu"),h="eu"),y)e=g<=removeNbFormat(a.replace(i,""),h);else if(A)e=g>=removeNbFormat(a.replace(j,""),h);else if(x)e=gremoveNbFormat(a.replace(l,""),h);else if(B)e=f.__containsStr(a.replace(m,""),b)?!1:!0;else if(E)e=f.__containsStr(a.replace(n,""),b,null,!1);else if(C)e=f.__containsStr(a.replace(o,""),b,null,!0);else if(F)e=0===b.indexOf(a.replace(p,""))?!0:!1;else if(G){var Q=a.replace(q,"");e=b.lastIndexOf(Q,b.length-1)===b.length-1-(Q.length-1)&&b.lastIndexOf(Q,b.length-1)>-1?!0:!1}else if(H)e=str.isEmpty(b);else if(I)e=!str.isEmpty(b);else if(J)try{var R=a.replace(u,""),S=new RegExp(R);e=S.test(b)}catch(T){e=!1}else{var U=d["col_"+c];e=f.__containsStr(a,b,U?U:this.fltTypeInp)}return e}if(this.fltGrid&&(this.hasGrid||this.isFirstLoad)){this.onBeforeFilter&&this.onBeforeFilter.call(null,this),""!==this.inpWatermark&&this.SetWatermark(!1);var c=this.tbl.rows,d=this.fObj||{},e=0;this.validRowsIndex=[];var f=this;this.highlightKeywords&&this.UnhighlightAll(),this.popUpFilters&&this.SetAllPopupFiltersIcon(),this.markActiveColumns&&this.ClearActiveColumns(),this.searchArgs=this.GetFiltersValue();for(var g,h,i=new RegExp(this.leOperator),j=new RegExp(this.geOperator),k=new RegExp(this.lwOperator),l=new RegExp(this.grOperator),m=new RegExp(this.dfOperator),n=new RegExp(str.rgxEsc(this.lkOperator)),o=new RegExp(this.eqOperator),p=new RegExp(this.stOperator),q=new RegExp(this.enOperator),r=new RegExp(this.anOperator),s=(new RegExp(this.curExp),this.emOperator),t=this.nmOperator,u=new RegExp(str.rgxEsc(this.rgxOperator)),v=this.refRow;vB;B++){var C=this.searchArgs[this.singleSearchFlt?0:B],D=this.hasColDateType?this.colDateType[B]:this.defaultDateType;if(""!==C){var E=str.matchCase(this.GetCellData(B,w[B]),this.matchCase),F=C.split(this.orOperator),G=F.length>1?!0:!1,H=C.split(this.anOperator),I=H.length>1?!0:!1;if(G||I){for(var J,K=!1,L=G?F:H,M=0;Mj;j++)if(j===a&&""===d[f].style.display){var k=str.lower(this.GetCellData(j,h[j])),l=this.colNbFormat?this.colNbFormat[a]:null,m=b?removeNbFormat(k,l):k;e.push(m)}}return e}},GetFilterValue:function(a){if(this.fltGrid){var b,c=this.GetFilterElement(a);if(!c)return"";var d=this.fltCol[a];if(d!==this.fltTypeMulti&&d!==this.fltTypeCheckList)b=c.value;else if(d===this.fltTypeMulti){b="";for(var e=0;e=jj;jj++)ucolIndex[jj]===colIndex[ii]&&(saved=1);0===saved&&(ucolMax++,ucolIndex[ucolMax]=colIndex[ii])}if("object"==str.lower(typeof labelId)&&"object"==str.lower(typeof colIndex)&&"object"==str.lower(typeof operation))for(var row=this.tbl.rows,colvalues=[],ucol=0;ucolMax>=ucol;ucol++){colvalues.push(this.GetColValues(ucolIndex[ucol],!0,excludeRow));for(var result,nbvalues=0,temp,meanValue=0,sumValue=0,minValue=null,maxValue=null,q1Value=null,medValue=null,q3Value=null,meanFlag=0,sumFlag=0,minFlag=0,maxFlag=0,q1Flag=0,medFlag=0,q3Flag=0,theList=[],opsThisCol=[],decThisCol=[],labThisCol=[],oTypeThisCol=[],mThisCol=-1,k=0;kmaxValue?parseFloat(cvalue):maxValue))}if(1===meanFlag&&(meanValue=sumValue/nbvalues),1===medFlag){var aux=0;nbvalues%2===1?(aux=Math.floor(nbvalues/2),medValue=theList[aux]):medValue=(theList[nbvalues/2]+theList[nbvalues/2-1])/2}var posa;if(1===q1Flag&&(posa=0,posa=Math.floor(nbvalues/4),q1Value=4*posa==nbvalues?(theList[posa-1]+theList[posa])/2:theList[posa]),1===q3Flag){posa=0;var posb=0;posa=Math.floor(nbvalues/4),4*posa===nbvalues?(posb=3*posa,q3Value=(theList[posb]+theList[posb-1])/2):q3Value=theList[nbvalues-posa-1]}for(var i=0;mThisCol>=i;i++){switch(opsThisCol[i]){case"mean":result=meanValue;break;case"sum":result=sumValue;break;case"min":result=minValue;break;case"max":result=maxValue;break;case"median":result=medValue;break;case"q1":result=q1Value;break;case"q3":result=q3Value}var precision=decThisCol[i]&&!isNaN(decThisCol[i])?decThisCol[i]:2;if(oTypeThisCol&&result){if(result=result.toFixed(precision),dom.id(labThisCol[i]))switch(str.lower(oTypeThisCol)){case"innerhtml":dom.id(labThisCol[i]).innerHTML=isNaN(result)||!isFinite(result)||0===nbvalues?".":result;break;case"setvalue":dom.id(labThisCol[i]).value=result;break;case"createtextnode":var oldnode=dom.id(labThisCol[i]).firstChild,txtnode=dom.text(result);dom.id(labThisCol[i]).replaceChild(txtnode,oldnode)}}else try{dom.id(labThisCol[i]).innerHTML=isNaN(result)||!isFinite(result)||0===nbvalues?".":result.toFixed(precision)}catch(e){}}totRowIndex&&row[totRowIndex[ucol]]&&(row[totRowIndex[ucol]].style.display="")}this.onAfterOperation&&this.onAfterOperation.call(null,this)}},UnhighlightAll:function(){if(this.highlightKeywords&&this.searchArgs){for(var a=0;a1){ diff --git a/src/modules/loader.js b/src/modules/loader.js index 46163cda..eaafe564 100644 --- a/src/modules/loader.js +++ b/src/modules/loader.js @@ -3,6 +3,10 @@ define(['../dom', '../types'], function (dom, types) { var global = window; + /** + * Loading message/spinner + * @param {Object} tf TableFilter instance + */ function Loader(tf){ // Original configuration diff --git a/test/libs/qunit/qunit.css b/test/libs/qunit/qunit.css new file mode 100644 index 00000000..9437b4b6 --- /dev/null +++ b/test/libs/qunit/qunit.css @@ -0,0 +1,237 @@ +/*! + * QUnit 1.15.0 + * http://qunitjs.com/ + * + * Copyright 2014 jQuery Foundation and other contributors + * Released under the MIT license + * http://jquery.org/license + * + * Date: 2014-08-08T16:00Z + */ + +/** Font Family and Sizes */ + +#qunit-tests, #qunit-header, #qunit-banner, #qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult { + font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial, sans-serif; +} + +#qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult, #qunit-tests li { font-size: small; } +#qunit-tests { font-size: smaller; } + + +/** Resets */ + +#qunit-tests, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult, #qunit-modulefilter { + margin: 0; + padding: 0; +} + + +/** Header */ + +#qunit-header { + padding: 0.5em 0 0.5em 1em; + + color: #8699A4; + background-color: #0D3349; + + font-size: 1.5em; + line-height: 1em; + font-weight: 400; + + border-radius: 5px 5px 0 0; +} + +#qunit-header a { + text-decoration: none; + color: #C2CCD1; +} + +#qunit-header a:hover, +#qunit-header a:focus { + color: #FFF; +} + +#qunit-testrunner-toolbar label { + display: inline-block; + padding: 0 0.5em 0 0.1em; +} + +#qunit-banner { + height: 5px; +} + +#qunit-testrunner-toolbar { + padding: 0.5em 1em 0.5em 1em; + color: #5E740B; + background-color: #EEE; + overflow: hidden; +} + +#qunit-userAgent { + padding: 0.5em 1em 0.5em 1em; + background-color: #2B81AF; + color: #FFF; + text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px; +} + +#qunit-modulefilter-container { + float: right; +} + +/** Tests: Pass/Fail */ + +#qunit-tests { + list-style-position: inside; +} + +#qunit-tests li { + padding: 0.4em 1em 0.4em 1em; + border-bottom: 1px solid #FFF; + list-style-position: inside; +} + +#qunit-tests.hidepass li.pass, #qunit-tests.hidepass li.running { + display: none; +} + +#qunit-tests li strong { + cursor: pointer; +} + +#qunit-tests li a { + padding: 0.5em; + color: #C2CCD1; + text-decoration: none; +} +#qunit-tests li a:hover, +#qunit-tests li a:focus { + color: #000; +} + +#qunit-tests li .runtime { + float: right; + font-size: smaller; +} + +.qunit-assert-list { + margin-top: 0.5em; + padding: 0.5em; + + background-color: #FFF; + + border-radius: 5px; +} + +.qunit-collapsed { + display: none; +} + +#qunit-tests table { + border-collapse: collapse; + margin-top: 0.2em; +} + +#qunit-tests th { + text-align: right; + vertical-align: top; + padding: 0 0.5em 0 0; +} + +#qunit-tests td { + vertical-align: top; +} + +#qunit-tests pre { + margin: 0; + white-space: pre-wrap; + word-wrap: break-word; +} + +#qunit-tests del { + background-color: #E0F2BE; + color: #374E0C; + text-decoration: none; +} + +#qunit-tests ins { + background-color: #FFCACA; + color: #500; + text-decoration: none; +} + +/*** Test Counts */ + +#qunit-tests b.counts { color: #000; } +#qunit-tests b.passed { color: #5E740B; } +#qunit-tests b.failed { color: #710909; } + +#qunit-tests li li { + padding: 5px; + background-color: #FFF; + border-bottom: none; + list-style-position: inside; +} + +/*** Passing Styles */ + +#qunit-tests li li.pass { + color: #3C510C; + background-color: #FFF; + border-left: 10px solid #C6E746; +} + +#qunit-tests .pass { color: #528CE0; background-color: #D2E0E6; } +#qunit-tests .pass .test-name { color: #366097; } + +#qunit-tests .pass .test-actual, +#qunit-tests .pass .test-expected { color: #999; } + +#qunit-banner.qunit-pass { background-color: #C6E746; } + +/*** Failing Styles */ + +#qunit-tests li li.fail { + color: #710909; + background-color: #FFF; + border-left: 10px solid #EE5757; + white-space: pre; +} + +#qunit-tests > li:last-child { + border-radius: 0 0 5px 5px; +} + +#qunit-tests .fail { color: #000; background-color: #EE5757; } +#qunit-tests .fail .test-name, +#qunit-tests .fail .module-name { color: #000; } + +#qunit-tests .fail .test-actual { color: #EE5757; } +#qunit-tests .fail .test-expected { color: #008000; } + +#qunit-banner.qunit-fail { background-color: #EE5757; } + + +/** Result */ + +#qunit-testresult { + padding: 0.5em 1em 0.5em 1em; + + color: #2B81AF; + background-color: #D2E0E6; + + border-bottom: 1px solid #FFF; +} +#qunit-testresult .module-name { + font-weight: 700; +} + +/** Fixture */ + +#qunit-fixture { + position: absolute; + top: -10000px; + left: -10000px; + width: 1000px; + height: 1000px; +} diff --git a/test/libs/qunit/qunit.js b/test/libs/qunit/qunit.js new file mode 100644 index 00000000..474cfe55 --- /dev/null +++ b/test/libs/qunit/qunit.js @@ -0,0 +1,2495 @@ +/*! + * QUnit 1.15.0 + * http://qunitjs.com/ + * + * Copyright 2014 jQuery Foundation and other contributors + * Released under the MIT license + * http://jquery.org/license + * + * Date: 2014-08-08T16:00Z + */ + +(function( window ) { + +var QUnit, + config, + onErrorFnPrev, + fileName = ( sourceFromStacktrace( 0 ) || "" ).replace( /(:\d+)+\)?/, "" ).replace( /.+\//, "" ), + toString = Object.prototype.toString, + hasOwn = Object.prototype.hasOwnProperty, + // Keep a local reference to Date (GH-283) + Date = window.Date, + now = Date.now || function() { + return new Date().getTime(); + }, + setTimeout = window.setTimeout, + clearTimeout = window.clearTimeout, + defined = { + document: typeof window.document !== "undefined", + setTimeout: typeof window.setTimeout !== "undefined", + sessionStorage: (function() { + var x = "qunit-test-string"; + try { + sessionStorage.setItem( x, x ); + sessionStorage.removeItem( x ); + return true; + } catch ( e ) { + return false; + } + }()) + }, + /** + * Provides a normalized error string, correcting an issue + * with IE 7 (and prior) where Error.prototype.toString is + * not properly implemented + * + * Based on http://es5.github.com/#x15.11.4.4 + * + * @param {String|Error} error + * @return {String} error message + */ + errorString = function( error ) { + var name, message, + errorString = error.toString(); + if ( errorString.substring( 0, 7 ) === "[object" ) { + name = error.name ? error.name.toString() : "Error"; + message = error.message ? error.message.toString() : ""; + if ( name && message ) { + return name + ": " + message; + } else if ( name ) { + return name; + } else if ( message ) { + return message; + } else { + return "Error"; + } + } else { + return errorString; + } + }, + /** + * Makes a clone of an object using only Array or Object as base, + * and copies over the own enumerable properties. + * + * @param {Object} obj + * @return {Object} New object with only the own properties (recursively). + */ + objectValues = function( obj ) { + var key, val, + vals = QUnit.is( "array", obj ) ? [] : {}; + for ( key in obj ) { + if ( hasOwn.call( obj, key ) ) { + val = obj[ key ]; + vals[ key ] = val === Object( val ) ? objectValues( val ) : val; + } + } + return vals; + }; + +// Root QUnit object. +// `QUnit` initialized at top of scope +QUnit = { + + // call on start of module test to prepend name to all tests + module: function( name, testEnvironment ) { + config.currentModule = name; + config.currentModuleTestEnvironment = testEnvironment; + config.modules[ name ] = true; + }, + + asyncTest: function( testName, expected, callback ) { + if ( arguments.length === 2 ) { + callback = expected; + expected = null; + } + + QUnit.test( testName, expected, callback, true ); + }, + + test: function( testName, expected, callback, async ) { + var test; + + if ( arguments.length === 2 ) { + callback = expected; + expected = null; + } + + test = new Test({ + testName: testName, + expected: expected, + async: async, + callback: callback, + module: config.currentModule, + moduleTestEnvironment: config.currentModuleTestEnvironment, + stack: sourceFromStacktrace( 2 ) + }); + + if ( !validTest( test ) ) { + return; + } + + test.queue(); + }, + + start: function( count ) { + var message; + + // QUnit hasn't been initialized yet. + // Note: RequireJS (et al) may delay onLoad + if ( config.semaphore === undefined ) { + QUnit.begin(function() { + // This is triggered at the top of QUnit.load, push start() to the event loop, to allow QUnit.load to finish first + setTimeout(function() { + QUnit.start( count ); + }); + }); + return; + } + + config.semaphore -= count || 1; + // don't start until equal number of stop-calls + if ( config.semaphore > 0 ) { + return; + } + + // Set the starting time when the first test is run + QUnit.config.started = QUnit.config.started || now(); + // ignore if start is called more often then stop + if ( config.semaphore < 0 ) { + config.semaphore = 0; + + message = "Called start() while already started (QUnit.config.semaphore was 0 already)"; + + if ( config.current ) { + QUnit.pushFailure( message, sourceFromStacktrace( 2 ) ); + } else { + throw new Error( message ); + } + + return; + } + // A slight delay, to avoid any current callbacks + if ( defined.setTimeout ) { + setTimeout(function() { + if ( config.semaphore > 0 ) { + return; + } + if ( config.timeout ) { + clearTimeout( config.timeout ); + } + + config.blocking = false; + process( true ); + }, 13 ); + } else { + config.blocking = false; + process( true ); + } + }, + + stop: function( count ) { + config.semaphore += count || 1; + config.blocking = true; + + if ( config.testTimeout && defined.setTimeout ) { + clearTimeout( config.timeout ); + config.timeout = setTimeout(function() { + QUnit.ok( false, "Test timed out" ); + config.semaphore = 1; + QUnit.start(); + }, config.testTimeout ); + } + } +}; + +// We use the prototype to distinguish between properties that should +// be exposed as globals (and in exports) and those that shouldn't +(function() { + function F() {} + F.prototype = QUnit; + QUnit = new F(); + + // Make F QUnit's constructor so that we can add to the prototype later + QUnit.constructor = F; +}()); + +/** + * Config object: Maintain internal state + * Later exposed as QUnit.config + * `config` initialized at top of scope + */ +config = { + // The queue of tests to run + queue: [], + + // block until document ready + blocking: true, + + // when enabled, show only failing tests + // gets persisted through sessionStorage and can be changed in UI via checkbox + hidepassed: false, + + // by default, run previously failed tests first + // very useful in combination with "Hide passed tests" checked + reorder: true, + + // by default, modify document.title when suite is done + altertitle: true, + + // by default, scroll to top of the page when suite is done + scrolltop: true, + + // when enabled, all tests must call expect() + requireExpects: false, + + // add checkboxes that are persisted in the query-string + // when enabled, the id is set to `true` as a `QUnit.config` property + urlConfig: [ + { + id: "noglobals", + label: "Check for Globals", + tooltip: "Enabling this will test if any test introduces new properties on the `window` object. Stored as query-strings." + }, + { + id: "notrycatch", + label: "No try-catch", + tooltip: "Enabling this will run tests outside of a try-catch block. Makes debugging exceptions in IE reasonable. Stored as query-strings." + } + ], + + // Set of all modules. + modules: {}, + + callbacks: {} +}; + +// Initialize more QUnit.config and QUnit.urlParams +(function() { + var i, current, + location = window.location || { search: "", protocol: "file:" }, + params = location.search.slice( 1 ).split( "&" ), + length = params.length, + urlParams = {}; + + if ( params[ 0 ] ) { + for ( i = 0; i < length; i++ ) { + current = params[ i ].split( "=" ); + current[ 0 ] = decodeURIComponent( current[ 0 ] ); + + // allow just a key to turn on a flag, e.g., test.html?noglobals + current[ 1 ] = current[ 1 ] ? decodeURIComponent( current[ 1 ] ) : true; + if ( urlParams[ current[ 0 ] ] ) { + urlParams[ current[ 0 ] ] = [].concat( urlParams[ current[ 0 ] ], current[ 1 ] ); + } else { + urlParams[ current[ 0 ] ] = current[ 1 ]; + } + } + } + + QUnit.urlParams = urlParams; + + // String search anywhere in moduleName+testName + config.filter = urlParams.filter; + + // Exact match of the module name + config.module = urlParams.module; + + config.testNumber = []; + if ( urlParams.testNumber ) { + + // Ensure that urlParams.testNumber is an array + urlParams.testNumber = [].concat( urlParams.testNumber ); + for ( i = 0; i < urlParams.testNumber.length; i++ ) { + current = urlParams.testNumber[ i ]; + config.testNumber.push( parseInt( current, 10 ) ); + } + } + + // Figure out if we're running the tests from a server or not + QUnit.isLocal = location.protocol === "file:"; +}()); + +extend( QUnit, { + + config: config, + + // Safe object type checking + is: function( type, obj ) { + return QUnit.objectType( obj ) === type; + }, + + objectType: function( obj ) { + if ( typeof obj === "undefined" ) { + return "undefined"; + } + + // Consider: typeof null === object + if ( obj === null ) { + return "null"; + } + + var match = toString.call( obj ).match( /^\[object\s(.*)\]$/ ), + type = match && match[ 1 ] || ""; + + switch ( type ) { + case "Number": + if ( isNaN( obj ) ) { + return "nan"; + } + return "number"; + case "String": + case "Boolean": + case "Array": + case "Date": + case "RegExp": + case "Function": + return type.toLowerCase(); + } + if ( typeof obj === "object" ) { + return "object"; + } + return undefined; + }, + + url: function( params ) { + params = extend( extend( {}, QUnit.urlParams ), params ); + var key, + querystring = "?"; + + for ( key in params ) { + if ( hasOwn.call( params, key ) ) { + querystring += encodeURIComponent( key ) + "=" + + encodeURIComponent( params[ key ] ) + "&"; + } + } + return window.location.protocol + "//" + window.location.host + + window.location.pathname + querystring.slice( 0, -1 ); + }, + + extend: extend +}); + +/** + * @deprecated: Created for backwards compatibility with test runner that set the hook function + * into QUnit.{hook}, instead of invoking it and passing the hook function. + * QUnit.constructor is set to the empty F() above so that we can add to it's prototype here. + * Doing this allows us to tell if the following methods have been overwritten on the actual + * QUnit object. + */ +extend( QUnit.constructor.prototype, { + + // Logging callbacks; all receive a single argument with the listed properties + // run test/logs.html for any related changes + begin: registerLoggingCallback( "begin" ), + + // done: { failed, passed, total, runtime } + done: registerLoggingCallback( "done" ), + + // log: { result, actual, expected, message } + log: registerLoggingCallback( "log" ), + + // testStart: { name } + testStart: registerLoggingCallback( "testStart" ), + + // testDone: { name, failed, passed, total, runtime } + testDone: registerLoggingCallback( "testDone" ), + + // moduleStart: { name } + moduleStart: registerLoggingCallback( "moduleStart" ), + + // moduleDone: { name, failed, passed, total } + moduleDone: registerLoggingCallback( "moduleDone" ) +}); + +QUnit.load = function() { + runLoggingCallbacks( "begin", { + totalTests: Test.count + }); + + // Initialize the configuration options + extend( config, { + stats: { all: 0, bad: 0 }, + moduleStats: { all: 0, bad: 0 }, + started: 0, + updateRate: 1000, + autostart: true, + filter: "", + semaphore: 1 + }, true ); + + config.blocking = false; + + if ( config.autostart ) { + QUnit.start(); + } +}; + +// `onErrorFnPrev` initialized at top of scope +// Preserve other handlers +onErrorFnPrev = window.onerror; + +// Cover uncaught exceptions +// Returning true will suppress the default browser handler, +// returning false will let it run. +window.onerror = function( error, filePath, linerNr ) { + var ret = false; + if ( onErrorFnPrev ) { + ret = onErrorFnPrev( error, filePath, linerNr ); + } + + // Treat return value as window.onerror itself does, + // Only do our handling if not suppressed. + if ( ret !== true ) { + if ( QUnit.config.current ) { + if ( QUnit.config.current.ignoreGlobalErrors ) { + return true; + } + QUnit.pushFailure( error, filePath + ":" + linerNr ); + } else { + QUnit.test( "global failure", extend(function() { + QUnit.pushFailure( error, filePath + ":" + linerNr ); + }, { validTest: validTest } ) ); + } + return false; + } + + return ret; +}; + +function done() { + config.autorun = true; + + // Log the last module results + if ( config.previousModule ) { + runLoggingCallbacks( "moduleDone", { + name: config.previousModule, + failed: config.moduleStats.bad, + passed: config.moduleStats.all - config.moduleStats.bad, + total: config.moduleStats.all + }); + } + delete config.previousModule; + + var runtime = now() - config.started, + passed = config.stats.all - config.stats.bad; + + runLoggingCallbacks( "done", { + failed: config.stats.bad, + passed: passed, + total: config.stats.all, + runtime: runtime + }); +} + +/** @return Boolean: true if this test should be ran */ +function validTest( test ) { + var include, + filter = config.filter && config.filter.toLowerCase(), + module = config.module && config.module.toLowerCase(), + fullName = ( test.module + ": " + test.testName ).toLowerCase(); + + // Internally-generated tests are always valid + if ( test.callback && test.callback.validTest === validTest ) { + delete test.callback.validTest; + return true; + } + + if ( config.testNumber.length > 0 ) { + if ( inArray( test.testNumber, config.testNumber ) < 0 ) { + return false; + } + } + + if ( module && ( !test.module || test.module.toLowerCase() !== module ) ) { + return false; + } + + if ( !filter ) { + return true; + } + + include = filter.charAt( 0 ) !== "!"; + if ( !include ) { + filter = filter.slice( 1 ); + } + + // If the filter matches, we need to honour include + if ( fullName.indexOf( filter ) !== -1 ) { + return include; + } + + // Otherwise, do the opposite + return !include; +} + +// Doesn't support IE6 to IE9 +// See also https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error/Stack +function extractStacktrace( e, offset ) { + offset = offset === undefined ? 4 : offset; + + var stack, include, i; + + if ( e.stacktrace ) { + + // Opera 12.x + return e.stacktrace.split( "\n" )[ offset + 3 ]; + } else if ( e.stack ) { + + // Firefox, Chrome, Safari 6+, IE10+, PhantomJS and Node + stack = e.stack.split( "\n" ); + if ( /^error$/i.test( stack[ 0 ] ) ) { + stack.shift(); + } + if ( fileName ) { + include = []; + for ( i = offset; i < stack.length; i++ ) { + if ( stack[ i ].indexOf( fileName ) !== -1 ) { + break; + } + include.push( stack[ i ] ); + } + if ( include.length ) { + return include.join( "\n" ); + } + } + return stack[ offset ]; + } else if ( e.sourceURL ) { + + // Safari < 6 + // exclude useless self-reference for generated Error objects + if ( /qunit.js$/.test( e.sourceURL ) ) { + return; + } + + // for actual exceptions, this is useful + return e.sourceURL + ":" + e.line; + } +} +function sourceFromStacktrace( offset ) { + try { + throw new Error(); + } catch ( e ) { + return extractStacktrace( e, offset ); + } +} + +function synchronize( callback, last ) { + config.queue.push( callback ); + + if ( config.autorun && !config.blocking ) { + process( last ); + } +} + +function process( last ) { + function next() { + process( last ); + } + var start = now(); + config.depth = config.depth ? config.depth + 1 : 1; + + while ( config.queue.length && !config.blocking ) { + if ( !defined.setTimeout || config.updateRate <= 0 || ( ( now() - start ) < config.updateRate ) ) { + config.queue.shift()(); + } else { + setTimeout( next, 13 ); + break; + } + } + config.depth--; + if ( last && !config.blocking && !config.queue.length && config.depth === 0 ) { + done(); + } +} + +function saveGlobal() { + config.pollution = []; + + if ( config.noglobals ) { + for ( var key in window ) { + if ( hasOwn.call( window, key ) ) { + // in Opera sometimes DOM element ids show up here, ignore them + if ( /^qunit-test-output/.test( key ) ) { + continue; + } + config.pollution.push( key ); + } + } + } +} + +function checkPollution() { + var newGlobals, + deletedGlobals, + old = config.pollution; + + saveGlobal(); + + newGlobals = diff( config.pollution, old ); + if ( newGlobals.length > 0 ) { + QUnit.pushFailure( "Introduced global variable(s): " + newGlobals.join( ", " ) ); + } + + deletedGlobals = diff( old, config.pollution ); + if ( deletedGlobals.length > 0 ) { + QUnit.pushFailure( "Deleted global variable(s): " + deletedGlobals.join( ", " ) ); + } +} + +// returns a new Array with the elements that are in a but not in b +function diff( a, b ) { + var i, j, + result = a.slice(); + + for ( i = 0; i < result.length; i++ ) { + for ( j = 0; j < b.length; j++ ) { + if ( result[ i ] === b[ j ] ) { + result.splice( i, 1 ); + i--; + break; + } + } + } + return result; +} + +function extend( a, b, undefOnly ) { + for ( var prop in b ) { + if ( hasOwn.call( b, prop ) ) { + + // Avoid "Member not found" error in IE8 caused by messing with window.constructor + if ( !( prop === "constructor" && a === window ) ) { + if ( b[ prop ] === undefined ) { + delete a[ prop ]; + } else if ( !( undefOnly && typeof a[ prop ] !== "undefined" ) ) { + a[ prop ] = b[ prop ]; + } + } + } + } + + return a; +} + +function registerLoggingCallback( key ) { + + // Initialize key collection of logging callback + if ( QUnit.objectType( config.callbacks[ key ] ) === "undefined" ) { + config.callbacks[ key ] = []; + } + + return function( callback ) { + config.callbacks[ key ].push( callback ); + }; +} + +function runLoggingCallbacks( key, args ) { + var i, l, callbacks; + + callbacks = config.callbacks[ key ]; + for ( i = 0, l = callbacks.length; i < l; i++ ) { + callbacks[ i ]( args ); + } +} + +// from jquery.js +function inArray( elem, array ) { + if ( array.indexOf ) { + return array.indexOf( elem ); + } + + for ( var i = 0, length = array.length; i < length; i++ ) { + if ( array[ i ] === elem ) { + return i; + } + } + + return -1; +} + +function Test( settings ) { + extend( this, settings ); + this.assert = new Assert( this ); + this.assertions = []; + this.testNumber = ++Test.count; +} + +Test.count = 0; + +Test.prototype = { + setup: function() { + if ( + + // Emit moduleStart when we're switching from one module to another + this.module !== config.previousModule || + + // They could be equal (both undefined) but if the previousModule property doesn't + // yet exist it means this is the first test in a suite that isn't wrapped in a + // module, in which case we'll just emit a moduleStart event for 'undefined'. + // Without this, reporters can get testStart before moduleStart which is a problem. + !hasOwn.call( config, "previousModule" ) + ) { + if ( hasOwn.call( config, "previousModule" ) ) { + runLoggingCallbacks( "moduleDone", { + name: config.previousModule, + failed: config.moduleStats.bad, + passed: config.moduleStats.all - config.moduleStats.bad, + total: config.moduleStats.all + }); + } + config.previousModule = this.module; + config.moduleStats = { all: 0, bad: 0 }; + runLoggingCallbacks( "moduleStart", { + name: this.module + }); + } + + config.current = this; + + this.testEnvironment = extend({ + setup: function() {}, + teardown: function() {} + }, this.moduleTestEnvironment ); + + this.started = now(); + runLoggingCallbacks( "testStart", { + name: this.testName, + module: this.module, + testNumber: this.testNumber + }); + + if ( !config.pollution ) { + saveGlobal(); + } + if ( config.notrycatch ) { + this.testEnvironment.setup.call( this.testEnvironment, this.assert ); + return; + } + try { + this.testEnvironment.setup.call( this.testEnvironment, this.assert ); + } catch ( e ) { + this.pushFailure( "Setup failed on " + this.testName + ": " + ( e.message || e ), extractStacktrace( e, 0 ) ); + } + }, + run: function() { + config.current = this; + + if ( this.async ) { + QUnit.stop(); + } + + this.callbackStarted = now(); + + if ( config.notrycatch ) { + this.callback.call( this.testEnvironment, this.assert ); + this.callbackRuntime = now() - this.callbackStarted; + return; + } + + try { + this.callback.call( this.testEnvironment, this.assert ); + this.callbackRuntime = now() - this.callbackStarted; + } catch ( e ) { + this.callbackRuntime = now() - this.callbackStarted; + + this.pushFailure( "Died on test #" + ( this.assertions.length + 1 ) + " " + this.stack + ": " + ( e.message || e ), extractStacktrace( e, 0 ) ); + + // else next test will carry the responsibility + saveGlobal(); + + // Restart the tests if they're blocking + if ( config.blocking ) { + QUnit.start(); + } + } + }, + teardown: function() { + config.current = this; + if ( config.notrycatch ) { + if ( typeof this.callbackRuntime === "undefined" ) { + this.callbackRuntime = now() - this.callbackStarted; + } + this.testEnvironment.teardown.call( this.testEnvironment, this.assert ); + return; + } else { + try { + this.testEnvironment.teardown.call( this.testEnvironment, this.assert ); + } catch ( e ) { + this.pushFailure( "Teardown failed on " + this.testName + ": " + ( e.message || e ), extractStacktrace( e, 0 ) ); + } + } + checkPollution(); + }, + finish: function() { + config.current = this; + if ( config.requireExpects && this.expected === null ) { + this.pushFailure( "Expected number of assertions to be defined, but expect() was not called.", this.stack ); + } else if ( this.expected !== null && this.expected !== this.assertions.length ) { + this.pushFailure( "Expected " + this.expected + " assertions, but " + this.assertions.length + " were run", this.stack ); + } else if ( this.expected === null && !this.assertions.length ) { + this.pushFailure( "Expected at least one assertion, but none were run - call expect(0) to accept zero assertions.", this.stack ); + } + + var i, + bad = 0; + + this.runtime = now() - this.started; + config.stats.all += this.assertions.length; + config.moduleStats.all += this.assertions.length; + + for ( i = 0; i < this.assertions.length; i++ ) { + if ( !this.assertions[ i ].result ) { + bad++; + config.stats.bad++; + config.moduleStats.bad++; + } + } + + runLoggingCallbacks( "testDone", { + name: this.testName, + module: this.module, + failed: bad, + passed: this.assertions.length - bad, + total: this.assertions.length, + runtime: this.runtime, + + // HTML Reporter use + assertions: this.assertions, + testNumber: this.testNumber, + + // DEPRECATED: this property will be removed in 2.0.0, use runtime instead + duration: this.runtime + }); + + config.current = undefined; + }, + + queue: function() { + var bad, + test = this; + + function run() { + // each of these can by async + synchronize(function() { + test.setup(); + }); + synchronize(function() { + test.run(); + }); + synchronize(function() { + test.teardown(); + }); + synchronize(function() { + test.finish(); + }); + } + + // `bad` initialized at top of scope + // defer when previous test run passed, if storage is available + bad = QUnit.config.reorder && defined.sessionStorage && + +sessionStorage.getItem( "qunit-test-" + this.module + "-" + this.testName ); + + if ( bad ) { + run(); + } else { + synchronize( run, true ); + } + }, + + push: function( result, actual, expected, message ) { + var source, + details = { + module: this.module, + name: this.testName, + result: result, + message: message, + actual: actual, + expected: expected, + testNumber: this.testNumber + }; + + if ( !result ) { + source = sourceFromStacktrace(); + + if ( source ) { + details.source = source; + } + } + + runLoggingCallbacks( "log", details ); + + this.assertions.push({ + result: !!result, + message: message + }); + }, + + pushFailure: function( message, source, actual ) { + if ( !this instanceof Test ) { + throw new Error( "pushFailure() assertion outside test context, was " + sourceFromStacktrace( 2 ) ); + } + + var details = { + module: this.module, + name: this.testName, + result: false, + message: message || "error", + actual: actual || null, + testNumber: this.testNumber + }; + + if ( source ) { + details.source = source; + } + + runLoggingCallbacks( "log", details ); + + this.assertions.push({ + result: false, + message: message + }); + } +}; + +QUnit.pushFailure = function() { + if ( !QUnit.config.current ) { + throw new Error( "pushFailure() assertion outside test context, in " + sourceFromStacktrace( 2 ) ); + } + + // Gets current test obj + var currentTest = QUnit.config.current.assert.test; + + return currentTest.pushFailure.apply( currentTest, arguments ); +}; + +function Assert( testContext ) { + this.test = testContext; +} + +// Assert helpers +QUnit.assert = Assert.prototype = { + + // Specify the number of expected assertions to guarantee that failed test (no assertions are run at all) don't slip through. + expect: function( asserts ) { + if ( arguments.length === 1 ) { + this.test.expected = asserts; + } else { + return this.test.expected; + } + }, + + // Exports test.push() to the user API + push: function() { + var assert = this; + + // Backwards compatibility fix. + // Allows the direct use of global exported assertions and QUnit.assert.* + // Although, it's use is not recommended as it can leak assertions + // to other tests from async tests, because we only get a reference to the current test, + // not exactly the test where assertion were intended to be called. + if ( !QUnit.config.current ) { + throw new Error( "assertion outside test context, in " + sourceFromStacktrace( 2 ) ); + } + if ( !( assert instanceof Assert ) ) { + assert = QUnit.config.current.assert; + } + return assert.test.push.apply( assert.test, arguments ); + }, + + /** + * Asserts rough true-ish result. + * @name ok + * @function + * @example ok( "asdfasdf".length > 5, "There must be at least 5 chars" ); + */ + ok: function( result, message ) { + message = message || ( result ? "okay" : "failed, expected argument to be truthy, was: " + + QUnit.dump.parse( result ) ); + if ( !!result ) { + this.push( true, result, true, message ); + } else { + this.test.pushFailure( message, null, result ); + } + }, + + /** + * Assert that the first two arguments are equal, with an optional message. + * Prints out both actual and expected values. + * @name equal + * @function + * @example equal( format( "Received {0} bytes.", 2), "Received 2 bytes.", "format() replaces {0} with next argument" ); + */ + equal: function( actual, expected, message ) { + /*jshint eqeqeq:false */ + this.push( expected == actual, actual, expected, message ); + }, + + /** + * @name notEqual + * @function + */ + notEqual: function( actual, expected, message ) { + /*jshint eqeqeq:false */ + this.push( expected != actual, actual, expected, message ); + }, + + /** + * @name propEqual + * @function + */ + propEqual: function( actual, expected, message ) { + actual = objectValues( actual ); + expected = objectValues( expected ); + this.push( QUnit.equiv( actual, expected ), actual, expected, message ); + }, + + /** + * @name notPropEqual + * @function + */ + notPropEqual: function( actual, expected, message ) { + actual = objectValues( actual ); + expected = objectValues( expected ); + this.push( !QUnit.equiv( actual, expected ), actual, expected, message ); + }, + + /** + * @name deepEqual + * @function + */ + deepEqual: function( actual, expected, message ) { + this.push( QUnit.equiv( actual, expected ), actual, expected, message ); + }, + + /** + * @name notDeepEqual + * @function + */ + notDeepEqual: function( actual, expected, message ) { + this.push( !QUnit.equiv( actual, expected ), actual, expected, message ); + }, + + /** + * @name strictEqual + * @function + */ + strictEqual: function( actual, expected, message ) { + this.push( expected === actual, actual, expected, message ); + }, + + /** + * @name notStrictEqual + * @function + */ + notStrictEqual: function( actual, expected, message ) { + this.push( expected !== actual, actual, expected, message ); + }, + + "throws": function( block, expected, message ) { + var actual, expectedType, + expectedOutput = expected, + ok = false; + + // 'expected' is optional unless doing string comparison + if ( message == null && typeof expected === "string" ) { + message = expected; + expected = null; + } + + this.test.ignoreGlobalErrors = true; + try { + block.call( this.test.testEnvironment ); + } catch (e) { + actual = e; + } + this.test.ignoreGlobalErrors = false; + + if ( actual ) { + expectedType = QUnit.objectType( expected ); + + // we don't want to validate thrown error + if ( !expected ) { + ok = true; + expectedOutput = null; + + // expected is a regexp + } else if ( expectedType === "regexp" ) { + ok = expected.test( errorString( actual ) ); + + // expected is a string + } else if ( expectedType === "string" ) { + ok = expected === errorString( actual ); + + // expected is a constructor, maybe an Error constructor + } else if ( expectedType === "function" && actual instanceof expected ) { + ok = true; + + // expected is an Error object + } else if ( expectedType === "object" ) { + ok = actual instanceof expected.constructor && + actual.name === expected.name && + actual.message === expected.message; + + // expected is a validation function which returns true if validation passed + } else if ( expectedType === "function" && expected.call( {}, actual ) === true ) { + expectedOutput = null; + ok = true; + } + + this.push( ok, actual, expectedOutput, message ); + } else { + this.test.pushFailure( message, null, "No exception was thrown." ); + } + } +}; + +// Test for equality any JavaScript type. +// Author: Philippe Rathé +QUnit.equiv = (function() { + + // Call the o related callback with the given arguments. + function bindCallbacks( o, callbacks, args ) { + var prop = QUnit.objectType( o ); + if ( prop ) { + if ( QUnit.objectType( callbacks[ prop ] ) === "function" ) { + return callbacks[ prop ].apply( callbacks, args ); + } else { + return callbacks[ prop ]; // or undefined + } + } + } + + // the real equiv function + var innerEquiv, + + // stack to decide between skip/abort functions + callers = [], + + // stack to avoiding loops from circular referencing + parents = [], + parentsB = [], + + getProto = Object.getPrototypeOf || function( obj ) { + /* jshint camelcase: false, proto: true */ + return obj.__proto__; + }, + callbacks = (function() { + + // for string, boolean, number and null + function useStrictEquality( b, a ) { + + /*jshint eqeqeq:false */ + if ( b instanceof a.constructor || a instanceof b.constructor ) { + + // to catch short annotation VS 'new' annotation of a + // declaration + // e.g. var i = 1; + // var j = new Number(1); + return a == b; + } else { + return a === b; + } + } + + return { + "string": useStrictEquality, + "boolean": useStrictEquality, + "number": useStrictEquality, + "null": useStrictEquality, + "undefined": useStrictEquality, + + "nan": function( b ) { + return isNaN( b ); + }, + + "date": function( b, a ) { + return QUnit.objectType( b ) === "date" && a.valueOf() === b.valueOf(); + }, + + "regexp": function( b, a ) { + return QUnit.objectType( b ) === "regexp" && + + // the regex itself + a.source === b.source && + + // and its modifiers + a.global === b.global && + + // (gmi) ... + a.ignoreCase === b.ignoreCase && + a.multiline === b.multiline && + a.sticky === b.sticky; + }, + + // - skip when the property is a method of an instance (OOP) + // - abort otherwise, + // initial === would have catch identical references anyway + "function": function() { + var caller = callers[ callers.length - 1 ]; + return caller !== Object && typeof caller !== "undefined"; + }, + + "array": function( b, a ) { + var i, j, len, loop, aCircular, bCircular; + + // b could be an object literal here + if ( QUnit.objectType( b ) !== "array" ) { + return false; + } + + len = a.length; + if ( len !== b.length ) { + // safe and faster + return false; + } + + // track reference to avoid circular references + parents.push( a ); + parentsB.push( b ); + for ( i = 0; i < len; i++ ) { + loop = false; + for ( j = 0; j < parents.length; j++ ) { + aCircular = parents[ j ] === a[ i ]; + bCircular = parentsB[ j ] === b[ i ]; + if ( aCircular || bCircular ) { + if ( a[ i ] === b[ i ] || aCircular && bCircular ) { + loop = true; + } else { + parents.pop(); + parentsB.pop(); + return false; + } + } + } + if ( !loop && !innerEquiv( a[ i ], b[ i ] ) ) { + parents.pop(); + parentsB.pop(); + return false; + } + } + parents.pop(); + parentsB.pop(); + return true; + }, + + "object": function( b, a ) { + + /*jshint forin:false */ + var i, j, loop, aCircular, bCircular, + // Default to true + eq = true, + aProperties = [], + bProperties = []; + + // comparing constructors is more strict than using + // instanceof + if ( a.constructor !== b.constructor ) { + + // Allow objects with no prototype to be equivalent to + // objects with Object as their constructor. + if ( !( ( getProto( a ) === null && getProto( b ) === Object.prototype ) || + ( getProto( b ) === null && getProto( a ) === Object.prototype ) ) ) { + return false; + } + } + + // stack constructor before traversing properties + callers.push( a.constructor ); + + // track reference to avoid circular references + parents.push( a ); + parentsB.push( b ); + + // be strict: don't ensure hasOwnProperty and go deep + for ( i in a ) { + loop = false; + for ( j = 0; j < parents.length; j++ ) { + aCircular = parents[ j ] === a[ i ]; + bCircular = parentsB[ j ] === b[ i ]; + if ( aCircular || bCircular ) { + if ( a[ i ] === b[ i ] || aCircular && bCircular ) { + loop = true; + } else { + eq = false; + break; + } + } + } + aProperties.push( i ); + if ( !loop && !innerEquiv( a[ i ], b[ i ] ) ) { + eq = false; + break; + } + } + + parents.pop(); + parentsB.pop(); + callers.pop(); // unstack, we are done + + for ( i in b ) { + bProperties.push( i ); // collect b's properties + } + + // Ensures identical properties name + return eq && innerEquiv( aProperties.sort(), bProperties.sort() ); + } + }; + }()); + + innerEquiv = function() { // can take multiple arguments + var args = [].slice.apply( arguments ); + if ( args.length < 2 ) { + return true; // end transition + } + + return ( (function( a, b ) { + if ( a === b ) { + return true; // catch the most you can + } else if ( a === null || b === null || typeof a === "undefined" || + typeof b === "undefined" || + QUnit.objectType( a ) !== QUnit.objectType( b ) ) { + + // don't lose time with error prone cases + return false; + } else { + return bindCallbacks( a, callbacks, [ b, a ] ); + } + + // apply transition with (1..n) arguments + }( args[ 0 ], args[ 1 ] ) ) && innerEquiv.apply( this, args.splice( 1, args.length - 1 ) ) ); + }; + + return innerEquiv; +}()); + +// Based on jsDump by Ariel Flesler +// http://flesler.blogspot.com/2008/05/jsdump-pretty-dump-of-any-javascript.html +QUnit.dump = (function() { + function quote( str ) { + return "\"" + str.toString().replace( /"/g, "\\\"" ) + "\""; + } + function literal( o ) { + return o + ""; + } + function join( pre, arr, post ) { + var s = dump.separator(), + base = dump.indent(), + inner = dump.indent( 1 ); + if ( arr.join ) { + arr = arr.join( "," + s + inner ); + } + if ( !arr ) { + return pre + post; + } + return [ pre, inner + arr, base + post ].join( s ); + } + function array( arr, stack ) { + var i = arr.length, + ret = new Array( i ); + this.up(); + while ( i-- ) { + ret[ i ] = this.parse( arr[ i ], undefined, stack ); + } + this.down(); + return join( "[", ret, "]" ); + } + + var reName = /^function (\w+)/, + dump = { + // type is used mostly internally, you can fix a (custom)type in advance + parse: function( obj, type, stack ) { + stack = stack || []; + var inStack, res, + parser = this.parsers[ type || this.typeOf( obj ) ]; + + type = typeof parser; + inStack = inArray( obj, stack ); + + if ( inStack !== -1 ) { + return "recursion(" + ( inStack - stack.length ) + ")"; + } + if ( type === "function" ) { + stack.push( obj ); + res = parser.call( this, obj, stack ); + stack.pop(); + return res; + } + return ( type === "string" ) ? parser : this.parsers.error; + }, + typeOf: function( obj ) { + var type; + if ( obj === null ) { + type = "null"; + } else if ( typeof obj === "undefined" ) { + type = "undefined"; + } else if ( QUnit.is( "regexp", obj ) ) { + type = "regexp"; + } else if ( QUnit.is( "date", obj ) ) { + type = "date"; + } else if ( QUnit.is( "function", obj ) ) { + type = "function"; + } else if ( typeof obj.setInterval !== undefined && typeof obj.document !== "undefined" && typeof obj.nodeType === "undefined" ) { + type = "window"; + } else if ( obj.nodeType === 9 ) { + type = "document"; + } else if ( obj.nodeType ) { + type = "node"; + } else if ( + + // native arrays + toString.call( obj ) === "[object Array]" || + + // NodeList objects + ( typeof obj.length === "number" && typeof obj.item !== "undefined" && ( obj.length ? obj.item( 0 ) === obj[ 0 ] : ( obj.item( 0 ) === null && typeof obj[ 0 ] === "undefined" ) ) ) + ) { + type = "array"; + } else if ( obj.constructor === Error.prototype.constructor ) { + type = "error"; + } else { + type = typeof obj; + } + return type; + }, + separator: function() { + return this.multiline ? this.HTML ? "
" : "\n" : this.HTML ? " " : " "; + }, + // extra can be a number, shortcut for increasing-calling-decreasing + indent: function( extra ) { + if ( !this.multiline ) { + return ""; + } + var chr = this.indentChar; + if ( this.HTML ) { + chr = chr.replace( /\t/g, " " ).replace( / /g, " " ); + } + return new Array( this.depth + ( extra || 0 ) ).join( chr ); + }, + up: function( a ) { + this.depth += a || 1; + }, + down: function( a ) { + this.depth -= a || 1; + }, + setParser: function( name, parser ) { + this.parsers[ name ] = parser; + }, + // The next 3 are exposed so you can use them + quote: quote, + literal: literal, + join: join, + // + depth: 1, + // This is the list of parsers, to modify them, use dump.setParser + parsers: { + window: "[Window]", + document: "[Document]", + error: function( error ) { + return "Error(\"" + error.message + "\")"; + }, + unknown: "[Unknown]", + "null": "null", + "undefined": "undefined", + "function": function( fn ) { + var ret = "function", + // functions never have name in IE + name = "name" in fn ? fn.name : ( reName.exec( fn ) || [] )[ 1 ]; + + if ( name ) { + ret += " " + name; + } + ret += "( "; + + ret = [ ret, dump.parse( fn, "functionArgs" ), "){" ].join( "" ); + return join( ret, dump.parse( fn, "functionCode" ), "}" ); + }, + array: array, + nodelist: array, + "arguments": array, + object: function( map, stack ) { + /*jshint forin:false */ + var ret = [], keys, key, val, i, nonEnumerableProperties; + dump.up(); + keys = []; + for ( key in map ) { + keys.push( key ); + } + + // Some properties are not always enumerable on Error objects. + nonEnumerableProperties = [ "message", "name" ]; + for ( i in nonEnumerableProperties ) { + key = nonEnumerableProperties[ i ]; + if ( key in map && !( key in keys ) ) { + keys.push( key ); + } + } + keys.sort(); + for ( i = 0; i < keys.length; i++ ) { + key = keys[ i ]; + val = map[ key ]; + ret.push( dump.parse( key, "key" ) + ": " + dump.parse( val, undefined, stack ) ); + } + dump.down(); + return join( "{", ret, "}" ); + }, + node: function( node ) { + var len, i, val, + open = dump.HTML ? "<" : "<", + close = dump.HTML ? ">" : ">", + tag = node.nodeName.toLowerCase(), + ret = open + tag, + attrs = node.attributes; + + if ( attrs ) { + for ( i = 0, len = attrs.length; i < len; i++ ) { + val = attrs[ i ].nodeValue; + + // IE6 includes all attributes in .attributes, even ones not explicitly set. + // Those have values like undefined, null, 0, false, "" or "inherit". + if ( val && val !== "inherit" ) { + ret += " " + attrs[ i ].nodeName + "=" + dump.parse( val, "attribute" ); + } + } + } + ret += close; + + // Show content of TextNode or CDATASection + if ( node.nodeType === 3 || node.nodeType === 4 ) { + ret += node.nodeValue; + } + + return ret + open + "/" + tag + close; + }, + + // function calls it internally, it's the arguments part of the function + functionArgs: function( fn ) { + var args, + l = fn.length; + + if ( !l ) { + return ""; + } + + args = new Array( l ); + while ( l-- ) { + + // 97 is 'a' + args[ l ] = String.fromCharCode( 97 + l ); + } + return " " + args.join( ", " ) + " "; + }, + // object calls it internally, the key part of an item in a map + key: quote, + // function calls it internally, it's the content of the function + functionCode: "[code]", + // node calls it internally, it's an html attribute value + attribute: quote, + string: quote, + date: quote, + regexp: literal, + number: literal, + "boolean": literal + }, + // if true, entities are escaped ( <, >, \t, space and \n ) + HTML: false, + // indentation unit + indentChar: " ", + // if true, items in a collection, are separated by a \n, else just a space. + multiline: true + }; + + return dump; +}()); + +// back compat +QUnit.jsDump = QUnit.dump; + +// For browser, export only select globals +if ( typeof window !== "undefined" ) { + + // Deprecated + // Extend assert methods to QUnit and Global scope through Backwards compatibility + (function() { + var i, + assertions = Assert.prototype; + + function applyCurrent( current ) { + return function() { + var assert = new Assert( QUnit.config.current ); + current.apply( assert, arguments ); + }; + } + + for ( i in assertions ) { + QUnit[ i ] = applyCurrent( assertions[ i ] ); + } + })(); + + (function() { + var i, l, + keys = [ + "test", + "module", + "expect", + "asyncTest", + "start", + "stop", + "ok", + "equal", + "notEqual", + "propEqual", + "notPropEqual", + "deepEqual", + "notDeepEqual", + "strictEqual", + "notStrictEqual", + "throws" + ]; + + for ( i = 0, l = keys.length; i < l; i++ ) { + window[ keys[ i ] ] = QUnit[ keys[ i ] ]; + } + })(); + + window.QUnit = QUnit; +} + +// For CommonJS environments, export everything +if ( typeof module !== "undefined" && module.exports ) { + module.exports = QUnit; +} + +// Get a reference to the global object, like window in browsers +}( (function() { + return this; +})() )); + +/*istanbul ignore next */ +/* + * Javascript Diff Algorithm + * By John Resig (http://ejohn.org/) + * Modified by Chu Alan "sprite" + * + * Released under the MIT license. + * + * More Info: + * http://ejohn.org/projects/javascript-diff-algorithm/ + * + * Usage: QUnit.diff(expected, actual) + * + * QUnit.diff( "the quick brown fox jumped over", "the quick fox jumps over" ) == "the quick brown fox jumped jumps over" + */ +QUnit.diff = (function() { + var hasOwn = Object.prototype.hasOwnProperty; + + /*jshint eqeqeq:false, eqnull:true */ + function diff( o, n ) { + var i, + ns = {}, + os = {}; + + for ( i = 0; i < n.length; i++ ) { + if ( !hasOwn.call( ns, n[ i ] ) ) { + ns[ n[ i ] ] = { + rows: [], + o: null + }; + } + ns[ n[ i ] ].rows.push( i ); + } + + for ( i = 0; i < o.length; i++ ) { + if ( !hasOwn.call( os, o[ i ] ) ) { + os[ o[ i ] ] = { + rows: [], + n: null + }; + } + os[ o[ i ] ].rows.push( i ); + } + + for ( i in ns ) { + if ( hasOwn.call( ns, i ) ) { + if ( ns[ i ].rows.length === 1 && hasOwn.call( os, i ) && os[ i ].rows.length === 1 ) { + n[ ns[ i ].rows[ 0 ] ] = { + text: n[ ns[ i ].rows[ 0 ] ], + row: os[ i ].rows[ 0 ] + }; + o[ os[ i ].rows[ 0 ] ] = { + text: o[ os[ i ].rows[ 0 ] ], + row: ns[ i ].rows[ 0 ] + }; + } + } + } + + for ( i = 0; i < n.length - 1; i++ ) { + if ( n[ i ].text != null && n[ i + 1 ].text == null && n[ i ].row + 1 < o.length && o[ n[ i ].row + 1 ].text == null && + n[ i + 1 ] == o[ n[ i ].row + 1 ] ) { + + n[ i + 1 ] = { + text: n[ i + 1 ], + row: n[ i ].row + 1 + }; + o[ n[ i ].row + 1 ] = { + text: o[ n[ i ].row + 1 ], + row: i + 1 + }; + } + } + + for ( i = n.length - 1; i > 0; i-- ) { + if ( n[ i ].text != null && n[ i - 1 ].text == null && n[ i ].row > 0 && o[ n[ i ].row - 1 ].text == null && + n[ i - 1 ] == o[ n[ i ].row - 1 ] ) { + + n[ i - 1 ] = { + text: n[ i - 1 ], + row: n[ i ].row - 1 + }; + o[ n[ i ].row - 1 ] = { + text: o[ n[ i ].row - 1 ], + row: i - 1 + }; + } + } + + return { + o: o, + n: n + }; + } + + return function( o, n ) { + o = o.replace( /\s+$/, "" ); + n = n.replace( /\s+$/, "" ); + + var i, pre, + str = "", + out = diff( o === "" ? [] : o.split( /\s+/ ), n === "" ? [] : n.split( /\s+/ ) ), + oSpace = o.match( /\s+/g ), + nSpace = n.match( /\s+/g ); + + if ( oSpace == null ) { + oSpace = [ " " ]; + } else { + oSpace.push( " " ); + } + + if ( nSpace == null ) { + nSpace = [ " " ]; + } else { + nSpace.push( " " ); + } + + if ( out.n.length === 0 ) { + for ( i = 0; i < out.o.length; i++ ) { + str += "" + out.o[ i ] + oSpace[ i ] + ""; + } + } else { + if ( out.n[ 0 ].text == null ) { + for ( n = 0; n < out.o.length && out.o[ n ].text == null; n++ ) { + str += "" + out.o[ n ] + oSpace[ n ] + ""; + } + } + + for ( i = 0; i < out.n.length; i++ ) { + if ( out.n[ i ].text == null ) { + str += "" + out.n[ i ] + nSpace[ i ] + ""; + } else { + + // `pre` initialized at top of scope + pre = ""; + + for ( n = out.n[ i ].row + 1; n < out.o.length && out.o[ n ].text == null; n++ ) { + pre += "" + out.o[ n ] + oSpace[ n ] + ""; + } + str += " " + out.n[ i ].text + nSpace[ i ] + pre; + } + } + } + + return str; + }; +}()); + +(function() { + +// Deprecated QUnit.init - Ref #530 +// Re-initialize the configuration options +QUnit.init = function() { + var tests, banner, result, qunit, + config = QUnit.config; + + config.stats = { all: 0, bad: 0 }; + config.moduleStats = { all: 0, bad: 0 }; + config.started = 0; + config.updateRate = 1000; + config.blocking = false; + config.autostart = true; + config.autorun = false; + config.filter = ""; + config.queue = []; + config.semaphore = 1; + + // Return on non-browser environments + // This is necessary to not break on node tests + if ( typeof window === "undefined" ) { + return; + } + + qunit = id( "qunit" ); + if ( qunit ) { + qunit.innerHTML = + "

" + escapeText( document.title ) + "

" + + "

" + + "
" + + "

" + + "
    "; + } + + tests = id( "qunit-tests" ); + banner = id( "qunit-banner" ); + result = id( "qunit-testresult" ); + + if ( tests ) { + tests.innerHTML = ""; + } + + if ( banner ) { + banner.className = ""; + } + + if ( result ) { + result.parentNode.removeChild( result ); + } + + if ( tests ) { + result = document.createElement( "p" ); + result.id = "qunit-testresult"; + result.className = "result"; + tests.parentNode.insertBefore( result, tests ); + result.innerHTML = "Running...
     "; + } +}; + +// Resets the test setup. Useful for tests that modify the DOM. +/* +DEPRECATED: Use multiple tests instead of resetting inside a test. +Use testStart or testDone for custom cleanup. +This method will throw an error in 2.0, and will be removed in 2.1 +*/ +QUnit.reset = function() { + + // Return on non-browser environments + // This is necessary to not break on node tests + if ( typeof window === "undefined" ) { + return; + } + + var fixture = id( "qunit-fixture" ); + if ( fixture ) { + fixture.innerHTML = config.fixture; + } +}; + +// Don't load the HTML Reporter on non-Browser environments +if ( typeof window === "undefined" ) { + return; +} + +var config = QUnit.config, + hasOwn = Object.prototype.hasOwnProperty, + defined = { + document: typeof window.document !== "undefined", + sessionStorage: (function() { + var x = "qunit-test-string"; + try { + sessionStorage.setItem( x, x ); + sessionStorage.removeItem( x ); + return true; + } catch ( e ) { + return false; + } + }()) + }; + +/** +* Escape text for attribute or text content. +*/ +function escapeText( s ) { + if ( !s ) { + return ""; + } + s = s + ""; + + // Both single quotes and double quotes (for attributes) + return s.replace( /['"<>&]/g, function( s ) { + switch ( s ) { + case "'": + return "'"; + case "\"": + return """; + case "<": + return "<"; + case ">": + return ">"; + case "&": + return "&"; + } + }); +} + +/** + * @param {HTMLElement} elem + * @param {string} type + * @param {Function} fn + */ +function addEvent( elem, type, fn ) { + if ( elem.addEventListener ) { + + // Standards-based browsers + elem.addEventListener( type, fn, false ); + } else if ( elem.attachEvent ) { + + // support: IE <9 + elem.attachEvent( "on" + type, fn ); + } +} + +/** + * @param {Array|NodeList} elems + * @param {string} type + * @param {Function} fn + */ +function addEvents( elems, type, fn ) { + var i = elems.length; + while ( i-- ) { + addEvent( elems[ i ], type, fn ); + } +} + +function hasClass( elem, name ) { + return ( " " + elem.className + " " ).indexOf( " " + name + " " ) >= 0; +} + +function addClass( elem, name ) { + if ( !hasClass( elem, name ) ) { + elem.className += ( elem.className ? " " : "" ) + name; + } +} + +function toggleClass( elem, name ) { + if ( hasClass( elem, name ) ) { + removeClass( elem, name ); + } else { + addClass( elem, name ); + } +} + +function removeClass( elem, name ) { + var set = " " + elem.className + " "; + + // Class name may appear multiple times + while ( set.indexOf( " " + name + " " ) >= 0 ) { + set = set.replace( " " + name + " ", " " ); + } + + // trim for prettiness + elem.className = typeof set.trim === "function" ? set.trim() : set.replace( /^\s+|\s+$/g, "" ); +} + +function id( name ) { + return defined.document && document.getElementById && document.getElementById( name ); +} + +function getUrlConfigHtml() { + var i, j, val, + escaped, escapedTooltip, + selection = false, + len = config.urlConfig.length, + urlConfigHtml = ""; + + for ( i = 0; i < len; i++ ) { + val = config.urlConfig[ i ]; + if ( typeof val === "string" ) { + val = { + id: val, + label: val + }; + } + + escaped = escapeText( val.id ); + escapedTooltip = escapeText( val.tooltip ); + + config[ val.id ] = QUnit.urlParams[ val.id ]; + if ( !val.value || typeof val.value === "string" ) { + urlConfigHtml += ""; + } else { + urlConfigHtml += ""; + } + } + + return urlConfigHtml; +} + +function toolbarUrlConfigContainer() { + var urlConfigContainer = document.createElement( "span" ); + + urlConfigContainer.innerHTML = getUrlConfigHtml(); + + // For oldIE support: + // * Add handlers to the individual elements instead of the container + // * Use "click" instead of "change" for checkboxes + // * Fallback from event.target to event.srcElement + addEvents( urlConfigContainer.getElementsByTagName( "input" ), "click", function( event ) { + var params = {}, + target = event.target || event.srcElement; + params[ target.name ] = target.checked ? + target.defaultValue || true : + undefined; + window.location = QUnit.url( params ); + }); + addEvents( urlConfigContainer.getElementsByTagName( "select" ), "change", function( event ) { + var params = {}, + target = event.target || event.srcElement; + params[ target.name ] = target.options[ target.selectedIndex ].value || undefined; + window.location = QUnit.url( params ); + }); + + return urlConfigContainer; +} + +function getModuleNames() { + var i, + moduleNames = []; + + for ( i in config.modules ) { + if ( config.modules.hasOwnProperty( i ) ) { + moduleNames.push( i ); + } + } + + moduleNames.sort(function( a, b ) { + return a.localeCompare( b ); + }); + + return moduleNames; +} + +function toolbarModuleFilterHtml() { + var i, + moduleFilterHtml = "", + moduleNames = getModuleNames(); + + if ( moduleNames.length <= 1 ) { + return false; + } + + moduleFilterHtml += "" + + ""; + + return moduleFilterHtml; +} + +function toolbarModuleFilter() { + var moduleFilter = document.createElement( "span" ), + moduleFilterHtml = toolbarModuleFilterHtml(); + + if ( !moduleFilterHtml ) { + return false; + } + + moduleFilter.setAttribute( "id", "qunit-modulefilter-container" ); + moduleFilter.innerHTML = moduleFilterHtml; + + addEvent( moduleFilter.lastChild, "change", function() { + var selectBox = moduleFilter.getElementsByTagName( "select" )[ 0 ], + selectedModule = decodeURIComponent( selectBox.options[ selectBox.selectedIndex ].value ); + + window.location = QUnit.url({ + module: ( selectedModule === "" ) ? undefined : selectedModule, + + // Remove any existing filters + filter: undefined, + testNumber: undefined + }); + }); + + return moduleFilter; +} + +function toolbarFilter() { + var testList = id( "qunit-tests" ), + filter = document.createElement( "input" ); + + filter.type = "checkbox"; + filter.id = "qunit-filter-pass"; + + addEvent( filter, "click", function() { + if ( filter.checked ) { + addClass( testList, "hidepass" ); + if ( defined.sessionStorage ) { + sessionStorage.setItem( "qunit-filter-passed-tests", "true" ); + } + } else { + removeClass( testList, "hidepass" ); + if ( defined.sessionStorage ) { + sessionStorage.removeItem( "qunit-filter-passed-tests" ); + } + } + }); + + if ( config.hidepassed || defined.sessionStorage && + sessionStorage.getItem( "qunit-filter-passed-tests" ) ) { + filter.checked = true; + + addClass( testList, "hidepass" ); + } + + return filter; +} + +function toolbarLabel() { + var label = document.createElement( "label" ); + label.setAttribute( "for", "qunit-filter-pass" ); + label.setAttribute( "title", "Only show tests and assertions that fail. Stored in sessionStorage." ); + label.innerHTML = "Hide passed tests"; + + return label; +} + +function appendToolbar() { + var moduleFilter, + toolbar = id( "qunit-testrunner-toolbar" ); + + if ( toolbar ) { + toolbar.appendChild( toolbarFilter() ); + toolbar.appendChild( toolbarLabel() ); + toolbar.appendChild( toolbarUrlConfigContainer() ); + + moduleFilter = toolbarModuleFilter(); + if ( moduleFilter ) { + toolbar.appendChild( moduleFilter ); + } + } +} + +function appendBanner() { + var banner = id( "qunit-banner" ); + + if ( banner ) { + banner.className = ""; + banner.innerHTML = "" + banner.innerHTML + " "; + } +} + +function appendTestResults() { + var tests = id( "qunit-tests" ), + result = id( "qunit-testresult" ); + + if ( result ) { + result.parentNode.removeChild( result ); + } + + if ( tests ) { + tests.innerHTML = ""; + result = document.createElement( "p" ); + result.id = "qunit-testresult"; + result.className = "result"; + tests.parentNode.insertBefore( result, tests ); + result.innerHTML = "Running...
     "; + } +} + +function storeFixture() { + var fixture = id( "qunit-fixture" ); + if ( fixture ) { + config.fixture = fixture.innerHTML; + } +} + +function appendUserAgent() { + var userAgent = id( "qunit-userAgent" ); + if ( userAgent ) { + userAgent.innerHTML = navigator.userAgent; + } +} + +// HTML Reporter initialization and load +QUnit.begin(function() { + var qunit = id( "qunit" ); + + if ( qunit ) { + qunit.innerHTML = + "

    " + escapeText( document.title ) + "

    " + + "

    " + + "
    " + + "

    " + + "
      "; + } + + appendBanner(); + appendTestResults(); + appendUserAgent(); + appendToolbar(); + storeFixture(); +}); + +QUnit.done(function( details ) { + var i, key, + banner = id( "qunit-banner" ), + tests = id( "qunit-tests" ), + html = [ + "Tests completed in ", + details.runtime, + " milliseconds.
      ", + "", + details.passed, + " assertions of ", + details.total, + " passed, ", + details.failed, + " failed." + ].join( "" ); + + if ( banner ) { + banner.className = details.failed ? "qunit-fail" : "qunit-pass"; + } + + if ( tests ) { + id( "qunit-testresult" ).innerHTML = html; + } + + if ( config.altertitle && defined.document && document.title ) { + + // show ✖ for good, ✔ for bad suite result in title + // use escape sequences in case file gets loaded with non-utf-8-charset + document.title = [ + ( details.failed ? "\u2716" : "\u2714" ), + document.title.replace( /^[\u2714\u2716] /i, "" ) + ].join( " " ); + } + + // clear own sessionStorage items if all tests passed + if ( config.reorder && defined.sessionStorage && details.failed === 0 ) { + for ( i = 0; i < sessionStorage.length; i++ ) { + key = sessionStorage.key( i++ ); + if ( key.indexOf( "qunit-test-" ) === 0 ) { + sessionStorage.removeItem( key ); + } + } + } + + // scroll back to top to show results + if ( config.scrolltop && window.scrollTo ) { + window.scrollTo( 0, 0 ); + } +}); + +function getNameHtml( name, module ) { + var nameHtml = ""; + + if ( module ) { + nameHtml = "" + escapeText( module ) + ": "; + } + + nameHtml += "" + escapeText( name ) + ""; + + return nameHtml; +} + +QUnit.testStart(function( details ) { + var a, b, li, running, assertList, + name = getNameHtml( details.name, details.module ), + tests = id( "qunit-tests" ); + + if ( tests ) { + b = document.createElement( "strong" ); + b.innerHTML = name; + + a = document.createElement( "a" ); + a.innerHTML = "Rerun"; + a.href = QUnit.url({ testNumber: details.testNumber }); + + li = document.createElement( "li" ); + li.appendChild( b ); + li.appendChild( a ); + li.className = "running"; + li.id = "qunit-test-output" + details.testNumber; + + assertList = document.createElement( "ol" ); + assertList.className = "qunit-assert-list"; + + li.appendChild( assertList ); + + tests.appendChild( li ); + } + + running = id( "qunit-testresult" ); + if ( running ) { + running.innerHTML = "Running:
      " + name; + } + +}); + +QUnit.log(function( details ) { + var assertList, assertLi, + message, expected, actual, + testItem = id( "qunit-test-output" + details.testNumber ); + + if ( !testItem ) { + return; + } + + message = escapeText( details.message ) || ( details.result ? "okay" : "failed" ); + message = "" + message + ""; + + // pushFailure doesn't provide details.expected + // when it calls, it's implicit to also not show expected and diff stuff + // Also, we need to check details.expected existence, as it can exist and be undefined + if ( !details.result && hasOwn.call( details, "expected" ) ) { + expected = escapeText( QUnit.dump.parse( details.expected ) ); + actual = escapeText( QUnit.dump.parse( details.actual ) ); + message += ""; + + if ( actual !== expected ) { + message += "" + + ""; + } + + if ( details.source ) { + message += ""; + } + + message += "
      Expected:
      " +
      +			expected +
      +			"
      Result:
      " +
      +				actual + "
      Diff:
      " +
      +				QUnit.diff( expected, actual ) + "
      Source:
      " +
      +				escapeText( details.source ) + "
      "; + + // this occours when pushFailure is set and we have an extracted stack trace + } else if ( !details.result && details.source ) { + message += "" + + "" + + "
      Source:
      " +
      +			escapeText( details.source ) + "
      "; + } + + assertList = testItem.getElementsByTagName( "ol" )[ 0 ]; + + assertLi = document.createElement( "li" ); + assertLi.className = details.result ? "pass" : "fail"; + assertLi.innerHTML = message; + assertList.appendChild( assertLi ); +}); + +QUnit.testDone(function( details ) { + var testTitle, time, testItem, assertList, + good, bad, testCounts, + tests = id( "qunit-tests" ); + + // QUnit.reset() is deprecated and will be replaced for a new + // fixture reset function on QUnit 2.0/2.1. + // It's still called here for backwards compatibility handling + QUnit.reset(); + + if ( !tests ) { + return; + } + + testItem = id( "qunit-test-output" + details.testNumber ); + assertList = testItem.getElementsByTagName( "ol" )[ 0 ]; + + good = details.passed; + bad = details.failed; + + // store result when possible + if ( config.reorder && defined.sessionStorage ) { + if ( bad ) { + sessionStorage.setItem( "qunit-test-" + details.module + "-" + details.name, bad ); + } else { + sessionStorage.removeItem( "qunit-test-" + details.module + "-" + details.name ); + } + } + + if ( bad === 0 ) { + addClass( assertList, "qunit-collapsed" ); + } + + // testItem.firstChild is the test name + testTitle = testItem.firstChild; + + testCounts = bad ? + "" + bad + ", " + "" + good + ", " : + ""; + + testTitle.innerHTML += " (" + testCounts + + details.assertions.length + ")"; + + addEvent( testTitle, "click", function() { + toggleClass( assertList, "qunit-collapsed" ); + }); + + time = document.createElement( "span" ); + time.className = "runtime"; + time.innerHTML = details.runtime + " ms"; + + testItem.className = bad ? "fail" : "pass"; + + testItem.insertBefore( time, assertList ); +}); + +if ( !defined.document || document.readyState === "complete" ) { + config.autorun = true; +} + +if ( defined.document ) { + addEvent( window, "load", QUnit.load ); +} + +})(); diff --git a/test/test.html b/test/test.html new file mode 100644 index 00000000..8950f2f0 --- /dev/null +++ b/test/test.html @@ -0,0 +1,79 @@ + + + + + TableFilter basic test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      FromDestinationRoad Distance (km)By Air (hrs)By Rail (hrs)
      SydneyAdelaide14121.425.3
      SydneyBrisbane9821.516
      SydneyCanberra286.64.3
      SydneyMelbourne8721.110.5
      AdelaidePerth27813.138
      AdelaideAlice Springs1533220.25
      AdelaideBrisbane20452.1540
      + + + +
      +
      + + + + + \ No newline at end of file diff --git a/test/test.js b/test/test.js new file mode 100644 index 00000000..02d5e4ac --- /dev/null +++ b/test/test.js @@ -0,0 +1,19 @@ +(function(TableFilter){ + + var tf = new TableFilter('demo'); + tf.init(); + + module("Sanity check tests"); + test("TableFilter object", function() { + equal(tf.id, 'demo', 'id check'); + equal(tf.filtersRowIndex, 0, 'Filters row index'); + deepEqual(tf.fltCol.length, 5, 'filters type collection length'); + }); + + module('DOM tests'); + test('Filters row', function() { + equal(tf.tbl.rows[0].className, 'fltrow', 'Filters row CSS class name'); + equal(tf.GetFilterElement(0).nodeName, 'INPUT', 'Filter DOM element'); + }); + +})(TableFilter); \ No newline at end of file