2014-10-10 15:34:45 +02:00
|
|
|
/*------------------------------------------------------------------------
|
2014-11-08 13:37:24 +01:00
|
|
|
- HTML Table Filter Generator v3.0
|
2014-09-07 12:07:28 +02:00
|
|
|
- By Max Guglielmi (tablefilter.free.fr)
|
|
|
|
- Licensed under the MIT License
|
2014-09-24 08:06:12 +02:00
|
|
|
---------------------------------------------------------------------------
|
2014-09-07 12:07:28 +02:00
|
|
|
- Special credit to:
|
2014-09-20 06:57:49 +02:00
|
|
|
Cedric Wartel, cnx.claude@free.fr, Florent Hirchy, Váry Péter,
|
2014-09-07 12:07:28 +02:00
|
|
|
Anthony Maes, Nuovella Williams, Fuggerbit, Venkata Seshagiri Rao
|
|
|
|
Raya, Piepiax, Manuel Kern, Baladhandayutham for active contribution
|
|
|
|
and/or inspiration
|
2014-09-24 08:06:12 +02:00
|
|
|
------------------------------------------------------------------------ */
|
2014-10-26 11:48:13 +01:00
|
|
|
define(function (require) {
|
2014-10-18 14:00:34 +02:00
|
|
|
|
|
|
|
var global = this,
|
|
|
|
TF = global.TF,
|
2014-10-26 11:48:13 +01:00
|
|
|
evt = require('event'),
|
|
|
|
dom = require('dom'),
|
|
|
|
str = require('string'),
|
|
|
|
cookie = require('cookie'),
|
|
|
|
types = require('types'),
|
|
|
|
array = require('array'),
|
2014-11-01 15:34:37 +01:00
|
|
|
hlp = require('helpers'),
|
2014-10-26 11:48:13 +01:00
|
|
|
isValidDate = require('date').isValid,
|
|
|
|
formatDate = require('date').format,
|
2014-10-18 14:00:34 +02:00
|
|
|
doc = global.document;
|
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
/**
|
|
|
|
* TF object constructor
|
|
|
|
* @param {String} id Table id
|
|
|
|
* @param {Number} row index indicating the 1st row
|
|
|
|
* @param {Object} configuration object
|
|
|
|
*/
|
2014-10-18 14:00:34 +02:00
|
|
|
function TableFilter(id) {
|
2014-09-20 15:56:35 +02:00
|
|
|
if(arguments.length === 0){ return; }
|
2014-10-06 13:08:29 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
this.id = id;
|
2014-10-26 02:42:34 +01:00
|
|
|
this.version = '3.0';
|
2014-09-20 15:56:35 +02:00
|
|
|
this.year = new Date().getFullYear();
|
2014-11-01 15:34:37 +01:00
|
|
|
this.tbl = dom.id(id);
|
2014-09-20 15:56:35 +02:00
|
|
|
this.startRow = null;
|
|
|
|
this.refRow = null;
|
|
|
|
this.headersRow = null;
|
|
|
|
this.fObj = null;
|
|
|
|
this.nbFilterableRows = null;
|
|
|
|
this.nbRows = null;
|
|
|
|
this.nbCells = null;
|
|
|
|
this.hasGrid = false;
|
|
|
|
this.enableModules = false;
|
|
|
|
|
2014-10-18 14:00:34 +02:00
|
|
|
if(!this.tbl || str.lower(this.tbl.nodeName) !== 'table' ||
|
2014-09-20 15:56:35 +02:00
|
|
|
this.GetRowsNb() === 0){
|
|
|
|
throw new Error(
|
2014-11-08 13:37:24 +01:00
|
|
|
'Could not instantiate TF object: HTML table not found.');
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
2014-09-20 10:09:23 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
if(arguments.length>1){
|
|
|
|
for(var i=0; i<arguments.length; i++){
|
|
|
|
var arg = arguments[i];
|
|
|
|
var argtype = typeof arg;
|
2014-10-18 14:00:34 +02:00
|
|
|
switch(str.lower(argtype)){
|
2014-09-20 15:56:35 +02:00
|
|
|
case 'number':
|
|
|
|
this.startRow = arg;
|
|
|
|
break;
|
|
|
|
case 'object':
|
|
|
|
this.fObj = arg;
|
|
|
|
break;
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
2014-09-20 10:09:23 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
// configuration object
|
|
|
|
var f = this.fObj || {};
|
|
|
|
|
|
|
|
//Start row et cols nb
|
|
|
|
this.refRow = this.startRow===null ? 2 : (this.startRow+1);
|
|
|
|
try{ this.nbCells = this.GetCellsNb(this.refRow); }
|
|
|
|
catch(e){ this.nbCells = this.GetCellsNb(0); }
|
|
|
|
|
|
|
|
//default script base path
|
2014-11-01 15:34:37 +01:00
|
|
|
this.basePath = f.base_path!==undefined ? f.base_path : '';
|
2014-09-20 15:56:35 +02:00
|
|
|
|
|
|
|
/*** filter types ***/
|
|
|
|
this.fltTypeInp = 'input';
|
|
|
|
this.fltTypeSlc = 'select';
|
|
|
|
this.fltTypeMulti = 'multiple';
|
|
|
|
this.fltTypeCheckList = 'checklist';
|
|
|
|
this.fltTypeNone = 'none';
|
|
|
|
this.fltCol = []; //filter type of each column
|
|
|
|
|
|
|
|
for(var j=0; j<this.nbCells; j++){
|
2014-10-18 14:00:34 +02:00
|
|
|
var cfgCol = f['col_'+j];
|
|
|
|
var col = !cfgCol ? this.fltTypeInp : str.lower(cfgCol);
|
2014-09-20 15:56:35 +02:00
|
|
|
this.fltCol.push(col);
|
2014-10-18 14:00:34 +02:00
|
|
|
this['col'+j] = col;
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
2014-09-20 06:57:49 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
/*** Developer's additional methods ***/
|
|
|
|
this.publicMethods = f.public_methods!==undefined ?
|
|
|
|
f.public_methods : false;
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
/*** filters' grid properties ***/
|
2014-09-20 06:57:49 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
//enables/disables filter grid
|
|
|
|
this.fltGrid = f.grid===false ? false : true;
|
2014-09-20 06:57:49 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
/*** Grid layout ***/
|
|
|
|
//enables/disables grid layout (fixed headers)
|
|
|
|
this.gridLayout = f.grid_layout ? true : false;
|
2014-09-20 06:57:49 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
//flag indicating if the grid has an additional row for column
|
|
|
|
//widths (IE<=7)
|
|
|
|
this.hasGridWidthsRow = false;
|
|
|
|
this.gridColElms = [];
|
|
|
|
this.sourceTblHtml = null;
|
|
|
|
if(this.gridLayout){
|
|
|
|
//Firefox does not support outerHTML property...
|
2014-10-18 14:00:34 +02:00
|
|
|
if(this.tbl.outerHTML===undefined){ setOuterHtml(); }
|
2014-09-20 15:56:35 +02:00
|
|
|
this.sourceTblHtml = this.tbl.outerHTML;
|
|
|
|
}
|
|
|
|
/*** ***/
|
2014-09-20 06:57:49 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
this.filtersRowIndex = f.filters_row_index || 0;
|
|
|
|
this.headersRow = f.headers_row_index ||
|
|
|
|
(this.filtersRowIndex===0 ? 1 : 0);
|
2014-09-20 10:09:23 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
if(this.gridLayout){
|
|
|
|
if(this.headersRow > 1){
|
|
|
|
this.filtersRowIndex = this.headersRow+1;
|
|
|
|
} else {
|
|
|
|
this.filtersRowIndex = 1;
|
|
|
|
this.headersRow = 0;
|
|
|
|
}
|
|
|
|
}
|
2014-09-20 10:09:23 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
//defines tag of the cells containing filters (td/th)
|
|
|
|
this.fltCellTag = f.filters_cell_tag!=='th' ||
|
|
|
|
f.filters_cell_tag!=='td' ? 'td' : f.filters_cell_tag;
|
|
|
|
|
|
|
|
//stores filters ids
|
|
|
|
this.fltIds = [];
|
|
|
|
//stores filters DOM elements
|
|
|
|
this.fltElms = [];
|
|
|
|
//stores filters values
|
|
|
|
this.searchArgs = null;
|
|
|
|
//stores table data
|
|
|
|
this.tblData = [];
|
|
|
|
//stores valid rows indexes (rows visible upon filtering)
|
|
|
|
this.validRowsIndex = null;
|
|
|
|
//stores filters row element
|
|
|
|
this.fltGridEl = null;
|
|
|
|
//is first load boolean
|
|
|
|
this.isFirstLoad = true;
|
|
|
|
//container div for paging elements, reset btn etc.
|
|
|
|
this.infDiv = null;
|
|
|
|
//div for rows counter
|
|
|
|
this.lDiv = null;
|
|
|
|
//div for reset button and results per page select
|
|
|
|
this.rDiv = null;
|
|
|
|
//div for paging elements
|
|
|
|
this.mDiv = null;
|
|
|
|
//table container div for fixed headers (IE only)
|
|
|
|
this.contDiv = null;
|
|
|
|
|
|
|
|
//defines css class for div containing paging elements, rows counter etc.
|
|
|
|
this.infDivCssClass = f.inf_div_css_class || 'inf';
|
|
|
|
//defines css class for left div
|
|
|
|
this.lDivCssClass = f.left_div_css_class || 'ldiv';
|
|
|
|
//defines css class for right div
|
|
|
|
this.rDivCssClass = f.right_div_css_class || 'rdiv';
|
|
|
|
//defines css class for mid div
|
|
|
|
this.mDivCssClass = f.middle_div_css_class || 'mdiv';
|
|
|
|
//table container div css class
|
|
|
|
this.contDivCssClass = f.content_div_css_class || 'cont';
|
|
|
|
|
|
|
|
/*** filters' grid appearance ***/
|
|
|
|
//stylesheet file
|
|
|
|
this.stylesheet = f.stylesheet || this.basePath+'filtergrid.css';
|
|
|
|
this.stylesheetId = this.id + '_style';
|
|
|
|
//defines css class for filters row
|
|
|
|
this.fltsRowCssClass = f.flts_row_css_class || 'fltrow';
|
|
|
|
//enables/disables icons (paging, reset button)
|
|
|
|
this.enableIcons = f.enable_icons===false ? false : true;
|
|
|
|
//enables/disbles rows alternating bg colors
|
|
|
|
this.alternateBgs = f.alternate_rows===true ? true : false;
|
|
|
|
//defines widths of columns
|
|
|
|
this.hasColWidth = f.col_width===true ? true : false;
|
|
|
|
this.colWidth = this.hasColWidth ? f.col_width : null;
|
|
|
|
//enables/disables fixed headers
|
|
|
|
this.fixedHeaders = f.fixed_headers===true ? true : false;
|
|
|
|
//tbody height if fixed headers enabled
|
|
|
|
this.tBodyH = !isNaN(f.tbody_height) ? f.tbody_height : 200;
|
|
|
|
//defines css class for filters
|
|
|
|
this.fltCssClass = f.flt_css_class || 'flt';
|
|
|
|
//defines css class for multiple selects filters
|
|
|
|
this.fltMultiCssClass = f.flt_multi_css_class || 'flt_multi';
|
|
|
|
//defines css class for filters
|
|
|
|
this.fltSmallCssClass = f.flt_small_css_class || 'flt_s';
|
|
|
|
//defines css class for single-filter
|
|
|
|
this.singleFltCssClass = f.single_flt_css_class || 'single_flt';
|
|
|
|
this.isStartBgAlternate = true;
|
2014-11-09 09:31:15 +01:00
|
|
|
// //defines css class for even rows
|
|
|
|
// this.rowBgEvenCssClass = f.even_row_css_class || 'even';
|
|
|
|
// //defines css class for odd rows
|
|
|
|
// this.rowBgOddCssClass = f.odd_row_css_class || 'odd';
|
2014-09-20 15:56:35 +02:00
|
|
|
|
|
|
|
/*** filters' grid behaviours ***/
|
|
|
|
//enables/disables enter key
|
|
|
|
this.enterKey = f.enter_key===false ? false : true;
|
|
|
|
//enables/disables alternative fn call
|
|
|
|
this.isModFilterFn = f.mod_filter_fn===true ? true : false;
|
|
|
|
// used by tf_DetectKey fn
|
|
|
|
this.modFilterFn = this.isModFilterFn ? f.mod_filter_fn : null;
|
|
|
|
//calls function before filtering starts
|
2014-10-18 14:00:34 +02:00
|
|
|
this.onBeforeFilter = types.isFn(f.on_before_filter) ?
|
2014-09-20 15:56:35 +02:00
|
|
|
f.on_before_filter : null;
|
|
|
|
//calls function after filtering
|
2014-10-18 14:00:34 +02:00
|
|
|
this.onAfterFilter = types.isFn(f.on_after_filter) ?
|
2014-09-20 15:56:35 +02:00
|
|
|
f.on_after_filter : null;
|
|
|
|
//enables/disables case sensitivity
|
|
|
|
this.matchCase = f.match_case===true ? true : false;
|
|
|
|
//enables/disbles exact match for search
|
|
|
|
this.exactMatch = f.exact_match===true ? true : false;
|
|
|
|
//refreshes drop-down lists upon validation
|
|
|
|
this.refreshFilters = f.refresh_filters===true ? true : false;
|
|
|
|
//wheter excluded options are disabled
|
|
|
|
this.disableExcludedOptions = f.disable_excluded_options===true ?
|
|
|
|
true : false;
|
|
|
|
//stores active filter element
|
|
|
|
this.activeFlt = null;
|
|
|
|
//id of active filter
|
|
|
|
this.activeFilterId = null;
|
|
|
|
//enables/disbles column operation(sum,mean)
|
|
|
|
this.hasColOperation = f.col_operation===true ? true : false;
|
|
|
|
this.colOperation = null;
|
|
|
|
//enables always visible rows
|
|
|
|
this.hasVisibleRows = f.rows_always_visible===true ? true : false;
|
|
|
|
//array containing always visible rows
|
|
|
|
this.visibleRows = this.hasVisibleRows ? f.rows_always_visible : [];
|
|
|
|
//defines search type: include or exclude
|
|
|
|
this.searchType = f.search_type || 'include';
|
|
|
|
//enables/disables external filters generation
|
|
|
|
this.isExternalFlt = f.external_flt_grid===true ? true : false;
|
|
|
|
//array containing ids of external elements containing filters
|
|
|
|
this.externalFltTgtIds = f.external_flt_grid_ids || null;
|
|
|
|
//stores filters elements if isExternalFlt is true
|
|
|
|
this.externalFltEls = [];
|
|
|
|
//delays any filtering process if loader true
|
|
|
|
this.execDelay = !isNaN(f.exec_delay) ? parseInt(f.exec_delay,10) : 100;
|
|
|
|
//enables/disables status messages
|
|
|
|
this.status = f.status===true ? true : false;
|
|
|
|
//calls function when filters grid loaded
|
2014-10-18 14:00:34 +02:00
|
|
|
this.onFiltersLoaded = types.isFn(f.on_filters_loaded) ?
|
2014-09-20 15:56:35 +02:00
|
|
|
f.on_filters_loaded : null;
|
|
|
|
//enables/disables single filter search
|
|
|
|
this.singleSearchFlt = f.single_search_filter===true ? true : false;
|
|
|
|
//calls function after row is validated
|
2014-10-18 14:00:34 +02:00
|
|
|
this.onRowValidated = types.isFn(f.on_row_validated) ?
|
2014-09-20 15:56:35 +02:00
|
|
|
f.on_row_validated : null;
|
|
|
|
//array defining columns for customCellData event
|
|
|
|
this.customCellDataCols = f.custom_cell_data_cols ?
|
|
|
|
f.custom_cell_data_cols : [];
|
|
|
|
//calls custom function for retrieving cell data
|
2014-10-18 14:00:34 +02:00
|
|
|
this.customCellData = types.isFn(f.custom_cell_data) ?
|
2014-09-20 15:56:35 +02:00
|
|
|
f.custom_cell_data : null;
|
|
|
|
//input watermark text array
|
|
|
|
this.inpWatermark = f.input_watermark || '';
|
|
|
|
//defines css class for input watermark
|
|
|
|
this.inpWatermarkCssClass = f.input_watermark_css_class ||
|
|
|
|
'fltWatermark';
|
2014-10-18 14:00:34 +02:00
|
|
|
this.isInpWatermarkArray = types.isArray(f.input_watermark);
|
2014-09-20 15:56:35 +02:00
|
|
|
//id of toolbar container element
|
|
|
|
this.toolBarTgtId = f.toolbar_target_id || null;
|
|
|
|
//enables/disables help div
|
|
|
|
this.helpInstructions = f.help_instructions || null;
|
|
|
|
//popup filters
|
|
|
|
this.popUpFilters = f.popup_filters===true ? true : false;
|
|
|
|
//active columns color
|
|
|
|
this.markActiveColumns = f.mark_active_columns===true ? true : false;
|
|
|
|
//defines css class for active column header
|
|
|
|
this.activeColumnsCssClass = f.active_columns_css_class ||
|
|
|
|
'activeHeader';
|
|
|
|
//calls function before active column header is marked
|
2014-10-18 14:00:34 +02:00
|
|
|
this.onBeforeActiveColumn = types.isFn(f.on_before_active_column) ?
|
2014-09-20 15:56:35 +02:00
|
|
|
f.on_before_active_column : null;
|
|
|
|
//calls function after active column header is marked
|
2014-10-18 14:00:34 +02:00
|
|
|
this.onAfterActiveColumn = types.isFn(f.on_after_active_column) ?
|
2014-09-20 15:56:35 +02:00
|
|
|
f.on_after_active_column : null;
|
|
|
|
|
|
|
|
/*** select filter's customisation and behaviours ***/
|
|
|
|
//defines 1st option text
|
|
|
|
this.displayAllText = f.display_all_text || '';
|
|
|
|
this.enableSlcResetFilter = f.enable_slc_reset_filter===false ?
|
|
|
|
false : true;
|
|
|
|
//enables/disables empty option in combo-box filters
|
|
|
|
this.enableEmptyOption = f.enable_empty_option===true ? true : false;
|
|
|
|
//defines empty option text
|
|
|
|
this.emptyText = f.empty_text || '(Empty)';
|
|
|
|
//enables/disables non empty option in combo-box filters
|
|
|
|
this.enableNonEmptyOption = f.enable_non_empty_option===true ?
|
|
|
|
true : false;
|
|
|
|
//defines empty option text
|
|
|
|
this.nonEmptyText = f.non_empty_text || '(Non empty)';
|
|
|
|
//enables/disables onChange event on combo-box
|
|
|
|
this.onSlcChange = f.on_change===false ? false : true;
|
|
|
|
//enables/disables select options sorting
|
|
|
|
this.sortSlc = f.sort_select===false ? false : true;
|
|
|
|
//enables/disables ascending numeric options sorting
|
|
|
|
this.isSortNumAsc = f.sort_num_asc===true ? true : false;
|
|
|
|
this.sortNumAsc = this.isSortNumAsc ? f.sort_num_asc : null;
|
|
|
|
//enables/disables descending numeric options sorting
|
|
|
|
this.isSortNumDesc = f.sort_num_desc===true ? true : false;
|
|
|
|
this.sortNumDesc = this.isSortNumDesc ? f.sort_num_desc : null;
|
|
|
|
//sets select filling method: 'innerHTML' or 'createElement'
|
|
|
|
this.slcFillingMethod = f.slc_filling_method || 'createElement';
|
|
|
|
//enabled selects are populated on demand
|
|
|
|
this.fillSlcOnDemand = f.fill_slc_on_demand===true ? true : false;
|
|
|
|
//IE only, tooltip text appearing on select before it is populated
|
|
|
|
this.activateSlcTooltip = f.activate_slc_tooltip ||
|
|
|
|
'Click to activate';
|
|
|
|
//tooltip text appearing on multiple select
|
|
|
|
this.multipleSlcTooltip = f.multiple_slc_tooltip ||
|
|
|
|
'Use Ctrl key for multiple selections';
|
2014-10-18 14:00:34 +02:00
|
|
|
this.hasCustomSlcOptions = types.isObj(f.custom_slc_options) ?
|
2014-09-20 15:56:35 +02:00
|
|
|
true : false;
|
2014-10-20 09:11:33 +02:00
|
|
|
this.customSlcOptions = types.isArray(f.custom_slc_options) ?
|
2014-09-20 15:56:35 +02:00
|
|
|
f.custom_slc_options : null;
|
|
|
|
//calls function before col operation
|
2014-10-18 14:00:34 +02:00
|
|
|
this.onBeforeOperation = types.isFn(f.on_before_operation) ?
|
2014-09-20 15:56:35 +02:00
|
|
|
f.on_before_operation : null;
|
|
|
|
//calls function after col operation
|
2014-10-18 14:00:34 +02:00
|
|
|
this.onAfterOperation = types.isFn(f.on_after_operation) ?
|
2014-09-20 15:56:35 +02:00
|
|
|
f.on_after_operation : null;
|
|
|
|
|
|
|
|
/*** checklist customisation and behaviours ***/
|
|
|
|
this.checkListDiv = []; //checklist container div
|
|
|
|
//defines css class for div containing checklist filter
|
|
|
|
this.checkListDivCssClass = f.div_checklist_css_class ||
|
|
|
|
'div_checklist';
|
|
|
|
//defines css class for checklist filters
|
|
|
|
this.checkListCssClass = f.checklist_css_class || 'flt_checklist';
|
|
|
|
//defines css class for checklist item (li)
|
|
|
|
this.checkListItemCssClass = f.checklist_item_css_class ||
|
|
|
|
'flt_checklist_item';
|
|
|
|
//defines css class for selected checklist item (li)
|
|
|
|
this.checkListSlcItemCssClass = f.checklist_selected_item_css_class ||
|
|
|
|
'flt_checklist_slc_item';
|
|
|
|
//Load on demand text
|
|
|
|
this.activateCheckListTxt = f.activate_checklist_text ||
|
|
|
|
'Click to load filter data';
|
|
|
|
//defines css class for checklist filters
|
|
|
|
this.checkListItemDisabledCssClass =
|
|
|
|
f.checklist_item_disabled_css_class ||
|
|
|
|
'flt_checklist_item_disabled';
|
|
|
|
this.enableCheckListResetFilter =
|
|
|
|
f.enable_checklist_reset_filter===false ? false : true;
|
|
|
|
|
|
|
|
/*** Filter operators ***/
|
|
|
|
this.rgxOperator = f.regexp_operator || 'rgx:';
|
|
|
|
this.emOperator = f.empty_operator || '[empty]';
|
|
|
|
this.nmOperator = f.nonempty_operator || '[nonempty]';
|
|
|
|
this.orOperator = f.or_operator || '||';
|
|
|
|
this.anOperator = f.and_operator || '&&';
|
|
|
|
this.grOperator = f.greater_operator || '>';
|
|
|
|
this.lwOperator = f.lower_operator || '<';
|
|
|
|
this.leOperator = f.lower_equal_operator || '<=';
|
|
|
|
this.geOperator = f.greater_equal_operator || '>=';
|
|
|
|
this.dfOperator = f.different_operator || '!';
|
|
|
|
this.lkOperator = f.like_operator || '*';
|
|
|
|
this.eqOperator = f.equal_operator || '=';
|
|
|
|
this.stOperator = f.start_with_operator || '{';
|
|
|
|
this.enOperator = f.end_with_operator || '}';
|
|
|
|
this.curExp = f.cur_exp || '^[¥£€$]';
|
|
|
|
this.separator = f.separator || ',';
|
|
|
|
|
|
|
|
/*** rows counter ***/
|
|
|
|
//show/hides rows counter
|
|
|
|
this.rowsCounter = f.rows_counter===true ? true : false;
|
|
|
|
|
|
|
|
/*** status bar ***/
|
|
|
|
//show/hides status bar
|
|
|
|
this.statusBar = f.status_bar===true ? true : false;
|
|
|
|
|
|
|
|
/*** loader ***/
|
|
|
|
//enables/disables loader/spinner indicator
|
|
|
|
this.loader = f.loader===true ? true : false;
|
|
|
|
|
|
|
|
/*** validation - reset buttons/links ***/
|
|
|
|
//show/hides filter's validation button
|
|
|
|
this.displayBtn = f.btn===true ? true : false;
|
|
|
|
//defines validation button text
|
|
|
|
this.btnText = f.btn_text || (!this.enableIcons ? 'Go' : '');
|
|
|
|
//defines css class for validation button
|
|
|
|
this.btnCssClass = f.btn_css_class ||
|
|
|
|
(!this.enableIcons ? 'btnflt' : 'btnflt_icon');
|
|
|
|
//show/hides reset link
|
|
|
|
this.btnReset = f.btn_reset===true ? true : false;
|
|
|
|
//defines css class for reset button
|
|
|
|
this.btnResetCssClass = f.btn_reset_css_class || 'reset';
|
|
|
|
//callback function before filters are cleared
|
2014-10-18 14:00:34 +02:00
|
|
|
this.onBeforeReset = types.isFn(f.on_before_reset) ?
|
2014-09-20 15:56:35 +02:00
|
|
|
f.on_before_reset : null;
|
|
|
|
//callback function after filters are cleared
|
2014-10-18 14:00:34 +02:00
|
|
|
this.onAfterReset = types.isFn(f.on_after_reset) ?
|
2014-10-12 13:40:08 +02:00
|
|
|
f.on_after_reset : null;
|
2014-09-20 15:56:35 +02:00
|
|
|
|
|
|
|
/*** paging ***/
|
|
|
|
//enables/disables table paging
|
|
|
|
this.paging = f.paging===true ? true : false;
|
|
|
|
//enables/disables results per page drop-down
|
|
|
|
this.hasResultsPerPage = f.results_per_page===true ? true : false;
|
|
|
|
//css class for paging buttons (previous,next,etc.)
|
|
|
|
this.btnPageCssClass = f.paging_btn_css_class || 'pgInp';
|
|
|
|
//stores paging select element
|
|
|
|
this.pagingSlc = null;
|
|
|
|
//stores results per page text and values
|
|
|
|
this.resultsPerPage = null;
|
|
|
|
//results per page select element
|
|
|
|
this.resultsPerPageSlc = null;
|
|
|
|
//indicates if paging elements were previously removed
|
|
|
|
this.isPagingRemoved = false;
|
|
|
|
this.nbVisibleRows = 0; //nb visible rows
|
|
|
|
this.nbHiddenRows = 0; //nb hidden rows
|
|
|
|
this.startPagingRow = 0; //1st row index of current page
|
|
|
|
this.nbPages = 0; //total nb of pages
|
|
|
|
this.currentPageNb = 1; //current page nb
|
|
|
|
|
|
|
|
/*** webfx sort adapter ***/
|
|
|
|
//enables/disables default table sorting
|
|
|
|
this.sort = f.sort===true ? true : false;
|
|
|
|
//indicates if sort is set (used in tfAdapter.sortabletable.js)
|
|
|
|
this.isSortEnabled = false;
|
|
|
|
//indicates if tables was sorted
|
|
|
|
this.sorted = false;
|
|
|
|
this.sortConfig = f.sort_config || {};
|
|
|
|
this.sortConfig.name = this.sortConfig['name']!==undefined ?
|
|
|
|
f.sort_config.name : 'sortabletable';
|
|
|
|
this.sortConfig.src = this.sortConfig['src']!==undefined ?
|
|
|
|
f.sort_config.src : this.basePath+'sortabletable.js';
|
|
|
|
this.sortConfig.adapterSrc =
|
|
|
|
this.sortConfig['adapter_src']!==undefined ?
|
|
|
|
f.sort_config.adapter_src :
|
|
|
|
this.basePath+'tfAdapter.sortabletable.js';
|
|
|
|
this.sortConfig.initialize =
|
|
|
|
this.sortConfig['initialize']!==undefined ?
|
|
|
|
f.sort_config.initialize :
|
|
|
|
function(o){
|
|
|
|
if(o.SetSortTable){ o.SetSortTable(); }
|
|
|
|
};
|
|
|
|
this.sortConfig.sortTypes =
|
2014-10-20 09:11:33 +02:00
|
|
|
types.isArray(this.sortConfig['sort_types']) ?
|
2014-09-20 15:56:35 +02:00
|
|
|
f.sort_config.sort_types : [];
|
|
|
|
this.sortConfig.sortCol = this.sortConfig['sort_col']!==undefined ?
|
|
|
|
f.sort_config.sort_col : null;
|
|
|
|
this.sortConfig.asyncSort =
|
|
|
|
this.sortConfig['async_sort']===true ? true : false;
|
|
|
|
this.sortConfig.triggerIds =
|
2014-10-20 09:11:33 +02:00
|
|
|
types.isArray(this.sortConfig['sort_trigger_ids']) ?
|
2014-09-20 15:56:35 +02:00
|
|
|
f.sort_config.sort_trigger_ids : [];
|
|
|
|
|
|
|
|
/*** ezEditTable extension ***/
|
|
|
|
//enables/disables table selection feature
|
|
|
|
this.selectable = f.selectable===true ? true : false;
|
|
|
|
//enables/disables editable table feature
|
|
|
|
this.editable = f.editable===true ? true : false;
|
|
|
|
this.ezEditTableConfig = f.ezEditTable_config || {};
|
|
|
|
this.ezEditTableConfig.name =
|
|
|
|
this.ezEditTableConfig['name']!==undefined ?
|
|
|
|
f.ezEditTable_config.name : 'ezedittable';
|
|
|
|
this.ezEditTableConfig.src = this.ezEditTableConfig['src']!==undefined ?
|
|
|
|
f.ezEditTable_config.src :
|
|
|
|
this.basePath+'ezEditTable/ezEditTable.js';
|
|
|
|
//ezEditTable stylesheet not imported by default as filtergrid.css
|
|
|
|
//applies
|
|
|
|
this.ezEditTableConfig.loadStylesheet =
|
|
|
|
this.ezEditTableConfig['loadStylesheet']===true ? true : false;
|
|
|
|
this.ezEditTableConfig.stylesheet =
|
|
|
|
this.ezEditTableConfig['stylesheet'] ||
|
|
|
|
this.basePath+'ezEditTable/ezEditTable.css';
|
|
|
|
this.ezEditTableConfig.stylesheetName =
|
|
|
|
this.ezEditTableConfig['stylesheetName']!==undefined ?
|
|
|
|
f.ezEditTable_config.stylesheetName : 'ezEditTableCss';
|
|
|
|
this.ezEditTableConfig.err = 'Failed to instantiate EditTable ' +
|
|
|
|
'object.\n"ezEditTable" module may not be available.';
|
|
|
|
|
|
|
|
/*** onkeyup event ***/
|
|
|
|
//enables/disables onkeyup event, table is filtered when user stops
|
|
|
|
//typing
|
|
|
|
this.onKeyUp = f.on_keyup===true ? true : false;
|
|
|
|
//onkeyup delay timer (msecs)
|
|
|
|
this.onKeyUpDelay = !isNaN(f.on_keyup_delay) ?
|
|
|
|
f.on_keyup_delay : 900;
|
|
|
|
this.isUserTyping = null; //typing indicator
|
|
|
|
this.onKeyUpTimer = undefined;
|
|
|
|
|
|
|
|
/*** keyword highlighting ***/
|
|
|
|
//enables/disables keyword highlighting
|
|
|
|
this.highlightKeywords = f.highlight_keywords===true ? true : false;
|
|
|
|
//defines css class for highlighting
|
|
|
|
this.highlightCssClass = f.highlight_css_class || 'keyword';
|
|
|
|
this.highlightedNodes = [];
|
|
|
|
|
|
|
|
/*** data types ***/
|
|
|
|
//defines default date type (european DMY)
|
|
|
|
this.defaultDateType = f.default_date_type || 'DMY';
|
|
|
|
//defines default thousands separator
|
|
|
|
//US = ',' EU = '.'
|
|
|
|
this.thousandsSeparator = f.thousands_separator || ',';
|
|
|
|
//defines default decimal separator
|
|
|
|
//US & javascript = '.' EU = ','
|
|
|
|
this.decimalSeparator = f.decimal_separator || '.';
|
|
|
|
//enables number format per column
|
|
|
|
this.hasColNbFormat = f.col_number_format===true ? true : false;
|
|
|
|
//array containing columns nb formats
|
2014-10-20 09:11:33 +02:00
|
|
|
this.colNbFormat = types.isArray(this.hasColNbFormat) ?
|
2014-09-20 15:56:35 +02:00
|
|
|
f.col_number_format : null;
|
|
|
|
//enables date type per column
|
|
|
|
this.hasColDateType = f.col_date_type===true ? true : false;
|
|
|
|
//array containing columns date type
|
2014-10-20 09:11:33 +02:00
|
|
|
this.colDateType = types.isArray(this.hasColDateType) ?
|
2014-09-20 15:56:35 +02:00
|
|
|
f.col_date_type : null;
|
|
|
|
|
|
|
|
/*** status messages ***/
|
|
|
|
//filtering
|
|
|
|
this.msgFilter = f.msg_filter || 'Filtering data...';
|
|
|
|
//populating drop-downs
|
|
|
|
this.msgPopulate = f.msg_populate || 'Populating filter...';
|
|
|
|
//populating drop-downs
|
|
|
|
this.msgPopulateCheckList = f.msg_populate_checklist ||
|
|
|
|
'Populating list...';
|
|
|
|
//changing paging page
|
|
|
|
this.msgChangePage = f.msg_change_page || 'Collecting paging data...';
|
|
|
|
//clearing filters
|
|
|
|
this.msgClear = f.msg_clear || 'Clearing filters...';
|
|
|
|
//changing nb results/page
|
|
|
|
this.msgChangeResults = f.msg_change_results ||
|
|
|
|
'Changing results per page...';
|
|
|
|
//re-setting grid values
|
|
|
|
this.msgResetValues = f.msg_reset_grid_values ||
|
|
|
|
'Re-setting filters values...';
|
|
|
|
//re-setting page
|
|
|
|
this.msgResetPage = f.msg_reset_page || 'Re-setting page...';
|
|
|
|
//re-setting page length
|
|
|
|
this.msgResetPageLength = f.msg_reset_page_length ||
|
|
|
|
'Re-setting page length...';
|
|
|
|
//table sorting
|
|
|
|
this.msgSort = f.msg_sort || 'Sorting data...';
|
|
|
|
//extensions loading
|
|
|
|
this.msgLoadExtensions = f.msg_load_extensions ||
|
|
|
|
'Loading extensions...';
|
|
|
|
//themes loading
|
|
|
|
this.msgLoadThemes = f.msg_load_themes || 'Loading theme(s)...';
|
|
|
|
|
|
|
|
/*** ids prefixes ***/
|
|
|
|
//css class name added to table
|
|
|
|
this.prfxTf = 'TF';
|
|
|
|
//filters (inputs - selects)
|
|
|
|
this.prfxFlt = 'flt';
|
|
|
|
//validation button
|
|
|
|
this.prfxValButton = 'btn';
|
|
|
|
//container div for paging elements, rows counter etc.
|
|
|
|
this.prfxInfDiv = 'inf_';
|
|
|
|
//left div
|
|
|
|
this.prfxLDiv = 'ldiv_';
|
|
|
|
//right div
|
|
|
|
this.prfxRDiv = 'rdiv_';
|
|
|
|
//middle div
|
|
|
|
this.prfxMDiv = 'mdiv_';
|
|
|
|
//table container if fixed headers enabled
|
|
|
|
this.prfxContentDiv = 'cont_';
|
|
|
|
//checklist filter container div
|
|
|
|
this.prfxCheckListDiv = 'chkdiv_';
|
|
|
|
//pages select
|
|
|
|
this.prfxSlcPages = 'slcPages_';
|
|
|
|
//results per page select
|
|
|
|
this.prfxSlcResults = 'slcResults_';
|
|
|
|
//label preciding results per page select
|
|
|
|
this.prfxSlcResultsTxt = 'slcResultsTxt_';
|
|
|
|
//span containing next page button
|
|
|
|
this.prfxBtnNextSpan = 'btnNextSpan_';
|
|
|
|
//span containing previous page button
|
|
|
|
this.prfxBtnPrevSpan = 'btnPrevSpan_';
|
|
|
|
//span containing last page button
|
|
|
|
this.prfxBtnLastSpan = 'btnLastSpan_';
|
|
|
|
//span containing first page button
|
|
|
|
this.prfxBtnFirstSpan = 'btnFirstSpan_';
|
|
|
|
//next button
|
|
|
|
this.prfxBtnNext = 'btnNext_';
|
|
|
|
//previous button
|
|
|
|
this.prfxBtnPrev = 'btnPrev_';
|
|
|
|
//last button
|
|
|
|
this.prfxBtnLast = 'btnLast_';
|
|
|
|
//first button
|
|
|
|
this.prfxBtnFirst = 'btnFirst_';
|
|
|
|
//span for tot nb pages
|
|
|
|
this.prfxPgSpan = 'pgspan_';
|
|
|
|
//span preceding pages select (contains 'Page')
|
|
|
|
this.prfxPgBeforeSpan = 'pgbeforespan_';
|
|
|
|
//span following pages select (contains ' of ')
|
|
|
|
this.prfxPgAfterSpan = 'pgafterspan_';
|
|
|
|
//rows counter div
|
|
|
|
this.prfxCounter = 'counter_';
|
|
|
|
//nb displayed rows label
|
|
|
|
this.prfxTotRows = 'totrows_span_';
|
|
|
|
//label preceding nb rows label
|
|
|
|
this.prfxTotRowsTxt = 'totRowsTextSpan_';
|
|
|
|
//span containing reset button
|
|
|
|
this.prfxResetSpan = 'resetspan_';
|
|
|
|
//loader div
|
|
|
|
this.prfxLoader = 'load_';
|
|
|
|
//status bar div
|
|
|
|
this.prfxStatus = 'status_';
|
|
|
|
//status bar label
|
|
|
|
this.prfxStatusSpan = 'statusSpan_';
|
|
|
|
//text preceding status bar label
|
|
|
|
this.prfxStatusTxt = 'statusText_';
|
|
|
|
//filter values cookie
|
|
|
|
this.prfxCookieFltsValues = 'tf_flts_';
|
|
|
|
//page nb cookie
|
|
|
|
this.prfxCookiePageNb = 'tf_pgnb_';
|
|
|
|
//page length cookie
|
|
|
|
this.prfxCookiePageLen = 'tf_pglen_';
|
|
|
|
//div containing grid elements if grid_layout true
|
|
|
|
this.prfxMainTblCont = 'gridCont_';
|
|
|
|
//div containing table if grid_layout true
|
|
|
|
this.prfxTblCont = 'tblCont_';
|
|
|
|
//div containing headers table if grid_layout true
|
|
|
|
this.prfxHeadTblCont = 'tblHeadCont_';
|
|
|
|
//headers' table if grid_layout true
|
|
|
|
this.prfxHeadTbl = 'tblHead_';
|
|
|
|
//id of td containing the filter if grid_layout true
|
|
|
|
this.prfxGridFltTd = '_td_';
|
|
|
|
//id of th containing column header if grid_layout true
|
|
|
|
this.prfxGridTh = 'tblHeadTh_';
|
|
|
|
//id prefix for help elements
|
|
|
|
this.prfxHelpSpan = 'helpSpan_';
|
|
|
|
//id prefix for help elements
|
|
|
|
this.prfxHelpDiv = 'helpDiv_';
|
|
|
|
//id prefix for pop-up filter span
|
|
|
|
this.prfxPopUpSpan = 'popUpSpan_';
|
|
|
|
//id prefix for pop-up div containing filter
|
|
|
|
this.prfxPopUpDiv = 'popUpDiv_';
|
|
|
|
|
|
|
|
/*** cookies ***/
|
|
|
|
this.hasStoredValues = false;
|
|
|
|
//remembers filters values on page load
|
|
|
|
this.rememberGridValues = f.remember_grid_values===true ?
|
|
|
|
true : false;
|
|
|
|
//cookie storing filter values
|
|
|
|
this.fltsValuesCookie = this.prfxCookieFltsValues + this.id;
|
|
|
|
//remembers page nb on page load
|
|
|
|
this.rememberPageNb = this.paging && f.remember_page_number ?
|
|
|
|
true : false;
|
|
|
|
//cookie storing page nb
|
|
|
|
this.pgNbCookie = this.prfxCookiePageNb + this.id;
|
|
|
|
//remembers page length on page load
|
|
|
|
this.rememberPageLen = this.paging && f.remember_page_length ?
|
|
|
|
true : false;
|
|
|
|
//cookie storing page length
|
|
|
|
this.pgLenCookie = this.prfxCookiePageLen + this.id;
|
|
|
|
//cookie duration
|
|
|
|
this.cookieDuration = !isNaN(f.set_cookie_duration) ?
|
|
|
|
parseInt(f.set_cookie_duration, 10) :100000;
|
|
|
|
|
|
|
|
/*** extensions ***/
|
|
|
|
//imports external script
|
|
|
|
this.hasExtensions = f.extensions===true ? true : false;
|
|
|
|
this.extensions = this.hasExtensions ? f.extensions : null;
|
|
|
|
|
|
|
|
/*** themes ***/
|
|
|
|
this.enableDefaultTheme = f.enable_default_theme===true ?
|
|
|
|
true : false;
|
|
|
|
//imports themes
|
|
|
|
this.hasThemes = (f.enable_default_theme ||
|
2014-10-18 14:00:34 +02:00
|
|
|
(f.themes && types.isObj(f.themes))) ? true : false;
|
2014-09-20 15:56:35 +02:00
|
|
|
this.themes = this.hasThemes ? f.themes : null;
|
|
|
|
//themes path
|
|
|
|
this.themesPath = f.themes_path || this.basePath+'TF_Themes/';
|
|
|
|
|
2014-11-01 15:34:37 +01:00
|
|
|
// Components
|
2014-11-09 09:31:15 +01:00
|
|
|
this.Cpt = {
|
|
|
|
loader: null,
|
|
|
|
alternateRows: null
|
|
|
|
};
|
2014-11-01 15:34:37 +01:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
/*** TF events ***/
|
|
|
|
var o = 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'
|
|
|
|
},
|
2014-09-28 10:59:14 +02:00
|
|
|
getKeyCode: function(evt){
|
|
|
|
return evt.charCode ? evt.charCode :
|
2014-09-20 15:56:35 +02:00
|
|
|
(evt.keyCode ? evt.keyCode: (evt.which ? evt.which : 0));
|
|
|
|
},
|
|
|
|
/*====================================================
|
|
|
|
- Detects <enter> key for a given element
|
|
|
|
=====================================================*/
|
|
|
|
_DetectKey: function(e) {
|
|
|
|
if(!o.enterKey){ return; }
|
2014-10-18 14:00:34 +02:00
|
|
|
var _evt = e || global.event;
|
|
|
|
if(_evt){
|
|
|
|
var key = o.Evt.getKeyCode(_evt);
|
2014-09-20 15:56:35 +02:00
|
|
|
if(key===13){
|
|
|
|
o._Filter();
|
2014-10-18 14:00:34 +02:00
|
|
|
evt.cancel(_evt);
|
|
|
|
evt.stop(_evt);
|
2014-09-20 10:09:23 +02:00
|
|
|
} else {
|
2014-09-20 15:56:35 +02:00
|
|
|
o.isUserTyping = true;
|
2014-10-18 14:00:34 +02:00
|
|
|
global.clearInterval(o.onKeyUpTimer);
|
2014-09-20 10:09:23 +02:00
|
|
|
o.onKeyUpTimer = undefined;
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}//if evt
|
|
|
|
},
|
|
|
|
/*====================================================
|
|
|
|
- onkeyup event for text filters
|
|
|
|
=====================================================*/
|
|
|
|
_OnKeyUp: function(e) {
|
|
|
|
if(!o.onKeyUp) return;
|
2014-10-18 14:00:34 +02:00
|
|
|
var _evt = e || global.event;
|
|
|
|
var key = o.Evt.getKeyCode(_evt);
|
2014-09-20 15:56:35 +02:00
|
|
|
o.isUserTyping = false;
|
|
|
|
|
|
|
|
function filter() {
|
2014-10-18 14:00:34 +02:00
|
|
|
global.clearInterval(o.onKeyUpTimer);
|
2014-09-20 15:56:35 +02:00
|
|
|
o.onKeyUpTimer = undefined;
|
2014-10-18 14:00:34 +02:00
|
|
|
if(!o.isUserTyping){
|
2014-09-20 15:56:35 +02:00
|
|
|
o.Filter();
|
|
|
|
o.isUserTyping = null;
|
2014-09-20 10:09:23 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(key!==13 && key!==9 && key!==27 && key!==38 && key!==40) {
|
|
|
|
if(o.onKeyUpTimer===undefined){
|
2014-10-18 14:00:34 +02:00
|
|
|
o.onKeyUpTimer = global.setInterval(filter, o.onKeyUpDelay);
|
2014-09-20 10:09:23 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
} else {
|
2014-10-18 14:00:34 +02:00
|
|
|
global.clearInterval(o.onKeyUpTimer);
|
2014-09-20 15:56:35 +02:00
|
|
|
o.onKeyUpTimer = undefined;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
/*====================================================
|
|
|
|
- onkeydown event for input filters
|
|
|
|
=====================================================*/
|
|
|
|
_OnKeyDown: function(e) {
|
|
|
|
if(!o.onKeyUp) { return; }
|
|
|
|
o.isUserTyping = true;
|
|
|
|
},
|
|
|
|
/*====================================================
|
|
|
|
- onblur event for input filters
|
|
|
|
=====================================================*/
|
|
|
|
_OnInpBlur: function(e) {
|
|
|
|
if(o.onKeyUp){
|
|
|
|
o.isUserTyping = false;
|
2014-10-18 14:00:34 +02:00
|
|
|
global.clearInterval(o.onKeyUpTimer);
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
|
|
|
//Watermark
|
|
|
|
if(this.value === '' && o.inpWatermark !== ''){
|
|
|
|
this.value = (o.isInpWatermarkArray) ?
|
|
|
|
o.inpWatermark[this.getAttribute('ct')] :
|
|
|
|
o.inpWatermark;
|
2014-10-18 14:00:34 +02:00
|
|
|
dom.addClass(this, o.inpWatermarkCssClass);
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
|
|
|
if(o.ezEditTable){
|
|
|
|
if(o.editable) o.ezEditTable.Editable.Set();
|
|
|
|
if(o.selectable) o.ezEditTable.Selection.Set();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
/*====================================================
|
|
|
|
- onfocus event for input filters
|
|
|
|
=====================================================*/
|
|
|
|
_OnInpFocus: function(e) {
|
2014-10-18 14:00:34 +02:00
|
|
|
var _evt = e || global.event;
|
2014-09-20 15:56:35 +02:00
|
|
|
o.activeFilterId = this.getAttribute('id');
|
2014-11-01 15:34:37 +01:00
|
|
|
o.activeFlt = dom.id(o.activeFilterId);
|
2014-09-20 15:56:35 +02:00
|
|
|
//Watermark
|
|
|
|
if(!o.isInpWatermarkArray){
|
|
|
|
if(this.value === o.inpWatermark &&
|
|
|
|
o.inpWatermark !== ''){
|
|
|
|
this.value = '';
|
2014-10-18 14:00:34 +02:00
|
|
|
dom.removeClass(this, o.inpWatermarkCssClass);
|
2014-09-20 10:09:23 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
} else {
|
|
|
|
var inpWatermark = o.inpWatermark[this.getAttribute('ct')];
|
|
|
|
if(this.value === inpWatermark && inpWatermark !== ''){
|
|
|
|
this.value = '';
|
2014-10-18 14:00:34 +02:00
|
|
|
dom.removeClass(this, o.inpWatermarkCssClass);
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
2014-09-20 10:09:23 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
if(o.popUpFilters){
|
2014-10-18 14:00:34 +02:00
|
|
|
evt.cancel(_evt);
|
|
|
|
evt.stop(_evt);
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
|
|
|
if(o.ezEditTable){
|
|
|
|
if(o.editable) o.ezEditTable.Editable.Remove();
|
|
|
|
if(o.selectable) o.ezEditTable.Selection.Remove();
|
|
|
|
}
|
|
|
|
},
|
2014-09-07 12:07:28 +02:00
|
|
|
/*====================================================
|
2014-09-20 15:56:35 +02:00
|
|
|
- onfocus event for select filters
|
2014-09-07 12:07:28 +02:00
|
|
|
=====================================================*/
|
2014-09-20 15:56:35 +02:00
|
|
|
_OnSlcFocus: function(e) {
|
2014-10-18 14:00:34 +02:00
|
|
|
var _evt = e || global.event;
|
2014-09-20 15:56:35 +02:00
|
|
|
o.activeFilterId = this.getAttribute('id');
|
2014-11-01 15:34:37 +01:00
|
|
|
o.activeFlt = dom.id(o.activeFilterId);
|
2014-10-26 02:42:34 +01:00
|
|
|
// select is populated when element has focus
|
|
|
|
if(o.fillSlcOnDemand && this.getAttribute('filled') === '0'){
|
2014-09-20 15:56:35 +02:00
|
|
|
var ct = this.getAttribute('ct');
|
|
|
|
o.PopulateSelect(ct);
|
2014-11-01 15:34:37 +01:00
|
|
|
if(!hlp.isIE()){ this.setAttribute('filled','1'); }
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
|
|
|
if(o.popUpFilters){
|
2014-10-18 14:00:34 +02:00
|
|
|
evt.cancel(_evt);
|
|
|
|
evt.stop(_evt);
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
/*====================================================
|
|
|
|
- onchange event for select filters
|
|
|
|
=====================================================*/
|
|
|
|
_OnSlcChange: function(e) {
|
|
|
|
var colIndex = o.activeFlt.getAttribute('colIndex');
|
|
|
|
//Checks filter is a checklist and caller is not null
|
|
|
|
if(o.activeFlt && colIndex &&
|
|
|
|
o['col'+colIndex]===o.fltTypeCheckList &&
|
|
|
|
!o.Evt._OnSlcChange.caller){ return; }
|
2014-10-18 14:00:34 +02:00
|
|
|
var _evt = e || global.event;
|
|
|
|
if(o.popUpFilters){ evt.stop(_evt); }
|
2014-09-20 15:56:35 +02:00
|
|
|
if(o.onSlcChange){ o.Filter(); }
|
|
|
|
},
|
|
|
|
/*====================================================
|
|
|
|
- onblur event for select filters
|
|
|
|
=====================================================*/
|
|
|
|
_OnSlcBlur: function(e) {},
|
|
|
|
/*====================================================
|
|
|
|
- onchange event for checklist filters
|
|
|
|
=====================================================*/
|
|
|
|
_OnCheckListChange: function(e) {
|
|
|
|
//Checks caller is not null
|
|
|
|
if(!o.Evt._OnCheckListChange.caller){ return; }
|
|
|
|
o.Evt._OnSlcChange(e);
|
|
|
|
},
|
|
|
|
/*====================================================
|
|
|
|
- onclick event for checklist filters
|
|
|
|
=====================================================*/
|
|
|
|
_OnCheckListClick: function() {
|
2014-10-18 14:00:34 +02:00
|
|
|
if(o.fillSlcOnDemand && this.getAttribute('filled') === '0'){
|
2014-09-20 15:56:35 +02:00
|
|
|
var ct = this.getAttribute('ct');
|
|
|
|
o.PopulateCheckList(ct);
|
|
|
|
o.checkListDiv[ct].onclick = null;
|
|
|
|
o.checkListDiv[ct].title = '';
|
|
|
|
}
|
|
|
|
},
|
|
|
|
/*====================================================
|
|
|
|
- onclick event for checklist filter container
|
|
|
|
=====================================================*/
|
|
|
|
_OnCheckListFocus: function(e) {
|
|
|
|
o.activeFilterId = this.firstChild.getAttribute('id');
|
2014-11-01 15:34:37 +01:00
|
|
|
o.activeFlt = dom.id(o.activeFilterId);
|
2014-09-20 15:56:35 +02:00
|
|
|
},
|
|
|
|
_OnCheckListBlur: function(e){},
|
|
|
|
/*====================================================
|
|
|
|
- onclick event for validation button
|
|
|
|
(btn property)
|
|
|
|
=====================================================*/
|
|
|
|
_OnBtnClick: function() {
|
|
|
|
o.Filter();
|
|
|
|
},
|
|
|
|
_OnSlcPagesChangeEvt: null, //used by sort adapter
|
|
|
|
/*====================================================
|
|
|
|
- onclick event slc parent node (enables filters)
|
|
|
|
IE only
|
|
|
|
=====================================================*/
|
|
|
|
_EnableSlc: function() {
|
|
|
|
this.firstChild.disabled = false;
|
|
|
|
this.firstChild.focus();
|
|
|
|
this.onclick = null;
|
|
|
|
},
|
|
|
|
/*====================================================
|
|
|
|
- clears filters
|
|
|
|
=====================================================*/
|
|
|
|
_Clear: function() {
|
|
|
|
o.ClearFilters();
|
|
|
|
},
|
|
|
|
/*====================================================
|
|
|
|
- Help button onclick event
|
|
|
|
=====================================================*/
|
|
|
|
_OnHelpBtnClick: function() {
|
|
|
|
o._ToggleHelp();
|
|
|
|
},
|
|
|
|
_Paging: { //used by sort adapter
|
|
|
|
nextEvt: null,
|
|
|
|
prevEvt: null,
|
|
|
|
lastEvt: null,
|
|
|
|
firstEvt: null
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-10-18 14:00:34 +02:00
|
|
|
TableFilter.prototype = {
|
2014-09-20 15:56:35 +02:00
|
|
|
/*====================================================
|
|
|
|
- adds row with filtering grid bar and sets grid
|
|
|
|
behaviours and layout
|
|
|
|
=====================================================*/
|
2014-10-26 11:48:13 +01:00
|
|
|
init: function(){
|
2014-09-20 15:56:35 +02:00
|
|
|
if(this.hasGrid) return;
|
|
|
|
if(this.gridLayout){
|
|
|
|
this.refRow = this.startRow===null ? 0 : this.startRow;
|
|
|
|
}
|
|
|
|
if(this.popUpFilters &&
|
|
|
|
((this.filtersRowIndex === 0 && this.headersRow === 1) ||
|
|
|
|
this.gridLayout)){
|
|
|
|
this.headersRow = 0;
|
|
|
|
}
|
|
|
|
var f = this.fObj || {},
|
|
|
|
n = this.singleSearchFlt ? 1 : this.nbCells,
|
|
|
|
inpclass;
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
if(window['tf_'+this.id] === undefined){
|
|
|
|
window['tf_'+this.id] = this;
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
//loads stylesheet if not imported
|
|
|
|
//Issues with browsers != IE, IE rules in this case
|
|
|
|
this.IncludeFile(this.stylesheetId, this.stylesheet, null, 'link');
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
//loads theme
|
|
|
|
if(this.hasThemes){ this._LoadThemes(); }
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
if(this.gridLayout){
|
|
|
|
this.isExternalFlt = true;
|
|
|
|
this.SetGridLayout();
|
|
|
|
//Once grid generated 1st filterable row is 0 again
|
2014-11-01 15:34:37 +01:00
|
|
|
this.refRow = hlp.isIE() ? (this.refRow+1) : 0;
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-10-27 08:01:33 +01:00
|
|
|
if(this.loader){
|
|
|
|
var Loader = require('modules/loader');
|
2014-11-09 09:31:15 +01:00
|
|
|
this.Cpt.loader = new Loader(this);
|
2014-10-27 08:01:33 +01:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
|
|
|
|
if(this.popUpFilters){
|
|
|
|
if(!this.isFirstLoad && !this.gridLayout){
|
|
|
|
this.headersRow--;
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
this.SetPopupFilterIcons();
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
if(this.hasResultsPerPage){
|
|
|
|
this.resultsPerPage = f['results_per_page'] || this.resultsPerPage;
|
|
|
|
if(this.resultsPerPage.length<2){
|
|
|
|
this.hasResultsPerPage = false;
|
2014-09-07 12:07:28 +02:00
|
|
|
} else {
|
2014-09-20 15:56:35 +02:00
|
|
|
this.pagingLength = this.resultsPerPage[1][0];
|
|
|
|
}
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
//filters grid is not generated
|
|
|
|
if(!this.fltGrid){
|
|
|
|
this.refRow = this.refRow-1;
|
|
|
|
if(this.gridLayout){
|
|
|
|
this.refRow = 0;
|
|
|
|
}
|
|
|
|
this.nbFilterableRows = this.GetRowsNb();
|
|
|
|
this.nbVisibleRows = this.nbFilterableRows;
|
|
|
|
this.nbRows = this.nbFilterableRows + this.refRow;
|
|
|
|
} else {
|
|
|
|
if(this.isFirstLoad){
|
|
|
|
var fltrow;
|
|
|
|
if(!this.gridLayout){
|
2014-11-01 15:34:37 +01:00
|
|
|
var thead = dom.tag(this.tbl,'thead');
|
2014-09-20 15:56:35 +02:00
|
|
|
if(thead.length > 0){
|
|
|
|
fltrow = thead[0].insertRow(this.filtersRowIndex);
|
|
|
|
} else {
|
|
|
|
fltrow = this.tbl.insertRow(this.filtersRowIndex);
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
if(this.headersRow > 1 &&
|
|
|
|
this.filtersRowIndex <= this.headersRow &&
|
|
|
|
!this.popUpFilters){
|
|
|
|
this.headersRow++;
|
|
|
|
}
|
|
|
|
if(this.popUpFilters){
|
|
|
|
this.headersRow++;
|
|
|
|
}
|
|
|
|
if(this.fixedHeaders){
|
|
|
|
this.SetFixedHeaders();
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
fltrow.className = this.fltsRowCssClass;
|
|
|
|
//Disable for grid_layout
|
|
|
|
if(this.isExternalFlt &&
|
|
|
|
(!this.gridLayout || this.popUpFilters)){
|
|
|
|
fltrow.style.display = 'none';
|
|
|
|
}
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
this.nbFilterableRows = this.GetRowsNb();
|
|
|
|
this.nbVisibleRows = this.nbFilterableRows;
|
|
|
|
this.nbRows = this.tbl.rows.length;
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
for(var i=0; i<n; i++){// this loop adds filters
|
2014-10-18 14:00:34 +02:00
|
|
|
var fltcell = dom.create(this.fltCellTag),
|
2014-09-20 15:56:35 +02:00
|
|
|
col = this['col'+i],
|
|
|
|
externalFltTgtId =
|
|
|
|
this.isExternalFlt && this.externalFltTgtIds ?
|
|
|
|
this.externalFltTgtIds[i] : null;
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
if(this.singleSearchFlt){
|
|
|
|
fltcell.colSpan = this.nbCells;
|
|
|
|
}
|
|
|
|
if(!this.gridLayout){
|
|
|
|
fltrow.appendChild(fltcell);
|
|
|
|
}
|
|
|
|
inpclass = (i==n-1 && this.displayBtn) ?
|
|
|
|
this.fltSmallCssClass : this.fltCssClass;
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
if(this.popUpFilters){
|
|
|
|
this.SetPopupFilter(i);
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
if(col===undefined){
|
|
|
|
col = f['col_'+i]===undefined ?
|
2014-10-18 14:00:34 +02:00
|
|
|
this.fltTypeInp : str.lower(f['col_'+i]);
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
//only 1 input for single search
|
|
|
|
if(this.singleSearchFlt){
|
|
|
|
col = this.fltTypeInp;
|
|
|
|
inpclass = this.singleFltCssClass;
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
//selects
|
|
|
|
if(col===this.fltTypeSlc ||
|
|
|
|
col===this.fltTypeMulti){
|
2014-10-18 14:00:34 +02:00
|
|
|
var slc = dom.create(this.fltTypeSlc,
|
2014-09-20 15:56:35 +02:00
|
|
|
['id',this.prfxFlt+i+'_'+this.id],
|
|
|
|
['ct',i], ['filled','0']);
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
if(col===this.fltTypeMulti){
|
|
|
|
slc.multiple = this.fltTypeMulti;
|
|
|
|
slc.title = this.multipleSlcTooltip;
|
|
|
|
}
|
2014-10-18 14:00:34 +02:00
|
|
|
slc.className = str.lower(col)===this.fltTypeSlc ?
|
2014-09-20 15:56:35 +02:00
|
|
|
inpclass : this.fltMultiCssClass;// for ie<=6
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
//filter is appended in desired element
|
|
|
|
if(externalFltTgtId){
|
2014-11-01 15:34:37 +01:00
|
|
|
dom.id(externalFltTgtId).appendChild(slc);
|
2014-09-20 15:56:35 +02:00
|
|
|
this.externalFltEls.push(slc);
|
|
|
|
} else {
|
|
|
|
fltcell.appendChild(slc);
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
this.fltIds.push(this.prfxFlt+i+'_'+this.id);
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
if(!this.fillSlcOnDemand){
|
|
|
|
this._PopulateSelect(i);
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
slc.onkeypress = this.Evt._DetectKey;
|
|
|
|
slc.onchange = this.Evt._OnSlcChange;
|
|
|
|
slc.onfocus = this.Evt._OnSlcFocus;
|
|
|
|
slc.onblur = this.Evt._OnSlcBlur;
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
//1st option is created here since PopulateSelect isn't
|
|
|
|
//invoked
|
|
|
|
if(this.fillSlcOnDemand){
|
2014-10-18 14:00:34 +02:00
|
|
|
var opt0 = dom.createOpt(this.displayAllText,'');
|
2014-09-20 15:56:35 +02:00
|
|
|
slc.appendChild(opt0);
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
/* Code below for IE: it prevents select options to
|
|
|
|
slide out before select it-self is populated.
|
|
|
|
This is an unexpeted behavior for users since at
|
|
|
|
1st click options are empty. Work around:
|
|
|
|
select is disabled and by clicking on element
|
|
|
|
(parent td), users enable drop-down and select is
|
|
|
|
populated at same time. */
|
2014-11-01 15:34:37 +01:00
|
|
|
if(this.fillSlcOnDemand && hlp.isIE()){
|
2014-09-20 15:56:35 +02:00
|
|
|
slc.disabled = true;
|
|
|
|
slc.title = this.activateSlcTooltip;
|
|
|
|
slc.parentNode.onclick = this.Evt._EnableSlc;
|
|
|
|
if(col===this.fltTypeMulti){
|
|
|
|
this.__deferMultipleSelection(slc,0);
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// checklist
|
|
|
|
else if(col===this.fltTypeCheckList){
|
2014-10-18 14:00:34 +02:00
|
|
|
var divCont = dom.create('div',
|
2014-09-20 15:56:35 +02:00
|
|
|
['id',this.prfxCheckListDiv+i+'_'+this.id],
|
|
|
|
['ct',i],['filled','0']);
|
|
|
|
divCont.className = this.checkListDivCssClass;
|
|
|
|
|
|
|
|
//filter is appended in desired element
|
|
|
|
if(externalFltTgtId){
|
2014-11-01 15:34:37 +01:00
|
|
|
dom.id(externalFltTgtId).appendChild(divCont);
|
2014-09-20 15:56:35 +02:00
|
|
|
this.externalFltEls.push(divCont);
|
|
|
|
} else {
|
|
|
|
fltcell.appendChild(divCont);
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
this.checkListDiv[i] = divCont;
|
|
|
|
this.fltIds.push(this.prfxFlt+i+'_'+this.id);
|
|
|
|
if(!this.fillSlcOnDemand){
|
|
|
|
this._PopulateCheckList(i);
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
divCont.onclick = this.Evt._OnCheckListFocus;
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
if(this.fillSlcOnDemand){
|
|
|
|
divCont.onclick = this.Evt._OnCheckListClick;
|
|
|
|
divCont.appendChild(
|
2014-10-18 14:00:34 +02:00
|
|
|
dom.text(this.activateCheckListTxt));
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
else{
|
|
|
|
//show/hide input
|
|
|
|
var inptype = col===this.fltTypeInp ? 'text' : 'hidden';
|
2014-10-18 14:00:34 +02:00
|
|
|
var inp = dom.create(this.fltTypeInp,
|
2014-09-20 15:56:35 +02:00
|
|
|
['id',this.prfxFlt+i+'_'+this.id],
|
|
|
|
['type',inptype],['ct',i]);
|
|
|
|
if(inptype!='hidden'){
|
|
|
|
inp.value = (this.isInpWatermarkArray) ?
|
|
|
|
this.inpWatermark[i] : this.inpWatermark;
|
|
|
|
}
|
|
|
|
inp.className = inpclass;// for ie<=6
|
|
|
|
if(this.inpWatermark!==''){
|
|
|
|
//watermark css class
|
2014-10-18 14:00:34 +02:00
|
|
|
dom.addClass(inp, this.inpWatermarkCssClass);
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
|
|
|
inp.onfocus = this.Evt._OnInpFocus;
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
//filter is appended in desired element
|
|
|
|
if(externalFltTgtId){
|
2014-11-01 15:34:37 +01:00
|
|
|
dom.id(externalFltTgtId).appendChild(inp);
|
2014-09-20 15:56:35 +02:00
|
|
|
this.externalFltEls.push(inp);
|
|
|
|
} else {
|
|
|
|
fltcell.appendChild(inp);
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
this.fltIds.push(this.prfxFlt+i+'_'+this.id);
|
|
|
|
|
|
|
|
inp.onkeypress = this.Evt._DetectKey;
|
|
|
|
inp.onkeydown = this.Evt._OnKeyDown;
|
|
|
|
inp.onkeyup = this.Evt._OnKeyUp;
|
|
|
|
inp.onblur = this.Evt._OnInpBlur;
|
|
|
|
|
|
|
|
if(this.rememberGridValues){
|
|
|
|
//reads the cookie
|
2014-10-18 14:00:34 +02:00
|
|
|
var flts = cookie.read(this.fltsValuesCookie);
|
2014-09-20 15:56:35 +02:00
|
|
|
var reg = new RegExp(this.separator,'g');
|
|
|
|
//creates an array with filters' values
|
|
|
|
var flts_values = flts.split(reg);
|
|
|
|
if(flts_values[i]!=' '){
|
|
|
|
this.SetFilterValue(i,flts_values[i],false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// this adds submit button
|
|
|
|
if(i==n-1 && this.displayBtn){
|
2014-10-18 14:00:34 +02:00
|
|
|
var btn = dom.create(this.fltTypeInp,
|
2014-09-20 15:56:35 +02:00
|
|
|
['id',this.prfxValButton+i+'_'+this.id],
|
|
|
|
['type','button'], ['value',this.btnText]);
|
|
|
|
btn.className = this.btnCssClass;
|
|
|
|
|
|
|
|
//filter is appended in desired element
|
|
|
|
if(externalFltTgtId){
|
2014-11-01 15:34:37 +01:00
|
|
|
dom.id(externalFltTgtId).appendChild(btn);
|
2014-09-20 15:56:35 +02:00
|
|
|
} else{
|
|
|
|
fltcell.appendChild(btn);
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
btn.onclick = this.Evt._OnBtnClick;
|
|
|
|
}//if
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
}// for i
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
} else {
|
|
|
|
this.__resetGrid();
|
|
|
|
}//if isFirstLoad
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
}//if this.fltGrid
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
/* Filter behaviours */
|
|
|
|
if(this.rowsCounter){
|
|
|
|
this.SetRowsCounter();
|
|
|
|
}
|
|
|
|
if(this.statusBar){
|
|
|
|
this.SetStatusBar();
|
|
|
|
}
|
|
|
|
if(this.fixedHeaders && !this.isFirstLoad){
|
|
|
|
this.SetFixedHeaders();
|
|
|
|
}
|
|
|
|
if(this.paging){
|
|
|
|
this.SetPaging();
|
|
|
|
}
|
|
|
|
if(this.hasResultsPerPage && this.paging){
|
|
|
|
this.SetResultsPerPage();
|
|
|
|
}
|
|
|
|
if(this.btnReset){
|
|
|
|
this.SetResetBtn();
|
|
|
|
}
|
|
|
|
if(this.helpInstructions){
|
|
|
|
this.SetHelpInstructions();
|
|
|
|
}
|
|
|
|
if(this.hasColWidth && !this.gridLayout){
|
|
|
|
this.SetColWidths();
|
|
|
|
}
|
|
|
|
if(this.alternateBgs && this.isStartBgAlternate){
|
|
|
|
//1st time only if no paging and rememberGridValues
|
2014-11-09 09:31:15 +01:00
|
|
|
var AlternateRows = require('modules/alternateRows');
|
|
|
|
this.Cpt.alternateRows = new AlternateRows(this);
|
|
|
|
this.Cpt.alternateRows.set();
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
|
|
|
if(this.hasColOperation && this.fltGrid){
|
|
|
|
this.colOperation = f.col_operation;
|
|
|
|
this.SetColOperation();
|
|
|
|
}
|
|
|
|
if(this.sort || this.gridLayout){
|
|
|
|
this.SetSort();
|
|
|
|
}
|
|
|
|
if(this.selectable || this.editable){
|
|
|
|
this.SetEditable();
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
this.isFirstLoad = false;
|
|
|
|
this.hasGrid = true;
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
if(this.rememberGridValues || this.rememberPageLen ||
|
|
|
|
this.rememberPageNb){
|
|
|
|
this.ResetValues();
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
//TF css class is added to table
|
|
|
|
if(!this.gridLayout){
|
2014-10-18 14:00:34 +02:00
|
|
|
dom.addClass(this.tbl, this.prfxTf);
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
if(this.loader){
|
2014-11-09 09:31:15 +01:00
|
|
|
this.Cpt.loader.show('none');
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
/* Loads extensions */
|
|
|
|
if(this.hasExtensions){
|
|
|
|
this.LoadExtensions();
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
if(this.onFiltersLoaded){
|
|
|
|
this.onFiltersLoaded.call(null,this);
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
},// AddGrid
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
/*====================================================
|
|
|
|
- TF events manager
|
|
|
|
- Params:
|
|
|
|
- event name (string)
|
|
|
|
- config object (optional literal object)
|
|
|
|
=====================================================*/
|
|
|
|
EvtManager: function(evt, s){
|
|
|
|
var o = this;
|
|
|
|
var slcIndex = s && s.slcIndex!==undefined ? s.slcIndex : null;
|
|
|
|
var slcExternal = s && s.slcExternal!==undefined ?
|
|
|
|
s.slcExternal : false;
|
|
|
|
var slcId = s && s.slcId!==undefined ? s.slcId : null;
|
|
|
|
var pgIndex = s && s.pgIndex!==undefined ? s.pgIndex : null;
|
|
|
|
|
|
|
|
function efx(){
|
|
|
|
if(!evt){ return; }
|
|
|
|
switch(evt){
|
|
|
|
case o.Evt.name.filter:
|
|
|
|
if(o.isModFilterFn){
|
|
|
|
o.modFilterFn.call(null,o);
|
|
|
|
} else {
|
2014-09-07 12:07:28 +02:00
|
|
|
o._Filter();
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
break;
|
|
|
|
case o.Evt.name.populateselect:
|
|
|
|
if(o.refreshFilters){
|
|
|
|
o._PopulateSelect(slcIndex,true);
|
|
|
|
} else {
|
|
|
|
o._PopulateSelect(slcIndex,false,slcExternal,slcId);
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
break;
|
|
|
|
case o.Evt.name.populatechecklist:
|
|
|
|
o._PopulateCheckList(slcIndex,slcExternal,slcId);
|
|
|
|
break;
|
|
|
|
case o.Evt.name.changepage:
|
|
|
|
o._ChangePage(pgIndex);
|
|
|
|
break;
|
|
|
|
case o.Evt.name.clear:
|
|
|
|
o._ClearFilters();
|
|
|
|
o._Filter();
|
|
|
|
break;
|
|
|
|
case o.Evt.name.changeresultsperpage:
|
|
|
|
o._ChangeResultsPerPage();
|
|
|
|
break;
|
|
|
|
case o.Evt.name.resetvalues:
|
|
|
|
o._ResetValues();
|
|
|
|
o._Filter();
|
|
|
|
break;
|
|
|
|
case o.Evt.name.resetpage:
|
|
|
|
o._ResetPage(o.pgNbCookie);
|
|
|
|
break;
|
|
|
|
case o.Evt.name.resetpagelength:
|
|
|
|
o._ResetPageLength(o.pgLenCookie);
|
|
|
|
break;
|
|
|
|
case o.Evt.name.sort:
|
|
|
|
void(0);
|
|
|
|
break;
|
|
|
|
case o.Evt.name.loadextensions:
|
|
|
|
o._LoadExtensions();
|
|
|
|
break;
|
|
|
|
case o.Evt.name.loadthemes:
|
|
|
|
o._LoadThemes();
|
|
|
|
break;
|
|
|
|
default: //to be used by extensions events when needed
|
|
|
|
o['_'+evt].call(null,o,s);
|
|
|
|
break;
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
if(o.status || o.statusBar){
|
|
|
|
o.StatusMsg('');
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
if(o.loader){
|
2014-11-09 09:31:15 +01:00
|
|
|
o.Cpt.loader.show('none');
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
if(this.loader || this.status || this.statusBar) {
|
|
|
|
try{
|
2014-11-09 09:31:15 +01:00
|
|
|
this.Cpt.loader.show('');
|
2014-09-20 15:56:35 +02:00
|
|
|
this.StatusMsg(o['msg'+evt]);
|
|
|
|
} catch(e){}
|
2014-11-09 06:12:03 +01:00
|
|
|
global.setTimeout(efx, this.execDelay);
|
2014-09-20 15:56:35 +02:00
|
|
|
} else {
|
|
|
|
efx();
|
|
|
|
}
|
|
|
|
},
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
ImportModule: function(module){
|
2014-09-21 14:52:12 +02:00
|
|
|
if(!module.path || !module.name){
|
|
|
|
return;
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
this.IncludeFile(module.name, module.path, module.init);
|
|
|
|
},
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
LoadExtensions : function(){
|
|
|
|
if(!this.Ext){
|
|
|
|
/*** TF extensions ***/
|
|
|
|
var o = this;
|
|
|
|
this.Ext = {
|
|
|
|
list: {},
|
2014-09-21 14:52:12 +02:00
|
|
|
add: function(extName, extDesc, extPath, extCallBack){
|
|
|
|
var file = extPath.split('/')[extPath.split('/').length-1],
|
|
|
|
re = new RegExp(file),
|
|
|
|
path = extPath.replace(re,'');
|
2014-09-20 15:56:35 +02:00
|
|
|
o.Ext.list[extName] = {
|
|
|
|
name: extName,
|
|
|
|
description: extDesc,
|
|
|
|
file: file,
|
|
|
|
path: path,
|
|
|
|
callback: extCallBack
|
|
|
|
};
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
this.EvtManager(this.Evt.name.loadextensions);
|
|
|
|
},
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
/*====================================================
|
|
|
|
- loads TF extensions
|
|
|
|
=====================================================*/
|
2014-09-21 14:52:12 +02:00
|
|
|
_LoadExtensions : function(){
|
2014-10-18 14:00:34 +02:00
|
|
|
if(!this.hasExtensions || !types.isArray(this.extensions.name) ||
|
|
|
|
!types.isArray(this.extensions.src)){
|
2014-09-21 14:52:12 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
var ext = this.extensions;
|
|
|
|
for(var e=0; e<ext.name.length; e++){
|
|
|
|
var extPath = ext.src[e],
|
|
|
|
extName = ext.name[e],
|
|
|
|
extInit = (ext.initialize && ext.initialize[e]) ?
|
|
|
|
ext.initialize[e] : null,
|
|
|
|
extDesc = (ext.description && ext.description[e] ) ?
|
|
|
|
ext.description[e] : null;
|
|
|
|
|
|
|
|
//Registers extension
|
|
|
|
this.Ext.add(extName, extDesc, extPath, extInit);
|
2014-10-18 14:00:34 +02:00
|
|
|
if(isImported(extPath)){
|
2014-09-21 14:52:12 +02:00
|
|
|
extInit.call(null,this);
|
|
|
|
} else {
|
|
|
|
this.IncludeFile(extName, extPath, extInit);
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-21 14:52:12 +02:00
|
|
|
LoadThemes: function(){
|
2014-09-20 15:56:35 +02:00
|
|
|
this.EvtManager(this.Evt.name.loadthemes);
|
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- loads TF themes
|
|
|
|
=====================================================*/
|
2014-09-21 14:52:12 +02:00
|
|
|
_LoadThemes: function(){
|
|
|
|
if(!this.hasThemes){
|
|
|
|
return;
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
if(!this.Thm){
|
|
|
|
/*** TF themes ***/
|
|
|
|
var o = this;
|
|
|
|
this.Thm = {
|
|
|
|
list: {},
|
2014-09-21 14:52:12 +02:00
|
|
|
add: function(thmName, thmDesc, thmPath, thmCallBack){
|
|
|
|
var file = thmPath.split('/')[thmPath.split('/').length-1],
|
|
|
|
re = new RegExp(file),
|
|
|
|
path = thmPath.replace(re,'');
|
2014-09-20 15:56:35 +02:00
|
|
|
o.Thm.list[thmName] = {
|
|
|
|
name: thmName,
|
|
|
|
description: thmDesc,
|
|
|
|
file: file,
|
|
|
|
path: path,
|
|
|
|
callback: thmCallBack
|
|
|
|
};
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
};
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-21 14:52:12 +02:00
|
|
|
//Default theme config
|
|
|
|
if(this.enableDefaultTheme){
|
2014-09-20 15:56:35 +02:00
|
|
|
this.themes = {
|
|
|
|
name:['DefaultTheme'],
|
|
|
|
src:[this.themesPath+'Default/TF_Default.css'],
|
|
|
|
description:['Default Theme']
|
|
|
|
};
|
2014-09-21 14:52:12 +02:00
|
|
|
this.Thm.add('DefaultTheme',
|
|
|
|
this.themesPath+'Default/TF_Default.css', 'Default Theme');
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
2014-10-18 14:00:34 +02:00
|
|
|
if(types.isArray(this.themes.name) &&
|
|
|
|
types.isArray(this.themes.src)){
|
2014-09-20 15:56:35 +02:00
|
|
|
var thm = this.themes;
|
|
|
|
for(var i=0; i<thm.name.length; i++){
|
2014-09-21 14:52:12 +02:00
|
|
|
var thmPath = thm.src[i],
|
|
|
|
thmName = thm.name[i],
|
|
|
|
thmInit = (thm.initialize && thm.initialize[i]) ?
|
|
|
|
thm.initialize[i] : null,
|
|
|
|
thmDesc = (thm.description && thm.description[i]) ?
|
|
|
|
thm.description[i] : null;
|
2014-09-20 15:56:35 +02:00
|
|
|
|
|
|
|
//Registers theme
|
|
|
|
this.Thm.add(thmName, thmDesc, thmPath, thmInit);
|
|
|
|
|
2014-10-18 14:00:34 +02:00
|
|
|
if(!isImported(thmPath,'link')){
|
2014-09-20 15:56:35 +02:00
|
|
|
this.IncludeFile(thmName, thmPath, null, 'link');
|
2014-09-21 14:52:12 +02:00
|
|
|
}
|
2014-10-18 14:00:34 +02:00
|
|
|
if(types.isFn(thmInit)){
|
2014-09-21 14:52:12 +02:00
|
|
|
thmInit.call(null,this);
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
//Some elements need to be overriden for theme
|
|
|
|
//Reset button
|
|
|
|
this.btnResetText = null;
|
2014-09-21 14:52:12 +02:00
|
|
|
this.btnResetHtml = '<input type="button" value="" class="' +
|
|
|
|
this.btnResetCssClass+'" title="Clear filters" />';
|
2014-09-20 15:56:35 +02:00
|
|
|
|
|
|
|
//Paging buttons
|
2014-09-21 14:52:12 +02:00
|
|
|
this.btnPrevPageHtml = '<input type="button" value="" class="' +
|
|
|
|
this.btnPageCssClass+' previousPage" title="Previous page" />';
|
|
|
|
this.btnNextPageHtml = '<input type="button" value="" class="' +
|
|
|
|
this.btnPageCssClass+' nextPage" title="Next page" />';
|
|
|
|
this.btnFirstPageHtml = '<input type="button" value="" class="' +
|
|
|
|
this.btnPageCssClass+' firstPage" title="First page" />';
|
|
|
|
this.btnLastPageHtml = '<input type="button" value="" class="' +
|
|
|
|
this.btnPageCssClass+' lastPage" title="Last page" />';
|
2014-09-20 15:56:35 +02:00
|
|
|
|
|
|
|
//Loader
|
|
|
|
this.loader = true;
|
|
|
|
this.loaderHtml = '<div class="defaultLoader"></div>';
|
|
|
|
this.loaderText = null;
|
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- removes a filter grid
|
|
|
|
=====================================================*/
|
2014-09-21 14:52:12 +02:00
|
|
|
RemoveGrid: function(){
|
|
|
|
if(this.fltGrid && this.hasGrid){
|
2014-09-20 15:56:35 +02:00
|
|
|
var rows = this.tbl.rows;
|
2014-09-21 14:52:12 +02:00
|
|
|
if(this.paging){
|
|
|
|
this.RemovePaging();
|
|
|
|
}
|
|
|
|
if(this.statusBar){
|
|
|
|
this.RemoveStatusBar();
|
|
|
|
}
|
|
|
|
if(this.rowsCounter){
|
|
|
|
this.RemoveRowsCounter();
|
|
|
|
}
|
|
|
|
if(this.btnReset){
|
|
|
|
this.RemoveResetBtn();
|
|
|
|
}
|
|
|
|
if(this.helpInstructions || !this.helpInstructions){
|
|
|
|
this.RemoveHelpInstructions();
|
|
|
|
}
|
|
|
|
if(this.paging){
|
|
|
|
this.RemoveResultsPerPage();
|
|
|
|
}
|
|
|
|
if(this.isExternalFlt && !this.popUpFilters){
|
|
|
|
this.RemoveExternalFlts();
|
|
|
|
}
|
|
|
|
if(this.fixedHeaders){
|
|
|
|
this.RemoveFixedHeaders();
|
|
|
|
}
|
|
|
|
if(this.infDiv){
|
|
|
|
this.RemoveTopDiv();
|
|
|
|
}
|
|
|
|
if(this.highlightKeywords){
|
|
|
|
this.UnhighlightAll();
|
|
|
|
}
|
|
|
|
if(this.sort){
|
|
|
|
this.RemoveSort();
|
|
|
|
}
|
|
|
|
if(this.loader){
|
2014-11-09 09:31:15 +01:00
|
|
|
this.Cpt.loader.remove();
|
2014-09-21 14:52:12 +02:00
|
|
|
}
|
|
|
|
if(this.popUpFilters){
|
|
|
|
this.RemovePopupFilters();
|
|
|
|
}
|
|
|
|
if(this.markActiveColumns){
|
|
|
|
this.ClearActiveColumns();
|
|
|
|
}
|
|
|
|
if(this.editable || this.selectable){
|
|
|
|
this.RemoveEditable();
|
|
|
|
}
|
|
|
|
//this loop shows all rows and removes validRow attribute
|
|
|
|
for(var j=this.refRow; j<this.nbRows; j++){
|
2014-09-20 15:56:35 +02:00
|
|
|
rows[j].style.display = '';
|
2014-09-21 14:52:12 +02:00
|
|
|
try{
|
|
|
|
if(rows[j].hasAttribute('validRow')){
|
2014-09-20 15:56:35 +02:00
|
|
|
rows[j].removeAttribute('validRow');
|
2014-09-21 14:52:12 +02:00
|
|
|
}
|
|
|
|
} catch(e) {
|
|
|
|
//ie<=6 doesn't support hasAttribute method
|
|
|
|
var row = rows[j];
|
|
|
|
var attribs = row.attributes;
|
|
|
|
for(var x = 0; x < attribs.length; x++){
|
2014-10-18 14:00:34 +02:00
|
|
|
if(str.lower(attribs.nodeName)==='validrow'){
|
2014-09-21 14:52:12 +02:00
|
|
|
row.removeAttribute('validRow');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-21 14:52:12 +02:00
|
|
|
//removes alternating colors
|
|
|
|
if(this.alternateBgs){
|
2014-11-09 09:31:15 +01:00
|
|
|
this.Cpt.alternateRows.removeRowBg(j);
|
2014-09-21 14:52:12 +02:00
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
}//for j
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-21 14:52:12 +02:00
|
|
|
if(this.fltGrid && !this.gridLayout){
|
2014-09-20 15:56:35 +02:00
|
|
|
this.fltGridEl = rows[this.filtersRowIndex];
|
|
|
|
this.tbl.deleteRow(this.filtersRowIndex);
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
2014-09-21 14:52:12 +02:00
|
|
|
if(this.gridLayout){
|
|
|
|
this.RemoveGridLayout();
|
|
|
|
}
|
2014-10-18 14:00:34 +02:00
|
|
|
dom.removeClass(this.tbl, this.prfxTf);
|
2014-09-20 15:56:35 +02:00
|
|
|
this.activeFlt = null;
|
|
|
|
this.isStartBgAlternate = true;
|
|
|
|
this.hasGrid = false;
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
}//if this.fltGrid
|
|
|
|
},
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
/*====================================================
|
|
|
|
- Generates div above table where paging,
|
|
|
|
reset button, rows counter label etc. are placed
|
|
|
|
=====================================================*/
|
2014-09-21 14:52:12 +02:00
|
|
|
SetTopDiv: function(){
|
|
|
|
if(this.infDiv!==null){
|
|
|
|
return;
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
|
|
|
|
/*** container div ***/
|
2014-10-18 14:00:34 +02:00
|
|
|
var infdiv = dom.create('div', ['id',this.prfxInfDiv+this.id]);
|
2014-09-21 14:52:12 +02:00
|
|
|
infdiv.className = this.infDivCssClass;
|
2014-09-20 15:56:35 +02:00
|
|
|
|
2014-09-21 14:52:12 +02:00
|
|
|
//custom container
|
|
|
|
if(this.toolBarTgtId){
|
2014-11-01 15:34:37 +01:00
|
|
|
dom.id(this.toolBarTgtId).appendChild(infdiv);
|
2014-09-21 14:52:12 +02:00
|
|
|
}
|
|
|
|
//fixed headers
|
|
|
|
else if(this.fixedHeaders && this.contDiv){
|
2014-09-20 15:56:35 +02:00
|
|
|
this.contDiv.parentNode.insertBefore(infdiv, this.contDiv);
|
2014-09-21 14:52:12 +02:00
|
|
|
}
|
|
|
|
//grid-layout
|
|
|
|
else if(this.gridLayout){
|
2014-09-20 15:56:35 +02:00
|
|
|
this.tblMainCont.appendChild(infdiv);
|
|
|
|
infdiv.className = this.gridInfDivCssClass;
|
|
|
|
}
|
2014-09-21 14:52:12 +02:00
|
|
|
//default location: just above the table
|
|
|
|
else{
|
2014-09-20 15:56:35 +02:00
|
|
|
this.tbl.parentNode.insertBefore(infdiv, this.tbl);
|
2014-09-21 14:52:12 +02:00
|
|
|
}
|
2014-11-01 15:34:37 +01:00
|
|
|
this.infDiv = dom.id(this.prfxInfDiv+this.id);
|
2014-09-20 15:56:35 +02:00
|
|
|
|
|
|
|
/*** left div containing rows # displayer ***/
|
2014-10-18 14:00:34 +02:00
|
|
|
var ldiv = dom.create('div', ['id',this.prfxLDiv+this.id]);
|
2014-09-21 14:52:12 +02:00
|
|
|
ldiv.className = this.lDivCssClass;
|
2014-09-20 15:56:35 +02:00
|
|
|
infdiv.appendChild(ldiv);
|
2014-11-01 15:34:37 +01:00
|
|
|
this.lDiv = dom.id(this.prfxLDiv+this.id);
|
2014-09-20 15:56:35 +02:00
|
|
|
|
|
|
|
/*** right div containing reset button
|
|
|
|
+ nb results per page select ***/
|
2014-10-18 14:00:34 +02:00
|
|
|
var rdiv = dom.create('div', ['id',this.prfxRDiv+this.id]);
|
2014-09-21 14:52:12 +02:00
|
|
|
rdiv.className = this.rDivCssClass;
|
2014-09-20 15:56:35 +02:00
|
|
|
infdiv.appendChild(rdiv);
|
2014-11-01 15:34:37 +01:00
|
|
|
this.rDiv = dom.id(this.prfxRDiv+this.id);
|
2014-09-20 15:56:35 +02:00
|
|
|
|
|
|
|
/*** mid div containing paging elements ***/
|
2014-10-18 14:00:34 +02:00
|
|
|
var mdiv = dom.create('div', ['id',this.prfxMDiv+this.id]);
|
2014-09-21 14:52:12 +02:00
|
|
|
mdiv.className = this.mDivCssClass;
|
2014-09-20 15:56:35 +02:00
|
|
|
infdiv.appendChild(mdiv);
|
2014-11-01 15:34:37 +01:00
|
|
|
this.mDiv = dom.id(this.prfxMDiv+this.id);
|
2014-09-20 15:56:35 +02:00
|
|
|
|
2014-09-21 14:52:12 +02:00
|
|
|
if(!this.helpInstructions){
|
|
|
|
this.SetHelpInstructions();
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- Removes div above table where paging,
|
|
|
|
reset button, rows counter label etc. are placed
|
|
|
|
=====================================================*/
|
2014-09-21 14:52:12 +02:00
|
|
|
RemoveTopDiv: function(){
|
|
|
|
if(!this.infDiv){
|
|
|
|
return;
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
this.infDiv.parentNode.removeChild(this.infDiv);
|
|
|
|
this.infDiv = null;
|
|
|
|
},
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
/*====================================================
|
|
|
|
- removes external filters
|
|
|
|
=====================================================*/
|
2014-09-21 14:52:12 +02:00
|
|
|
RemoveExternalFlts: function(){
|
|
|
|
if(!this.isExternalFlt && !this.externalFltTgtIds){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for(var ct=0; ct<this.externalFltTgtIds.length; ct++){
|
|
|
|
var externalFltTgtId = this.externalFltTgtIds[ct],
|
2014-11-01 15:34:37 +01:00
|
|
|
externalFlt = dom.id(externalFltTgtId);
|
2014-09-21 14:52:12 +02:00
|
|
|
if(externalFlt){
|
|
|
|
externalFlt.innerHTML = '';
|
|
|
|
}
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- Sets sorting feature by loading
|
2014-09-21 14:52:12 +02:00
|
|
|
WebFX Sortable Table 1.12 plugin by Erik Arvidsson
|
2014-09-20 15:56:35 +02:00
|
|
|
and TF adapter by Max Guglielmi
|
|
|
|
=====================================================*/
|
2014-09-21 14:52:12 +02:00
|
|
|
SetSort: function(){
|
|
|
|
var fn = this.Evt._EnableSort,
|
|
|
|
sortConfig = this.sortConfig;
|
|
|
|
|
2014-10-18 14:00:34 +02:00
|
|
|
if(!types.isFn(fn)){
|
2014-09-20 15:56:35 +02:00
|
|
|
var o = this;
|
|
|
|
/*====================================================
|
|
|
|
- enables table sorting
|
|
|
|
=====================================================*/
|
2014-09-21 14:52:12 +02:00
|
|
|
this.Evt._EnableSort = function(){
|
|
|
|
//gridLayout needs sort to be re-enabled
|
|
|
|
if(o.isSortEnabled && !o.gridLayout){
|
|
|
|
return;
|
|
|
|
}
|
2014-10-18 14:00:34 +02:00
|
|
|
if(isImported(sortConfig.adapterSrc)){
|
2014-09-21 14:52:12 +02:00
|
|
|
sortConfig.initialize.call(null,o);
|
|
|
|
} else {
|
2014-09-20 15:56:35 +02:00
|
|
|
o.IncludeFile(
|
2014-09-21 14:52:12 +02:00
|
|
|
sortConfig.name+'_adapter',
|
|
|
|
sortConfig.adapterSrc,
|
|
|
|
function(){ sortConfig.initialize.call(null,o); }
|
2014-09-20 15:56:35 +02:00
|
|
|
);
|
2014-09-21 14:52:12 +02:00
|
|
|
}
|
|
|
|
};
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-10-18 14:00:34 +02:00
|
|
|
if(isImported(this.sortConfig.src)){
|
2014-09-20 15:56:35 +02:00
|
|
|
this.Evt._EnableSort();
|
2014-09-21 14:52:12 +02:00
|
|
|
} else {
|
2014-09-20 15:56:35 +02:00
|
|
|
this.IncludeFile(
|
2014-09-21 14:52:12 +02:00
|
|
|
sortConfig.name, sortConfig.src,this.Evt._EnableSort);
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
},
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
/*====================================================
|
|
|
|
- removes sorting feature
|
|
|
|
=====================================================*/
|
2014-09-21 14:52:12 +02:00
|
|
|
RemoveSort: function(){
|
2014-09-20 15:56:35 +02:00
|
|
|
this.sort = false;
|
|
|
|
},
|
|
|
|
|
2014-09-21 14:52:12 +02:00
|
|
|
Sort: function(){
|
2014-09-20 15:56:35 +02:00
|
|
|
this.EvtManager(this.Evt.name.sort);
|
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- Sets selection or edition features by loading
|
|
|
|
ezEditTable script by Max Guglielmi
|
|
|
|
=====================================================*/
|
2014-09-21 14:52:12 +02:00
|
|
|
SetEditable: function(){
|
|
|
|
var ezEditConfig = this.ezEditTableConfig;
|
2014-10-18 14:00:34 +02:00
|
|
|
if(isImported(ezEditConfig.src)){
|
2014-09-20 15:56:35 +02:00
|
|
|
this._EnableEditable();
|
|
|
|
} else {
|
|
|
|
this.IncludeFile(
|
2014-09-21 14:52:12 +02:00
|
|
|
ezEditConfig.name,
|
|
|
|
ezEditConfig.src,
|
2014-09-20 15:56:35 +02:00
|
|
|
this._EnableEditable
|
|
|
|
);
|
|
|
|
}
|
2014-09-21 14:52:12 +02:00
|
|
|
if(ezEditConfig.loadStylesheet &&
|
2014-10-18 14:00:34 +02:00
|
|
|
!isImported(ezEditConfig.stylesheet, 'link')){
|
2014-09-20 15:56:35 +02:00
|
|
|
this.IncludeFile(
|
2014-09-21 14:52:12 +02:00
|
|
|
ezEditConfig.stylesheetName,
|
|
|
|
ezEditConfig.stylesheet, null, 'link'
|
2014-09-20 15:56:35 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- Removes selection or edition features
|
|
|
|
=====================================================*/
|
2014-09-21 14:52:12 +02:00
|
|
|
RemoveEditable: function(){
|
|
|
|
var ezEditTable = this.ezEditTable;
|
|
|
|
if(ezEditTable){
|
2014-09-20 15:56:35 +02:00
|
|
|
if(this.selectable){
|
2014-09-21 14:52:12 +02:00
|
|
|
ezEditTable.Selection.ClearSelections();
|
|
|
|
ezEditTable.Selection.Remove();
|
|
|
|
}
|
|
|
|
if(this.editable){
|
|
|
|
ezEditTable.Editable.Remove();
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
|
|
|
},
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
/*====================================================
|
|
|
|
- Resets selection or edition features after
|
|
|
|
removal
|
|
|
|
=====================================================*/
|
2014-09-21 14:52:12 +02:00
|
|
|
ResetEditable: function(){
|
|
|
|
var ezEditTable = this.ezEditTable;
|
|
|
|
if(ezEditTable){
|
|
|
|
if(this.selectable){
|
|
|
|
ezEditTable.Selection.Set();
|
|
|
|
}
|
|
|
|
if(this.editable){
|
|
|
|
ezEditTable.Editable.Set();
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2014-09-21 14:52:12 +02:00
|
|
|
_EnableEditable: function(o){
|
|
|
|
if(!o){
|
|
|
|
o = this;
|
|
|
|
}
|
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
//start row for EditTable constructor needs to be calculated
|
2014-09-21 14:52:12 +02:00
|
|
|
var startRow,
|
|
|
|
ezEditConfig = o.ezEditTableConfig,
|
2014-11-01 15:34:37 +01:00
|
|
|
thead = dom.tag(o.tbl,'thead');
|
2014-09-21 14:52:12 +02:00
|
|
|
|
|
|
|
//if thead exists and startRow not specified, startRow is calculated
|
|
|
|
//automatically by EditTable
|
|
|
|
if(thead.length > 0 && !ezEditConfig.startRow){
|
|
|
|
startRow = undefined;
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
//otherwise startRow config property if any or TableFilter refRow
|
2014-09-21 14:52:12 +02:00
|
|
|
else{
|
|
|
|
startRow = ezEditConfig.startRow || o.refRow;
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
|
2014-09-21 14:52:12 +02:00
|
|
|
ezEditConfig.scroll_into_view = ezEditConfig.scroll_into_view===false ?
|
|
|
|
false : true;
|
|
|
|
ezEditConfig.base_path = ezEditConfig.base_path ||
|
|
|
|
o.basePath + 'ezEditTable/';
|
|
|
|
ezEditConfig.editable = o.editable = o.fObj.editable;
|
|
|
|
ezEditConfig.selection = o.selectable = o.fObj.selectable;
|
2014-09-20 15:56:35 +02:00
|
|
|
|
2014-09-21 14:52:12 +02:00
|
|
|
if(o.selectable){
|
|
|
|
ezEditConfig.default_selection =
|
|
|
|
ezEditConfig.default_selection || 'row';
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
//CSS Styles
|
2014-09-21 14:52:12 +02:00
|
|
|
ezEditConfig.active_cell_css = ezEditConfig.active_cell_css ||
|
|
|
|
'ezETSelectedCell';
|
2014-09-20 15:56:35 +02:00
|
|
|
|
|
|
|
o._lastValidRowIndex = 0;
|
|
|
|
o._lastRowIndex = 0;
|
|
|
|
|
|
|
|
if(o.selectable){
|
2014-09-21 14:52:12 +02:00
|
|
|
//Row navigation needs to be calculated according to TableFilter's
|
|
|
|
//validRowsIndex array
|
|
|
|
var onAfterSelection = function(et, selectedElm, e){
|
|
|
|
//table is not filtered
|
|
|
|
if(!o.validRowsIndex){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
var validIndexes = o.validRowsIndex,
|
|
|
|
validIdxLen = validIndexes.length,
|
|
|
|
row = et.defaultSelection !== 'row' ?
|
|
|
|
selectedElm.parentNode : selectedElm,
|
|
|
|
//cell for default_selection = 'both' or 'cell'
|
|
|
|
cell = selectedElm.nodeName==='TD' ? selectedElm : null,
|
|
|
|
keyCode = e !== undefined ? et.Event.GetKey(e) : 0,
|
2014-10-18 14:00:34 +02:00
|
|
|
isRowValid = array.has(validIndexes, row.rowIndex),
|
2014-09-21 14:52:12 +02:00
|
|
|
nextRowIndex,
|
|
|
|
//pgup/pgdown keys
|
|
|
|
d = (keyCode === 34 || keyCode === 33 ?
|
|
|
|
(o.pagingLength || et.nbRowsPerPage) : 1);
|
|
|
|
|
|
|
|
//If next row is not valid, next valid filtered row needs to be
|
|
|
|
//calculated
|
2014-09-20 15:56:35 +02:00
|
|
|
if(!isRowValid){
|
|
|
|
//Selection direction up/down
|
|
|
|
if(row.rowIndex>o._lastRowIndex){
|
2014-09-21 14:52:12 +02:00
|
|
|
//last row
|
|
|
|
if(row.rowIndex >= validIndexes[validIdxLen-1]){
|
|
|
|
nextRowIndex = validIndexes[validIdxLen-1];
|
|
|
|
} else {
|
2014-09-20 15:56:35 +02:00
|
|
|
var calcRowIndex = (o._lastValidRowIndex + d);
|
2014-09-21 14:52:12 +02:00
|
|
|
if(calcRowIndex > (validIdxLen-1)){
|
|
|
|
nextRowIndex = validIndexes[validIdxLen-1];
|
|
|
|
} else {
|
|
|
|
nextRowIndex = validIndexes[calcRowIndex];
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
} else{
|
2014-09-21 14:52:12 +02:00
|
|
|
//first row
|
|
|
|
if(row.rowIndex <= validIndexes[0]){
|
|
|
|
nextRowIndex = validIndexes[0];
|
|
|
|
} else {
|
|
|
|
var v = validIndexes[o._lastValidRowIndex - d];
|
|
|
|
nextRowIndex = v ? v : validIndexes[0];
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
o._lastRowIndex = row.rowIndex;
|
|
|
|
DoSelection(nextRowIndex);
|
2014-09-21 14:52:12 +02:00
|
|
|
} else {
|
|
|
|
//If filtered row is valid, special calculation for
|
|
|
|
//pgup/pgdown keys
|
|
|
|
if(keyCode!==34 && keyCode!==33){
|
2014-10-18 14:00:34 +02:00
|
|
|
o._lastValidRowIndex = array.indexByValue(validIndexes,
|
2014-09-21 14:52:12 +02:00
|
|
|
row.rowIndex);
|
2014-09-20 15:56:35 +02:00
|
|
|
o._lastRowIndex = row.rowIndex;
|
|
|
|
} else {
|
2014-09-21 14:52:12 +02:00
|
|
|
if(keyCode === 34){ //pgdown
|
|
|
|
//last row
|
|
|
|
if((o._lastValidRowIndex + d) <= (validIdxLen-1)){
|
|
|
|
nextRowIndex = validIndexes[
|
|
|
|
o._lastValidRowIndex + d];
|
|
|
|
} else {
|
|
|
|
nextRowIndex = [validIdxLen-1];
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
} else { //pgup
|
2014-09-21 14:52:12 +02:00
|
|
|
//first row
|
|
|
|
if((o._lastValidRowIndex - d) <= validIndexes[0]){
|
|
|
|
nextRowIndex = validIndexes[0];
|
|
|
|
} else {
|
|
|
|
nextRowIndex = validIndexes[
|
|
|
|
o._lastValidRowIndex - d];
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
o._lastRowIndex = nextRowIndex;
|
2014-10-18 14:00:34 +02:00
|
|
|
o._lastValidRowIndex = array.indexByValue(validIndexes,
|
2014-09-21 14:52:12 +02:00
|
|
|
nextRowIndex);
|
2014-09-20 15:56:35 +02:00
|
|
|
DoSelection(nextRowIndex);
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
//Next valid filtered row needs to be selected
|
2014-09-21 14:52:12 +02:00
|
|
|
var DoSelection = function(nextRowIndex){
|
|
|
|
if(et.defaultSelection === 'row'){
|
2014-09-20 15:56:35 +02:00
|
|
|
et.Selection.SelectRowByIndex(nextRowIndex);
|
|
|
|
} else {
|
|
|
|
et.ClearSelections();
|
2014-09-21 14:52:12 +02:00
|
|
|
var cellIndex = selectedElm.cellIndex,
|
|
|
|
row = o.tbl.rows[nextRowIndex];
|
|
|
|
if(et.defaultSelection === 'both'){
|
|
|
|
et.Selection.SelectRowByIndex(nextRowIndex);
|
|
|
|
}
|
|
|
|
if(row){
|
|
|
|
et.Selection.SelectCell(row.cells[cellIndex]);
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
|
|
|
//Table is filtered
|
2014-09-21 14:52:12 +02:00
|
|
|
if(o.validRowsIndex.length !== o.GetRowsNb()){
|
|
|
|
var r = o.tbl.rows[nextRowIndex];
|
|
|
|
if(r){
|
|
|
|
r.scrollIntoView(false);
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
if(cell){
|
2014-09-21 14:52:12 +02:00
|
|
|
if(cell.cellIndex===(o.GetCellsNb()-1) &&
|
|
|
|
o.gridLayout){
|
|
|
|
o.tblCont.scrollLeft = 100000000;
|
|
|
|
}
|
|
|
|
else if(cell.cellIndex===0 && o.gridLayout){
|
|
|
|
o.tblCont.scrollLeft = 0;
|
|
|
|
} else {
|
|
|
|
cell.scrollIntoView(false);
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
|
|
|
}
|
2014-09-21 14:52:12 +02:00
|
|
|
};
|
|
|
|
};
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-21 14:52:12 +02:00
|
|
|
//Page navigation has to be enforced whenever selected row is out of
|
|
|
|
//the current page range
|
|
|
|
var onBeforeSelection = function(et, selectedElm, e){
|
|
|
|
var row = et.defaultSelection !== 'row' ?
|
|
|
|
selectedElm.parentNode : selectedElm;
|
2014-09-07 12:07:28 +02:00
|
|
|
if(o.paging){
|
2014-09-20 15:56:35 +02:00
|
|
|
if(o.nbPages>1){
|
2014-09-21 14:52:12 +02:00
|
|
|
//page length is re-assigned in case it has changed
|
|
|
|
et.nbRowsPerPage = o.pagingLength;
|
|
|
|
var validIndexes = o.validRowsIndex,
|
|
|
|
validIdxLen = validIndexes.length,
|
|
|
|
pagingEndRow = parseInt(o.startPagingRow,10) +
|
|
|
|
parseInt(o.pagingLength,10);
|
2014-09-20 15:56:35 +02:00
|
|
|
var rowIndex = row.rowIndex;
|
2014-09-21 14:52:12 +02:00
|
|
|
if((rowIndex === validIndexes[validIdxLen-1]) &&
|
|
|
|
o.currentPageNb!=o.nbPages){
|
|
|
|
o.SetPage('last');
|
|
|
|
}
|
|
|
|
else if((rowIndex == validIndexes[0]) &&
|
|
|
|
o.currentPageNb!==1){
|
|
|
|
o.SetPage('first');
|
|
|
|
}
|
|
|
|
else if(rowIndex > validIndexes[pagingEndRow-1] &&
|
|
|
|
rowIndex < validIndexes[validIdxLen-1]){
|
|
|
|
o.SetPage('next');
|
|
|
|
}
|
|
|
|
else if(rowIndex < validIndexes[o.startPagingRow] &&
|
|
|
|
rowIndex > validIndexes[0]){
|
|
|
|
o.SetPage('previous');
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
|
|
|
}
|
2014-09-21 14:52:12 +02:00
|
|
|
};
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
//Selected row needs to be visible when paging is activated
|
|
|
|
if(o.paging){
|
|
|
|
o.onAfterChangePage = function(tf, i){
|
2014-09-21 14:52:12 +02:00
|
|
|
var et = tf.ezEditTable;
|
|
|
|
var row = et.Selection.GetActiveRow();
|
|
|
|
if(row){
|
|
|
|
row.scrollIntoView(false);
|
|
|
|
}
|
|
|
|
var cell = et.Selection.GetActiveCell();
|
|
|
|
if(cell){
|
|
|
|
cell.scrollIntoView(false);
|
|
|
|
}
|
|
|
|
};
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
|
2014-09-21 14:52:12 +02:00
|
|
|
//Rows navigation when rows are filtered is performed with the
|
|
|
|
//EditTable row selection callback events
|
|
|
|
if(ezEditConfig.default_selection==='row'){
|
|
|
|
var fnB = ezEditConfig.on_before_selected_row;
|
|
|
|
ezEditConfig.on_before_selected_row = function(){
|
2014-09-20 15:56:35 +02:00
|
|
|
onBeforeSelection(arguments[0], arguments[1], arguments[2]);
|
2014-09-21 14:52:12 +02:00
|
|
|
if(fnB){
|
|
|
|
fnB.call(
|
|
|
|
null, arguments[0], arguments[1], arguments[2]);
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
};
|
2014-09-21 14:52:12 +02:00
|
|
|
var fnA = ezEditConfig.on_after_selected_row;
|
|
|
|
ezEditConfig.on_after_selected_row = function(){
|
2014-09-20 15:56:35 +02:00
|
|
|
onAfterSelection(arguments[0], arguments[1], arguments[2]);
|
2014-09-21 14:52:12 +02:00
|
|
|
if(fnA){
|
|
|
|
fnA.call(
|
|
|
|
null, arguments[0], arguments[1], arguments[2]);
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
};
|
|
|
|
} else {
|
2014-09-21 14:52:12 +02:00
|
|
|
var fnD = ezEditConfig.on_before_selected_cell;
|
|
|
|
ezEditConfig.on_before_selected_cell = function(){
|
2014-09-20 15:56:35 +02:00
|
|
|
onBeforeSelection(arguments[0], arguments[1], arguments[2]);
|
2014-09-21 14:52:12 +02:00
|
|
|
if(fnD){
|
|
|
|
fnD.call(
|
|
|
|
null, arguments[0], arguments[1], arguments[2]);
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
};
|
2014-09-21 14:52:12 +02:00
|
|
|
var fnC = ezEditConfig.on_after_selected_cell;
|
|
|
|
ezEditConfig.on_after_selected_cell = function(){
|
2014-09-20 15:56:35 +02:00
|
|
|
onAfterSelection(arguments[0], arguments[1], arguments[2]);
|
2014-09-21 14:52:12 +02:00
|
|
|
if(fnC){
|
|
|
|
fnC.call(
|
|
|
|
null, arguments[0], arguments[1], arguments[2]);
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(o.editable){
|
|
|
|
//Added or removed rows, TF rows number needs to be re-calculated
|
2014-09-21 14:52:12 +02:00
|
|
|
var fnE = ezEditConfig.on_added_dom_row;
|
|
|
|
ezEditConfig.on_added_dom_row = function(){
|
2014-09-20 15:56:35 +02:00
|
|
|
o.nbFilterableRows++;
|
|
|
|
if(!o.paging){ o.RefreshNbRows(); }
|
|
|
|
else {
|
2014-09-21 14:52:12 +02:00
|
|
|
o.nbRows++;
|
|
|
|
o.nbVisibleRows++;
|
|
|
|
o.nbFilterableRows++;
|
|
|
|
o.paging=false;
|
|
|
|
o.RemovePaging();
|
|
|
|
o.AddPaging(false);
|
|
|
|
}
|
|
|
|
if(o.alternateBgs){
|
2014-11-09 09:31:15 +01:00
|
|
|
o.Cpt.alternateRows.set();
|
2014-09-21 14:52:12 +02:00
|
|
|
}
|
|
|
|
if(fnE){
|
|
|
|
fnE.call(null, arguments[0], arguments[1], arguments[2]);
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
|
|
|
};
|
2014-09-21 14:52:12 +02:00
|
|
|
if(ezEditConfig.actions && ezEditConfig.actions['delete']){
|
|
|
|
var fnF = ezEditConfig.actions['delete'].on_after_submit;
|
|
|
|
ezEditConfig.actions['delete'].on_after_submit = function(){
|
2014-09-20 15:56:35 +02:00
|
|
|
o.nbFilterableRows--;
|
2014-09-07 12:07:28 +02:00
|
|
|
if(!o.paging){ o.RefreshNbRows(); }
|
|
|
|
else {
|
2014-09-21 14:52:12 +02:00
|
|
|
o.nbRows--;
|
|
|
|
o.nbVisibleRows--;
|
|
|
|
o.nbFilterableRows--;
|
|
|
|
o.paging=false;
|
|
|
|
o.RemovePaging();
|
|
|
|
o.AddPaging(false);
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
2014-09-21 14:52:12 +02:00
|
|
|
if(o.alternateBgs){
|
2014-11-09 09:31:15 +01:00
|
|
|
o.Cpt.alternateRows.set();
|
2014-09-21 14:52:12 +02:00
|
|
|
}
|
|
|
|
if(fnF){
|
|
|
|
fnF.call(null, arguments[0], arguments[1]);
|
|
|
|
}
|
|
|
|
};
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
try{
|
2014-09-21 14:52:12 +02:00
|
|
|
o.ezEditTable = new EditTable(o.id, ezEditConfig, startRow);
|
2014-09-20 15:56:35 +02:00
|
|
|
o.ezEditTable.Init();
|
2014-09-21 14:52:12 +02:00
|
|
|
} catch(e) { console.log(ezEditConfig.err); }
|
2014-09-20 15:56:35 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- Generates paging elements:
|
|
|
|
- pages drop-down list
|
|
|
|
- previous, next, first, last buttons
|
|
|
|
=====================================================*/
|
2014-09-21 14:52:12 +02:00
|
|
|
SetPaging: function(){
|
|
|
|
if(!this.hasGrid && !this.isFirstLoad || !this.paging ||
|
|
|
|
(!this.isPagingRemoved && !this.isFirstLoad)){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
var f = this.fObj;
|
2014-09-21 14:52:12 +02:00
|
|
|
//id of container element
|
|
|
|
this.pagingTgtId = f.paging_target_id || null;
|
|
|
|
//defines table paging length
|
|
|
|
this.pagingLength = !isNaN(f.paging_length) ? f.paging_length : 10;
|
|
|
|
//id of container element
|
|
|
|
this.resultsPerPageTgtId = f.results_per_page_target_id || null;
|
|
|
|
//css class for paging select element
|
|
|
|
this.pgSlcCssClass = f.paging_slc_css_class || 'pgSlc';
|
|
|
|
//css class for paging input element
|
|
|
|
this.pgInpCssClass = f.paging_inp_css_class || 'pgNbInp';
|
|
|
|
//defines css class for results per page select
|
|
|
|
this.resultsSlcCssClass = f.results_slc_css_class || 'rspg';
|
|
|
|
//css class for label preceding results per page select
|
|
|
|
this.resultsSpanCssClass = f.results_span_css_class || 'rspgSpan';
|
|
|
|
//nb visible rows
|
|
|
|
this.nbVisibleRows = 0;
|
|
|
|
//nb hidden rows
|
|
|
|
this.nbHiddenRows = 0;
|
|
|
|
//1st row index of current page
|
|
|
|
this.startPagingRow = 0;
|
|
|
|
//total nb of pages
|
|
|
|
this.nbPages = 0;
|
|
|
|
//defines next page button text
|
|
|
|
this.btnNextPageText = f.btn_next_page_text || '>';
|
|
|
|
//defines previous page button text
|
|
|
|
this.btnPrevPageText = f.btn_prev_page_text || '<';
|
|
|
|
//defines last page button text
|
|
|
|
this.btnLastPageText = f.btn_last_page_text || '>|';
|
|
|
|
//defines first page button text
|
|
|
|
this.btnFirstPageText = f.btn_first_page_text || '|<';
|
|
|
|
//defines next page button html
|
|
|
|
this.btnNextPageHtml = f.btn_next_page_html ||
|
|
|
|
(!this.enableIcons ? null :
|
|
|
|
'<input type="button" value="" class="'+this.btnPageCssClass +
|
|
|
|
' nextPage" title="Next page" />');
|
|
|
|
//defines previous page button html
|
|
|
|
this.btnPrevPageHtml = f.btn_prev_page_html ||
|
|
|
|
(!this.enableIcons ? null :
|
|
|
|
'<input type="button" value="" class="'+this.btnPageCssClass +
|
|
|
|
' previousPage" title="Previous page" />');
|
|
|
|
//defines last page button html
|
|
|
|
this.btnFirstPageHtml = f.btn_first_page_html ||
|
|
|
|
(!this.enableIcons ? null :
|
|
|
|
'<input type="button" value="" class="'+this.btnPageCssClass +
|
|
|
|
' firstPage" title="First page" />');
|
|
|
|
//defines previous page button html
|
|
|
|
this.btnLastPageHtml = f.btn_last_page_html ||
|
|
|
|
(!this.enableIcons ? null :
|
|
|
|
'<input type="button" value="" class="'+this.btnPageCssClass +
|
|
|
|
' lastPage" title="Last page" />');
|
|
|
|
//defines text preceeding page selector drop-down
|
|
|
|
this.pageText = f.page_text || ' Page ';
|
|
|
|
//defines text after page selector drop-down
|
|
|
|
this.ofText = f.of_text || ' of ';
|
|
|
|
//css class for span containing tot nb of pages
|
|
|
|
this.nbPgSpanCssClass = f.nb_pages_css_class || 'nbpg';
|
|
|
|
//enables/disables paging buttons
|
|
|
|
this.hasPagingBtns = f.paging_btns===false ? false : true;
|
|
|
|
//stores paging buttons events
|
|
|
|
this.pagingBtnEvents = null;
|
|
|
|
//defines previous page button html
|
|
|
|
this.pageSelectorType = f.page_selector_type || this.fltTypeSlc;
|
|
|
|
//calls function before page is changed
|
2014-10-18 14:00:34 +02:00
|
|
|
this.onBeforeChangePage = types.isFn(f.on_before_change_page) ?
|
2014-09-21 14:52:12 +02:00
|
|
|
f.on_before_change_page : null;
|
|
|
|
//calls function before page is changed
|
2014-10-18 14:00:34 +02:00
|
|
|
this.onAfterChangePage = types.isFn(f.on_after_change_page) ?
|
2014-09-21 14:52:12 +02:00
|
|
|
f.on_after_change_page : null;
|
2014-09-20 15:56:35 +02:00
|
|
|
var start_row = this.refRow;
|
|
|
|
var nrows = this.nbRows;
|
2014-09-21 14:52:12 +02:00
|
|
|
//calculates page nb
|
|
|
|
this.nbPages = Math.ceil((nrows-start_row)/this.pagingLength);
|
2014-09-20 15:56:35 +02:00
|
|
|
|
|
|
|
//Paging elements events
|
2014-09-21 14:52:12 +02:00
|
|
|
if(!this.Evt._Paging.next){
|
2014-09-20 15:56:35 +02:00
|
|
|
var o = this;
|
|
|
|
this.Evt._Paging = {// paging buttons events
|
|
|
|
slcIndex: function(){
|
2014-09-22 01:18:17 +02:00
|
|
|
return (o.pageSelectorType===o.fltTypeSlc) ?
|
2014-09-21 14:52:12 +02:00
|
|
|
o.pagingSlc.options.selectedIndex :
|
|
|
|
parseInt(o.pagingSlc.value,10)-1;
|
2014-09-20 15:56:35 +02:00
|
|
|
},
|
|
|
|
nbOpts: function(){
|
2014-09-22 01:18:17 +02:00
|
|
|
return (o.pageSelectorType===o.fltTypeSlc) ?
|
|
|
|
parseInt(o.pagingSlc.options.length,10)-1 :
|
|
|
|
(o.nbPages-1);
|
2014-09-20 15:56:35 +02:00
|
|
|
},
|
|
|
|
next: function(){
|
2014-09-22 01:18:17 +02:00
|
|
|
if(o.Evt._Paging.nextEvt){
|
|
|
|
o.Evt._Paging.nextEvt();
|
|
|
|
}
|
|
|
|
var nextIndex =
|
|
|
|
o.Evt._Paging.slcIndex()<o.Evt._Paging.nbOpts() ?
|
|
|
|
o.Evt._Paging.slcIndex()+1 : 0;
|
2014-09-20 15:56:35 +02:00
|
|
|
o.ChangePage(nextIndex);
|
|
|
|
},
|
|
|
|
prev: function(){
|
2014-09-22 01:18:17 +02:00
|
|
|
if(o.Evt._Paging.prevEvt){
|
|
|
|
o.Evt._Paging.prevEvt();
|
|
|
|
}
|
|
|
|
var prevIndex = o.Evt._Paging.slcIndex()>0 ?
|
|
|
|
o.Evt._Paging.slcIndex()-1 : o.Evt._Paging.nbOpts();
|
2014-09-20 15:56:35 +02:00
|
|
|
o.ChangePage(prevIndex);
|
|
|
|
},
|
|
|
|
last: function(){
|
|
|
|
if(o.Evt._Paging.lastEvt) o.Evt._Paging.lastEvt();
|
|
|
|
o.ChangePage(o.Evt._Paging.nbOpts());
|
|
|
|
},
|
|
|
|
first: function(){
|
2014-09-22 01:18:17 +02:00
|
|
|
if(o.Evt._Paging.firstEvt){
|
|
|
|
o.Evt._Paging.firstEvt();
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
o.ChangePage(0);
|
|
|
|
},
|
2014-09-22 01:18:17 +02:00
|
|
|
_detectKey: function(e){
|
2014-10-18 14:00:34 +02:00
|
|
|
var evt = e || global.event;
|
2014-09-22 01:18:17 +02:00
|
|
|
if(evt){
|
|
|
|
var key = o.Evt.getKeyCode(e);
|
|
|
|
if(key===13){
|
|
|
|
if(o.sorted){
|
|
|
|
o.Filter();
|
|
|
|
o.ChangePage(o.Evt._Paging.slcIndex());
|
|
|
|
} else{
|
|
|
|
o.ChangePage();
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
this.blur();
|
|
|
|
}
|
2014-09-22 01:18:17 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
},
|
|
|
|
nextEvt: null,
|
|
|
|
prevEvt: null,
|
|
|
|
lastEvt: null,
|
|
|
|
firstEvt: null
|
2014-09-21 14:52:12 +02:00
|
|
|
};
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-22 01:18:17 +02:00
|
|
|
/*====================================================
|
|
|
|
- onchange event for paging select
|
|
|
|
=====================================================*/
|
|
|
|
if(!this.Evt._OnSlcPagesChange){
|
|
|
|
this.Evt._OnSlcPagesChange = function(){
|
|
|
|
if(o.Evt._Paging._OnSlcPagesChangeEvt){
|
2014-09-20 15:56:35 +02:00
|
|
|
o.Evt._Paging._OnSlcPagesChangeEvt();
|
2014-09-22 01:18:17 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
o.ChangePage();
|
|
|
|
this.blur();
|
|
|
|
//ie only: blur is not enough...
|
2014-11-01 15:34:37 +01:00
|
|
|
if(this.parentNode && hlp.isIE()){
|
2014-09-20 15:56:35 +02:00
|
|
|
this.parentNode.focus();
|
2014-09-22 01:18:17 +02:00
|
|
|
}
|
|
|
|
};
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-24 08:06:12 +02:00
|
|
|
var slcPages;
|
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
// Paging drop-down list selector
|
2014-09-22 01:18:17 +02:00
|
|
|
if(this.pageSelectorType === this.fltTypeSlc){
|
2014-10-18 14:00:34 +02:00
|
|
|
slcPages = dom.create(
|
2014-09-22 01:18:17 +02:00
|
|
|
this.fltTypeSlc, ['id',this.prfxSlcPages+this.id]);
|
2014-09-20 15:56:35 +02:00
|
|
|
slcPages.className = this.pgSlcCssClass;
|
|
|
|
slcPages.onchange = this.Evt._OnSlcPagesChange;
|
|
|
|
}
|
2014-09-22 01:18:17 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
// Paging input selector
|
2014-09-22 01:18:17 +02:00
|
|
|
if(this.pageSelectorType === this.fltTypeInp){
|
2014-10-18 14:00:34 +02:00
|
|
|
slcPages = dom.create(
|
2014-09-20 15:56:35 +02:00
|
|
|
this.fltTypeInp,
|
|
|
|
['id',this.prfxSlcPages+this.id],
|
|
|
|
['value',this.currentPageNb]
|
|
|
|
);
|
|
|
|
slcPages.className = this.pgInpCssClass;
|
|
|
|
slcPages.onkeypress = this.Evt._Paging._detectKey;
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-22 01:18:17 +02:00
|
|
|
// btns containers
|
2014-10-18 14:00:34 +02:00
|
|
|
var btnNextSpan = dom.create(
|
2014-09-22 01:18:17 +02:00
|
|
|
'span',['id',this.prfxBtnNextSpan+this.id]);
|
2014-10-18 14:00:34 +02:00
|
|
|
var btnPrevSpan = dom.create(
|
2014-09-22 01:18:17 +02:00
|
|
|
'span',['id',this.prfxBtnPrevSpan+this.id]);
|
2014-10-18 14:00:34 +02:00
|
|
|
var btnLastSpan = dom.create(
|
2014-09-22 01:18:17 +02:00
|
|
|
'span',['id',this.prfxBtnLastSpan+this.id]);
|
2014-10-18 14:00:34 +02:00
|
|
|
var btnFirstSpan = dom.create(
|
2014-09-22 01:18:17 +02:00
|
|
|
'span',['id',this.prfxBtnFirstSpan+this.id]);
|
|
|
|
|
|
|
|
if(this.hasPagingBtns){
|
|
|
|
// Next button
|
|
|
|
if(!this.btnNextPageHtml){
|
2014-10-18 14:00:34 +02:00
|
|
|
var btn_next = dom.create(
|
2014-09-22 01:18:17 +02:00
|
|
|
this.fltTypeInp,['id',this.prfxBtnNext+this.id],
|
|
|
|
['type','button'],
|
|
|
|
['value',this.btnNextPageText],
|
|
|
|
['title','Next']
|
|
|
|
);
|
2014-09-20 15:56:35 +02:00
|
|
|
btn_next.className = this.btnPageCssClass;
|
|
|
|
btn_next.onclick = this.Evt._Paging.next;
|
|
|
|
btnNextSpan.appendChild(btn_next);
|
|
|
|
} else {
|
|
|
|
btnNextSpan.innerHTML = this.btnNextPageHtml;
|
|
|
|
btnNextSpan.onclick = this.Evt._Paging.next;
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
2014-09-22 01:18:17 +02:00
|
|
|
// Previous button
|
|
|
|
if(!this.btnPrevPageHtml){
|
2014-10-18 14:00:34 +02:00
|
|
|
var btn_prev = dom.create(
|
2014-09-22 01:18:17 +02:00
|
|
|
this.fltTypeInp,
|
|
|
|
['id',this.prfxBtnPrev+this.id],
|
|
|
|
['type','button'],
|
|
|
|
['value',this.btnPrevPageText],
|
|
|
|
['title','Previous']
|
|
|
|
);
|
2014-09-20 15:56:35 +02:00
|
|
|
btn_prev.className = this.btnPageCssClass;
|
|
|
|
btn_prev.onclick = this.Evt._Paging.prev;
|
|
|
|
btnPrevSpan.appendChild(btn_prev);
|
|
|
|
} else {
|
|
|
|
btnPrevSpan.innerHTML = this.btnPrevPageHtml;
|
|
|
|
btnPrevSpan.onclick = this.Evt._Paging.prev;
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
2014-09-22 01:18:17 +02:00
|
|
|
// Last button
|
|
|
|
if(!this.btnLastPageHtml){
|
2014-10-18 14:00:34 +02:00
|
|
|
var btn_last = dom.create(
|
2014-09-22 01:18:17 +02:00
|
|
|
this.fltTypeInp,
|
|
|
|
['id',this.prfxBtnLast+this.id],
|
|
|
|
['type','button'],
|
|
|
|
['value',this.btnLastPageText],
|
|
|
|
['title','Last']
|
|
|
|
);
|
2014-09-20 15:56:35 +02:00
|
|
|
btn_last.className = this.btnPageCssClass;
|
|
|
|
btn_last.onclick = this.Evt._Paging.last;
|
|
|
|
btnLastSpan.appendChild(btn_last);
|
|
|
|
} else {
|
|
|
|
btnLastSpan.innerHTML = this.btnLastPageHtml;
|
|
|
|
btnLastSpan.onclick = this.Evt._Paging.last;
|
|
|
|
}
|
2014-09-22 01:18:17 +02:00
|
|
|
// First button
|
|
|
|
if(!this.btnFirstPageHtml){
|
2014-10-18 14:00:34 +02:00
|
|
|
var btn_first = dom.create(
|
2014-09-22 01:18:17 +02:00
|
|
|
this.fltTypeInp,
|
|
|
|
['id',this.prfxBtnFirst+this.id],
|
|
|
|
['type','button'],
|
|
|
|
['value',this.btnFirstPageText],
|
|
|
|
['title','First']
|
|
|
|
);
|
2014-09-20 15:56:35 +02:00
|
|
|
btn_first.className = this.btnPageCssClass;
|
|
|
|
btn_first.onclick = this.Evt._Paging.first;
|
|
|
|
btnFirstSpan.appendChild(btn_first);
|
|
|
|
} else {
|
|
|
|
btnFirstSpan.innerHTML = this.btnFirstPageHtml;
|
|
|
|
btnFirstSpan.onclick = this.Evt._Paging.first;
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
2014-09-22 01:18:17 +02:00
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
// paging elements (buttons+drop-down list) are added to defined element
|
2014-09-22 01:18:17 +02:00
|
|
|
if(!this.pagingTgtId){
|
|
|
|
this.SetTopDiv();
|
|
|
|
}
|
2014-11-01 15:34:37 +01:00
|
|
|
var targetEl = !this.pagingTgtId ? this.mDiv : dom.id(this.pagingTgtId);
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-22 01:18:17 +02:00
|
|
|
/***
|
|
|
|
if paging previously removed this prevents IE memory leak with
|
|
|
|
removeChild used in RemovePaging method. For more info refer to
|
|
|
|
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2840253&SiteID=1
|
|
|
|
***/
|
|
|
|
if (targetEl.innerHTML!==''){
|
|
|
|
targetEl.innerHTML = '';
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
/*** ***/
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
targetEl.appendChild(btnFirstSpan);
|
|
|
|
targetEl.appendChild(btnPrevSpan);
|
|
|
|
|
2014-10-18 14:00:34 +02:00
|
|
|
var pgBeforeSpan = dom.create(
|
2014-09-22 01:18:17 +02:00
|
|
|
'span',['id',this.prfxPgBeforeSpan+this.id] );
|
2014-10-18 14:00:34 +02:00
|
|
|
pgBeforeSpan.appendChild( dom.text(this.pageText) );
|
2014-09-20 15:56:35 +02:00
|
|
|
pgBeforeSpan.className = this.nbPgSpanCssClass;
|
|
|
|
targetEl.appendChild(pgBeforeSpan);
|
|
|
|
targetEl.appendChild(slcPages);
|
2014-10-18 14:00:34 +02:00
|
|
|
var pgAfterSpan = dom.create(
|
2014-09-22 01:18:17 +02:00
|
|
|
'span',['id',this.prfxPgAfterSpan+this.id]);
|
2014-10-18 14:00:34 +02:00
|
|
|
pgAfterSpan.appendChild( dom.text(this.ofText) );
|
2014-09-20 15:56:35 +02:00
|
|
|
pgAfterSpan.className = this.nbPgSpanCssClass;
|
2014-10-06 13:08:29 +02:00
|
|
|
targetEl.appendChild(pgAfterSpan);
|
2014-10-18 14:00:34 +02:00
|
|
|
var pgspan = dom.create( 'span',['id',this.prfxPgSpan+this.id] );
|
2014-09-20 15:56:35 +02:00
|
|
|
pgspan.className = this.nbPgSpanCssClass;
|
2014-10-18 14:00:34 +02:00
|
|
|
pgspan.appendChild( dom.text(' '+this.nbPages+' ') );
|
2014-09-20 15:56:35 +02:00
|
|
|
targetEl.appendChild(pgspan);
|
|
|
|
targetEl.appendChild(btnNextSpan);
|
|
|
|
targetEl.appendChild(btnLastSpan);
|
2014-11-01 15:34:37 +01:00
|
|
|
this.pagingSlc = dom.id(this.prfxSlcPages+this.id);
|
2014-09-20 15:56:35 +02:00
|
|
|
|
|
|
|
// if this.rememberGridValues==true this.SetPagingInfo() is called
|
|
|
|
// in ResetGridValues() method
|
2014-09-22 01:18:17 +02:00
|
|
|
if(!this.rememberGridValues || this.isPagingRemoved){
|
2014-09-20 15:56:35 +02:00
|
|
|
this.SetPagingInfo();
|
2014-09-22 01:18:17 +02:00
|
|
|
}
|
|
|
|
if(!this.fltGrid){
|
2014-09-20 15:56:35 +02:00
|
|
|
this.ValidateAllRows();
|
|
|
|
this.SetPagingInfo(this.validRowsIndex);
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
this.pagingBtnEvents = this.Evt._Paging;
|
|
|
|
this.isPagingRemoved = false;
|
|
|
|
},
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
/*====================================================
|
|
|
|
- Removes paging elements
|
|
|
|
=====================================================*/
|
2014-09-24 08:06:12 +02:00
|
|
|
RemovePaging: function(){
|
|
|
|
if(!this.hasGrid || !this.pagingSlc){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// btns containers
|
|
|
|
var btnNextSpan, btnPrevSpan, btnLastSpan, btnFirstSpan;
|
2014-09-20 15:56:35 +02:00
|
|
|
var pgBeforeSpan, pgAfterSpan, pgspan;
|
2014-11-01 15:34:37 +01:00
|
|
|
btnNextSpan = dom.id(this.prfxBtnNextSpan+this.id);
|
|
|
|
btnPrevSpan = dom.id(this.prfxBtnPrevSpan+this.id);
|
|
|
|
btnLastSpan = dom.id(this.prfxBtnLastSpan+this.id);
|
|
|
|
btnFirstSpan = dom.id(this.prfxBtnFirstSpan+this.id);
|
2014-09-24 08:06:12 +02:00
|
|
|
//span containing 'Page' text
|
2014-11-01 15:34:37 +01:00
|
|
|
pgBeforeSpan = dom.id(this.prfxPgBeforeSpan+this.id);
|
2014-09-24 08:06:12 +02:00
|
|
|
//span containing 'of' text
|
2014-11-01 15:34:37 +01:00
|
|
|
pgAfterSpan = dom.id(this.prfxPgAfterSpan+this.id);
|
2014-09-24 08:06:12 +02:00
|
|
|
//span containing nb of pages
|
2014-11-01 15:34:37 +01:00
|
|
|
pgspan = dom.id(this.prfxPgSpan+this.id);
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
this.pagingSlc.parentNode.removeChild(this.pagingSlc);
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-24 08:06:12 +02:00
|
|
|
if(btnNextSpan){
|
2014-09-20 15:56:35 +02:00
|
|
|
btnNextSpan.parentNode.removeChild( btnNextSpan );
|
2014-09-24 08:06:12 +02:00
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-24 08:06:12 +02:00
|
|
|
if(btnPrevSpan){
|
2014-09-20 15:56:35 +02:00
|
|
|
btnPrevSpan.parentNode.removeChild( btnPrevSpan );
|
2014-09-24 08:06:12 +02:00
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-24 08:06:12 +02:00
|
|
|
if(btnLastSpan){
|
2014-09-20 15:56:35 +02:00
|
|
|
btnLastSpan.parentNode.removeChild( btnLastSpan );
|
2014-09-24 08:06:12 +02:00
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-24 08:06:12 +02:00
|
|
|
if(btnFirstSpan){
|
2014-09-20 15:56:35 +02:00
|
|
|
btnFirstSpan.parentNode.removeChild( btnFirstSpan );
|
2014-09-24 08:06:12 +02:00
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-24 08:06:12 +02:00
|
|
|
if(pgBeforeSpan){
|
2014-09-20 15:56:35 +02:00
|
|
|
pgBeforeSpan.parentNode.removeChild( pgBeforeSpan );
|
2014-09-24 08:06:12 +02:00
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-24 08:06:12 +02:00
|
|
|
if(pgAfterSpan){
|
2014-09-20 15:56:35 +02:00
|
|
|
pgAfterSpan.parentNode.removeChild( pgAfterSpan );
|
2014-09-24 08:06:12 +02:00
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-24 08:06:12 +02:00
|
|
|
if(pgspan){
|
2014-09-20 15:56:35 +02:00
|
|
|
pgspan.parentNode.removeChild( pgspan );
|
2014-09-24 08:06:12 +02:00
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
this.pagingBtnEvents = null;
|
|
|
|
this.pagingSlc = null;
|
|
|
|
this.isPagingRemoved = true;
|
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- calculates page # according to valid rows
|
|
|
|
- refreshes paging select according to page #
|
|
|
|
- Calls GroupByPage method
|
|
|
|
=====================================================*/
|
2014-09-24 08:06:12 +02:00
|
|
|
SetPagingInfo: function(validRows){
|
|
|
|
var rows = this.tbl.rows;
|
2014-11-01 15:34:37 +01:00
|
|
|
var mdiv = !this.pagingTgtId ? this.mDiv : dom.id(this.pagingTgtId);
|
|
|
|
var pgspan = dom.id(this.prfxPgSpan+this.id);
|
2014-09-24 08:06:12 +02:00
|
|
|
//stores valid rows indexes
|
|
|
|
if(validRows && validRows.length>0){
|
|
|
|
this.validRowsIndex = validRows;
|
|
|
|
} else {
|
|
|
|
//re-sets valid rows indexes array
|
|
|
|
this.validRowsIndex = [];
|
2014-09-20 15:56:35 +02:00
|
|
|
|
2014-09-24 08:06:12 +02:00
|
|
|
//counts rows to be grouped
|
|
|
|
for(var j=this.refRow; j<this.nbRows; j++){
|
|
|
|
var row = rows[j];
|
|
|
|
if(!row){
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
var isRowValid = row.getAttribute('validRow');
|
|
|
|
if(isRowValid==='true' || !isRowValid){
|
|
|
|
this.validRowsIndex.push(j);
|
|
|
|
}
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-24 08:06:12 +02:00
|
|
|
//calculate nb of pages
|
|
|
|
this.nbPages = Math.ceil(this.validRowsIndex.length/this.pagingLength);
|
|
|
|
//refresh page nb span
|
|
|
|
pgspan.innerHTML = this.nbPages;
|
|
|
|
//select clearing shortcut
|
|
|
|
if(this.pageSelectorType===this.fltTypeSlc){
|
|
|
|
this.pagingSlc.innerHTML = '';
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-24 08:06:12 +02:00
|
|
|
if(this.nbPages>0){
|
2014-09-20 15:56:35 +02:00
|
|
|
mdiv.style.visibility = 'visible';
|
2014-09-24 08:06:12 +02:00
|
|
|
if(this.pageSelectorType===this.fltTypeSlc){
|
|
|
|
for(var z=0; z<this.nbPages; z++){
|
|
|
|
var currOpt = new Option(
|
|
|
|
(z+1),
|
|
|
|
z*this.pagingLength,
|
|
|
|
false,
|
|
|
|
false
|
|
|
|
);
|
2014-09-20 15:56:35 +02:00
|
|
|
this.pagingSlc.options[z] = currOpt;
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
2014-09-24 08:06:12 +02:00
|
|
|
} else{
|
|
|
|
//input type
|
|
|
|
this.pagingSlc.value = this.currentPageNb;
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-24 08:06:12 +02:00
|
|
|
} else {
|
|
|
|
/*** if no results paging select and buttons are hidden ***/
|
2014-09-20 15:56:35 +02:00
|
|
|
mdiv.style.visibility = 'hidden';
|
|
|
|
}
|
2014-09-24 08:06:12 +02:00
|
|
|
this.GroupByPage(this.validRowsIndex);
|
2014-09-20 15:56:35 +02:00
|
|
|
},
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
/*====================================================
|
|
|
|
- Displays current page rows
|
|
|
|
=====================================================*/
|
2014-09-24 08:06:12 +02:00
|
|
|
GroupByPage: function(validRows){
|
|
|
|
var rows = this.tbl.rows;
|
|
|
|
var paging_end_row = parseInt(this.startPagingRow, 10) +
|
|
|
|
parseInt(this.pagingLength, 10);
|
2014-09-20 15:56:35 +02:00
|
|
|
|
2014-09-24 08:06:12 +02:00
|
|
|
//store valid rows indexes
|
|
|
|
if(validRows){
|
|
|
|
this.validRowsIndex = validRows;
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-24 08:06:12 +02:00
|
|
|
//this loop shows valid rows of current page
|
|
|
|
for(var h=0; h<this.validRowsIndex.length; h++){
|
|
|
|
var r = rows[ this.validRowsIndex[h] ];
|
|
|
|
if(h>=this.startPagingRow && h<paging_end_row){
|
|
|
|
if(r.getAttribute('validRow')==='true' ||
|
|
|
|
!r.getAttribute('validRow')){
|
2014-09-20 15:56:35 +02:00
|
|
|
r.style.display = '';
|
2014-09-24 08:06:12 +02:00
|
|
|
}
|
|
|
|
if(this.alternateBgs){
|
2014-11-09 09:31:15 +01:00
|
|
|
this.Cpt.alternateRows(this.validRowsIndex[h], h);
|
2014-09-24 08:06:12 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
} else {
|
2014-09-24 08:06:12 +02:00
|
|
|
r.style.display = 'none';
|
|
|
|
if(this.alternateBgs){
|
2014-11-09 09:31:15 +01:00
|
|
|
this.Cpt.alternateRows.removeRowBg(this.validRowsIndex[h]);
|
2014-09-24 08:06:12 +02:00
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
this.nbVisibleRows = this.validRowsIndex.length;
|
|
|
|
this.isStartBgAlternate = false;
|
2014-09-24 08:06:12 +02:00
|
|
|
//re-applies filter behaviours after filtering process
|
|
|
|
this.ApplyGridProps();
|
2014-09-20 15:56:35 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- If paging set true shows page according to
|
|
|
|
param value (string or number):
|
|
|
|
- strings: 'next','previous','last','first' or
|
|
|
|
- number: page number
|
|
|
|
=====================================================*/
|
2014-09-24 08:06:12 +02:00
|
|
|
SetPage: function(cmd){
|
|
|
|
if(!this.hasGrid || !this.paging){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
var btnEvt = this.pagingBtnEvents,
|
|
|
|
cmdtype = typeof cmd;
|
|
|
|
if(cmdtype==='string'){
|
2014-10-18 14:00:34 +02:00
|
|
|
switch(str.lower(cmd)){
|
2014-09-24 08:06:12 +02:00
|
|
|
case 'next':
|
|
|
|
btnEvt.next();
|
|
|
|
break;
|
|
|
|
case 'previous':
|
|
|
|
btnEvt.prev();
|
|
|
|
break;
|
|
|
|
case 'last':
|
|
|
|
btnEvt.last();
|
|
|
|
break;
|
|
|
|
case 'first':
|
|
|
|
btnEvt.first();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
btnEvt.next();
|
|
|
|
break;
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
2014-09-24 08:06:12 +02:00
|
|
|
}
|
|
|
|
if(cmdtype==='number'){
|
|
|
|
this.ChangePage(cmd-1);
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- Generates results per page select + label
|
|
|
|
=====================================================*/
|
2014-09-24 08:06:12 +02:00
|
|
|
SetResultsPerPage: function(){
|
|
|
|
if(!this.hasGrid && !this.isFirstLoad){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(this.resultsPerPageSlc || !this.resultsPerPage){
|
|
|
|
return;
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
//Change nb results per page event
|
2014-09-24 08:06:12 +02:00
|
|
|
if(!this.Evt._OnSlcResultsChange){
|
2014-09-20 15:56:35 +02:00
|
|
|
var o = this;
|
|
|
|
/*====================================================
|
|
|
|
- onchange event for results per page select
|
|
|
|
=====================================================*/
|
2014-09-24 08:06:12 +02:00
|
|
|
this.Evt._OnSlcResultsChange = function(){
|
2014-09-20 15:56:35 +02:00
|
|
|
o.ChangeResultsPerPage();
|
|
|
|
this.blur();
|
|
|
|
//ie only: blur is not enough...
|
2014-11-01 15:34:37 +01:00
|
|
|
if(this.parentNode && hlp.isIE()){
|
2014-09-20 15:56:35 +02:00
|
|
|
this.parentNode.focus();
|
2014-09-24 08:06:12 +02:00
|
|
|
}
|
|
|
|
};
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-10-18 14:00:34 +02:00
|
|
|
var slcR = dom.create(
|
2014-09-24 08:06:12 +02:00
|
|
|
this.fltTypeSlc, ['id',this.prfxSlcResults+this.id]);
|
2014-09-20 15:56:35 +02:00
|
|
|
slcR.className = this.resultsSlcCssClass;
|
2014-09-24 08:06:12 +02:00
|
|
|
var slcRText = this.resultsPerPage[0],
|
|
|
|
slcROpts = this.resultsPerPage[1];
|
2014-10-18 14:00:34 +02:00
|
|
|
var slcRSpan = dom.create(
|
2014-09-24 08:06:12 +02:00
|
|
|
'span',['id',this.prfxSlcResultsTxt+this.id]);
|
2014-09-20 15:56:35 +02:00
|
|
|
slcRSpan.className = this.resultsSpanCssClass;
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-24 08:06:12 +02:00
|
|
|
// results per page select is added to external element
|
|
|
|
if(!this.resultsPerPageTgtId){
|
|
|
|
this.SetTopDiv();
|
|
|
|
}
|
2014-10-10 15:34:45 +02:00
|
|
|
var targetEl = !this.resultsPerPageTgtId ?
|
2014-11-01 15:34:37 +01:00
|
|
|
this.rDiv : dom.id( this.resultsPerPageTgtId );
|
2014-10-18 14:00:34 +02:00
|
|
|
slcRSpan.appendChild(dom.text(slcRText));
|
2014-09-20 15:56:35 +02:00
|
|
|
targetEl.appendChild(slcRSpan);
|
|
|
|
targetEl.appendChild(slcR);
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-11-01 15:34:37 +01:00
|
|
|
this.resultsPerPageSlc = dom.id(this.prfxSlcResults+this.id);
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
for(var r=0; r<slcROpts.length; r++)
|
|
|
|
{
|
|
|
|
var currOpt = new Option(slcROpts[r],slcROpts[r],false,false);
|
|
|
|
this.resultsPerPageSlc.options[r] = currOpt;
|
|
|
|
}
|
|
|
|
slcR.onchange = this.Evt._OnSlcResultsChange;
|
|
|
|
},
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
/*====================================================
|
|
|
|
- Removes results per page select + label
|
|
|
|
=====================================================*/
|
2014-09-24 09:10:31 +02:00
|
|
|
RemoveResultsPerPage: function(){
|
|
|
|
if(!this.hasGrid || !this.resultsPerPageSlc || !this.resultsPerPage){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
var slcR = this.resultsPerPageSlc,
|
2014-11-01 15:34:37 +01:00
|
|
|
slcRSpan = dom.id(this.prfxSlcResultsTxt+this.id);
|
2014-09-24 09:10:31 +02:00
|
|
|
if(slcR){
|
2014-09-20 15:56:35 +02:00
|
|
|
slcR.parentNode.removeChild( slcR );
|
2014-09-24 09:10:31 +02:00
|
|
|
}
|
|
|
|
if(slcRSpan){
|
2014-09-20 15:56:35 +02:00
|
|
|
slcRSpan.parentNode.removeChild( slcRSpan );
|
2014-09-24 09:10:31 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
this.resultsPerPageSlc = null;
|
|
|
|
},
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
/*====================================================
|
|
|
|
- Generates help instructions
|
|
|
|
=====================================================*/
|
2014-09-24 09:10:31 +02:00
|
|
|
SetHelpInstructions: function(){
|
|
|
|
if(this.helpInstrBtnEl){
|
|
|
|
return;
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
var f = this.fObj;
|
2014-09-24 09:10:31 +02:00
|
|
|
//id of custom container element for instructions
|
|
|
|
this.helpInstrTgtId = f.help_instructions_target_id || null;
|
|
|
|
//id of custom container element for instructions
|
|
|
|
this.helpInstrContTgtId = f.help_instructions_container_target_id ||
|
|
|
|
null;
|
|
|
|
//defines help text
|
|
|
|
this.helpInstrText = f.help_instructions_text ?
|
|
|
|
f.help_instructions_text :
|
|
|
|
'Use the filters above each column to filter and limit table ' +
|
|
|
|
'data. Avanced searches can be performed by using the following ' +
|
|
|
|
'operators: <br /><b><</b>, <b><=</b>, <b>></b>, ' +
|
|
|
|
'<b>>=</b>, <b>=</b>, <b>*</b>, <b>!</b>, <b>{</b>, <b>}</b>, ' +
|
|
|
|
'<b>||</b>,<b>&&</b>, <b>[empty]</b>, <b>[nonempty]</b>, ' +
|
|
|
|
'<b>rgx:</b><br/> These operators are described here:<br/>' +
|
|
|
|
'<a href="http://tablefilter.free.fr/#operators" ' +
|
|
|
|
'target="_blank">http://tablefilter.free.fr/#operators</a><hr/>';
|
|
|
|
//defines help innerHtml
|
|
|
|
this.helpInstrHtml = f.help_instructions_html || null;
|
|
|
|
//defines reset button text
|
|
|
|
this.helpInstrBtnText = f.help_instructions_btn_text || '?';
|
|
|
|
//defines reset button innerHtml
|
|
|
|
this.helpInstrBtnHtml = f.help_instructions_btn_html || null;
|
|
|
|
//defines css class for help button
|
|
|
|
this.helpInstrBtnCssClass = f.help_instructions_btn_css_class ||
|
|
|
|
'helpBtn';
|
|
|
|
//defines css class for help container
|
|
|
|
this.helpInstrContCssClass = f.help_instructions_container_css_class ||
|
|
|
|
'helpCont';
|
|
|
|
//help button element
|
|
|
|
this.helpInstrBtnEl = null;
|
|
|
|
//help content div
|
|
|
|
this.helpInstrContEl = null;
|
|
|
|
this.helpInstrDefaultHtml = '<div class="helpFooter"><h4>HTML Table ' +
|
|
|
|
'Filter Generator v. '+ this.version +'</h4>' +
|
|
|
|
'<a href="http://tablefilter.free.fr" target="_blank">' +
|
|
|
|
'http://tablefilter.free.fr</a><br/>' +
|
|
|
|
'<span>©2009-'+ this.year +' Max Guglielmi.</span>' +
|
|
|
|
'<div align="center" style="margin-top:8px;">' +
|
|
|
|
'<a href="javascript:;" onclick="window[\'tf_'+ this.id +
|
|
|
|
'\']._ToggleHelp();">Close</a></div></div>';
|
2014-09-20 15:56:35 +02:00
|
|
|
|
2014-10-18 14:00:34 +02:00
|
|
|
var helpspan = dom.create('span',['id',this.prfxHelpSpan+this.id]);
|
|
|
|
var helpdiv = dom.create('div',['id',this.prfxHelpDiv+this.id]);
|
2014-09-20 15:56:35 +02:00
|
|
|
|
|
|
|
//help button is added to defined element
|
2014-09-24 09:10:31 +02:00
|
|
|
if(!this.helpInstrTgtId){
|
|
|
|
this.SetTopDiv();
|
|
|
|
}
|
|
|
|
var targetEl = !this.helpInstrTgtId ?
|
2014-11-01 15:34:37 +01:00
|
|
|
this.rDiv : dom.id(this.helpInstrTgtId);
|
2014-09-20 15:56:35 +02:00
|
|
|
targetEl.appendChild(helpspan);
|
|
|
|
|
2014-09-24 09:10:31 +02:00
|
|
|
var divContainer = !this.helpInstrContTgtId ?
|
2014-11-01 15:34:37 +01:00
|
|
|
helpspan : dom.id( this.helpInstrContTgtId );
|
2014-09-20 15:56:35 +02:00
|
|
|
|
2014-09-24 09:10:31 +02:00
|
|
|
if(!this.helpInstrBtnHtml){
|
2014-09-20 15:56:35 +02:00
|
|
|
divContainer.appendChild(helpdiv);
|
2014-10-18 14:00:34 +02:00
|
|
|
var helplink = dom.create('a', ['href', 'javascript:void(0);']);
|
2014-09-20 15:56:35 +02:00
|
|
|
helplink.className = this.helpInstrBtnCssClass;
|
2014-10-18 14:00:34 +02:00
|
|
|
helplink.appendChild(dom.text(this.helpInstrBtnText));
|
2014-09-20 15:56:35 +02:00
|
|
|
helpspan.appendChild(helplink);
|
|
|
|
helplink.onclick = this.Evt._OnHelpBtnClick;
|
|
|
|
} else {
|
|
|
|
helpspan.innerHTML = this.helpInstrBtnHtml;
|
|
|
|
var helpEl = helpspan.firstChild;
|
|
|
|
helpEl.onclick = this.Evt._OnHelpBtnClick;
|
|
|
|
divContainer.appendChild(helpdiv);
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-24 09:10:31 +02:00
|
|
|
if(!this.helpInstrHtml){
|
2014-09-20 15:56:35 +02:00
|
|
|
helpdiv.innerHTML = this.helpInstrText;
|
|
|
|
helpdiv.className = this.helpInstrContCssClass;
|
|
|
|
helpdiv.ondblclick = this.Evt._OnHelpBtnClick;
|
|
|
|
} else {
|
|
|
|
if(this.helpInstrContTgtId) divContainer.appendChild(helpdiv);
|
|
|
|
helpdiv.innerHTML = this.helpInstrHtml;
|
|
|
|
if(!this.helpInstrContTgtId){
|
|
|
|
helpdiv.className = this.helpInstrContCssClass;
|
|
|
|
helpdiv.ondblclick = this.Evt._OnHelpBtnClick;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
helpdiv.innerHTML += this.helpInstrDefaultHtml;
|
|
|
|
this.helpInstrContEl = helpdiv;
|
|
|
|
this.helpInstrBtnEl = helpspan;
|
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- Removes help instructions
|
|
|
|
=====================================================*/
|
2014-09-24 09:10:31 +02:00
|
|
|
RemoveHelpInstructions: function() {
|
|
|
|
if(!this.helpInstrBtnEl){
|
|
|
|
return;
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
this.helpInstrBtnEl.parentNode.removeChild(this.helpInstrBtnEl);
|
|
|
|
this.helpInstrBtnEl = null;
|
2014-09-24 09:10:31 +02:00
|
|
|
if(!this.helpInstrContEl){
|
|
|
|
return;
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
this.helpInstrContEl.parentNode.removeChild(this.helpInstrContEl);
|
|
|
|
this.helpInstrContEl = null;
|
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- Toggles help div
|
|
|
|
=====================================================*/
|
2014-09-24 09:10:31 +02:00
|
|
|
_ToggleHelp: function(){
|
|
|
|
if(!this.helpInstrContEl){
|
|
|
|
return;
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
var divDisplay = this.helpInstrContEl.style.display;
|
2014-09-24 09:10:31 +02:00
|
|
|
if(divDisplay==='' || divDisplay==='none'){
|
2014-09-20 15:56:35 +02:00
|
|
|
this.helpInstrContEl.style.display = 'block';
|
2014-10-18 14:00:34 +02:00
|
|
|
var btnLeft = dom.position(this.helpInstrBtnEl).left;
|
2014-09-24 09:10:31 +02:00
|
|
|
if(!this.helpInstrContTgtId){
|
|
|
|
this.helpInstrContEl.style.left =
|
|
|
|
(btnLeft - this.helpInstrContEl.clientWidth + 25) + 'px';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
this.helpInstrContEl.style.display = 'none';
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
|
|
|
},
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-24 09:10:31 +02:00
|
|
|
ChangePage: function(index){
|
2014-09-20 15:56:35 +02:00
|
|
|
this.EvtManager(this.Evt.name.changepage,{ pgIndex:index });
|
|
|
|
},
|
|
|
|
/*====================================================
|
|
|
|
- Changes page
|
|
|
|
- Param:
|
|
|
|
- index: option index of paging select
|
|
|
|
(numeric value)
|
|
|
|
=====================================================*/
|
2014-09-24 09:10:31 +02:00
|
|
|
_ChangePage: function(index){
|
|
|
|
if(!this.paging){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(!index){
|
|
|
|
index = this.pageSelectorType===this.fltTypeSlc ?
|
2014-09-20 15:56:35 +02:00
|
|
|
this.pagingSlc.options.selectedIndex : (this.pagingSlc.value-1);
|
2014-09-24 09:10:31 +02:00
|
|
|
}
|
|
|
|
if( index>=0 && index<=(this.nbPages-1) ){
|
|
|
|
if(this.onBeforeChangePage){
|
|
|
|
this.onBeforeChangePage.call(null, this, index);
|
|
|
|
}
|
2014-10-06 13:08:29 +02:00
|
|
|
this.currentPageNb = parseInt(index, 10)+1;
|
2014-09-24 09:10:31 +02:00
|
|
|
if(this.pageSelectorType===this.fltTypeSlc){
|
2014-09-20 15:56:35 +02:00
|
|
|
this.pagingSlc.options[index].selected = true;
|
2014-09-24 09:10:31 +02:00
|
|
|
} else {
|
2014-09-20 15:56:35 +02:00
|
|
|
this.pagingSlc.value = this.currentPageNb;
|
2014-09-24 09:10:31 +02:00
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-24 09:10:31 +02:00
|
|
|
if(this.rememberPageNb){
|
|
|
|
this.RememberPageNb(this.pgNbCookie);
|
|
|
|
}
|
|
|
|
this.startPagingRow = (this.pageSelectorType===this.fltTypeSlc) ?
|
|
|
|
this.pagingSlc.value : (index*this.pagingLength);
|
2014-09-20 15:56:35 +02:00
|
|
|
this.GroupByPage();
|
2014-09-24 09:10:31 +02:00
|
|
|
if(this.onAfterChangePage){
|
|
|
|
this.onAfterChangePage.call(null, this, index);
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
|
|
|
},
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-24 09:10:31 +02:00
|
|
|
ChangeResultsPerPage: function(){
|
2014-09-20 15:56:35 +02:00
|
|
|
this.EvtManager(this.Evt.name.changeresultsperpage);
|
|
|
|
},
|
|
|
|
/*====================================================
|
|
|
|
- calculates rows to be displayed in a page
|
|
|
|
- method called by nb results per page select
|
|
|
|
=====================================================*/
|
2014-09-24 09:10:31 +02:00
|
|
|
_ChangeResultsPerPage: function(){
|
|
|
|
if(!this.paging){
|
|
|
|
return;
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
var slcR = this.resultsPerPageSlc;
|
2014-09-24 09:10:31 +02:00
|
|
|
var slcPagesSelIndex = (this.pageSelectorType==this.fltTypeSlc) ?
|
|
|
|
this.pagingSlc.selectedIndex :
|
|
|
|
parseInt(this.pagingSlc.value-1,10);
|
|
|
|
this.pagingLength = parseInt(slcR.options[slcR.selectedIndex].value,10);
|
2014-09-20 15:56:35 +02:00
|
|
|
this.startPagingRow = this.pagingLength*slcPagesSelIndex;
|
|
|
|
|
2014-09-24 09:10:31 +02:00
|
|
|
if(!isNaN(this.pagingLength)){
|
|
|
|
if(this.startPagingRow>=this.nbFilterableRows){
|
2014-09-20 15:56:35 +02:00
|
|
|
this.startPagingRow = (this.nbFilterableRows-this.pagingLength);
|
2014-09-24 09:10:31 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
this.SetPagingInfo();
|
|
|
|
|
2014-09-24 09:10:31 +02:00
|
|
|
if(this.pageSelectorType===this.fltTypeSlc){
|
|
|
|
var slcIndex =
|
|
|
|
(this.pagingSlc.options.length-1<=slcPagesSelIndex ) ?
|
|
|
|
(this.pagingSlc.options.length-1) : slcPagesSelIndex;
|
2014-09-20 15:56:35 +02:00
|
|
|
this.pagingSlc.options[slcIndex].selected = true;
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
2014-09-24 09:10:31 +02:00
|
|
|
if(this.rememberPageLen){
|
|
|
|
this.RememberPageLength( this.pgLenCookie );
|
|
|
|
}
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
},
|
|
|
|
|
2014-09-24 09:10:31 +02:00
|
|
|
ResetPage: function(name){
|
2014-09-20 15:56:35 +02:00
|
|
|
this.EvtManager(this.Evt.name.resetpage);
|
|
|
|
},
|
|
|
|
/*==============================================
|
|
|
|
- re-sets page nb at page re-load
|
|
|
|
- Params:
|
|
|
|
- name: cookie name (string)
|
|
|
|
===============================================*/
|
2014-09-24 09:10:31 +02:00
|
|
|
_ResetPage: function(name){
|
2014-10-18 14:00:34 +02:00
|
|
|
var pgnb = cookie.read(name);
|
2014-09-24 09:10:31 +02:00
|
|
|
if(pgnb!==''){
|
2014-09-20 15:56:35 +02:00
|
|
|
this.ChangePage((pgnb-1));
|
2014-09-24 09:10:31 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
},
|
|
|
|
|
2014-09-24 09:10:31 +02:00
|
|
|
ResetPageLength: function(name){
|
2014-09-20 15:56:35 +02:00
|
|
|
this.EvtManager(this.Evt.name.resetpagelength);
|
|
|
|
},
|
|
|
|
/*==============================================
|
|
|
|
- re-sets page length at page re-load
|
|
|
|
- Params:
|
|
|
|
- name: cookie name (string)
|
|
|
|
===============================================*/
|
2014-09-24 09:10:31 +02:00
|
|
|
_ResetPageLength: function(name){
|
|
|
|
if(!this.paging){
|
|
|
|
return;
|
|
|
|
}
|
2014-10-18 14:00:34 +02:00
|
|
|
var pglenIndex = cookie.read(name);
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-24 09:10:31 +02:00
|
|
|
if(pglenIndex!==''){
|
2014-09-20 15:56:35 +02:00
|
|
|
this.resultsPerPageSlc.options[pglenIndex].selected = true;
|
|
|
|
this.ChangeResultsPerPage();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- Adds paging feature if filter grid bar is
|
|
|
|
already set
|
|
|
|
- Param(s):
|
|
|
|
- execFilter: if true table is filtered
|
|
|
|
(boolean)
|
|
|
|
=====================================================*/
|
2014-09-24 09:10:31 +02:00
|
|
|
AddPaging: function(filterTable){
|
|
|
|
if(!this.hasGrid || this.paging){
|
|
|
|
return;
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
this.paging = true;
|
|
|
|
this.isPagingRemoved = true;
|
|
|
|
this.SetPaging();
|
|
|
|
this.ResetValues();
|
2014-09-24 09:10:31 +02:00
|
|
|
if(filterTable){
|
|
|
|
this.Filter();
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
},
|
|
|
|
|
2014-09-24 09:10:31 +02:00
|
|
|
PopulateSelect: function(colIndex,isExternal,extSlcId){
|
2014-09-20 15:56:35 +02:00
|
|
|
this.EvtManager(
|
|
|
|
this.Evt.name.populateselect,
|
|
|
|
{ slcIndex:colIndex, slcExternal:isExternal, slcId:extSlcId }
|
|
|
|
);
|
|
|
|
},
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
/*====================================================
|
|
|
|
- populates drop-down filters
|
|
|
|
=====================================================*/
|
2014-09-24 09:10:31 +02:00
|
|
|
_PopulateSelect: function(colIndex,isRefreshed,isExternal,extSlcId) {
|
|
|
|
isExternal = isExternal===undefined ? false : isExternal;
|
2014-09-20 15:56:35 +02:00
|
|
|
var slcId = this.fltIds[colIndex];
|
2014-11-01 15:34:37 +01:00
|
|
|
if((!dom.id(slcId) && !isExternal) ||
|
|
|
|
(!dom.id(extSlcId) && isExternal)){
|
2014-09-24 09:10:31 +02:00
|
|
|
return;
|
|
|
|
}
|
2014-11-01 15:34:37 +01:00
|
|
|
var slc = !isExternal ? dom.id(slcId) : dom.id(extSlcId),
|
2014-09-24 09:10:31 +02:00
|
|
|
o = this,
|
|
|
|
row = this.tbl.rows,
|
|
|
|
matchCase = this.matchCase,
|
2014-10-18 14:00:34 +02:00
|
|
|
fillMethod = str.lower(this.slcFillingMethod),
|
2014-09-24 09:10:31 +02:00
|
|
|
optArray = [],
|
|
|
|
slcInnerHtml = '',
|
|
|
|
opt0,
|
|
|
|
//custom select test
|
|
|
|
isCustomSlc = (this.hasCustomSlcOptions &&
|
2014-10-18 14:00:34 +02:00
|
|
|
array.has(this.customSlcOptions.cols, colIndex));
|
2014-09-24 09:10:31 +02:00
|
|
|
//custom selects text
|
|
|
|
var optTxt = [],
|
|
|
|
activeFlt;
|
2014-09-20 15:56:35 +02:00
|
|
|
if(isRefreshed && this.activeFilterId){
|
|
|
|
activeFlt = this.activeFilterId.split('_')[0];
|
|
|
|
activeFlt = activeFlt.split(this.prfxFlt)[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
/*** remember grid values ***/
|
|
|
|
var flts_values = [], fltArr = [];
|
2014-09-24 09:10:31 +02:00
|
|
|
if(this.rememberGridValues){
|
2014-10-18 14:00:34 +02:00
|
|
|
flts_values = cookie.valueToArray(
|
2014-09-24 09:10:31 +02:00
|
|
|
this.fltsValuesCookie, this.separator);
|
2014-10-18 14:00:34 +02:00
|
|
|
if(flts_values && !str.isEmpty(flts_values.toString())){
|
2014-09-24 09:10:31 +02:00
|
|
|
if(isCustomSlc){
|
2014-09-20 15:56:35 +02:00
|
|
|
fltArr.push(flts_values[colIndex]);
|
2014-09-24 09:10:31 +02:00
|
|
|
} else {
|
|
|
|
fltArr = flts_values[colIndex].split(' '+o.orOperator+' ');
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-24 09:10:31 +02:00
|
|
|
var excludedOpts = null,
|
|
|
|
filteredDataCol = null;
|
|
|
|
if(isRefreshed && this.disableExcludedOptions){
|
|
|
|
excludedOpts = [];
|
|
|
|
filteredDataCol = [];
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-24 09:10:31 +02:00
|
|
|
for(var k=this.refRow; k<this.nbRows; k++){
|
|
|
|
// always visible rows don't need to appear on selects as always
|
|
|
|
// valid
|
2014-10-18 14:00:34 +02:00
|
|
|
if(this.hasVisibleRows && array.has(this.visibleRows, k) &&
|
2014-09-24 09:10:31 +02:00
|
|
|
!this.paging){
|
2014-09-20 15:56:35 +02:00
|
|
|
continue;
|
2014-09-24 09:10:31 +02:00
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-24 09:10:31 +02:00
|
|
|
var cell = row[k].cells,
|
|
|
|
nchilds = cell.length;
|
|
|
|
|
|
|
|
// checks if row has exact cell #
|
|
|
|
if(nchilds === this.nbCells && !isCustomSlc){
|
|
|
|
// this loop retrieves cell data
|
|
|
|
for(var j=0; j<nchilds; j++){
|
|
|
|
if((colIndex===j &&
|
|
|
|
(!isRefreshed ||
|
|
|
|
(isRefreshed && this.disableExcludedOptions))) ||
|
|
|
|
(colIndex==j && isRefreshed &&
|
2014-10-12 13:40:08 +02:00
|
|
|
((row[k].style.display === '' && !this.paging) ||
|
2014-09-24 09:10:31 +02:00
|
|
|
(this.paging && (!this.validRowsIndex ||
|
|
|
|
(this.validRowsIndex &&
|
2014-10-18 14:00:34 +02:00
|
|
|
array.has(this.validRowsIndex, k))) &&
|
2014-10-12 13:40:08 +02:00
|
|
|
((activeFlt===undefined || activeFlt==colIndex) ||
|
2014-09-24 09:10:31 +02:00
|
|
|
(activeFlt!=colIndex &&
|
2014-10-18 14:00:34 +02:00
|
|
|
array.has(this.validRowsIndex, k) ))) ))){
|
2014-09-24 09:10:31 +02:00
|
|
|
var cell_data = this.GetCellData(j, cell[j]),
|
2014-10-06 13:08:29 +02:00
|
|
|
//Vary Peter's patch
|
2014-10-18 14:00:34 +02:00
|
|
|
cell_string = str.matchCase(cell_data, matchCase);
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
// checks if celldata is already in array
|
2014-10-18 14:00:34 +02:00
|
|
|
if(!array.has(optArray, cell_string, matchCase)){
|
2014-09-24 09:10:31 +02:00
|
|
|
optArray.push(cell_data);
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
|
|
|
|
if(isRefreshed && this.disableExcludedOptions){
|
2014-09-24 09:10:31 +02:00
|
|
|
var filteredCol = filteredDataCol[j];
|
|
|
|
if(!filteredCol){
|
|
|
|
filteredCol = this.GetFilteredDataCol(j);
|
|
|
|
}
|
2014-10-18 14:00:34 +02:00
|
|
|
if(!array.has(filteredCol,cell_string, matchCase) &&
|
|
|
|
!array.has(
|
|
|
|
excludedOpts,cell_string,matchCase) &&
|
2014-09-24 09:10:31 +02:00
|
|
|
!this.isFirstLoad){
|
|
|
|
excludedOpts.push(cell_data);
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
|
|
|
}//if colIndex==j
|
|
|
|
}//for j
|
|
|
|
}//if
|
|
|
|
}//for k
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
//Retrieves custom values
|
2014-09-24 09:10:31 +02:00
|
|
|
if(isCustomSlc){
|
2014-09-20 15:56:35 +02:00
|
|
|
var customValues = this.__getCustomValues(colIndex);
|
|
|
|
optArray = customValues[0];
|
|
|
|
optTxt = customValues[1];
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
if(this.sortSlc && !isCustomSlc){
|
2014-09-24 09:10:31 +02:00
|
|
|
if (!matchCase){
|
2014-10-18 14:00:34 +02:00
|
|
|
optArray.sort(ignoreCaseSort);
|
|
|
|
if(excludedOpts) excludedOpts.sort(ignoreCaseSort);
|
2014-09-24 09:10:31 +02:00
|
|
|
} else {
|
|
|
|
optArray.sort();
|
|
|
|
if(excludedOpts){ excludedOpts.sort(); }
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-24 09:10:31 +02:00
|
|
|
//asc sort
|
2014-10-18 14:00:34 +02:00
|
|
|
if(this.sortNumAsc && array.has(this.sortNumAsc, colIndex)){
|
2014-09-20 15:56:35 +02:00
|
|
|
try{
|
2014-10-18 14:00:34 +02:00
|
|
|
optArray.sort( numSortAsc );
|
2014-09-24 09:10:31 +02:00
|
|
|
if(excludedOpts){
|
2014-10-18 14:00:34 +02:00
|
|
|
excludedOpts.sort( numSortAsc );
|
2014-09-24 09:10:31 +02:00
|
|
|
}
|
|
|
|
if(isCustomSlc){
|
2014-10-18 14:00:34 +02:00
|
|
|
optTxt.sort( numSortAsc );
|
2014-09-24 09:10:31 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
} catch(e) {
|
2014-09-24 09:10:31 +02:00
|
|
|
optArray.sort();
|
|
|
|
if(excludedOpts){
|
|
|
|
excludedOpts.sort();
|
|
|
|
}
|
|
|
|
if(isCustomSlc){
|
|
|
|
optTxt.sort();
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}//in case there are alphanumeric values
|
|
|
|
}
|
2014-09-24 09:10:31 +02:00
|
|
|
//desc sort
|
2014-10-18 14:00:34 +02:00
|
|
|
if(this.sortNumDesc && array.has(this.sortNumDesc, colIndex)){
|
2014-09-20 15:56:35 +02:00
|
|
|
try{
|
2014-10-18 14:00:34 +02:00
|
|
|
optArray.sort( numSortDesc );
|
2014-09-24 09:10:31 +02:00
|
|
|
if(excludedOpts){
|
2014-10-18 14:00:34 +02:00
|
|
|
excludedOpts.sort( numSortDesc );
|
2014-09-24 09:10:31 +02:00
|
|
|
}
|
|
|
|
if(isCustomSlc){
|
2014-10-18 14:00:34 +02:00
|
|
|
optTxt.sort( numSortDesc );
|
2014-09-24 09:10:31 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
} catch(e) {
|
2014-09-24 09:10:31 +02:00
|
|
|
optArray.sort();
|
|
|
|
if(excludedOpts){ excludedOpts.sort(); }
|
|
|
|
if(isCustomSlc){
|
|
|
|
optTxt.sort();
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}//in case there are alphanumeric values
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
AddOpts();//populates drop-down
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-24 09:10:31 +02:00
|
|
|
// adds 1st option
|
|
|
|
function AddOpt0(){
|
|
|
|
if(fillMethod === 'innerhtml'){
|
|
|
|
slcInnerHtml +='<option value="">'+o.displayAllText+'</option>';
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
else {
|
2014-10-18 14:00:34 +02:00
|
|
|
var opt0 = dom.createOpt(
|
2014-09-24 09:10:31 +02:00
|
|
|
(!o.enableSlcResetFilter ? '' : o.displayAllText),'');
|
|
|
|
if(!o.enableSlcResetFilter){
|
|
|
|
opt0.style.display = 'none';
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
slc.appendChild(opt0);
|
2014-09-07 12:07:28 +02:00
|
|
|
if(o.enableEmptyOption){
|
2014-10-18 14:00:34 +02:00
|
|
|
var opt1 = dom.createOpt(o.emptyText,o.emOperator);
|
2014-09-20 15:56:35 +02:00
|
|
|
slc.appendChild(opt1);
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
|
|
|
if(o.enableNonEmptyOption){
|
2014-10-18 14:00:34 +02:00
|
|
|
var opt2 = dom.createOpt(o.nonEmptyText,o.nmOperator);
|
2014-09-20 15:56:35 +02:00
|
|
|
slc.appendChild(opt2);
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-24 09:10:31 +02:00
|
|
|
// populates select
|
|
|
|
function AddOpts(){
|
2014-09-20 15:56:35 +02:00
|
|
|
var slcValue = slc.value;
|
|
|
|
slc.innerHTML = '';
|
|
|
|
AddOpt0();
|
|
|
|
|
2014-09-24 09:10:31 +02:00
|
|
|
for(var y=0; y<optArray.length; y++){
|
|
|
|
if(optArray[y]===''){
|
|
|
|
continue;
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
var val = optArray[y]; //option value
|
2014-09-24 09:10:31 +02:00
|
|
|
var lbl = isCustomSlc ? optTxt[y] : val; //option text
|
2014-09-20 15:56:35 +02:00
|
|
|
var isDisabled = false;
|
|
|
|
if(isRefreshed && o.disableExcludedOptions &&
|
2014-10-18 14:00:34 +02:00
|
|
|
array.has(excludedOpts,
|
|
|
|
str.matchCase(val, o.matchCase), o.matchCase)){
|
2014-09-20 15:56:35 +02:00
|
|
|
isDisabled = true;
|
2014-09-24 09:10:31 +02:00
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-24 09:10:31 +02:00
|
|
|
if(fillMethod === 'innerhtml'){
|
2014-09-20 15:56:35 +02:00
|
|
|
var slcAttr = '';
|
2014-09-24 09:10:31 +02:00
|
|
|
if(o.fillSlcOnDemand && slcValue==optArray[y]){
|
2014-09-20 15:56:35 +02:00
|
|
|
slcAttr = 'selected="selected"';
|
2014-09-24 09:10:31 +02:00
|
|
|
}
|
|
|
|
slcInnerHtml += '<option value="'+val+'" ' + slcAttr +
|
|
|
|
(isDisabled ? 'disabled="disabled"' : '')+ '>' +
|
|
|
|
lbl+'</option>';
|
2014-09-20 15:56:35 +02:00
|
|
|
} else {
|
|
|
|
var opt;
|
|
|
|
//fill select on demand
|
2014-09-24 09:10:31 +02:00
|
|
|
if(o.fillSlcOnDemand && slcValue==optArray[y] &&
|
|
|
|
o['col'+colIndex]===o.fltTypeSlc){
|
2014-10-18 14:00:34 +02:00
|
|
|
opt = dom.createOpt(lbl, val, true);
|
2014-09-24 09:10:31 +02:00
|
|
|
} else {
|
|
|
|
if(o['col'+colIndex]!=o.fltTypeMulti){
|
2014-10-18 14:00:34 +02:00
|
|
|
opt = dom.createOpt(
|
2014-09-24 09:10:31 +02:00
|
|
|
lbl,
|
|
|
|
val,
|
|
|
|
(flts_values[colIndex]!==' ' &&
|
|
|
|
val==flts_values[colIndex]) ? true : false
|
|
|
|
);
|
|
|
|
} else {
|
2014-10-18 14:00:34 +02:00
|
|
|
opt = dom.createOpt(
|
2014-09-24 09:10:31 +02:00
|
|
|
lbl,
|
|
|
|
val,
|
2014-10-18 14:00:34 +02:00
|
|
|
(array.has(fltArr,
|
|
|
|
str.matchCase(optArray[y],o.matchCase),
|
2014-10-12 13:40:08 +02:00
|
|
|
o.matchCase) ||
|
2014-09-24 09:10:31 +02:00
|
|
|
fltArr.toString().indexOf(val)!== -1) ?
|
|
|
|
true : false
|
|
|
|
);
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
|
|
|
}
|
2014-09-24 09:10:31 +02:00
|
|
|
if(isDisabled){
|
|
|
|
opt.disabled = true;
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
slc.appendChild(opt);
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}// for y
|
|
|
|
|
2014-09-24 09:10:31 +02:00
|
|
|
if(fillMethod === 'innerhtml'){
|
|
|
|
slc.innerHTML += slcInnerHtml;
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
slc.setAttribute('filled','1');
|
|
|
|
}// fn AddOpt
|
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- IE bug: it seems there is no way to make
|
|
|
|
multiple selections programatically, only last
|
|
|
|
selection is kept (multiple select previously
|
|
|
|
populated via DOM)
|
|
|
|
- Work-around: defer selection with a setTimeout
|
|
|
|
If you find a more elegant solution to
|
|
|
|
this let me know ;-)
|
2014-09-24 09:10:31 +02:00
|
|
|
- For the moment only this solution seems to work!
|
2014-09-20 15:56:35 +02:00
|
|
|
- Params:
|
|
|
|
- slc = select object (select obj)
|
|
|
|
- index to be selected (integer)
|
|
|
|
- execute filtering (boolean)
|
|
|
|
=====================================================*/
|
2014-09-24 09:10:31 +02:00
|
|
|
__deferMultipleSelection: function(slc,index,filter){
|
2014-10-18 14:00:34 +02:00
|
|
|
if(str.lower(slc.nodeName)!=='select'){
|
2014-09-24 09:10:31 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
var doFilter = filter===undefined ? false : filter;
|
2014-09-20 15:56:35 +02:00
|
|
|
var o = this;
|
2014-10-18 14:00:34 +02:00
|
|
|
global.setTimeout(function(){
|
2014-09-24 09:10:31 +02:00
|
|
|
slc.options[0].selected = false;
|
|
|
|
|
2014-09-28 10:59:14 +02:00
|
|
|
if(slc.options[index].value==='')
|
2014-09-24 09:10:31 +02:00
|
|
|
slc.options[index].selected = false;
|
|
|
|
else
|
|
|
|
slc.options[index].selected = true;
|
|
|
|
if(doFilter) o.Filter();
|
|
|
|
}, 0.1);
|
2014-09-20 15:56:35 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- Returns an array [[values],[texts]] with
|
|
|
|
custom values for a given filter
|
|
|
|
- Param: column index (integer)
|
|
|
|
=====================================================*/
|
2014-09-28 10:59:14 +02:00
|
|
|
__getCustomValues: function(colIndex){
|
|
|
|
if(!colIndex){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
//custom select test
|
|
|
|
var isCustomSlc = this.hasCustomSlcOptions &&
|
2014-10-18 14:00:34 +02:00
|
|
|
array.has(this.customSlcOptions.cols, colIndex);
|
2014-09-28 10:59:14 +02:00
|
|
|
if(!isCustomSlc){
|
|
|
|
return;
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
var optTxt = [], optArray = [];
|
2014-10-18 14:00:34 +02:00
|
|
|
var index = array.indexByValue(this.customSlcOptions.cols, colIndex);
|
2014-09-20 15:56:35 +02:00
|
|
|
var slcValues = this.customSlcOptions.values[index];
|
|
|
|
var slcTexts = this.customSlcOptions.texts[index];
|
|
|
|
var slcSort = this.customSlcOptions.sorts[index];
|
2014-09-28 10:59:14 +02:00
|
|
|
for(var r=0; r<slcValues.length; r++){
|
2014-09-20 15:56:35 +02:00
|
|
|
optArray.push(slcValues[r]);
|
2014-09-28 10:59:14 +02:00
|
|
|
if(slcTexts[r]){
|
2014-09-20 15:56:35 +02:00
|
|
|
optTxt.push(slcTexts[r]);
|
2014-09-28 10:59:14 +02:00
|
|
|
} else {
|
2014-09-20 15:56:35 +02:00
|
|
|
optTxt.push(slcValues[r]);
|
2014-09-28 10:59:14 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
2014-09-28 10:59:14 +02:00
|
|
|
if(slcSort){
|
2014-09-20 15:56:35 +02:00
|
|
|
optArray.sort();
|
|
|
|
optTxt.sort();
|
|
|
|
}
|
|
|
|
return [optArray,optTxt];
|
|
|
|
},
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-28 10:59:14 +02:00
|
|
|
PopulateCheckList: function(colIndex, isExternal, extFltId){
|
2014-09-20 15:56:35 +02:00
|
|
|
this.EvtManager(
|
|
|
|
this.Evt.name.populatechecklist,
|
|
|
|
{ slcIndex:colIndex, slcExternal:isExternal, slcId:extFltId }
|
|
|
|
);
|
|
|
|
},
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
/*====================================================
|
|
|
|
- populates checklist filters
|
|
|
|
=====================================================*/
|
2014-09-28 10:59:14 +02:00
|
|
|
_PopulateCheckList: function(colIndex, isExternal, extFltId){
|
|
|
|
isExternal = !isExternal ? false : isExternal;
|
2014-09-20 15:56:35 +02:00
|
|
|
var divFltId = this.prfxCheckListDiv+colIndex+'_'+this.id;
|
2014-11-01 15:34:37 +01:00
|
|
|
if(!dom.id(divFltId) && !isExternal){
|
2014-09-28 10:59:14 +02:00
|
|
|
return;
|
|
|
|
}
|
2014-11-01 15:34:37 +01:00
|
|
|
if(!dom.id(extFltId) && isExternal){
|
2014-09-28 10:59:14 +02:00
|
|
|
return;
|
|
|
|
}
|
2014-11-01 15:34:37 +01:00
|
|
|
var flt = !isExternal ? this.checkListDiv[colIndex] : dom.id(extFltId);
|
2014-10-18 14:00:34 +02:00
|
|
|
var ul = dom.create('ul',
|
2014-09-28 10:59:14 +02:00
|
|
|
['id',this.fltIds[colIndex]], ['colIndex',colIndex]);
|
2014-09-20 15:56:35 +02:00
|
|
|
ul.className = this.checkListCssClass;
|
|
|
|
ul.onchange = this.Evt._OnCheckListChange;
|
|
|
|
var o = this, row = this.tbl.rows;
|
|
|
|
var optArray = [];
|
2014-09-28 10:59:14 +02:00
|
|
|
//custom select test
|
|
|
|
var isCustomSlc = (this.hasCustomSlcOptions &&
|
2014-10-18 14:00:34 +02:00
|
|
|
array.has(this.customSlcOptions.cols, colIndex));
|
2014-09-28 10:59:14 +02:00
|
|
|
//custom selects text
|
|
|
|
var optTxt = [],
|
|
|
|
activeFlt;
|
2014-09-20 15:56:35 +02:00
|
|
|
if(this.refreshFilters && this.activeFilterId){
|
|
|
|
activeFlt = this.activeFilterId.split('_')[0];
|
|
|
|
activeFlt = activeFlt.split(this.prfxFlt)[1];
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-28 10:59:14 +02:00
|
|
|
var excludedOpts,
|
2014-10-18 14:00:34 +02:00
|
|
|
filteredDataCol = [];
|
2014-09-28 10:59:14 +02:00
|
|
|
if(this.refreshFilters && this.disableExcludedOptions){
|
|
|
|
excludedOpts = [];
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-28 10:59:14 +02:00
|
|
|
for(var k=this.refRow; k<this.nbRows; k++){
|
|
|
|
// always visible rows don't need to appear on selects as always
|
|
|
|
// valid
|
2014-10-18 14:00:34 +02:00
|
|
|
if(this.hasVisibleRows && array.has(this.visibleRows, k) &&
|
2014-09-28 10:59:14 +02:00
|
|
|
!this.paging){
|
2014-09-20 15:56:35 +02:00
|
|
|
continue;
|
2014-09-28 10:59:14 +02:00
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
var cells = row[k].cells;
|
|
|
|
var ncells = cells.length;
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-28 10:59:14 +02:00
|
|
|
// checks if row has exact cell #
|
|
|
|
if(ncells == this.nbCells && !isCustomSlc){
|
|
|
|
// this loop retrieves cell data
|
|
|
|
for(var j=0; j<ncells; j++){
|
|
|
|
if((colIndex===j && (!this.refreshFilters ||
|
|
|
|
(this.refreshFilters && this.disableExcludedOptions)))||
|
|
|
|
(colIndex===j && this.refreshFilters &&
|
|
|
|
((row[k].style.display === '' && !this.paging) ||
|
|
|
|
(this.paging && ((!activeFlt || activeFlt===colIndex )||
|
|
|
|
(activeFlt!=colIndex &&
|
2014-10-18 14:00:34 +02:00
|
|
|
array.has(this.validRowsIndex, k))) )))){
|
2014-09-20 15:56:35 +02:00
|
|
|
var cell_data = this.GetCellData(j, cells[j]);
|
2014-10-06 13:08:29 +02:00
|
|
|
//Vary Peter's patch
|
2014-09-28 10:59:14 +02:00
|
|
|
var cell_string =
|
2014-10-18 14:00:34 +02:00
|
|
|
str.matchCase(cell_data, this.matchCase);
|
2014-09-20 15:56:35 +02:00
|
|
|
// checks if celldata is already in array
|
2014-10-18 14:00:34 +02:00
|
|
|
if(!array.has(optArray, cell_string, this.matchCase)){
|
2014-09-28 10:59:14 +02:00
|
|
|
optArray.push(cell_data);
|
|
|
|
}
|
|
|
|
var filteredCol = filteredDataCol[j];
|
2014-09-20 15:56:35 +02:00
|
|
|
if(this.refreshFilters && this.disableExcludedOptions){
|
2014-09-28 10:59:14 +02:00
|
|
|
if(!filteredCol){
|
|
|
|
filteredDataCol[j] = this.GetFilteredDataCol(j);
|
|
|
|
}
|
2014-10-18 14:00:34 +02:00
|
|
|
if(!array.has(filteredCol,
|
2014-09-28 10:59:14 +02:00
|
|
|
cell_string,this.matchCase) &&
|
2014-10-18 14:00:34 +02:00
|
|
|
!array.has(excludedOpts,
|
2014-09-28 10:59:14 +02:00
|
|
|
cell_string,this.matchCase) &&
|
|
|
|
!this.isFirstLoad){
|
|
|
|
excludedOpts.push(cell_data);
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
//Retrieves custom values
|
2014-09-28 10:59:14 +02:00
|
|
|
if(isCustomSlc){
|
2014-09-20 15:56:35 +02:00
|
|
|
var customValues = this.__getCustomValues(colIndex);
|
|
|
|
optArray = customValues[0];
|
|
|
|
optTxt = customValues[1];
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
if(this.sortSlc && !isCustomSlc){
|
|
|
|
if (!this.matchCase){
|
2014-10-18 14:00:34 +02:00
|
|
|
optArray.sort(ignoreCaseSort);
|
2014-09-28 10:59:14 +02:00
|
|
|
if(excludedOpts){
|
2014-10-18 14:00:34 +02:00
|
|
|
excludedOpts.sort(ignoreCaseSort);
|
2014-09-28 10:59:14 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
optArray.sort();
|
|
|
|
if(excludedOpts){ excludedOpts.sort(); }
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
2014-09-28 10:59:14 +02:00
|
|
|
//asc sort
|
2014-10-18 14:00:34 +02:00
|
|
|
if(this.sortNumAsc && array.has(this.sortNumAsc, colIndex)){
|
2014-09-20 15:56:35 +02:00
|
|
|
try{
|
2014-10-18 14:00:34 +02:00
|
|
|
optArray.sort( numSortAsc );
|
2014-09-28 10:59:14 +02:00
|
|
|
if(excludedOpts){
|
2014-10-18 14:00:34 +02:00
|
|
|
excludedOpts.sort( numSortAsc );
|
2014-09-28 10:59:14 +02:00
|
|
|
}
|
|
|
|
if(isCustomSlc){
|
2014-10-18 14:00:34 +02:00
|
|
|
optTxt.sort( numSortAsc );
|
2014-09-28 10:59:14 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
} catch(e) {
|
|
|
|
optArray.sort(); if(excludedOpts){ excludedOpts.sort(); }
|
2014-09-28 10:59:14 +02:00
|
|
|
if(isCustomSlc){
|
|
|
|
optTxt.sort();
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}//in case there are alphanumeric values
|
|
|
|
}
|
2014-09-28 10:59:14 +02:00
|
|
|
//desc sort
|
2014-10-18 14:00:34 +02:00
|
|
|
if(this.sortNumDesc && array.has(this.sortNumDesc, colIndex)){
|
2014-09-20 15:56:35 +02:00
|
|
|
try{
|
2014-10-18 14:00:34 +02:00
|
|
|
optArray.sort( numSortDesc );
|
2014-09-28 10:59:14 +02:00
|
|
|
if(excludedOpts){
|
2014-10-18 14:00:34 +02:00
|
|
|
excludedOpts.sort( numSortDesc );
|
2014-09-28 10:59:14 +02:00
|
|
|
}
|
|
|
|
if(isCustomSlc){
|
2014-10-18 14:00:34 +02:00
|
|
|
optTxt.sort( numSortDesc );
|
2014-09-28 10:59:14 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
} catch(e) {
|
|
|
|
optArray.sort(); if(excludedOpts){ excludedOpts.sort(); }
|
2014-09-28 10:59:14 +02:00
|
|
|
if(isCustomSlc){
|
|
|
|
optTxt.sort();
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}//in case there are alphanumeric values
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
AddChecks(this.separator);
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-28 10:59:14 +02:00
|
|
|
// adds 1st option
|
|
|
|
function AddTChecks(){
|
2014-09-20 15:56:35 +02:00
|
|
|
var chkCt = 1;
|
2014-10-18 14:00:34 +02:00
|
|
|
var li0 = dom.createCheckItem(
|
2014-09-28 10:59:14 +02:00
|
|
|
o.fltIds[colIndex]+'_0', '', o.displayAllText);
|
2014-09-20 15:56:35 +02:00
|
|
|
li0.className = o.checkListItemCssClass;
|
|
|
|
ul.appendChild(li0);
|
2014-09-28 10:59:14 +02:00
|
|
|
li0.check.onclick = function(e){
|
|
|
|
o.__setCheckListValues(this);
|
|
|
|
ul.onchange.call(null, e);
|
|
|
|
};
|
|
|
|
if(!o.enableCheckListResetFilter){
|
|
|
|
li0.style.display = 'none';
|
|
|
|
}
|
|
|
|
//IE: label looses check capability
|
2014-11-01 15:34:37 +01:00
|
|
|
if(hlp.isIE()){
|
2014-09-20 15:56:35 +02:00
|
|
|
li0.label.onclick = function(){ li0.check.click(); };
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
if(o.enableEmptyOption){
|
2014-10-18 14:00:34 +02:00
|
|
|
var li1 = dom.createCheckItem(
|
2014-09-28 10:59:14 +02:00
|
|
|
o.fltIds[colIndex]+'_1', o.emOperator, o.emptyText);
|
2014-09-20 15:56:35 +02:00
|
|
|
li1.className = o.checkListItemCssClass;
|
|
|
|
ul.appendChild(li1);
|
2014-09-28 10:59:14 +02:00
|
|
|
li1.check.onclick = function(e){
|
|
|
|
o.__setCheckListValues(this);
|
|
|
|
ul.onchange.call(null, e);
|
|
|
|
};
|
|
|
|
//IE: label looses check capability
|
2014-11-01 15:34:37 +01:00
|
|
|
if(hlp.isIE()){
|
2014-09-20 15:56:35 +02:00
|
|
|
li1.label.onclick = function(){ li1.check.click(); };
|
|
|
|
}
|
|
|
|
chkCt++;
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
if(o.enableNonEmptyOption){
|
2014-10-18 14:00:34 +02:00
|
|
|
var li2 = dom.createCheckItem(
|
2014-09-28 10:59:14 +02:00
|
|
|
o.fltIds[colIndex]+'_2',
|
|
|
|
o.nmOperator,
|
|
|
|
o.nonEmptyText
|
|
|
|
);
|
2014-09-20 15:56:35 +02:00
|
|
|
li2.className = o.checkListItemCssClass;
|
|
|
|
ul.appendChild(li2);
|
2014-09-28 10:59:14 +02:00
|
|
|
li2.check.onclick = function(e){
|
|
|
|
o.__setCheckListValues(this);
|
|
|
|
ul.onchange.call(null, e);
|
|
|
|
};
|
|
|
|
//IE: label looses check capability
|
2014-11-01 15:34:37 +01:00
|
|
|
if(hlp.isIE())
|
2014-09-28 10:59:14 +02:00
|
|
|
{
|
2014-09-20 15:56:35 +02:00
|
|
|
li2.label.onclick = function(){ li2.check.click(); };
|
|
|
|
}
|
|
|
|
chkCt++;
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
return chkCt;
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-28 10:59:14 +02:00
|
|
|
function AddChecks(separator){
|
2014-09-20 15:56:35 +02:00
|
|
|
var chkCt = AddTChecks();
|
|
|
|
|
|
|
|
var flts_values = [], fltArr = []; //remember grid values
|
2014-10-18 14:00:34 +02:00
|
|
|
var tmpVal = cookie.getValueByIndex(
|
2014-09-28 10:59:14 +02:00
|
|
|
o.fltsValuesCookie, colIndex, separator);
|
2014-10-18 14:00:34 +02:00
|
|
|
if(tmpVal && str.trim(tmpVal).length > 0){
|
2014-09-28 10:59:14 +02:00
|
|
|
if(o.hasCustomSlcOptions &&
|
2014-10-18 14:00:34 +02:00
|
|
|
array.has(o.customSlcOptions.cols, colIndex)){
|
2014-09-20 15:56:35 +02:00
|
|
|
fltArr.push(tmpVal);
|
2014-09-28 10:59:14 +02:00
|
|
|
} else {
|
|
|
|
fltArr = tmpVal.split(' '+o.orOperator+' ');
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
|
|
|
|
2014-10-06 13:08:29 +02:00
|
|
|
function optionClick(evt){
|
|
|
|
o.__setCheckListValues(this);
|
|
|
|
ul.onchange.call(null, evt);
|
|
|
|
}
|
|
|
|
|
2014-09-28 10:59:14 +02:00
|
|
|
for(var y=0; y<optArray.length; y++){
|
2014-09-20 15:56:35 +02:00
|
|
|
var val = optArray[y]; //item value
|
2014-09-28 10:59:14 +02:00
|
|
|
var lbl = isCustomSlc ? optTxt[y] : val; //item text
|
2014-10-18 14:00:34 +02:00
|
|
|
var li = dom.createCheckItem(
|
2014-09-28 10:59:14 +02:00
|
|
|
o.fltIds[colIndex]+'_'+(y+chkCt), val, lbl);
|
2014-09-20 15:56:35 +02:00
|
|
|
li.className = o.checkListItemCssClass;
|
|
|
|
if(o.refreshFilters && o.disableExcludedOptions &&
|
2014-10-18 14:00:34 +02:00
|
|
|
array.has(excludedOpts,
|
|
|
|
str.matchCase(val, o.matchCase), o.matchCase)){
|
|
|
|
dom.addClass(li, o.checkListItemDisabledCssClass);
|
2014-09-20 15:56:35 +02:00
|
|
|
li.check.disabled = true;
|
|
|
|
li.disabled = true;
|
2014-09-28 10:59:14 +02:00
|
|
|
} else{
|
2014-10-06 13:08:29 +02:00
|
|
|
li.check.onclick = optionClick;
|
2014-09-28 10:59:14 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
ul.appendChild(li);
|
|
|
|
|
2014-09-28 10:59:14 +02:00
|
|
|
if(val===''){
|
|
|
|
//item is hidden
|
|
|
|
li.style.display = 'none';
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
|
|
|
|
/*** remember grid values ***/
|
2014-09-28 10:59:14 +02:00
|
|
|
if(o.rememberGridValues){
|
|
|
|
if((o.hasCustomSlcOptions &&
|
2014-10-18 14:00:34 +02:00
|
|
|
array.has(o.customSlcOptions.cols, colIndex) &&
|
2014-09-28 10:59:14 +02:00
|
|
|
fltArr.toString().indexOf(val)!= -1) ||
|
2014-10-18 14:00:34 +02:00
|
|
|
array.has(fltArr,
|
|
|
|
str.matchCase(val, o.matchCase), o.matchCase)){
|
2014-09-20 15:56:35 +02:00
|
|
|
li.check.checked = true;
|
|
|
|
o.__setCheckListValues(li.check);
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
2014-09-28 10:59:14 +02:00
|
|
|
//IE: label looses check capability
|
2014-11-01 15:34:37 +01:00
|
|
|
if(hlp.isIE()){
|
2014-10-06 13:08:29 +02:00
|
|
|
li.label.onclick = labelClick;
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
|
|
|
}
|
2014-10-06 13:08:29 +02:00
|
|
|
function labelClick(){
|
|
|
|
this.firstChild.click();
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
|
|
|
|
2014-09-28 10:59:14 +02:00
|
|
|
if(this.fillSlcOnDemand){
|
|
|
|
flt.innerHTML = '';
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
flt.appendChild(ul);
|
|
|
|
flt.setAttribute('filled','1');
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
/*** remember grid values IE only, items remain un-checked ***/
|
2014-11-01 15:34:37 +01:00
|
|
|
if(o.rememberGridValues && hlp.isIE()){
|
2014-09-20 15:56:35 +02:00
|
|
|
var slcIndexes = ul.getAttribute('indexes');
|
2014-09-28 10:59:14 +02:00
|
|
|
if(slcIndexes){
|
2014-09-20 15:56:35 +02:00
|
|
|
var indSplit = slcIndexes.split(',');//items indexes
|
2014-09-28 10:59:14 +02:00
|
|
|
for(var n=0; n<indSplit.length; n++){
|
|
|
|
//checked item
|
2014-11-01 15:34:37 +01:00
|
|
|
var cChk = dom.id(this.fltIds[colIndex]+'_'+indSplit[n]);
|
2014-09-28 10:59:14 +02:00
|
|
|
if(cChk){
|
|
|
|
cChk.checked = true;
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
|
|
|
},
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
/*====================================================
|
|
|
|
- Sets checked items information of a checklist
|
|
|
|
=====================================================*/
|
2014-09-28 10:59:14 +02:00
|
|
|
__setCheckListValues: function(o){
|
|
|
|
if(!o){
|
|
|
|
return;
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
var chkValue = o.value; //checked item value
|
2014-09-28 10:59:14 +02:00
|
|
|
var chkIndex = parseInt(o.id.split('_')[2], 10);
|
2014-09-20 15:56:35 +02:00
|
|
|
var filterTag = 'ul', itemTag = 'li';
|
|
|
|
var n = o;
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
//ul tag search
|
2014-10-18 14:00:34 +02:00
|
|
|
while(str.lower(n.nodeName)!==filterTag){
|
2014-09-20 15:56:35 +02:00
|
|
|
n = n.parentNode;
|
2014-09-28 10:59:14 +02:00
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
var li = n.childNodes[chkIndex];
|
|
|
|
var colIndex = n.getAttribute('colIndex');
|
|
|
|
var fltValue = n.getAttribute('value'); //filter value (ul tag)
|
|
|
|
var fltIndexes = n.getAttribute('indexes'); //selected items (ul tag)
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-28 10:59:14 +02:00
|
|
|
if(o.checked){
|
|
|
|
//show all item
|
|
|
|
if(chkValue===''){
|
|
|
|
if((fltIndexes && fltIndexes!=='')){
|
|
|
|
//items indexes
|
|
|
|
var indSplit = fltIndexes.split(this.separator);
|
|
|
|
//checked items loop
|
|
|
|
for(var u=0; u<indSplit.length; u++){
|
|
|
|
//checked item
|
2014-11-01 15:34:37 +01:00
|
|
|
var cChk = dom.id(
|
|
|
|
this.fltIds[colIndex]+'_'+indSplit[u]);
|
2014-09-28 10:59:14 +02:00
|
|
|
if(cChk){
|
2014-09-20 15:56:35 +02:00
|
|
|
cChk.checked = false;
|
2014-10-18 14:00:34 +02:00
|
|
|
dom.removeClass(
|
2014-09-20 15:56:35 +02:00
|
|
|
n.childNodes[indSplit[u]],
|
|
|
|
this.checkListSlcItemCssClass
|
|
|
|
);
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
n.setAttribute('value', '');
|
|
|
|
n.setAttribute('indexes', '');
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
} else {
|
|
|
|
fltValue = (fltValue) ? fltValue : '';
|
2014-10-18 14:00:34 +02:00
|
|
|
chkValue = str.trim(
|
2014-10-10 15:34:45 +02:00
|
|
|
fltValue+' '+chkValue+' '+this.orOperator);
|
2014-09-20 15:56:35 +02:00
|
|
|
chkIndex = fltIndexes + chkIndex + this.separator;
|
|
|
|
n.setAttribute('value', chkValue );
|
|
|
|
n.setAttribute('indexes', chkIndex);
|
|
|
|
//1st option unchecked
|
2014-11-01 15:34:37 +01:00
|
|
|
if(dom.id(this.fltIds[colIndex]+'_0')){
|
|
|
|
dom.id(this.fltIds[colIndex]+'_0').checked = false;
|
2014-09-28 10:59:14 +02:00
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
|
|
|
|
2014-10-18 14:00:34 +02:00
|
|
|
if(str.lower(li.nodeName) === itemTag){
|
|
|
|
dom.removeClass(
|
2014-10-10 15:34:45 +02:00
|
|
|
n.childNodes[0],this.checkListSlcItemCssClass);
|
2014-10-18 14:00:34 +02:00
|
|
|
dom.addClass(li,this.checkListSlcItemCssClass);
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
} else { //removes values and indexes
|
2014-09-28 10:59:14 +02:00
|
|
|
if(chkValue!==''){
|
|
|
|
var replaceValue = new RegExp(
|
2014-10-18 14:00:34 +02:00
|
|
|
str.rgxEsc(chkValue+' '+this.orOperator));
|
2014-09-20 15:56:35 +02:00
|
|
|
fltValue = fltValue.replace(replaceValue,'');
|
2014-10-18 14:00:34 +02:00
|
|
|
n.setAttribute('value', str.trim(fltValue));
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-28 10:59:14 +02:00
|
|
|
var replaceIndex = new RegExp(
|
2014-10-18 14:00:34 +02:00
|
|
|
str.rgxEsc(chkIndex + this.separator));
|
2014-09-20 15:56:35 +02:00
|
|
|
fltIndexes = fltIndexes.replace(replaceIndex,'');
|
|
|
|
n.setAttribute('indexes', fltIndexes);
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
2014-10-18 14:00:34 +02:00
|
|
|
if(str.lower(li.nodeName)===itemTag){
|
|
|
|
dom.removeClass(li,this.checkListSlcItemCssClass);
|
2014-09-28 10:59:14 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
|
|
|
},
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
/*====================================================
|
|
|
|
- Generates reset button
|
|
|
|
=====================================================*/
|
2014-09-28 10:59:14 +02:00
|
|
|
SetResetBtn: function(){
|
|
|
|
if(!this.hasGrid && !this.isFirstLoad && this.btnResetEl){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
var f = this.fObj;
|
2014-09-28 10:59:14 +02:00
|
|
|
//id of container element
|
|
|
|
this.btnResetTgtId = f.btn_reset_target_id || null;
|
|
|
|
//reset button element
|
|
|
|
this.btnResetEl = null;
|
|
|
|
//defines reset text
|
|
|
|
this.btnResetText = f.btn_reset_text || 'Reset';
|
|
|
|
//defines reset button tooltip
|
|
|
|
this.btnResetTooltip = f.btn_reset_tooltip || 'Clear filters';
|
|
|
|
//defines reset button innerHtml
|
|
|
|
this.btnResetHtml = f.btn_reset_html ||
|
|
|
|
(!this.enableIcons ? null :
|
|
|
|
'<input type="button" value="" class="'+this.btnResetCssClass+'" ' +
|
|
|
|
'title="'+this.btnResetTooltip+'" />');
|
2014-09-20 15:56:35 +02:00
|
|
|
|
2014-10-18 14:00:34 +02:00
|
|
|
var resetspan = dom.create('span', ['id',this.prfxResetSpan+this.id]);
|
2014-09-20 15:56:35 +02:00
|
|
|
|
|
|
|
// reset button is added to defined element
|
2014-09-28 10:59:14 +02:00
|
|
|
if(!this.btnResetTgtId){
|
|
|
|
this.SetTopDiv();
|
|
|
|
}
|
|
|
|
var targetEl = !this.btnResetTgtId ? this.rDiv :
|
2014-11-01 15:34:37 +01:00
|
|
|
dom.id( this.btnResetTgtId );
|
2014-09-20 15:56:35 +02:00
|
|
|
targetEl.appendChild(resetspan);
|
|
|
|
|
2014-09-28 10:59:14 +02:00
|
|
|
if(!this.btnResetHtml){
|
2014-10-18 14:00:34 +02:00
|
|
|
var fltreset = dom.create('a', ['href', 'javascript:void(0);']);
|
2014-09-20 15:56:35 +02:00
|
|
|
fltreset.className = this.btnResetCssClass;
|
2014-10-18 14:00:34 +02:00
|
|
|
fltreset.appendChild(dom.text(this.btnResetText));
|
2014-09-20 15:56:35 +02:00
|
|
|
resetspan.appendChild(fltreset);
|
|
|
|
fltreset.onclick = this.Evt._Clear;
|
|
|
|
} else {
|
|
|
|
resetspan.innerHTML = this.btnResetHtml;
|
|
|
|
var resetEl = resetspan.firstChild;
|
|
|
|
resetEl.onclick = this.Evt._Clear;
|
|
|
|
}
|
2014-11-01 15:34:37 +01:00
|
|
|
this.btnResetEl = dom.id(this.prfxResetSpan+this.id).firstChild;
|
2014-09-20 15:56:35 +02:00
|
|
|
},
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
/*====================================================
|
|
|
|
- Removes reset button
|
|
|
|
=====================================================*/
|
2014-09-28 10:59:14 +02:00
|
|
|
RemoveResetBtn: function(){
|
|
|
|
if(!this.hasGrid || !this.btnResetEl){
|
|
|
|
return;
|
|
|
|
}
|
2014-11-01 15:34:37 +01:00
|
|
|
var resetspan = dom.id(this.prfxResetSpan+this.id);
|
2014-09-28 10:59:14 +02:00
|
|
|
if(resetspan){
|
2014-09-20 15:56:35 +02:00
|
|
|
resetspan.parentNode.removeChild( resetspan );
|
2014-09-28 10:59:14 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
this.btnResetEl = null;
|
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- Generates status bar label
|
|
|
|
=====================================================*/
|
2014-09-28 13:17:01 +02:00
|
|
|
SetStatusBar: function(){
|
|
|
|
if(!this.hasGrid && !this.isFirstLoad){
|
|
|
|
return;
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
var f = this.fObj;
|
2014-09-28 13:17:01 +02:00
|
|
|
//id of custom container element
|
|
|
|
this.statusBarTgtId = f.status_bar_target_id || null;
|
|
|
|
//element containing status bar label
|
|
|
|
this.statusBarDiv = null;
|
|
|
|
//status bar
|
|
|
|
this.statusBarSpan = null;
|
|
|
|
//status bar label
|
|
|
|
this.statusBarSpanText = null;
|
|
|
|
//defines status bar text
|
|
|
|
this.statusBarText = f.status_bar_text || '';
|
|
|
|
//defines css class status bar
|
|
|
|
this.statusBarCssClass = f.status_bar_css_class || 'status';
|
|
|
|
//delay for status bar clearing
|
|
|
|
this.statusBarCloseDelay = 250;
|
|
|
|
//status bar container
|
2014-10-18 14:00:34 +02:00
|
|
|
var statusDiv = dom.create('div', ['id',this.prfxStatus+this.id]);
|
2014-09-20 15:56:35 +02:00
|
|
|
statusDiv.className = this.statusBarCssClass;
|
2014-09-28 13:17:01 +02:00
|
|
|
//status bar label
|
2014-10-18 14:00:34 +02:00
|
|
|
var statusSpan = dom.create(
|
2014-09-28 13:17:01 +02:00
|
|
|
'span', ['id',this.prfxStatusSpan+this.id]);
|
|
|
|
//preceding text
|
2014-10-18 14:00:34 +02:00
|
|
|
var statusSpanText = dom.create(
|
2014-09-28 13:17:01 +02:00
|
|
|
'span', ['id',this.prfxStatusTxt+this.id]);
|
2014-10-18 14:00:34 +02:00
|
|
|
statusSpanText.appendChild(dom.text(this.statusBarText));
|
2014-09-28 13:17:01 +02:00
|
|
|
//calls function before message is displayed
|
2014-10-18 14:00:34 +02:00
|
|
|
this.onBeforeShowMsg = types.isFn(f.on_before_show_msg) ?
|
2014-09-28 13:17:01 +02:00
|
|
|
f.on_before_show_msg : null;
|
|
|
|
//calls function after message is displayed
|
2014-10-18 14:00:34 +02:00
|
|
|
this.onAfterShowMsg = types.isFn(f.on_after_show_msg) ?
|
2014-09-28 13:17:01 +02:00
|
|
|
f.on_after_show_msg : null;
|
2014-09-20 15:56:35 +02:00
|
|
|
|
|
|
|
// target element container
|
2014-09-28 13:17:01 +02:00
|
|
|
if(!this.statusBarTgtId){
|
|
|
|
this.SetTopDiv();
|
|
|
|
}
|
|
|
|
var targetEl = (!this.statusBarTgtId) ?
|
2014-11-01 15:34:37 +01:00
|
|
|
this.lDiv : dom.id(this.statusBarTgtId);
|
2014-09-20 15:56:35 +02:00
|
|
|
|
2014-11-01 15:34:37 +01:00
|
|
|
if(this.statusBarDiv && hlp.isIE()){
|
2014-09-20 15:56:35 +02:00
|
|
|
this.statusBarDiv.outerHTML = '';
|
2014-09-28 13:17:01 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
|
2014-09-28 13:17:01 +02:00
|
|
|
//default container: 'lDiv'
|
|
|
|
if(!this.statusBarTgtId){
|
2014-09-20 15:56:35 +02:00
|
|
|
statusDiv.appendChild(statusSpanText);
|
|
|
|
statusDiv.appendChild(statusSpan);
|
|
|
|
targetEl.appendChild(statusDiv);
|
2014-09-28 13:17:01 +02:00
|
|
|
} else {
|
|
|
|
// custom container, no need to append statusDiv
|
2014-09-20 15:56:35 +02:00
|
|
|
targetEl.appendChild(statusSpanText);
|
|
|
|
targetEl.appendChild(statusSpan);
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-11-01 15:34:37 +01:00
|
|
|
this.statusBarDiv = dom.id( this.prfxStatus+this.id );
|
|
|
|
this.statusBarSpan = dom.id( this.prfxStatusSpan+this.id );
|
|
|
|
this.statusBarSpanText = dom.id( this.prfxStatusTxt+this.id );
|
2014-09-20 15:56:35 +02:00
|
|
|
},
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
/*====================================================
|
|
|
|
- Removes status bar div
|
|
|
|
=====================================================*/
|
2014-09-28 13:17:01 +02:00
|
|
|
RemoveStatusBar: function(){
|
|
|
|
if(!this.hasGrid && !this.statusBarDiv){
|
|
|
|
return;
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
2014-09-28 13:17:01 +02:00
|
|
|
|
|
|
|
this.statusBarDiv.innerHTML = '';
|
|
|
|
this.statusBarDiv.parentNode.removeChild(this.statusBarDiv);
|
|
|
|
this.statusBarSpan = null;
|
|
|
|
this.statusBarSpanText = null;
|
|
|
|
this.statusBarDiv = null;
|
2014-09-20 15:56:35 +02:00
|
|
|
},
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
/*====================================================
|
|
|
|
- sets status messages
|
|
|
|
=====================================================*/
|
2014-09-28 13:17:01 +02:00
|
|
|
StatusMsg: function(t){
|
|
|
|
if(!t){
|
|
|
|
this.StatusMsg('');
|
|
|
|
}
|
|
|
|
if(this.status){ this.WinStatusMsg(t); }
|
|
|
|
if(this.statusBar){ this.StatusBarMsg(t); }
|
2014-09-20 15:56:35 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- sets window status messages
|
|
|
|
=====================================================*/
|
2014-09-28 13:17:01 +02:00
|
|
|
WinStatusMsg: function(t){
|
|
|
|
if(!this.status){
|
|
|
|
return;
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
if(this.onBeforeShowMsg){ this.onBeforeShowMsg.call(null, this, t); }
|
2014-10-18 14:00:34 +02:00
|
|
|
global.status = t;
|
2014-09-20 15:56:35 +02:00
|
|
|
if(this.onAfterShowMsg){ this.onAfterShowMsg.call(null, this, t); }
|
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- sets status bar messages
|
|
|
|
=====================================================*/
|
2014-09-28 13:17:01 +02:00
|
|
|
StatusBarMsg: function(t){
|
|
|
|
if(!this.statusBar || !this.statusBarSpan){
|
|
|
|
return;
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
if(this.onBeforeShowMsg){ this.onBeforeShowMsg.call(null, this, t); }
|
|
|
|
var o = this;
|
|
|
|
function setMsg(){
|
|
|
|
o.statusBarSpan.innerHTML = t;
|
|
|
|
if(o.onAfterShowMsg){ o.onAfterShowMsg.call(null, o, t); }
|
|
|
|
}
|
2014-09-28 13:17:01 +02:00
|
|
|
var d = t==='' ? this.statusBarCloseDelay : 1;
|
2014-10-18 14:00:34 +02:00
|
|
|
global.setTimeout(setMsg, d);
|
2014-09-20 15:56:35 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- Generates rows counter label
|
|
|
|
=====================================================*/
|
2014-09-28 13:17:01 +02:00
|
|
|
SetRowsCounter: function(){
|
|
|
|
if((!this.hasGrid && !this.isFirstLoad) || this.rowsCounterSpan){
|
|
|
|
return;
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
var f = this.fObj;
|
2014-09-28 13:17:01 +02:00
|
|
|
//id of custom container element
|
|
|
|
this.rowsCounterTgtId = f.rows_counter_target_id || null;
|
|
|
|
//element containing tot nb rows
|
|
|
|
this.rowsCounterDiv = null;
|
|
|
|
//element containing tot nb rows label
|
|
|
|
this.rowsCounterSpan = null;
|
|
|
|
//defines rows counter text
|
|
|
|
this.rowsCounterText = f.rows_counter_text || 'Rows: ';
|
|
|
|
this.fromToTextSeparator = f.from_to_text_separator || '-';
|
|
|
|
this.overText = f.over_text || ' / ';
|
|
|
|
//defines css class rows counter
|
|
|
|
this.totRowsCssClass = f.tot_rows_css_class || 'tot';
|
|
|
|
//callback raised before counter is refreshed
|
2014-10-12 13:40:08 +02:00
|
|
|
this.onBeforeRefreshCounter =
|
2014-10-18 14:00:34 +02:00
|
|
|
types.isFn(f.on_before_refresh_counter) ?
|
2014-10-12 13:40:08 +02:00
|
|
|
f.on_before_refresh_counter : null;
|
2014-09-28 13:17:01 +02:00
|
|
|
//callback raised after counter is refreshed
|
2014-10-18 14:00:34 +02:00
|
|
|
this.onAfterRefreshCounter = types.isFn(f.on_after_refresh_counter) ?
|
2014-09-28 13:17:01 +02:00
|
|
|
f.on_after_refresh_counter : null;
|
|
|
|
//rows counter container
|
2014-10-18 14:00:34 +02:00
|
|
|
var countDiv = dom.create('div', ['id',this.prfxCounter+this.id]);
|
2014-09-20 15:56:35 +02:00
|
|
|
countDiv.className = this.totRowsCssClass;
|
2014-09-28 13:17:01 +02:00
|
|
|
//rows counter label
|
2014-10-18 14:00:34 +02:00
|
|
|
var countSpan = dom.create('span',['id',this.prfxTotRows+this.id]);
|
|
|
|
var countText = dom.create('span',['id',this.prfxTotRowsTxt+this.id]);
|
|
|
|
countText.appendChild(dom.text(this.rowsCounterText));
|
2014-09-20 15:56:35 +02:00
|
|
|
|
|
|
|
// counter is added to defined element
|
2014-09-28 13:17:01 +02:00
|
|
|
if(!this.rowsCounterTgtId){
|
|
|
|
this.SetTopDiv();
|
|
|
|
}
|
|
|
|
var targetEl = !this.rowsCounterTgtId ?
|
2014-11-01 15:34:37 +01:00
|
|
|
this.lDiv : dom.id( this.rowsCounterTgtId );
|
2014-09-20 15:56:35 +02:00
|
|
|
|
|
|
|
//IE only: clears all for sure
|
2014-11-01 15:34:37 +01:00
|
|
|
if(this.rowsCounterDiv && hlp.isIE()){
|
2014-09-20 15:56:35 +02:00
|
|
|
this.rowsCounterDiv.outerHTML = '';
|
2014-09-28 13:17:01 +02:00
|
|
|
}
|
|
|
|
//default container: 'lDiv'
|
|
|
|
if(!this.rowsCounterTgtId){
|
2014-09-20 15:56:35 +02:00
|
|
|
countDiv.appendChild(countText);
|
|
|
|
countDiv.appendChild(countSpan);
|
|
|
|
targetEl.appendChild(countDiv);
|
|
|
|
}
|
2014-09-28 13:17:01 +02:00
|
|
|
else{
|
|
|
|
//custom container, no need to append statusDiv
|
2014-09-20 15:56:35 +02:00
|
|
|
targetEl.appendChild(countText);
|
|
|
|
targetEl.appendChild(countSpan);
|
|
|
|
}
|
2014-11-01 15:34:37 +01:00
|
|
|
this.rowsCounterDiv = dom.id( this.prfxCounter+this.id );
|
|
|
|
this.rowsCounterSpan = dom.id( this.prfxTotRows+this.id );
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
this.RefreshNbRows();
|
|
|
|
},
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
/*====================================================
|
|
|
|
- Removes rows counter label
|
|
|
|
=====================================================*/
|
2014-09-28 13:17:01 +02:00
|
|
|
RemoveRowsCounter: function(){
|
|
|
|
if(!this.hasGrid){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(!this.rowsCounterSpan){
|
|
|
|
return;
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-28 13:17:01 +02:00
|
|
|
if(!this.rowsCounterTgtId && this.rowsCounterDiv){
|
2014-09-20 15:56:35 +02:00
|
|
|
//IE only: clears all for sure
|
2014-11-01 15:34:37 +01:00
|
|
|
if(hlp.isIE()){
|
2014-09-28 13:17:01 +02:00
|
|
|
this.rowsCounterDiv.outerHTML = '';
|
|
|
|
} else {
|
|
|
|
this.rowsCounterDiv.parentNode.removeChild(this.rowsCounterDiv);
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
} else {
|
2014-11-01 15:34:37 +01:00
|
|
|
dom.id( this.rowsCounterTgtId ).innerHTML = '';
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
|
|
|
this.rowsCounterSpan = null;
|
|
|
|
this.rowsCounterDiv = null;
|
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- Shows total number of filtered rows
|
|
|
|
=====================================================*/
|
2014-09-28 13:17:01 +02:00
|
|
|
RefreshNbRows: function(p){
|
|
|
|
if(!this.rowsCounterSpan){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(this.onBeforeRefreshCounter){
|
|
|
|
this.onBeforeRefreshCounter.call(null, this, this.rowsCounterSpan);
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
var totTxt;
|
2014-09-28 13:17:01 +02:00
|
|
|
if(!this.paging){
|
|
|
|
if(p && p!==''){
|
|
|
|
totTxt=p;
|
|
|
|
} else{
|
|
|
|
totTxt = this.nbFilterableRows - this.nbHiddenRows -
|
|
|
|
(this.hasVisibleRows ? this.visibleRows.length : 0);
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
} else {
|
2014-09-28 13:17:01 +02:00
|
|
|
//paging start row
|
|
|
|
var paging_start_row = parseInt(this.startPagingRow,10) +
|
|
|
|
((this.nbVisibleRows>0) ? 1 : 0);
|
|
|
|
var paging_end_row = (paging_start_row+this.pagingLength)-1 <=
|
|
|
|
this.nbVisibleRows ? paging_start_row+this.pagingLength-1 :
|
|
|
|
this.nbVisibleRows;
|
|
|
|
totTxt = paging_start_row + this.fromToTextSeparator +
|
|
|
|
paging_end_row + this.overText + this.nbVisibleRows;
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
|
|
|
this.rowsCounterSpan.innerHTML = totTxt;
|
2014-09-28 13:17:01 +02:00
|
|
|
if(this.onAfterRefreshCounter){
|
|
|
|
this.onAfterRefreshCounter.call(
|
|
|
|
null, this, this.rowsCounterSpan, totTxt);
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- inserts or removes input watermark
|
|
|
|
- Params:
|
|
|
|
- set: if true inserts watermark (boolean)
|
|
|
|
=====================================================*/
|
2014-09-28 13:17:01 +02:00
|
|
|
SetWatermark: function(set){
|
|
|
|
if(!this.fltGrid && this.inpWatermark===''){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
set = set===undefined ? true : set;
|
|
|
|
for(var i=0; i<this.fltIds.length; i++){
|
|
|
|
//only input type filters
|
|
|
|
if(this['col'+i]!==this.fltTypeInp){
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
var inpWatermark = !this.isInpWatermarkArray ?
|
|
|
|
this.inpWatermark : this.inpWatermark[i];
|
|
|
|
if(this.GetFilterValue(i)===(set ? '' : inpWatermark)){
|
|
|
|
this.SetFilterValue(i, (!set ? '' : inpWatermark));
|
2014-10-18 14:00:34 +02:00
|
|
|
dom.addClass(
|
2014-09-28 13:17:01 +02:00
|
|
|
this.GetFilterElement(i), this.inpWatermarkCssClass);
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
|
|
|
},
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
/*====================================================
|
|
|
|
- generates a grid with fixed headers
|
|
|
|
=====================================================*/
|
2014-09-28 13:17:01 +02:00
|
|
|
SetGridLayout: function(){
|
|
|
|
if(!this.gridLayout){
|
|
|
|
return;
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
var f = this.fObj;
|
2014-09-28 13:17:01 +02:00
|
|
|
//defines grid width
|
|
|
|
this.gridWidth = f.grid_width || null;
|
|
|
|
//defines grid height
|
|
|
|
this.gridHeight = f.grid_height || null;
|
|
|
|
//defines css class for main container
|
|
|
|
this.gridMainContCssClass = f.grid_cont_css_class || 'grd_Cont';
|
|
|
|
//defines css class for div containing table
|
|
|
|
this.gridContCssClass = f.grid_tbl_cont_css_class || 'grd_tblCont';
|
|
|
|
//defines css class for div containing headers' table
|
|
|
|
this.gridHeadContCssClass = f.grid_tblHead_cont_css_class ||
|
|
|
|
'grd_headTblCont';
|
|
|
|
//defines css class for div containing rows counter, paging etc.
|
|
|
|
this.gridInfDivCssClass = f.grid_inf_grid_css_class || 'grd_inf';
|
|
|
|
//defines which row contains column headers
|
|
|
|
this.gridHeadRowIndex = f.grid_headers_row_index || 0;
|
|
|
|
//array of headers row indexes to be placed in header table
|
|
|
|
this.gridHeadRows = f.grid_headers_rows || [0];
|
|
|
|
//generate filters in table headers
|
|
|
|
this.gridEnableFilters = f.grid_enable_default_filters!==undefined ?
|
|
|
|
f.grid_enable_default_filters : true;
|
|
|
|
//default col width
|
|
|
|
this.gridDefaultColWidth = f.grid_default_col_width || '100px';
|
|
|
|
//enables/disables columns resizer
|
|
|
|
this.gridEnableColResizer = f.grid_enable_cols_resizer!==undefined ?
|
|
|
|
f.grid_enable_cols_resizer : true;
|
|
|
|
//defines col resizer script path
|
|
|
|
this.gridColResizerPath = f.grid_cont_col_resizer_path ||
|
|
|
|
this.basePath+'TFExt_ColsResizer/TFExt_ColsResizer.js';
|
|
|
|
|
|
|
|
// in case column widths are not set default width 100px
|
|
|
|
if(!this.hasColWidth){
|
2014-09-20 15:56:35 +02:00
|
|
|
this.colWidth = [];
|
|
|
|
for(var k=0; k<this.nbCells; k++){
|
2014-09-28 13:17:01 +02:00
|
|
|
var colW,
|
|
|
|
cell = this.tbl.rows[this.gridHeadRowIndex].cells[k];
|
|
|
|
if(cell.width!==''){
|
|
|
|
colW = cell.width;
|
|
|
|
} else if(cell.style.width!==''){
|
2014-10-06 13:08:29 +02:00
|
|
|
colW = parseInt(cell.style.width, 10);
|
2014-09-28 13:17:01 +02:00
|
|
|
} else {
|
|
|
|
colW = this.gridDefaultColWidth;
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
this.colWidth[k] = colW;
|
|
|
|
}
|
|
|
|
this.hasColWidth = true;
|
|
|
|
}
|
|
|
|
this.SetColWidths(this.gridHeadRowIndex);
|
|
|
|
|
|
|
|
var tblW;//initial table width
|
2014-09-28 13:17:01 +02:00
|
|
|
if(this.tbl.width!==''){
|
|
|
|
tblW = this.tbl.width;
|
|
|
|
}
|
|
|
|
else if(this.tbl.style.width!==''){
|
2014-10-06 13:08:29 +02:00
|
|
|
tblW = parseInt(this.tbl.style.width, 10);
|
2014-09-28 13:17:01 +02:00
|
|
|
} else {
|
|
|
|
tblW = this.tbl.clientWidth;
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
|
|
|
|
//Main container: it will contain all the elements
|
2014-10-18 14:00:34 +02:00
|
|
|
this.tblMainCont = dom.create(
|
2014-09-28 13:17:01 +02:00
|
|
|
'div',['id', this.prfxMainTblCont + this.id]);
|
2014-09-20 15:56:35 +02:00
|
|
|
this.tblMainCont.className = this.gridMainContCssClass;
|
2014-09-28 13:17:01 +02:00
|
|
|
if(this.gridWidth){
|
|
|
|
this.tblMainCont.style.width = this.gridWidth;
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
this.tbl.parentNode.insertBefore(this.tblMainCont, this.tbl);
|
|
|
|
|
|
|
|
//Table container: div wrapping content table
|
2014-10-18 14:00:34 +02:00
|
|
|
this.tblCont = dom.create('div',['id', this.prfxTblCont + this.id]);
|
2014-09-20 15:56:35 +02:00
|
|
|
this.tblCont.className = this.gridContCssClass;
|
2014-09-28 13:17:01 +02:00
|
|
|
if(this.gridWidth){
|
|
|
|
this.tblCont.style.width = this.gridWidth;
|
|
|
|
}
|
|
|
|
if(this.gridHeight){
|
|
|
|
this.tblCont.style.height = this.gridHeight;
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
this.tbl.parentNode.insertBefore(this.tblCont, this.tbl);
|
|
|
|
var t = this.tbl.parentNode.removeChild(this.tbl);
|
|
|
|
this.tblCont.appendChild(t);
|
|
|
|
|
|
|
|
//In case table width is expressed in %
|
2014-09-28 13:17:01 +02:00
|
|
|
if(this.tbl.style.width === ''){
|
|
|
|
this.tbl.style.width = (this.__containsStr('%', tblW) ?
|
|
|
|
this.tbl.clientWidth : tblW) + 'px';
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
|
|
|
|
var d = this.tblCont.parentNode.removeChild(this.tblCont);
|
|
|
|
this.tblMainCont.appendChild(d);
|
|
|
|
|
|
|
|
//Headers table container: div wrapping headers table
|
2014-10-18 14:00:34 +02:00
|
|
|
this.headTblCont = dom.create(
|
2014-09-28 13:17:01 +02:00
|
|
|
'div',['id', this.prfxHeadTblCont + this.id]);
|
2014-09-20 15:56:35 +02:00
|
|
|
this.headTblCont.className = this.gridHeadContCssClass;
|
2014-09-28 13:17:01 +02:00
|
|
|
if(this.gridWidth){
|
|
|
|
this.headTblCont.style.width = this.gridWidth;
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
|
|
|
|
//Headers table
|
2014-10-18 14:00:34 +02:00
|
|
|
this.headTbl = dom.create('table',['id', this.prfxHeadTbl + this.id]);
|
|
|
|
var tH = dom.create('tHead'); //IE<7 needs it
|
2014-09-20 15:56:35 +02:00
|
|
|
|
|
|
|
//1st row should be headers row, ids are added if not set
|
|
|
|
//Those ids are used by the sort feature
|
|
|
|
var hRow = this.tbl.rows[this.gridHeadRowIndex];
|
|
|
|
var sortTriggers = [];
|
|
|
|
for(var n=0; n<this.nbCells; n++){
|
2014-09-28 13:17:01 +02:00
|
|
|
var c = hRow.cells[n];
|
|
|
|
var thId = c.getAttribute('id');
|
|
|
|
if(!thId || thId===''){
|
|
|
|
thId = this.prfxGridTh+n+'_'+this.id;
|
|
|
|
c.setAttribute('id', thId);
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
|
|
|
sortTriggers.push(thId);
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
//Filters row is created
|
2014-10-18 14:00:34 +02:00
|
|
|
var filtersRow = dom.create('tr');
|
2014-09-20 15:56:35 +02:00
|
|
|
if(this.gridEnableFilters && this.fltGrid){
|
2014-09-07 12:07:28 +02:00
|
|
|
this.externalFltTgtIds = [];
|
2014-09-28 13:17:01 +02:00
|
|
|
for(var j=0; j<this.nbCells; j++){
|
2014-09-20 15:56:35 +02:00
|
|
|
var fltTdId = this.prfxFlt+j+ this.prfxGridFltTd +this.id;
|
2014-10-18 14:00:34 +02:00
|
|
|
var cl = dom.create(this.fltCellTag, ['id', fltTdId]);
|
2014-09-28 13:17:01 +02:00
|
|
|
filtersRow.appendChild(cl);
|
2014-09-20 15:56:35 +02:00
|
|
|
this.externalFltTgtIds[j] = fltTdId;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//Headers row are moved from content table to headers table
|
2014-09-28 13:17:01 +02:00
|
|
|
for(var i=0; i<this.gridHeadRows.length; i++){
|
2014-09-20 15:56:35 +02:00
|
|
|
var headRow = this.tbl.rows[this.gridHeadRows[0]];
|
|
|
|
tH.appendChild(headRow);
|
|
|
|
}
|
|
|
|
this.headTbl.appendChild(tH);
|
2014-09-28 13:17:01 +02:00
|
|
|
if(this.filtersRowIndex === 0){
|
|
|
|
tH.insertBefore(filtersRow,hRow);
|
|
|
|
} else {
|
|
|
|
tH.appendChild(filtersRow);
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
|
|
|
|
this.headTblCont.appendChild(this.headTbl);
|
|
|
|
this.tblCont.parentNode.insertBefore(this.headTblCont, this.tblCont);
|
|
|
|
|
|
|
|
//THead needs to be removed in content table for sort feature
|
2014-11-01 15:34:37 +01:00
|
|
|
var thead = dom.tag(this.tbl,'thead');
|
2014-09-28 13:17:01 +02:00
|
|
|
if(thead.length>0){
|
|
|
|
this.tbl.removeChild(thead[0]);
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
|
|
|
|
//Headers table style
|
|
|
|
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;
|
|
|
|
|
|
|
|
//Headers container width
|
|
|
|
this.headTblCont.style.width = this.tblCont.clientWidth+'px';
|
|
|
|
|
|
|
|
//content table without headers needs col widths to be reset
|
|
|
|
this.SetColWidths();
|
|
|
|
|
|
|
|
this.tbl.style.width = '';
|
2014-11-01 15:34:37 +01:00
|
|
|
if(hlp.isIE()){
|
2014-09-28 13:17:01 +02:00
|
|
|
this.headTbl.style.width = '';
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
|
|
|
|
//scroll synchronisation
|
|
|
|
var o = this; //TF object
|
|
|
|
this.tblCont.onscroll = function(){
|
|
|
|
o.headTblCont.scrollLeft = this.scrollLeft;
|
|
|
|
var _o = this; //this = scroll element
|
|
|
|
//New pointerX calc taking into account scrollLeft
|
|
|
|
if(!o.isPointerXOverwritten){
|
|
|
|
try{
|
2014-09-28 13:17:01 +02:00
|
|
|
TF.Evt.pointerX = function(e){
|
2014-10-18 14:00:34 +02:00
|
|
|
e = e || global.event;
|
2014-09-28 13:17:01 +02:00
|
|
|
var scrollLeft = tf_StandardBody().scrollLeft +
|
|
|
|
_o.scrollLeft;
|
|
|
|
return (e.pageX + _o.scrollLeft) ||
|
|
|
|
(e.clientX + scrollLeft);
|
|
|
|
};
|
2014-09-20 15:56:35 +02:00
|
|
|
o.isPointerXOverwritten = true;
|
2014-09-28 13:17:01 +02:00
|
|
|
} catch(err) {
|
2014-09-20 15:56:35 +02:00
|
|
|
o.isPointerXOverwritten = false;
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
2014-09-28 13:17:01 +02:00
|
|
|
};
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
//Sort is enabled if not specified in config object
|
2014-09-28 13:17:01 +02:00
|
|
|
if(f.sort !== false){
|
2014-09-20 15:56:35 +02:00
|
|
|
this.sort = true;
|
|
|
|
this.sortConfig.asyncSort = true;
|
|
|
|
this.sortConfig.triggerIds = sortTriggers;
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
if(this.gridEnableColResizer){
|
|
|
|
if(!this.hasExtensions){
|
|
|
|
this.extensions = {
|
|
|
|
name:['ColumnsResizer_'+this.id],
|
|
|
|
src:[this.gridColResizerPath],
|
|
|
|
description:['Columns Resizing'],
|
2014-09-28 13:17:01 +02:00
|
|
|
initialize:[function(o){
|
|
|
|
o.SetColsResizer('ColumnsResizer_'+o.id);}]
|
|
|
|
};
|
2014-09-20 15:56:35 +02:00
|
|
|
this.hasExtensions = true;
|
2014-09-07 12:07:28 +02:00
|
|
|
} else {
|
2014-09-28 13:17:01 +02:00
|
|
|
if(!this.__containsStr(
|
2014-10-10 15:34:45 +02:00
|
|
|
'colsresizer',
|
2014-10-18 14:00:34 +02:00
|
|
|
str.lower(this.extensions.src.toString())) ){
|
2014-09-20 15:56:35 +02:00
|
|
|
this.extensions.name.push('ColumnsResizer_'+this.id);
|
|
|
|
this.extensions.src.push(this.gridColResizerPath);
|
|
|
|
this.extensions.description.push('Columns Resizing');
|
2014-09-28 13:17:01 +02:00
|
|
|
this.extensions.initialize.push(function(o){
|
|
|
|
o.SetColsResizer('ColumnsResizer_'+o.id);});
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
//Default columns resizer properties for grid layout
|
|
|
|
f.col_resizer_cols_headers_table = this.headTbl.getAttribute('id');
|
|
|
|
f.col_resizer_cols_headers_index = this.gridHeadRowIndex;
|
|
|
|
f.col_resizer_width_adjustment = 0;
|
|
|
|
f.col_enable_text_ellipsis = false;
|
|
|
|
|
|
|
|
//Cols generation for all browsers excepted IE<=7
|
2014-11-01 15:34:37 +01:00
|
|
|
o.tblHasColTag = dom.tag(o.tbl,'col').length > 0 ? true : false;
|
|
|
|
if(!hlp.isIE()){
|
2014-09-28 13:17:01 +02:00
|
|
|
//Col elements are enough to keep column widths after sorting and
|
|
|
|
//filtering
|
2014-10-06 13:08:29 +02:00
|
|
|
var createColTags = function(o){
|
2014-09-28 13:17:01 +02:00
|
|
|
if(!o){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for(var k=(o.nbCells-1); k>=0; k--){
|
2014-10-18 14:00:34 +02:00
|
|
|
var col = dom.create( 'col', ['id', o.id+'_col_'+k]);
|
2014-09-28 13:17:01 +02:00
|
|
|
o.tbl.firstChild.parentNode.insertBefore(
|
|
|
|
col,o.tbl.firstChild);
|
2014-09-20 15:56:35 +02:00
|
|
|
col.style.width = o.colWidth[k];
|
|
|
|
o.gridColElms[k] = col;
|
|
|
|
}
|
|
|
|
o.tblHasColTag = true;
|
2014-10-06 13:08:29 +02:00
|
|
|
};
|
2014-09-28 13:17:01 +02:00
|
|
|
if(!o.tblHasColTag){
|
|
|
|
createColTags(o);
|
|
|
|
} else {
|
2014-11-01 15:34:37 +01:00
|
|
|
var cols = dom.tag(o.tbl,'col');
|
2014-09-28 13:17:01 +02:00
|
|
|
for(var ii=0; ii<o.nbCells; ii++){
|
|
|
|
cols[ii].setAttribute('id', o.id+'_col_'+ii);
|
|
|
|
cols[ii].style.width = o.colWidth[ii];
|
|
|
|
o.gridColElms.push(cols[ii]);
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-28 13:17:01 +02:00
|
|
|
//IE <= 7 needs an additional row for widths as col element width is
|
|
|
|
//not enough...
|
2014-11-01 15:34:37 +01:00
|
|
|
if(hlp.isIE()){
|
|
|
|
var tbody = dom.tag(o.tbl,'tbody'),
|
2014-09-28 13:17:01 +02:00
|
|
|
r;
|
|
|
|
if( tbody.length>0 ){
|
|
|
|
r = tbody[0].insertRow(0);
|
|
|
|
} else{
|
|
|
|
r = o.tbl.insertRow(0);
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
r.style.height = '0px';
|
2014-09-28 13:17:01 +02:00
|
|
|
for(var x=0; x<o.nbCells; x++){
|
2014-10-18 14:00:34 +02:00
|
|
|
var col = dom.create('td', ['id', o.id+'_col_'+x]);
|
2014-09-28 13:17:01 +02:00
|
|
|
col.style.width = o.colWidth[x];
|
|
|
|
o.tbl.rows[1].cells[x].style.width = '';
|
2014-09-20 15:56:35 +02:00
|
|
|
r.appendChild(col);
|
|
|
|
o.gridColElms.push(col);
|
|
|
|
}
|
|
|
|
this.hasGridWidthsRow = true;
|
|
|
|
//Data table row with widths expressed
|
|
|
|
o.leadColWidthsRow = o.tbl.rows[0];
|
|
|
|
o.leadColWidthsRow.setAttribute('validRow','false');
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-10-18 14:00:34 +02:00
|
|
|
var beforeSortFn = types.isFn(f.on_before_sort) ?
|
2014-09-28 13:17:01 +02:00
|
|
|
f.on_before_sort : null;
|
2014-09-20 15:56:35 +02:00
|
|
|
f.on_before_sort = function(o,colIndex){
|
|
|
|
o.leadColWidthsRow.setAttribute('validRow','false');
|
2014-09-28 13:17:01 +02:00
|
|
|
if(beforeSortFn){
|
|
|
|
beforeSortFn.call(null,o,colIndex);
|
|
|
|
}
|
|
|
|
};
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-10-18 14:00:34 +02:00
|
|
|
var afterSortFn = types.isFn(f.on_after_sort) ?
|
2014-10-12 13:40:08 +02:00
|
|
|
f.on_after_sort : null;
|
2014-09-20 15:56:35 +02:00
|
|
|
f.on_after_sort = function(o,colIndex){
|
2014-09-28 13:17:01 +02:00
|
|
|
if(o.leadColWidthsRow.rowIndex !== 0){
|
2014-09-20 15:56:35 +02:00
|
|
|
var r = o.leadColWidthsRow;
|
2014-09-28 13:17:01 +02:00
|
|
|
if(tbody.length>0){
|
2014-09-20 15:56:35 +02:00
|
|
|
tbody[0].moveRow(o.leadColWidthsRow.rowIndex, 0);
|
2014-09-28 13:17:01 +02:00
|
|
|
} else {
|
|
|
|
o.tbl.moveRow(o.leadColWidthsRow.rowIndex, 0);
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
2014-09-28 13:17:01 +02:00
|
|
|
if(afterSortFn){
|
|
|
|
afterSortFn.call(null,o,colIndex);
|
|
|
|
}
|
|
|
|
};
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-10-18 14:00:34 +02:00
|
|
|
var afterColResizedFn = types.isFn(f.on_after_col_resized) ?
|
2014-09-28 13:17:01 +02:00
|
|
|
f.on_after_col_resized : null;
|
2014-09-20 15:56:35 +02:00
|
|
|
f.on_after_col_resized = function(o,colIndex){
|
2014-09-28 13:17:01 +02:00
|
|
|
if(!colIndex){
|
|
|
|
return;
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
var w = o.crWColsRow.cells[colIndex].style.width;
|
|
|
|
var col = o.gridColElms[colIndex];
|
|
|
|
col.style.width = w;
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
var thCW = o.crWColsRow.cells[colIndex].clientWidth;
|
|
|
|
var tdCW = o.crWRowDataTbl.cells[colIndex].clientWidth;
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-11-01 15:34:37 +01:00
|
|
|
if(hlp.isIE()){
|
2014-09-20 15:56:35 +02:00
|
|
|
o.tbl.style.width = o.headTbl.clientWidth+'px';
|
2014-09-28 13:17:01 +02:00
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-11-01 15:34:37 +01:00
|
|
|
if(thCW != tdCW && !hlp.isIE()){
|
2014-09-20 15:56:35 +02:00
|
|
|
o.headTbl.style.width = o.tbl.clientWidth+'px';
|
2014-09-28 13:17:01 +02:00
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-28 13:17:01 +02:00
|
|
|
if(afterColResizedFn){
|
|
|
|
afterColResizedFn.call(null,o,colIndex);
|
|
|
|
}
|
|
|
|
};
|
2014-09-20 15:56:35 +02:00
|
|
|
|
2014-09-28 13:17:01 +02:00
|
|
|
if(this.tbl.clientWidth !== this.headTbl.clientWidth){
|
2014-09-20 15:56:35 +02:00
|
|
|
this.tbl.style.width = this.headTbl.clientWidth+'px';
|
2014-09-28 13:17:01 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- removes the grid layout
|
|
|
|
=====================================================*/
|
2014-09-28 13:17:01 +02:00
|
|
|
RemoveGridLayout: function(){
|
|
|
|
if(!this.gridLayout){
|
|
|
|
return;
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
var t = this.tbl.parentNode.removeChild(this.tbl);
|
|
|
|
this.tblMainCont.parentNode.insertBefore(t, 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;
|
2014-11-01 15:34:37 +01:00
|
|
|
this.tbl = dom.id(this.id); //needed to keep reference
|
2014-09-20 15:56:35 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- generates popup filters div
|
|
|
|
=====================================================*/
|
2014-09-28 13:17:01 +02:00
|
|
|
SetPopupFilterIcons: function(){
|
|
|
|
if(!this.popUpFilters){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
//external filters behaviour is enabled
|
|
|
|
this.isExternalFlt = true;
|
2014-09-20 15:56:35 +02:00
|
|
|
var f = this.fObj;
|
2014-09-28 13:17:01 +02:00
|
|
|
//filter icon path
|
|
|
|
this.popUpImgFlt = f.popup_filters_image ||
|
|
|
|
this.themesPath+'icn_filter.gif';
|
|
|
|
//active filter icon path
|
|
|
|
this.popUpImgFltActive = f.popup_filters_image_active ||
|
|
|
|
this.themesPath+'icn_filterActive.gif';
|
|
|
|
this.popUpImgFltHtml = f.popup_filters_image_html ||
|
|
|
|
'<img src="'+ this.popUpImgFlt +'" alt="Column filter" />';
|
|
|
|
//defines css class for popup div containing filter
|
|
|
|
this.popUpDivCssClass = f.popup_div_css_class || 'popUpFilter';
|
|
|
|
//callback function before popup filtes is opened
|
2014-10-18 14:00:34 +02:00
|
|
|
this.onBeforePopUpOpen = types.isFn(f.on_before_popup_filter_open) ?
|
2014-09-28 13:17:01 +02:00
|
|
|
f.on_before_popup_filter_open : null;
|
|
|
|
//callback function after popup filtes is opened
|
2014-10-18 14:00:34 +02:00
|
|
|
this.onAfterPopUpOpen = types.isFn(f.on_after_popup_filter_open) ?
|
2014-09-28 13:17:01 +02:00
|
|
|
f.on_after_popup_filter_open : null;
|
|
|
|
//callback function before popup filtes is closed
|
2014-10-12 13:40:08 +02:00
|
|
|
this.onBeforePopUpClose =
|
2014-10-18 14:00:34 +02:00
|
|
|
types.isFn(f.on_before_popup_filter_close) ?
|
2014-09-28 13:17:01 +02:00
|
|
|
f.on_before_popup_filter_close : null;
|
|
|
|
//callback function after popup filtes is closed
|
2014-10-18 14:00:34 +02:00
|
|
|
this.onAfterPopUpClose = types.isFn(f.on_after_popup_filter_close) ?
|
2014-09-28 13:17:01 +02:00
|
|
|
f.on_after_popup_filter_close : null;
|
2014-09-20 15:56:35 +02:00
|
|
|
this.externalFltTgtIds = [];
|
2014-09-28 13:17:01 +02:00
|
|
|
//stores filters spans
|
|
|
|
this.popUpFltSpans = [];
|
|
|
|
//stores filters icons
|
|
|
|
this.popUpFltImgs = [];
|
|
|
|
//stores filters containers
|
|
|
|
this.popUpFltElms = this.popUpFltElmCache || [];
|
2014-09-20 15:56:35 +02:00
|
|
|
this.popUpFltAdjustToContainer = true;
|
|
|
|
|
2014-09-30 11:19:12 +02:00
|
|
|
function onClick(e){
|
2014-10-18 14:00:34 +02:00
|
|
|
var evt = e || global.event,
|
2014-10-06 13:08:29 +02:00
|
|
|
colIndex = parseInt(this.getAttribute('ci'), 10);
|
2014-09-30 11:19:12 +02:00
|
|
|
|
|
|
|
o.CloseAllPopupFilters(colIndex);
|
|
|
|
o.TogglePopupFilter(colIndex);
|
|
|
|
|
|
|
|
if(o.popUpFltAdjustToContainer){
|
|
|
|
var popUpDiv = o.popUpFltElms[colIndex],
|
|
|
|
header = o.GetHeaderElement(colIndex),
|
|
|
|
headerWidth = header.clientWidth * 0.95;
|
2014-11-01 15:34:37 +01:00
|
|
|
if(hlp.isIE()){
|
2014-10-18 14:00:34 +02:00
|
|
|
var headerLeft = dom.position(header).left;
|
2014-09-30 11:19:12 +02:00
|
|
|
popUpDiv.style.left = (headerLeft) + 'px';
|
|
|
|
}
|
2014-10-06 13:08:29 +02:00
|
|
|
popUpDiv.style.width = parseInt(headerWidth, 10) + 'px';
|
2014-09-30 11:19:12 +02:00
|
|
|
}
|
2014-10-18 14:00:34 +02:00
|
|
|
evt.cancel(evt);
|
|
|
|
evt.stop(evt);
|
2014-09-30 11:19:12 +02:00
|
|
|
}
|
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
var o = this;
|
|
|
|
for(var i=0; i<this.nbCells; i++){
|
2014-09-30 11:19:12 +02:00
|
|
|
if(this['col'+i] == this.fltTypeNone){
|
|
|
|
continue;
|
|
|
|
}
|
2014-10-18 14:00:34 +02:00
|
|
|
var popUpSpan = dom.create(
|
2014-09-30 11:19:12 +02:00
|
|
|
'span', ['id', this.prfxPopUpSpan+this.id+'_'+i], ['ci',i]);
|
2014-09-20 15:56:35 +02:00
|
|
|
popUpSpan.innerHTML = this.popUpImgFltHtml;
|
|
|
|
var header = this.GetHeaderElement(i);
|
|
|
|
header.appendChild(popUpSpan);
|
2014-09-30 11:19:12 +02:00
|
|
|
popUpSpan.onclick = onClick;
|
2014-09-20 15:56:35 +02:00
|
|
|
this.popUpFltSpans[i] = popUpSpan;
|
|
|
|
this.popUpFltImgs[i] = popUpSpan.firstChild;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- generates all popup filters div
|
|
|
|
=====================================================*/
|
2014-09-30 11:19:12 +02:00
|
|
|
SetPopupFilters: function(){
|
|
|
|
for(var i=0; i<this.popUpFltElmCache.length; i++){
|
2014-09-20 15:56:35 +02:00
|
|
|
this.SetPopupFilter(i, this.popUpFltElmCache[i]);
|
2014-09-30 11:19:12 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- generates a popup filters div for specifies
|
|
|
|
column
|
|
|
|
=====================================================*/
|
2014-09-30 11:19:12 +02:00
|
|
|
SetPopupFilter: function(colIndex, div){
|
|
|
|
var popUpDiv = !div ?
|
2014-10-18 14:00:34 +02:00
|
|
|
dom.create('div',['id',this.prfxPopUpDiv+this.id+'_'+colIndex]) :
|
2014-09-30 11:19:12 +02:00
|
|
|
div;
|
2014-09-20 15:56:35 +02:00
|
|
|
popUpDiv.className = this.popUpDivCssClass;
|
|
|
|
this.externalFltTgtIds.push(this.prfxPopUpDiv+this.id+'_'+colIndex);
|
|
|
|
var header = this.GetHeaderElement(colIndex);
|
|
|
|
header.insertBefore(popUpDiv, header.firstChild);
|
2014-10-18 14:00:34 +02:00
|
|
|
popUpDiv.onclick = function(e){ evt.stop(e || global.event); };
|
2014-09-20 15:56:35 +02:00
|
|
|
this.popUpFltElms[colIndex] = popUpDiv;
|
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- toggles popup filters div
|
|
|
|
=====================================================*/
|
2014-09-30 11:19:12 +02:00
|
|
|
TogglePopupFilter: function(colIndex){
|
2014-09-20 15:56:35 +02:00
|
|
|
var popUpFltElm = this.popUpFltElms[colIndex];
|
2014-09-30 11:19:12 +02:00
|
|
|
if(popUpFltElm.style.display === 'none' ||
|
|
|
|
popUpFltElm.style.display === ''){
|
|
|
|
if(this.onBeforePopUpOpen){
|
|
|
|
this.onBeforePopUpOpen.call(
|
|
|
|
null,this, this.popUpFltElms[colIndex],colIndex);
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
popUpFltElm.style.display = 'block';
|
2014-09-30 11:19:12 +02:00
|
|
|
if(this['col'+colIndex] === this.fltTypeInp){
|
|
|
|
this.GetFilterElement(colIndex).focus();
|
|
|
|
}
|
|
|
|
if(this.onAfterPopUpOpen){
|
|
|
|
this.onAfterPopUpOpen.call(
|
|
|
|
null,this, this.popUpFltElms[colIndex],colIndex);
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
} else {
|
2014-09-30 11:19:12 +02:00
|
|
|
if(this.onBeforePopUpClose){
|
|
|
|
this.onBeforePopUpClose.call(
|
|
|
|
null,this, this.popUpFltElms[colIndex],colIndex);
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
popUpFltElm.style.display = 'none';
|
2014-09-30 11:19:12 +02:00
|
|
|
if(this.onAfterPopUpClose){
|
|
|
|
this.onAfterPopUpClose.call(
|
|
|
|
null,this, this.popUpFltElms[colIndex],colIndex);
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
|
|
|
},
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
/*====================================================
|
|
|
|
- closes all popup filters
|
|
|
|
=====================================================*/
|
2014-09-30 11:19:12 +02:00
|
|
|
CloseAllPopupFilters: function(exceptColIndex){
|
2014-09-20 15:56:35 +02:00
|
|
|
for(var i=0; i<this.popUpFltElms.length; i++){
|
2014-09-30 11:19:12 +02:00
|
|
|
if(i === exceptColIndex){
|
|
|
|
continue;
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
var popUpFltElm = this.popUpFltElms[i];
|
2014-09-30 11:19:12 +02:00
|
|
|
if(popUpFltElm){
|
|
|
|
popUpFltElm.style.display = 'none';
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
/*====================================================
|
|
|
|
- removes popup filters div
|
|
|
|
=====================================================*/
|
2014-09-30 11:19:12 +02:00
|
|
|
RemovePopupFilters: function(){
|
2014-09-20 15:56:35 +02:00
|
|
|
this.popUpFltElmCache = [];
|
|
|
|
for(var i=0; i<this.popUpFltElms.length; i++){
|
2014-09-30 11:19:12 +02:00
|
|
|
var popUpFltElm = this.popUpFltElms[i],
|
|
|
|
popUpFltSpan = this.popUpFltSpans[i];
|
2014-09-20 15:56:35 +02:00
|
|
|
if(popUpFltElm){
|
|
|
|
popUpFltElm.parentNode.removeChild(popUpFltElm);
|
|
|
|
this.popUpFltElmCache[i] = popUpFltElm;
|
|
|
|
}
|
|
|
|
popUpFltElm = null;
|
2014-09-30 11:19:12 +02:00
|
|
|
if(popUpFltSpan){
|
|
|
|
popUpFltSpan.parentNode.removeChild(popUpFltSpan);
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
popUpFltSpan = null;
|
|
|
|
}
|
|
|
|
},
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
/*====================================================
|
|
|
|
- sets inactive or active filter icon
|
|
|
|
=====================================================*/
|
2014-09-30 11:19:12 +02:00
|
|
|
SetPopupFilterIcon: function(colIndex, active){
|
|
|
|
var activeImg = active===undefined ? true : active;
|
|
|
|
if(this.popUpFltImgs[colIndex]){
|
|
|
|
this.popUpFltImgs[colIndex].src = active ?
|
|
|
|
this.popUpImgFltActive : this.popUpImgFlt;
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- sets inactive or active filter icon for all
|
|
|
|
filters
|
|
|
|
=====================================================*/
|
2014-09-30 11:19:12 +02:00
|
|
|
SetAllPopupFiltersIcon: function(active){
|
|
|
|
var activeImg = active===undefined ? false : active;
|
|
|
|
for(var i=0; i<this.popUpFltImgs.length; i++){
|
2014-09-20 15:56:35 +02:00
|
|
|
this.SetPopupFilterIcon(i, false);
|
2014-09-30 11:19:12 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
/*==============================================
|
|
|
|
- stores filters' values in a cookie
|
|
|
|
when Filter() method is called
|
|
|
|
- Params:
|
|
|
|
- name: cookie name (string)
|
|
|
|
- credits to Florent Hirchy
|
|
|
|
===============================================*/
|
2014-09-30 11:19:12 +02:00
|
|
|
RememberFiltersValue: function(name){
|
2014-09-20 15:56:35 +02:00
|
|
|
var flt_values = [];
|
2014-09-30 11:19:12 +02:00
|
|
|
//store filters' values
|
|
|
|
for(var i=0; i<this.fltIds.length; i++){
|
|
|
|
var value = this.GetFilterValue(i);
|
|
|
|
if (value === ''){
|
|
|
|
value = ' ';
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
flt_values.push(value);
|
|
|
|
}
|
2014-09-30 11:19:12 +02:00
|
|
|
//adds array size
|
|
|
|
flt_values.push(this.fltIds.length);
|
|
|
|
//writes cookie
|
2014-10-18 14:00:34 +02:00
|
|
|
cookie.write(
|
2014-09-20 15:56:35 +02:00
|
|
|
name,
|
|
|
|
flt_values.join(this.separator),
|
|
|
|
this.cookieDuration
|
2014-09-30 11:19:12 +02:00
|
|
|
);
|
2014-09-20 15:56:35 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
/*==============================================
|
|
|
|
- stores page number value in a cookie
|
|
|
|
when ChangePage method is called
|
|
|
|
- Params:
|
|
|
|
- name: cookie name (string)
|
|
|
|
===============================================*/
|
2014-09-30 11:19:12 +02:00
|
|
|
RememberPageNb: function(name){
|
2014-10-18 14:00:34 +02:00
|
|
|
cookie.write(
|
2014-09-20 15:56:35 +02:00
|
|
|
name,
|
|
|
|
this.currentPageNb,
|
|
|
|
this.cookieDuration
|
2014-09-30 11:19:12 +02:00
|
|
|
);
|
2014-09-20 15:56:35 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
/*==============================================
|
|
|
|
- stores page length value in a cookie
|
|
|
|
when ChangePageLength method is called
|
|
|
|
- Params:
|
|
|
|
- name: cookie name (string)
|
|
|
|
===============================================*/
|
2014-09-30 11:19:12 +02:00
|
|
|
RememberPageLength: function(name){
|
2014-10-18 14:00:34 +02:00
|
|
|
cookie.write(
|
2014-09-20 15:56:35 +02:00
|
|
|
name,
|
|
|
|
this.resultsPerPageSlc.selectedIndex,
|
|
|
|
this.cookieDuration
|
2014-09-30 11:19:12 +02:00
|
|
|
);
|
2014-09-20 15:56:35 +02:00
|
|
|
},
|
|
|
|
|
2014-09-30 11:19:12 +02:00
|
|
|
ResetValues: function(){
|
2014-09-20 15:56:35 +02:00
|
|
|
this.EvtManager(this.Evt.name.resetvalues);
|
|
|
|
},
|
|
|
|
|
|
|
|
/*==============================================
|
|
|
|
- re-sets grid values when page is
|
|
|
|
re-loaded. It invokes ResetGridValues,
|
|
|
|
ResetPage and ResetPageLength methods
|
|
|
|
- Params:
|
|
|
|
- name: cookie name (string)
|
|
|
|
===============================================*/
|
2014-09-30 11:19:12 +02:00
|
|
|
_ResetValues: function(){
|
|
|
|
//only fillSlcOnDemand
|
|
|
|
if(this.rememberGridValues && this.fillSlcOnDemand){
|
2014-09-20 15:56:35 +02:00
|
|
|
this.ResetGridValues(this.fltsValuesCookie);
|
2014-09-30 11:19:12 +02:00
|
|
|
}
|
|
|
|
if(this.rememberPageLen){
|
|
|
|
this.ResetPageLength(this.pgLenCookie);
|
|
|
|
}
|
|
|
|
if(this.rememberPageNb){
|
|
|
|
this.ResetPage(this.pgNbCookie);
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
/*==============================================
|
|
|
|
- re-sets filters' values when page is
|
|
|
|
re-loaded if load on demand is enabled
|
|
|
|
- Params:
|
|
|
|
- name: cookie name (string)
|
|
|
|
- credits to Florent Hirchy
|
|
|
|
===============================================*/
|
2014-09-30 11:19:12 +02:00
|
|
|
ResetGridValues: function(name){
|
|
|
|
if(!this.fillSlcOnDemand){
|
|
|
|
return;
|
|
|
|
}
|
2014-10-18 14:00:34 +02:00
|
|
|
var flts = cookie.read(name),
|
2014-09-30 11:19:12 +02:00
|
|
|
reg = new RegExp(this.separator,'g'),
|
|
|
|
//creates an array with filters' values
|
|
|
|
flts_values = flts.split(reg),
|
|
|
|
slcFltsIndex = this.GetFiltersByType(this.fltTypeSlc, true),
|
|
|
|
multiFltsIndex = this.GetFiltersByType(this.fltTypeMulti, true);
|
|
|
|
|
|
|
|
//if the number of columns is the same as before page reload
|
|
|
|
if(flts_values[(flts_values.length-1)] === this.fltIds.length){
|
|
|
|
for(var i=0; i<(flts_values.length - 1); i++){
|
2014-10-04 16:38:42 +02:00
|
|
|
if(flts_values[i]===' '){
|
2014-09-30 11:19:12 +02:00
|
|
|
continue;
|
|
|
|
}
|
2014-10-04 16:38:42 +02:00
|
|
|
var s, opt;
|
2014-09-30 11:19:12 +02:00
|
|
|
// if fillSlcOnDemand, drop-down needs to contain stored
|
|
|
|
// value(s) for filtering
|
|
|
|
if(this['col'+i]===this.fltTypeSlc ||
|
|
|
|
this['col'+i]===this.fltTypeMulti){
|
2014-11-01 15:34:37 +01:00
|
|
|
var slc = dom.id( this.fltIds[i] );
|
2014-09-20 15:56:35 +02:00
|
|
|
slc.options[0].selected = false;
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-30 11:19:12 +02:00
|
|
|
//selects
|
2014-10-18 14:00:34 +02:00
|
|
|
if(array.has(slcFltsIndex, i)){
|
|
|
|
opt = dom.createOpt(flts_values[i],flts_values[i],true);
|
2014-09-20 15:56:35 +02:00
|
|
|
slc.appendChild(opt);
|
|
|
|
this.hasStoredValues = true;
|
|
|
|
}
|
2014-09-30 11:19:12 +02:00
|
|
|
//multiple select
|
2014-10-18 14:00:34 +02:00
|
|
|
if(array.has(multiFltsIndex, i)){
|
2014-10-04 16:38:42 +02:00
|
|
|
s = flts_values[i].split(' '+this.orOperator+' ');
|
2014-09-30 11:19:12 +02:00
|
|
|
for(j=0; j<s.length; j++){
|
2014-10-04 16:38:42 +02:00
|
|
|
if(s[j]===''){
|
|
|
|
continue;
|
|
|
|
}
|
2014-10-18 14:00:34 +02:00
|
|
|
opt = dom.createOpt(s[j],s[j],true);
|
2014-09-20 15:56:35 +02:00
|
|
|
slc.appendChild(opt);
|
2014-09-07 12:07:28 +02:00
|
|
|
this.hasStoredValues = true;
|
2014-09-20 15:56:35 +02:00
|
|
|
|
2014-10-04 16:38:42 +02:00
|
|
|
// IE multiple selection work-around
|
2014-11-01 15:34:37 +01:00
|
|
|
if(hlp.isIE()){
|
2014-09-20 15:56:35 +02:00
|
|
|
this.__deferMultipleSelection(slc,j,false);
|
|
|
|
hasStoredValues = false;
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}// if multiFltsIndex
|
|
|
|
}
|
2014-10-04 16:38:42 +02:00
|
|
|
else if(this['col'+i]==this.fltTypeCheckList){
|
2014-09-20 15:56:35 +02:00
|
|
|
var divChk = this.checkListDiv[i];
|
|
|
|
divChk.title = divChk.innerHTML;
|
|
|
|
divChk.innerHTML = '';
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-10-18 14:00:34 +02:00
|
|
|
var ul = dom.create(
|
2014-10-04 16:38:42 +02:00
|
|
|
'ul',['id',this.fltIds[i]],['colIndex',i]);
|
2014-09-20 15:56:35 +02:00
|
|
|
ul.className = this.checkListCssClass;
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-10-18 14:00:34 +02:00
|
|
|
var li0 = dom.createCheckItem(
|
2014-10-04 16:38:42 +02:00
|
|
|
this.fltIds[i]+'_0', '', this.displayAllText);
|
2014-09-20 15:56:35 +02:00
|
|
|
li0.className = this.checkListItemCssClass;
|
|
|
|
ul.appendChild(li0);
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
divChk.appendChild(ul);
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-10-04 16:38:42 +02:00
|
|
|
flts_values[i].split(' '+this.orOperator+' ');
|
|
|
|
for(j=0; j<s.length; j++){
|
|
|
|
if(s[j]===''){
|
|
|
|
continue;
|
|
|
|
}
|
2014-10-18 14:00:34 +02:00
|
|
|
var li = dom.createCheckItem(
|
2014-10-04 16:38:42 +02:00
|
|
|
this.fltIds[i]+'_'+(j+1), s[j], s[j]);
|
2014-09-20 15:56:35 +02:00
|
|
|
li.className = this.checkListItemCssClass;
|
|
|
|
ul.appendChild(li);
|
|
|
|
li.check.checked = true;
|
|
|
|
this.__setCheckListValues(li.check);
|
|
|
|
this.hasStoredValues = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}//end for
|
|
|
|
|
|
|
|
if(!this.hasStoredValues && this.paging) this.SetPagingInfo();
|
|
|
|
}//end if
|
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- CSS solution making headers fixed
|
|
|
|
=====================================================*/
|
2014-10-04 16:38:42 +02:00
|
|
|
SetFixedHeaders: function(){
|
|
|
|
if((!this.hasGrid && !this.isFirstLoad) || !this.fixedHeaders){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(this.contDiv){
|
|
|
|
return;
|
|
|
|
}
|
2014-11-01 15:34:37 +01:00
|
|
|
var thead = dom.tag(this.tbl,'thead');
|
2014-10-04 16:38:42 +02:00
|
|
|
if(thead.length===0){
|
|
|
|
return;
|
|
|
|
}
|
2014-11-01 15:34:37 +01:00
|
|
|
var tbody = dom.tag(this.tbl,'tbody');
|
2014-10-04 16:38:42 +02:00
|
|
|
//firefox returns tbody height
|
|
|
|
if(tbody[0].clientHeight!==0){
|
2014-09-20 15:56:35 +02:00
|
|
|
//previous values
|
|
|
|
this.prevTBodyH = tbody[0].clientHeight;
|
|
|
|
this.prevTBodyOverflow = tbody[0].style.overflow;
|
|
|
|
this.prevTBodyOverflowX = tbody[0].style.overflowX;
|
|
|
|
|
|
|
|
tbody[0].style.height = this.tBodyH+'px';
|
|
|
|
tbody[0].style.overflow = 'auto';
|
|
|
|
tbody[0].style.overflowX = 'hidden';
|
|
|
|
} else { //IE returns 0
|
|
|
|
// cont div is added to emulate fixed headers behaviour
|
2014-10-18 14:00:34 +02:00
|
|
|
var contDiv = dom.create(
|
2014-10-04 16:38:42 +02:00
|
|
|
'div',['id',this.prfxContentDiv+this.id]);
|
2014-09-20 15:56:35 +02:00
|
|
|
contDiv.className = this.contDivCssClass;
|
|
|
|
this.tbl.parentNode.insertBefore(contDiv, this.tbl);
|
|
|
|
contDiv.appendChild(this.tbl);
|
2014-11-01 15:34:37 +01:00
|
|
|
this.contDiv = dom.id(this.prfxContentDiv+this.id);
|
2014-09-20 15:56:35 +02:00
|
|
|
//prevents headers moving during window scroll (IE)
|
|
|
|
this.contDiv.style.position = 'relative';
|
|
|
|
|
|
|
|
var theadH = 0;
|
2014-11-01 15:34:37 +01:00
|
|
|
var theadTr = dom.tag(thead[0],'tr');
|
2014-10-04 16:38:42 +02:00
|
|
|
//css below emulates fixed headers on IE<=6
|
|
|
|
for(var i=0; i<theadTr.length; i++){
|
2014-09-20 15:56:35 +02:00
|
|
|
theadTr[i].style.cssText += 'position:relative; ' +
|
2014-10-04 16:38:42 +02:00
|
|
|
'top:expression(offsetParent.scrollTop);';
|
2014-10-06 13:08:29 +02:00
|
|
|
theadH += parseInt(theadTr[i].clientHeight, 10);
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
this.contDiv.style.height = (this.tBodyH+theadH)+'px';
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-11-01 15:34:37 +01:00
|
|
|
var tfoot = dom.tag(this.tbl,'tfoot');
|
2014-10-04 16:38:42 +02:00
|
|
|
if(tfoot.length===0){
|
|
|
|
return;
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
|
2014-11-01 15:34:37 +01:00
|
|
|
var tfootTr = dom.tag(tfoot[0],'tr');
|
2014-09-20 15:56:35 +02:00
|
|
|
|
2014-10-04 16:38:42 +02:00
|
|
|
//css below emulates fixed footer on IE<=6
|
|
|
|
for(var j=0; j<tfootTr.length; j++){
|
|
|
|
tfootTr[j].style.cssText +=
|
|
|
|
'position:relative; overflow-x: hidden; ' +
|
|
|
|
'top: expression(parentNode.parentNode.offsetHeight >= ' +
|
|
|
|
'offsetParent.offsetHeight ? ' +
|
|
|
|
'0 - parentNode.parentNode.offsetHeight + '+
|
|
|
|
'offsetParent.offsetHeight + offsetParent.scrollTop : 0);';
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- Removes fixed headers
|
|
|
|
=====================================================*/
|
|
|
|
RemoveFixedHeaders: function(){
|
|
|
|
if(!this.hasGrid || !this.fixedHeaders ) return;
|
2014-10-04 16:38:42 +02:00
|
|
|
|
|
|
|
if(this.contDiv){
|
2014-09-20 15:56:35 +02:00
|
|
|
this.contDiv.parentNode.insertBefore(this.tbl, this.contDiv);
|
|
|
|
this.contDiv.parentNode.removeChild( this.contDiv );
|
|
|
|
this.contDiv = null;
|
2014-11-01 15:34:37 +01:00
|
|
|
var thead = dom.tag(this.tbl,'thead');
|
2014-10-04 16:38:42 +02:00
|
|
|
if(thead.length===0){
|
|
|
|
return;
|
|
|
|
}
|
2014-11-01 15:34:37 +01:00
|
|
|
var theadTr = dom.tag(thead[0],'tr');
|
2014-10-04 16:38:42 +02:00
|
|
|
if(theadTr.length===0){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for(var i=0; i<theadTr.length; i++){
|
2014-09-20 15:56:35 +02:00
|
|
|
theadTr[i].style.cssText = '';
|
2014-10-04 16:38:42 +02:00
|
|
|
}
|
2014-11-01 15:34:37 +01:00
|
|
|
var tfoot = dom.tag(this.tbl,'tfoot');
|
2014-10-04 16:38:42 +02:00
|
|
|
if(tfoot.length===0){
|
|
|
|
return;
|
|
|
|
}
|
2014-11-01 15:34:37 +01:00
|
|
|
var tfootTr = dom.tag(tfoot[0],'tr');
|
2014-10-04 16:38:42 +02:00
|
|
|
for(var j=0; j<tfootTr.length; j++){
|
2014-09-20 15:56:35 +02:00
|
|
|
tfootTr[j].style.position = 'relative';
|
|
|
|
tfootTr[j].style.top = '';
|
|
|
|
tfootTr[j].style.overeflowX = '';
|
|
|
|
}
|
|
|
|
} else {
|
2014-11-01 15:34:37 +01:00
|
|
|
var tbody = dom.tag(this.tbl,'tbody');
|
2014-10-04 16:38:42 +02:00
|
|
|
if(tbody.length===0){
|
|
|
|
return;
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
tbody[0].style.height = this.prevTBodyH+'px';
|
|
|
|
tbody[0].style.overflow = this.prevTBodyOverflow;
|
|
|
|
tbody[0].style.overflowX = this.prevTBodyOverflowX;
|
|
|
|
}
|
|
|
|
},
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-10-04 16:38:42 +02:00
|
|
|
Filter: function(){
|
2014-09-20 15:56:35 +02:00
|
|
|
this.EvtManager(this.Evt.name.filter);
|
|
|
|
},
|
|
|
|
/*====================================================
|
|
|
|
- Filtering fn
|
|
|
|
- retrieves data from each td in every single tr
|
|
|
|
and compares to search string for current
|
|
|
|
column
|
|
|
|
- tr is hidden if all search strings are not
|
|
|
|
found
|
|
|
|
=====================================================*/
|
2014-10-04 16:38:42 +02:00
|
|
|
_Filter: function(){
|
|
|
|
if(!this.fltGrid || (!this.hasGrid && !this.isFirstLoad)){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
//invokes onbefore callback
|
|
|
|
if(this.onBeforeFilter){
|
|
|
|
this.onBeforeFilter.call(null, this);
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-10-04 16:38:42 +02:00
|
|
|
if(this.inpWatermark !== ''){
|
|
|
|
this.SetWatermark(false);
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-10-04 16:38:42 +02:00
|
|
|
var row = this.tbl.rows,
|
|
|
|
f = this.fObj || {},
|
|
|
|
hiddenrows = 0;
|
2014-09-20 15:56:35 +02:00
|
|
|
this.validRowsIndex = [];
|
|
|
|
var o = this;
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
// removes keyword highlighting
|
2014-10-04 16:38:42 +02:00
|
|
|
if(this.highlightKeywords){
|
|
|
|
this.UnhighlightAll();
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
//removes popup filters active icons
|
2014-10-04 16:38:42 +02:00
|
|
|
if(this.popUpFilters){
|
|
|
|
this.SetAllPopupFiltersIcon();
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
//removes active column header class
|
2014-10-04 16:38:42 +02:00
|
|
|
if(this.markActiveColumns){
|
|
|
|
this.ClearActiveColumns();
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
// search args re-init
|
|
|
|
this.searchArgs = this.GetFiltersValue();
|
|
|
|
|
|
|
|
var num_cell_data, nbFormat;
|
2014-10-04 16:38:42 +02:00
|
|
|
var re_le = new RegExp(this.leOperator),
|
|
|
|
re_ge = new RegExp(this.geOperator),
|
|
|
|
re_l = new RegExp(this.lwOperator),
|
|
|
|
re_g = new RegExp(this.grOperator),
|
|
|
|
re_d = new RegExp(this.dfOperator),
|
2014-10-18 14:00:34 +02:00
|
|
|
re_lk = new RegExp(str.rgxEsc(this.lkOperator)),
|
2014-10-04 16:38:42 +02:00
|
|
|
re_eq = new RegExp(this.eqOperator),
|
|
|
|
re_st = new RegExp(this.stOperator),
|
|
|
|
re_en = new RegExp(this.enOperator),
|
|
|
|
re_an = new RegExp(this.anOperator),
|
|
|
|
re_cr = new RegExp(this.curExp),
|
|
|
|
re_em = this.emOperator,
|
|
|
|
re_nm = this.nmOperator,
|
2014-10-18 14:00:34 +02:00
|
|
|
re_re = new RegExp(str.rgxEsc(this.rgxOperator));
|
2014-10-04 16:38:42 +02:00
|
|
|
|
|
|
|
//keyword highlighting
|
|
|
|
function highlight(str, ok, cell){
|
2014-09-20 15:56:35 +02:00
|
|
|
if(o.highlightKeywords && ok){
|
|
|
|
str = str.replace(re_lk,'');
|
|
|
|
str = str.replace(re_eq,'');
|
|
|
|
str = str.replace(re_st,'');
|
|
|
|
str = str.replace(re_en,'');
|
|
|
|
var w = str;
|
2014-10-04 16:38:42 +02:00
|
|
|
if(re_le.test(str) || re_ge.test(str) || re_l.test(str) ||
|
|
|
|
re_g.test(str) || re_d.test(str)){
|
2014-10-18 14:00:34 +02:00
|
|
|
w = dom.getText(cell);
|
2014-10-04 16:38:42 +02:00
|
|
|
}
|
|
|
|
if(w!==''){
|
2014-10-12 13:40:08 +02:00
|
|
|
o.HighlightWord(cell,w,o.highlightCssClass);
|
2014-10-04 16:38:42 +02:00
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
//looks for search argument in current row
|
2014-10-04 16:38:42 +02:00
|
|
|
function hasArg(sA, cell_data, j){
|
2014-09-20 15:56:35 +02:00
|
|
|
var occurence;
|
|
|
|
//Search arg operator tests
|
2014-10-04 16:38:42 +02:00
|
|
|
var hasLO = re_l.test(sA),
|
|
|
|
hasLE = re_le.test(sA),
|
|
|
|
hasGR = re_g.test(sA),
|
|
|
|
hasGE = re_ge.test(sA),
|
|
|
|
hasDF = re_d.test(sA),
|
|
|
|
hasEQ = re_eq.test(sA),
|
|
|
|
hasLK = re_lk.test(sA),
|
|
|
|
hasAN = re_an.test(sA),
|
|
|
|
hasST = re_st.test(sA),
|
|
|
|
hasEN = re_en.test(sA),
|
|
|
|
hasEM = (re_em === sA),
|
|
|
|
hasNM = (re_nm === sA),
|
|
|
|
hasRE = re_re.test(sA);
|
2014-09-20 15:56:35 +02:00
|
|
|
|
|
|
|
//Search arg dates tests
|
2014-10-26 02:42:34 +01:00
|
|
|
var isLDate = hasLO && isValidDate(sA.replace(re_l,''),dtType);
|
|
|
|
var isLEDate = hasLE && isValidDate(sA.replace(re_le,''),dtType);
|
|
|
|
var isGDate = hasGR && isValidDate(sA.replace(re_g,''),dtType);
|
|
|
|
var isGEDate = hasGE && isValidDate(sA.replace(re_ge,''),dtType);
|
|
|
|
var isDFDate = hasDF && isValidDate(sA.replace(re_d,''),dtType);
|
|
|
|
var isEQDate = hasEQ && isValidDate(sA.replace(re_eq,''),dtType);
|
2014-10-04 16:38:42 +02:00
|
|
|
|
|
|
|
var dte1, dte2;
|
|
|
|
//dates
|
2014-10-26 02:42:34 +01:00
|
|
|
if(isValidDate(cell_data,dtType)){
|
|
|
|
dte1 = formatDate(cell_data,dtType);
|
2014-10-04 16:38:42 +02:00
|
|
|
// lower date
|
|
|
|
if(isLDate){
|
2014-10-26 02:42:34 +01:00
|
|
|
dte2 = formatDate(sA.replace(re_l,''),dtType);
|
2014-10-04 16:38:42 +02:00
|
|
|
occurence = dte1 < dte2;
|
|
|
|
}
|
|
|
|
// lower equal date
|
|
|
|
else if(isLEDate){
|
2014-10-26 02:42:34 +01:00
|
|
|
dte2 = formatDate(sA.replace(re_le,''),dtType);
|
2014-10-04 16:38:42 +02:00
|
|
|
occurence = dte1 <= dte2;
|
|
|
|
}
|
|
|
|
// greater equal date
|
|
|
|
else if(isGEDate){
|
2014-10-26 02:42:34 +01:00
|
|
|
dte2 = formatDate(sA.replace(re_ge,''),dtType);
|
2014-10-04 16:38:42 +02:00
|
|
|
occurence = dte1 >= dte2;
|
|
|
|
}
|
|
|
|
// greater date
|
|
|
|
else if(isGDate){
|
2014-10-26 02:42:34 +01:00
|
|
|
dte2 = formatDate(sA.replace(re_g,''),dtType);
|
2014-10-04 16:38:42 +02:00
|
|
|
occurence = dte1 > dte2;
|
|
|
|
}
|
|
|
|
// different date
|
|
|
|
else if(isDFDate){
|
2014-10-26 02:42:34 +01:00
|
|
|
dte2 = formatDate(sA.replace(re_d,''),dtType);
|
2014-10-04 16:38:42 +02:00
|
|
|
occurence = dte1.toString() != dte2.toString();
|
|
|
|
}
|
|
|
|
// equal date
|
|
|
|
else if(isEQDate){
|
2014-10-26 02:42:34 +01:00
|
|
|
dte2 = formatDate(sA.replace(re_eq,''),dtType);
|
2014-10-04 16:38:42 +02:00
|
|
|
occurence = dte1.toString() == dte2.toString();
|
|
|
|
}
|
|
|
|
// searched keyword with * operator doesn't have to be a date
|
|
|
|
else if(re_lk.test(sA)){// like date
|
|
|
|
occurence = o.__containsStr(
|
|
|
|
sA.replace(re_lk,''),cell_data,null,false);
|
|
|
|
}
|
2014-10-26 02:42:34 +01:00
|
|
|
else if(isValidDate(sA,dtType)){
|
|
|
|
dte2 = formatDate(sA,dtType);
|
2014-10-04 16:38:42 +02:00
|
|
|
occurence = dte1.toString() == dte2.toString();
|
|
|
|
}
|
|
|
|
//empty
|
|
|
|
else if(hasEM){
|
2014-10-18 14:00:34 +02:00
|
|
|
occurence = str.isEmpty(cell_data);
|
2014-10-04 16:38:42 +02:00
|
|
|
}
|
|
|
|
//non-empty
|
|
|
|
else if(hasNM){
|
2014-10-18 14:00:34 +02:00
|
|
|
occurence = !str.isEmpty(cell_data);
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-04 16:38:42 +02:00
|
|
|
else{
|
2014-09-20 15:56:35 +02:00
|
|
|
//first numbers need to be formated
|
2014-10-04 16:38:42 +02:00
|
|
|
if(o.hasColNbFormat && o.colNbFormat[j]){
|
2014-10-18 14:00:34 +02:00
|
|
|
num_cell_data = removeNbFormat(
|
2014-10-04 16:38:42 +02:00
|
|
|
cell_data,o.colNbFormat[j]);
|
2014-09-20 15:56:35 +02:00
|
|
|
nbFormat = o.colNbFormat[j];
|
|
|
|
} else {
|
2014-10-04 16:38:42 +02:00
|
|
|
if(o.thousandsSeparator===',' && o.decimalSeparator==='.'){
|
2014-10-18 14:00:34 +02:00
|
|
|
num_cell_data = removeNbFormat(cell_data,'us');
|
2014-09-20 15:56:35 +02:00
|
|
|
nbFormat = 'us';
|
2014-09-07 12:07:28 +02:00
|
|
|
} else {
|
2014-10-18 14:00:34 +02:00
|
|
|
num_cell_data = removeNbFormat(cell_data,'eu');
|
2014-09-20 15:56:35 +02:00
|
|
|
nbFormat = 'eu';
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-10-04 16:38:42 +02:00
|
|
|
// first checks if there is any operator (<,>,<=,>=,!,*,=,{,},
|
|
|
|
// rgx:)
|
|
|
|
// lower equal
|
|
|
|
if(hasLE){
|
2014-10-18 14:00:34 +02:00
|
|
|
occurence = num_cell_data <= removeNbFormat(
|
2014-10-04 16:38:42 +02:00
|
|
|
sA.replace(re_le,''),nbFormat);
|
|
|
|
}
|
|
|
|
//greater equal
|
|
|
|
else if(hasGE){
|
2014-10-18 14:00:34 +02:00
|
|
|
occurence = num_cell_data >= removeNbFormat(
|
2014-10-04 16:38:42 +02:00
|
|
|
sA.replace(re_ge,''),nbFormat);
|
|
|
|
}
|
|
|
|
//lower
|
|
|
|
else if(hasLO){
|
2014-10-18 14:00:34 +02:00
|
|
|
occurence = num_cell_data < removeNbFormat(
|
2014-10-04 16:38:42 +02:00
|
|
|
sA.replace(re_l,''),nbFormat);
|
|
|
|
}
|
|
|
|
//greater
|
|
|
|
else if(hasGR){
|
2014-10-18 14:00:34 +02:00
|
|
|
occurence = num_cell_data > removeNbFormat(
|
2014-10-04 16:38:42 +02:00
|
|
|
sA.replace(re_g,''),nbFormat);
|
|
|
|
}
|
|
|
|
//different
|
|
|
|
else if(hasDF){
|
|
|
|
occurence = o.__containsStr(
|
|
|
|
sA.replace(re_d,''),cell_data) ? false : true;
|
|
|
|
}
|
|
|
|
//like
|
|
|
|
else if(hasLK){
|
|
|
|
occurence = o.__containsStr(
|
|
|
|
sA.replace(re_lk,''),cell_data,null,false);
|
|
|
|
}
|
|
|
|
//equal
|
|
|
|
else if(hasEQ){
|
|
|
|
occurence = o.__containsStr(
|
|
|
|
sA.replace(re_eq,''),cell_data,null,true);
|
|
|
|
}
|
|
|
|
//starts with
|
|
|
|
else if(hasST){
|
|
|
|
occurence = cell_data.indexOf(sA.replace(re_st,''))===0 ?
|
|
|
|
true : false;
|
|
|
|
}
|
|
|
|
//ends with
|
|
|
|
else if(hasEN){
|
2014-09-20 15:56:35 +02:00
|
|
|
var searchArg = sA.replace(re_en,'');
|
2014-10-04 16:38:42 +02:00
|
|
|
occurence =
|
|
|
|
cell_data.lastIndexOf(searchArg,cell_data.length-1) ===
|
|
|
|
(cell_data.length-1)-(searchArg.length-1) &&
|
|
|
|
cell_data.lastIndexOf(
|
|
|
|
searchArg,cell_data.length-1) > -1 ? true : false;
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
2014-10-04 16:38:42 +02:00
|
|
|
//empty
|
|
|
|
else if(hasEM){
|
2014-10-18 14:00:34 +02:00
|
|
|
occurence = str.isEmpty(cell_data);
|
2014-10-04 16:38:42 +02:00
|
|
|
}
|
|
|
|
//non-empty
|
|
|
|
else if(hasNM){
|
2014-10-18 14:00:34 +02:00
|
|
|
occurence = !str.isEmpty(cell_data);
|
2014-10-04 16:38:42 +02:00
|
|
|
}
|
|
|
|
//regexp
|
|
|
|
else if(hasRE){
|
|
|
|
//in case regexp fires an exception
|
|
|
|
try{
|
|
|
|
//operator is removed
|
|
|
|
var srchArg = sA.replace(re_re,'');
|
|
|
|
var rgx = new RegExp(srchArg);
|
2014-09-20 15:56:35 +02:00
|
|
|
occurence = rgx.test(cell_data);
|
|
|
|
} catch(e) { occurence = false; }
|
|
|
|
}
|
2014-10-04 16:38:42 +02:00
|
|
|
else{
|
|
|
|
var fCol = f['col_'+j];
|
|
|
|
occurence = o.__containsStr(
|
|
|
|
sA, cell_data, !fCol ? this.fltTypeInp : fCol);
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
}//else
|
|
|
|
return occurence;
|
|
|
|
}//fn
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-10-04 16:38:42 +02:00
|
|
|
for(var k=this.refRow; k<this.nbRows; k++){
|
2014-09-20 15:56:35 +02:00
|
|
|
/*** if table already filtered some rows are not visible ***/
|
2014-10-04 16:38:42 +02:00
|
|
|
if(row[k].style.display === 'none'){
|
|
|
|
row[k].style.display = '';
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-10-04 16:38:42 +02:00
|
|
|
var cell = row[k].cells,
|
|
|
|
nchilds = cell.length;
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
// checks if row has exact cell #
|
2014-10-04 16:38:42 +02:00
|
|
|
if(nchilds !== this.nbCells){
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
var occurence = [],
|
|
|
|
isRowValid = this.searchType==='include' ? true : false,
|
|
|
|
//only for single filter search
|
|
|
|
singleFltRowValid = false;
|
|
|
|
|
|
|
|
// this loop retrieves cell data
|
|
|
|
for(var j=0; j<nchilds; j++){
|
|
|
|
//searched keyword
|
|
|
|
var sA = this.searchArgs[this.singleSearchFlt ? 0 : j],
|
|
|
|
dtType = this.hasColDateType ?
|
|
|
|
this.colDateType[j] : this.defaultDateType;
|
|
|
|
if(sA===''){
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2014-10-18 14:00:34 +02:00
|
|
|
var cell_data = str.matchCase(
|
2014-10-12 13:40:08 +02:00
|
|
|
this.GetCellData(j, cell[j]), this.matchCase);
|
2014-10-04 16:38:42 +02:00
|
|
|
|
|
|
|
//multiple search parameter operator ||
|
|
|
|
var sAOrSplit = sA.split(this.orOperator),
|
|
|
|
//multiple search || parameter boolean
|
|
|
|
hasMultiOrSA = (sAOrSplit.length>1) ? true : false,
|
|
|
|
//multiple search parameter operator &&
|
|
|
|
sAAndSplit = sA.split(this.anOperator),
|
|
|
|
//multiple search && parameter boolean
|
|
|
|
hasMultiAndSA = sAAndSplit.length>1 ? true : false;
|
|
|
|
|
|
|
|
//multiple sarch parameters
|
|
|
|
if(hasMultiOrSA || hasMultiAndSA){
|
|
|
|
var cS,
|
|
|
|
occur = false,
|
|
|
|
s = hasMultiOrSA ? sAOrSplit : sAAndSplit;
|
|
|
|
for(var w=0; w<s.length; w++){
|
2014-10-18 14:00:34 +02:00
|
|
|
cS = str.trim(s[w]);
|
2014-09-20 15:56:35 +02:00
|
|
|
occur = hasArg(cS,cell_data,j);
|
|
|
|
highlight(cS,occur,cell[j]);
|
2014-10-04 16:38:42 +02:00
|
|
|
if(hasMultiOrSA && occur){
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if(hasMultiAndSA && !occur){
|
|
|
|
break;
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
|
|
|
occurence[j] = occur;
|
|
|
|
}
|
2014-10-04 16:38:42 +02:00
|
|
|
//single search parameter
|
|
|
|
else {
|
2014-10-18 14:00:34 +02:00
|
|
|
occurence[j] = hasArg(str.trim(sA), cell_data, j);
|
2014-09-20 15:56:35 +02:00
|
|
|
highlight(sA,occurence[j],cell[j]);
|
|
|
|
}//else single param
|
|
|
|
|
2014-10-04 16:38:42 +02:00
|
|
|
if(!occurence[j]){
|
|
|
|
isRowValid = this.searchType==='include' ? false : true;
|
|
|
|
}
|
|
|
|
if(this.singleSearchFlt && occurence[j]){
|
|
|
|
singleFltRowValid = true;
|
|
|
|
}
|
|
|
|
if(this.popUpFilters){
|
|
|
|
this.SetPopupFilterIcon(j, true);
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
if(this.markActiveColumns){
|
2014-10-04 16:38:42 +02:00
|
|
|
if(k === this.refRow){
|
|
|
|
if(this.onBeforeActiveColumn){
|
|
|
|
this.onBeforeActiveColumn.call(null, this, j);
|
|
|
|
}
|
2014-10-18 14:00:34 +02:00
|
|
|
dom.addClass(
|
2014-10-04 16:38:42 +02:00
|
|
|
this.GetHeaderElement(j),
|
|
|
|
this.activeColumnsCssClass);
|
|
|
|
if(this.onAfterActiveColumn){
|
|
|
|
this.onAfterActiveColumn.call(null, this, j);
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}//for j
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-10-04 16:38:42 +02:00
|
|
|
if(this.singleSearchFlt && singleFltRowValid){
|
|
|
|
isRowValid = true;
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-10-04 16:38:42 +02:00
|
|
|
if(!isRowValid){
|
2014-09-20 15:56:35 +02:00
|
|
|
this.SetRowValidation(k,false);
|
|
|
|
// always visible rows need to be counted as valid
|
2014-10-18 14:00:34 +02:00
|
|
|
if(this.hasVisibleRows && array.has(this.visibleRows, k) &&
|
2014-10-04 16:38:42 +02:00
|
|
|
!this.paging){
|
2014-09-20 15:56:35 +02:00
|
|
|
this.validRowsIndex.push(k);
|
2014-10-04 16:38:42 +02:00
|
|
|
} else {
|
2014-09-20 15:56:35 +02:00
|
|
|
hiddenrows++;
|
2014-10-04 16:38:42 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
} else {
|
|
|
|
this.SetRowValidation(k,true);
|
|
|
|
this.validRowsIndex.push(k);
|
2014-10-04 16:38:42 +02:00
|
|
|
if(this.alternateBgs){
|
2014-11-09 09:31:15 +01:00
|
|
|
this.Cpt.alternateRows.setRowBg(
|
|
|
|
k, this.validRowsIndex.length);
|
2014-10-04 16:38:42 +02:00
|
|
|
}
|
|
|
|
if(this.onRowValidated){
|
|
|
|
this.onRowValidated.call(null,this,k);
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}// for k
|
|
|
|
|
|
|
|
this.nbVisibleRows = this.validRowsIndex.length;
|
|
|
|
this.nbHiddenRows = hiddenrows;
|
|
|
|
this.isStartBgAlternate = false;
|
2014-10-04 16:38:42 +02:00
|
|
|
if(this.rememberGridValues){
|
|
|
|
this.RememberFiltersValue(this.fltsValuesCookie);
|
|
|
|
}
|
|
|
|
//applies filter props after filtering process
|
|
|
|
if(!this.paging){
|
|
|
|
this.ApplyGridProps();
|
|
|
|
} else {
|
2014-09-20 15:56:35 +02:00
|
|
|
this.startPagingRow = 0;
|
|
|
|
this.currentPageNb = 1;
|
|
|
|
this.SetPagingInfo(this.validRowsIndex);
|
|
|
|
}//starts paging process
|
2014-10-04 16:38:42 +02:00
|
|
|
//invokes onafter callback
|
|
|
|
if(this.onAfterFilter){
|
|
|
|
this.onAfterFilter.call(null,this);
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- checks methods that should be called
|
|
|
|
after filtering and/or paging process
|
|
|
|
=====================================================*/
|
2014-10-04 16:38:42 +02:00
|
|
|
ApplyGridProps: function(){
|
|
|
|
// blurs active filter (IE)
|
|
|
|
if(this.activeFlt &&
|
2014-10-18 14:00:34 +02:00
|
|
|
str.lower(this.activeFlt.nodeName)===this.fltTypeSlc &&
|
2014-10-04 16:38:42 +02:00
|
|
|
!this.popUpFilters){
|
2014-09-20 15:56:35 +02:00
|
|
|
this.activeFlt.blur();
|
2014-10-04 16:38:42 +02:00
|
|
|
if(this.activeFlt.parentNode){
|
|
|
|
this.activeFlt.parentNode.focus();
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-10-04 16:38:42 +02:00
|
|
|
//shows rows always visible
|
|
|
|
if(this.visibleRows)
|
|
|
|
this.SetVisibleRows();
|
|
|
|
//makes operation on a col
|
|
|
|
if(this.colOperation){
|
|
|
|
this.SetColOperation();
|
|
|
|
}
|
|
|
|
//re-populates drop-down filters
|
|
|
|
if(this.refreshFilters){
|
|
|
|
this.RefreshFiltersGrid();
|
|
|
|
}
|
|
|
|
var nr = !this.paging && this.hasVisibleRows ?
|
|
|
|
this.nbVisibleRows - this.visibleRows.length : this.nbVisibleRows;
|
|
|
|
//refreshes rows counter
|
|
|
|
if(this.rowsCounter){
|
|
|
|
this.RefreshNbRows(nr);
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
|
2014-10-04 16:38:42 +02:00
|
|
|
if(this.inpWatermark !== ''){
|
|
|
|
this.SetWatermark(true);
|
|
|
|
}
|
|
|
|
if(this.popUpFilters){
|
|
|
|
this.CloseAllPopupFilters();
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- returns an array containing cell values of
|
|
|
|
a column
|
|
|
|
- needs following args:
|
|
|
|
- column index (number)
|
|
|
|
- a boolean set to true if we want only
|
|
|
|
numbers to be returned
|
|
|
|
- array containing rows index to be excluded
|
|
|
|
from returned values
|
|
|
|
=====================================================*/
|
2014-10-04 16:38:42 +02:00
|
|
|
GetColValues: function(colindex, num, exclude){
|
|
|
|
if(!this.fltGrid){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
var row = this.tbl.rows,
|
|
|
|
colValues = [];
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-10-04 16:38:42 +02:00
|
|
|
for(var i=this.refRow; i<this.nbRows; i++){
|
2014-09-20 15:56:35 +02:00
|
|
|
var isExludedRow = false;
|
2014-10-04 16:38:42 +02:00
|
|
|
// checks if current row index appears in exclude array
|
2014-10-18 14:00:34 +02:00
|
|
|
if(exclude && types.isObj(exclude)){
|
|
|
|
isExludedRow = array.has(exclude, i); //boolean
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
2014-10-04 16:38:42 +02:00
|
|
|
var cell = row[i].cells,
|
|
|
|
nchilds = cell.length;
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-10-04 16:38:42 +02:00
|
|
|
// checks if row has exact cell # and is not excluded
|
|
|
|
if(nchilds == this.nbCells && !isExludedRow){
|
|
|
|
// this loop retrieves cell data
|
|
|
|
for(var j=0; j<nchilds; j++){
|
|
|
|
if(j===colindex && row[i].style.display===''){
|
2014-10-18 14:00:34 +02:00
|
|
|
var cell_data = str.lower(
|
2014-10-10 15:34:45 +02:00
|
|
|
this.GetCellData(j, cell[j])),
|
2014-10-04 16:38:42 +02:00
|
|
|
nbFormat = this.colNbFormat ?
|
|
|
|
this.colNbFormat[colindex] : null,
|
|
|
|
data = num ?
|
2014-10-18 14:00:34 +02:00
|
|
|
removeNbFormat(cell_data,nbFormat) :
|
2014-10-04 16:38:42 +02:00
|
|
|
cell_data;
|
|
|
|
colValues.push(data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}//for i
|
|
|
|
return colValues;
|
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- Returns value of a specified filter
|
|
|
|
- Params:
|
|
|
|
- index: filter column index (numeric value)
|
|
|
|
=====================================================*/
|
2014-10-04 16:38:42 +02:00
|
|
|
GetFilterValue: function(index){
|
|
|
|
if(!this.fltGrid){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
var fltValue,
|
|
|
|
flt = this.GetFilterElement(index);
|
|
|
|
if(!flt){
|
|
|
|
return '';
|
|
|
|
}
|
2014-10-18 14:00:34 +02:00
|
|
|
var fltColType = this.fltCol[index];
|
2014-10-04 16:38:42 +02:00
|
|
|
if(fltColType !== this.fltTypeMulti &&
|
|
|
|
fltColType !== this.fltTypeCheckList){
|
2014-09-20 15:56:35 +02:00
|
|
|
fltValue = flt.value;
|
2014-10-04 16:38:42 +02:00
|
|
|
}
|
|
|
|
//mutiple select
|
|
|
|
else if(fltColType === this.fltTypeMulti){
|
2014-09-20 15:56:35 +02:00
|
|
|
fltValue = '';
|
2014-10-04 16:38:42 +02:00
|
|
|
for(var j=0; j<flt.options.length; j++){
|
|
|
|
if(flt.options[j].selected){
|
2014-09-20 15:56:35 +02:00
|
|
|
fltValue = fltValue.concat(
|
2014-10-04 16:38:42 +02:00
|
|
|
flt.options[j].value+' ' +
|
|
|
|
this.orOperator + ' '
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
//removes last operator ||
|
|
|
|
fltValue = fltValue.substr(0,fltValue.length-4);
|
|
|
|
}
|
2014-10-04 16:38:42 +02:00
|
|
|
//checklist
|
|
|
|
else if(fltColType === this.fltTypeCheckList){
|
|
|
|
if(flt.getAttribute('value') !== null){
|
2014-09-20 15:56:35 +02:00
|
|
|
fltValue = flt.getAttribute('value');
|
|
|
|
//removes last operator ||
|
|
|
|
fltValue = fltValue.substr(0,fltValue.length-3);
|
2014-10-04 16:38:42 +02:00
|
|
|
} else{
|
|
|
|
fltValue = '';
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
|
|
|
return fltValue;
|
|
|
|
},
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
/*====================================================
|
|
|
|
- Returns the value of every single filter
|
|
|
|
=====================================================*/
|
2014-10-04 16:38:42 +02:00
|
|
|
GetFiltersValue: function(){
|
|
|
|
if(!this.fltGrid){
|
|
|
|
return;
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
var searchArgs = [];
|
2014-10-04 16:38:42 +02:00
|
|
|
for(var i=0; i<this.fltIds.length; i++){
|
2014-09-20 15:56:35 +02:00
|
|
|
searchArgs.push(
|
2014-10-18 14:00:34 +02:00
|
|
|
str.trim(
|
|
|
|
str.matchCase(this.GetFilterValue(i), this.matchCase))
|
2014-09-20 15:56:35 +02:00
|
|
|
);
|
2014-10-04 16:38:42 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
return searchArgs;
|
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- Returns filter id of a specified column
|
|
|
|
- Params:
|
|
|
|
- index: column index (numeric value)
|
|
|
|
=====================================================*/
|
2014-10-04 16:38:42 +02:00
|
|
|
GetFilterId: function(index){
|
|
|
|
if(!this.fltGrid){
|
|
|
|
return;
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
return this.fltIds[i];
|
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- returns an array containing ids of filters of a
|
|
|
|
specified type (inputs or selects)
|
|
|
|
- Note that hidden filters are also returned
|
|
|
|
- Needs folllowing args:
|
|
|
|
- filter type string ('input','select',
|
|
|
|
'multiple')
|
|
|
|
- optional boolean: if set true method
|
|
|
|
returns column indexes otherwise filters ids
|
|
|
|
=====================================================*/
|
2014-10-04 16:38:42 +02:00
|
|
|
GetFiltersByType: function(type, bool){
|
|
|
|
if(!this.fltGrid){
|
|
|
|
return;
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
var arr = [];
|
2014-10-04 16:38:42 +02:00
|
|
|
for(var i=0; i<this.fltIds.length; i++){
|
2014-09-20 15:56:35 +02:00
|
|
|
var fltType = this['col'+i];
|
2014-10-18 14:00:34 +02:00
|
|
|
if(fltType === str.lower(type)){
|
2014-09-20 15:56:35 +02:00
|
|
|
var a = (bool) ? i : this.fltIds[i];
|
|
|
|
arr.push(a);
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
|
|
|
return arr;
|
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- returns filter DOM element for a given column
|
|
|
|
index
|
|
|
|
=====================================================*/
|
2014-10-04 16:38:42 +02:00
|
|
|
GetFilterElement: function(index){
|
|
|
|
if(!this.fltGrid){
|
|
|
|
return null;
|
|
|
|
}
|
2014-11-01 15:34:37 +01:00
|
|
|
return dom.id(this.fltIds[index]);
|
2014-09-20 15:56:35 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- returns number of cells in a row
|
|
|
|
- if rowIndex param is passed returns number of
|
|
|
|
cells of specified row (number)
|
|
|
|
=====================================================*/
|
2014-10-04 16:38:42 +02:00
|
|
|
GetCellsNb: function(rowIndex){
|
|
|
|
var tr = !rowIndex ? this.tbl.rows[0] : this.tbl.rows[rowIndex];
|
2014-09-20 15:56:35 +02:00
|
|
|
return tr.cells.length;
|
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- returns total nb of filterable rows starting
|
|
|
|
from reference row if defined
|
|
|
|
- Param:
|
|
|
|
- includeHeaders: if true header rows are
|
|
|
|
included in calculation(= table rows number)
|
|
|
|
=====================================================*/
|
2014-10-04 16:38:42 +02:00
|
|
|
GetRowsNb: function(includeHeaders){
|
|
|
|
var s = !this.refRow ? 0 : this.refRow,
|
|
|
|
ntrs = this.tbl.rows.length;
|
2014-09-20 15:56:35 +02:00
|
|
|
if(includeHeaders){ s = 0; }
|
2014-10-04 16:38:42 +02:00
|
|
|
return parseInt(ntrs-s, 10);
|
2014-09-20 15:56:35 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- returns text content of a given cell
|
|
|
|
- Params:
|
|
|
|
- i: index of the column (number)
|
|
|
|
- cell: td DOM object
|
|
|
|
=====================================================*/
|
2014-10-04 16:38:42 +02:00
|
|
|
GetCellData: function(i, cell){
|
|
|
|
if(i===undefined || !cell){
|
|
|
|
return '';
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
//First checks for customCellData event
|
2014-10-18 14:00:34 +02:00
|
|
|
if(this.customCellData && array.has(this.customCellDataCols, i)){
|
2014-09-20 15:56:35 +02:00
|
|
|
return this.customCellData.call(null,this,cell,i);
|
2014-10-04 16:38:42 +02:00
|
|
|
} else {
|
2014-10-18 14:00:34 +02:00
|
|
|
return dom.getText(cell);
|
2014-10-04 16:38:42 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- returns an array containing table data:
|
|
|
|
[rowindex,[value1,value2,value3...]]
|
|
|
|
=====================================================*/
|
2014-10-04 16:38:42 +02:00
|
|
|
GetTableData: function(){
|
2014-09-20 15:56:35 +02:00
|
|
|
var row = this.tbl.rows;
|
2014-10-04 16:38:42 +02:00
|
|
|
for(var k=this.refRow; k<this.nbRows; k++){
|
|
|
|
var rowData = [k,[]];
|
2014-09-20 15:56:35 +02:00
|
|
|
var cells = row[k].cells;
|
2014-10-04 16:38:42 +02:00
|
|
|
// this loop retrieves cell data
|
|
|
|
for(var j=0; j<cells.length; j++){
|
2014-09-20 15:56:35 +02:00
|
|
|
var cell_data = this.GetCellData(j, cells[j]);
|
|
|
|
rowData[1].push(cell_data);
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
2014-10-04 16:38:42 +02:00
|
|
|
this.tblData.push(rowData);
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
|
|
|
return this.tblData;
|
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- returns an array containing filtered data:
|
|
|
|
[rowindex,[value1,value2,value3...]]
|
|
|
|
=====================================================*/
|
2014-10-04 16:38:42 +02:00
|
|
|
GetFilteredData: function(includeHeaders){
|
|
|
|
if(!this.validRowsIndex){
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
var row = this.tbl.rows,
|
|
|
|
filteredData = [];
|
2014-09-20 15:56:35 +02:00
|
|
|
if(includeHeaders){
|
2014-10-04 16:38:42 +02:00
|
|
|
var table = this.gridLayout ? this.headTbl : this.tbl,
|
|
|
|
r = table.rows[this.headersRow],
|
|
|
|
rowData = [r.rowIndex,[]];
|
|
|
|
for(var j=0; j<this.nbCells; j++){
|
2014-09-20 15:56:35 +02:00
|
|
|
var headerText = this.GetCellData(j, r.cells[j]);
|
|
|
|
rowData[1].push(headerText);
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
filteredData.push(rowData);
|
|
|
|
}
|
2014-10-04 16:38:42 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
var validRows = this.GetValidRowsIndex(true);
|
2014-10-04 16:38:42 +02:00
|
|
|
for(var i=0; i<validRows.length; i++){
|
|
|
|
var rData = [this.validRowsIndex[i],[]],
|
|
|
|
cells = row[this.validRowsIndex[i]].cells;
|
|
|
|
for(var k=0; k<cells.length; k++){
|
|
|
|
var cell_data = this.GetCellData(k, cells[k]);
|
|
|
|
rData[1].push(cell_data);
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
2014-10-04 16:38:42 +02:00
|
|
|
filteredData.push(rData);
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
|
|
|
return filteredData;
|
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- returns an array containing filtered data of a
|
|
|
|
specified column.
|
|
|
|
- Params:
|
|
|
|
- colIndex: index of the column (number)
|
|
|
|
- returned array:
|
|
|
|
[value1,value2,value3...]
|
|
|
|
=====================================================*/
|
2014-10-04 16:38:42 +02:00
|
|
|
GetFilteredDataCol: function(colIndex){
|
|
|
|
if(colIndex===undefined){
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
var data = this.GetFilteredData(),
|
|
|
|
colData = [];
|
|
|
|
for(var i=0; i<data.length; i++){
|
|
|
|
var r = data[i],
|
|
|
|
//cols values of current row
|
|
|
|
d = r[1],
|
|
|
|
//data of searched column
|
|
|
|
c = d[colIndex];
|
2014-09-20 15:56:35 +02:00
|
|
|
colData.push(c);
|
|
|
|
}
|
|
|
|
return colData;
|
|
|
|
},
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-10-04 16:38:42 +02:00
|
|
|
GetRowDisplay: function(row){
|
2014-10-18 14:00:34 +02:00
|
|
|
if(!this.fltGrid && !types.isObj(row)){
|
2014-10-04 16:38:42 +02:00
|
|
|
return;
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
return row.style.display;
|
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- Validates/unvalidates row by setting 'validRow'
|
|
|
|
attribute and shows/hides row
|
|
|
|
- Params:
|
|
|
|
- rowIndex: index of the row (number)
|
|
|
|
- isValid: boolean
|
|
|
|
=====================================================*/
|
2014-10-04 16:38:42 +02:00
|
|
|
SetRowValidation: function(rowIndex, isValid){
|
2014-09-20 15:56:35 +02:00
|
|
|
var row = this.tbl.rows[rowIndex];
|
2014-10-18 14:00:34 +02:00
|
|
|
if(!row || str.lower(typeof isValid)!=='boolean'){
|
2014-10-04 16:38:42 +02:00
|
|
|
return;
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
// always visible rows are valid
|
2014-10-18 14:00:34 +02:00
|
|
|
if(this.hasVisibleRows && array.has(this.visibleRows, rowIndex) &&
|
2014-10-04 16:38:42 +02:00
|
|
|
!this.paging){
|
2014-09-20 15:56:35 +02:00
|
|
|
isValid = true;
|
2014-10-04 16:38:42 +02:00
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-10-04 16:38:42 +02:00
|
|
|
var displayFlag = isValid ? '' : 'none',
|
|
|
|
validFlag = isValid ? 'true' : 'false';
|
2014-09-20 15:56:35 +02:00
|
|
|
row.style.display = displayFlag;
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-10-04 16:38:42 +02:00
|
|
|
if(this.paging){
|
2014-09-20 15:56:35 +02:00
|
|
|
row.setAttribute('validRow',validFlag);
|
2014-10-04 16:38:42 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
},
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
/*====================================================
|
|
|
|
- Validates all filterable rows
|
|
|
|
=====================================================*/
|
2014-10-04 16:38:42 +02:00
|
|
|
ValidateAllRows: function(){
|
|
|
|
if(!this.hasGrid){
|
|
|
|
return;
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
this.validRowsIndex = [];
|
2014-10-04 16:38:42 +02:00
|
|
|
for(var k=this.refRow; k<this.nbFilterableRows; k++){
|
|
|
|
this.SetRowValidation(k, true);
|
2014-09-20 15:56:35 +02:00
|
|
|
this.validRowsIndex.push(k);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- Inserts value in a specified filter
|
|
|
|
- Params:
|
|
|
|
- index: filter column index (numeric value)
|
|
|
|
- searcharg: search string
|
|
|
|
- doFilter: optional boolean for multiple
|
|
|
|
selects: executes filtering when multiple
|
|
|
|
select populated... IE only!
|
|
|
|
=====================================================*/
|
2014-10-04 16:38:42 +02:00
|
|
|
SetFilterValue: function(index, searcharg, doFilter){
|
|
|
|
if((!this.fltGrid && !this.isFirstLoad) ||
|
|
|
|
!this.GetFilterElement(index)){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
var slc = this.GetFilterElement(index),
|
|
|
|
execFilter = doFilter===undefined ? true : doFilter,
|
|
|
|
fltColType = this['col'+index];
|
|
|
|
searcharg = searcharg===undefined ? '' : searcharg;
|
|
|
|
|
|
|
|
if(fltColType !== this.fltTypeMulti &&
|
|
|
|
fltColType != this.fltTypeCheckList){
|
2014-09-20 15:56:35 +02:00
|
|
|
slc.value = searcharg;
|
2014-10-04 16:38:42 +02:00
|
|
|
if(fltColType===this.fltTypeInp && this.inpWatermark!==''){
|
2014-10-18 14:00:34 +02:00
|
|
|
dom.removeClass(slc, this.inpWatermarkCssClass);
|
2014-10-04 16:38:42 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
2014-10-04 16:38:42 +02:00
|
|
|
//multiple selects
|
|
|
|
else if(fltColType === this.fltTypeMulti){
|
|
|
|
var s = searcharg.split(' '+this.orOperator+' '),
|
|
|
|
ct = 0; //keywords counter
|
|
|
|
for(var j=0; j<slc.options.length; j++){
|
|
|
|
if(s===''){
|
|
|
|
slc.options[j].selected = false;
|
|
|
|
}
|
|
|
|
if(slc.options[j].value===''){
|
|
|
|
slc.options[j].selected = false;
|
|
|
|
}
|
|
|
|
if(slc.options[j].value!=='' &&
|
2014-10-18 14:00:34 +02:00
|
|
|
array.has(s, slc.options[j].value, true)){
|
2014-10-04 16:38:42 +02:00
|
|
|
// IE multiple selection work-around
|
2014-11-01 15:34:37 +01:00
|
|
|
if(hlp.isIE()){
|
2014-09-20 15:56:35 +02:00
|
|
|
//when last value reached filtering can be executed
|
2014-10-04 16:38:42 +02:00
|
|
|
var filter = ct==(s.length-1) && execFilter ?
|
|
|
|
true : false;
|
2014-09-20 15:56:35 +02:00
|
|
|
this.__deferMultipleSelection(slc,j,filter);
|
|
|
|
ct++;
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
2014-10-04 16:38:42 +02:00
|
|
|
else{
|
2014-09-20 15:56:35 +02:00
|
|
|
slc.options[j].selected = true;
|
2014-10-04 16:38:42 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}//if
|
|
|
|
}//for j
|
|
|
|
}
|
2014-10-04 16:38:42 +02:00
|
|
|
//checklist
|
|
|
|
else if(fltColType === this.fltTypeCheckList){
|
2014-10-18 14:00:34 +02:00
|
|
|
searcharg = str.matchCase(searcharg, this.matchCase);
|
2014-10-04 16:38:42 +02:00
|
|
|
var sarg = searcharg.split(' '+this.orOperator+' '),
|
|
|
|
fltValue = slc.setAttribute('value',''),
|
|
|
|
fltIndex = slc.setAttribute('indexes','');
|
2014-11-01 15:34:37 +01:00
|
|
|
for(var k=0; k<dom.tag(slc,'li').length; k++){
|
|
|
|
var li = dom.tag(slc,'li')[k],
|
|
|
|
lbl = dom.tag(li,'label')[0],
|
|
|
|
chk = dom.tag(li,'input')[0],
|
2014-10-18 14:00:34 +02:00
|
|
|
lblTxt = str.matchCase(
|
|
|
|
dom.getText(lbl), this.matchCase);
|
|
|
|
if(lblTxt!=='' && array.has(sarg, lblTxt, true)){
|
2014-09-20 15:56:35 +02:00
|
|
|
chk.checked = true;
|
|
|
|
this.__setCheckListValues(chk);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
chk.checked = false;
|
|
|
|
this.__setCheckListValues(chk);
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
|
|
|
},
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
/*====================================================
|
|
|
|
- sets coluun widths in pixels
|
|
|
|
=====================================================*/
|
2014-10-04 16:38:42 +02:00
|
|
|
SetColWidths: function(rowIndex){
|
|
|
|
if(!this.fltGrid || !this.hasColWidth){
|
|
|
|
return;
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
var o = this, rIndex;
|
2014-10-04 16:38:42 +02:00
|
|
|
if(rowIndex===undefined){
|
|
|
|
rIndex = this.tbl.rows[0].style.display!='none' ? 0 : 1;
|
|
|
|
} else{
|
|
|
|
rIndex = rowIndex;
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
setWidths(this.tbl.rows[rIndex]);
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-10-04 16:38:42 +02:00
|
|
|
function setWidths(row){
|
|
|
|
if(!o && (o.nbCells!=o.colWidth.length)){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(o.nbCells==row.cells.length){
|
|
|
|
for(var k=0; k<o.nbCells; k++){
|
2014-09-20 15:56:35 +02:00
|
|
|
row.cells[k].style.width = o.colWidth[k];
|
2014-10-04 16:38:42 +02:00
|
|
|
}
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
|
|
|
},
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
/*====================================================
|
|
|
|
- makes a row always visible
|
|
|
|
- Note this works only if paging is false
|
|
|
|
=====================================================*/
|
2014-10-04 16:38:42 +02:00
|
|
|
SetVisibleRows: function(){
|
|
|
|
if(this.hasGrid && this.hasVisibleRows && !this.paging){
|
|
|
|
for(var i=0; i<this.visibleRows.length; i++){
|
|
|
|
//row index cannot be > nrows
|
|
|
|
if(this.visibleRows[i] <= this.nbRows){
|
2014-09-20 15:56:35 +02:00
|
|
|
this.SetRowValidation(this.visibleRows[i],true);
|
2014-10-04 16:38:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
},
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-10-04 16:38:42 +02:00
|
|
|
ClearFilters: function(){
|
2014-09-20 15:56:35 +02:00
|
|
|
this.EvtManager(this.Evt.name.clear);
|
|
|
|
},
|
|
|
|
/*====================================================
|
|
|
|
- clears grid filters
|
|
|
|
=====================================================*/
|
2014-10-04 16:38:42 +02:00
|
|
|
_ClearFilters: function(){
|
|
|
|
if(!this.fltGrid){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(this.onBeforeReset){
|
|
|
|
this.onBeforeReset.call(null, this, this.GetFiltersValue());
|
|
|
|
}
|
|
|
|
for(var i=0; i<this.fltIds.length; i++){
|
2014-09-20 15:56:35 +02:00
|
|
|
this.SetFilterValue(i,'');
|
2014-10-04 16:38:42 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
if(this.refreshFilters){
|
|
|
|
this.activeFilterId = '';
|
|
|
|
this.RefreshFiltersGrid();
|
|
|
|
}
|
2014-10-18 14:00:34 +02:00
|
|
|
if(this.rememberPageLen){ cookie.remove(this.pgLenCookie); }
|
|
|
|
if(this.rememberPageNb){ cookie.remove(this.pgNbCookie); }
|
2014-09-20 15:56:35 +02:00
|
|
|
if(this.onAfterReset){ this.onAfterReset.call(null, this); }
|
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- clears active columns header class name
|
|
|
|
=====================================================*/
|
2014-10-04 16:38:42 +02:00
|
|
|
ClearActiveColumns: function(){
|
|
|
|
for(var i=0; i<this.fltIds.length; i++){
|
2014-10-18 14:00:34 +02:00
|
|
|
dom.removeClass(
|
2014-10-04 16:38:42 +02:00
|
|
|
this.GetHeaderElement(i), this.activeColumnsCssClass);
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- Re-generates filters grid
|
|
|
|
=====================================================*/
|
2014-10-04 16:38:42 +02:00
|
|
|
RefreshGrid: function(config){
|
2014-09-20 15:56:35 +02:00
|
|
|
var configObj = !config ? this.fObj : config;
|
|
|
|
var hasSort = this.sort;
|
2014-10-04 16:38:42 +02:00
|
|
|
//sort property is set to false in order to avoid sort object
|
|
|
|
//re-instanciation
|
|
|
|
if(hasSort){
|
|
|
|
this.sort = false;
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
this.nbRows = this.GetRowsNb(); //in case table is refreshed
|
|
|
|
this.RemoveGrid();
|
|
|
|
window['tf_'+this.id] = new TF(this.id, this.startRow, configObj);
|
|
|
|
this.isFirstLoad = true;
|
|
|
|
this.fltIds = [];
|
|
|
|
this._AddGrid();
|
2014-10-04 16:38:42 +02:00
|
|
|
//New tbody content needs to be referenced in sortabletable script with
|
|
|
|
//setTBody() method
|
2014-09-20 15:56:35 +02:00
|
|
|
if(hasSort){
|
|
|
|
//this.st = SortableTable object
|
2014-10-04 16:38:42 +02:00
|
|
|
//Note this is a method of the Sortable Table 1.12 script
|
|
|
|
//(Erik Arvidsson)
|
|
|
|
this.st.setTBody(this.tbl.tBodies[0]);
|
|
|
|
//finally sort property is enabled again
|
|
|
|
this.sort = true;
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
|
|
|
},
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
/*====================================================
|
|
|
|
- retrieves select, multiple and checklist filters
|
|
|
|
- calls method repopulating filters
|
|
|
|
=====================================================*/
|
2014-10-04 16:38:42 +02:00
|
|
|
RefreshFiltersGrid: function(){
|
|
|
|
var slcA1 = this.GetFiltersByType(this.fltTypeSlc, true),
|
|
|
|
slcA2 = this.GetFiltersByType(this.fltTypeMulti, true),
|
|
|
|
slcA3 = this.GetFiltersByType(this.fltTypeCheckList, true),
|
|
|
|
slcIndex = slcA1.concat(slcA2);
|
2014-09-20 15:56:35 +02:00
|
|
|
slcIndex = slcIndex.concat(slcA3);
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-10-04 16:38:42 +02:00
|
|
|
if(this.activeFilterId){
|
2014-09-20 15:56:35 +02:00
|
|
|
var activeFlt = this.activeFilterId.split('_')[0];
|
|
|
|
activeFlt = activeFlt.split(this.prfxFlt)[1];
|
|
|
|
var slcSelectedValue;
|
2014-10-04 16:38:42 +02:00
|
|
|
for(var i=0; i<slcIndex.length; i++){
|
2014-11-01 15:34:37 +01:00
|
|
|
var curSlc = dom.id(this.fltIds[slcIndex[i]]);
|
2014-10-04 16:38:42 +02:00
|
|
|
slcSelectedValue = this.GetFilterValue(slcIndex[i]);
|
|
|
|
if(activeFlt!==slcIndex[i] ||
|
2014-10-18 14:00:34 +02:00
|
|
|
(this.paging && array.has(slcA1, slcIndex[i]) &&
|
2014-10-04 16:38:42 +02:00
|
|
|
activeFlt === slcIndex[i] ) ||
|
2014-10-18 14:00:34 +02:00
|
|
|
(!this.paging && (array.has(slcA3, slcIndex[i]) ||
|
|
|
|
array.has(slcA2, slcIndex[i]))) ||
|
2014-10-04 16:38:42 +02:00
|
|
|
slcSelectedValue === this.displayAllText ){
|
|
|
|
|
2014-10-18 14:00:34 +02:00
|
|
|
if(array.has(slcA3, slcIndex[i])){
|
2014-09-20 15:56:35 +02:00
|
|
|
this.checkListDiv[slcIndex[i]].innerHTML = '';
|
2014-10-04 16:38:42 +02:00
|
|
|
} else {
|
|
|
|
curSlc.innerHTML = '';
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
|
2014-10-04 16:38:42 +02:00
|
|
|
//1st option needs to be inserted
|
|
|
|
if(this.fillSlcOnDemand) {
|
2014-10-18 14:00:34 +02:00
|
|
|
var opt0 = dom.createOpt(this.displayAllText,'');
|
2014-10-04 16:38:42 +02:00
|
|
|
if(curSlc){
|
|
|
|
curSlc.appendChild(opt0);
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
|
|
|
|
2014-10-18 14:00:34 +02:00
|
|
|
if(array.has(slcA3, slcIndex[i])){
|
2014-09-20 15:56:35 +02:00
|
|
|
this._PopulateCheckList(slcIndex[i]);
|
2014-10-04 16:38:42 +02:00
|
|
|
} else {
|
2014-09-20 15:56:35 +02:00
|
|
|
this._PopulateSelect(slcIndex[i],true);
|
2014-10-04 16:38:42 +02:00
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
this.SetFilterValue(slcIndex[i],slcSelectedValue);
|
|
|
|
}
|
|
|
|
}// for i
|
|
|
|
}
|
|
|
|
},
|
|
|
|
/*====================================================
|
|
|
|
- Calculates values of a column
|
|
|
|
- params are stored in 'colOperation' table's
|
|
|
|
attribute
|
|
|
|
- colOperation['id'] contains ids of elements
|
|
|
|
showing result (array)
|
|
|
|
- colOperation['col'] contains index of
|
|
|
|
columns (array)
|
|
|
|
- colOperation['operation'] contains operation
|
|
|
|
type (array, values: sum, mean)
|
|
|
|
- colOperation['write_method'] array defines
|
|
|
|
which method to use for displaying the
|
|
|
|
result (innerHTML, setValue, createTextNode).
|
|
|
|
Note that innerHTML is the default value.
|
|
|
|
- colOperation['tot_row_index'] defines in
|
|
|
|
which row results are displayed (integers array)
|
|
|
|
|
2014-10-04 16:38:42 +02:00
|
|
|
- changes made by Nuovella:
|
2014-09-20 15:56:35 +02:00
|
|
|
(1) optimized the routine (now it will only
|
|
|
|
process each column once),
|
|
|
|
(2) added calculations for the median, lower and
|
|
|
|
upper quartile.
|
|
|
|
=====================================================*/
|
2014-10-04 16:38:42 +02:00
|
|
|
SetColOperation: function(){
|
|
|
|
if(!this.isFirstLoad && !this.hasGrid){
|
|
|
|
return;
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-10-04 16:38:42 +02:00
|
|
|
if(this.onBeforeOperation){
|
|
|
|
this.onBeforeOperation.call(null,this);
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-10-04 16:38:42 +02:00
|
|
|
var colOperation = this.colOperation,
|
|
|
|
labelId = colOperation.id,
|
|
|
|
colIndex = colOperation.col,
|
|
|
|
operation = colOperation.operation,
|
|
|
|
outputType = colOperation.write_method,
|
|
|
|
totRowIndex = colOperation.tot_row_index,
|
|
|
|
excludeRow = colOperation.exclude_row,
|
|
|
|
decimalPrecision = colOperation.decimal_precision !== undefined ?
|
|
|
|
colOperation.decimal_precision : 2;
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
//nuovella: determine unique list of columns to operate on
|
2014-10-04 16:38:42 +02:00
|
|
|
var ucolIndex = [],
|
|
|
|
ucolMax = 0;
|
|
|
|
ucolIndex[ucolMax] = colIndex[0];
|
|
|
|
|
|
|
|
for(var ii=1; ii<colIndex.length; ii++){
|
|
|
|
var saved = 0;
|
|
|
|
//see if colIndex[ii] is already in the list of unique indexes
|
|
|
|
for(var jj=0; jj<=ucolMax; jj++){
|
|
|
|
if(ucolIndex[jj] === colIndex[ii]){
|
|
|
|
saved = 1;
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
2014-10-04 16:38:42 +02:00
|
|
|
//if not saved then, save the index;
|
|
|
|
if (saved === 0){
|
2014-09-20 15:56:35 +02:00
|
|
|
ucolMax++;
|
2014-10-04 16:38:42 +02:00
|
|
|
ucolIndex[ucolMax] = colIndex[ii];
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
2014-10-04 16:38:42 +02:00
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-10-18 14:00:34 +02:00
|
|
|
if(str.lower(typeof labelId)=='object' &&
|
|
|
|
str.lower(typeof colIndex)=='object' &&
|
|
|
|
str.lower(typeof operation)=='object'){
|
2014-10-04 16:38:42 +02:00
|
|
|
var row = this.tbl.rows,
|
|
|
|
colvalues = [];
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-10-04 16:38:42 +02:00
|
|
|
for(var ucol=0; ucol<=ucolMax; ucol++){
|
2014-09-20 15:56:35 +02:00
|
|
|
//this retrieves col values
|
2014-10-04 16:38:42 +02:00
|
|
|
//use ucolIndex because we only want to pass through this loop
|
|
|
|
//once for each column get the values in this unique column
|
|
|
|
colvalues.push(
|
|
|
|
this.GetColValues(ucolIndex[ucol],true,excludeRow));
|
|
|
|
|
|
|
|
//next: calculate all operations for this column
|
|
|
|
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;
|
|
|
|
|
2014-10-06 13:08:29 +02:00
|
|
|
for(var k=0; k<colIndex.length; k++){
|
|
|
|
if(colIndex[k] === ucolIndex[ucol]){
|
2014-09-20 15:56:35 +02:00
|
|
|
mThisCol++;
|
2014-10-18 14:00:34 +02:00
|
|
|
opsThisCol[mThisCol]=str.lower(operation[k]);
|
2014-10-06 13:08:29 +02:00
|
|
|
decThisCol[mThisCol]=decimalPrecision[k];
|
|
|
|
labThisCol[mThisCol]=labelId[k];
|
2014-10-04 16:38:42 +02:00
|
|
|
oTypeThisCol = outputType !== undefined &&
|
2014-10-18 14:00:34 +02:00
|
|
|
str.lower(typeof outputType)==='object' ?
|
2014-10-06 13:08:29 +02:00
|
|
|
outputType[k] : null;
|
2014-09-20 15:56:35 +02:00
|
|
|
|
2014-10-04 16:38:42 +02:00
|
|
|
switch(opsThisCol[mThisCol]){
|
2014-09-07 12:07:28 +02:00
|
|
|
case 'mean':
|
2014-09-20 15:56:35 +02:00
|
|
|
meanFlag=1;
|
2014-09-07 12:07:28 +02:00
|
|
|
break;
|
|
|
|
case 'sum':
|
2014-09-20 15:56:35 +02:00
|
|
|
sumFlag=1;
|
2014-09-07 12:07:28 +02:00
|
|
|
break;
|
|
|
|
case 'min':
|
2014-09-20 15:56:35 +02:00
|
|
|
minFlag=1;
|
2014-09-07 12:07:28 +02:00
|
|
|
break;
|
|
|
|
case 'max':
|
2014-09-20 15:56:35 +02:00
|
|
|
maxFlag=1;
|
2014-09-07 12:07:28 +02:00
|
|
|
break;
|
|
|
|
case 'median':
|
2014-09-20 15:56:35 +02:00
|
|
|
medFlag=1;
|
2014-09-07 12:07:28 +02:00
|
|
|
break;
|
|
|
|
case 'q1':
|
2014-09-20 15:56:35 +02:00
|
|
|
q1Flag=1;
|
2014-09-07 12:07:28 +02:00
|
|
|
break;
|
|
|
|
case 'q3':
|
2014-09-20 15:56:35 +02:00
|
|
|
q3Flag=1;
|
2014-09-07 12:07:28 +02:00
|
|
|
break;
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-04 16:38:42 +02:00
|
|
|
for(var j=0; j<colvalues[ucol].length; j++){
|
|
|
|
//sort the list for calculation of median and quartiles
|
|
|
|
if((q1Flag==1)||(q3Flag==1) || (medFlag==1)){
|
|
|
|
if (j<colvalues[ucol].length -1){
|
2014-09-20 15:56:35 +02:00
|
|
|
for(k=j+1;k<colvalues[ucol].length; k++) {
|
2014-10-04 16:38:42 +02:00
|
|
|
if(eval(colvalues[ucol][k]) <
|
|
|
|
eval(colvalues[ucol][j])){
|
2014-09-20 15:56:35 +02:00
|
|
|
temp = colvalues[ucol][j];
|
|
|
|
colvalues[ucol][j] = colvalues[ucol][k];
|
|
|
|
colvalues[ucol][k] = temp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var cvalue = parseFloat(colvalues[ucol][j]);
|
2014-10-04 16:38:42 +02:00
|
|
|
theList[j] = parseFloat(cvalue);
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-10-04 16:38:42 +02:00
|
|
|
if(!isNaN(cvalue)){
|
2014-09-20 15:56:35 +02:00
|
|
|
nbvalues++;
|
2014-10-04 16:38:42 +02:00
|
|
|
if(sumFlag===1 || meanFlag===1){
|
|
|
|
sumValue += parseFloat( cvalue );
|
|
|
|
}
|
|
|
|
if(minFlag===1){
|
|
|
|
if(minValue===null){
|
2014-09-20 15:56:35 +02:00
|
|
|
minValue = parseFloat( cvalue );
|
2014-10-04 16:38:42 +02:00
|
|
|
} else{
|
|
|
|
minValue = parseFloat( cvalue ) < minValue ?
|
|
|
|
parseFloat( cvalue ): minValue;
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
2014-10-04 16:38:42 +02:00
|
|
|
if(maxFlag===1){
|
|
|
|
if (maxValue===null){
|
|
|
|
maxValue = parseFloat( cvalue );
|
|
|
|
} else {
|
|
|
|
maxValue = parseFloat( cvalue ) > maxValue ?
|
|
|
|
parseFloat( cvalue ): maxValue;
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}//for j
|
2014-10-04 16:38:42 +02:00
|
|
|
if(meanFlag===1){
|
|
|
|
meanValue = sumValue/nbvalues;
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
2014-10-04 16:38:42 +02:00
|
|
|
if(medFlag===1){
|
|
|
|
var aux = 0;
|
|
|
|
if(nbvalues%2 === 1){
|
|
|
|
aux = Math.floor(nbvalues/2);
|
|
|
|
medValue = theList[aux];
|
|
|
|
} else{
|
|
|
|
medValue =
|
|
|
|
(theList[nbvalues/2] + theList[((nbvalues/2)-1)])/2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var posa;
|
|
|
|
if(q1Flag===1){
|
|
|
|
posa=0.0;
|
2014-09-20 15:56:35 +02:00
|
|
|
posa = Math.floor(nbvalues/4);
|
2014-10-04 16:38:42 +02:00
|
|
|
if(4*posa == nbvalues){
|
|
|
|
q1Value = (theList[posa-1] + theList[posa])/2;
|
|
|
|
} else {
|
|
|
|
q1Value = theList[posa];
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
2014-10-04 16:38:42 +02:00
|
|
|
if (q3Flag===1){
|
|
|
|
posa=0.0;
|
2014-09-20 15:56:35 +02:00
|
|
|
var posb=0.0;
|
|
|
|
posa = Math.floor(nbvalues/4);
|
2014-10-04 16:38:42 +02:00
|
|
|
if (4*posa === nbvalues){
|
2014-09-20 15:56:35 +02:00
|
|
|
posb = 3*posa;
|
|
|
|
q3Value = (theList[posb] + theList[posb-1])/2;
|
2014-10-04 16:38:42 +02:00
|
|
|
} else {
|
2014-09-20 15:56:35 +02:00
|
|
|
q3Value = theList[nbvalues-posa-1];
|
2014-10-04 16:38:42 +02:00
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
|
|
|
|
2014-10-04 16:38:42 +02:00
|
|
|
for(var i=0; i<=mThisCol; i++){
|
|
|
|
switch( opsThisCol[i] ){
|
2014-09-20 15:56:35 +02:00
|
|
|
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;
|
|
|
|
break;
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
2014-10-04 16:38:42 +02:00
|
|
|
|
|
|
|
var precision = decThisCol[i] && !isNaN( decThisCol[i] ) ?
|
|
|
|
decThisCol[i] : 2;
|
|
|
|
//if outputType is defined
|
|
|
|
if(oTypeThisCol && result){
|
|
|
|
result = result.toFixed( precision );
|
2014-11-01 15:34:37 +01:00
|
|
|
if(dom.id(labThisCol[i])){
|
2014-10-18 14:00:34 +02:00
|
|
|
switch( str.lower(oTypeThisCol) ){
|
2014-10-04 16:38:42 +02:00
|
|
|
case 'innerhtml':
|
|
|
|
if (isNaN(result) || !isFinite(result) ||
|
|
|
|
nbvalues===0){
|
2014-11-01 15:34:37 +01:00
|
|
|
dom.id(labThisCol[i]).innerHTML = '.';
|
2014-10-04 16:38:42 +02:00
|
|
|
} else{
|
2014-11-01 15:34:37 +01:00
|
|
|
dom.id(labThisCol[i]).innerHTML = result;
|
2014-10-04 16:38:42 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'setvalue':
|
2014-11-01 15:34:37 +01:00
|
|
|
dom.id( labThisCol[i] ).value = result;
|
2014-10-04 16:38:42 +02:00
|
|
|
break;
|
|
|
|
case 'createtextnode':
|
2014-11-01 15:34:37 +01:00
|
|
|
var oldnode = dom.id(labThisCol[i])
|
2014-10-04 16:38:42 +02:00
|
|
|
.firstChild;
|
2014-10-18 14:00:34 +02:00
|
|
|
var txtnode = dom.text(result);
|
2014-11-01 15:34:37 +01:00
|
|
|
dom.id(labThisCol[i])
|
2014-10-04 16:38:42 +02:00
|
|
|
.replaceChild(txtnode, oldnode);
|
|
|
|
break;
|
|
|
|
}//switch
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
try{
|
|
|
|
if(isNaN(result) || !isFinite(result) ||
|
|
|
|
nbvalues===0){
|
2014-11-01 15:34:37 +01:00
|
|
|
dom.id(labThisCol[i]).innerHTML = '.';
|
2014-10-04 16:38:42 +02:00
|
|
|
} else {
|
2014-11-01 15:34:37 +01:00
|
|
|
dom.id(labThisCol[i]).innerHTML = result.toFixed(
|
2014-10-04 16:38:42 +02:00
|
|
|
precision);
|
|
|
|
}
|
|
|
|
} catch(e) {}//catch
|
|
|
|
}//else
|
|
|
|
}//for i
|
|
|
|
//eventual row(s) with result are always visible
|
|
|
|
if(totRowIndex && row[totRowIndex[ucol]]){
|
|
|
|
row[totRowIndex[ucol]].style.display = '';
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}//for ucol
|
|
|
|
}//if typeof
|
|
|
|
|
2014-10-04 16:38:42 +02:00
|
|
|
if(this.onAfterOperation){
|
|
|
|
this.onAfterOperation.call(null,this);
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- removes keyword highlighting
|
|
|
|
=====================================================*/
|
2014-10-04 16:38:42 +02:00
|
|
|
UnhighlightAll: function(){
|
|
|
|
if( this.highlightKeywords && this.searchArgs){
|
2014-09-20 15:56:35 +02:00
|
|
|
for(var y=0; y<this.searchArgs.length; y++){
|
2014-10-12 13:40:08 +02:00
|
|
|
this.UnhighlightWord(
|
|
|
|
this.searchArgs[y], this.highlightCssClass);
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
this.highlightedNodes = [];
|
|
|
|
}
|
|
|
|
},
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-10-12 13:40:08 +02:00
|
|
|
/*====================================================
|
|
|
|
- highlights keyword found in passed node
|
|
|
|
- accepts the following params:
|
|
|
|
- node
|
|
|
|
- word to search
|
|
|
|
- css class name for highlighting
|
|
|
|
=====================================================*/
|
|
|
|
HighlightWord: function(node, word, cssClass){
|
|
|
|
// Iterate into this nodes childNodes
|
|
|
|
if(node.hasChildNodes){
|
|
|
|
for(var i=0; i<node.childNodes.length; i++){
|
|
|
|
this.HighlightWord(node.childNodes[i], word, cssClass);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// And do this node itself
|
|
|
|
// text node
|
|
|
|
if(node.nodeType === 3){
|
2014-10-18 14:00:34 +02:00
|
|
|
var tempNodeVal = str.lower(node.nodeValue);
|
|
|
|
var tempWordVal = str.lower(word);
|
2014-10-12 13:40:08 +02:00
|
|
|
if(tempNodeVal.indexOf(tempWordVal) != -1){
|
|
|
|
var pn = node.parentNode;
|
|
|
|
if(pn && pn.className != cssClass){
|
|
|
|
// word has not already been highlighted!
|
|
|
|
var nv = node.nodeValue,
|
|
|
|
ni = tempNodeVal.indexOf(tempWordVal),
|
|
|
|
// Create a load of replacement nodes
|
2014-10-18 14:00:34 +02:00
|
|
|
before = dom.text(nv.substr(0,ni)),
|
2014-10-12 13:40:08 +02:00
|
|
|
docWordVal = nv.substr(ni,word.length),
|
2014-10-18 14:00:34 +02:00
|
|
|
after = dom.text(nv.substr(ni+word.length)),
|
|
|
|
hiwordtext = dom.text(docWordVal),
|
|
|
|
hiword = dom.create('span');
|
2014-10-12 13:40:08 +02:00
|
|
|
hiword.className = cssClass;
|
|
|
|
hiword.appendChild(hiwordtext);
|
|
|
|
pn.insertBefore(before,node);
|
|
|
|
pn.insertBefore(hiword,node);
|
|
|
|
pn.insertBefore(after,node);
|
|
|
|
pn.removeChild(node);
|
|
|
|
this.highlightedNodes.push(hiword.firstChild);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- removes highlights found in passed node
|
|
|
|
- accepts the following params:
|
|
|
|
- node
|
|
|
|
- word to search
|
|
|
|
- css class name for highlighting
|
|
|
|
=====================================================*/
|
|
|
|
UnhighlightWord: function(word, cssClass){
|
|
|
|
var arrRemove = [];
|
|
|
|
for(var i=0; i<this.highlightedNodes.length; i++){
|
|
|
|
var n = this.highlightedNodes[i];
|
|
|
|
if(!n){
|
|
|
|
continue;
|
|
|
|
}
|
2014-10-18 14:00:34 +02:00
|
|
|
var tempNodeVal = str.lower(n.nodeValue),
|
|
|
|
tempWordVal = str.lower(word);
|
2014-10-12 13:40:08 +02:00
|
|
|
if(tempNodeVal.indexOf(tempWordVal) !== -1){
|
|
|
|
var pn = n.parentNode;
|
|
|
|
if(pn && pn.className === cssClass){
|
|
|
|
var prevSib = pn.previousSibling,
|
|
|
|
nextSib = pn.nextSibling;
|
|
|
|
if(!prevSib || !nextSib){ continue; }
|
|
|
|
nextSib.nodeValue = prevSib.nodeValue + n.nodeValue +
|
|
|
|
nextSib.nodeValue;
|
|
|
|
prevSib.nodeValue = '';
|
|
|
|
n.nodeValue = '';
|
|
|
|
arrRemove.push(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for(var k=0; k<arrRemove.length; k++){
|
|
|
|
this.highlightedNodes.splice(arrRemove[k], 1);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
/*====================================================
|
|
|
|
- Private methods
|
|
|
|
=====================================================*/
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
/*====================================================
|
|
|
|
- Only used by AddGrid() method
|
|
|
|
- Resets filtering grid bar if previously removed
|
|
|
|
=====================================================*/
|
2014-10-04 16:38:42 +02:00
|
|
|
__resetGrid: function(){
|
|
|
|
if(this.isFirstLoad){
|
|
|
|
return;
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
// grid was removed, grid row element is stored in fltGridEl property
|
|
|
|
if(!this.gridLayout){
|
|
|
|
this.tbl.rows[this.filtersRowIndex].parentNode.insertBefore(
|
|
|
|
this.fltGridEl,
|
|
|
|
this.tbl.rows[this.filtersRowIndex]
|
|
|
|
);
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-10-04 16:38:42 +02:00
|
|
|
// filters are appended in external placeholders elements
|
|
|
|
if(this.isExternalFlt){
|
|
|
|
for(var ct=0; ct<this.externalFltTgtIds.length; ct++){
|
2014-11-01 15:34:37 +01:00
|
|
|
var extFlt = dom.id(this.externalFltTgtIds[ct]);
|
2014-10-04 16:38:42 +02:00
|
|
|
if(extFlt){
|
|
|
|
extFlt.appendChild(this.externalFltEls[ct]);
|
|
|
|
var colFltType = this['col'+ct];
|
2014-10-12 13:40:08 +02:00
|
|
|
//IE special treatment for gridLayout, appended filters are
|
|
|
|
//empty
|
2014-10-04 16:38:42 +02:00
|
|
|
if(this.gridLayout &&
|
|
|
|
this.externalFltEls[ct].innerHTML === '' &&
|
|
|
|
colFltType !== this.fltTypeInp){
|
|
|
|
if(colFltType === this.fltTypeSlc ||
|
|
|
|
colFltType === this.fltTypeMulti){
|
2014-09-20 15:56:35 +02:00
|
|
|
this.PopulateSelect(ct);
|
2014-10-04 16:38:42 +02:00
|
|
|
}
|
|
|
|
if(colFltType === this.fltTypeCheckList){
|
|
|
|
this.PopulateCheckList(ct);
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
2014-10-04 16:38:42 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
this.nbFilterableRows = this.GetRowsNb();
|
|
|
|
this.nbVisibleRows = this.nbFilterableRows;
|
|
|
|
this.nbRows = this.tbl.rows.length;
|
2014-10-04 16:38:42 +02:00
|
|
|
if(this.isSortEnabled){
|
|
|
|
this.sort = true;
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
|
2014-10-04 16:38:42 +02:00
|
|
|
if(this.tbl.rows[this.filtersRowIndex].innerHTML === ''){
|
2014-09-20 15:56:35 +02:00
|
|
|
refreshFilters(this);
|
2014-10-04 16:38:42 +02:00
|
|
|
} else {
|
|
|
|
if(this.popUpFilters){
|
|
|
|
this.headersRow++;
|
|
|
|
this.SetPopupFilters();
|
|
|
|
}
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
|
2014-10-04 16:38:42 +02:00
|
|
|
/*** ie bug work-around, filters need to be re-generated since row
|
|
|
|
is empty; insertBefore method doesn't seem to work properly
|
2014-09-20 15:56:35 +02:00
|
|
|
with previously generated DOM nodes modified by innerHTML ***/
|
|
|
|
function refreshFilters(o){
|
|
|
|
o.tbl.deleteRow(o.filtersRowIndex);
|
|
|
|
o.RemoveGrid();
|
|
|
|
o.fltIds = [];
|
|
|
|
o.isFirstLoad = true;
|
2014-10-04 16:38:42 +02:00
|
|
|
if(o.popUpFilters){
|
|
|
|
o.RemovePopupFilters();
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
o._AddGrid();
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-10-04 16:38:42 +02:00
|
|
|
if(!this.gridLayout){
|
2014-10-18 14:00:34 +02:00
|
|
|
dom.addClass(this.tbl, this.prfxTf);
|
2014-10-04 16:38:42 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
this.hasGrid = true;
|
|
|
|
},
|
|
|
|
|
|
|
|
/*==============================================
|
|
|
|
- Checks if data contains searched arg,
|
|
|
|
returns a boolean
|
|
|
|
- Params:
|
|
|
|
- arg: searched string
|
|
|
|
- data: data string
|
|
|
|
- fltType: filter type (string,
|
|
|
|
exact match by default for selects -
|
|
|
|
optional)
|
|
|
|
- forceMatch: boolean forcing exact
|
|
|
|
match (optional)
|
|
|
|
===============================================*/
|
2014-10-04 16:38:42 +02:00
|
|
|
__containsStr: function(arg, data, fltType, forceMatch){
|
2014-09-20 15:56:35 +02:00
|
|
|
// Improved by Cedric Wartel (cwl)
|
2014-10-04 16:38:42 +02:00
|
|
|
// automatic exact match for selects and special characters are now
|
|
|
|
// filtered
|
|
|
|
var regexp,
|
|
|
|
modifier = (this.matchCase) ? 'g' : 'gi',
|
|
|
|
exactMatch = !forceMatch ? this.exactMatch : forceMatch;
|
|
|
|
if(exactMatch || (fltType!==this.fltTypeInp && fltType)){
|
|
|
|
regexp = new RegExp(
|
2014-10-18 14:00:34 +02:00
|
|
|
'(^\\s*)'+ str.rgxEsc(arg) +'(\\s*$)', modifier);
|
2014-10-04 16:38:42 +02:00
|
|
|
} else{
|
2014-10-18 14:00:34 +02:00
|
|
|
regexp = new RegExp(str.rgxEsc(arg), modifier);
|
2014-10-04 16:38:42 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
return regexp.test(data);
|
|
|
|
},
|
|
|
|
|
2014-10-04 16:38:42 +02:00
|
|
|
IncludeFile: function(fileId, filePath, callback, type){
|
|
|
|
var ftype = !type ? 'script' : type,
|
2014-10-18 14:00:34 +02:00
|
|
|
imported = isImported(filePath, ftype);
|
|
|
|
if(imported){
|
2014-10-04 16:38:42 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
var o = this,
|
|
|
|
isLoaded = false,
|
|
|
|
file,
|
2014-11-01 15:34:37 +01:00
|
|
|
head = dom.tag(doc,'head')[0];
|
2014-09-20 15:56:35 +02:00
|
|
|
|
2014-10-18 14:00:34 +02:00
|
|
|
if(str.lower(ftype) === 'link'){
|
|
|
|
file = dom.create(
|
2014-10-04 16:38:42 +02:00
|
|
|
'link',
|
|
|
|
['id', fileId], ['type', 'text/css'],
|
|
|
|
['rel', 'stylesheet'], ['href', filePath]
|
|
|
|
);
|
|
|
|
} else {
|
2014-10-18 14:00:34 +02:00
|
|
|
file = dom.create(
|
2014-10-04 16:38:42 +02:00
|
|
|
'script', ['id', fileId],
|
|
|
|
['type', 'text/javascript'], ['src', filePath]
|
|
|
|
);
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-10-04 16:38:42 +02:00
|
|
|
//Browser <> IE onload event works only for scripts, not for stylesheets
|
|
|
|
file.onload = file.onreadystatechange = function(){
|
2014-09-20 15:56:35 +02:00
|
|
|
if(!isLoaded &&
|
2014-10-04 16:38:42 +02:00
|
|
|
(!this.readyState || this.readyState === 'loaded' ||
|
|
|
|
this.readyState === 'complete')){
|
2014-09-20 15:56:35 +02:00
|
|
|
isLoaded = true;
|
2014-10-04 16:38:42 +02:00
|
|
|
if(typeof callback === 'function'){
|
|
|
|
callback.call(null, o);
|
|
|
|
}
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
2014-10-04 16:38:42 +02:00
|
|
|
};
|
2014-09-20 15:56:35 +02:00
|
|
|
file.onerror = function(){
|
|
|
|
throw new Error('TF script could not load:\n' + this.src);
|
2014-10-04 16:38:42 +02:00
|
|
|
};
|
2014-09-20 15:56:35 +02:00
|
|
|
head.appendChild(file);
|
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- checks if table has a filter grid
|
|
|
|
- returns a boolean
|
|
|
|
=====================================================*/
|
2014-10-04 16:38:42 +02:00
|
|
|
HasGrid: function(){
|
2014-09-20 15:56:35 +02:00
|
|
|
return this.hasGrid;
|
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- returns an array containing filters ids
|
|
|
|
- Note that hidden filters are also returned
|
|
|
|
=====================================================*/
|
2014-10-04 16:38:42 +02:00
|
|
|
GetFiltersId: function(){
|
|
|
|
if(!this.hasGrid){
|
|
|
|
return;
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
return this.fltIds;
|
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- returns an array containing valid rows indexes
|
|
|
|
(valid rows upon filtering)
|
|
|
|
=====================================================*/
|
2014-10-04 16:38:42 +02:00
|
|
|
GetValidRowsIndex: function(reCalc){
|
|
|
|
if(!this.hasGrid){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(!reCalc){
|
|
|
|
return this.validRowsIndex;
|
|
|
|
}
|
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
this.validRowsIndex = [];
|
|
|
|
for(var k=this.refRow; k<this.GetRowsNb(true); k++){
|
|
|
|
var r = this.tbl.rows[k];
|
|
|
|
if(!this.paging){
|
2014-10-04 16:38:42 +02:00
|
|
|
if(this.GetRowDisplay(r) !== 'none'){
|
2014-09-20 15:56:35 +02:00
|
|
|
this.validRowsIndex.push(r.rowIndex);
|
2014-10-04 16:38:42 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
} else {
|
2014-10-04 16:38:42 +02:00
|
|
|
if(r.getAttribute('validRow') === 'true' ||
|
|
|
|
r.getAttribute('validRow') === null){
|
2014-09-20 15:56:35 +02:00
|
|
|
this.validRowsIndex.push(r.rowIndex);
|
2014-10-04 16:38:42 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return this.validRowsIndex;
|
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- Returns the index of the row containing the
|
|
|
|
filters
|
|
|
|
=====================================================*/
|
2014-10-04 16:38:42 +02:00
|
|
|
GetFiltersRowIndex: function(){
|
|
|
|
if(!this.hasGrid){
|
|
|
|
return;
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
return this.filtersRowIndex;
|
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- Returns the index of the headers row
|
|
|
|
=====================================================*/
|
2014-10-04 16:38:42 +02:00
|
|
|
GetHeadersRowIndex: function(){
|
|
|
|
if(!this.hasGrid){
|
|
|
|
return;
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
return this.headersRow;
|
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- Returns the index of the row from which will
|
|
|
|
start the filtering process (1st filterable row)
|
|
|
|
=====================================================*/
|
2014-10-04 16:38:42 +02:00
|
|
|
GetStartRowIndex: function(){
|
|
|
|
if(!this.hasGrid){
|
|
|
|
return;
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
return this.refRow;
|
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- Returns the index of the last row
|
|
|
|
=====================================================*/
|
2014-10-04 16:38:42 +02:00
|
|
|
GetLastRowIndex: function(){
|
|
|
|
if(!this.hasGrid){
|
|
|
|
return;
|
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
return (this.nbRows-1);
|
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- returns a header DOM element for a given column
|
|
|
|
index
|
|
|
|
=====================================================*/
|
2014-10-04 16:38:42 +02:00
|
|
|
GetHeaderElement: function(colIndex){
|
|
|
|
var table = this.gridLayout ? this.headTbl : this.tbl;
|
2014-11-01 15:34:37 +01:00
|
|
|
var header, tHead = dom.tag(this.tbl,'thead');
|
2014-10-04 16:38:42 +02:00
|
|
|
for(var i=0; i<this.nbCells; i++){
|
|
|
|
if(i !== colIndex){
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if(tHead.length === 0){
|
2014-09-20 15:56:35 +02:00
|
|
|
header = table.rows[this.headersRow].cells[i];
|
2014-10-04 16:38:42 +02:00
|
|
|
}
|
|
|
|
if(tHead.length === 1){
|
2014-09-20 15:56:35 +02:00
|
|
|
header = tHead[0].rows[this.headersRow].cells[i];
|
2014-10-04 16:38:42 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
break;
|
2014-09-07 12:07:28 +02:00
|
|
|
}
|
2014-09-20 15:56:35 +02:00
|
|
|
return header;
|
|
|
|
},
|
2014-09-07 12:07:28 +02:00
|
|
|
|
2014-09-20 15:56:35 +02:00
|
|
|
/*====================================================
|
|
|
|
- returns the original configuration object
|
|
|
|
=====================================================*/
|
2014-10-04 16:38:42 +02:00
|
|
|
GetConfigObject: function(){
|
2014-09-20 15:56:35 +02:00
|
|
|
return this.fObj;
|
|
|
|
},
|
|
|
|
|
|
|
|
/*====================================================
|
|
|
|
- returns the total number of rows that can be
|
|
|
|
filtered
|
|
|
|
=====================================================*/
|
2014-10-04 16:38:42 +02:00
|
|
|
GetFilterableRowsNb: function(){
|
2014-09-20 15:56:35 +02:00
|
|
|
return this.GetRowsNb(false);
|
|
|
|
}
|
|
|
|
};
|
2014-09-07 09:56:17 +02:00
|
|
|
|
2014-10-18 14:00:34 +02:00
|
|
|
function numSortAsc(a, b){ return (a-b); }
|
2014-09-07 09:56:17 +02:00
|
|
|
|
2014-10-18 14:00:34 +02:00
|
|
|
function numSortDesc(a, b){ return (b-a); }
|
2014-09-07 09:56:17 +02:00
|
|
|
|
2014-10-18 14:00:34 +02:00
|
|
|
function ignoreCaseSort(a, b){
|
|
|
|
var x = str.lower(a);
|
|
|
|
var y = str.lower(b);
|
|
|
|
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
|
2014-09-07 09:56:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-18 14:00:34 +02:00
|
|
|
function removeNbFormat(data, format){
|
|
|
|
if(!data){
|
2014-09-07 12:07:28 +02:00
|
|
|
return;
|
2014-10-04 16:38:42 +02:00
|
|
|
}
|
2014-10-18 14:00:34 +02:00
|
|
|
if(!format){
|
|
|
|
format = 'us';
|
|
|
|
}
|
|
|
|
var n = data;
|
|
|
|
if(str.lower(format)==='us'){
|
|
|
|
n =+ n.replace(/[^\d\.-]/g,'');
|
|
|
|
} else {
|
|
|
|
n =+ n.replace(/[^\d\,-]/g,'').replace(',','.');
|
|
|
|
}
|
|
|
|
return n;
|
2014-09-07 09:56:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-18 14:00:34 +02:00
|
|
|
function isImported(filePath, type){
|
|
|
|
var imported = false,
|
|
|
|
importType = !type ? 'script' : type,
|
|
|
|
attr = importType == 'script' ? 'src' : 'href',
|
2014-11-01 15:34:37 +01:00
|
|
|
files = dom.tag(doc,importType);
|
2014-10-18 14:00:34 +02:00
|
|
|
for (var i=0; i<files.length; i++){
|
|
|
|
if(files[i][attr] === undefined){
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if(files[i][attr].match(filePath)){
|
|
|
|
imported = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return imported;
|
2014-09-07 09:56:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-18 14:00:34 +02:00
|
|
|
// function isStylesheetImported(stylesheet){
|
|
|
|
// var isImported = false;
|
|
|
|
// if(!doc.styleSheets){
|
|
|
|
// return isImported;
|
|
|
|
// }
|
|
|
|
// var s = doc.styleSheets,
|
|
|
|
// regexp = new RegExp(stylesheet);
|
|
|
|
// for(var i=0; i<s.length; i++){
|
|
|
|
// if(s[i].imports){//IE
|
|
|
|
// var imp = s[i].imports;
|
|
|
|
// for(var j=0; j<imp.length; j++){
|
|
|
|
// if(str.lower(imp[j].href) === str.lower(stylesheet)){
|
|
|
|
// isImported = true;
|
|
|
|
// break;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// } else {
|
|
|
|
// var r = s[i].cssRules ? s[i].cssRules : s[i].rules;
|
|
|
|
// for(var k=0; k<r.length; k++){
|
|
|
|
// if(regexp.test(r[k].cssText)){
|
|
|
|
// isImported = true;
|
|
|
|
// break;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// return isImported;
|
|
|
|
// }
|
|
|
|
|
|
|
|
//Firefox does not support outerHTML property
|
|
|
|
function setOuterHtml(){
|
|
|
|
if(doc.body.__defineGetter__){
|
|
|
|
if(HTMLElement) {
|
|
|
|
var element = HTMLElement.prototype;
|
|
|
|
if(element.__defineGetter__){
|
|
|
|
element.__defineGetter__("outerHTML",
|
|
|
|
function(){
|
|
|
|
var parent = this.parentNode;
|
|
|
|
var el = dom.create(parent.tagName);
|
|
|
|
el.appendChild(this);
|
|
|
|
var shtml = el.innerHTML;
|
|
|
|
parent.appendChild(this);
|
|
|
|
return shtml;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
if(element.__defineSetter__) {
|
|
|
|
HTMLElement.prototype.__defineSetter__(
|
|
|
|
"outerHTML", function(sHTML){
|
|
|
|
var r = this.ownerDocument.createRange();
|
|
|
|
r.setStartBefore(this);
|
|
|
|
var df = r.createContextualFragment(sHTML);
|
|
|
|
this.parentNode.replaceChild(df, this);
|
|
|
|
return sHTML;
|
|
|
|
});
|
|
|
|
}
|
2014-10-04 16:38:42 +02:00
|
|
|
}
|
|
|
|
}
|
2014-10-18 14:00:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return TableFilter;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2014-09-07 09:56:17 +02:00
|
|
|
/*====================================================
|
2014-09-07 12:07:28 +02:00
|
|
|
- Sets filters grid bar
|
|
|
|
- Calls TF Constructor and generates grid bar
|
|
|
|
- Params:
|
|
|
|
- id: table id (string)
|
|
|
|
- refRow (optional): row index (number)
|
|
|
|
- config (optional): configuration
|
|
|
|
object (literal object)
|
|
|
|
- Returns TF object
|
2014-09-07 09:56:17 +02:00
|
|
|
=====================================================*/
|
2014-10-26 11:48:13 +01:00
|
|
|
// function setFilterGrid(id){
|
|
|
|
// if(arguments.length === 0){
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
// var tf = new TableFilter(arguments[0], arguments[1], arguments[2]);
|
|
|
|
// tf.init();
|
|
|
|
// window['tf_'+id] = tf;
|
|
|
|
// return tf;
|
|
|
|
// }
|
2014-09-07 09:56:17 +02:00
|
|
|
|
|
|
|
/*===BEGIN removable section===========================
|
2014-09-07 12:07:28 +02:00
|
|
|
- Unobtrusive grid bar generation using
|
|
|
|
'filterable' class
|
|
|
|
- If you don't use it you can remove safely this
|
|
|
|
section
|
2014-09-07 09:56:17 +02:00
|
|
|
/*=====================================================*/
|
2014-10-26 02:42:34 +01:00
|
|
|
// window['tf_isNotIE'] = !(/msie|MSIE/.test(navigator.userAgent));
|
2014-10-18 14:00:34 +02:00
|
|
|
// TF.Event.add(window,
|
|
|
|
// (tf_isNotIE || (typeof window.addEventListener === 'function') ?
|
|
|
|
// 'DOMContentLoaded' : 'load'),
|
|
|
|
// initFilterGrid);
|
2014-09-07 09:56:17 +02:00
|
|
|
|
2014-10-26 02:42:34 +01:00
|
|
|
// function initFilterGrid(){
|
|
|
|
// if(!document.getElementsByTagName){ return; }
|
2014-11-01 15:34:37 +01:00
|
|
|
// var tbls = dom.tag(document,'table'), config;
|
2014-10-26 02:42:34 +01:00
|
|
|
// for (var i=0; i<tbls.length; i++){
|
|
|
|
// var cTbl = tbls[i], cTblId = cTbl.getAttribute('id');
|
|
|
|
// if(TF.Dom.hasClass(cTbl,'filterable') && cTblId){
|
|
|
|
// if(TF.Types.isObj(cTblId+'_config')){
|
|
|
|
// config = window[cTblId+'_config'];
|
|
|
|
// } else { config = undefined; }
|
|
|
|
// window[cTblId+'_isUnob'] = true;
|
|
|
|
// setFilterGrid(cTblId,config);
|
|
|
|
// }
|
|
|
|
// }// for i
|
|
|
|
// }
|
2014-09-07 09:56:17 +02:00
|
|
|
/*===END removable section===========================*/
|