1
0
Fork 0
mirror of https://github.com/koalyptus/TableFilter.git synced 2024-05-11 10:57:04 +02:00

Continued refactoring

This commit is contained in:
Max Guglielmi 2014-10-18 23:00:34 +11:00
parent a0639cfe1d
commit 9663088ff2
11 changed files with 663 additions and 8013 deletions

View file

@ -15,7 +15,8 @@ module.exports = function (grunt) {
'<%= source_folder %>event.js', '<%= source_folder %>event.js',
'<%= source_folder %>types.js', '<%= source_folder %>types.js',
'<%= source_folder %>cookie.js', '<%= source_folder %>cookie.js',
'<%= source_folder %>tablefilter_all.js' '<%= source_folder %>array.js',
'<%= source_folder %>core.js'
] ]
}, },

2
dist/filtergrid.css vendored
View file

@ -1,6 +1,6 @@
/*------------------------------------------------------------------------ /*------------------------------------------------------------------------
- TableFilter stylesheet by Max Guglielmi - 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 - Edit below for your projects' needs
------------------------------------------------------------------------*/ ------------------------------------------------------------------------*/

7383
dist/tablefilter_all.js vendored

File diff suppressed because one or more lines are too long

31
src/array.js Normal file
View 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);

View file

@ -58,4 +58,4 @@
return val[index]; return val[index];
}; };
})(this, this.TF || {}); })(this, this.TF);

File diff suppressed because it is too large Load diff

View file

@ -106,9 +106,49 @@
ele.className = ele.className.replace(reg, ''); 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 // HTML5 classList API
function supportsClassList(){ function supportsClassList(){
return document.documentElement.classList; return document.documentElement.classList;
} }
})(this, this.TF || {}); })(this, this.TF);

View file

@ -53,4 +53,4 @@
} }
}; };
})(this, this.TF || {}); })(this, this.TF);

View file

@ -68,13 +68,16 @@
<script type="text/javascript" src="../dist/tablefilter_all.js"></script> <script type="text/javascript" src="../dist/tablefilter_all.js"></script>
<script> <script>
var tf = setFilterGrid("demo", { var tf = setFilterGrid("demo", {
col_0: 'select',
col_3: 'checklist',
base_path: './', base_path: './',
enable_default_theme: true, enable_default_theme: true,
paging: false, paging: false,
alternate_rows: true, alternate_rows: true,
highlight_keywords: true, highlight_keywords: true,
match_case: false, match_case: false,
remember_grid_values: true remember_grid_values: true,
btn_reset: true
}); });
</script> </script>
</body> </body>

View file

@ -16,7 +16,10 @@
}; };
TF.Str.trim = function(text){ 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){ TF.Str.isEmpty = function(text){
@ -43,4 +46,4 @@
return text; return text;
}; };
})(this, this.TF || {}); })(this, this.TF);

View file

@ -44,4 +44,4 @@
return (obj && obj.constructor == Array); return (obj && obj.constructor == Array);
}; };
})(this, this.TF || {}); })(this, this.TF);