|
|
|
|
|
//select陦ィ遉コselect譛ャ霄ォ<EFBFBD>計iew陦ィ遉コ霍ウ蜃コ逧<EFBFBD>?ク鬆<EFBFBD>
|
|
|
;(function($){
|
|
|
|
|
|
$.fn.extend({
|
|
|
|
|
|
//險育ョ玲枚蟄唯yte謨ク<EFBFBD>御クヲ蝗槫さ
|
|
|
getByteLength: function(strIN){
|
|
|
var i, cnt=0;
|
|
|
|
|
|
for (i=0; i<strIN.length; i++){
|
|
|
if (escape(strIN.charAt(i)).length >= 4) cnt+=2;
|
|
|
else cnt++;
|
|
|
}
|
|
|
|
|
|
return cnt;
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
$.fn.extend({
|
|
|
|
|
|
//讙「譟・譁<EFBFBD>ュ礼噪Byte謨ク<EFBFBD>瑚カ<EFBFBD>?四imit謖<EFBFBD>ョ夂噪蛟区丙逧<EFBFBD>ゥア<EFBFBD>悟ーア蝗槫さtrue 蜥<EFBFBD> 譛ェ雜<EFBFBD>?惹ケ句<EFBFBD>?逧<EFBFBD>枚蟄擁ndex
|
|
|
getIndexByByte: function(strIN,limit){
|
|
|
var i, cnt=0;
|
|
|
|
|
|
for (i=0; i<strIN.length; i++){
|
|
|
if (escape(strIN.charAt(i)).length >= 4) cnt+=2;
|
|
|
else cnt++;
|
|
|
|
|
|
if(cnt>limit)
|
|
|
{
|
|
|
return [true,i];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
$.fn.extend({
|
|
|
|
|
|
finalselect: function(options) {
|
|
|
|
|
|
var settings =
|
|
|
{
|
|
|
id:null,
|
|
|
animalSpeed:100,
|
|
|
selectWidth:"190px",
|
|
|
selectImage:"image/select.png",
|
|
|
selectText:"My friend",
|
|
|
zIndex: 0,
|
|
|
viewHeight:"100px",
|
|
|
viewWidth:"300px",
|
|
|
viewMouseoverColor:"#cfdfff",//#dcdcdc
|
|
|
viewTop:"28px",//top,bottom
|
|
|
viewLeft:" -1px"//left,right
|
|
|
};
|
|
|
|
|
|
|
|
|
if (typeof(options)!='undefined')
|
|
|
{
|
|
|
//蟆<EFBFBD>紛謇ケoptions逧<EFBFBD>シassign邨ヲsettings
|
|
|
jQuery.extend(settings, options);
|
|
|
}
|
|
|
|
|
|
var tmp='<div id="'+settings.id+'-select" style="cursor:default;font-size:12px;z-index:'+settings.zIndex+';border: solid 0px #999; padding: 3px; width: 180px; position: relative;">'
|
|
|
tmp+='<div id="'+settings.id+'-Text" style="background: url('+settings.selectImage+') no-repeat 0 0; width: '+settings.selectWidth+'; height: 21px; color: Black; padding: 0 0 0 10px;">';
|
|
|
tmp+='<div class="textshow" style="padding: 4px 0 0 0;">'+settings.selectText+'</div><div class="valueshow" style="display:none;"></div></div><div id="'+settings.id+'-selectshow" style="overflow-y:auto; overflow-x:hidden; height:'+settings.viewHeight+';width:'+settings.viewWidth+'; display:none; position: absolute; left:'+settings.viewLeft+'; top:'+settings.viewTop+'; border: solid 1px #999; background: white;"></div></div>';
|
|
|
|
|
|
|
|
|
|
|
|
var _handler = function() {
|
|
|
// 蠕樣呵」。髢句ァ<EFBFBD>
|
|
|
$(this).html(tmp);
|
|
|
bindArrowClick();
|
|
|
bindSelectMouseover();
|
|
|
bindSelectMouseleave();
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var bindArrowClick=function(){
|
|
|
var tmp=$('#'+settings.id+'-Text');
|
|
|
$("#"+settings.id+'-Text').bind("click", function(e){
|
|
|
var obj=$('#'+settings.id+'-selectshow');
|
|
|
if(obj.css('display')=='none')
|
|
|
{
|
|
|
// obj.slide();
|
|
|
obj.slideDown(settings.animalSpeed,function(){
|
|
|
obj.show();
|
|
|
obj.css('overflow','auto');
|
|
|
obj.css('overflow-x','hidden');
|
|
|
});
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
obj.slideUp(settings.animalSpeed,function(){
|
|
|
obj.hide();
|
|
|
});
|
|
|
}
|
|
|
|
|
|
});
|
|
|
};
|
|
|
|
|
|
var bindItemMouseover=function(){
|
|
|
|
|
|
var inx=0;
|
|
|
while($(".selectitem",$("#"+settings.id+"-selectshow")).get(inx)!=null)
|
|
|
{
|
|
|
var item=$(".selectitem",$("#"+settings.id+"-selectshow")).get(inx);
|
|
|
|
|
|
$(item).bind("mouseover", function(e){
|
|
|
$(this).css('background-color',settings.viewMouseoverColor);
|
|
|
});
|
|
|
|
|
|
$(item).bind("mouseout", function(e){
|
|
|
$(this).css('background-color','#fff');
|
|
|
});
|
|
|
|
|
|
$(item).bind("click", function(e){
|
|
|
|
|
|
var tmpstr=$(".thistext",$(this)).html();
|
|
|
var arr=$().getIndexByByte(tmpstr,30);
|
|
|
if(arr[0]==true)
|
|
|
tmpstr=tmpstr.substring(0,arr[1])+'...';
|
|
|
|
|
|
$(".textshow",$("#"+settings.id+"-Text")).html(tmpstr);
|
|
|
document.getElementById(settings.id+'-selectshow').style.display="none";
|
|
|
|
|
|
$(".valueshow",$("#"+settings.id+"-Text")).html($(".selectvalue",$(this)).html());
|
|
|
|
|
|
});
|
|
|
|
|
|
inx++;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
var bindSelectMouseover=function(){
|
|
|
$('#'+settings.id+'-Text').bind("mouseover",function(){
|
|
|
if($.browser.msie==false)
|
|
|
$('#'+settings.id+'-Text').css("background-position","0 -21px");
|
|
|
});
|
|
|
}
|
|
|
|
|
|
var bindSelectMouseleave=function(){
|
|
|
$('#'+settings.id+'-Text').bind("mouseout",function(){
|
|
|
if($.browser.msie==false)
|
|
|
$('#'+settings.id+'-Text').css("background-position","0 0px");
|
|
|
});
|
|
|
}
|
|
|
|
|
|
this.setViewTop = function(top){
|
|
|
$('#'+settings.id+'-selectshow').css('top',top+'px');
|
|
|
}
|
|
|
|
|
|
this.setViewLeft = function(left){
|
|
|
$('#'+settings.id+'-selectshow').css('left',left+'px');
|
|
|
}
|
|
|
|
|
|
this.getLength = function(){
|
|
|
return $('.selectitem',$('#'+settings.id+'-selectshow')).length;
|
|
|
}
|
|
|
|
|
|
|
|
|
//add item蛻ーselect陬。<EFBFBD>?「
|
|
|
//蝨ィ蛯ウitemtext譎ゑシ檎畑<span class="thistext"></span>蛹<EFBFBD>オキ隕?鬘ッ遉コ逧<EFBFBD> "譁<EFBFBD>ュ<EFBFBD>"
|
|
|
//萓句ヲ<EFBFBD>:<span class="thistext">蜩<EFBFBD>嶋蜩<EFBFBD></span><EFBFBD>碁呎ィ」select<EFBFBD>?ク謫<EFBFBD>セ鯉シ悟ーア譛<EFBFBD>。ッ遉コ "蜩<EFBFBD>嶋蜩<EFBFBD>"
|
|
|
this.addItem = function(itemtext,itemvalue){
|
|
|
|
|
|
var itemhtml='<div class="selectitem"><div class="selecttext">'+itemtext
|
|
|
+'</div><div class="selectvalue" style=" display:none;">'+itemvalue+'</div></div><div class="selectborder"><div>';
|
|
|
|
|
|
$("#"+settings.id+'-selectshow').html($("#"+settings.id+'-selectshow').html()+itemhtml);
|
|
|
|
|
|
bindItemMouseover();
|
|
|
};
|
|
|
|
|
|
this.removeItem = function(index){
|
|
|
if($('.selectitem',$('#'+settings.id+'-selectshow')).length>index)
|
|
|
$($('.selectitem',$('#'+settings.id+'-selectshow')).get(index)).remove();
|
|
|
if($('.selectborder',$('#'+settings.id+'-selectshow')).length>index)
|
|
|
$($('.selectborder',$('#'+settings.id+'-selectshow')).get(index)).remove();
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.getValue = function(){
|
|
|
return $('.valueshow',$('#'+settings.id+'-Text')).html();
|
|
|
}
|
|
|
|
|
|
this.getText = function(){
|
|
|
return $('.textshow',$('#'+settings.id+'-Text')).html();
|
|
|
}
|
|
|
|
|
|
|
|
|
return this.each(_handler);
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
})(jQuery); |