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

bselect

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bselect - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

46

bselect.js
/*!
* BSelect v0.2.0 - 2013-03-03
* BSelect v0.2.1 - 2013-03-04
*

@@ -41,6 +41,2 @@ * Created by Gustavo Henke <gustavo@injoin.com.br>

// Retrieve the currently selected value
value: function() {
return this.data("bselect").value;
},
toggle: function( e ) {

@@ -117,7 +113,7 @@ var bselect = _callMethod( this, "element" );

// Remove the highlighted status from any item
// Remove the highlighted status from any previously selected item...
bselect.find("li").removeClass("active");
val = $elem.addClass("active").data("value");
this.data("bselect").value = val;
// ...and add to the new selected item :)
$elem.addClass("active");

@@ -181,2 +177,21 @@ bselect.find(".bselect-label").text( $elem.text() );

// Refreshes the option list. Useful when new HTML is added
refresh: function() {
var bselect = _callMethod( this, "element" ),
html = "";
this.find("option").each(function() {
if ( !this.value ) {
return;
}
html += "<li class='bselect-option' data-value='" + this.value + "'>" +
"<a href='#'>" + this.text + "</a>" +
"</li>";
});
bselect.find(".bselect-option-list").html( html );
return this;
},
destroy : function() {

@@ -261,15 +276,5 @@ var bselect = _callMethod( this, "element" );

html += "<ul class='bselect-option-list'>";
html += "<ul class='bselect-option-list'></ul>";
html += "</div></div>";
$elem.find("option").each(function() {
if ( !this.value ) {
return;
}
html += "<li class='bselect-option' data-value='" + this.value + "'>" +
"<a href='#'>" + this.text + "</a>" +
"</li>";
});
html += "</ul></div></div>";
container = $elem.after( html ).next();

@@ -284,2 +289,3 @@

updateOptions( $elem, $.bselect.defaults, options );
_callMethod( $elem, "refresh" );

@@ -286,0 +292,0 @@ label = $("<span />").addClass("bselect-label").text( getPlaceholder( $elem ) );

/*!
* BSelect v0.2.0 - 2013-03-03
* BSelect v0.2.1 - 2013-03-04
*

@@ -7,2 +7,2 @@ * Created by Gustavo Henke <gustavo@injoin.com.br>

*/
(function(e,t){"use strict";function n(e,n){return o[n]!==t?o[n].apply(e,Array.prototype.slice.call(arguments,2)):e}function i(t){return n(t,"option","placeholder")||t.data("placeholder")||e.bselect.i18n.selectAnOption}function s(e){var t=e.find(".bselect-option-list"),n=t.find("li:visible").length;t.innerHeight(1.5*parseInt(t.css("line-height"),10)*(5>n?n:5))}function l(t,i,s){var l=n(t,"element");e.each(i,function(t,n){if(s[t]!==n&&"size"===t){var i;i=e.map(r.slice(0),function(e){return"bselect-"+e}).join(" "),l.removeClass(i),r.indexOf(s.size)>-1&&l.addClass("bselect-"+s.size)}})}function a(t,s){var a,r,h,d,u=e(t);d="<div class='bselect' id='bselect-"+ ++c+"'>",d+="<div class='bselect-dropdown'>",s.searchInput===!0&&(d+="<div class='bselect-search'><input type='text' class='bselect-search-input' /><span class='bselect-search-icon'><i class='icon-search'></i></span></div>"),d+="<ul class='bselect-option-list'>",u.find("option").each(function(){this.value&&(d+="<li class='bselect-option' data-value='"+this.value+"'>"+"<a href='#'>"+this.text+"</a>"+"</li>")}),d+="</ul></div></div>",h=u.after(d).next(),u.data("bselect",{options:s,element:h}),l(u,e.bselect.defaults,s),r=e("<span />").addClass("bselect-label").text(i(u)),a=e("<button type='button' />").addClass("bselect-caret").html("<span class='caret'></span>"),h.prepend(a).prepend(r),r.outerWidth(u.outerWidth()-a.outerWidth()),u.hide(),e(document).click(function(t){h.find(".bselect-dropdown").is(":visible")&&!e(".bselect-dropdown, .bselect-dropdown *",h).find(t.target).length&&n(u,"hide")}),h.find(".bselect-search-input").keyup(e.proxy(o.search,u)),h.on("click",".bselect-option",e.proxy(o.select,u)),h.on("click",".bselect-caret, .bselect-label",e.proxy(o.toggle,u))}var c=0,o={option:function(n,i){var s=this.data("bselect").options||{},a=e.extend({},s);return"string"==typeof n&&"_"!==n[0]?i===t?s[n]:(s[n]=i,l(this,a,s),this):(e.isPlainObject(n)&&(e.extend(s,n),l(this,a,s),this.data("bselect").options=s),s)},element:function(){return this.data("bselect").element},value:function(){return this.data("bselect").value},toggle:function(t){var i=n(this,"element");if(t instanceof e.Event){var s=n(this,"option","showOn");if(t.stopPropagation(),e(t.target).is(".bselect-label")&&"both"!==s)return this}return i.find(".bselect-dropdown").is(":hidden")?n(this,"show"):n(this,"hide"),this},show:function(){var e,t=n(this,"element"),i=t.find(".bselect-dropdown");return i.css("left","-9999em").show(),s(t),i.hide().css("left","auto"),i.slideDown(n(this,"option","animationDuration")),t.addClass("open"),e=t.find(".bselect-search-input"),e.innerWidth(e.parent().width()-e.next().outerWidth()),this},hide:function(e){var i=n(this,"option"),s=n(this,"element");return e=e===t?!0:e,s.find(".bselect-dropdown").slideUp(i.animationDuration),s.removeClass("open"),e&&i.clearSearchOnExit&&n(this,"clearSearch"),this},select:function(t){var i,s,l=n(this,"option"),a=n(this,"element");if(t instanceof e.Event)i=e(t.currentTarget);else if(i=a.find("li").eq(t),!i.length)return this;return a.find("li").removeClass("active"),s=i.addClass("active").data("value"),this.data("bselect").value=s,a.find(".bselect-label").text(i.text()),n(this,"hide"),this.val(s),"function"==typeof l.selected&&l.selected.call(this,s,i),this},search:function(t){var i,l,a=n(this,"option"),c=t instanceof e.Event?t.target.value:t,o=n(this,"element");if(""===c&&n(this,"clearSearch"),t instanceof e.Event||o.find(".bselect-search").val(c),!(c===a.lastSearch||c.length<a.minSearchInput)){for(i=o.find("li").hide(),l=0;i.length>l;l++)i[l].textContent.toLowerCase().indexOf(c.toLowerCase())>-1&&e(i[l]).show();return s(i.end()),this}},clearSearch:function(){var e=n(this,"element");return e.find(".bselect-search").val(""),e.find("li").show(),s(e),this},destroy:function(){var e=n(this,"element");this.data("bselect",null),e.remove(),this.show()}},r=["mini","small","large"];e.fn.bselect=function(n){return"string"==typeof n&&this[0]&&e.isPlainObject(e(this[0]).data("bselect"))&&o[n]!==t?o[n].apply(e(this[0]),Array.prototype.slice.call(arguments,1)):this.each(function(){n=e.isPlainObject(n)?n:{},n=e.extend({},e.bselect.defaults,n),a(this,n)})},e.bselect={defaults:{size:"normal",showOn:"both",clearSearchOnExit:!0,minSearchInput:0,animationDuration:300,searchInput:!0,select:null,selected:null},i18n:{selectAnOption:"Select an option"}}})(jQuery);
(function(e,t){"use strict";function n(e,n){return o[n]!==t?o[n].apply(e,Array.prototype.slice.call(arguments,2)):e}function i(t){return n(t,"option","placeholder")||t.data("placeholder")||e.bselect.i18n.selectAnOption}function s(e){var t=e.find(".bselect-option-list"),n=t.find("li:visible").length;t.innerHeight(1.5*parseInt(t.css("line-height"),10)*(5>n?n:5))}function l(t,i,s){var l=n(t,"element");e.each(i,function(t,n){if(s[t]!==n&&"size"===t){var i;i=e.map(r.slice(0),function(e){return"bselect-"+e}).join(" "),l.removeClass(i),r.indexOf(s.size)>-1&&l.addClass("bselect-"+s.size)}})}function a(t,s){var a,r,h,d,u=e(t);d="<div class='bselect' id='bselect-"+ ++c+"'>",d+="<div class='bselect-dropdown'>",s.searchInput===!0&&(d+="<div class='bselect-search'><input type='text' class='bselect-search-input' /><span class='bselect-search-icon'><i class='icon-search'></i></span></div>"),d+="<ul class='bselect-option-list'></ul>",d+="</div></div>",h=u.after(d).next(),u.data("bselect",{options:s,element:h}),l(u,e.bselect.defaults,s),n(u,"refresh"),r=e("<span />").addClass("bselect-label").text(i(u)),a=e("<button type='button' />").addClass("bselect-caret").html("<span class='caret'></span>"),h.prepend(a).prepend(r),r.outerWidth(u.outerWidth()-a.outerWidth()),u.hide(),e(document).click(function(t){h.find(".bselect-dropdown").is(":visible")&&!e(".bselect-dropdown, .bselect-dropdown *",h).find(t.target).length&&n(u,"hide")}),h.find(".bselect-search-input").keyup(e.proxy(o.search,u)),h.on("click",".bselect-option",e.proxy(o.select,u)),h.on("click",".bselect-caret, .bselect-label",e.proxy(o.toggle,u))}var c=0,o={option:function(n,i){var s=this.data("bselect").options||{},a=e.extend({},s);return"string"==typeof n&&"_"!==n[0]?i===t?s[n]:(s[n]=i,l(this,a,s),this):(e.isPlainObject(n)&&(e.extend(s,n),l(this,a,s),this.data("bselect").options=s),s)},element:function(){return this.data("bselect").element},toggle:function(t){var i=n(this,"element");if(t instanceof e.Event){var s=n(this,"option","showOn");if(t.stopPropagation(),e(t.target).is(".bselect-label")&&"both"!==s)return this}return i.find(".bselect-dropdown").is(":hidden")?n(this,"show"):n(this,"hide"),this},show:function(){var e,t=n(this,"element"),i=t.find(".bselect-dropdown");return i.css("left","-9999em").show(),s(t),i.hide().css("left","auto"),i.slideDown(n(this,"option","animationDuration")),t.addClass("open"),e=t.find(".bselect-search-input"),e.innerWidth(e.parent().width()-e.next().outerWidth()),this},hide:function(e){var i=n(this,"option"),s=n(this,"element");return e=e===t?!0:e,s.find(".bselect-dropdown").slideUp(i.animationDuration),s.removeClass("open"),e&&i.clearSearchOnExit&&n(this,"clearSearch"),this},select:function(t){var i,s,l=n(this,"option"),a=n(this,"element");if(t instanceof e.Event)i=e(t.currentTarget);else if(i=a.find("li").eq(t),!i.length)return this;return a.find("li").removeClass("active"),i.addClass("active"),a.find(".bselect-label").text(i.text()),n(this,"hide"),this.val(s),"function"==typeof l.selected&&l.selected.call(this,s,i),this},search:function(t){var i,l,a=n(this,"option"),c=t instanceof e.Event?t.target.value:t,o=n(this,"element");if(""===c&&n(this,"clearSearch"),t instanceof e.Event||o.find(".bselect-search").val(c),!(c===a.lastSearch||c.length<a.minSearchInput)){for(i=o.find("li").hide(),l=0;i.length>l;l++)i[l].textContent.toLowerCase().indexOf(c.toLowerCase())>-1&&e(i[l]).show();return s(i.end()),this}},clearSearch:function(){var e=n(this,"element");return e.find(".bselect-search").val(""),e.find("li").show(),s(e),this},refresh:function(){var e=n(this,"element"),t="";return this.find("option").each(function(){this.value&&(t+="<li class='bselect-option' data-value='"+this.value+"'>"+"<a href='#'>"+this.text+"</a>"+"</li>")}),e.find(".bselect-option-list").html(t),this},destroy:function(){var e=n(this,"element");this.data("bselect",null),e.remove(),this.show()}},r=["mini","small","large"];e.fn.bselect=function(n){return"string"==typeof n&&this[0]&&e.isPlainObject(e(this[0]).data("bselect"))&&o[n]!==t?o[n].apply(e(this[0]),Array.prototype.slice.call(arguments,1)):this.each(function(){n=e.isPlainObject(n)?n:{},n=e.extend({},e.bselect.defaults,n),a(this,n)})},e.bselect={defaults:{size:"normal",showOn:"both",clearSearchOnExit:!0,minSearchInput:0,animationDuration:300,searchInput:!0,select:null,selected:null},i18n:{selectAnOption:"Select an option"}}})(jQuery);
{
"name": "bselect",
"version": "0.2.0",
"version": "0.2.1",
"main": ["./bselect.js", "./bselect.css"],

@@ -5,0 +5,0 @@ "dependencies": {

/*!
* BSelect v0.2.0 - 2013-03-03
* BSelect v0.2.1 - 2013-03-04
*

@@ -4,0 +4,0 @@ * Created by Gustavo Henke <gustavo@injoin.com.br>

{
"name": "bselect",
"title": "BSelect",
"version": "0.2.0",
"version": "0.2.1",
"homepage": "http://gustavohenke.github.com/bselect/",

@@ -6,0 +6,0 @@ "author": {

Sorry, the diff of this file is not supported yet

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