mirror of
https://github.com/koalyptus/TableFilter.git
synced 2024-05-11 10:57:04 +02:00
Code formatting
This commit is contained in:
parent
fef259dbdb
commit
0a7ddf6d36
|
@ -706,8 +706,8 @@ function TF(id) {
|
||||||
loadextensions: 'LoadExtensions',
|
loadextensions: 'LoadExtensions',
|
||||||
loadthemes: 'LoadThemes'
|
loadthemes: 'LoadThemes'
|
||||||
},
|
},
|
||||||
getKeyCode: function(e){
|
getKeyCode: function(evt){
|
||||||
return e.charCode ? evt.charCode :
|
return evt.charCode ? evt.charCode :
|
||||||
(evt.keyCode ? evt.keyCode: (evt.which ? evt.which : 0));
|
(evt.keyCode ? evt.keyCode: (evt.which ? evt.which : 0));
|
||||||
},
|
},
|
||||||
/*====================================================
|
/*====================================================
|
||||||
|
@ -3282,7 +3282,7 @@ TF.prototype = {
|
||||||
- execute filtering (boolean)
|
- execute filtering (boolean)
|
||||||
=====================================================*/
|
=====================================================*/
|
||||||
__deferMultipleSelection: function(slc,index,filter){
|
__deferMultipleSelection: function(slc,index,filter){
|
||||||
if(slc.nodeName.tf_LCase() !== 'select'){
|
if(slc.nodeName.tf_LCase()!=='select'){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var doFilter = filter===undefined ? false : filter;
|
var doFilter = filter===undefined ? false : filter;
|
||||||
|
@ -3290,7 +3290,7 @@ TF.prototype = {
|
||||||
window.setTimeout(function(){
|
window.setTimeout(function(){
|
||||||
slc.options[0].selected = false;
|
slc.options[0].selected = false;
|
||||||
|
|
||||||
if(slc.options[index].value=='')
|
if(slc.options[index].value==='')
|
||||||
slc.options[index].selected = false;
|
slc.options[index].selected = false;
|
||||||
else
|
else
|
||||||
slc.options[index].selected = true;
|
slc.options[index].selected = true;
|
||||||
|
@ -3298,99 +3298,127 @@ TF.prototype = {
|
||||||
}, 0.1);
|
}, 0.1);
|
||||||
},
|
},
|
||||||
|
|
||||||
__getCustomValues: function(colIndex)
|
|
||||||
/*====================================================
|
/*====================================================
|
||||||
- Returns an array [[values],[texts]] with
|
- Returns an array [[values],[texts]] with
|
||||||
custom values for a given filter
|
custom values for a given filter
|
||||||
- Param: column index (integer)
|
- Param: column index (integer)
|
||||||
=====================================================*/
|
=====================================================*/
|
||||||
{
|
__getCustomValues: function(colIndex){
|
||||||
if(colIndex==undefined) return;
|
if(!colIndex){
|
||||||
var isCustomSlc = (this.hasCustomSlcOptions //custom select test
|
return;
|
||||||
&& this.customSlcOptions.cols.tf_Has(colIndex));
|
}
|
||||||
if(!isCustomSlc) return;
|
//custom select test
|
||||||
|
var isCustomSlc = this.hasCustomSlcOptions &&
|
||||||
|
this.customSlcOptions.cols.tf_Has(colIndex);
|
||||||
|
if(!isCustomSlc){
|
||||||
|
return;
|
||||||
|
}
|
||||||
var optTxt = [], optArray = [];
|
var optTxt = [], optArray = [];
|
||||||
var index = this.customSlcOptions.cols.tf_IndexByValue(colIndex);
|
var index = this.customSlcOptions.cols.tf_IndexByValue(colIndex);
|
||||||
var slcValues = this.customSlcOptions.values[index];
|
var slcValues = this.customSlcOptions.values[index];
|
||||||
var slcTexts = this.customSlcOptions.texts[index];
|
var slcTexts = this.customSlcOptions.texts[index];
|
||||||
var slcSort = this.customSlcOptions.sorts[index];
|
var slcSort = this.customSlcOptions.sorts[index];
|
||||||
for(var r=0; r<slcValues.length; r++)
|
for(var r=0; r<slcValues.length; r++){
|
||||||
{
|
|
||||||
optArray.push(slcValues[r]);
|
optArray.push(slcValues[r]);
|
||||||
if(slcTexts[r]!=undefined)
|
if(slcTexts[r]){
|
||||||
optTxt.push(slcTexts[r]);
|
optTxt.push(slcTexts[r]);
|
||||||
else
|
} else {
|
||||||
optTxt.push(slcValues[r]);
|
optTxt.push(slcValues[r]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(slcSort)
|
if(slcSort){
|
||||||
{
|
|
||||||
optArray.sort();
|
optArray.sort();
|
||||||
optTxt.sort();
|
optTxt.sort();
|
||||||
}
|
}
|
||||||
return [optArray,optTxt];
|
return [optArray,optTxt];
|
||||||
},
|
},
|
||||||
|
|
||||||
PopulateCheckList: function(colIndex, isExternal, extFltId)
|
PopulateCheckList: function(colIndex, isExternal, extFltId){
|
||||||
{
|
|
||||||
this.EvtManager(
|
this.EvtManager(
|
||||||
this.Evt.name.populatechecklist,
|
this.Evt.name.populatechecklist,
|
||||||
{ slcIndex:colIndex, slcExternal:isExternal, slcId:extFltId }
|
{ slcIndex:colIndex, slcExternal:isExternal, slcId:extFltId }
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
_PopulateCheckList: function(colIndex, isExternal, extFltId)
|
|
||||||
/*====================================================
|
/*====================================================
|
||||||
- populates checklist filters
|
- populates checklist filters
|
||||||
=====================================================*/
|
=====================================================*/
|
||||||
{
|
_PopulateCheckList: function(colIndex, isExternal, extFltId){
|
||||||
isExternal = (isExternal==undefined) ? false : isExternal;
|
isExternal = !isExternal ? false : isExternal;
|
||||||
var divFltId = this.prfxCheckListDiv+colIndex+'_'+this.id;
|
var divFltId = this.prfxCheckListDiv+colIndex+'_'+this.id;
|
||||||
if( tf_Id(divFltId)==null && !isExternal ) return;
|
if(!tf_Id(divFltId) && !isExternal){
|
||||||
if( tf_Id(extFltId)==null && isExternal ) return;
|
return;
|
||||||
var flt = (!isExternal) ? this.checkListDiv[colIndex] : tf_Id(extFltId);
|
}
|
||||||
var ul = tf_CreateElm('ul',['id',this.fltIds[colIndex]],['colIndex',colIndex]);
|
if(!tf_Id(extFltId) && isExternal){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var flt = !isExternal ? this.checkListDiv[colIndex] : tf_Id(extFltId);
|
||||||
|
var ul = tf_CreateElm('ul',
|
||||||
|
['id',this.fltIds[colIndex]], ['colIndex',colIndex]);
|
||||||
ul.className = this.checkListCssClass;
|
ul.className = this.checkListCssClass;
|
||||||
ul.onchange = this.Evt._OnCheckListChange;
|
ul.onchange = this.Evt._OnCheckListChange;
|
||||||
var o = this, row = this.tbl.rows;
|
var o = this, row = this.tbl.rows;
|
||||||
var optArray = [];
|
var optArray = [];
|
||||||
var isCustomSlc = (this.hasCustomSlcOptions //custom select test
|
//custom select test
|
||||||
&& this.customSlcOptions.cols.tf_Has(colIndex));
|
var isCustomSlc = (this.hasCustomSlcOptions &&
|
||||||
var optTxt = []; //custom selects text
|
this.customSlcOptions.cols.tf_Has(colIndex));
|
||||||
var activeFlt;
|
//custom selects text
|
||||||
|
var optTxt = [],
|
||||||
|
activeFlt;
|
||||||
if(this.refreshFilters && this.activeFilterId){
|
if(this.refreshFilters && this.activeFilterId){
|
||||||
activeFlt = this.activeFilterId.split('_')[0];
|
activeFlt = this.activeFilterId.split('_')[0];
|
||||||
activeFlt = activeFlt.split(this.prfxFlt)[1];
|
activeFlt = activeFlt.split(this.prfxFlt)[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
var excludedOpts = null, filteredDataCol = null;
|
var excludedOpts,
|
||||||
if(this.refreshFilters && this.disableExcludedOptions){ excludedOpts = []; filteredDataCol = []; }
|
filteredDataCol;
|
||||||
|
if(this.refreshFilters && this.disableExcludedOptions){
|
||||||
|
excludedOpts = [];
|
||||||
|
filteredDataCol = [];
|
||||||
|
}
|
||||||
|
|
||||||
for(var k=this.refRow; k<this.nbRows; k++)
|
for(var k=this.refRow; k<this.nbRows; k++){
|
||||||
{
|
// always visible rows don't need to appear on selects as always
|
||||||
// always visible rows don't need to appear on selects as always valid
|
// valid
|
||||||
if( this.hasVisibleRows && this.visibleRows.tf_Has(k) && !this.paging )
|
if(this.hasVisibleRows && this.visibleRows.tf_Has(k) &&
|
||||||
|
!this.paging){
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
var cells = row[k].cells;
|
var cells = row[k].cells;
|
||||||
var ncells = cells.length;
|
var ncells = cells.length;
|
||||||
|
|
||||||
if(ncells == this.nbCells && !isCustomSlc)
|
// checks if row has exact cell #
|
||||||
{// checks if row has exact cell #
|
if(ncells == this.nbCells && !isCustomSlc){
|
||||||
for(var j=0; j<ncells; j++)
|
// this loop retrieves cell data
|
||||||
{// this loop retrieves cell data
|
for(var j=0; j<ncells; j++){
|
||||||
if((colIndex==j && (!this.refreshFilters || (this.refreshFilters && this.disableExcludedOptions))) ||
|
if((colIndex===j && (!this.refreshFilters ||
|
||||||
(colIndex==j && this.refreshFilters && ((row[k].style.display == '' && !this.paging) ||
|
(this.refreshFilters && this.disableExcludedOptions)))||
|
||||||
(this.paging && ((activeFlt==undefined || activeFlt==colIndex ) ||(activeFlt!=colIndex && this.validRowsIndex.tf_Has(k))) ))))
|
(colIndex===j && this.refreshFilters &&
|
||||||
{
|
((row[k].style.display === '' && !this.paging) ||
|
||||||
|
(this.paging && ((!activeFlt || activeFlt===colIndex )||
|
||||||
|
(activeFlt!=colIndex &&
|
||||||
|
this.validRowsIndex.tf_Has(k))) )))){
|
||||||
var cell_data = this.GetCellData(j, cells[j]);
|
var cell_data = this.GetCellData(j, cells[j]);
|
||||||
var cell_string = cell_data.tf_MatchCase(this.matchCase);//V<>ry P<>ter's patch
|
//V<>ry P<>ter's patch
|
||||||
|
var cell_string =
|
||||||
|
cell_data.tf_MatchCase(this.matchCase);
|
||||||
// checks if celldata is already in array
|
// checks if celldata is already in array
|
||||||
if(!optArray.tf_Has(cell_string,this.matchCase)) optArray.push(cell_data);
|
if(!optArray.tf_Has(cell_string,this.matchCase)){
|
||||||
|
optArray.push(cell_data);
|
||||||
|
}
|
||||||
|
var filteredCol = filteredDataCol[j];
|
||||||
if(this.refreshFilters && this.disableExcludedOptions){
|
if(this.refreshFilters && this.disableExcludedOptions){
|
||||||
if(!filteredDataCol[j]) filteredDataCol[j] = this.GetFilteredDataCol(j);
|
if(!filteredCol){
|
||||||
if(!filteredDataCol[j].tf_Has(cell_string,this.matchCase)
|
filteredDataCol[j] = this.GetFilteredDataCol(j);
|
||||||
&& !excludedOpts.tf_Has(cell_string,this.matchCase) && !this.isFirstLoad) excludedOpts.push(cell_data);
|
}
|
||||||
|
if(!filteredCol.tf_Has(
|
||||||
|
cell_string,this.matchCase) &&
|
||||||
|
!excludedOpts.tf_Has(
|
||||||
|
cell_string,this.matchCase) &&
|
||||||
|
!this.isFirstLoad){
|
||||||
|
excludedOpts.push(cell_data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3398,8 +3426,7 @@ TF.prototype = {
|
||||||
}
|
}
|
||||||
|
|
||||||
//Retrieves custom values
|
//Retrieves custom values
|
||||||
if(isCustomSlc)
|
if(isCustomSlc){
|
||||||
{
|
|
||||||
var customValues = this.__getCustomValues(colIndex);
|
var customValues = this.__getCustomValues(colIndex);
|
||||||
optArray = customValues[0];
|
optArray = customValues[0];
|
||||||
optTxt = customValues[1];
|
optTxt = customValues[1];
|
||||||
|
@ -3408,68 +3435,101 @@ TF.prototype = {
|
||||||
if(this.sortSlc && !isCustomSlc){
|
if(this.sortSlc && !isCustomSlc){
|
||||||
if (!this.matchCase){
|
if (!this.matchCase){
|
||||||
optArray.sort(tf_IgnoreCaseSort);
|
optArray.sort(tf_IgnoreCaseSort);
|
||||||
if(excludedOpts) excludedOpts.sort(tf_IgnoreCaseSort);
|
if(excludedOpts){
|
||||||
} else { optArray.sort(); if(excludedOpts){ excludedOpts.sort(); } }
|
excludedOpts.sort(tf_IgnoreCaseSort);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
optArray.sort();
|
||||||
|
if(excludedOpts){ excludedOpts.sort(); }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
//asc sort
|
||||||
if(this.sortNumAsc && this.sortNumAsc.tf_Has(colIndex))
|
if(this.sortNumAsc && this.sortNumAsc.tf_Has(colIndex)){
|
||||||
{//asc sort
|
|
||||||
try{
|
try{
|
||||||
optArray.sort( tf_NumSortAsc );
|
optArray.sort( tf_NumSortAsc );
|
||||||
if(excludedOpts) excludedOpts.sort( tf_NumSortAsc );
|
if(excludedOpts){
|
||||||
if(isCustomSlc) optTxt.sort( tf_NumSortAsc );
|
excludedOpts.sort( tf_NumSortAsc );
|
||||||
|
}
|
||||||
|
if(isCustomSlc){
|
||||||
|
optTxt.sort( tf_NumSortAsc );
|
||||||
|
}
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
optArray.sort(); if(excludedOpts){ excludedOpts.sort(); }
|
optArray.sort(); if(excludedOpts){ excludedOpts.sort(); }
|
||||||
if(isCustomSlc) optTxt.sort();
|
if(isCustomSlc){
|
||||||
|
optTxt.sort();
|
||||||
|
}
|
||||||
}//in case there are alphanumeric values
|
}//in case there are alphanumeric values
|
||||||
}
|
}
|
||||||
if(this.sortNumDesc && this.sortNumDesc.tf_Has(colIndex))
|
//desc sort
|
||||||
{//desc sort
|
if(this.sortNumDesc && this.sortNumDesc.tf_Has(colIndex)){
|
||||||
try{
|
try{
|
||||||
optArray.sort( tf_NumSortDesc );
|
optArray.sort( tf_NumSortDesc );
|
||||||
if(excludedOpts) excludedOpts.sort( tf_NumSortDesc );
|
if(excludedOpts){
|
||||||
if(isCustomSlc) optTxt.sort( tf_NumSortDesc );
|
excludedOpts.sort( tf_NumSortDesc );
|
||||||
|
}
|
||||||
|
if(isCustomSlc){
|
||||||
|
optTxt.sort( tf_NumSortDesc );
|
||||||
|
}
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
optArray.sort(); if(excludedOpts){ excludedOpts.sort(); }
|
optArray.sort(); if(excludedOpts){ excludedOpts.sort(); }
|
||||||
if(isCustomSlc) optTxt.sort();
|
if(isCustomSlc){
|
||||||
|
optTxt.sort();
|
||||||
|
}
|
||||||
}//in case there are alphanumeric values
|
}//in case there are alphanumeric values
|
||||||
}
|
}
|
||||||
|
|
||||||
AddChecks(this.separator);
|
AddChecks(this.separator);
|
||||||
|
|
||||||
function AddTChecks()
|
// adds 1st option
|
||||||
{// adds 1st option
|
function AddTChecks(){
|
||||||
var chkCt = 1;
|
var chkCt = 1;
|
||||||
var li0 = tf_CreateCheckItem(o.fltIds[colIndex]+'_0', '', o.displayAllText);
|
var li0 = tf_CreateCheckItem(
|
||||||
|
o.fltIds[colIndex]+'_0', '', o.displayAllText);
|
||||||
li0.className = o.checkListItemCssClass;
|
li0.className = o.checkListItemCssClass;
|
||||||
ul.appendChild(li0);
|
ul.appendChild(li0);
|
||||||
li0.check.onclick = function(e){ o.__setCheckListValues(this); ul.onchange.call(null, e); };
|
li0.check.onclick = function(e){
|
||||||
if(!o.enableCheckListResetFilter) li0.style.display = 'none';
|
o.__setCheckListValues(this);
|
||||||
|
ul.onchange.call(null, e);
|
||||||
if(tf_isIE)
|
};
|
||||||
{//IE: label looses check capability
|
if(!o.enableCheckListResetFilter){
|
||||||
|
li0.style.display = 'none';
|
||||||
|
}
|
||||||
|
//IE: label looses check capability
|
||||||
|
if(tf_isIE){
|
||||||
li0.label.onclick = function(){ li0.check.click(); };
|
li0.label.onclick = function(){ li0.check.click(); };
|
||||||
}
|
}
|
||||||
|
|
||||||
if(o.enableEmptyOption){
|
if(o.enableEmptyOption){
|
||||||
var li1 = tf_CreateCheckItem(o.fltIds[colIndex]+'_1', o.emOperator, o.emptyText);
|
var li1 = tf_CreateCheckItem(
|
||||||
|
o.fltIds[colIndex]+'_1', o.emOperator, o.emptyText);
|
||||||
li1.className = o.checkListItemCssClass;
|
li1.className = o.checkListItemCssClass;
|
||||||
ul.appendChild(li1);
|
ul.appendChild(li1);
|
||||||
li1.check.onclick = function(e){ o.__setCheckListValues(this); ul.onchange.call(null, e); };
|
li1.check.onclick = function(e){
|
||||||
if(tf_isIE)
|
o.__setCheckListValues(this);
|
||||||
{//IE: label looses check capability
|
ul.onchange.call(null, e);
|
||||||
|
};
|
||||||
|
//IE: label looses check capability
|
||||||
|
if(tf_isIE){
|
||||||
li1.label.onclick = function(){ li1.check.click(); };
|
li1.label.onclick = function(){ li1.check.click(); };
|
||||||
}
|
}
|
||||||
chkCt++;
|
chkCt++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(o.enableNonEmptyOption){
|
if(o.enableNonEmptyOption){
|
||||||
var li2 = tf_CreateCheckItem(o.fltIds[colIndex]+'_2', o.nmOperator, o.nonEmptyText);
|
var li2 = tf_CreateCheckItem(
|
||||||
|
o.fltIds[colIndex]+'_2',
|
||||||
|
o.nmOperator,
|
||||||
|
o.nonEmptyText
|
||||||
|
);
|
||||||
li2.className = o.checkListItemCssClass;
|
li2.className = o.checkListItemCssClass;
|
||||||
ul.appendChild(li2);
|
ul.appendChild(li2);
|
||||||
li2.check.onclick = function(e){ o.__setCheckListValues(this); ul.onchange.call(null, e); };
|
li2.check.onclick = function(e){
|
||||||
|
o.__setCheckListValues(this);
|
||||||
|
ul.onchange.call(null, e);
|
||||||
|
};
|
||||||
|
//IE: label looses check capability
|
||||||
if(tf_isIE)
|
if(tf_isIE)
|
||||||
{//IE: label looses check capability
|
{
|
||||||
li2.label.onclick = function(){ li2.check.click(); };
|
li2.label.onclick = function(){ li2.check.click(); };
|
||||||
}
|
}
|
||||||
chkCt++;
|
chkCt++;
|
||||||
|
@ -3477,108 +3537,123 @@ TF.prototype = {
|
||||||
return chkCt;
|
return chkCt;
|
||||||
}
|
}
|
||||||
|
|
||||||
function AddChecks(separator)
|
function AddChecks(separator){
|
||||||
{
|
|
||||||
var chkCt = AddTChecks();
|
var chkCt = AddTChecks();
|
||||||
|
|
||||||
var flts_values = [], fltArr = []; //remember grid values
|
var flts_values = [], fltArr = []; //remember grid values
|
||||||
var tmpVal = tf_CookieValueByIndex(o.fltsValuesCookie, colIndex, separator);
|
var tmpVal = tf_CookieValueByIndex(
|
||||||
if(tmpVal != undefined && tmpVal.tf_Trim().length > 0){
|
o.fltsValuesCookie, colIndex, separator);
|
||||||
if(o.hasCustomSlcOptions && o.customSlcOptions.cols.tf_Has(colIndex)){
|
if(tmpVal && tmpVal.tf_Trim().length > 0){
|
||||||
|
if(o.hasCustomSlcOptions &&
|
||||||
|
o.customSlcOptions.cols.tf_Has(colIndex)){
|
||||||
fltArr.push(tmpVal);
|
fltArr.push(tmpVal);
|
||||||
} else { fltArr = tmpVal.split(' '+o.orOperator+' '); }
|
} else {
|
||||||
|
fltArr = tmpVal.split(' '+o.orOperator+' ');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(var y=0; y<optArray.length; y++)
|
for(var y=0; y<optArray.length; y++){
|
||||||
{
|
|
||||||
var val = optArray[y]; //item value
|
var val = optArray[y]; //item value
|
||||||
var lbl = (isCustomSlc) ? optTxt[y] : val; //item text
|
var lbl = isCustomSlc ? optTxt[y] : val; //item text
|
||||||
var li = tf_CreateCheckItem(o.fltIds[colIndex]+'_'+(y+chkCt), val, lbl);
|
var li = tf_CreateCheckItem(
|
||||||
|
o.fltIds[colIndex]+'_'+(y+chkCt), val, lbl);
|
||||||
li.className = o.checkListItemCssClass;
|
li.className = o.checkListItemCssClass;
|
||||||
if(o.refreshFilters && o.disableExcludedOptions &&
|
if(o.refreshFilters && o.disableExcludedOptions &&
|
||||||
excludedOpts.tf_Has(val.tf_MatchCase(o.matchCase), o.matchCase)){
|
excludedOpts.tf_Has(
|
||||||
|
val.tf_MatchCase(o.matchCase), o.matchCase)){
|
||||||
tf_AddClass(li, o.checkListItemDisabledCssClass);
|
tf_AddClass(li, o.checkListItemDisabledCssClass);
|
||||||
li.check.disabled = true;
|
li.check.disabled = true;
|
||||||
li.disabled = true;
|
li.disabled = true;
|
||||||
} else
|
} else{
|
||||||
li.check.onclick = function(e){ o.__setCheckListValues(this); ul.onchange.call(null, e); };
|
li.check.onclick = function(e){
|
||||||
|
o.__setCheckListValues(this);
|
||||||
|
ul.onchange.call(null, e);
|
||||||
|
};
|
||||||
|
}
|
||||||
ul.appendChild(li);
|
ul.appendChild(li);
|
||||||
|
|
||||||
if(val=='') li.style.display = 'none'; //item is hidden
|
if(val===''){
|
||||||
|
//item is hidden
|
||||||
|
li.style.display = 'none';
|
||||||
|
}
|
||||||
|
|
||||||
/*** remember grid values ***/
|
/*** remember grid values ***/
|
||||||
if(o.rememberGridValues)
|
if(o.rememberGridValues){
|
||||||
{
|
if((o.hasCustomSlcOptions &&
|
||||||
if((o.hasCustomSlcOptions && o.customSlcOptions.cols.tf_Has(colIndex)
|
o.customSlcOptions.cols.tf_Has(colIndex) &&
|
||||||
&& fltArr.toString().indexOf(val)!= -1)
|
fltArr.toString().indexOf(val)!= -1) ||
|
||||||
|| fltArr.tf_Has(val.tf_MatchCase(o.matchCase),o.matchCase))
|
fltArr.tf_Has(
|
||||||
{
|
val.tf_MatchCase(o.matchCase),o.matchCase)){
|
||||||
li.check.checked = true;
|
li.check.checked = true;
|
||||||
o.__setCheckListValues(li.check);
|
o.__setCheckListValues(li.check);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//IE: label looses check capability
|
||||||
if(tf_isIE)
|
if(tf_isIE){
|
||||||
{//IE: label looses check capability
|
|
||||||
li.label.onclick = function(){ this.firstChild.click(); };
|
li.label.onclick = function(){ this.firstChild.click(); };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.fillSlcOnDemand) flt.innerHTML = '';
|
if(this.fillSlcOnDemand){
|
||||||
|
flt.innerHTML = '';
|
||||||
|
}
|
||||||
flt.appendChild(ul);
|
flt.appendChild(ul);
|
||||||
flt.setAttribute('filled','1');
|
flt.setAttribute('filled','1');
|
||||||
|
|
||||||
/*** remember grid values IE only, items remain un-checked ***/
|
/*** remember grid values IE only, items remain un-checked ***/
|
||||||
if(o.rememberGridValues && tf_isIE)
|
if(o.rememberGridValues && tf_isIE){
|
||||||
{
|
|
||||||
var slcIndexes = ul.getAttribute('indexes');
|
var slcIndexes = ul.getAttribute('indexes');
|
||||||
if(slcIndexes != null)
|
if(slcIndexes){
|
||||||
{
|
|
||||||
var indSplit = slcIndexes.split(',');//items indexes
|
var indSplit = slcIndexes.split(',');//items indexes
|
||||||
for(var n=0; n<indSplit.length; n++)
|
for(var n=0; n<indSplit.length; n++){
|
||||||
{
|
//checked item
|
||||||
var cChk = tf_Id(this.fltIds[colIndex]+'_'+indSplit[n]); //checked item
|
var cChk = tf_Id(this.fltIds[colIndex]+'_'+indSplit[n]);
|
||||||
if(cChk) cChk.checked = true;
|
if(cChk){
|
||||||
|
cChk.checked = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
__setCheckListValues: function(o)
|
|
||||||
/*====================================================
|
/*====================================================
|
||||||
- Sets checked items information of a checklist
|
- Sets checked items information of a checklist
|
||||||
=====================================================*/
|
=====================================================*/
|
||||||
{
|
__setCheckListValues: function(o){
|
||||||
if(o==null) return;
|
if(!o){
|
||||||
|
return;
|
||||||
|
}
|
||||||
var chkValue = o.value; //checked item value
|
var chkValue = o.value; //checked item value
|
||||||
var chkIndex = parseInt(o.id.split('_')[2]);
|
var chkIndex = parseInt(o.id.split('_')[2], 10);
|
||||||
var filterTag = 'ul', itemTag = 'li';
|
var filterTag = 'ul', itemTag = 'li';
|
||||||
var n = o;
|
var n = o;
|
||||||
|
|
||||||
//ul tag search
|
//ul tag search
|
||||||
while(n.nodeName.tf_LCase() != filterTag)
|
while(n.nodeName.tf_LCase()!==filterTag){
|
||||||
n = n.parentNode;
|
n = n.parentNode;
|
||||||
|
}
|
||||||
|
|
||||||
if(n.nodeName.tf_LCase() != filterTag) return;
|
if(n.nodeName.tf_LCase()!==filterTag){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var li = n.childNodes[chkIndex];
|
var li = n.childNodes[chkIndex];
|
||||||
var colIndex = n.getAttribute('colIndex');
|
var colIndex = n.getAttribute('colIndex');
|
||||||
var fltValue = n.getAttribute('value'); //filter value (ul tag)
|
var fltValue = n.getAttribute('value'); //filter value (ul tag)
|
||||||
var fltIndexes = n.getAttribute('indexes'); //selected items (ul tag)
|
var fltIndexes = n.getAttribute('indexes'); //selected items (ul tag)
|
||||||
|
|
||||||
if(o.checked)
|
if(o.checked){
|
||||||
{
|
//show all item
|
||||||
if(chkValue=='')
|
if(chkValue===''){
|
||||||
{//show all item
|
if((fltIndexes && fltIndexes!=='')){
|
||||||
if((fltIndexes!=null && fltIndexes!=''))
|
//items indexes
|
||||||
{
|
var indSplit = fltIndexes.split(this.separator);
|
||||||
var indSplit = fltIndexes.split(this.separator);//items indexes
|
//checked items loop
|
||||||
for(var u=0; u<indSplit.length; u++)
|
for(var u=0; u<indSplit.length; u++){
|
||||||
{//checked items loop
|
//checked item
|
||||||
var cChk = tf_Id(this.fltIds[colIndex]+'_'+indSplit[u]); //checked item
|
var cChk = tf_Id(this.fltIds[colIndex]+'_'+indSplit[u]);
|
||||||
if(cChk)
|
if(cChk){
|
||||||
{
|
|
||||||
cChk.checked = false;
|
cChk.checked = false;
|
||||||
tf_RemoveClass(
|
tf_RemoveClass(
|
||||||
n.childNodes[indSplit[u]],
|
n.childNodes[indSplit[u]],
|
||||||
|
@ -3592,62 +3667,74 @@ TF.prototype = {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
fltValue = (fltValue) ? fltValue : '';
|
fltValue = (fltValue) ? fltValue : '';
|
||||||
chkValue = (fltValue+' '+chkValue +' '+this.orOperator).tf_Trim();
|
chkValue = (fltValue+' '+chkValue+' '+this.orOperator)
|
||||||
|
.tf_Trim();
|
||||||
chkIndex = fltIndexes + chkIndex + this.separator;
|
chkIndex = fltIndexes + chkIndex + this.separator;
|
||||||
n.setAttribute('value', chkValue );
|
n.setAttribute('value', chkValue );
|
||||||
n.setAttribute('indexes', chkIndex);
|
n.setAttribute('indexes', chkIndex);
|
||||||
//1st option unchecked
|
//1st option unchecked
|
||||||
if(tf_Id(this.fltIds[colIndex]+'_0'))
|
if(tf_Id(this.fltIds[colIndex]+'_0')){
|
||||||
tf_Id(this.fltIds[colIndex]+'_0').checked = false;
|
tf_Id(this.fltIds[colIndex]+'_0').checked = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(li.nodeName.tf_LCase() == itemTag)
|
if(li.nodeName.tf_LCase() === itemTag){
|
||||||
{
|
|
||||||
tf_RemoveClass(n.childNodes[0],this.checkListSlcItemCssClass);
|
tf_RemoveClass(n.childNodes[0],this.checkListSlcItemCssClass);
|
||||||
tf_AddClass(li,this.checkListSlcItemCssClass);
|
tf_AddClass(li,this.checkListSlcItemCssClass);
|
||||||
}
|
}
|
||||||
} else { //removes values and indexes
|
} else { //removes values and indexes
|
||||||
if(chkValue!='')
|
if(chkValue!==''){
|
||||||
{
|
var replaceValue = new RegExp(
|
||||||
var replaceValue = new RegExp(tf_RegexpEscape(chkValue+' '+this.orOperator));
|
tf_RegexpEscape(chkValue+' '+this.orOperator));
|
||||||
fltValue = fltValue.replace(replaceValue,'');
|
fltValue = fltValue.replace(replaceValue,'');
|
||||||
n.setAttribute('value', fltValue.tf_Trim());
|
n.setAttribute('value', fltValue.tf_Trim());
|
||||||
|
|
||||||
var replaceIndex = new RegExp(tf_RegexpEscape(chkIndex + this.separator));
|
var replaceIndex = new RegExp(
|
||||||
|
tf_RegexpEscape(chkIndex + this.separator));
|
||||||
fltIndexes = fltIndexes.replace(replaceIndex,'');
|
fltIndexes = fltIndexes.replace(replaceIndex,'');
|
||||||
n.setAttribute('indexes', fltIndexes);
|
n.setAttribute('indexes', fltIndexes);
|
||||||
}
|
}
|
||||||
if(li.nodeName.tf_LCase() == itemTag)
|
if(li.nodeName.tf_LCase()===itemTag){
|
||||||
tf_RemoveClass(li,this.checkListSlcItemCssClass);
|
tf_RemoveClass(li,this.checkListSlcItemCssClass);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
SetResetBtn: function()
|
|
||||||
/*====================================================
|
/*====================================================
|
||||||
- Generates reset button
|
- Generates reset button
|
||||||
=====================================================*/
|
=====================================================*/
|
||||||
{
|
SetResetBtn: function(){
|
||||||
if(!this.hasGrid && !this.isFirstLoad) return;
|
if(!this.hasGrid && !this.isFirstLoad && this.btnResetEl){
|
||||||
if( this.btnResetEl!=null ) return;
|
return;
|
||||||
var f = this.fObj;
|
}
|
||||||
this.btnResetTgtId = f.btn_reset_target_id!=undefined //id of container element
|
|
||||||
? f.btn_reset_target_id : null;
|
|
||||||
this.btnResetEl = null; //reset button element
|
|
||||||
this.btnResetText = f.btn_reset_text!=undefined ? f.btn_reset_text : 'Reset'; //defines reset text
|
|
||||||
this.btnResetTooltip = f.btn_reset_tooltip!=undefined ? f.btn_reset_tooltip : 'Clear filters'; //defines reset button tooltip
|
|
||||||
this.btnResetHtml = f.btn_reset_html!=undefined ? f.btn_reset_html : (!this.enableIcons ? null : //defines reset button innerHtml
|
|
||||||
'<input type="button" value="" class="'+this.btnResetCssClass+'" title="'+this.btnResetTooltip+'" />');
|
|
||||||
|
|
||||||
var resetspan = tf_CreateElm('span',['id',this.prfxResetSpan+this.id]);
|
var f = this.fObj;
|
||||||
|
//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+'" />');
|
||||||
|
|
||||||
|
var resetspan = tf_CreateElm('span', ['id',this.prfxResetSpan+this.id]);
|
||||||
|
|
||||||
// reset button is added to defined element
|
// reset button is added to defined element
|
||||||
if(this.btnResetTgtId==null) this.SetTopDiv();
|
if(!this.btnResetTgtId){
|
||||||
var targetEl = ( this.btnResetTgtId==null ) ? this.rDiv : tf_Id( this.btnResetTgtId );
|
this.SetTopDiv();
|
||||||
|
}
|
||||||
|
var targetEl = !this.btnResetTgtId ? this.rDiv :
|
||||||
|
tf_Id( this.btnResetTgtId );
|
||||||
targetEl.appendChild(resetspan);
|
targetEl.appendChild(resetspan);
|
||||||
|
|
||||||
if(this.btnResetHtml==null)
|
if(!this.btnResetHtml){
|
||||||
{
|
var fltreset = tf_CreateElm('a', ['href', 'javascript:void(0);']);
|
||||||
var fltreset = tf_CreateElm( 'a', ['href','javascript:void(0);'] );
|
|
||||||
fltreset.className = this.btnResetCssClass;
|
fltreset.className = this.btnResetCssClass;
|
||||||
fltreset.appendChild(tf_CreateText(this.btnResetText));
|
fltreset.appendChild(tf_CreateText(this.btnResetText));
|
||||||
resetspan.appendChild(fltreset);
|
resetspan.appendChild(fltreset);
|
||||||
|
@ -3660,16 +3747,17 @@ TF.prototype = {
|
||||||
this.btnResetEl = tf_Id(this.prfxResetSpan+this.id).firstChild;
|
this.btnResetEl = tf_Id(this.prfxResetSpan+this.id).firstChild;
|
||||||
},
|
},
|
||||||
|
|
||||||
RemoveResetBtn: function()
|
|
||||||
/*====================================================
|
/*====================================================
|
||||||
- Removes reset button
|
- Removes reset button
|
||||||
=====================================================*/
|
=====================================================*/
|
||||||
{
|
RemoveResetBtn: function(){
|
||||||
if(!this.hasGrid) return;
|
if(!this.hasGrid || !this.btnResetEl){
|
||||||
if( this.btnResetEl==null ) return;
|
return;
|
||||||
|
}
|
||||||
var resetspan = tf_Id(this.prfxResetSpan+this.id);
|
var resetspan = tf_Id(this.prfxResetSpan+this.id);
|
||||||
if( resetspan!=null )
|
if(resetspan){
|
||||||
resetspan.parentNode.removeChild( resetspan );
|
resetspan.parentNode.removeChild( resetspan );
|
||||||
|
}
|
||||||
this.btnResetEl = null;
|
this.btnResetEl = null;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue