New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

fastsearch

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fastsearch - npm Package Compare versions

Comparing version 1.9.1 to 1.10.0

2

bower.json
{
"name": "fastsearch",
"version": "1.9.1",
"version": "1.10.0",
"homepage": "https://github.com/dbrekalo/fastsearch",

@@ -5,0 +5,0 @@ "authors": [

@@ -285,2 +285,6 @@ (function(factory) {

if (this.options.focusFirstItem && this.$resultItems.length) {
this.navigateItem('down');
}
this.resultsOpened = true;

@@ -505,2 +509,3 @@

mouseEvents: !('ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0), // detect if client is touch enabled so plugin can decide if mouse specific events should be set.
focusFirstItem: false,

@@ -507,0 +512,0 @@ responseFormat: { // Adjust where plugin looks for data in your JSON server response

@@ -1,1 +0,1 @@

!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof module&&module.exports?module.exports=a(require("jquery")):a(jQuery)}(function(a){function b(){this.init.apply(this,arguments)}var c=a(window.document),d=0,e={13:"enter",27:"escape",40:"downArrow",38:"upArrow"};return a.extend(b.prototype,{init:function(c,e){e=this.options=a.extend(!0,{},b.defaults,e),this.$input=a(c),this.$el=e.wrapSelector instanceof a?e.wrapSelector:this.$input.closest(e.wrapSelector),b.pickTo(e,this.$el.data(),["url","onItemSelect","noResultsText","inputIdName","apiInputName"]),e.url=e.url||this.$el.attr("action"),this.ens=".fastsearch"+ ++d,this.itemSelector=b.selectorFromClass(e.itemClass),this.focusedItemSelector=b.selectorFromClass(e.focusedItemClass),this.events()},namespaceEvents:function(a){var b=this.ens;return a.replace(/\w\b/g,function(a){return a+b})},events:function(){var b=this,c=this.options;this.$input.on(this.namespaceEvents("keyup focus click"),function(a){"enter"!==e[a.keyCode]&&b.handleTyping()}).on(this.namespaceEvents("keydown"),function(a){if("enter"===e[a.keyCode]&&c.preventSubmit&&a.preventDefault(),b.hasResults&&b.resultsOpened)switch(e[a.keyCode]){case"downArrow":a.preventDefault(),b.navigateItem("down");break;case"upArrow":a.preventDefault(),b.navigateItem("up");break;case"enter":b.onEnter(a)}}),this.$el.on(this.namespaceEvents("click"),this.itemSelector,function(c){c.preventDefault(),b.handleItemSelect(a(this))}),c.mouseEvents&&this.$el.on(this.namespaceEvents("mouseleave"),this.itemSelector,function(){a(this).removeClass(c.focusedItemClass)}).on(this.namespaceEvents("mouseenter"),this.itemSelector,function(){b.$resultItems.removeClass(c.focusedItemClass),a(this).addClass(c.focusedItemClass)})},handleTyping:function(){var b=a.trim(this.$input.val()),c=this;b.length<this.options.minQueryLength?this.hideResults():b===this.query?this.showResults():(clearTimeout(this.keyupTimeout),this.keyupTimeout=setTimeout(function(){c.$el.addClass(c.options.loadingClass),c.query=b,c.getResults(function(a){c.showResults(c.storeResponse(a).generateResults(a))})},this.options.typeTimeout))},getResults:function(b){var c=this,d=this.options,e=this.$el.find("input, textarea, select").serializeArray();d.apiInputName&&e.push({name:d.apiInputName,value:this.$input.val()}),a.get(d.url,e,function(a){b(d.parseResponse?d.parseResponse.call(c,a,c):a)})},storeResponse:function(a){return this.responseData=a,this.hasResults=0!==a.length,this},generateResults:function(b){var c=a("<div>"),d=this.options;return d.template?a(d.template(b,this)):(0===b.length?c.html('<p class="'+d.noResultsClass+'">'+("function"==typeof d.noResultsText?d.noResultsText.call(this):d.noResultsText)+"</p>"):"html"===this.options.responseType?c.html(b):this["generate"+(b[0][d.responseFormat.groupItems]?"GroupedResults":"SimpleResults")](b,c),c.children())},generateSimpleResults:function(b,c){var d=this;this.itemModels=b,a.each(b,function(a,b){c.append(d.generateItem(b))})},generateGroupedResults:function(b,c){var d=this,e=this.options,f=e.responseFormat;this.itemModels=[],a.each(b,function(b,g){var h=a('<div class="'+e.groupClass+'">').appendTo(c);g[f.groupCaption]&&h.append('<h3 class="'+e.groupTitleClass+'">'+g[f.groupCaption]+"</h3>"),a.each(g.items,function(a,b){d.itemModels.push(b),h.append(d.generateItem(b))}),e.onGroupCreate&&e.onGroupCreate.call(d,h,g,d)})},generateItem:function(b){var c=this.options,d=c.responseFormat,e=b[d.url],f=b[d.html]||b[d.label],g=a("<"+(e?"a":"span")+">").html(f).addClass(c.itemClass);return e&&g.attr("href",e),c.onItemCreate&&c.onItemCreate.call(this,g,b,this),g},showResults:function(b){(b||!this.resultsOpened)&&(this.$el.removeClass(this.options.loadingClass).addClass(this.options.resultsOpenedClass),this.$resultsCont=this.$resultsCont||a("<div>").addClass(this.options.resultsContClass).appendTo(this.$el),b&&(this.$resultsCont.html(b),this.$resultItems=this.$resultsCont.find(this.itemSelector),this.options.onResultsCreate&&this.options.onResultsCreate.call(this,this.$resultsCont,this.responseData,this)),this.resultsOpened||(this.documentCancelEvents("on"),this.$input.trigger("openingResults")),this.resultsOpened=!0)},documentCancelEvents:function(b,d){var f=this;return"off"===b&&this.closeEventsSetuped?(c.off(this.ens),void(this.closeEventsSetuped=!1)):void("on"!==b||this.closeEventsSetuped||(c.on(this.namespaceEvents("click keyup"),function(b){("escape"===e[b.keyCode]||!a(b.target).is(f.$el)&&!a.contains(f.$el.get(0),b.target)&&a.contains(document.documentElement,b.target))&&(d?d.call(f):f.hideResults())}),this.closeEventsSetuped=!0))},navigateItem:function(a){var b=this.$resultItems.filter(this.focusedItemSelector),c=this.$resultItems.length-1;if(0===b.length)return void this.$resultItems.eq("up"===a?c:0).addClass(this.options.focusedItemClass);var d=this.$resultItems.index(b),e="up"===a?d-1:d+1;e>c&&(e=0),0>e&&(e=c),b.removeClass(this.options.focusedItemClass),this.$resultItems.eq(e).addClass(this.options.focusedItemClass)},navigateDown:function(){this.navigateItem("down")},navigateUp:function(){this.navigateItem("up")},onEnter:function(a){var b=this.$resultItems.filter(this.focusedItemSelector);b.length&&(a.preventDefault(),this.handleItemSelect(b))},handleItemSelect:function(a){var b=this.options.onItemSelect,c=this.itemModels.length?this.itemModels[this.$resultItems.index(a)]:{};this.$input.trigger("itemSelected"),"fillInput"===b?this.fillInput(c):"follow"===b?window.location.href=a.attr("href"):"function"==typeof b&&b.call(this,a,c,this)},fillInput:function(b){var c=this.options,d=c.responseFormat;if(this.query=b[d.label],this.$input.val(b[d.label]).trigger("change"),c.fillInputId&&b.id){if(!this.$inputId){var e=c.inputIdName||this.$input.attr("name")+"_id";this.$inputId=this.$el.find('input[name="'+e+'"]'),this.$inputId.length||(this.$inputId=a('<input type="hidden" name="'+e+'" />').appendTo(this.$el))}this.$inputId.val(b.id).trigger("change")}this.hideResults()},hideResults:function(){return this.resultsOpened&&(this.resultsOpened=!1,this.$el.removeClass(this.options.resultsOpenedClass),this.$input.trigger("closingResults"),this.documentCancelEvents("off")),this},clear:function(){return this.hideResults(),this.$input.val("").trigger("change"),this},destroy:function(){c.off(this.ens),this.$input.off(this.ens),this.$el.off(this.ens).removeClass(this.options.resultsOpenedClass).removeClass(this.options.loadingClass),this.$resultsCont&&(this.$resultsCont.remove(),delete this.$resultsCont),delete this.$el.data().fastsearch}}),a.extend(b,{pickTo:function(b,c,d){return a.each(d,function(a,d){b[d]=c&&c[d]||b[d]}),b},selectorFromClass:function(a){return"."+a.replace(/\s/g,".")}}),b.defaults={wrapSelector:"form",url:null,responseType:"JSON",preventSubmit:!1,resultsContClass:"fs_results",resultsOpenedClass:"fsr_opened",groupClass:"fs_group",itemClass:"fs_result_item",groupTitleClass:"fs_group_title",loadingClass:"loading",noResultsClass:"fs_no_results",focusedItemClass:"focused",typeTimeout:140,minQueryLength:2,template:null,mouseEvents:!("ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0),responseFormat:{url:"url",html:"html",label:"label",groupCaption:"caption",groupItems:"items"},fillInputId:!0,inputIdName:null,apiInputName:null,noResultsText:"No results found",onItemSelect:"follow",parseResponse:null,onResultsCreate:null,onGroupCreate:null,onItemCreate:null},a.fastsearch=b,a.fn.fastsearch=function(c){return this.each(function(){a.data(this,"fastsearch")||a.data(this,"fastsearch",new b(this,c))})},a});
!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof module&&module.exports?module.exports=a(require("jquery")):a(jQuery)}(function(a){function b(a,b){this.init.apply(this,arguments)}var c=a(window.document),d=0,e={13:"enter",27:"escape",40:"downArrow",38:"upArrow"};return a.extend(b.prototype,{init:function(c,e){e=this.options=a.extend(!0,{},b.defaults,e),this.$input=a(c),this.$el=e.wrapSelector instanceof a?e.wrapSelector:this.$input.closest(e.wrapSelector),b.pickTo(e,this.$el.data(),["url","onItemSelect","noResultsText","inputIdName","apiInputName"]),e.url=e.url||this.$el.attr("action"),this.ens=".fastsearch"+ ++d,this.itemSelector=b.selectorFromClass(e.itemClass),this.focusedItemSelector=b.selectorFromClass(e.focusedItemClass),this.events()},namespaceEvents:function(a){var b=this.ens;return a.replace(/\w\b/g,function(a){return a+b})},events:function(){var b=this,c=this.options;this.$input.on(this.namespaceEvents("keyup focus click"),function(a){"enter"!==e[a.keyCode]&&b.handleTyping()}).on(this.namespaceEvents("keydown"),function(a){if("enter"===e[a.keyCode]&&c.preventSubmit&&a.preventDefault(),b.hasResults&&b.resultsOpened)switch(e[a.keyCode]){case"downArrow":a.preventDefault(),b.navigateItem("down");break;case"upArrow":a.preventDefault(),b.navigateItem("up");break;case"enter":b.onEnter(a)}}),this.$el.on(this.namespaceEvents("click"),this.itemSelector,function(c){c.preventDefault(),b.handleItemSelect(a(this))}),c.mouseEvents&&this.$el.on(this.namespaceEvents("mouseleave"),this.itemSelector,function(b){a(this).removeClass(c.focusedItemClass)}).on(this.namespaceEvents("mouseenter"),this.itemSelector,function(d){b.$resultItems.removeClass(c.focusedItemClass),a(this).addClass(c.focusedItemClass)})},handleTyping:function(){var b=a.trim(this.$input.val()),c=this;b.length<this.options.minQueryLength?this.hideResults():b===this.query?this.showResults():(clearTimeout(this.keyupTimeout),this.keyupTimeout=setTimeout(function(){c.$el.addClass(c.options.loadingClass),c.query=b,c.getResults(function(a){c.showResults(c.storeResponse(a).generateResults(a))})},this.options.typeTimeout))},getResults:function(b){var c=this,d=this.options,e=this.$el.find("input, textarea, select").serializeArray();d.apiInputName&&e.push({name:d.apiInputName,value:this.$input.val()}),a.get(d.url,e,function(a){b(d.parseResponse?d.parseResponse.call(c,a,c):a)})},storeResponse:function(a){return this.responseData=a,this.hasResults=0!==a.length,this},generateResults:function(b){var c=a("<div>"),d=this.options;return d.template?a(d.template(b,this)):(0===b.length?c.html('<p class="'+d.noResultsClass+'">'+("function"==typeof d.noResultsText?d.noResultsText.call(this):d.noResultsText)+"</p>"):"html"===this.options.responseType?c.html(b):this["generate"+(b[0][d.responseFormat.groupItems]?"GroupedResults":"SimpleResults")](b,c),c.children())},generateSimpleResults:function(b,c){var d=this;this.itemModels=b,a.each(b,function(a,b){c.append(d.generateItem(b))})},generateGroupedResults:function(b,c){var d=this,e=this.options,f=e.responseFormat;this.itemModels=[],a.each(b,function(b,g){var h=a('<div class="'+e.groupClass+'">').appendTo(c);g[f.groupCaption]&&h.append('<h3 class="'+e.groupTitleClass+'">'+g[f.groupCaption]+"</h3>"),a.each(g.items,function(a,b){d.itemModels.push(b),h.append(d.generateItem(b))}),e.onGroupCreate&&e.onGroupCreate.call(d,h,g,d)})},generateItem:function(b){var c=this.options,d=c.responseFormat,e=b[d.url],f=b[d.html]||b[d.label],g=a("<"+(e?"a":"span")+">").html(f).addClass(c.itemClass);return e&&g.attr("href",e),c.onItemCreate&&c.onItemCreate.call(this,g,b,this),g},showResults:function(b){!b&&this.resultsOpened||(this.$el.removeClass(this.options.loadingClass).addClass(this.options.resultsOpenedClass),this.$resultsCont=this.$resultsCont||a("<div>").addClass(this.options.resultsContClass).appendTo(this.$el),b&&(this.$resultsCont.html(b),this.$resultItems=this.$resultsCont.find(this.itemSelector),this.options.onResultsCreate&&this.options.onResultsCreate.call(this,this.$resultsCont,this.responseData,this)),this.resultsOpened||(this.documentCancelEvents("on"),this.$input.trigger("openingResults")),this.options.focusFirstItem&&this.$resultItems.length&&this.navigateItem("down"),this.resultsOpened=!0)},documentCancelEvents:function(b,d){var f=this;return"off"===b&&this.closeEventsSetuped?(c.off(this.ens),void(this.closeEventsSetuped=!1)):void("on"!==b||this.closeEventsSetuped||(c.on(this.namespaceEvents("click keyup"),function(b){("escape"===e[b.keyCode]||!a(b.target).is(f.$el)&&!a.contains(f.$el.get(0),b.target)&&a.contains(document.documentElement,b.target))&&(d?d.call(f):f.hideResults())}),this.closeEventsSetuped=!0))},navigateItem:function(a){var b=this.$resultItems.filter(this.focusedItemSelector),c=this.$resultItems.length-1;if(0===b.length)return void this.$resultItems.eq("up"===a?c:0).addClass(this.options.focusedItemClass);var d=this.$resultItems.index(b),e="up"===a?d-1:d+1;e>c&&(e=0),e<0&&(e=c),b.removeClass(this.options.focusedItemClass),this.$resultItems.eq(e).addClass(this.options.focusedItemClass)},navigateDown:function(){this.navigateItem("down")},navigateUp:function(){this.navigateItem("up")},onEnter:function(a){var b=this.$resultItems.filter(this.focusedItemSelector);b.length&&(a.preventDefault(),this.handleItemSelect(b))},handleItemSelect:function(a){var b=this.options.onItemSelect,c=this.itemModels.length?this.itemModels[this.$resultItems.index(a)]:{};this.$input.trigger("itemSelected"),"fillInput"===b?this.fillInput(c):"follow"===b?window.location.href=a.attr("href"):"function"==typeof b&&b.call(this,a,c,this)},fillInput:function(b){var c=this.options,d=c.responseFormat;if(this.query=b[d.label],this.$input.val(b[d.label]).trigger("change"),c.fillInputId&&b.id){if(!this.$inputId){var e=c.inputIdName||this.$input.attr("name")+"_id";this.$inputId=this.$el.find('input[name="'+e+'"]'),this.$inputId.length||(this.$inputId=a('<input type="hidden" name="'+e+'" />').appendTo(this.$el))}this.$inputId.val(b.id).trigger("change")}this.hideResults()},hideResults:function(){return this.resultsOpened&&(this.resultsOpened=!1,this.$el.removeClass(this.options.resultsOpenedClass),this.$input.trigger("closingResults"),this.documentCancelEvents("off")),this},clear:function(){return this.hideResults(),this.$input.val("").trigger("change"),this},destroy:function(){c.off(this.ens),this.$input.off(this.ens),this.$el.off(this.ens).removeClass(this.options.resultsOpenedClass).removeClass(this.options.loadingClass),this.$resultsCont&&(this.$resultsCont.remove(),delete this.$resultsCont),delete this.$el.data().fastsearch}}),a.extend(b,{pickTo:function(b,c,d){return a.each(d,function(a,d){b[d]=c&&c[d]||b[d]}),b},selectorFromClass:function(a){return"."+a.replace(/\s/g,".")}}),b.defaults={wrapSelector:"form",url:null,responseType:"JSON",preventSubmit:!1,resultsContClass:"fs_results",resultsOpenedClass:"fsr_opened",groupClass:"fs_group",itemClass:"fs_result_item",groupTitleClass:"fs_group_title",loadingClass:"loading",noResultsClass:"fs_no_results",focusedItemClass:"focused",typeTimeout:140,minQueryLength:2,template:null,mouseEvents:!("ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0),focusFirstItem:!1,responseFormat:{url:"url",html:"html",label:"label",groupCaption:"caption",groupItems:"items"},fillInputId:!0,inputIdName:null,apiInputName:null,noResultsText:"No results found",onItemSelect:"follow",parseResponse:null,onResultsCreate:null,onGroupCreate:null,onItemCreate:null},a.fastsearch=b,a.fn.fastsearch=function(c){return this.each(function(){a.data(this,"fastsearch")||a.data(this,"fastsearch",new b(this,c))})},a});

@@ -61,2 +61,11 @@ /* jshint node: true */

}
},
bump: {
options: {
files: ['package.json', 'bower.json'],
commitFiles: ['package.json', 'bower.json'],
tagName: '%VERSION%',
push: false
}
}

@@ -63,0 +72,0 @@

{
"name": "fastsearch",
"version": "1.9.1",
"version": "1.10.0",
"main": "src/fastsearch.js",

@@ -15,2 +15,9 @@ "description": "Lightweight fast search / autocomplete plugin based on jQuery",

},
"scripts": {
"watch": "grunt build && grunt watch",
"build": "grunt build",
"bump:patch": "grunt bump:patch",
"bump:minor": "grunt bump:minor",
"bump:major": "grunt bump:major"
},
"keywords": [

@@ -24,2 +31,4 @@ "fastsearch",

"grunt": "^0.4.5",
"grunt-bump": "^0.7.0",
"grunt-cli": "^0.1.13",
"grunt-contrib-copy": "^0.6.0",

@@ -26,0 +35,0 @@ "grunt-contrib-jshint": "^0.10.0",

@@ -285,2 +285,6 @@ (function(factory) {

if (this.options.focusFirstItem && this.$resultItems.length) {
this.navigateItem('down');
}
this.resultsOpened = true;

@@ -505,2 +509,3 @@

mouseEvents: !('ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0), // detect if client is touch enabled so plugin can decide if mouse specific events should be set.
focusFirstItem: false,

@@ -507,0 +512,0 @@ responseFormat: { // Adjust where plugin looks for data in your JSON server response

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