/** * 自定义下拉列 * * Licensed under the GPL: * http://www.gnu.org/licenses/gpl.txt * * Copyright 2010 goldensoft.com * */ var gSelect = {}; gSelect.bindInputs = new Map(); gSelect.currentOpen = null; gSelect.canClose = true; gSelect.isDrpWdInit=false; gSelect.init = function (D){ if (gSelect.isDrpWdInit) return; var domain = ""; if (typeof(HOST_DOMAIN)!='undefined'){ if (HOST_DOMAIN!=""){ domain = ""; } } try{ D.open(); D.write(""); D.write("
"); D.write(domain); // Write Domain D.write(""); D.write(""); D.write(''); D.write(""); // 判断IE浏览器,IE浏览器close会触发load,死循环 if(navigator.userAgent.indexOf("MSIE")>0) { gSelect.isDrpWdInit = true; } D.close(); } catch(E) { } gSelect.iframe = $("#__ieselect"); gSelect.iframediv = gSelect.iframe.contents().find("#iframediv"); } /** * 绑定下拉事件到控件 * parm: * id -- 需要绑定的input控件ID * url -- 取值URL(必须返回规定的格式) * params -- 调用HTTP参数 * codeid -- code回写的input控件ID(可选) * showclosebt -- 是否显示关闭按钮(可选,默认true,若为false,则关闭及分页不再显示) */ gSelect.bind = function (id,_url,_params,_codeid,_showclosebt){ if (this.bindInputs.containsKey(id)){ var f = this.bindInputs.get(id); f.params = _params; if (_showclosebt==undefined) _showclosebt = true; f.isShowCloseBt = _showclosebt; return; } if (!this.outerDiv){ this.iframe = null; this.iframediv=null; this.outerDiv = $("#_smanDisp"); this.outerDiv.mouseenter(function (e){ gSelect.canClose = false; }); this.outerDiv.mouseleave(function (e){ gSelect.canClose = true; }); var src = "about:blank"; if (typeof(HOST_DOMAIN)!='undefined'){ if (HOST_DOMAIN!=""){ src = "javascript:void((function(){document.open();document.domain='"+HOST_DOMAIN+"';document.write('');document.close()})())" } } var _iframe = document.createElement("iframe"); _iframe.src = src; _iframe.scrolling = "no"; _iframe.id = "__ieselect"; _iframe.setAttribute('frameborder', '0' , 0); var smanDisp = document.getElementById("_smanDisp"); if (_iframe.attachEvent){ _iframe.attachEvent("onload", function(){ //判断对象是否为空,同时捕获异常 bug:52994 edit by gt 2013-6-28 try{ if("undefined"!=typeof(_iframe.contentWindow) && "undefined" != typeof(_iframe.contentWindow.document)){ var D = _iframe.contentWindow.document; gSelect.init(D); } }catch(e){ } }); }else{ _iframe.onload = function(){ var D = _iframe.contentWindow.document; gSelect.init(D); } } smanDisp.appendChild(_iframe); } this.bindInputs.put(id,new bindInput(id,_url,_params,_codeid,_showclosebt)); function bindInput(id,_url,_params,_codeid,_showclosebt){ this.id = "#"+id; this.input = $(this.id); this.params = _params; this.url = _url; if (_codeid) this.codeid = _codeid; if (_showclosebt==undefined){ _showclosebt = true; } this._showclosebt = _showclosebt; this.input.bind("click",function (e){ // this.id -> input.id if (null!=gSelect.currentOpen&&gSelect.currentOpen == this.id)return; if (this.readOnly){ this.value=""; } var fun = gSelect.bindInputs.get(this.id); onFocus(this,fun); }); this.input.bind("blur",function (e){ try{ if (!gSelect.canClose) return; }catch(e){ } gSelect.closeDivPage(); }); this.input.bind("change",function (e){ this.value = this.value.toUpperCase(); gSelect.nextpage(this.id,1); }); function onFocus(ipt,e){ ipt.select(); gSelect.load(ipt.id,e,1); ipt.focus(); } this.input.keyup(function (e){ //this.value = this.value.toUpperCase(); //gSelect.nextpage(this.id,1); }); } } gSelect.nextpage = function (id,page){ var fun = gSelect.bindInputs.get(id); gSelect.load(id,fun,page); } gSelect.load = function(id,fun,page){ var input = $("#"+id); var param = fun.params; var strInput = input.val(); if (strInput == $("#"+id).attr("alt")) { strInput =""; } var divWidth = 50; // 增加分页 param.page = page; param.keyworld = strInput; // 打开下拉 divPosition(); $.post(fun.url,fun.params,function (result){ var allpage = result[0].allPage; var pageno = result[0].pageNo; var allcount = result[0].allCount; var closeHTML = " 关闭 "; if (!fun._showclosebt) closeHTML = ""; // 不显示关闭按钮 gSelect.iframediv.html("';
if(parseInt(pageno)>1){
pagetext +="![]() | "; pagetext += " 共"+allcount+"条 "; pagetext += " | ";
if(parseInt(pageno)![]() |