(function($){"use strict";var defaults={data:undefined,lang:"cn",multiple:false,pagination:true,dropButton:true,listSize:10,multipleControlbar:true,maxSelectLimit:0,selectToCloseList:false,initRecord:undefined,dbTable:"tbl",keyField:"id",showField:"name",searchField:undefined,andOr:"OR",separator:",",orderBy:undefined,pageSize:10,params:undefined,formatItem:undefined,autoFillResult:false,autoSelectFirst:false,noResultClean:true,selectOnly:false,inputDelay:.5,eSelect:undefined,eOpen:undefined,eAjaxSuccess:undefined,eTagRemove:undefined,eClear:undefined};var SelectPage=function(input,option){$.each({data:"source",keyField:"primaryKey",showField:"field",pageSize:"perPage"},function(i,j){if(typeof option[j]!=="undefined"){option[i]=option[j];delete option[j]}});this.setOption(option);this.setLanguage();this.setCssClass();this.setProp();this.setElem(input);this.setButtonAttrDefault();this.setInitRecord();this.eDropdownButton();this.eInput();this.eWhole()};SelectPage.version="2.19";SelectPage.dataKey="selectPageObject";SelectPage.prototype.setOption=function(option){option.searchField=option.searchField||option.showField;option.andOr=option.andOr.toUpperCase();if(option.andOr!=="AND"&&option.andOr!=="OR")option.andOr="AND";var arr=["searchField"];for(var i=0;i#item_text#',textKey:"#item_text#",valueKey:"#item_value#"},page:{current:"page_num",total:"page_count"},msg:{maxSelectLimit:"max_selected_limit"}}};SelectPage.prototype.elementRealSize=function(element,method){var defaults={absolute:false,clone:false,includeMargin:false,display:"block"};var configs=defaults,$target=element.eq(0),fix,restore,tmp=[],style="",$hidden;fix=function(){$hidden=$target.parents().addBack().filter(":hidden");style+="visibility: hidden !important; display: "+configs.display+" !important; ";if(configs.absolute===true)style+="position: absolute !important;";$hidden.each(function(){var $this=$(this),thisStyle=$this.attr("style");tmp.push(thisStyle);$this.attr("style",thisStyle?thisStyle+";"+style:style)})};restore=function(){$hidden.each(function(i){var $this=$(this),_tmp=tmp[i];if(_tmp===undefined)$this.removeAttr("style");else $this.attr("style",_tmp)})};fix();var actual=/(outer)/.test(method)?$target[method](configs.includeMargin):$target[method]();restore();return actual};SelectPage.prototype.setElem=function(combo_input){var elem={},p=this.option,css=this.css_class,msg=this.message,input=$(combo_input);var cssWidth=input.css("width");var orgWidth=input.outerWidth();if(cssWidth.indexOf("%")>-1||input.parent().length>0&&input.parent().width()==orgWidth){orgWidth="100%"}else{if(orgWidth<=0)orgWidth=this.elementRealSize(input,"outerWidth");if(orgWidth<150)orgWidth=150}elem.combo_input=input.attr({autocomplete:"off"}).addClass(css.input).wrap("
");if(p.selectOnly)elem.combo_input.prop("readonly",true);elem.container=elem.combo_input.parent().addClass(css.container);if(elem.combo_input.prop("disabled")){if(p.multiple)elem.container.addClass(css.disabled);else elem.combo_input.addClass(css.input_off)}elem.container.width(orgWidth);elem.button=$("
").addClass(css.button);elem.dropdown=$('');elem.clear_btn=$("
").html($("").addClass("spfont sp-close")).addClass(css.clear_btn).attr("title",msg.clear);if(!p.dropButton)elem.clear_btn.addClass(css.align_right);elem.element_box=$("
    ").addClass(css.element_box);if(p.multiple&&p.multipleControlbar)elem.control=$("
    ").addClass(css.control_box);elem.result_area=$("
    ").addClass(css.re_area);if(p.pagination)elem.navi=$("
    ").addClass("sp_pagination").append("
      ");elem.results=$("
        ").addClass(css.results);var namePrefix="_text",input_id=elem.combo_input.attr("id")||elem.combo_input.attr("name"),input_name=elem.combo_input.attr("name")||"selectPage",hidden_name=input_name,hidden_id=input_id;elem.hidden=$('').attr({name:hidden_name,id:hidden_id}).val("");elem.combo_input.attr({name:typeof input.data("name")!=="undefined"?input.data("name"):input_name+namePrefix,id:input_id+namePrefix});elem.hidden.attr("data-rule",elem.combo_input.data("rule")||"");elem.combo_input.attr("novalidate","novalidate");elem.container.append(elem.hidden);if(p.dropButton){elem.container.append(elem.button);elem.button.append(elem.dropdown)}$(document.body).append(elem.result_area);elem.result_area.append(elem.results);if(p.pagination)elem.result_area.append(elem.navi);if(p.multiple){if(p.multipleControlbar){elem.control.append('');elem.control.append('');elem.control.append('');elem.control_text=$("

        ");elem.control.append(elem.control_text);elem.result_area.prepend(elem.control)}elem.container.addClass("sp_container_combo");elem.combo_input.addClass("sp_combo_input").before(elem.element_box);var li=$("

      • ").addClass("input_box");li.append(elem.combo_input);elem.element_box.append(li);if(elem.combo_input.attr("placeholder"))elem.combo_input.attr("placeholder_bak",elem.combo_input.attr("placeholder"))}this.elem=elem};SelectPage.prototype.setButtonAttrDefault=function(){if(this.option.dropButton)this.elem.button.attr("title",this.message.close_btn)};SelectPage.prototype.setInitRecord=function(refresh){var self=this,p=self.option,el=self.elem,key="";if($.type(el.combo_input.data("init"))!="undefined")p.initRecord=String(el.combo_input.data("init"));if(!refresh&&!p.initRecord&&el.combo_input.val())p.initRecord=el.combo_input.val();el.combo_input.val("");if(!refresh)el.hidden.val(p.initRecord);key=refresh&&el.hidden.val()?el.hidden.val():p.initRecord;if(key){if(typeof p.data==="object"){var data=new Array;var keyarr=key.split(",");$.each(keyarr,function(index,row){for(var i=0;i1)data=[data[0]];self.afterInit(self,data)}else{var _paramsFunc=p.params,_params={},searchKey=p.searchField;var _orgParams={searchTable:p.dbTable,searchKey:p.keyField,searchValue:key,orderBy:p.orderBy,showField:p.showField,keyField:p.keyField,keyValue:key,searchField:p.searchField};if(_paramsFunc){var result=$.isFunction(_paramsFunc)?_paramsFunc(self):_paramsFunc;if(result&&$.isPlainObject(result)){_params=$.extend({},_orgParams,result)}else{_params=_orgParams}}else{_params=_orgParams}$.ajax({dataType:"json",type:"POST",url:p.data,data:_params,success:function(json){var d=null;if(p.eAjaxSuccess&&$.isFunction(p.eAjaxSuccess))d=p.eAjaxSuccess(json);self.afterInit(self,d.list)},error:function(jqXHR,textStatus,errorThrown){self.ajaxErrorNotify(self,errorThrown)}})}}};SelectPage.prototype.afterInit=function(self,data){if(!data||$.isArray(data)&&data.length===0)return;if(!$.isArray(data))data=[data];var p=self.option,css=self.css_class;self.data=data;if(p.multiple){self.prop.init_set=true;self.clearAll(self);$.each(data,function(i,row){var value=row[p.keyField];var text=row[p.showField];var item={text:text,value:value};if(!self.isAlreadySelected(self,item))self.addNewTag(self,row,item)});self.tagValuesSet(self);self.inputResize(self);self.elem.hidden.blur();self.prop.init_set=false}else{var row=data[0];var value=row[p.keyField];var text=row[p.showField];self.elem.combo_input.val(text);self.elem.hidden.val(value);self.prop.prev_value=text;self.prop.selected_text=text;if(p.selectOnly){self.elem.combo_input.attr("title",self.message.select_ok).removeClass(css.select_ng).addClass(css.select_ok)}self.putClearButton()}};SelectPage.prototype.eDropdownButton=function(){var self=this;if(self.option.dropButton){self.elem.button.mouseup(function(ev){ev.stopPropagation();if(self.elem.result_area.is(":hidden")&&!self.elem.combo_input.prop("disabled")){self.elem.combo_input.focus()}else self.hideResults(self)})}};SelectPage.prototype.eInput=function(){var self=this,p=self.option,el=self.elem,msg=self.message;var showList=function(){self.prop.page_move=false;self.suggest(self);self.setCssFocusedInput(self)};el.combo_input.keyup(function(e){self.processKey(self,e)}).keydown(function(e){self.processControl(self,e)}).focus(function(e){if(el.result_area.is(":hidden")){e.stopPropagation();self.prop.first_show=true;showList()}});el.container.on("click.SelectPage","div."+self.css_class.clear_btn,function(e){e.stopPropagation();if(!self.disabled(self)){self.clearAll(self,true);self.elem.hidden.change();if(p.eClear&&$.isFunction(p.eClear))p.eClear(self)}});el.result_area.on("mousedown.SelectPage",function(e){e.stopPropagation()});if(p.multiple){if(p.multipleControlbar){el.control.find(".sp_select_all").on("click.SelectPage",function(e){self.selectAllLine(self)}).hover(function(){el.control_text.html(msg.select_all)},function(){el.control_text.html("")});el.control.find(".sp_unselect_all").on("click.SelectPage",function(e){self.unSelectAllLine(self)}).hover(function(){el.control_text.html(msg.unselect_all)},function(){el.control_text.html("")});el.control.find(".sp_clear_all").on("click.SelectPage",function(e){self.clearAll(self,true)}).hover(function(){el.control_text.html(msg.clear_all)},function(){el.control_text.html("")})}el.element_box.on("click.SelectPage",function(e){var srcEl=e.target||e.srcElement;if($(srcEl).is("ul"))el.combo_input.focus()});el.element_box.on("click.SelectPage","span.tag_close",function(){var li=$(this).closest("li"),data=li.data("dataObj");self.removeTag(self,li);showList();if(p.eTagRemove&&$.isFunction(p.eTagRemove))p.eTagRemove([data])});self.inputResize(self)}};SelectPage.prototype.eWhole=function(){var self=this,css=self.css_class;var cleanContent=function(obj){obj.elem.combo_input.val("");if(!obj.option.multiple)obj.elem.hidden.val("");obj.prop.selected_text=""};$(document.body).off("mousedown.selectPage").on("mousedown.selectPage",function(e){var ele=e.target||e.srcElement;var sp=$(ele).closest("div."+css.container);$("div."+css.container+"."+css.container_open).each(function(){if(this==sp[0])return;var $this=$(this),d=$this.find("input."+css.input).data(SelectPage.dataKey);if(!d.elem.combo_input.val()&&d.elem.hidden.val()&&!d.option.multiple){d.prop.current_page=1;cleanContent(d);d.hideResults(d);return true}if(d.elem.results.find("li").not("."+css.message_box).length){if(d.option.autoFillResult){if(d.elem.hidden.val())d.hideResults(d);else if(d.elem.results.find("li.sp_over").length){d.selectCurrentLine(d,true)}else if(d.option.autoSelectFirst){d.nextLine(d);d.selectCurrentLine(d,true)}else d.hideResults(d)}else d.hideResults(d)}else{if(d.option.noResultClean)cleanContent(d);else{if(!d.option.multiple)d.elem.hidden.val("")}d.hideResults(d)}})})};SelectPage.prototype.eResultList=function(){var self=this,css=this.css_class;self.elem.results.children("li").hover(function(){if(self.prop.key_select){self.prop.key_select=false;return}if(!$(this).hasClass(css.selected)&&!$(this).hasClass(css.message_box)){$(this).addClass(css.select);self.setCssFocusedResults(self)}},function(){$(this).removeClass(css.select)}).click(function(e){if(self.prop.key_select){self.prop.key_select=false;return}e.preventDefault();e.stopPropagation();if(!$(this).hasClass(css.selected))self.selectCurrentLine(self,false)})};SelectPage.prototype.eScroll=function(){var self=this,css=this.css_class;$(window).on("scroll.SelectPage",function(e){$("div."+css.container+"."+css.container_open).each(function(){var $this=$(this),d=$this.find("input."+css.input).data(SelectPage.dataKey),offset=d.elem.result_area.offset(),screenScrollTop=$(window).scrollTop(),docHeight=$(document).height(),viewHeight=$(window).height(),listHeight=d.elem.result_area.outerHeight(),listBottom=offset.top+listHeight,hasOverflow=docHeight>viewHeight,down=d.elem.result_area.hasClass("shadowDown");if(hasOverflow){if(down){if(listBottom>viewHeight+screenScrollTop)d.calcResultsSize(d)}else{if(offset.top '+msg+"
      • ";self.elem.results.empty().append(msgLi).show();self.calcResultsSize(self);self.setOpenStatus(self,true);if(self.elem.control)self.elem.control.hide();if(self.option.pagination)self.elem.navi.hide()};SelectPage.prototype.scrollWindow=function(self,enforce){var current_result=self.getCurrentLine(self),target_top=current_result&&!enforce?current_result.offset().top:self.elem.container.offset().top,target_size;self.prop.size_li=self.elem.results.children("li:first").outerHeight();target_size=self.prop.size_li;var gap,client_height=$(window).height(),scroll_top=$(window).scrollTop(),scroll_bottom=scroll_top+client_height-target_size;if(current_result.length){if(target_topclient_height){gap=target_top-scroll_top}else if(target_top>scroll_bottom){gap=target_top-scroll_bottom}else return}else if(target_top-1&&self.elem.result_area.is(":visible")||$.inArray(e.keyCode,[13,9])>-1&&self.getCurrentLine(self)){e.preventDefault();e.stopPropagation();e.cancelBubble=true;e.returnValue=false;switch(e.keyCode){case 37:if(e.shiftKey)self.firstPage(self);else self.prevPage(self);break;case 38:self.prop.key_select=true;self.prevLine(self);break;case 39:if(e.shiftKey)self.lastPage(self);else self.nextPage(self);break;case 40:if(self.elem.results.children("li").length){self.prop.key_select=true;self.nextLine(self)}else self.suggest(self);break;case 9:self.prop.key_paging=true;self.selectCurrentLine(self,true);break;case 13:self.selectCurrentLine(self,true);break;case 27:self.prop.key_paging=true;self.hideResults(self);break}}};SelectPage.prototype.abortAjax=function(self){if(self.prop.xhr){self.prop.xhr.abort();self.prop.xhr=false}};SelectPage.prototype.suggest=function(self){var q_word,val=$.trim(self.elem.combo_input.val());if(self.option.multiple)q_word=val;else{if(val&&val===self.prop.selected_text)q_word="";else q_word=val}q_word=q_word.split(self.option.separator);if(self.option.eOpen&&$.isFunction(self.option.eOpen))self.option.eOpen.call(self);self.abortAjax(self);var which_page_num=self.prop.current_page||1;if(typeof self.option.data=="object")self.searchForJson(self,q_word,which_page_num);else self.searchForDb(self,q_word,which_page_num)};SelectPage.prototype.setLoading=function(self){if(self.elem.results.html()===""){self.setOpenStatus(self,true)}};SelectPage.prototype.searchForDb=function(self,q_word,which_page_num){var p=self.option;if(!p.eAjaxSuccess||!$.isFunction(p.eAjaxSuccess))self.hideResults(self);var _paramsFunc=p.params,_params={},searchKey=p.searchField;if(q_word.length&&q_word[0]&&q_word.join(self.option.separator)!==self.prop.prev_value)which_page_num=1;var _orgParams={q_word:q_word,pageNumber:which_page_num,pageSize:p.pageSize,andOr:p.andOr,orderBy:p.orderBy,searchTable:p.dbTable,showField:self.option.showField,keyField:self.option.keyField,searchField:self.option.searchField};if(p.orderBy!==false)_orgParams.orderBy=p.orderBy;_orgParams[searchKey]=q_word[0];if(_paramsFunc){var result=$.isFunction(_paramsFunc)?_paramsFunc(self):_paramsFunc;if(result&&$.isPlainObject(result)){_params=$.extend({},_orgParams,result)}else{_params=_orgParams}}else{_params=_orgParams}self.prop.xhr=$.ajax({dataType:"json",url:p.data,type:"POST",data:_params,success:function(returnData){if(!returnData||!$.isPlainObject(returnData)){self.hideResults(self);self.ajaxErrorNotify(self,errorThrown);return}var data={},json={};try{data=p.eAjaxSuccess(returnData);json.originalResult=data.list;json.cnt_whole=data.totalRow}catch(e){self.showMessage(self,self.message.ajax_error);return}if(self.elem.navi){$(self.elem.navi).toggleClass("hide",json.cnt_whole<=json.originalResult.length)}json.candidate=[];json.keyField=[];if(typeof json.originalResult!="object"){self.prop.xhr=null;self.notFoundSearch(self);return}json.cnt_page=json.originalResult.length;for(var i=0;i ');pagebar.append('
      • ');pagebar.append('
      • '+updatePageInfo()+"
      • ");pagebar.append('
      • ');pagebar.append('
      • ');pagebar.show()}else{pagebar.find("li.pageInfoBox a").html(updatePageInfo())}};var pagebar=self.elem.navi.find("ul"),last_page=Math.ceil(cnt_whole/self.option.pageSize);if(last_page===0)page_num=0;else{if(last_page1)self.ePaging()};SelectPage.prototype.displayResults=function(self,json,is_query){var p=self.option,el=self.elem;el.results.hide().empty();if(p.multiple&&$.type(p.maxSelectLimit)==="number"&&p.maxSelectLimit>0){var selectedSize=el.element_box.find("li.selected_tag").length;if(selectedSize>0&&selectedSize>=p.maxSelectLimit){var msg=self.message.max_selected;self.showMessage(self,msg.replace(self.template.msg.maxSelectLimit,p.maxSelectLimit));return}}if(json.candidate.length){var arr_candidate=json.candidate,arr_primary_key=json.keyField,keystr=el.hidden.val(),keyArr=keystr?keystr.split(","):new Array,itemText="";for(var i=0;i").html(itemText).attr({pkey:arr_primary_key[i],index:i});if(!p.formatItem)list.attr("title",itemText);if($.inArray(arr_primary_key[i].toString(),keyArr)!==-1){list.addClass(self.css_class.selected)}list.data("dataObj",json.originalResult[i]);el.results.append(list)}}else{var li='
      • '+self.message.not_found+"
      • ";el.results.append(li)}el.results.show();if(p.multiple&&p.multipleControlbar)el.control.show();if(p.pagination)el.navi.show();self.calcResultsSize(self);self.setOpenStatus(self,true);self.eResultList();self.eScroll();if(is_query&&json.candidate.length&&p.autoSelectFirst)self.nextLine(self)};SelectPage.prototype.calcResultsSize=function(self){var p=self.option,el=self.elem;var rePosition=function(){if(el.container.css("position")==="static"){var offset=el.combo_input.offset();el.result_area.css({top:offset.top+el.combo_input.outerHeight()+"px",left:offset.left+"px"})}else{if(!p.pagination){var itemHeight=el.results.find("li:first").outerHeight(true),listHeight=itemHeight*p.listSize;el.results.css({"max-height":listHeight,"overflow-y":"auto"})}var docWidth=$(document).width(),docHeight=$(document).height(),viewHeight=$(window).height(),offset=el.container.offset(),screenScrollTop=$(window).scrollTop(),listWidth=el.result_area.outerWidth(),listHeight=el.result_area.outerHeight(),defaultLeft=offset.left,inputHeight=el.container.outerHeight(),left=offset.left+listWidth>docWidth?defaultLeft-(listWidth-el.container.outerWidth()):defaultLeft,screenTop=offset.top,top=0,dist=5,listBottom=screenTop+inputHeight+listHeight+dist,listTop=screenTop+listHeight+dist,hasOverflow=docHeight>viewHeight;if(screenTop-screenScrollTop-dist>listHeight&&(hasOverflow&&listBottom>viewHeight+screenScrollTop)||!hasOverflow&&listBottom>viewHeight&&screenTop>=listTop){top=offset.top-listHeight-dist;el.result_area.removeClass("shadowUp shadowDown").addClass("shadowUp")}else{top=offset.top+(p.multiple?el.container.outerHeight():inputHeight);el.result_area.removeClass("shadowUp shadowDown").addClass("shadowDown");top+=dist}return{top:top+"px",left:left+"px"}}};if(el.result_area.is(":visible")){el.result_area.css(rePosition())}else{var pss=rePosition();el.result_area.css(pss).show(1,function(){var repss=rePosition();if(pss.top!==repss.top||pss.left!==repss.left)el.result_area.css(repss)})}};SelectPage.prototype.hideResults=function(self){if(self.prop.key_paging){self.scrollWindow(self,true);self.prop.key_paging=false}self.setCssFocusedInput(self);if(self.option.autoFillResult){}self.elem.results.empty();self.elem.result_area.hide();self.setOpenStatus(self,false);$(window).off("scroll.SelectPage");self.abortAjax(self);self.setButtonAttrDefault()};SelectPage.prototype.disabled=function(self,disabled){var p=self.option,el=self.elem;if($.type(disabled)==="undefined")return el.combo_input.prop("disabled");if($.type(disabled)==="boolean"){el.combo_input.prop("disabled",disabled);if(disabled)el.container.addClass(self.css_class.disabled);else el.container.removeClass(self.css_class.disabled)}};SelectPage.prototype.firstPage=function(self){if(self.prop.current_page>1){self.prop.current_page=1;self.prop.page_move=true;self.suggest(self)}};SelectPage.prototype.prevPage=function(self){if(self.prop.current_page>1){self.prop.current_page--;self.prop.page_move=true;self.suggest(self)}};SelectPage.prototype.nextPage=function(self){if(self.prop.current_page0&&p.maxSelectLimit===self.elem.element_box.find("li.selected_tag").length){return false}});if(p.eSelect&&$.isFunction(p.eSelect))p.eSelect(jsonarr,self);self.afterAction(self,true)};SelectPage.prototype.unSelectAllLine=function(self){var p=self.option,size=self.elem.results.find("li").length,ds=[];self.elem.results.find("li").each(function(i,row){var key=$(row).attr("pkey");var tag=self.elem.element_box.find('li.selected_tag[itemvalue="'+key+'"]');if(tag.length)ds.push(tag.data("dataObj"));self.removeTag(self,tag)});self.afterAction(self,true);if(p.eTagRemove&&$.isFunction(p.eTagRemove))p.eTagRemove(ds)};SelectPage.prototype.clearAll=function(self,open){var p=self.option,ds=[];if(p.multiple){self.elem.element_box.find("li.selected_tag").each(function(i,row){ds.push($(row).data("dataObj"));row.remove()});self.elem.element_box.find("li.selected_tag").remove()}self.reset(self);self.afterAction(self,open);if(p.multiple){if(p.eTagRemove&&$.isFunction(p.eTagRemove))p.eTagRemove(ds)}else self.elem.clear_btn.remove()};SelectPage.prototype.reset=function(self){self.elem.combo_input.val("");self.elem.hidden.val("");self.prop.prev_value="";self.prop.selected_text="";self.prop.current_page=1};SelectPage.prototype.getCurrentLine=function(self){if(self.elem.result_area.is(":hidden"))return false;var obj=self.elem.results.find("li."+self.css_class.select);if(obj.length)return obj;else return false};SelectPage.prototype.isAlreadySelected=function(self,item){var isExist=false;if(item.value){var keys=self.elem.hidden.val();if(keys){var karr=keys.split(",");if(karr&&karr.length&&$.inArray(item.value,karr)!=-1)isExist=true}}return isExist};SelectPage.prototype.addNewTag=function(self,data,item){if(!self.option.multiple||!data||!item)return;var tmp=self.template.tag.content,tag;tmp=tmp.replace(self.template.tag.textKey,item.text);tmp=tmp.replace(self.template.tag.valueKey,item.value);tag=$(tmp);tag.data("dataObj",data);if(self.elem.combo_input.prop("disabled"))tag.find("span.tag_close").hide();self.elem.combo_input.closest("li").before(tag)};SelectPage.prototype.removeTag=function(self,item){var key=$(item).attr("itemvalue");var keys=self.elem.hidden.val();if($.type(key)!="undefined"&&keys){var keyarr=keys.split(","),index=$.inArray(key.toString(),keyarr);if(index!=-1){keyarr.splice(index,1);self.elem.hidden.val(keyarr.toString()).trigger("change")}}$(item).remove();self.inputResize(self)};SelectPage.prototype.tagValuesSet=function(self){if(!self.option.multiple)return;var tags=self.elem.element_box.find("li.selected_tag");if(tags&&tags.length){var result=new Array;$.each(tags,function(i,li){var v=$(li).attr("itemvalue");if($.type(v)!=="undefined")result.push(v)});if(result.length){self.elem.hidden.val(result.join(",")).trigger("change")}}};SelectPage.prototype.inputResize=function(self){if(!self.option.multiple)return;var width="",inputLi=self.elem.combo_input.closest("li");var setDefaultSize=function(self,inputLi){inputLi.removeClass("full_width");var minimumWidth=self.elem.combo_input.val().length+1,width=minimumWidth*.75+"em";self.elem.combo_input.css("width",width).removeAttr("placeholder")};if(self.elem.element_box.find("li.selected_tag").length===0){if(!inputLi.hasClass("full_width"))inputLi.addClass("full_width");if(self.elem.combo_input.attr("placeholder_bak")){self.elem.combo_input.attr("placeholder",self.elem.combo_input.attr("placeholder_bak")).removeAttr("style")}}else setDefaultSize(self,inputLi)};SelectPage.prototype.nextLine=function(self){var obj=self.getCurrentLine(self),idx;if(!obj)idx=-1;else{idx=self.elem.results.children("li").index(obj);obj.removeClass(self.css_class.select)}idx++;if(idx-1){var prev=self.elem.results.children("li").eq(idx);prev.addClass(self.css_class.select);self.setCssFocusedResults(self)}else self.setCssFocusedInput(self);self.scrollWindow(self,false)};function Plugin(option){return this.each(function(){var $this=$(this),data=$this.data(SelectPage.dataKey),params=$.extend({},defaults,$this.data(),data&&data.option,typeof option==="object"&&option);if(!data)$this.data(SelectPage.dataKey,data=new SelectPage(this,params))})}function getPlugin(obj){return $(obj).closest("div.sp_container").find("input.sp_input")}function ClearSelected(){return this.each(function(){var $this=getPlugin(this),data=$this.data(SelectPage.dataKey);if(data){data.prop.init_set=true;data.clearAll(data);data.prop.init_set=false}})}function SelectedRefresh(){return this.each(function(){var $this=getPlugin(this),data=$this.data(SelectPage.dataKey);if(data&&data.elem.hidden.val())data.setInitRecord(true)})}function ModifyDataSource(data){return this.each(function(){if(data&&$.isArray(data)){var $this=getPlugin(this),plugin=$this.data(SelectPage.dataKey);if(plugin){plugin.clearAll(plugin);plugin.option.data=data}}})}function PluginDisabled(disabled){var status=false;this.each(function(){var $this=getPlugin(this),plugin=$this.data(SelectPage.dataKey);if(plugin){if($.type(disabled)!=="undefined")plugin.disabled(plugin,disabled);else status=plugin.disabled(plugin)}});return status}function GetInputText(){var str="";this.each(function(){var $this=getPlugin(this),data=$this.data(SelectPage.dataKey);if(data){if(data.option.multiple){var tags=[];data.elem.element_box.find("li.selected_tag").each(function(i,tag){tags.push($(tag).text())});str+=tags.toString()}else{str+=data.elem.combo_input.val()}}});return str}function GetSelectedData(){var results=[];this.each(function(){var $this=getPlugin(this),data=$this.data(SelectPage.dataKey);if(data){if(data.option.multiple){data.elem.element_box.find("li.selected_tag").each(function(i,tag){results.push($(tag).data("dataObj"))})}else{var selected=data.elem.combo_input.data("dataObj");if(selected)results.push(selected)}}});return results}var old=$.fn.selectPage;$.fn.selectPage=Plugin;$.fn.selectPage.Constructor=SelectPage;$.fn.selectPageClear=ClearSelected;$.fn.selectPageRefresh=SelectedRefresh;$.fn.selectPageData=ModifyDataSource;$.fn.selectPageDisabled=PluginDisabled;$.fn.selectPageText=GetInputText;$.fn.selectPageSelectedData=GetSelectedData;$.fn.selectPage.noConflict=function(){$.fn.selectPage=old;return this}})(window.jQuery);