锘緼rray.prototype.unique = function () {//鍘绘暟缁勯噸澶 return this.sort().join(",,").replace(/(,|^)([^,]+)(,,\2)+(,|$)/g, "$1$2$4").replace(/,,+/g, ",").replace(/,$/, "").split(","); } var Iput = { confg: { hand: "0", //0瀵瑰儚浣嶇疆1榧犳爣浣嶇疆divID婊氬姩浣嶇疆 idIframe: "PoPx", //榛樿鍙笉鐢ㄦ敼 idBox: "PoPy", //榛樿鍙笉鐢ㄦ敼 content: "", //浼犺繃鏉ョ殑鍐呭 ok: null, //寮瑰嚭妗嗕箣鍚庢墽琛岀殑鍑芥暟 id: null, //涓嶈兘涓虹┖涓€鑸紶this瀵瑰儚鑰屼笉鏄鍍廔D event: window.event, //杩欎釜蹇呭啓涓€鑸负e灏卞彲浠ヤ簡 top: 0, //椤堕儴鍋忕Щ浣嶇疆 left: 0, //宸﹂儴鍋忕Щ浣嶇疆 bodyHeight: 0, //鍦ㄨposition:absolute鍏冪礌涓嬪緱鍒癏TML鐪熷疄楂樺害 bodyWidth: 0, width: 0, soll: null, pop: null //鎸囧畾ID鐐瑰嚮鏃朵笉鍏抽棴 }, get: function (obj) { return document.getElementById(obj); }, clear: function () { Iput.confg.hand = "0"; Iput.confg.ok = null; Iput.confg.top = 0; Iput.confg.left = 0; Iput.confg.bodyHeight = 0; Iput.confg.bodyWidth = 0; Iput.confg.width = 0; Iput.confg.pop = null; }, stopBubble: function (e) { if (e && e.stopPropagation) { e.stopPropagation(); //w3c } else { window.event.cancelBubble = true; //IE } }, pop: function () { var $a = document.getElementsByTagName("body").item(0); var $c = document.createElement("iframe"); var $b = document.createElement("div"); $c.setAttribute('id', Iput.confg.idIframe); $c.setAttribute("src", "about:blank"); $c.style.zindex = '100'; $c.frameBorder = "0"; $c.style.width = "0px"; $c.style.height = "0px"; $c.style.position = 'absolute'; $b.setAttribute('id', Iput.confg.idBox); $b.setAttribute('class', Iput.confg.idBox); $b.setAttribute('align', 'left'); $b.style.position = 'fixed'; $b.style.background = 'transparent'; $b.style.zIndex = '20000'; if ($a) { if (Iput.get(Iput.confg.idIframe)) { Iput.colse(); } $a.appendChild($c); if ($c) { $c.ownerDocument.body.appendChild($b); } Iput.get(Iput.confg.idBox).innerHTML = Iput.confg.content; Iput.drice(Iput.confg.event); } if (!document.all) { window.document.addEventListener("click", Iput.hide, false); } else { window.document.attachEvent("onclick", Iput.hide); } }, drice: function (e) { if (!e) e = window.event; var a = Iput.get(Iput.confg.idBox); var b = Iput.get(Iput.confg.idIframe); var c = "60%"; var w = "100%"; if (Iput.get(Iput.confg.idIframe)) { if (Iput.confg.hand == "1") { b.style.top = 0 + "px"; a.style.left = 0 + "px"; a.style.bottom = 0 + "px"; b.style.left = 0 + "px"; } else if (Iput.confg.hand == "0") { w = "100%"; a.style.width = w; b.style.width = w; a.style.height = c; b.style.top = 0 + "px"; b.style.left = 0 + "px"; a.style.left = 0 + "px"; a.style.bottom = 0 + "px"; } else { a.style.height = c; b.style.top = 0 + "px"; b.style.left = 0 + "px"; a.style.left = 0 + "px"; a.style.bottom = 0 + "px"; } } }, show: function () { Iput.unScroll(); var config = arguments[0]; var that = Iput.confg; Iput.clear(); for (var i in that) { if (config[i] != undefined) { that[i] = config[i]; } }; Iput.pop(); if (Iput.confg.ok != null) { Iput.action(Iput.confg.ok()); } }, colse: function () { Iput.removeUnScroll(); if (Iput.get(Iput.confg.idIframe)) { document.body.removeChild(Iput.get(Iput.confg.idBox)); document.body.removeChild(Iput.get(Iput.confg.idIframe)); } if (Iput.get(Iput.confg.pop)) { Iput.get(Iput.confg.pop).style.display = "none"; } }, hide: function (e) {//鐐瑰嚮浠讳綍澶勫叧闂眰 e = window.event || e; var srcElement = e.srcElement || e.target; if (Iput.confg.event == undefined) {//杈撳叆鏃剁敤,鑸湪娌′紶鍏put.confg.event璇峰喌涓嬩娇鐢 Iput.colse(); } else { var a = Iput.confg.event.srcElement || Iput.confg.event.target; var b = Iput.get(Iput.confg.pop); console.log(a); console.log(srcElement); if (a != srcElement) { Iput.colse(); } if (b != null) { if (b != srcElement && a != srcElement) { Iput.colse(); } } } if (Iput.get(Iput.confg.idIframe)) { Iput.get(Iput.confg.idIframe).onclick = function (e) { Iput.stopBubble(e); }; Iput.get(Iput.confg.idBox).onclick = function (e) { Iput.stopBubble(e); }; } if (Iput.get(Iput.confg.pop)) { Iput.get(Iput.confg.pop).onclick = function (e) { Iput.stopBubble(e); }; } }, action: function (obj) { eval(obj); }, contains: function (star, end, isIgnoreCase) { if (isIgnoreCase) { star = star.toLowerCase(); end = end.toLowerCase(); } var startChar = end.substring(0, 1); var strLen = end.length; for (var j = 0; j < star.length - strLen + 1; j++) { if (star.charAt(j) == startChar)//濡傛灉鍖归厤璧峰瀛楃,寮€濮嬫煡鎵 { if (star.substring(j, j + strLen) == end)//濡傛灉浠巎寮€濮嬬殑瀛楃涓巗tr鍖归厤锛岄偅ok { return true; } } } return false; },unScroll() { //婊氬姩鏉℃秷澶 $('html,body').css({'overflow': 'hidden'}); },removeUnScroll() { //婊氬姩鏉″嚭鐜 $('html,body').css({'overflow': 'auto'}); } }