From d0d6aa0f63fd48754c6153927382528e28cd4ab9 Mon Sep 17 00:00:00 2001 From: TerryZ Date: Mon, 30 Oct 2017 15:02:10 +0800 Subject: [PATCH] update --- package.json | 2 +- selectpage.js | 96 +++++++++++++++++++++++++---------------------- selectpage.min.js | 2 +- 3 files changed, 53 insertions(+), 47 deletions(-) diff --git a/package.json b/package.json index 2452dff..abfaebf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "selectpage", - "version": "2.12.0", + "version": "2.13.0", "description": "A simple style and powerful selection jQuery plugin, including ajax remote data, autocomplete, pagination, tags, i18n, keyboard navigation functions", "main": "selectpage.js", "dependencies": { diff --git a/selectpage.js b/selectpage.js index ab9787c..bc7eead 100644 --- a/selectpage.js +++ b/selectpage.js @@ -23,8 +23,8 @@ */ data: undefined, /** - * @desc 插件显示语言 ('ja', 'en', 'es', 'pt-br'等) - * @type string 默认'cn' + * Language ('ja', 'en', 'es', 'pt-br') + * @type string - default:'cn' */ lang: 'cn', /** @@ -139,7 +139,7 @@ */ noResultClean: true, /** - * @desc 只选择模式 + * Select only mode * @type boolean */ selectOnly: false, @@ -152,16 +152,23 @@ * -----------------------------------------事件回调-------------------------------------------- */ /** - * @type function - * @param object - * @param dom + * Result list item selected callback + * @type function + * @param object - selected item json data + * @param self - plugin object */ eSelect : undefined, + /** + * Before result list show up callback, you can do anything prepared + * @param self - plugin object + */ + eOpen : undefined, /** * ajax请求模式,请求成功后的数据处理回调 * 回调的功能用于自定义处理服务端返回的数据 * @type function * @param data {object} ajax服务端返回的json数据 + * @param self {object} plugin object * @return {object} 函数返回的数据结构如下: * @example * { @@ -171,14 +178,16 @@ */ eAjaxSuccess : undefined, /** - * 多选模式下,关闭标签是的回调函数 + * Close selected item tag callback (multiple mode) * @type function - * @param removeCount 被移除的个数 + * @param removeCount {number} remove item count + * @param self {object} plugin object */ eTagRemove : undefined, /** - * 单选模式下,选中项目后的清除按钮功能回调 + * Clear selected item callback(single select mode) * @type function + * @param self {object} plugin object */ eClear : undefined }; @@ -203,7 +212,6 @@ this.eDropdownButton(); this.eInput(); this.eWhole(); - return this; }; /** * Plugin version number @@ -768,7 +776,7 @@ e.stopPropagation(); if(!self.disabled(self)){ self.clearAll(self); - if(p.eClear && $.isFunction(p.eClear)) p.eClear(); + if(p.eClear && $.isFunction(p.eClear)) p.eClear(self); } }); el.result_area.on('mousedown.SelectPage',function(e){ @@ -799,7 +807,7 @@ self.removeTag(self,li); showList(); if(p.eTagRemove && $.isFunction(p.eTagRemove)) - p.eTagRemove(1); + p.eTagRemove(1, self); }); self.inputResize(self); } @@ -829,30 +837,22 @@ //若控件已有选中的的项目,而文本输入框中清空了关键字,则清空控件已选中的项目 if(!d.elem.combo_input.val() && d.elem.hidden.val() && !d.option.multiple){ - d.prop.current_page = 1;//重置当前页为1 + d.prop.current_page = 1;//reset page to 1 cleanContent(d); d.hideResults(d); return true; } - if (d.elem.results.find('li').size()) { - if(d.option.autoFillResult) {//打开自动内容填充功能 - //若已有选中项目,则直接隐藏列表 - if (d.elem.results.find('li.sp_selected').size()) { - d.hideResults(d); - }else if(d.elem.results.find('li.sp_over').size()){ - //若控件已有选中的值,则忽略高亮的项目 - if(d.elem.hidden.val()) d.hideResults(d); - //若没有已选中的项目,且列表中有高亮项目时,选中当前高亮的行 - else d.selectCurrentLine(d, true); + if (d.elem.results.find('li').not('.'+css.message_box).size()) { + if(d.option.autoFillResult) { + //have selected item, then hide result list + if (d.elem.hidden.val()) d.hideResults(d); + else if(d.elem.results.find('li.sp_over').size()){ + //no one selected and have highlight item, select the highlight item + d.selectCurrentLine(d, true); }else if(d.option.autoSelectFirst){ - //若控件已有选中的值,则忽略自动选择第一项的功能 - if(d.elem.hidden.val()) d.hideResults(d); - else{ - //对于没有选中,没有高亮的情况,若插件设置了自动选中第一项时,则选中第一项 - d.nextLine(d); - //self.nextLine(self); - d.selectCurrentLine(d, true); - } + //no one selected, no one highlight, select the first item + d.nextLine(d); + d.selectCurrentLine(d, true); }else d.hideResults(d); }else d.hideResults(d); } else { @@ -872,16 +872,16 @@ */ SelectPage.prototype.eResultList = function() { var self = this, css = this.css_class; - self.elem.results.children('li').mouseenter(function() { + 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('sp_message_box')){ + if(!$(this).hasClass(css.selected) && !$(this).hasClass(css.message_box)){ $(this).addClass(css.select); self.setCssFocusedResults(self); } - }).mouseleave(function(){ + },function(){ $(this).removeClass(css.select); }).click(function(e) { if (self.prop.key_select) { @@ -969,7 +969,7 @@ */ SelectPage.prototype.showMessage = function(self,msg){ if(!msg) return; - var msgLi = '
  • '+msg+'
  • '; + var msgLi = '
  • '+msg+'
  • '; self.elem.results.empty().append(msgLi).show(); self.calcResultsSize(self); self.setOpenStatus(self, true); @@ -1165,6 +1165,11 @@ else q_word = val; } q_word = q_word.split(/[\s ]+/); + + //Before show up result list callback + if(self.option.eOpen && $.isFunction(self.option.eOpen)) + self.option.eOpen.call(self); + self.abortAjax(self); //self.setLoading(self); var which_page_num = self.prop.current_page > 0 ? self.prop.current_page : 1; @@ -1195,7 +1200,7 @@ var p = self.option; if(!p.eAjaxSuccess || !$.isFunction(p.eAjaxSuccess)) self.hideResults(self); var _paramsFunc = p.params, _params = {}, searchKey = p.searchField; - //when have query keyword, then reset page number to 1. + //when have new query keyword, then reset page number to 1. if(q_word.length && q_word[0] && q_word[0] !== self.prop.prev_value) which_page_num = 1; var _orgParams = { q_word: q_word, @@ -1203,13 +1208,13 @@ pageSize: p.pageSize, andOr: p.andOr, orderBy: p.orderBy, - searchTable: p.dbTable, - searchKey: q_word[0] + searchTable: p.dbTable }; + _orgParams[searchKey] = q_word[0]; if (_paramsFunc && $.isFunction(_paramsFunc)) { - var result = _paramsFunc(); + var result = _paramsFunc.call(self); if (result && $.isPlainObject(result)) { - _params = $.extend({},_orgParams, result); + _params = $.extend({}, _orgParams, result); } else _params = _orgParams; } else _params = _orgParams; self.prop.xhr = $.ajax({ @@ -1560,7 +1565,8 @@ el.results.append(list); } }else{ - var li = '
  • ' + self.message.not_found + '
  • '; + var li = '
  • '+ + self.message.not_found + '
  • '; el.results.append(li); } el.results.show(); @@ -1801,7 +1807,7 @@ //Select item callback if(p.eSelect && $.isFunction(p.eSelect)) - p.eSelect(current.data('dataObj')); + p.eSelect(current.data('dataObj'), self); self.prop.prev_value = self.elem.combo_input.val(); self.prop.selected_text = self.elem.combo_input.val(); @@ -1838,7 +1844,7 @@ } }); if(p.eSelect && $.isFunction(p.eSelect)) - p.eSelect(jsonarr); + p.eSelect(jsonarr, self); self.afterAction(self); }; /** @@ -1854,7 +1860,7 @@ }); self.afterAction(self); if(p.eTagRemove && $.isFunction(p.eTagRemove)) - p.eTagRemove(size); + p.eTagRemove(size, self); }; /** * Clear all selected items @@ -1872,7 +1878,7 @@ if(!p.multiple) self.elem.clear_btn.remove(); if(p.multiple) { if (p.eTagRemove && $.isFunction(p.eTagRemove)) - p.eTagRemove(size); + p.eTagRemove(size, self); } }; diff --git a/selectpage.min.js b/selectpage.min.js index 29126a5..eb73895 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:false,autoFillResult:false,noResultClean:true,selectOnly:false,inputDelay:0.5,eSelect:undefined,eAjaxSuccess:undefined,eTagRemove:undefined,eClear:undefined};var h=function(l,m){this.setOption(m);this.setLanguage();this.setCssClass();this.setProp();this.setElem(l);this.setButtonAttrDefault();this.setInitRecord();this.eDropdownButton();this.eInput();this.eWhole();return this};h.version="2.12";h.dataKey="selectPageObject";h.prototype.setOption=function(n){n.searchField=(n.searchField===undefined)?n.showField:n.searchField;n.andOr=n.andOr.toUpperCase();if(n.andOr!=="AND"&&n.andOr!=="OR"){n.andOr="AND"}var l=["searchField"];for(var m=0;m#item_text#×',textKey:"#item_text#",valueKey:"#item_value#"}}};h.prototype.setElem=function(o){var n={},m=this.option,t=this.css_class;var r=g(o).outerWidth();if(r<150){r=150}n.combo_input=g(o).attr({"autocomplete":"off"}).addClass(t.input).wrap("
    ");if(m.selectOnly){n.combo_input.prop("readonly",true)}n.container=n.combo_input.parent().addClass(t.container);if(n.combo_input.prop("disabled")){if(m.multiple){n.container.addClass(t.disabled)}else{n.combo_input.addClass(t.input_off)}}n.container.width(r);n.button=g("
    ").addClass(t.button);n.dropdown=g('');n.clear_btn=g("
    ").append("×").addClass(t.clear_btn).attr("title","清除内容");n.element_box=g("
      ").addClass(t.element_box);if(m.multiple&&m.multipleControlbar){n.control=g("
      ").addClass(t.control_box)}n.result_area=g("
      ").addClass(t.re_area);if(m.pagination){n.navi=g("
      ").addClass("pagination").append("
        ")}n.results=g("
          ").addClass(t.results);var l="_text",v=(n.combo_input.attr("id")!==undefined)?n.combo_input.attr("id"):n.combo_input.attr("name"),s=(n.combo_input.attr("name")!==undefined)?n.combo_input.attr("name"):"selectPage",u=s,q=v;n.hidden=g('').attr({name:u,id:q}).val("");n.combo_input.attr({name:s+l,id:v+l});n.container.append(n.button).append(n.hidden);g(document.body).append(n.result_area);n.button.append(n.dropdown);n.result_area.append(n.results);if(m.pagination){n.result_area.append(n.navi)}if(m.multiple){if(m.multipleControlbar){n.control.append('');n.control.append('');n.control.append('');n.result_area.prepend(n.control)}n.container.addClass("sp_container_combo");n.combo_input.addClass("sp_combo_input").before(n.element_box);var w=g("
        • ").addClass("input_box");w.append(n.combo_input);n.element_box.append(w);if(n.combo_input.attr("placeholder")){n.combo_input.attr("placeholder_bak",n.combo_input.attr("placeholder"))}}this.elem=n};h.prototype.setButtonAttrDefault=function(){this.elem.button.attr("title",this.message.close_btn)};h.prototype.setInitRecord=function(o){var l=this,s=l.option,n=l.elem,m="";if(g.type(n.combo_input.data("init"))!="undefined"){s.initRecord=String(n.combo_input.data("init"))}if(!o&&!s.initRecord&&n.combo_input.val()){s.initRecord=n.combo_input.val()}n.combo_input.val("");if(!o){n.hidden.val(s.initRecord)}m=o&&n.hidden.val()?n.hidden.val():s.initRecord;if(m){if(typeof s.data==="object"){var r=new Array();var q=m.split(",");g.each(q,function(p,u){for(var t=0;t1){r=[r[0]]}l.afterInit(l,r)}else{g.ajax({dataType:"json",type:"POST",url:s.data,data:{searchTable:s.dbTable,searchKey:s.keyField,searchValue:m},success:function(p){var t=null;if(s.eAjaxSuccess&&g.isFunction(s.eAjaxSuccess)){t=s.eAjaxSuccess(p)}l.afterInit(l,t.list)},error:function(p,u,t){l.ajaxErrorNotify(l,t)}})}}};h.prototype.afterInit=function(m,o){if(!o){return}if(!g.isArray(o)){o=[o]}var q=m.option,n=m.css_class;var l=function(t){var s=t[q.showField];if(q.formatItem&&g.isFunction(q.formatItem)){try{s=q.formatItem(t)}catch(p){}}return s};if(q.multiple){m.clearAll(m);g.each(o,function(p,t){var s={text:l(t),value:t[q.keyField]};if(!m.isAlreadySelected(m,s)){m.addNewTag(m,s)}});m.tagValuesSet(m);m.inputResize(m)}else{var r=o[0];m.elem.combo_input.val(l(r));m.elem.hidden.val(r[q.keyField]);m.prop.prev_value=l(r);m.prop.selected_text=l(r);if(q.selectOnly){m.elem.combo_input.attr("title",m.message.select_ok).removeClass(n.select_ng).addClass(n.select_ok)}m.putClearButton()}};h.prototype.eDropdownButton=function(){var l=this;l.elem.button.mouseup(function(m){m.stopPropagation();if(l.elem.result_area.is(":hidden")&&!l.elem.combo_input.prop("disabled")){l.elem.combo_input.focus()}else{l.hideResults(l)}}).mouseout()};h.prototype.eInput=function(){var m=this,o=m.option,n=m.elem;var l=function(){m.prop.page_move=false;m.suggest(m);m.setCssFocusedInput(m)};n.combo_input.keyup(function(p){m.processKey(m,p)}).keydown(function(p){m.processControl(m,p)}).focus(function(p){if(n.result_area.is(":hidden")){p.stopPropagation();m.prop.first_show=true;l()}});n.container.on("click.SelectPage","div."+m.css_class.clear_btn,function(p){p.stopPropagation();if(!m.disabled(m)){m.clearAll(m);if(o.eClear&&g.isFunction(o.eClear)){o.eClear()}}});n.result_area.on("mousedown.SelectPage",function(p){p.stopPropagation()});if(o.multiple){if(o.multipleControlbar){n.control.find(".sp_select_all").on("click.SelectPage",function(p){m.selectAllLine(m)});n.control.find(".sp_unselect_all").on("click.SelectPage",function(p){m.unSelectAllLine(m)});n.control.find(".sp_clear_all").on("click.SelectPage",function(p){m.clearAll(m)})}n.element_box.on("click.SelectPage",function(q){var p=q.target||q.srcElement;if(g(p).is("ul")){n.combo_input.focus()}});n.element_box.on("click.SelectPage","span.tag_close",function(){var p=g(this).closest("li");m.removeTag(m,p);l();if(o.eTagRemove&&g.isFunction(o.eTagRemove)){o.eTagRemove(1)}});m.inputResize(m)}};h.prototype.eWhole=function(){var l=this,m=l.css_class;var n=function(o){o.elem.combo_input.val("");if(!o.option.multiple){o.elem.hidden.val("")}o.prop.selected_text=""};g(document).off("mousedown.selectPage").on("mousedown.selectPage",function(q){var p=q.target||q.srcElement;var o=g(p).closest("div."+m.container);g("div."+m.container+"."+m.container_open).each(function(){if(this==o[0]){return}var r=g(this),s=r.find("input."+m.input).data(h.dataKey);if(!s.elem.combo_input.val()&&s.elem.hidden.val()&&!s.option.multiple){s.prop.current_page=1;n(s);s.hideResults(s);return true}if(s.elem.results.find("li").size()){if(s.option.autoFillResult){if(s.elem.results.find("li.sp_selected").size()){s.hideResults(s)}else{if(s.elem.results.find("li.sp_over").size()){if(s.elem.hidden.val()){s.hideResults(s)}else{s.selectCurrentLine(s,true)}}else{if(s.option.autoSelectFirst){if(s.elem.hidden.val()){s.hideResults(s)}else{s.nextLine(s);s.selectCurrentLine(s,true)}}else{s.hideResults(s)}}}}else{s.hideResults(s)}}else{if(s.option.noResultClean){n(s)}else{if(!s.option.multiple){s.elem.hidden.val("")}}s.hideResults(s)}})})};h.prototype.eResultList=function(){var l=this,m=this.css_class;l.elem.results.children("li").mouseenter(function(){if(l.prop.key_select){l.prop.key_select=false;return}if(!g(this).hasClass(m.selected)&&!g(this).hasClass("sp_message_box")){g(this).addClass(m.select);l.setCssFocusedResults(l)}}).mouseleave(function(){g(this).removeClass(m.select)}).click(function(n){if(l.prop.key_select){l.prop.key_select=false;return}n.preventDefault();n.stopPropagation();if(!g(this).hasClass(m.selected)){l.selectCurrentLine(l,false)}})};h.prototype.eScroll=function(){var l=this,m=this.css_class;g(window).on("scroll.SelectPage",function(n){g("div."+m.container+"."+m.container_open).each(function(){var v=g(this),u=v.find("input."+m.input).data(h.dataKey),t=u.elem.result_area.offset(),s=g(window).scrollTop(),x=g(document).height(),q=g(window).height(),p=u.elem.result_area.outerHeight(),o=t.top+p,r=x>q,w=u.elem.result_area.hasClass("shadowDown");if(r){if(w){if(o>(q+s)){u.calcResultsSize(u)}}else{if(t.top";l.elem.results.empty().append(m).show();l.calcResultsSize(l);l.setOpenStatus(l,true);l.elem.control.hide();if(l.option.pagination){l.elem.navi.hide()}};h.prototype.scrollWindow=function(t,q){var l=t.getCurrentLine(t),s=(l&&!q)?l.offset().top:t.elem.container.offset().top,n;t.prop.size_li=t.elem.results.children("li:first").outerHeight();n=t.prop.size_li;var r,p=g(window).height(),o=g(window).scrollTop(),m=o+p-n;if(l.length){if(sp){r=s-o}else{if(s>m){r=s-m}else{return}}}else{if(s-1&&l.elem.result_area.is(":visible"))||(g.inArray(m.keyCode,[13,9])>-1&&l.getCurrentLine(l))){m.preventDefault();m.stopPropagation();m.cancelBubble=true;m.returnValue=false;switch(m.keyCode){case 37:if(m.shiftKey){l.firstPage(l)}else{l.prevPage(l)}break;case 38:l.prop.key_select=true;l.prevLine(l);break;case 39:if(m.shiftKey){l.lastPage(l)}else{l.nextPage(l)}break;case 40:if(l.elem.results.children("li").length){l.prop.key_select=true;l.nextLine(l)}else{l.suggest(l)}break;case 9:l.prop.key_paging=true;l.selectCurrentLine(l,true);break;case 13:l.selectCurrentLine(l,true);break;case 27:l.prop.key_paging=true;l.hideResults(l);break}}};h.prototype.abortAjax=function(l){if(l.prop.xhr){l.prop.xhr.abort();l.prop.xhr=false}};h.prototype.suggest=function(m){var n,o=g.trim(m.elem.combo_input.val());if(m.option.multiple){n=o}else{if(o&&o===m.prop.selected_text){n=""}else{n=o}}n=n.split(/[\s ]+/);m.abortAjax(m);var l=m.prop.current_page>0?m.prop.current_page:1;if(typeof m.option.data=="object"){m.searchForJson(m,n,l)}else{m.searchForDb(m,n,l)}};h.prototype.setLoading=function(l){if(l.elem.results.html()===""){l.setOpenStatus(l,true)}};h.prototype.searchForDb=function(t,q,s){var m=t.option;if(!m.eAjaxSuccess||!g.isFunction(m.eAjaxSuccess)){t.hideResults(t)}var n=m.params,r={},o=m.searchField;if(q.length&&q[0]&&q[0]!==t.prop.prev_value){s=1}var l={q_word:q,pageNumber:s,pageSize:m.pageSize,andOr:m.andOr,orderBy:m.orderBy,searchTable:m.dbTable,searchKey:q[0]};if(n&&g.isFunction(n)){var u=n();if(u&&g.isPlainObject(u)){r=g.extend({},l,u)}else{r=l}}else{r=l}t.prop.xhr=g.ajax({dataType:"json",url:m.data,type:"POST",data:r,success:function(x){if(!x||!g.isPlainObject(x)){t.hideResults(t);t.ajaxErrorNotify(t,errorThrown);return}var y=m.eAjaxSuccess(x),w={};w.originalResult=y.list;w.cnt_whole=y.totalRow;w.candidate=[];w.keyField=[];if(typeof w.originalResult!="object"){t.prop.xhr=null;t.notFoundSearch(t);return}w.cnt_page=w.originalResult.length;for(var v=0;v
        • ');E.append('
        • ');var G="第 "+z+" 页 ( 共"+D+"页 ) ";E.append('
        • '+G+"
        • ");B=z===D?" disabled ":"";E.append('
        • ');E.append('
        • ');E.show()}};var t=y.elem.navi.find("ul"),r=Math.ceil(w/y.option.pageSize);if(r===0){m=0}else{if(r '+v+" ");var s="disabled",p=t.find("li.csFirstPage"),q=t.find("li.csPreviousPage"),o=t.find("li.csNextPage"),u=t.find("li.csLastPage");if(m===1||m===0){if(!p.hasClass(s)){p.addClass(s)}if(!q.hasClass(s)){q.addClass(s)}}else{if(p.hasClass(s)){p.removeClass(s)}if(q.hasClass(s)){q.removeClass(s)}}if(m===r||r===0){if(!o.hasClass(s)){o.addClass(s)}if(!u.hasClass(s)){u.addClass(s)}}else{if(o.hasClass(s)){o.removeClass(s)}if(u.hasClass(s)){u.removeClass(s)}}if(r>1){y.ePaging()}};h.prototype.displayResults=function(z,y,r){var l=z.option,n=z.elem;n.results.hide().empty();if(l.multiple&&g.type(l.maxSelectLimit)==="number"&&l.maxSelectLimit>0){var o=n.element_box.find("li.selected_tag").size();if(o>0&&o>=l.maxSelectLimit){z.showMessage(z,"最多只能选择 "+l.maxSelectLimit+" 个项目");return}}if(y.candidate.length){var x=y.candidate,v=y.keyField,m=n.hidden.val(),A=m?m.split(","):new Array(),u="";for(var q=0;q").html(u).attr({pkey:v[q],title:u});if(g.inArray(v[q].toString(),A)!==-1){s.addClass(z.css_class.selected)}s.data("dataObj",y.originalResult[q]);n.results.append(s)}}else{var w='
        • '+z.message.not_found+"
        • ";n.results.append(w)}n.results.show();if(l.multiple&&l.multipleControlbar){n.control.show()}if(l.pagination){n.navi.show()}z.calcResultsSize(z);z.setOpenStatus(z,true);z.eResultList();z.eScroll();if(r&&y.candidate.length&&l.autoSelectFirst){z.nextLine(z)}};h.prototype.calcResultsSize=function(m){var o=m.option,n=m.elem;var l=function(){if(n.container.css("position")==="static"){var z=n.combo_input.offset();n.result_area.css({top:z.top+n.combo_input.outerHeight()+"px",left:z.left+"px"})}else{if(!o.pagination){var w=n.results.find("li:first").outerHeight(true),u=w*o.listSize;n.results.css({"max-height":u,"overflow-y":"auto"})}var A=g(document).width(),E=g(document).height(),v=g(window).height(),z=n.container.offset(),y=g(window).scrollTop(),D=n.result_area.outerWidth(),u=n.result_area.outerHeight(),q=z.left,p=n.container.outerHeight(),t=(z.left+D)>A?q-(D-n.container.outerWidth()):q,s=z.top,C=0,B=5,r=s+p+u+B,x=E>v;if((s-y-B>u)&&(x&&r>(v+y))||(!x&&r>v)){C=z.top-u-B;n.result_area.removeClass("shadowUp shadowDown").addClass("shadowUp")}else{C=z.top+(o.multiple?n.container.outerHeight():p);n.result_area.removeClass("shadowUp shadowDown").addClass("shadowDown");C+=B}return{top:C+"px",left:t+"px"}}};if(n.result_area.is(":visible")){n.result_area.css(l())}else{n.result_area.show(1,function(){g(this).css(l())})}};h.prototype.hideResults=function(l){if(l.prop.key_paging){l.scrollWindow(l,true);l.prop.key_paging=false}l.setCssFocusedInput(l);if(l.option.autoFillResult){}l.elem.results.empty();l.elem.result_area.hide();l.setOpenStatus(l,false);g(window).off("scroll.SelectPage");l.abortAjax(l);l.setButtonAttrDefault()};h.prototype.disabled=function(l,n){var o=l.option,m=l.elem;if(g.type(n)==="undefined"){return m.combo_input.prop("disabled")}if(g.type(n)==="boolean"){m.combo_input.prop("disabled",n);if(n){m.container.addClass(l.css_class.disabled)}else{m.container.removeClass(l.css_class.disabled)}}};h.prototype.firstPage=function(l){if(l.prop.current_page>1){l.prop.current_page=1;l.prop.page_move=true;l.suggest(l)}};h.prototype.prevPage=function(l){if(l.prop.current_page>1){l.prop.current_page--;l.prop.page_move=true;l.suggest(l)}};h.prototype.nextPage=function(l){if(l.prop.current_page0&&n.maxSelectLimit===l.elem.element_box.find("li.selected_tag").size()){return false}});if(n.eSelect&&g.isFunction(n.eSelect)){n.eSelect(m)}l.afterAction(l)};h.prototype.unSelectAllLine=function(l){var n=l.option,m=l.elem.results.find("li").size();l.elem.results.find("li").each(function(q,r){var p=g(r).attr("pkey");var o=l.elem.element_box.find('li.selected_tag[itemvalue="'+p+'"]');l.removeTag(l,o)});l.afterAction(l);if(n.eTagRemove&&g.isFunction(n.eTagRemove)){n.eTagRemove(m)}};h.prototype.clearAll=function(l){var n=l.option,m=0;if(n.multiple){m=l.elem.element_box.find("li.selected_tag").size();l.elem.element_box.find("li.selected_tag").remove()}l.elem.combo_input.val("");l.elem.hidden.val("");l.afterAction(l);if(!n.multiple){l.elem.clear_btn.remove()}if(n.multiple){if(n.eTagRemove&&g.isFunction(n.eTagRemove)){n.eTagRemove(m)}}};h.prototype.getCurrentLine=function(l){if(l.elem.result_area.is(":hidden")){return false}var m=l.elem.results.find("li."+l.css_class.select);if(m.size()){return m}else{return false}};h.prototype.isAlreadySelected=function(l,n){var o=false;if(n.value){var m=l.elem.hidden.val();if(m){var p=m.split(",");if(p&&p.length&&g.inArray(n.value,p)!=-1){o=true}}}return o};h.prototype.addNewTag=function(m,o){if(!m.option.multiple||!o){return}var n=m.template.tag.content,l;n=n.replace(m.template.tag.textKey,o.text);n=n.replace(m.template.tag.valueKey,o.value);l=g(n);if(m.elem.combo_input.prop("disabled")){l.find("span.tag_close").hide()}m.elem.combo_input.closest("li").before(l)};h.prototype.removeTag=function(l,q){var n=g(q).attr("itemvalue");var p=l.elem.hidden.val();if(g.type(n)!="undefined"&&p){var o=p.split(","),m=g.inArray(n.toString(),o);if(m!=-1){o.splice(m,1);l.elem.hidden.val(o.toString())}}g(q).remove();l.inputResize(l)};h.prototype.tagValuesSet=function(m){if(!m.option.multiple){return}var n=m.elem.element_box.find("li.selected_tag");if(n&&n.size()){var l=new Array();g.each(n,function(q,o){var p=g(o).attr("itemvalue");if(g.type(p)!=="undefined"){l.push(p)}});if(l.length){m.elem.hidden.val(l.join(","))}}};h.prototype.inputResize=function(l){if(!l.option.multiple){return}var o="",m=l.elem.combo_input.closest("li");var n=function(p,q){q.removeClass("full_width");var s=p.elem.combo_input.val().length+1,r=(s*0.75)+"em";p.elem.combo_input.css("width",r).removeAttr("placeholder")};if(l.elem.element_box.find("li.selected_tag").size()===0){if(l.elem.combo_input.attr("placeholder_bak")){if(!m.hasClass("full_width")){m.addClass("full_width")}l.elem.combo_input.attr("placeholder",l.elem.combo_input.attr("placeholder_bak")).removeAttr("style")}else{n(l,m)}}else{n(l,m)}};h.prototype.nextLine=function(m){var o=m.getCurrentLine(m),l;if(!o){l=-1}else{l=m.elem.results.children("li").index(o);o.removeClass(m.css_class.select)}l++;if(l-1){var n=m.elem.results.children("li").eq(l);n.addClass(m.css_class.select);m.setCssFocusedResults(m)}else{m.setCssFocusedInput(m)}m.scrollWindow(m,false)};function j(l){return this.each(function(){var n=g(this),m=n.data(h.dataKey),o=g.extend({},e,n.data(),m&&m.option,typeof l==="object"&&l);if(!m){n.data(h.dataKey,(m=new h(this,o)))}})}function a(l){return g(l).closest("div.sp_container").find("input.sp_input")}function b(){return this.each(function(){var m=a(this),l=m.data(h.dataKey);if(l){l.clearAll(l)}})}function f(){return this.each(function(){var m=a(this),l=m.data(h.dataKey);if(l&&l.elem.hidden.val()){l.setInitRecord(true)}})}function c(l){return this.each(function(){if(l&&g.isArray(l)&&l.length){var n=a(this),m=n.data(h.dataKey);if(m){m.clearAll(m);m.option.data=l}}})}function k(m){var l=false;this.each(function(){var o=a(this),n=o.data(h.dataKey);if(n){if(g.type(m)!=="undefined"){n.disabled(n,m)}else{l=n.disabled(n)}}});return l}function i(){var l="";this.each(function(){var n=a(this),m=n.data(h.dataKey);if(m){l+=m.elem.combo_input.val()}});return l}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.selectPageDisabled=k;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:false,autoFillResult:false,noResultClean:true,selectOnly:false,inputDelay:0.5,eSelect:undefined,eOpen:undefined,eAjaxSuccess:undefined,eTagRemove:undefined,eClear:undefined};var h=function(l,m){this.setOption(m);this.setLanguage();this.setCssClass();this.setProp();this.setElem(l);this.setButtonAttrDefault();this.setInitRecord();this.eDropdownButton();this.eInput();this.eWhole()};h.version="2.12";h.dataKey="selectPageObject";h.prototype.setOption=function(n){n.searchField=(n.searchField===undefined)?n.showField:n.searchField;n.andOr=n.andOr.toUpperCase();if(n.andOr!=="AND"&&n.andOr!=="OR"){n.andOr="AND"}var l=["searchField"];for(var m=0;m#item_text#×',textKey:"#item_text#",valueKey:"#item_value#"}}};h.prototype.setElem=function(o){var n={},m=this.option,t=this.css_class;var r=g(o).outerWidth();if(r<150){r=150}n.combo_input=g(o).attr({"autocomplete":"off"}).addClass(t.input).wrap("
          ");if(m.selectOnly){n.combo_input.prop("readonly",true)}n.container=n.combo_input.parent().addClass(t.container);if(n.combo_input.prop("disabled")){if(m.multiple){n.container.addClass(t.disabled)}else{n.combo_input.addClass(t.input_off)}}n.container.width(r);n.button=g("
          ").addClass(t.button);n.dropdown=g('');n.clear_btn=g("
          ").append("×").addClass(t.clear_btn).attr("title","清除内容");n.element_box=g("
            ").addClass(t.element_box);if(m.multiple&&m.multipleControlbar){n.control=g("
            ").addClass(t.control_box)}n.result_area=g("
            ").addClass(t.re_area);if(m.pagination){n.navi=g("
            ").addClass("pagination").append("
              ")}n.results=g("
                ").addClass(t.results);var l="_text",v=(n.combo_input.attr("id")!==undefined)?n.combo_input.attr("id"):n.combo_input.attr("name"),s=(n.combo_input.attr("name")!==undefined)?n.combo_input.attr("name"):"selectPage",u=s,q=v;n.hidden=g('').attr({name:u,id:q}).val("");n.combo_input.attr({name:s+l,id:v+l});n.container.append(n.button).append(n.hidden);g(document.body).append(n.result_area);n.button.append(n.dropdown);n.result_area.append(n.results);if(m.pagination){n.result_area.append(n.navi)}if(m.multiple){if(m.multipleControlbar){n.control.append('');n.control.append('');n.control.append('');n.result_area.prepend(n.control)}n.container.addClass("sp_container_combo");n.combo_input.addClass("sp_combo_input").before(n.element_box);var w=g("
              • ").addClass("input_box");w.append(n.combo_input);n.element_box.append(w);if(n.combo_input.attr("placeholder")){n.combo_input.attr("placeholder_bak",n.combo_input.attr("placeholder"))}}this.elem=n};h.prototype.setButtonAttrDefault=function(){this.elem.button.attr("title",this.message.close_btn)};h.prototype.setInitRecord=function(o){var l=this,s=l.option,n=l.elem,m="";if(g.type(n.combo_input.data("init"))!="undefined"){s.initRecord=String(n.combo_input.data("init"))}if(!o&&!s.initRecord&&n.combo_input.val()){s.initRecord=n.combo_input.val()}n.combo_input.val("");if(!o){n.hidden.val(s.initRecord)}m=o&&n.hidden.val()?n.hidden.val():s.initRecord;if(m){if(typeof s.data==="object"){var r=new Array();var q=m.split(",");g.each(q,function(p,u){for(var t=0;t1){r=[r[0]]}l.afterInit(l,r)}else{g.ajax({dataType:"json",type:"POST",url:s.data,data:{searchTable:s.dbTable,searchKey:s.keyField,searchValue:m},success:function(p){var t=null;if(s.eAjaxSuccess&&g.isFunction(s.eAjaxSuccess)){t=s.eAjaxSuccess(p)}l.afterInit(l,t.list)},error:function(p,u,t){l.ajaxErrorNotify(l,t)}})}}};h.prototype.afterInit=function(m,o){if(!o){return}if(!g.isArray(o)){o=[o]}var q=m.option,n=m.css_class;var l=function(t){var s=t[q.showField];if(q.formatItem&&g.isFunction(q.formatItem)){try{s=q.formatItem(t)}catch(p){}}return s};if(q.multiple){m.clearAll(m);g.each(o,function(p,t){var s={text:l(t),value:t[q.keyField]};if(!m.isAlreadySelected(m,s)){m.addNewTag(m,s)}});m.tagValuesSet(m);m.inputResize(m)}else{var r=o[0];m.elem.combo_input.val(l(r));m.elem.hidden.val(r[q.keyField]);m.prop.prev_value=l(r);m.prop.selected_text=l(r);if(q.selectOnly){m.elem.combo_input.attr("title",m.message.select_ok).removeClass(n.select_ng).addClass(n.select_ok)}m.putClearButton()}};h.prototype.eDropdownButton=function(){var l=this;l.elem.button.mouseup(function(m){m.stopPropagation();if(l.elem.result_area.is(":hidden")&&!l.elem.combo_input.prop("disabled")){l.elem.combo_input.focus()}else{l.hideResults(l)}}).mouseout()};h.prototype.eInput=function(){var m=this,o=m.option,n=m.elem;var l=function(){m.prop.page_move=false;m.suggest(m);m.setCssFocusedInput(m)};n.combo_input.keyup(function(p){m.processKey(m,p)}).keydown(function(p){m.processControl(m,p)}).focus(function(p){if(n.result_area.is(":hidden")){p.stopPropagation();m.prop.first_show=true;l()}});n.container.on("click.SelectPage","div."+m.css_class.clear_btn,function(p){p.stopPropagation();if(!m.disabled(m)){m.clearAll(m);if(o.eClear&&g.isFunction(o.eClear)){o.eClear(m)}}});n.result_area.on("mousedown.SelectPage",function(p){p.stopPropagation()});if(o.multiple){if(o.multipleControlbar){n.control.find(".sp_select_all").on("click.SelectPage",function(p){m.selectAllLine(m)});n.control.find(".sp_unselect_all").on("click.SelectPage",function(p){m.unSelectAllLine(m)});n.control.find(".sp_clear_all").on("click.SelectPage",function(p){m.clearAll(m)})}n.element_box.on("click.SelectPage",function(q){var p=q.target||q.srcElement;if(g(p).is("ul")){n.combo_input.focus()}});n.element_box.on("click.SelectPage","span.tag_close",function(){var p=g(this).closest("li");m.removeTag(m,p);l();if(o.eTagRemove&&g.isFunction(o.eTagRemove)){o.eTagRemove(1,m)}});m.inputResize(m)}};h.prototype.eWhole=function(){var l=this,m=l.css_class;var n=function(o){o.elem.combo_input.val("");if(!o.option.multiple){o.elem.hidden.val("")}o.prop.selected_text=""};g(document).off("mousedown.selectPage").on("mousedown.selectPage",function(q){var p=q.target||q.srcElement;var o=g(p).closest("div."+m.container);g("div."+m.container+"."+m.container_open).each(function(){if(this==o[0]){return}var r=g(this),s=r.find("input."+m.input).data(h.dataKey);if(!s.elem.combo_input.val()&&s.elem.hidden.val()&&!s.option.multiple){s.prop.current_page=1;n(s);s.hideResults(s);return true}if(s.elem.results.find("li").not("."+m.message_box).size()){if(s.option.autoFillResult){if(s.elem.hidden.val()){s.hideResults(s)}else{if(s.elem.results.find("li.sp_over").size()){s.selectCurrentLine(s,true)}else{if(s.option.autoSelectFirst){s.nextLine(s);s.selectCurrentLine(s,true)}else{s.hideResults(s)}}}}else{s.hideResults(s)}}else{if(s.option.noResultClean){n(s)}else{if(!s.option.multiple){s.elem.hidden.val("")}}s.hideResults(s)}})})};h.prototype.eResultList=function(){var l=this,m=this.css_class;l.elem.results.children("li").hover(function(){if(l.prop.key_select){l.prop.key_select=false;return}if(!g(this).hasClass(m.selected)&&!g(this).hasClass(m.message_box)){g(this).addClass(m.select);l.setCssFocusedResults(l)}},function(){g(this).removeClass(m.select)}).click(function(n){if(l.prop.key_select){l.prop.key_select=false;return}n.preventDefault();n.stopPropagation();if(!g(this).hasClass(m.selected)){l.selectCurrentLine(l,false)}})};h.prototype.eScroll=function(){var l=this,m=this.css_class;g(window).on("scroll.SelectPage",function(n){g("div."+m.container+"."+m.container_open).each(function(){var v=g(this),u=v.find("input."+m.input).data(h.dataKey),t=u.elem.result_area.offset(),s=g(window).scrollTop(),x=g(document).height(),q=g(window).height(),p=u.elem.result_area.outerHeight(),o=t.top+p,r=x>q,w=u.elem.result_area.hasClass("shadowDown");if(r){if(w){if(o>(q+s)){u.calcResultsSize(u)}}else{if(t.top '+n+"
              • ";l.elem.results.empty().append(m).show();l.calcResultsSize(l);l.setOpenStatus(l,true);l.elem.control.hide();if(l.option.pagination){l.elem.navi.hide()}};h.prototype.scrollWindow=function(t,q){var l=t.getCurrentLine(t),s=(l&&!q)?l.offset().top:t.elem.container.offset().top,n;t.prop.size_li=t.elem.results.children("li:first").outerHeight();n=t.prop.size_li;var r,p=g(window).height(),o=g(window).scrollTop(),m=o+p-n;if(l.length){if(sp){r=s-o}else{if(s>m){r=s-m}else{return}}}else{if(s-1&&l.elem.result_area.is(":visible"))||(g.inArray(m.keyCode,[13,9])>-1&&l.getCurrentLine(l))){m.preventDefault();m.stopPropagation();m.cancelBubble=true;m.returnValue=false;switch(m.keyCode){case 37:if(m.shiftKey){l.firstPage(l)}else{l.prevPage(l)}break;case 38:l.prop.key_select=true;l.prevLine(l);break;case 39:if(m.shiftKey){l.lastPage(l)}else{l.nextPage(l)}break;case 40:if(l.elem.results.children("li").length){l.prop.key_select=true;l.nextLine(l)}else{l.suggest(l)}break;case 9:l.prop.key_paging=true;l.selectCurrentLine(l,true);break;case 13:l.selectCurrentLine(l,true);break;case 27:l.prop.key_paging=true;l.hideResults(l);break}}};h.prototype.abortAjax=function(l){if(l.prop.xhr){l.prop.xhr.abort();l.prop.xhr=false}};h.prototype.suggest=function(m){var n,o=g.trim(m.elem.combo_input.val());if(m.option.multiple){n=o}else{if(o&&o===m.prop.selected_text){n=""}else{n=o}}n=n.split(/[\s ]+/);if(m.option.eOpen&&g.isFunction(m.option.eOpen)){m.option.eOpen.call(m)}m.abortAjax(m);var l=m.prop.current_page>0?m.prop.current_page:1;if(typeof m.option.data=="object"){m.searchForJson(m,n,l)}else{m.searchForDb(m,n,l)}};h.prototype.setLoading=function(l){if(l.elem.results.html()===""){l.setOpenStatus(l,true)}};h.prototype.searchForDb=function(t,q,s){var m=t.option;if(!m.eAjaxSuccess||!g.isFunction(m.eAjaxSuccess)){t.hideResults(t)}var n=m.params,r={},o=m.searchField;if(q.length&&q[0]&&q[0]!==t.prop.prev_value){s=1}var l={q_word:q,pageNumber:s,pageSize:m.pageSize,andOr:m.andOr,orderBy:m.orderBy,searchTable:m.dbTable};l[o]=q[0];if(n&&g.isFunction(n)){var u=n.call(t);if(u&&g.isPlainObject(u)){r=g.extend({},l,u)}else{r=l}}else{r=l}t.prop.xhr=g.ajax({dataType:"json",url:m.data,type:"POST",data:r,success:function(x){if(!x||!g.isPlainObject(x)){t.hideResults(t);t.ajaxErrorNotify(t,errorThrown);return}var y=m.eAjaxSuccess(x),w={};w.originalResult=y.list;w.cnt_whole=y.totalRow;w.candidate=[];w.keyField=[];if(typeof w.originalResult!="object"){t.prop.xhr=null;t.notFoundSearch(t);return}w.cnt_page=w.originalResult.length;for(var v=0;v ');E.append('
              • ');var G="第 "+z+" 页 ( 共"+D+"页 ) ";E.append('
              • '+G+"
              • ");B=z===D?" disabled ":"";E.append('
              • ');E.append('
              • ');E.show()}};var t=y.elem.navi.find("ul"),r=Math.ceil(w/y.option.pageSize);if(r===0){m=0}else{if(r '+v+" ");var s="disabled",p=t.find("li.csFirstPage"),q=t.find("li.csPreviousPage"),o=t.find("li.csNextPage"),u=t.find("li.csLastPage");if(m===1||m===0){if(!p.hasClass(s)){p.addClass(s)}if(!q.hasClass(s)){q.addClass(s)}}else{if(p.hasClass(s)){p.removeClass(s)}if(q.hasClass(s)){q.removeClass(s)}}if(m===r||r===0){if(!o.hasClass(s)){o.addClass(s)}if(!u.hasClass(s)){u.addClass(s)}}else{if(o.hasClass(s)){o.removeClass(s)}if(u.hasClass(s)){u.removeClass(s)}}if(r>1){y.ePaging()}};h.prototype.displayResults=function(z,y,r){var l=z.option,n=z.elem;n.results.hide().empty();if(l.multiple&&g.type(l.maxSelectLimit)==="number"&&l.maxSelectLimit>0){var o=n.element_box.find("li.selected_tag").size();if(o>0&&o>=l.maxSelectLimit){z.showMessage(z,"最多只能选择 "+l.maxSelectLimit+" 个项目");return}}if(y.candidate.length){var x=y.candidate,v=y.keyField,m=n.hidden.val(),A=m?m.split(","):new Array(),u="";for(var q=0;q").html(u).attr({pkey:v[q],title:u});if(g.inArray(v[q].toString(),A)!==-1){s.addClass(z.css_class.selected)}s.data("dataObj",y.originalResult[q]);n.results.append(s)}}else{var w='
              • '+z.message.not_found+"
              • ";n.results.append(w)}n.results.show();if(l.multiple&&l.multipleControlbar){n.control.show()}if(l.pagination){n.navi.show()}z.calcResultsSize(z);z.setOpenStatus(z,true);z.eResultList();z.eScroll();if(r&&y.candidate.length&&l.autoSelectFirst){z.nextLine(z)}};h.prototype.calcResultsSize=function(m){var o=m.option,n=m.elem;var l=function(){if(n.container.css("position")==="static"){var z=n.combo_input.offset();n.result_area.css({top:z.top+n.combo_input.outerHeight()+"px",left:z.left+"px"})}else{if(!o.pagination){var w=n.results.find("li:first").outerHeight(true),u=w*o.listSize;n.results.css({"max-height":u,"overflow-y":"auto"})}var A=g(document).width(),E=g(document).height(),v=g(window).height(),z=n.container.offset(),y=g(window).scrollTop(),D=n.result_area.outerWidth(),u=n.result_area.outerHeight(),q=z.left,p=n.container.outerHeight(),t=(z.left+D)>A?q-(D-n.container.outerWidth()):q,s=z.top,C=0,B=5,r=s+p+u+B,x=E>v;if((s-y-B>u)&&(x&&r>(v+y))||(!x&&r>v)){C=z.top-u-B;n.result_area.removeClass("shadowUp shadowDown").addClass("shadowUp")}else{C=z.top+(o.multiple?n.container.outerHeight():p);n.result_area.removeClass("shadowUp shadowDown").addClass("shadowDown");C+=B}return{top:C+"px",left:t+"px"}}};if(n.result_area.is(":visible")){n.result_area.css(l())}else{n.result_area.show(1,function(){g(this).css(l())})}};h.prototype.hideResults=function(l){if(l.prop.key_paging){l.scrollWindow(l,true);l.prop.key_paging=false}l.setCssFocusedInput(l);if(l.option.autoFillResult){}l.elem.results.empty();l.elem.result_area.hide();l.setOpenStatus(l,false);g(window).off("scroll.SelectPage");l.abortAjax(l);l.setButtonAttrDefault()};h.prototype.disabled=function(l,n){var o=l.option,m=l.elem;if(g.type(n)==="undefined"){return m.combo_input.prop("disabled")}if(g.type(n)==="boolean"){m.combo_input.prop("disabled",n);if(n){m.container.addClass(l.css_class.disabled)}else{m.container.removeClass(l.css_class.disabled)}}};h.prototype.firstPage=function(l){if(l.prop.current_page>1){l.prop.current_page=1;l.prop.page_move=true;l.suggest(l)}};h.prototype.prevPage=function(l){if(l.prop.current_page>1){l.prop.current_page--;l.prop.page_move=true;l.suggest(l)}};h.prototype.nextPage=function(l){if(l.prop.current_page0&&n.maxSelectLimit===l.elem.element_box.find("li.selected_tag").size()){return false}});if(n.eSelect&&g.isFunction(n.eSelect)){n.eSelect(m,l)}l.afterAction(l)};h.prototype.unSelectAllLine=function(l){var n=l.option,m=l.elem.results.find("li").size();l.elem.results.find("li").each(function(q,r){var p=g(r).attr("pkey");var o=l.elem.element_box.find('li.selected_tag[itemvalue="'+p+'"]');l.removeTag(l,o)});l.afterAction(l);if(n.eTagRemove&&g.isFunction(n.eTagRemove)){n.eTagRemove(m,l)}};h.prototype.clearAll=function(l){var n=l.option,m=0;if(n.multiple){m=l.elem.element_box.find("li.selected_tag").size();l.elem.element_box.find("li.selected_tag").remove()}l.elem.combo_input.val("");l.elem.hidden.val("");l.afterAction(l);if(!n.multiple){l.elem.clear_btn.remove()}if(n.multiple){if(n.eTagRemove&&g.isFunction(n.eTagRemove)){n.eTagRemove(m,l)}}};h.prototype.getCurrentLine=function(l){if(l.elem.result_area.is(":hidden")){return false}var m=l.elem.results.find("li."+l.css_class.select);if(m.size()){return m}else{return false}};h.prototype.isAlreadySelected=function(l,n){var o=false;if(n.value){var m=l.elem.hidden.val();if(m){var p=m.split(",");if(p&&p.length&&g.inArray(n.value,p)!=-1){o=true}}}return o};h.prototype.addNewTag=function(m,o){if(!m.option.multiple||!o){return}var n=m.template.tag.content,l;n=n.replace(m.template.tag.textKey,o.text);n=n.replace(m.template.tag.valueKey,o.value);l=g(n);if(m.elem.combo_input.prop("disabled")){l.find("span.tag_close").hide()}m.elem.combo_input.closest("li").before(l)};h.prototype.removeTag=function(l,q){var n=g(q).attr("itemvalue");var p=l.elem.hidden.val();if(g.type(n)!="undefined"&&p){var o=p.split(","),m=g.inArray(n.toString(),o);if(m!=-1){o.splice(m,1);l.elem.hidden.val(o.toString())}}g(q).remove();l.inputResize(l)};h.prototype.tagValuesSet=function(m){if(!m.option.multiple){return}var n=m.elem.element_box.find("li.selected_tag");if(n&&n.size()){var l=new Array();g.each(n,function(q,o){var p=g(o).attr("itemvalue");if(g.type(p)!=="undefined"){l.push(p)}});if(l.length){m.elem.hidden.val(l.join(","))}}};h.prototype.inputResize=function(l){if(!l.option.multiple){return}var o="",m=l.elem.combo_input.closest("li");var n=function(p,q){q.removeClass("full_width");var s=p.elem.combo_input.val().length+1,r=(s*0.75)+"em";p.elem.combo_input.css("width",r).removeAttr("placeholder")};if(l.elem.element_box.find("li.selected_tag").size()===0){if(l.elem.combo_input.attr("placeholder_bak")){if(!m.hasClass("full_width")){m.addClass("full_width")}l.elem.combo_input.attr("placeholder",l.elem.combo_input.attr("placeholder_bak")).removeAttr("style")}else{n(l,m)}}else{n(l,m)}};h.prototype.nextLine=function(m){var o=m.getCurrentLine(m),l;if(!o){l=-1}else{l=m.elem.results.children("li").index(o);o.removeClass(m.css_class.select)}l++;if(l-1){var n=m.elem.results.children("li").eq(l);n.addClass(m.css_class.select);m.setCssFocusedResults(m)}else{m.setCssFocusedInput(m)}m.scrollWindow(m,false)};function j(l){return this.each(function(){var n=g(this),m=n.data(h.dataKey),o=g.extend({},e,n.data(),m&&m.option,typeof l==="object"&&l);if(!m){n.data(h.dataKey,(m=new h(this,o)))}})}function a(l){return g(l).closest("div.sp_container").find("input.sp_input")}function b(){return this.each(function(){var m=a(this),l=m.data(h.dataKey);if(l){l.clearAll(l)}})}function f(){return this.each(function(){var m=a(this),l=m.data(h.dataKey);if(l&&l.elem.hidden.val()){l.setInitRecord(true)}})}function c(l){return this.each(function(){if(l&&g.isArray(l)&&l.length){var n=a(this),m=n.data(h.dataKey);if(m){m.clearAll(m);m.option.data=l}}})}function k(m){var l=false;this.each(function(){var o=a(this),n=o.data(h.dataKey);if(n){if(g.type(m)!=="undefined"){n.disabled(n,m)}else{l=n.disabled(n)}}});return l}function i(){var l="";this.each(function(){var n=a(this),m=n.data(h.dataKey);if(m){l+=m.elem.combo_input.val()}});return l}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.selectPageDisabled=k;g.fn.selectPageText=i;g.fn.selectPage.noConflict=function(){g.fn.selectPage=d;return this}})(window.jQuery); \ No newline at end of file