From a4830fd639f5f095c57bb8054cc7573957111619 Mon Sep 17 00:00:00 2001 From: Terry Zeng Date: Thu, 7 Sep 2017 20:58:33 +0800 Subject: [PATCH] update --- selectpage.js | 56 ++++++++++++++++++++++++++--------------------- selectpage.min.js | 2 +- 2 files changed, 32 insertions(+), 26 deletions(-) diff --git a/selectpage.js b/selectpage.js index 09defcb..d5eecfa 100644 --- a/selectpage.js +++ b/selectpage.js @@ -2,7 +2,7 @@ * @summary SelectPage * @desc 基于jQuery及使用Bootstrap环境开发的,下拉列表带输入快速查找及结果分页展示的多功能选择器 * @file selectpage.js - * @version 2.5 + * @version 2.6 * @author TerryZeng * @contact https://terryz.github.io/ * @license MIT License @@ -119,6 +119,10 @@ * 2017.09.07(v2.5) * 修复多选模式下,初始化项目的显示文本没有使用formatItem回调进行格式化 * 修复ajax数据源模式下,输入查询关键字时,翻页始终为第一页的问题 + * 2017.09.07(v2.6) + * 修复单选模式下初始化项目的显示文本没有使用formatItem回调格式化的问题 + * 修复单选模式存在初始化项目时,再打开下拉列表时,仅显示匹配的项目一条数据的问题 + * 修复多选模式下,动态修改选中值selectPageRefresh功能无效 */ ;(function($){ "use strict"; @@ -314,7 +318,7 @@ /** * 插件版本号 */ - SelectPage.version = '2.5'; + SelectPage.version = '2.6'; /** * 插件缓存内部对象的KEY */ @@ -365,7 +369,6 @@ if(!option.pagination) option.pageSize = 200; if($.type(option.listSize) !== 'number' || option.listSize < 0) option.listSize = 10; - if($.type(option.init) != 'undefined') option.initRecord = String(option.init); this.option = option; }; @@ -694,15 +697,6 @@ id: input_id }); - //若在输入框中放入了初始化值,则将它放到隐藏域中进行选中项目初始化 - //若输入框设置了初始值,同时又设置了data-init属性,那么以data-init属性为优先选择 - if(!option.initRecord){ - if($(elem.combo_input).val()){ - option.initRecord = $(elem.combo_input).val(); - $(elem.combo_input).val(''); - } - }else $(elem.combo_input).val(''); - // 2. DOM内容放置 $(elem.container).append(elem.button).append(elem.result_area).append(elem.hidden); $(elem.button).append(elem.dropdown); @@ -758,6 +752,13 @@ */ SelectPage.prototype.setInitRecord = function(refresh) { var self = this; + if($.type($(self.elem.combo_input).data('init')) != 'undefined') + self.option.initRecord = String($(self.elem.combo_input).data('init')); + //若在输入框中放入了初始化值,则将它放到隐藏域中进行选中项目初始化 + //若输入框设置了初始值,同时又设置了data-init属性,那么以data-init属性为优先选择 + if(!self.option.initRecord) + if($(self.elem.combo_input).val()) self.option.initRecord = $(self.elem.combo_input).val(); + $(self.elem.combo_input).val(''); if((refresh && $(self.elem.hidden).val()) || $.type(self.option.initRecord) === 'string'){ // 初始的KEY值放入隐藏域 if(!refresh) $(self.elem.hidden).val(self.option.initRecord); @@ -784,7 +785,7 @@ data: { searchTable: self.option.dbTable, searchKey: self.option.keyField, - searchValue: self.option.initRecord + searchValue: refresh ? $(self.elem.hidden).val() : self.option.initRecord }, success: function(json) { var d = null; @@ -808,27 +809,31 @@ SelectPage.prototype.afterInit = function(self, data) { if(!data) return; if(!$.isArray(data)) data = [data]; + + var getText = function(row){ + var text = row[self.option.showField]; + if(self.option.formatItem && $.isFunction(self.option.formatItem)){ + try{ + text = self.option.formatItem(row); + }catch(e){} + } + return text; + }; if(self.option.multiple){//多选模式初始化 - $(self.elem.combo_input).val(''); + self.clearAll(self); $.each(data,function(i,row){ - var text = row[self.option.showField]; - if(self.option.formatItem && $.isFunction(self.option.formatItem)){ - try{ - text = self.option.formatItem(row); - }catch(e){} - } - var item = {text:text,value:row[self.option.keyField]}; + var item = {text:getText(row),value:row[self.option.keyField]}; if(!self.isAlreadySelected(self,item)) self.addNewTag(self,item); }); self.tagValuesSet(self); self.inputResize(self); }else{//单选模式初始化 var row = data[0]; - $(self.elem.combo_input).val(row[self.option.showField]); + $(self.elem.combo_input).val(getText(row)); $(self.elem.hidden).val(row[self.option.keyField]); - self.prop.prev_value = row[self.option.showField]; - self.prop.selected_text = row[self.option.showField]; + self.prop.prev_value = getText(row); + self.prop.selected_text = getText(row); if (self.option.selectOnly) { $(self.elem.combo_input).attr('title', self.message.select_ok).removeClass(self.css_class.select_ng).addClass(self.css_class.select_ok); } @@ -2123,7 +2128,8 @@ * @returns */ function getPlugin(obj){ - return $(obj).siblings('input.sp_input'); + var container = $(obj).closest('div.sp_container'); + return $('input.sp_input',container); } /** diff --git a/selectpage.min.js b/selectpage.min.js index d13600b..ae80506 100644 --- a/selectpage.min.js +++ b/selectpage.min.js @@ -1 +1 @@ -(function(g){var e={data:undefined,lang:"cn",multiple:false,pagination:true,listSize:10,multipleControlbar:true,maxSelectLimit:0,selectToCloseList:true,initRecord:undefined,dbTable:"tbl",keyField:"id",showField:"name",searchField:undefined,andOr:"AND",orderBy:undefined,pageSize:10,params:undefined,formatItem:undefined,focusDropList:true,autoSelectFirst:true,autoFillResult:true,noResultClean:true,selectOnly:false,inputDelay:0.5,eSelect:undefined,eAjaxSuccess:undefined,eTagRemove:undefined};var h=function(k,l){this.setOption(l);this.setLanguage();this.setCssClass();this.setProp();this.setElem(k,l);this.setButtonAttrDefault();this.setInitRecord();this.eDropdownButton();this.eInput();this.eWhole()};h.version="2.5";h.dataKey="selectPageObject";h.objStatusKey="selectPage-self-mark";h.objStatusIndex="selectPage-self-index";h.prototype.setOption=function(m){m.searchField=(m.searchField===undefined)?m.showField:m.searchField;m.andOr=m.andOr.toUpperCase();if(m.andOr!=="AND"&&m.andOr!=="OR"){m.andOr="AND"}var k=["searchField"];for(var l=0;l#item_text#×',textKey:"#item_text#",valueKey:"#item_value#"}}};h.prototype.setElem=function(m,q){var l={};var o=g(m).outerWidth();l.combo_input=g(m).attr({"autocomplete":"off"}).addClass(this.css_class.input).wrap("
");if(q.selectOnly){g(l.combo_input).prop("readonly",true)}l.container=g(l.combo_input).parent().addClass(this.css_class.container);g(l.container).width(o);l.button=g("
").addClass(this.css_class.button);l.dropdown=g('');l.clear_btn=g("
").append("×").addClass(this.css_class.clear_btn).attr("title","清除内容");l.element_box=g("
    ").addClass(this.css_class.element_box);if(q.multiple&&q.multipleControlbar){l.control=g("
    ").addClass(this.css_class.control_box)}l.result_area=g("
    ").addClass(this.css_class.re_area);if(q.pagination){l.navi=g("
    ").addClass("pagination").append("
      ")}l.results=g("
        ").addClass(this.css_class.results);var k="_text";var s=(g(l.combo_input).attr("id")!==undefined)?g(l.combo_input).attr("id"):g(l.combo_input).attr("name");var p=(g(l.combo_input).attr("name")!==undefined)?g(l.combo_input).attr("name"):"selectPage";var r=p,n=s;if(p.match(/\]$/)){p=p.replace(/\]?$/,k)}else{p+=k}if(s.match(/\]$/)){s=s.replace(/\]?$/,k)}else{s+=k}l.hidden=g('').attr({name:r,id:n}).val("");g(l.combo_input).attr({name:p,id:s});if(!q.initRecord){if(g(l.combo_input).val()){q.initRecord=g(l.combo_input).val();g(l.combo_input).val("")}}else{g(l.combo_input).val("")}g(l.container).append(l.button).append(l.result_area).append(l.hidden);g(l.button).append(l.dropdown);g(l.result_area).append(l.results);if(q.pagination){g(l.result_area).append(l.navi)}if(q.multiple){if(q.multipleControlbar){g(l.control).append('');g(l.control).append('');g(l.control).append('');g(l.result_area).prepend(l.control)}g(l.container).addClass("sp_container_combo");g(l.combo_input).addClass("sp_combo_input").before(g(l.element_box));var t=g("
      • ").addClass("input_box");g(t).append(g(l.combo_input));g(l.element_box).append(g(t));if(g(l.combo_input).attr("placeholder")){g(l.combo_input).attr("placeholder_bak",g(l.combo_input).attr("placeholder"))}}this.elem=l};h.prototype.setButtonAttrDefault=function(){g(this.elem.button).attr("title",this.message.get_all_btn);g(this.elem.button).attr("title",this.message.close_btn)};h.prototype.setInitRecord=function(l){var k=this;if((l&&g(k.elem.hidden).val())||g.type(k.option.initRecord)==="string"){if(!l){g(k.elem.hidden).val(k.option.initRecord)}if(typeof k.option.data==="object"){var n=new Array();var m=l?g(k.elem.hidden).val().split(","):k.option.initRecord.split(",");g.each(m,function(o,q){for(var p=0;p1){n=null}k.afterInit(k,n)}else{g.ajax({dataType:"json",type:"POST",url:k.option.data,data:{searchTable:k.option.dbTable,searchKey:k.option.keyField,searchValue:k.option.initRecord},success:function(o){var p=null;if(k.option.eAjaxSuccess&&g.isFunction(k.option.eAjaxSuccess)){p=k.option.eAjaxSuccess(o)}k.afterInit(k,p.list)},error:function(o,q,p){k.ajaxErrorNotify(k,p)}})}}};h.prototype.afterInit=function(k,l){if(!l){return}if(!g.isArray(l)){l=[l]}if(k.option.multiple){g(k.elem.combo_input).val("");g.each(l,function(n,r){var q=r[k.option.showField];if(k.option.formatItem&&g.isFunction(k.option.formatItem)){try{q=k.option.formatItem(r)}catch(p){}}var o={text:q,value:r[k.option.keyField]};if(!k.isAlreadySelected(k,o)){k.addNewTag(k,o)}});k.tagValuesSet(k);k.inputResize(k)}else{var m=l[0];g(k.elem.combo_input).val(m[k.option.showField]);g(k.elem.hidden).val(m[k.option.keyField]);k.prop.prev_value=m[k.option.showField];k.prop.selected_text=m[k.option.showField];if(k.option.selectOnly){g(k.elem.combo_input).attr("title",k.message.select_ok).removeClass(k.css_class.select_ng).addClass(k.css_class.select_ok)}k.putClearButton()}};h.prototype.eDropdownButton=function(){var k=this;g(k.elem.button).mouseup(function(l){l.stopPropagation();if(g(k.elem.result_area).is(":hidden")&&!g(k.elem.combo_input).prop("disabled")){g(k.elem.combo_input).focus()}else{k.hideResults(k)}}).mouseout()};h.prototype.eInput=function(){var l=this;var k=function(){l.prop.page_move=false;l.suggest(l);l.setCssFocusedInput(l)};g(l.elem.combo_input).keyup(function(m){l.processKey(l,m)}).focus(function(m){if(g(l.elem.result_area).is(":hidden")){m.stopPropagation();l.prop.first_show=true;k()}});g(l.elem.container).on("click.SelectPage","div."+l.css_class.clear_btn,function(m){m.stopPropagation();l.clearAll(l);g(l.elem.clear_btn).remove()});if(l.option.multiple){if(l.option.multipleControlbar){g(".sp_select_all",l.elem.control).on("click.SelectPage",function(m){l.selectAllLine(l)});g(".sp_unselect_all",l.elem.control).on("click.SelectPage",function(m){l.unselectAllLine(l)});g(".sp_clear_all",l.elem.control).on("click.SelectPage",function(m){l.clearAll(l)})}g(l.elem.element_box).on("click.SelectPage",function(n){var m=n.target||n.srcElement;if(g(m).is("ul")){g(l.elem.combo_input).focus()}});g(l.elem.element_box).on("click.SelectPage","span.tag_close",function(){var m=g(this).closest("li");l.removeTag(l,m);k();if(l.option.eTagRemove&&g.isFunction(l.option.eTagRemove)){l.option.eTagRemove(1)}});l.inputResize(l)}};h.prototype.eWhole=function(){var k=this;g(k.elem.container).mousedown(function(){var l=g("div.sp_container").index(this);var m=g(document.body).data(h.objStatusIndex);if(m!=undefined&&l!=m){g(document.body).data(h.objStatusKey,false)}else{g(document.body).data(h.objStatusKey,true)}g(document.body).data(h.objStatusIndex,l)});g(document).off("mousedown.selectPage").on("mousedown.selectPage",function(l){if(g(document.body).data(h.objStatusKey)){g(document.body).data(h.objStatusKey,false)}else{var m=function(n){g(n.elem.combo_input).val("");if(!n.option.multiple){g(n.elem.hidden).val("")}n.prop.selected_text=""};g("div."+k.css_class.container+"."+k.css_class.container_open).each(function(){var n=g("input."+k.css_class.input,this).data(h.dataKey);if(!g(n.elem.combo_input).val()&&g(n.elem.hidden).val()&&!n.option.multiple){n.prop.current_page=1;m(n);n.hideResults(n);return true}if(g("li",g(n.elem.results)).size()>0){if(n.option.autoFillResult){if(g("li.sp_selected",g(n.elem.results)).size()>0){n.hideResults(n)}else{if(g("li.sp_over",g(n.elem.results)).size()>0){if(g(n.elem.hidden).val()){n.hideResults(n)}else{n.selectCurrentLine(n,true)}}else{if(n.option.autoSelectFirst){if(g(n.elem.hidden).val()){n.hideResults(n)}else{n.nextLine(n);n.selectCurrentLine(n,true)}}else{n.hideResults(n)}}}}else{n.hideResults(n)}}else{if(n.option.noResultClean){m(n)}else{if(!n.option.multiple){g(n.elem.hidden).val("")}}n.hideResults(n)}})}})};h.prototype.eResultList=function(){var k=this;g(k.elem.results).children("li").mouseenter(function(){if(k.prop.key_select){k.prop.key_select=false;return}if(!g(this).hasClass(k.css_class.selected)&&!g(this).hasClass("sp_message_box")){g(this).addClass(k.css_class.select);k.setCssFocusedResults(k)}}).mouseleave(function(){g(this).removeClass(k.css_class.select)}).click(function(l){if(k.prop.key_select){k.prop.key_select=false;return}l.preventDefault();l.stopPropagation();if(!g(this).hasClass(k.css_class.selected)){k.selectCurrentLine(k,false)}})};h.prototype.ehNaviPaging=function(){var k=this;if(!k.option.pagination){return}g("li.csFirstPage",g(k.elem.navi)).off("click").on("click",function(l){l.preventDefault();k.firstPage(k)});g("li.csPreviousPage",g(k.elem.navi)).off("click").on("click",function(l){l.preventDefault();k.prevPage(k)});g("li.csNextPage",g(k.elem.navi)).off("click").on("click",function(l){l.preventDefault();k.nextPage(k)});g("li.csLastPage",g(k.elem.navi)).off("click").on("click",function(l){l.preventDefault();k.lastPage(k)})};h.prototype.ajaxErrorNotify=function(k,l){k.showMessage(k.message.ajax_error)};h.prototype.showMessage=function(k,m){if(!m){return}var l='
      • '+m+"
      • ";g(k.elem.results).empty().append(l);k.calcResultsSize(k);g(k.elem.container).addClass(k.css_class.container_open);g(k.elem.control).hide();if(k.option.pagination){g(k.elem.navi).hide()}};h.prototype.scrollWindow=function(s,p){var k=s.getCurrentLine(s);var r=(k&&!p)?k.offset().top:g(s.elem.container).offset().top;var m;s.prop.size_li=g(s.elem.results).children("li:first").outerHeight();m=s.prop.size_li;var o=g(window).height();var n=g(window).scrollTop();var l=n+o-m;var q;if(g(k).length){if(ro){q=r-n}else{if(r>l){q=r-l}else{return}}}else{if(r-1&&g(k.elem.result_area).is(":visible"))||(g.inArray(l.keyCode,[13,9])>-1&&k.getCurrentLine(k))){l.preventDefault();l.stopPropagation();l.cancelBubble=true;l.returnValue=false;switch(l.keyCode){case 37:if(l.shiftKey){k.firstPage(k)}else{k.prevPage(k)}break;case 38:k.prop.key_select=true;k.prevLine(k);break;case 39:if(l.shiftKey){k.lastPage(k)}else{k.nextPage(k)}break;case 40:if(g(k.elem.results).children("li").length){k.prop.key_select=true;k.nextLine(k)}else{k.suggest(k)}break;case 9:k.prop.key_paging=true;k.selectCurrentLine(k,true);break;case 13:k.selectCurrentLine(k,true);break;case 27:k.prop.key_paging=true;k.hideResults(k);break}}else{if(l.keyCode!=16){k.setCssFocusedInput(k)}k.inputResize(k);if(g.type(k.option.data)==="string"){k.prop.last_input_time=l.timeStamp;setTimeout(function(){if((l.timeStamp-k.prop.last_input_time)===0){k.checkValue(k)}},k.option.inputDelay*1000)}else{k.checkValue(k)}}};h.prototype.abortAjax=function(k){if(k.prop.xhr){k.prop.xhr.abort();k.prop.xhr=false}};h.prototype.suggest=function(l){var m;var n=g.trim(g(l.elem.combo_input).val());if(l.option.multiple){m=n}else{if(n&&n===l.prop.selected_text){m=""}else{m=n}}m=m.split(/[\s ]+/);l.abortAjax(l);l.setLoading(l);var k=l.prop.current_page>0?l.prop.current_page:1;if(typeof l.option.data=="object"){l.searchForJson(l,m,k)}else{l.searchForDb(l,m,k)}};h.prototype.setLoading=function(k){if(g(k.elem.results).html()===""){g(k.elem.container).addClass(k.css_class.container_open)}};h.prototype.searchForDb=function(n,q,l){if(!n.option.eAjaxSuccess&&g.isFunction(n.option.eAjaxSuccess)){n.hideResults(n)}var o=n.option.params;var m={};var r=n.option.searchField;if(q.length>0&&q[0]&&q[0]!==n.prop.prev_value){l=1}var p={q_word:q,pageNumber:l,pageSize:n.option.pageSize,andOr:n.option.andOr,orderBy:n.option.orderBy,searchTable:n.option.dbTable};p[r]=q[0];if(o&&g.isFunction(o)){var k=o();if(k&&g.isPlainObject(k)){m=g.extend({},p,k)}else{m=p}}else{m=p}n.prop.xhr=g.ajax({dataType:"json",url:n.option.data,type:"POST",data:m,success:function(v){if(!v||!g.isPlainObject(v)){n.hideResults(n);n.ajaxErrorNotify(n,errorThrown);return}var w;if(n.option.eAjaxSuccess&&g.isFunction(n.option.eAjaxSuccess)){w=n.option.eAjaxSuccess(v)}else{w=v}var u={};u.originalResult=w.list;u.cnt_whole=w.totalRow;u.candidate=[];u.keyField=[];if(typeof u.originalResult!="object"){n.prop.xhr=null;n.notFoundSearch(n);return}u.cnt_page=u.originalResult.length;for(var t=0;t0&&o[0]){l=true}m.displayResults(m,n,l)};h.prototype.setNavi=function(x,v,w,l){var m=function(H,E,y,D){if(g("li",g(E)).size()==0){g(E).empty();var A="",C=true;g.each(document.styleSheets,function(J,K){if(K&&K.href&&K.href.indexOf("font-awesome-3.2.1")!=-1){C=false;return false}});var F="fa fa-angle-double-left",I="fa fa-angle-left",z="fa fa-angle-right",B="fa fa-angle-double-right";if(!C){F="icon-step-backward";I="icon-backward";z="icon-forward";B="icon-step-forward"}if(y==1){A=" disabled "}g(E).append('
      • ');g(E).append('
      • ');var G="第 "+y+" 页(共"+D+"页)";g(E).append('
      • '+G+"
      • ");if(y==D){A=" disabled "}else{A=""}g(E).append('
      • ');g(E).append('
      • ')}};var s=g("ul",g(x.elem.navi));var q=Math.ceil(v/x.option.pageSize);if(q==0){l=0}else{if(q '+u+" ");var r="disabled";var o=g("li.csFirstPage",g(s));var p=g("li.csPreviousPage",g(s));var n=g("li.csNextPage",g(s));var t=g("li.csLastPage",g(s));if(l===1||l===0){if(!g(o).hasClass(r)){g(o).addClass(r)}if(!g(p).hasClass(r)){g(p).addClass(r)}}else{if(g(o).hasClass(r)){g(o).removeClass(r)}if(g(p).hasClass(r)){g(p).removeClass(r)}}if(l==q||q==0){if(!g(n).hasClass(r)){g(n).addClass(r)}if(!g(t).hasClass(r)){g(t).addClass(r)}}else{if(g(n).hasClass(r)){g(n).removeClass(r)}if(g(t).hasClass(r)){g(t).removeClass(r)}}if(q>1){x.ehNaviPaging()}};h.prototype.displayResults=function(v,u,n){g(v.elem.results).empty();if(v.option.multiple&&g.type(v.option.maxSelectLimit)==="number"&&v.option.maxSelectLimit>0){var l=g("li.selected_tag",v.elem.element_box).size();if(l>0&&l>=v.option.maxSelectLimit){v.showMessage(v,"最多只能选择 "+v.option.maxSelectLimit+" 个项目");return}}if(u.candidate.length>0){var t=u.candidate;var r=u.keyField;var k=g(v.elem.hidden).val();var w=k?k.split(","):new Array();for(var m=0;m").html(q).attr({pkey:r[m],title:q});if(g.inArray(r[m].toString(),w)!==-1){g(o).addClass(v.css_class.selected)}g(o).data("dataObj",u.originalResult[m]);g(v.elem.results).append(o)}}else{var s='
      • '+v.message.not_found+"
      • ";g(v.elem.results).append(s)}if(v.option.multiple&&v.option.multipleControlbar){g(v.elem.control).show()}if(v.option.pagination){g(v.elem.navi).show()}v.calcResultsSize(v);g(v.elem.container).addClass(v.css_class.container_open);v.eResultList();if(n&&u.candidate.length>0&&v.option.autoSelectFirst){v.nextLine(v)}};h.prototype.calcResultsSize=function(k){g(k.elem.result_area).show(1,function(){if(g(k.elem.container).css("position")==="static"){var v=g(k.elem.combo_input).offset();g(k.elem.result_area).css({top:v.top+g(k.elem.combo_input).outerHeight()+"px",left:v.left+"px"})}else{if(!k.option.pagination){var s=g("li:first",k.elem.results).outerHeight(true);var q=s*k.option.listSize;g(k.elem.results).css({"max-height":q,"overflow-y":"auto"})}var w=g(document).width();var A=g(document).height();var r=g(window).height();var v=g(k.elem.container).offset();var u=g(window).scrollTop();var z=g(k.elem.result_area).outerWidth();var q=g(k.elem.result_area).outerHeight();var m=k.option.multiple?-1:0;var l=g(k.elem.container).outerHeight();var p=(v.left+z)>w?-(z-g(k.elem.container).outerWidth()):m;var o=v.top;var y=0,x=5;var n=o+l+q+x;var t=A>r;if((t&&n>(r+u))||(!t&&n>r)){y=-(q+1)-x;g(k.elem.result_area).removeClass("shadowUp shadowDown").addClass("shadowUp")}else{y=k.option.multiple?g(k.elem.container).innerHeight()+1:g(k.elem.container).outerHeight();g(k.elem.result_area).removeClass("shadowUp shadowDown").addClass("shadowDown");y+=x}g(k.elem.result_area).css({top:y+"px",left:p+"px"})}})};h.prototype.hideResults=function(k){if(k.prop.key_paging){k.scrollWindow(k,true);k.prop.key_paging=false}k.setCssFocusedInput(k);if(k.option.autoFillResult){}g(k.elem.results).empty();g(k.elem.result_area).hide();g(k.elem.container).removeClass(k.css_class.container_open);k.abortAjax(k);k.setButtonAttrDefault()};h.prototype.firstPage=function(k){if(k.prop.current_page>1){k.prop.current_page=1;k.prop.page_move=true;k.suggest(k)}};h.prototype.prevPage=function(k){if(k.prop.current_page>1){k.prop.current_page--;k.prop.page_move=true;k.suggest(k)}};h.prototype.nextPage=function(k){if(k.prop.current_page0&&k.option.maxSelectLimit===g("li.selected_tag",k.elem.element_box).size()){return false}});if(k.option.eSelect&&g.isFunction(k.option.eSelect)){k.option.eSelect(l)}k.afterAction(k)};h.prototype.unselectAllLine=function(k){var l=g("li",k.elem.results).size();g("li",k.elem.results).each(function(o,p){var n=g(p).attr("pkey");var m=g('li.selected_tag[itemvalue="'+n+'"]',k.elem.element_box);k.removeTag(k,m)});k.afterAction(k);if(k.option.eTagRemove&&g.isFunction(k.option.eTagRemove)){k.option.eTagRemove(l)}};h.prototype.clearAll=function(k){var l=0;if(k.option.multiple){l=g("li.selected_tag",k.elem.element_box).size();g("li.selected_tag",k.elem.element_box).remove()}g(k.elem.combo_input).val("");g(k.elem.hidden).val("");k.afterAction(k);if(k.option.multiple){if(k.option.eTagRemove&&g.isFunction(k.option.eTagRemove)){k.option.eTagRemove(l)}}};h.prototype.getCurrentLine=function(k){if(g(k.elem.result_area).is(":hidden")){return false}var l=g("li."+k.css_class.select,k.elem.results);if(g(l).size()){return l}else{return false}};h.prototype.isAlreadySelected=function(k,m){var n=false;if(m.value){var l=g(k.elem.hidden).val();if(l){var o=l.split(",");if(o&&o.length>0&&g.inArray(m.value,o)!=-1){n=true}}}return n};h.prototype.addNewTag=function(k,m){if(!k.option.multiple||!m){return}var l=k.template.tag.content;l=l.replace(k.template.tag.textKey,m.text);l=l.replace(k.template.tag.valueKey,m.value);g(k.elem.combo_input).closest("li").before(g(l))};h.prototype.removeTag=function(k,p){var m=g(p).attr("itemvalue");var o=g(k.elem.hidden).val();if(g.type(m)!="undefined"&&o){var n=o.split(",");var l=g.inArray(m.toString(),n);if(l!=-1){n.splice(l,1);g(k.elem.hidden).val(n.toString())}}g(p).remove();k.inputResize(k)};h.prototype.tagValuesSet=function(l){if(!l.option.multiple){return}var m=g("li.selected_tag",g(l.elem.element_box));if(m&&g(m).size()>0){var k=new Array();g.each(m,function(p,n){var o=g(n).attr("itemvalue");if(g.type(o)!=="undefined"){k.push(o)}});if(k.length>0){g(l.elem.hidden).val(k.join(","))}}};h.prototype.inputResize=function(k){if(!k.option.multiple){return}var n="";var l=k.elem.combo_input.closest("li");var m=function(o,p){p.removeClass("full_width");var r=o.elem.combo_input.val().length+1;var q=(r*0.75)+"em";o.elem.combo_input.css("width",q);o.elem.combo_input.removeAttr("placeholder")};if(g("li.selected_tag",g(k.elem.element_box)).size()===0){if(k.elem.combo_input.attr("placeholder_bak")){if(!l.hasClass("full_width")){l.addClass("full_width")}k.elem.combo_input.attr("placeholder",k.elem.combo_input.attr("placeholder_bak"));k.elem.combo_input.removeAttr("style")}else{m(k,l)}}else{m(k,l)}};h.prototype.nextLine=function(l){var n=l.getCurrentLine(l);var k;if(!n){k=-1}else{k=g(l.elem.results).children("li").index(n);g(n).removeClass(l.css_class.select)}k++;if(k-1){var m=g(l.elem.results).children("li").eq(k);g(m).addClass(l.css_class.select);l.setCssFocusedResults(l)}else{l.setCssFocusedInput(l)}l.scrollWindow(l,false)};function j(k){return this.each(function(){var m=g(this),l=m.data(h.dataKey),n=g.extend({},e,m.data(),l&&l.option,typeof k==="object"&&k);if(!l){m.data(h.dataKey,(l=new h(this,n)))}})}function a(k){return g(k).siblings("input.sp_input")}function b(){return this.each(function(){var l=a(this),k=l.data(h.dataKey);if(k){k.clearAll(k)}})}function f(){return this.each(function(){var l=a(this),k=l.data(h.dataKey);if(k&&k.elem.hidden.val()){k.setInitRecord(true)}})}function c(k){return this.each(function(){if(k&&g.isArray(k)&&k.length>0){var m=a(this),l=m.data(h.dataKey);if(l){l.clearAll(l);l.option.data=k}}})}function i(){var k="";this.each(function(){var m=a(this),l=m.data(h.dataKey);if(l){k+=l.elem.combo_input.val()}});return k}var d=g.fn.selectPage;g.fn.selectPage=j;g.fn.selectPage.Constructor=h;g.fn.selectPageClear=b;g.fn.selectPageRefresh=f;g.fn.selectPageData=c;g.fn.selectPageText=i;g.fn.selectPage.noConflict=function(){g.fn.selectPage=d;return this}})(window.jQuery); \ No newline at end of file +(function(g){var e={data:undefined,lang:"cn",multiple:false,pagination:true,listSize:10,multipleControlbar:true,maxSelectLimit:0,selectToCloseList:true,initRecord:undefined,dbTable:"tbl",keyField:"id",showField:"name",searchField:undefined,andOr:"AND",orderBy:undefined,pageSize:10,params:undefined,formatItem:undefined,focusDropList:true,autoSelectFirst:true,autoFillResult:true,noResultClean:true,selectOnly:false,inputDelay:0.5,eSelect:undefined,eAjaxSuccess:undefined,eTagRemove:undefined};var h=function(k,l){this.setOption(l);this.setLanguage();this.setCssClass();this.setProp();this.setElem(k,l);this.setButtonAttrDefault();this.setInitRecord();this.eDropdownButton();this.eInput();this.eWhole()};h.version="2.6";h.dataKey="selectPageObject";h.objStatusKey="selectPage-self-mark";h.objStatusIndex="selectPage-self-index";h.prototype.setOption=function(m){m.searchField=(m.searchField===undefined)?m.showField:m.searchField;m.andOr=m.andOr.toUpperCase();if(m.andOr!=="AND"&&m.andOr!=="OR"){m.andOr="AND"}var k=["searchField"];for(var l=0;l#item_text#×',textKey:"#item_text#",valueKey:"#item_value#"}}};h.prototype.setElem=function(m,q){var l={};var o=g(m).outerWidth();l.combo_input=g(m).attr({"autocomplete":"off"}).addClass(this.css_class.input).wrap("
        ");if(q.selectOnly){g(l.combo_input).prop("readonly",true)}l.container=g(l.combo_input).parent().addClass(this.css_class.container);g(l.container).width(o);l.button=g("
        ").addClass(this.css_class.button);l.dropdown=g('');l.clear_btn=g("
        ").append("×").addClass(this.css_class.clear_btn).attr("title","清除内容");l.element_box=g("
          ").addClass(this.css_class.element_box);if(q.multiple&&q.multipleControlbar){l.control=g("
          ").addClass(this.css_class.control_box)}l.result_area=g("
          ").addClass(this.css_class.re_area);if(q.pagination){l.navi=g("
          ").addClass("pagination").append("
            ")}l.results=g("
              ").addClass(this.css_class.results);var k="_text";var s=(g(l.combo_input).attr("id")!==undefined)?g(l.combo_input).attr("id"):g(l.combo_input).attr("name");var p=(g(l.combo_input).attr("name")!==undefined)?g(l.combo_input).attr("name"):"selectPage";var r=p,n=s;if(p.match(/\]$/)){p=p.replace(/\]?$/,k)}else{p+=k}if(s.match(/\]$/)){s=s.replace(/\]?$/,k)}else{s+=k}l.hidden=g('').attr({name:r,id:n}).val("");g(l.combo_input).attr({name:p,id:s});g(l.container).append(l.button).append(l.result_area).append(l.hidden);g(l.button).append(l.dropdown);g(l.result_area).append(l.results);if(q.pagination){g(l.result_area).append(l.navi)}if(q.multiple){if(q.multipleControlbar){g(l.control).append('');g(l.control).append('');g(l.control).append('');g(l.result_area).prepend(l.control)}g(l.container).addClass("sp_container_combo");g(l.combo_input).addClass("sp_combo_input").before(g(l.element_box));var t=g("
            • ").addClass("input_box");g(t).append(g(l.combo_input));g(l.element_box).append(g(t));if(g(l.combo_input).attr("placeholder")){g(l.combo_input).attr("placeholder_bak",g(l.combo_input).attr("placeholder"))}}this.elem=l};h.prototype.setButtonAttrDefault=function(){g(this.elem.button).attr("title",this.message.get_all_btn);g(this.elem.button).attr("title",this.message.close_btn)};h.prototype.setInitRecord=function(l){var k=this;if(g.type(g(k.elem.combo_input).data("init"))!="undefined"){k.option.initRecord=String(g(k.elem.combo_input).data("init"))}if(!k.option.initRecord){if(g(k.elem.combo_input).val()){k.option.initRecord=g(k.elem.combo_input).val()}}g(k.elem.combo_input).val("");if((l&&g(k.elem.hidden).val())||g.type(k.option.initRecord)==="string"){if(!l){g(k.elem.hidden).val(k.option.initRecord)}if(typeof k.option.data==="object"){var n=new Array();var m=l?g(k.elem.hidden).val().split(","):k.option.initRecord.split(",");g.each(m,function(o,q){for(var p=0;p1){n=null}k.afterInit(k,n)}else{g.ajax({dataType:"json",type:"POST",url:k.option.data,data:{searchTable:k.option.dbTable,searchKey:k.option.keyField,searchValue:l?g(k.elem.hidden).val():k.option.initRecord},success:function(o){var p=null;if(k.option.eAjaxSuccess&&g.isFunction(k.option.eAjaxSuccess)){p=k.option.eAjaxSuccess(o)}k.afterInit(k,p.list)},error:function(o,q,p){k.ajaxErrorNotify(k,p)}})}}};h.prototype.afterInit=function(l,m){if(!m){return}if(!g.isArray(m)){m=[m]}var k=function(q){var p=q[l.option.showField];if(l.option.formatItem&&g.isFunction(l.option.formatItem)){try{p=l.option.formatItem(q)}catch(o){}}return p};if(l.option.multiple){l.clearAll(l);g.each(m,function(o,q){var p={text:k(q),value:q[l.option.keyField]};if(!l.isAlreadySelected(l,p)){l.addNewTag(l,p)}});l.tagValuesSet(l);l.inputResize(l)}else{var n=m[0];g(l.elem.combo_input).val(k(n));g(l.elem.hidden).val(n[l.option.keyField]);l.prop.prev_value=k(n);l.prop.selected_text=k(n);if(l.option.selectOnly){g(l.elem.combo_input).attr("title",l.message.select_ok).removeClass(l.css_class.select_ng).addClass(l.css_class.select_ok)}l.putClearButton()}};h.prototype.eDropdownButton=function(){var k=this;g(k.elem.button).mouseup(function(l){l.stopPropagation();if(g(k.elem.result_area).is(":hidden")&&!g(k.elem.combo_input).prop("disabled")){g(k.elem.combo_input).focus()}else{k.hideResults(k)}}).mouseout()};h.prototype.eInput=function(){var l=this;var k=function(){l.prop.page_move=false;l.suggest(l);l.setCssFocusedInput(l)};g(l.elem.combo_input).keyup(function(m){l.processKey(l,m)}).focus(function(m){if(g(l.elem.result_area).is(":hidden")){m.stopPropagation();l.prop.first_show=true;k()}});g(l.elem.container).on("click.SelectPage","div."+l.css_class.clear_btn,function(m){m.stopPropagation();l.clearAll(l);g(l.elem.clear_btn).remove()});if(l.option.multiple){if(l.option.multipleControlbar){g(".sp_select_all",l.elem.control).on("click.SelectPage",function(m){l.selectAllLine(l)});g(".sp_unselect_all",l.elem.control).on("click.SelectPage",function(m){l.unselectAllLine(l)});g(".sp_clear_all",l.elem.control).on("click.SelectPage",function(m){l.clearAll(l)})}g(l.elem.element_box).on("click.SelectPage",function(n){var m=n.target||n.srcElement;if(g(m).is("ul")){g(l.elem.combo_input).focus()}});g(l.elem.element_box).on("click.SelectPage","span.tag_close",function(){var m=g(this).closest("li");l.removeTag(l,m);k();if(l.option.eTagRemove&&g.isFunction(l.option.eTagRemove)){l.option.eTagRemove(1)}});l.inputResize(l)}};h.prototype.eWhole=function(){var k=this;g(k.elem.container).mousedown(function(){var l=g("div.sp_container").index(this);var m=g(document.body).data(h.objStatusIndex);if(m!=undefined&&l!=m){g(document.body).data(h.objStatusKey,false)}else{g(document.body).data(h.objStatusKey,true)}g(document.body).data(h.objStatusIndex,l)});g(document).off("mousedown.selectPage").on("mousedown.selectPage",function(l){if(g(document.body).data(h.objStatusKey)){g(document.body).data(h.objStatusKey,false)}else{var m=function(n){g(n.elem.combo_input).val("");if(!n.option.multiple){g(n.elem.hidden).val("")}n.prop.selected_text=""};g("div."+k.css_class.container+"."+k.css_class.container_open).each(function(){var n=g("input."+k.css_class.input,this).data(h.dataKey);if(!g(n.elem.combo_input).val()&&g(n.elem.hidden).val()&&!n.option.multiple){n.prop.current_page=1;m(n);n.hideResults(n);return true}if(g("li",g(n.elem.results)).size()>0){if(n.option.autoFillResult){if(g("li.sp_selected",g(n.elem.results)).size()>0){n.hideResults(n)}else{if(g("li.sp_over",g(n.elem.results)).size()>0){if(g(n.elem.hidden).val()){n.hideResults(n)}else{n.selectCurrentLine(n,true)}}else{if(n.option.autoSelectFirst){if(g(n.elem.hidden).val()){n.hideResults(n)}else{n.nextLine(n);n.selectCurrentLine(n,true)}}else{n.hideResults(n)}}}}else{n.hideResults(n)}}else{if(n.option.noResultClean){m(n)}else{if(!n.option.multiple){g(n.elem.hidden).val("")}}n.hideResults(n)}})}})};h.prototype.eResultList=function(){var k=this;g(k.elem.results).children("li").mouseenter(function(){if(k.prop.key_select){k.prop.key_select=false;return}if(!g(this).hasClass(k.css_class.selected)&&!g(this).hasClass("sp_message_box")){g(this).addClass(k.css_class.select);k.setCssFocusedResults(k)}}).mouseleave(function(){g(this).removeClass(k.css_class.select)}).click(function(l){if(k.prop.key_select){k.prop.key_select=false;return}l.preventDefault();l.stopPropagation();if(!g(this).hasClass(k.css_class.selected)){k.selectCurrentLine(k,false)}})};h.prototype.ehNaviPaging=function(){var k=this;if(!k.option.pagination){return}g("li.csFirstPage",g(k.elem.navi)).off("click").on("click",function(l){l.preventDefault();k.firstPage(k)});g("li.csPreviousPage",g(k.elem.navi)).off("click").on("click",function(l){l.preventDefault();k.prevPage(k)});g("li.csNextPage",g(k.elem.navi)).off("click").on("click",function(l){l.preventDefault();k.nextPage(k)});g("li.csLastPage",g(k.elem.navi)).off("click").on("click",function(l){l.preventDefault();k.lastPage(k)})};h.prototype.ajaxErrorNotify=function(k,l){k.showMessage(k.message.ajax_error)};h.prototype.showMessage=function(k,m){if(!m){return}var l='
            • '+m+"
            • ";g(k.elem.results).empty().append(l);k.calcResultsSize(k);g(k.elem.container).addClass(k.css_class.container_open);g(k.elem.control).hide();if(k.option.pagination){g(k.elem.navi).hide()}};h.prototype.scrollWindow=function(s,p){var k=s.getCurrentLine(s);var r=(k&&!p)?k.offset().top:g(s.elem.container).offset().top;var m;s.prop.size_li=g(s.elem.results).children("li:first").outerHeight();m=s.prop.size_li;var o=g(window).height();var n=g(window).scrollTop();var l=n+o-m;var q;if(g(k).length){if(ro){q=r-n}else{if(r>l){q=r-l}else{return}}}else{if(r-1&&g(k.elem.result_area).is(":visible"))||(g.inArray(l.keyCode,[13,9])>-1&&k.getCurrentLine(k))){l.preventDefault();l.stopPropagation();l.cancelBubble=true;l.returnValue=false;switch(l.keyCode){case 37:if(l.shiftKey){k.firstPage(k)}else{k.prevPage(k)}break;case 38:k.prop.key_select=true;k.prevLine(k);break;case 39:if(l.shiftKey){k.lastPage(k)}else{k.nextPage(k)}break;case 40:if(g(k.elem.results).children("li").length){k.prop.key_select=true;k.nextLine(k)}else{k.suggest(k)}break;case 9:k.prop.key_paging=true;k.selectCurrentLine(k,true);break;case 13:k.selectCurrentLine(k,true);break;case 27:k.prop.key_paging=true;k.hideResults(k);break}}else{if(l.keyCode!=16){k.setCssFocusedInput(k)}k.inputResize(k);if(g.type(k.option.data)==="string"){k.prop.last_input_time=l.timeStamp;setTimeout(function(){if((l.timeStamp-k.prop.last_input_time)===0){k.checkValue(k)}},k.option.inputDelay*1000)}else{k.checkValue(k)}}};h.prototype.abortAjax=function(k){if(k.prop.xhr){k.prop.xhr.abort();k.prop.xhr=false}};h.prototype.suggest=function(l){var m;var n=g.trim(g(l.elem.combo_input).val());if(l.option.multiple){m=n}else{if(n&&n===l.prop.selected_text){m=""}else{m=n}}m=m.split(/[\s ]+/);l.abortAjax(l);l.setLoading(l);var k=l.prop.current_page>0?l.prop.current_page:1;if(typeof l.option.data=="object"){l.searchForJson(l,m,k)}else{l.searchForDb(l,m,k)}};h.prototype.setLoading=function(k){if(g(k.elem.results).html()===""){g(k.elem.container).addClass(k.css_class.container_open)}};h.prototype.searchForDb=function(n,q,l){if(!n.option.eAjaxSuccess&&g.isFunction(n.option.eAjaxSuccess)){n.hideResults(n)}var o=n.option.params;var m={};var r=n.option.searchField;if(q.length>0&&q[0]&&q[0]!==n.prop.prev_value){l=1}var p={q_word:q,pageNumber:l,pageSize:n.option.pageSize,andOr:n.option.andOr,orderBy:n.option.orderBy,searchTable:n.option.dbTable};p[r]=q[0];if(o&&g.isFunction(o)){var k=o();if(k&&g.isPlainObject(k)){m=g.extend({},p,k)}else{m=p}}else{m=p}n.prop.xhr=g.ajax({dataType:"json",url:n.option.data,type:"POST",data:m,success:function(v){if(!v||!g.isPlainObject(v)){n.hideResults(n);n.ajaxErrorNotify(n,errorThrown);return}var w;if(n.option.eAjaxSuccess&&g.isFunction(n.option.eAjaxSuccess)){w=n.option.eAjaxSuccess(v)}else{w=v}var u={};u.originalResult=w.list;u.cnt_whole=w.totalRow;u.candidate=[];u.keyField=[];if(typeof u.originalResult!="object"){n.prop.xhr=null;n.notFoundSearch(n);return}u.cnt_page=u.originalResult.length;for(var t=0;t0&&o[0]){l=true}m.displayResults(m,n,l)};h.prototype.setNavi=function(x,v,w,l){var m=function(H,E,y,D){if(g("li",g(E)).size()==0){g(E).empty();var A="",C=true;g.each(document.styleSheets,function(J,K){if(K&&K.href&&K.href.indexOf("font-awesome-3.2.1")!=-1){C=false;return false}});var F="fa fa-angle-double-left",I="fa fa-angle-left",z="fa fa-angle-right",B="fa fa-angle-double-right";if(!C){F="icon-step-backward";I="icon-backward";z="icon-forward";B="icon-step-forward"}if(y==1){A=" disabled "}g(E).append('
            • ');g(E).append('
            • ');var G="第 "+y+" 页(共"+D+"页)";g(E).append('
            • '+G+"
            • ");if(y==D){A=" disabled "}else{A=""}g(E).append('
            • ');g(E).append('
            • ')}};var s=g("ul",g(x.elem.navi));var q=Math.ceil(v/x.option.pageSize);if(q==0){l=0}else{if(q '+u+" ");var r="disabled";var o=g("li.csFirstPage",g(s));var p=g("li.csPreviousPage",g(s));var n=g("li.csNextPage",g(s));var t=g("li.csLastPage",g(s));if(l===1||l===0){if(!g(o).hasClass(r)){g(o).addClass(r)}if(!g(p).hasClass(r)){g(p).addClass(r)}}else{if(g(o).hasClass(r)){g(o).removeClass(r)}if(g(p).hasClass(r)){g(p).removeClass(r)}}if(l==q||q==0){if(!g(n).hasClass(r)){g(n).addClass(r)}if(!g(t).hasClass(r)){g(t).addClass(r)}}else{if(g(n).hasClass(r)){g(n).removeClass(r)}if(g(t).hasClass(r)){g(t).removeClass(r)}}if(q>1){x.ehNaviPaging()}};h.prototype.displayResults=function(v,u,n){g(v.elem.results).empty();if(v.option.multiple&&g.type(v.option.maxSelectLimit)==="number"&&v.option.maxSelectLimit>0){var l=g("li.selected_tag",v.elem.element_box).size();if(l>0&&l>=v.option.maxSelectLimit){v.showMessage(v,"最多只能选择 "+v.option.maxSelectLimit+" 个项目");return}}if(u.candidate.length>0){var t=u.candidate;var r=u.keyField;var k=g(v.elem.hidden).val();var w=k?k.split(","):new Array();for(var m=0;m").html(q).attr({pkey:r[m],title:q});if(g.inArray(r[m].toString(),w)!==-1){g(o).addClass(v.css_class.selected)}g(o).data("dataObj",u.originalResult[m]);g(v.elem.results).append(o)}}else{var s='
            • '+v.message.not_found+"
            • ";g(v.elem.results).append(s)}if(v.option.multiple&&v.option.multipleControlbar){g(v.elem.control).show()}if(v.option.pagination){g(v.elem.navi).show()}v.calcResultsSize(v);g(v.elem.container).addClass(v.css_class.container_open);v.eResultList();if(n&&u.candidate.length>0&&v.option.autoSelectFirst){v.nextLine(v)}};h.prototype.calcResultsSize=function(k){g(k.elem.result_area).show(1,function(){if(g(k.elem.container).css("position")==="static"){var v=g(k.elem.combo_input).offset();g(k.elem.result_area).css({top:v.top+g(k.elem.combo_input).outerHeight()+"px",left:v.left+"px"})}else{if(!k.option.pagination){var s=g("li:first",k.elem.results).outerHeight(true);var q=s*k.option.listSize;g(k.elem.results).css({"max-height":q,"overflow-y":"auto"})}var w=g(document).width();var A=g(document).height();var r=g(window).height();var v=g(k.elem.container).offset();var u=g(window).scrollTop();var z=g(k.elem.result_area).outerWidth();var q=g(k.elem.result_area).outerHeight();var m=k.option.multiple?-1:0;var l=g(k.elem.container).outerHeight();var p=(v.left+z)>w?-(z-g(k.elem.container).outerWidth()):m;var o=v.top;var y=0,x=5;var n=o+l+q+x;var t=A>r;if((t&&n>(r+u))||(!t&&n>r)){y=-(q+1)-x;g(k.elem.result_area).removeClass("shadowUp shadowDown").addClass("shadowUp")}else{y=k.option.multiple?g(k.elem.container).innerHeight()+1:g(k.elem.container).outerHeight();g(k.elem.result_area).removeClass("shadowUp shadowDown").addClass("shadowDown");y+=x}g(k.elem.result_area).css({top:y+"px",left:p+"px"})}})};h.prototype.hideResults=function(k){if(k.prop.key_paging){k.scrollWindow(k,true);k.prop.key_paging=false}k.setCssFocusedInput(k);if(k.option.autoFillResult){}g(k.elem.results).empty();g(k.elem.result_area).hide();g(k.elem.container).removeClass(k.css_class.container_open);k.abortAjax(k);k.setButtonAttrDefault()};h.prototype.firstPage=function(k){if(k.prop.current_page>1){k.prop.current_page=1;k.prop.page_move=true;k.suggest(k)}};h.prototype.prevPage=function(k){if(k.prop.current_page>1){k.prop.current_page--;k.prop.page_move=true;k.suggest(k)}};h.prototype.nextPage=function(k){if(k.prop.current_page0&&k.option.maxSelectLimit===g("li.selected_tag",k.elem.element_box).size()){return false}});if(k.option.eSelect&&g.isFunction(k.option.eSelect)){k.option.eSelect(l)}k.afterAction(k)};h.prototype.unselectAllLine=function(k){var l=g("li",k.elem.results).size();g("li",k.elem.results).each(function(o,p){var n=g(p).attr("pkey");var m=g('li.selected_tag[itemvalue="'+n+'"]',k.elem.element_box);k.removeTag(k,m)});k.afterAction(k);if(k.option.eTagRemove&&g.isFunction(k.option.eTagRemove)){k.option.eTagRemove(l)}};h.prototype.clearAll=function(k){var l=0;if(k.option.multiple){l=g("li.selected_tag",k.elem.element_box).size();g("li.selected_tag",k.elem.element_box).remove()}g(k.elem.combo_input).val("");g(k.elem.hidden).val("");k.afterAction(k);if(k.option.multiple){if(k.option.eTagRemove&&g.isFunction(k.option.eTagRemove)){k.option.eTagRemove(l)}}};h.prototype.getCurrentLine=function(k){if(g(k.elem.result_area).is(":hidden")){return false}var l=g("li."+k.css_class.select,k.elem.results);if(g(l).size()){return l}else{return false}};h.prototype.isAlreadySelected=function(k,m){var n=false;if(m.value){var l=g(k.elem.hidden).val();if(l){var o=l.split(",");if(o&&o.length>0&&g.inArray(m.value,o)!=-1){n=true}}}return n};h.prototype.addNewTag=function(k,m){if(!k.option.multiple||!m){return}var l=k.template.tag.content;l=l.replace(k.template.tag.textKey,m.text);l=l.replace(k.template.tag.valueKey,m.value);g(k.elem.combo_input).closest("li").before(g(l))};h.prototype.removeTag=function(k,p){var m=g(p).attr("itemvalue");var o=g(k.elem.hidden).val();if(g.type(m)!="undefined"&&o){var n=o.split(",");var l=g.inArray(m.toString(),n);if(l!=-1){n.splice(l,1);g(k.elem.hidden).val(n.toString())}}g(p).remove();k.inputResize(k)};h.prototype.tagValuesSet=function(l){if(!l.option.multiple){return}var m=g("li.selected_tag",g(l.elem.element_box));if(m&&g(m).size()>0){var k=new Array();g.each(m,function(p,n){var o=g(n).attr("itemvalue");if(g.type(o)!=="undefined"){k.push(o)}});if(k.length>0){g(l.elem.hidden).val(k.join(","))}}};h.prototype.inputResize=function(k){if(!k.option.multiple){return}var n="";var l=k.elem.combo_input.closest("li");var m=function(o,p){p.removeClass("full_width");var r=o.elem.combo_input.val().length+1;var q=(r*0.75)+"em";o.elem.combo_input.css("width",q);o.elem.combo_input.removeAttr("placeholder")};if(g("li.selected_tag",g(k.elem.element_box)).size()===0){if(k.elem.combo_input.attr("placeholder_bak")){if(!l.hasClass("full_width")){l.addClass("full_width")}k.elem.combo_input.attr("placeholder",k.elem.combo_input.attr("placeholder_bak"));k.elem.combo_input.removeAttr("style")}else{m(k,l)}}else{m(k,l)}};h.prototype.nextLine=function(l){var n=l.getCurrentLine(l);var k;if(!n){k=-1}else{k=g(l.elem.results).children("li").index(n);g(n).removeClass(l.css_class.select)}k++;if(k-1){var m=g(l.elem.results).children("li").eq(k);g(m).addClass(l.css_class.select);l.setCssFocusedResults(l)}else{l.setCssFocusedInput(l)}l.scrollWindow(l,false)};function j(k){return this.each(function(){var m=g(this),l=m.data(h.dataKey),n=g.extend({},e,m.data(),l&&l.option,typeof k==="object"&&k);if(!l){m.data(h.dataKey,(l=new h(this,n)))}})}function a(l){var k=g(l).closest("div.sp_container");return g("input.sp_input",k)}function b(){return this.each(function(){var l=a(this),k=l.data(h.dataKey);if(k){k.clearAll(k)}})}function f(){return this.each(function(){var l=a(this),k=l.data(h.dataKey);if(k&&k.elem.hidden.val()){k.setInitRecord(true)}})}function c(k){return this.each(function(){if(k&&g.isArray(k)&&k.length>0){var m=a(this),l=m.data(h.dataKey);if(l){l.clearAll(l);l.option.data=k}}})}function i(){var k="";this.each(function(){var m=a(this),l=m.data(h.dataKey);if(l){k+=l.elem.combo_input.val()}});return k}var d=g.fn.selectPage;g.fn.selectPage=j;g.fn.selectPage.Constructor=h;g.fn.selectPageClear=b;g.fn.selectPageRefresh=f;g.fn.selectPageData=c;g.fn.selectPageText=i;g.fn.selectPage.noConflict=function(){g.fn.selectPage=d;return this}})(window.jQuery); \ No newline at end of file