mirror of
https://github.com/koalyptus/TableFilter.git
synced 2024-05-09 18:06:53 +02:00
Continued refactoring
This commit is contained in:
parent
a0639cfe1d
commit
9663088ff2
|
@ -15,7 +15,8 @@ module.exports = function (grunt) {
|
|||
'<%= source_folder %>event.js',
|
||||
'<%= source_folder %>types.js',
|
||||
'<%= source_folder %>cookie.js',
|
||||
'<%= source_folder %>tablefilter_all.js'
|
||||
'<%= source_folder %>array.js',
|
||||
'<%= source_folder %>core.js'
|
||||
]
|
||||
},
|
||||
|
||||
|
|
2
dist/filtergrid.css
vendored
2
dist/filtergrid.css
vendored
|
@ -1,6 +1,6 @@
|
|||
/*------------------------------------------------------------------------
|
||||
- TableFilter stylesheet by Max Guglielmi
|
||||
- (build date: Sun Oct 12 2014 22:35:16)
|
||||
- (build date: Sat Oct 18 2014 22:43:34)
|
||||
- Edit below for your projects' needs
|
||||
------------------------------------------------------------------------*/
|
||||
|
||||
|
|
7383
dist/tablefilter_all.js
vendored
7383
dist/tablefilter_all.js
vendored
File diff suppressed because one or more lines are too long
31
src/array.js
Normal file
31
src/array.js
Normal file
|
@ -0,0 +1,31 @@
|
|||
/**
|
||||
* Array utilities
|
||||
*/
|
||||
|
||||
(function(global, TF){
|
||||
'use strict';
|
||||
|
||||
var str = TF.Str;
|
||||
|
||||
TF.Array = {
|
||||
has: function(arr, val, caseSensitive){
|
||||
var sCase = caseSensitive===undefined ? false : caseSensitive;
|
||||
for (var i=0; i<arr.length; i++){
|
||||
if(str.matchCase(arr[i].toString(), sCase) === val){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
indexByValue: function(arr, val, caseSensitive){
|
||||
var sCase = caseSensitive===undefined ? false : caseSensitive;
|
||||
for (var i=0; i<arr.length; i++){
|
||||
if(str.matchCase(arr[i].toString(), sCase) === val){
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
};
|
||||
|
||||
})(this, this.TF);
|
|
@ -58,4 +58,4 @@
|
|||
return val[index];
|
||||
};
|
||||
|
||||
})(this, this.TF || {});
|
||||
})(this, this.TF);
|
File diff suppressed because it is too large
Load diff
42
src/dom.js
42
src/dom.js
|
@ -106,9 +106,49 @@
|
|||
ele.className = ele.className.replace(reg, '');
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates and returns an option element
|
||||
* @param {String} text option text
|
||||
* @param {String} value option value
|
||||
* @param {Boolean} isSel whether option is selected
|
||||
* @return {Object} option element
|
||||
*/
|
||||
TF.Dom.createOpt = function(text, value, isSel){
|
||||
var isSelected = isSel ? true : false,
|
||||
opt = isSelected ?
|
||||
this.create('option', ['value',value], ['selected','true']) :
|
||||
this.create('option', ['value',value]);
|
||||
opt.appendChild(this.text(text));
|
||||
return opt;
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates and returns a checklist item
|
||||
* @param {Number} chkIndex index of check item
|
||||
* @param {String} chkValue check item value
|
||||
* @param {String} labelText check item label text
|
||||
* @return {Object} li DOM element
|
||||
*/
|
||||
TF.Dom.createCheckItem = function(chkIndex, chkValue, labelText){
|
||||
var li = this.create('li'),
|
||||
label = this.create('label', ['for', chkIndex]),
|
||||
check = this.create('input',
|
||||
['id', chkIndex],
|
||||
['name', chkIndex],
|
||||
['type', 'checkbox'],
|
||||
['value', chkValue]
|
||||
);
|
||||
label.appendChild(check);
|
||||
label.appendChild(this.text(labelText));
|
||||
li.appendChild(label);
|
||||
li.label = label;
|
||||
li.check = check;
|
||||
return li;
|
||||
};
|
||||
|
||||
// HTML5 classList API
|
||||
function supportsClassList(){
|
||||
return document.documentElement.classList;
|
||||
}
|
||||
|
||||
})(this, this.TF || {});
|
||||
})(this, this.TF);
|
||||
|
|
|
@ -53,4 +53,4 @@
|
|||
}
|
||||
};
|
||||
|
||||
})(this, this.TF || {});
|
||||
})(this, this.TF);
|
|
@ -68,13 +68,16 @@
|
|||
<script type="text/javascript" src="../dist/tablefilter_all.js"></script>
|
||||
<script>
|
||||
var tf = setFilterGrid("demo", {
|
||||
col_0: 'select',
|
||||
col_3: 'checklist',
|
||||
base_path: './',
|
||||
enable_default_theme: true,
|
||||
paging: false,
|
||||
alternate_rows: true,
|
||||
highlight_keywords: true,
|
||||
match_case: false,
|
||||
remember_grid_values: true
|
||||
remember_grid_values: true,
|
||||
btn_reset: true
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
|
|
@ -16,7 +16,10 @@
|
|||
};
|
||||
|
||||
TF.Str.trim = function(text){
|
||||
return text.replace(/(^[\s\xA0]*)|([\s\xA0]*$)/g,'');
|
||||
if (text.trim){
|
||||
return text.trim();
|
||||
}
|
||||
return text.replace(/^\s*|\s*$/g, '');
|
||||
};
|
||||
|
||||
TF.Str.isEmpty = function(text){
|
||||
|
@ -43,4 +46,4 @@
|
|||
return text;
|
||||
};
|
||||
|
||||
})(this, this.TF || {});
|
||||
})(this, this.TF);
|
|
@ -44,4 +44,4 @@
|
|||
return (obj && obj.constructor == Array);
|
||||
};
|
||||
|
||||
})(this, this.TF || {});
|
||||
})(this, this.TF);
|
Loading…
Reference in a new issue