Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bootstrap-list-filter

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bootstrap-list-filter - npm Package Compare versions

Comparing version 0.1.7 to 0.2.1

6

bootstrap-list-filter.min.js
/*
* bootstrap-list-filter v0.1.7 - 2014-11-18
* bootstrap-list-filter v0.2.1 - 2015-07-24
*
* Copyright 2014 Stefano Cudini
* Copyright 2015 Stefano Cudini
* stefano.cudini@gmail.com

@@ -17,2 +17,2 @@ * http://labs.easyblog.it/

*/
!function(a){a.fn.btsListFilter=function(b,c){function d(a,b){return a.replace(/\{ *([\w_]+) *\}/g,function(a,c){return b[c]||""})}function e(a,b){var c;return b=b||300,function(){var d=this,e=arguments;clearTimeout(c),c=setTimeout(function(){a.apply(d,Array.prototype.slice.call(e))},b)}}var f,g=this,h=a(this),i=a(b),j=h;return c=a.extend({delay:300,minLength:1,initial:!0,eventKey:"keyup",resetOnBlur:!0,sourceData:null,sourceTmpl:'<a class="list-group-item" href="#"><span>{title}</span></a>',sourceNode:function(a){return d(c.sourceTmpl,a)},emptyNode:function(){return'<a class="list-group-item well" href="#"><span>No Results</span></a>'},itemEl:".list-group-item",itemChild:null,itemFilter:function(b,d){d=d&&d.replace(new RegExp("[({[^.$*+?\\]})]","g"),"");var e=a(b).text(),f=c.initial?"^":"",g=new RegExp(f+d,"i");return g.test(e)}},c),i.on(c.eventKey,e(function(){var b=a(this).val();c.itemEl&&(j=h.find(c.itemEl)),c.itemChild&&(j=j.find(c.itemChild));var d=j.filter(function(){return c.itemFilter.call(g,this,b)}),e=j.not(d);c.itemChild&&(d=d.parents(c.itemEl),e=e.parents(c.itemEl).hide()),""!==b&&b.length>=c.minLength?(d.show(),e.hide(),"function"===a.type(c.sourceData)&&(d.hide(),e.hide(),f&&(a.isFunction(f.abort)?f.abort():a.isFunction(f.stop)&&f.stop()),f=c.sourceData.call(g,b,function(b){if(f=null,d.hide(),e.hide(),h.find(".bts-dynamic-item").remove(),b&&0!==b.length)for(var i in b)a(c.sourceNode.call(g,b[i])).addClass("bts-dynamic-item").appendTo(h);else a(c.emptyNode.call(g)).addClass("bts-dynamic-item").appendTo(h)}))):(d.show(),e.show(),h.find(".bts-dynamic-item").remove())},c.delay)),c.resetOnBlur&&i.on("blur",function(){a(this).val("").trigger(c.eventKey)}),h}}(jQuery);
!function(a){a.fn.btsListFilter=function(b,c){"use strict";function d(a,b){return a.replace(/\{ *([\w_]+) *\}/g,function(a,c){return b[c]||""})}function e(a,b){var c;return b=b||300,function(){var d=this,e=arguments;clearTimeout(c),c=setTimeout(function(){a.apply(d,Array.prototype.slice.call(e))},b)}}var f,g=this,h=a(this),i=a(b),j=h;return c=a.extend({delay:300,minLength:1,initial:!0,casesensitive:!1,eventKey:"keyup",resetOnBlur:!0,sourceData:null,sourceTmpl:'<a class="list-group-item" href="#"><span>{title}</span></a>',sourceNode:function(a){return d(c.sourceTmpl,a)},emptyNode:function(a){return'<a class="list-group-item well" href="#"><span>No Results</span></a>'},itemClassTmp:"bts-dynamic-item",itemEl:".list-group-item",itemChild:null,itemFilter:function(b,d){d=d&&d.replace(new RegExp("[({[^.$*+?\\]})]","g"),"");var e=a(b).text(),f=c.initial?"^":"",g=new RegExp(f+d,c.casesensitive?"":"i");return g.test(e)}},c),i.on(c.eventKey,e(function(b){var d=a(this).val();c.itemEl&&(j=h.find(c.itemEl)),c.itemChild&&(j=j.find(c.itemChild));var e=j.filter(function(){return c.itemFilter.call(g,this,d)}),i=j.not(e);c.itemChild&&(e=e.parents(c.itemEl),i=i.parents(c.itemEl).hide()),""!==d&&d.length>=c.minLength?(e.show(),i.hide(),"function"===a.type(c.sourceData)?(e.hide(),i.hide(),f&&(a.isFunction(f.abort)?f.abort():a.isFunction(f.stop)&&f.stop()),f=c.sourceData.call(g,d,function(b){if(f=null,e.hide(),i.hide(),h.find("."+c.itemClassTmp).remove(),b&&0!==b.length)for(var d in b)a(c.sourceNode.call(g,b[d])).addClass(c.itemClassTmp).appendTo(h);else a(c.emptyNode.call(g)).addClass(c.itemClassTmp).appendTo(h)})):(h.find("."+c.itemClassTmp).remove(),0===e.length&&a(c.emptyNode.call(g)).addClass(c.itemClassTmp).appendTo(h))):(e.show(),i.show(),h.find("."+c.itemClassTmp).remove())},c.delay)),c.resetOnBlur&&i.on("blur",function(b){a(this).val("").trigger(c.eventKey)}),h}}(jQuery);
(function($) {
$.fn.btsListFilter = function(inputEl, options) {
$.fn.btsListFilter = function(inputEl, opts) {
'use strict';

@@ -30,6 +32,7 @@ var searchlist = this,

options = $.extend({
opts = $.extend({
delay: 300,
minLength: 1,
initial: true,
casesensitive: false,
eventKey: 'keyup',

@@ -40,3 +43,3 @@ resetOnBlur: true,

sourceNode: function(data) {
return tmpl(options.sourceTmpl, data);
return tmpl(opts.sourceTmpl, data);
},

@@ -46,4 +49,5 @@ emptyNode: function(data) {

},
itemClassTmp: 'bts-dynamic-item',
itemEl: '.list-group-item',
itemChild: null,
itemChild: null,
itemFilter: function(item, val) {

@@ -55,31 +59,31 @@ //val = val.replace(new RegExp("^[.]$|[\[\]|()*]",'g'),'');

var text = $(item).text(),
i = options.initial ? '^' : '',
regSearch = new RegExp(i + val,'i');
i = opts.initial?'^':'',
regSearch = new RegExp(i + val, opts.casesensitive?'':'i');
return regSearch.test( text );
}
}, options);
}, opts);
inputEl$.on(options.eventKey, debouncer(function(e) {
inputEl$.on(opts.eventKey, debouncer(function(e) {
var val = $(this).val();
if(options.itemEl)
items$ = searchlist$.find(options.itemEl);
if(opts.itemEl)
items$ = searchlist$.find(opts.itemEl);
if(options.itemChild)
items$ = items$.find(options.itemChild);
if(opts.itemChild)
items$ = items$.find(opts.itemChild);
var contains = items$.filter(function(){
return options.itemFilter.call(searchlist, this, val);
return opts.itemFilter.call(searchlist, this, val);
}),
containsNot = items$.not(contains);
if (options.itemChild){
contains = contains.parents(options.itemEl);
containsNot = containsNot.parents(options.itemEl).hide();
if (opts.itemChild){
contains = contains.parents(opts.itemEl);
containsNot = containsNot.parents(opts.itemEl).hide();
}
if(val!=='' && val.length >= options.minLength)
if(val!=='' && val.length >= opts.minLength)
{

@@ -89,3 +93,3 @@ contains.show();

if($.type(options.sourceData)==='function')
if($.type(opts.sourceData)==='function')
{

@@ -103,14 +107,21 @@ contains.hide();

callReq = options.sourceData.call(searchlist, val, function(data) {
callReq = opts.sourceData.call(searchlist, val, function(data) {
callReq = null;
contains.hide();
containsNot.hide();
searchlist$.find('.bts-dynamic-item').remove();
searchlist$.find('.'+opts.itemClassTmp).remove();
if(!data || data.length===0)
$( options.emptyNode.call(searchlist) ).addClass('bts-dynamic-item').appendTo(searchlist$);
$( opts.emptyNode.call(searchlist) ).addClass(opts.itemClassTmp).appendTo(searchlist$);
else
for(var i in data)
$( options.sourceNode.call(searchlist, data[i]) ).addClass('bts-dynamic-item').appendTo(searchlist$);
$( opts.sourceNode.call(searchlist, data[i]) ).addClass(opts.itemClassTmp).appendTo(searchlist$);
});
}
else {
searchlist$.find('.'+opts.itemClassTmp).remove();
if(contains.length===0)
$( opts.emptyNode.call(searchlist) ).addClass(opts.itemClassTmp).appendTo(searchlist$);
}

@@ -123,9 +134,9 @@

containsNot.show();
searchlist$.find('.bts-dynamic-item').remove();
searchlist$.find('.'+opts.itemClassTmp).remove();
}
}, options.delay));
}, opts.delay));
if(options.resetOnBlur)
if(opts.resetOnBlur)
inputEl$.on('blur', function(e) {
$(this).val('').trigger(options.eventKey);
$(this).val('').trigger(opts.eventKey);
});

@@ -132,0 +143,0 @@

{
"name": "bootstrap-list-filter",
"version": "0.1.7",
"version": "0.2.1",
"main": "bootstrap-list-filter.min.js",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/stefanocudini/bootstrap-list-filter",

Package.describe({
version: "0.2.1",
name: "bootstrap-list-filter",
summary: "bootstrap-list-filter"

@@ -3,0 +5,0 @@ });

{
"name": "bootstrap-list-filter",
"version": "0.1.7",
"version": "0.2.1",
"description": "Search widget to filter Bootstrap lists",
"main": "bootstrap-list-filter.src.js",
"repository": {

@@ -19,4 +20,3 @@ "type": "git",

"jquery",
"list",
"filter"
"javascript"
],

@@ -26,2 +26,5 @@ "dependencies": {

},
"peerDependencies": {
"bootstrap": "^3.4.5"
},
"devDependencies": {

@@ -28,0 +31,0 @@ "grunt": "^0.4.5",

@@ -20,2 +20,3 @@ Bootstrap List Filter

* filter by sub elements
* search text in case sensitive

@@ -53,1 +54,16 @@ **Demo online:**

```
#Options
* delay *millisecond before apply filter*
* minLength *min string lentgh searched*
* initial *search only initial text (default: true)*
* eventKey *event digit (default: 'keyup')*
* resetOnBlur *auto reset selection*
* sourceData *function generate data source(receive: text, callback)*
* sourceTmpl *html template contains {title} placeholder*
* sourceNode *function builder DOM html fragment (default: sourceTmpl)*
* emptyNode *function builder for empty result*
* itemEl *item selector (default: .list-group-item)*,
* itemChild *sub item selector (default: .list-group-item)*,
* itemFilter *function for filter results(receive: text, item)*

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc