Comparing version 0.3.0 to 0.3.1
{ | ||
"name": "bselect", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"main": ["./bselect.js", "./bselect.css"], | ||
@@ -5,0 +5,0 @@ "dependencies": { |
/*! | ||
* BSelect v0.3.0 - 2013-03-12 | ||
* BSelect v0.3.1 - 2013-03-13 | ||
* | ||
@@ -4,0 +4,0 @@ * Created by Gustavo Henke <gustavo@injoin.com.br> |
/*! | ||
* BSelect v0.3.0 - 2013-03-12 | ||
* BSelect v0.3.1 - 2013-03-13 | ||
* | ||
@@ -7,8 +7,2 @@ * Created by Gustavo Henke <gustavo@injoin.com.br> | ||
*/ | ||
/*! | ||
* BSelect v0.3.0 - 2013-03-12 | ||
* | ||
* Created by Gustavo Henke <gustavo@injoin.com.br> | ||
* http://gustavohenke.github.com/bselect/ | ||
*/ | ||
(function( $, undefined ) { | ||
@@ -438,3 +432,3 @@ "use strict"; | ||
container.on( "click", ".bselect-caret, .bselect-label", $.proxy( methods.toggle, $elem ) ); | ||
container.on( "keypress", ".bselect-option, .bselect-search-input", handleKeypress ); | ||
container.on( "keydown", ".bselect-option, .bselect-search-input", handleKeypress ); | ||
@@ -441,0 +435,0 @@ // Issue #6 - Listen to the change event and update the selected value |
@@ -1,1 +0,1 @@ | ||
(function(e,t){"use strict";function s(e,s){return d[s]!==t?d[s].apply(e,Array.prototype.slice.call(arguments,2)):e}function i(t){return s(t,"option","placeholder")||t.data("placeholder")||e.bselect.i18n.selectAnOption}function n(e){var t=e.find(".bselect-option-list"),s=t.find("li:visible").length;t.innerHeight(1.5*parseInt(t.css("line-height"),10)*(5>s?s:5))}function a(t,i,n){var a=s(t,"element");e.each(i,function(t,s){if(n[t]!==s&&"size"===t){var i;i=e.map(h.slice(0),function(e){return"bselect-"+e}).join(" "),a.removeClass(i),h.indexOf(n.size)>-1&&a.addClass("bselect-"+n.size)}})}function l(t){var i=s(t,"element");i.find(".bselect-message").text(e.bselect.i18n.noOptionsAvailable).show()}function c(t){if(38===t.keyCode||40===t.keyCode||13===t.keyCode){var s=e(this),i=s.is(".bselect-search-input");switch(t.keyCode){case 38:i?e(t.delegateTarget).find(".bselect-option:visible:last").focus():s.prevAll(":visible").eq(0).focus();break;case 40:i?e(t.delegateTarget).find(".bselect-option:visible:first").focus():s.nextAll(":visible").eq(0).focus();break;case 13:i||s.trigger("click")}return!1}}function o(t,n){var l,o,h,p,b,u=e(t);if(p=++r,h=e("<div class='bselect' />",{id:"bselect-"+p}),b=e("<div class='bselect-dropdown' />"),n.searchInput===!0){var f=e("<div class='bselect-search' />");e("<input type='text' class='bselect-search-input' />").attr({role:"combobox",tabindex:1,"aria-expanded":"false","aria-owns":"bselect-option-list-"+p}).appendTo(f),e("<span class='bselect-search-icon'><i class='icon-search' /></span>").appendTo(f),f.appendTo(b)}e("<div class='bselect-message' role='status' />").appendTo(b),e("<ul class='bselect-option-list' />").attr({id:"bselect-option-list-"+p,role:"listbox"}).appendTo(b),h.append(b).insertAfter(u),u.data("bselect",{options:n,element:h}),a(u,e.bselect.defaults,n),s(u,"refresh"),u.bind("bselectselect",n.select),u.bind("bselectselected",n.selected),u.bind("bselectsearch",n.search),o=e("<span />").addClass("bselect-label").text(i(u)),l=e("<button type='button' />").addClass("bselect-caret").html("<span class='caret'></span>"),h.prepend(l).prepend(o),o.outerWidth(u.outerWidth()-l.outerWidth()),u.hide(),e(window).click(function(t){h.find(".bselect-dropdown").is(":visible")&&!e(".bselect-dropdown, .bselect-dropdown *",h).find(t.target).length&&s(u,"hide")}),h.find(".bselect-search-input").keyup(e.proxy(d.search,u)),h.on("click",".bselect-option",e.proxy(d.select,u)),h.on("click",".bselect-caret, .bselect-label",e.proxy(d.toggle,u)),h.on("keypress",".bselect-option, .bselect-search-input",c),u.bind("change.bselect",function(){var e=u.data("bselect").itemsMap[this.value];s(u,"select",e)}).trigger("change.bselect"),e(document).on("click","label[for='"+u.attr("id")+"']",function(){return s(u,"show"),!1})}var r=0,d={option:function(s,i){var n=this.data("bselect").options||{},l=e.extend({},n);return"string"==typeof s&&"_"!==s[0]?i===t?n[s]:(n[s]=i,a(this,l,n),this):(e.isPlainObject(s)&&(e.extend(n,s),a(this,l,n),this.data("bselect").options=n),n)},element:function(){return this.data("bselect").element},toggle:function(t){var i=s(this,"element");if(t instanceof e.Event){var n=s(this,"option","showOn");if(t.stopPropagation(),e(t.target).is(".bselect-label")&&"both"!==n)return this}return i.find(".bselect-dropdown").is(":hidden")?s(this,"show"):s(this,"hide"),this},show:function(){var e,t,i=s(this,"element"),a=i.find(".bselect-dropdown");if(a.css("left","-9999em").show(),n(i),t=i.find(".bselect-option.active"),t.length){var l=i.find(".bselect-option-list"),c=t.position().top,o=l.position().top;l.height()>c-o?l.scrollTop(0):l.scrollTop(c-o)}return a.hide().css("left","auto"),a.slideDown(s(this,"option","animationDuration")),i.addClass("open"),e=i.find(".bselect-search-input").focus(),e.innerWidth(e.parent().width()-e.next().outerWidth()),i.find(".bselect-search-input").attr("aria-expanded","true"),this},hide:function(e){var i=s(this,"option"),n=s(this,"element");return e=e===t?!0:e,n.find(".bselect-dropdown").slideUp(i.animationDuration),n.removeClass("open"),e&&i.clearSearchOnExit&&s(this,"clearSearch"),n.find(".bselect-search-input").attr("aria-expanded","false"),this},select:function(t){var i,n,a=(s(this,"option"),s(this,"element"));if(t instanceof e.Event)i=e(t.currentTarget);else if(i=a.find("li").eq(t),!i.length)return this;var l=a.find("li").removeClass("active").attr("aria-selected","false").index(i),c=this.find("option[value!='']").get(l);return this.trigger("bselectselect",[c]),n=i.addClass("active").data("value"),i.attr("aria-selected","true"),a.find(".bselect-label").text(i.text()),s(this,"hide"),this.val(n),this.trigger("bselectselected",[n,c]),this},search:function(t){var i,a,c=s(this,"option"),o=t instanceof e.Event?t.target.value:t,r=s(this,"element");if(""===o&&s(this,"clearSearch"),t instanceof e.Event||r.find(".bselect-search").val(o),!(o===c.lastSearch||o.length<c.minSearchInput)){var d=e();for(i=r.find("li").hide(),a=0;i.length>a;a++)i[a].textContent.toLowerCase().indexOf(o.toLowerCase())>-1&&(d=d.add(e(i[a]).show()));return 0===d.length?l(this):r.find(".bselect-message").hide(),this.trigger("bselectsearch",[o,d]),n(i.end()),this}},clearSearch:function(){var e=s(this,"element");return e.find(".bselect-search-input").val(""),e.find("li").show(),e.find(".bselect-message").hide(),n(e),this},refresh:function(){var t=s(this,"element"),i=t.find(".bselect-option-list").empty(),n={},a=0;return this.find("option").each(function(){if(this.value){var t=e("<li class='bselect-option' />").attr({role:"option",tabindex:2,"aria-selected":"false"}).data("value",this.value);n[this.value]=a,t.append("<a href='#'>"+this.text+"</a>"),t.appendTo(i),a++}}),0===a&&l(this),this.data("bselect").itemsMap=n,this},destroy:function(){var e=s(this,"element");return this.data("bselect",null),e.remove(),this.show(),this}},h=["mini","small","large"];e.fn.bselect=function(s){return"string"==typeof s&&this[0]?e.isPlainObject(e(this[0]).data("bselect"))&&d[s]!==t?d[s].apply(e(this[0]),Array.prototype.slice.call(arguments,1)):this:this.each(function(){e.isPlainObject(e(this).data("bselect"))||(s=e.isPlainObject(s)?s:{},s=e.extend({},e.bselect.defaults,s),o(this,s))})},e.bselect={defaults:{size:"normal",showOn:"both",clearSearchOnExit:!0,minSearchInput:0,animationDuration:300,searchInput:!0,search:null,select:null,selected:null},i18n:{selectAnOption:"Select an option",noOptionsAvailable:"No options available."}}})(jQuery); | ||
(function(e,t){"use strict";function s(e,s){return d[s]!==t?d[s].apply(e,Array.prototype.slice.call(arguments,2)):e}function i(t){return s(t,"option","placeholder")||t.data("placeholder")||e.bselect.i18n.selectAnOption}function n(e){var t=e.find(".bselect-option-list"),s=t.find("li:visible").length;t.innerHeight(1.5*parseInt(t.css("line-height"),10)*(5>s?s:5))}function a(t,i,n){var a=s(t,"element");e.each(i,function(t,s){if(n[t]!==s&&"size"===t){var i;i=e.map(h.slice(0),function(e){return"bselect-"+e}).join(" "),a.removeClass(i),h.indexOf(n.size)>-1&&a.addClass("bselect-"+n.size)}})}function l(t){var i=s(t,"element");i.find(".bselect-message").text(e.bselect.i18n.noOptionsAvailable).show()}function c(t){if(38===t.keyCode||40===t.keyCode||13===t.keyCode){var s=e(this),i=s.is(".bselect-search-input");switch(t.keyCode){case 38:i?e(t.delegateTarget).find(".bselect-option:visible:last").focus():s.prevAll(":visible").eq(0).focus();break;case 40:i?e(t.delegateTarget).find(".bselect-option:visible:first").focus():s.nextAll(":visible").eq(0).focus();break;case 13:i||s.trigger("click")}return!1}}function o(t,n){var l,o,h,p,b,u=e(t);if(p=++r,h=e("<div class='bselect' />",{id:"bselect-"+p}),b=e("<div class='bselect-dropdown' />"),n.searchInput===!0){var f=e("<div class='bselect-search' />");e("<input type='text' class='bselect-search-input' />").attr({role:"combobox",tabindex:1,"aria-expanded":"false","aria-owns":"bselect-option-list-"+p}).appendTo(f),e("<span class='bselect-search-icon'><i class='icon-search' /></span>").appendTo(f),f.appendTo(b)}e("<div class='bselect-message' role='status' />").appendTo(b),e("<ul class='bselect-option-list' />").attr({id:"bselect-option-list-"+p,role:"listbox"}).appendTo(b),h.append(b).insertAfter(u),u.data("bselect",{options:n,element:h}),a(u,e.bselect.defaults,n),s(u,"refresh"),u.bind("bselectselect",n.select),u.bind("bselectselected",n.selected),u.bind("bselectsearch",n.search),o=e("<span />").addClass("bselect-label").text(i(u)),l=e("<button type='button' />").addClass("bselect-caret").html("<span class='caret'></span>"),h.prepend(l).prepend(o),o.outerWidth(u.outerWidth()-l.outerWidth()),u.hide(),e(window).click(function(t){h.find(".bselect-dropdown").is(":visible")&&!e(".bselect-dropdown, .bselect-dropdown *",h).find(t.target).length&&s(u,"hide")}),h.find(".bselect-search-input").keyup(e.proxy(d.search,u)),h.on("click",".bselect-option",e.proxy(d.select,u)),h.on("click",".bselect-caret, .bselect-label",e.proxy(d.toggle,u)),h.on("keydown",".bselect-option, .bselect-search-input",c),u.bind("change.bselect",function(){var e=u.data("bselect").itemsMap[this.value];s(u,"select",e)}).trigger("change.bselect"),e(document).on("click","label[for='"+u.attr("id")+"']",function(){return s(u,"show"),!1})}var r=0,d={option:function(s,i){var n=this.data("bselect").options||{},l=e.extend({},n);return"string"==typeof s&&"_"!==s[0]?i===t?n[s]:(n[s]=i,a(this,l,n),this):(e.isPlainObject(s)&&(e.extend(n,s),a(this,l,n),this.data("bselect").options=n),n)},element:function(){return this.data("bselect").element},toggle:function(t){var i=s(this,"element");if(t instanceof e.Event){var n=s(this,"option","showOn");if(t.stopPropagation(),e(t.target).is(".bselect-label")&&"both"!==n)return this}return i.find(".bselect-dropdown").is(":hidden")?s(this,"show"):s(this,"hide"),this},show:function(){var e,t,i=s(this,"element"),a=i.find(".bselect-dropdown");if(a.css("left","-9999em").show(),n(i),t=i.find(".bselect-option.active"),t.length){var l=i.find(".bselect-option-list"),c=t.position().top,o=l.position().top;l.height()>c-o?l.scrollTop(0):l.scrollTop(c-o)}return a.hide().css("left","auto"),a.slideDown(s(this,"option","animationDuration")),i.addClass("open"),e=i.find(".bselect-search-input").focus(),e.innerWidth(e.parent().width()-e.next().outerWidth()),i.find(".bselect-search-input").attr("aria-expanded","true"),this},hide:function(e){var i=s(this,"option"),n=s(this,"element");return e=e===t?!0:e,n.find(".bselect-dropdown").slideUp(i.animationDuration),n.removeClass("open"),e&&i.clearSearchOnExit&&s(this,"clearSearch"),n.find(".bselect-search-input").attr("aria-expanded","false"),this},select:function(t){var i,n,a=(s(this,"option"),s(this,"element"));if(t instanceof e.Event)i=e(t.currentTarget);else if(i=a.find("li").eq(t),!i.length)return this;var l=a.find("li").removeClass("active").attr("aria-selected","false").index(i),c=this.find("option[value!='']").get(l);return this.trigger("bselectselect",[c]),n=i.addClass("active").data("value"),i.attr("aria-selected","true"),a.find(".bselect-label").text(i.text()),s(this,"hide"),this.val(n),this.trigger("bselectselected",[n,c]),this},search:function(t){var i,a,c=s(this,"option"),o=t instanceof e.Event?t.target.value:t,r=s(this,"element");if(""===o&&s(this,"clearSearch"),t instanceof e.Event||r.find(".bselect-search").val(o),!(o===c.lastSearch||o.length<c.minSearchInput)){var d=e();for(i=r.find("li").hide(),a=0;i.length>a;a++)i[a].textContent.toLowerCase().indexOf(o.toLowerCase())>-1&&(d=d.add(e(i[a]).show()));return 0===d.length?l(this):r.find(".bselect-message").hide(),this.trigger("bselectsearch",[o,d]),n(i.end()),this}},clearSearch:function(){var e=s(this,"element");return e.find(".bselect-search-input").val(""),e.find("li").show(),e.find(".bselect-message").hide(),n(e),this},refresh:function(){var t=s(this,"element"),i=t.find(".bselect-option-list").empty(),n={},a=0;return this.find("option").each(function(){if(this.value){var t=e("<li class='bselect-option' />").attr({role:"option",tabindex:2,"aria-selected":"false"}).data("value",this.value);n[this.value]=a,t.append("<a href='#'>"+this.text+"</a>"),t.appendTo(i),a++}}),0===a&&l(this),this.data("bselect").itemsMap=n,this},destroy:function(){var e=s(this,"element");return this.data("bselect",null),e.remove(),this.show(),this}},h=["mini","small","large"];e.fn.bselect=function(s){return"string"==typeof s&&this[0]?e.isPlainObject(e(this[0]).data("bselect"))&&d[s]!==t?d[s].apply(e(this[0]),Array.prototype.slice.call(arguments,1)):this:this.each(function(){e.isPlainObject(e(this).data("bselect"))||(s=e.isPlainObject(s)?s:{},s=e.extend({},e.bselect.defaults,s),o(this,s))})},e.bselect={defaults:{size:"normal",showOn:"both",clearSearchOnExit:!0,minSearchInput:0,animationDuration:300,searchInput:!0,search:null,select:null,selected:null},i18n:{selectAnOption:"Select an option",noOptionsAvailable:"No options available."}}})(jQuery); |
{ | ||
"name": "bselect", | ||
"title": "BSelect", | ||
"version": "0.3.0", | ||
"version": "0.3.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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1453
138816