From 6994225345f81f8229a15f0c39223312fea50799 Mon Sep 17 00:00:00 2001 From: sunhater Date: Fri, 24 Jan 2014 00:01:35 +0200 Subject: [PATCH] search fix --- jquery.shCheckset-min.js | 6 +++--- jquery.shCheckset.js | 9 ++++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/jquery.shCheckset-min.js b/jquery.shCheckset-min.js index db152ea..a3d954a 100644 --- a/jquery.shCheckset-min.js +++ b/jquery.shCheckset-min.js @@ -1,9 +1,9 @@ /*! - * jQuery shCheckset v1.0 + * jQuery shCheckset v1.1 * http://jquery.sunhater.com/shCheckset - * 2014-01-22 + * 2014-01-24 * * Copyright (c) 2010-2014 Pavel Tzonkov * Dual licensed under the MIT and GPL licenses. */ -(function(b){var a=0;b.fn.shCheckset=function(e){var g={namespace:"shcs",search:false,uniform:true,labels:{search:"Search..."},widthOffset:0},d=function(c,h,j){try{c.add(new Option(j,h),null)}catch(i){c.add(new Option(j,h))}};b.extend(g,e);if(!a){var f=b("
").css({width:100,height:100,overflow:"auto",position:"absolute",top:-1000,left:-1000}).prependTo("body").append("
").find("div").css({width:"100%",height:200});a=100-f.width();f.parent().remove()}this.each(function(){var l=this;if(!b(l).is("select")||!l.length){return}b(l).after('
');var o=b(l).next().get(0),h=b(l).attr("name"),c={width:l.style.width?l.style.width:b(l).outerWidth()+"px",height:l.style.height?l.style.height:b(l).outerHeight()+"px"};if(!h){h=g.namespace+"[]"}else{if(h.substr(h.length-2,2)!="[]"){h+="[]"}}b(o).html((g.search?'':"")+"
");var k=b(o).find('input[type="text"]'),n=0,j=0,m=b(o).find("div");m.css({overflow:"auto",height:parseInt(c.height)-k.outerHeight(true)-parseInt(m.css("marginTop"))-parseInt(m.css("marginBottom"))-parseInt(m.css("paddingTop"))-parseInt(m.css("paddingBottom"))-parseInt(m.css("borderTopWidth"))-parseInt(m.css("borderBottomWidth"))+"px"});b(l).find("option").each(function(){var p,r,i,s,q=this;do{s=g.namespace+"_"+h.substr(0,h.length-2)+"_"+j++}while(b("#"+s).get(0));b(o).find("div").append("");p=b(o).find("label").last();p.attr("for",s).html(''+q.text+"").css({whitespace:"nowrap","float":"left"});r=p.find("input").first();r.attr({name:h,id:s,value:q.value,checked:q.selected});if(q.selected){p.addClass("checked")}if(g.uniform&&b.uniform){r.uniform()}i=p.outerWidth(true);if(n").css({width:100,height:100,overflow:"auto",position:"absolute",top:-1000,left:-1000}).prependTo("body").append("
").find("div").css({width:"100%",height:200});a=100-f.width();f.parent().remove()}this.each(function(){var l=this;if(!b(l).is("select")||!l.length){return}b(l).after('
');var o=b(l).next().get(0),h=b(l).attr("name"),c={width:l.style.width?l.style.width:b(l).outerWidth()+"px",height:l.style.height?l.style.height:b(l).outerHeight()+"px"};if(!h){h=g.namespace+"[]"}else{if(h.substr(h.length-2,2)!="[]"){h+="[]"}}b(o).html((g.search?'':"")+"
");var k=b(o).find('input[type="text"]'),n=0,j=0,m=b(o).find("div");m.css({overflow:"auto",height:parseInt(c.height)-k.outerHeight(true)-parseInt(m.css("marginTop"))-parseInt(m.css("marginBottom"))-parseInt(m.css("paddingTop"))-parseInt(m.css("paddingBottom"))-parseInt(m.css("borderTopWidth"))-parseInt(m.css("borderBottomWidth"))+"px"});b(l).find("option").each(function(){var p,r,i,s,q=this;do{s=g.namespace+"_"+h.substr(0,h.length-2)+"_"+j++}while(b("#"+s).get(0));b(o).find("div").append("");p=b(o).find("label").last();p.attr("for",s).html(''+q.text+"").css({whitespace:"nowrap","float":"left"});r=p.find("input").first();r.attr({name:h,id:s,value:q.value,checked:q.selected});if(q.selected){p.addClass("checked")}if(g.uniform&&b.uniform){r.uniform()}i=p.outerWidth(true);if(n * Dual licensed under the MIT and GPL licenses. @@ -156,9 +156,8 @@ $(this).val(search + (lastSpace ? " " : "")); - $(t).find('option').each(function(i) { - $(div).find('label[for="' + c.namespace + '_' + (name.substr(0, name.length - 2) + this.value + '_' + i) + '"]') - .css('display', (search.length && (this.text.toLowerCase().indexOf(search.toLowerCase()) == -1)) ? 'none' : 'block'); + $(div).find('label').each(function(i) { + $(this).css('display', (search.length && ($(this).find('span').text().toLowerCase().indexOf(search.toLowerCase()) == -1)) ? 'none' : 'block'); }); }); $(t).detach();