Created
February 25, 2012 00:11
-
-
Save hunterbridges/1904787 to your computer and use it in GitHub Desktop.
Command T style
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
filtered: function(q) { | |
q = q || this.query || ''; | |
if (q === '') return this; | |
var chars = q.toLowerCase().replace(/[^0-9a-z]/,'').split(''); | |
var searchFields = [ | |
'order_number', | |
'vendor_name', | |
'product_name', | |
'redemption_shipping_label_tracking_number' | |
]; | |
return _(this.filter(function (item) { | |
var include = false; | |
_(searchFields).each(function(f) { | |
var val = item.get(f) + ''; | |
val = val.toLowerCase().replace(/[^0-9a-z]/,''); | |
if (!val) return; | |
var index = 0; | |
_(chars).each(function (c) { | |
if (index < 0) return; | |
index = val.indexOf(c, index); | |
}); | |
if (index > -1) include = true; | |
}); | |
return include; | |
})); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment