// 甯冨眬鑴氭湰 /*==================================== *鍩轰簬jquery 1.9.0涓绘鏋� *vlcms绠$悊鐣岄潰 *浣滆€咃細涓€浜涗簨鎯� ====================================*/ //缁戝畾闇€瑕佹诞鍔ㄧ殑琛ㄥご $(function(){ $(".ltable tr:nth-child(odd)").addclass("odd_bg"); //闅旇鍙樿壊 $("#floathead").smartfloat(); $(".rule-single-checkbox").rulesinglecheckbox(); $(".rule-multi-checkbox").rulemulticheckbox(); $(".rule-multi-radio").rulemultiradio(); $(".rule-single-select").rulesingleselect(); $(".rule-multi-porp").rulemultiporp(); }); //鍏ㄩ€夊彇娑堟寜閽嚱鏁� function checkall(chkobj) { if ($(chkobj).text() == "鍏ㄩ€�") { $(chkobj).children("span").text("鍙栨秷"); $(".checkall input:enabled").prop("checked", true); } else { $(chkobj).children("span").text("鍏ㄩ€�"); $(".checkall input:enabled").prop("checked", false); } } //tab鎺у埗鍑芥暟 function tabs(tabobj) { var tabnum = $(tabobj).parent().index("li") //璁剧疆鐐瑰嚮鍚庣殑鍒囨崲鏍峰紡 $(tabobj).parent().parent().find("li a").removeclass("selected"); $(tabobj).addclass("selected"); //鏍规嵁鍙傛暟鍐冲畾鏄剧ず鍐呭 $(".tab-content").hide(); $(".tab-content").eq(tabnum).show(); } //===========================宸ュ叿绫诲嚱鏁�============================ //鍙厑璁歌緭鍏ユ暟瀛� function checknumber(e) { if (isfirefox = navigator.useragent.indexof("firefox") > 0) { //ff if (!((e.which >= 48 && e.which <= 57) || (e.which >= 96 && e.which <= 105) || (e.which == 8) || (e.which == 46))) return false; } else { if (!((event.keycode >= 48 && event.keycode <= 57) || (event.keycode >= 96 && event.keycode <= 105) || (event.keycode == 8) || (event.keycode == 46))) event.returnvalue = false; } } //妫€鏌ョ煭淇″瓧鏁� function checktxt(obj, txtid) { var txtcount = $(obj).val().length; if (txtcount < 1) { return false; } var smslength = math.ceil(txtcount / 62); $("#" + txtid).html("鎮ㄥ凡杈撳叆" + txtcount + "涓瓧绗︼紝灏嗕互" + smslength + "鏉$煭淇℃墸鍙栬垂鐢ㄣ€�"); } //妫€鏌ョ煭淇″瓧鏁� function checktxt2(obj, txtid) { var txtcount = $(obj).val().length; if (txtcount < 1) { return false; } var smslength = math.ceil(txtcount / 62); $("#" + txtid).html("鎮ㄥ凡杈撳叆" + txtcount + "涓瓧绗�"); } //鍥涜垗浜斿叆鍑芥暟 function fordight(dight, how) { dight = math.round(dight * math.pow(10, how)) / math.pow(10, how); return dight; } //鍐機ookie function addcookie(objname, objvalue, objhours) { var str = objname + "=" + escape(objvalue); if (objhours > 0) {//涓�0鏃朵笉璁惧畾杩囨湡鏃堕棿锛屾祻瑙堝櫒鍏抽棴鏃禼ookie鑷姩娑堝け var date = new date(); var ms = objhours * 3600 * 1000; date.settime(date.gettime() + ms); str += "; expires=" + date.togmtstring(); } document.cookie = str; } //璇籆ookie function getcookie(objname) {//鑾峰彇鎸囧畾鍚嶇о鐨刢ookie鐨勫€� var arrstr = document.cookie.split("; "); for (var i = 0; i < arrstr.length; i++) { var temp = arrstr[i].split("="); if (temp[0] == objname) return unescape(temp[1]); } return ""; } //========================鍩轰簬lhgdialog鎻掍欢======================== //鍙互鑷姩鍏抽棴鐨勬彁绀猴紝鍩轰簬lhgdialog鎻掍欢 function jsprint(msgtitle, url, msgcss, callback) { var iconurl = ""; switch (msgcss) { case "success": iconurl = "32x32/succ.png"; break; case "error": iconurl = "32x32/fail.png"; break; default: iconurl = "32x32/hits.png"; break; } $.dialog.tips(msgtitle, 2, iconurl); if (url == "back") { frames["mainframe"].history.back(-1); } else if (url != "") { frames["mainframe"].location.href = url; } //鎵ц鍥炶皟鍑芥暟 if (arguments.length == 4) { callback(); } } //寮瑰嚭涓€涓狣ialog绐楀彛 function jsdialog(msgtitle, msgcontent, url, msgcss, callback) { var iconurl = ""; var argnum = arguments.length; switch (msgcss) { case "success": iconurl = "success.gif"; break; case "error": iconurl = "error.gif"; break; default: iconurl = "alert.gif"; break; } var dialog = $.dialog({ title: msgtitle, content: msgcontent, fixed: true, min: false, max: false, lock: true, icon: iconurl, ok: true, close: function () { if (url == "back") { history.back(-1); } else if (url != "") { location.href = url; } //鎵ц鍥炶皟鍑芥暟 if (argnum == 5) { callback(); } } }); } //鎵撳紑涓€涓渶澶у寲鐨凞ialog function showmaxdialog(tit, url) { $.dialog({ title: tit, content: 'url:' + url, min: false, max: false, lock: false }).max(); } //鎵ц鍥炰紶鍑芥暟 function exepostback(objid, objmsg) { if ($(".checkall input:checked").size() < 1) { $.dialog.alert('瀵逛笉璧凤紝璇烽€変腑鎮ㄨ鎿嶄綔鐨勮褰曪紒'); return false; } var msg = "鍒犻櫎璁板綍鍚庝笉鍙仮澶嶏紝鎮ㄧ‘瀹氬悧锛�"; if (arguments.length == 2) { msg = objmsg; } $.dialog.confirm(msg, function () { __dopostback(objid, ''); }); return false; } //妫€鏌ユ槸鍚︽湁閫変腑鍐嶅喅瀹氬洖浼� function checkpostback(objid, objmsg) { var msg = "瀵逛笉璧凤紝璇烽€変腑鎮ㄨ鎿嶄綔鐨勮褰曪紒"; if (arguments.length == 2) { msg = objmsg; } if ($(".checkall input:checked").size() < 1) { $.dialog.alert(msg); return false; } __dopostback(objid, ''); return false; } //鎵ц鍥炰紶鏃犲閫夋纭鍑芥暟 function exenocheckpostback(objid, objmsg) { var msg = "鍒犻櫎璁板綍鍚庝笉鍙仮澶嶏紝鎮ㄧ‘瀹氬悧锛�"; if (arguments.length == 2) { msg = objmsg; } $.dialog.confirm(msg, function () { __dopostback(objid, ''); }); return false; } //鎵ц鍥炰紶鏃犲閫夋纭鍑芥暟 function exenocheckpostback2(objid, objmsg,url) { var msg = "鍒犻櫎璁板綍鍚庝笉鍙仮澶嶏紝鎮ㄧ‘瀹氬悧锛�"; if (arguments.length == 2) { msg = objmsg; } $.dialog.confirm(msg, function () { $.ajax({ url: url, data: { id: objid,action: "delete" }, success: function (obj) { if (obj == "ok") { parent.jsprint("鍒犻櫎鎴愬姛","/admin/settings/area_list.aspx","success"); } else { $.dialog.alert(obj); } } }); }); return false; } //======================浠ヤ笂鍩轰簬lhgdialog鎻掍欢====================== //========================鍩轰簬validform鎻掍欢======================== //鍒濆鍖栭獙璇佽〃鍗� $.fn.initvalidform = function () { var checkvalidform = function (formobj) { $(formobj).validform({ tiptype: function (msg, o, cssctl) { /*msg锛氭彁绀轰俊鎭�; o:{obj:*,type:*,curform:*} obj鎸囧悜鐨勬槸褰撳墠楠岃瘉鐨勮〃鍗曞厓绱狅紙鎴栬〃鍗曞璞★級锛� type鎸囩ず鎻愮ず鐨勭姸鎬侊紝鍊间负1銆�2銆�3銆�4锛� 1锛氭鍦ㄦ娴�/鎻愪氦鏁版嵁锛�2锛氶€氳繃楠岃瘉锛�3锛氶獙璇佸け璐ワ紝4锛氭彁绀篿gnore鐘舵€侊紱 curform涓哄綋鍓峟orm瀵硅薄; cssctl:鍐呯疆鐨勬彁绀轰俊鎭牱寮忔帶鍒跺嚱鏁帮紝璇ュ嚱鏁伴渶浼犲叆涓や釜鍙傛暟锛氭樉绀烘彁绀轰俊鎭殑瀵硅薄 鍜� 褰撳墠鎻愮ず鐨勭姸鎬侊紙鏃㈠舰鍙俹涓殑type锛夛紱*/ //鍏ㄩ儴楠岃瘉閫氳繃鎻愪氦琛ㄥ崟鏃秓.obj涓鸿琛ㄥ崟瀵硅薄; if (!o.obj.is("form")) { //瀹氫綅鍒扮浉搴旂殑tab椤甸潰 if (o.obj.is(o.curform.find(".validform_error:first"))) { var tabobj = o.obj.parents(".tab-content"); //鏄剧ず褰撳墠鐨勯€夐」 var tabindex = $(".tab-content").index(tabobj); //鏄剧ず褰撳墠閫夐」绱㈠紩 if (!$(".content-tab ul li").eq(tabindex).children("a").hasclass("selected")) { $(".content-tab ul li a").removeclass("selected"); $(".content-tab ul li").eq(tabindex).children("a").addclass("selected"); $(".tab-content").hide(); tabobj.show(); } } //椤甸潰涓婁笉瀛樺湪鎻愮ず淇℃伅鐨勬爣绛炬椂锛岃嚜鍔ㄥ垱寤�; if (o.obj.parents("dd").find(".validform_checktip").length == 0) { o.obj.parents("dd").append(""); o.obj.parents("dd").next().find(".validform_checktip").remove(); } var objtip = o.obj.parents("dd").find(".validform_checktip"); cssctl(objtip, o.type); objtip.text(msg); } }, showallerror: true }); }; return $(this).each(function () { checkvalidform($(this)); }); } //======================浠ヤ笂鍩轰簬validform鎻掍欢====================== //鏅鸿兘娴姩灞傚嚱鏁� $.fn.smartfloat = function() { var position = function(element) { var top = element.position().top; var pos = element.css("position"); $(window).scroll(function() { var scrolls = $(this).scrolltop(); if (scrolls > top) { if (window.xmlhttprequest) { element.css({ position: "fixed", top: 0 }); } else { element.css({ top: scrolls }); } }else { element.css({ position: pos, top: top }); } }); }; return $(this).each(function() { position($(this)); }); }; //澶嶉€夋 $.fn.rulesinglecheckbox = function () { var singlecheckbox = function (parentobj) { //鏌ユ壘澶嶉€夋 var checkobj = parentobj.children('input:checkbox').eq(0); parentobj.children().hide(); //娣诲姞鍏冪礌鍙婃牱寮� var newobj = $('' + '鍚�' + '鏄�' + '').prependto(parentobj); parentobj.addclass("single-checkbox"); //鍒ゆ柇鏄惁閫変腑 if (checkobj.prop("checked") == true) { newobj.addclass("selected"); } //妫€鏌ユ帶浠舵槸鍚﹀惎鐢� if(checkobj.prop("disabled") == true){ newobj.css("cursor","default"); return; } //缁戝畾浜嬩欢 $(newobj).click(function () { if ($(this).hasclass("selected")) { $(this).removeclass("selected"); //checkobj.prop("checked", false); } else { $(this).addclass("selected"); //checkobj.prop("checked", true); } checkobj.trigger("click"); //瑙﹀彂瀵瑰簲鐨刢heckbox鐨刢lick浜嬩欢 }); }; return $(this).each(function () { singlecheckbox($(this)); }); }; //澶氶」澶嶉€夋 $.fn.rulemulticheckbox = function() { var multicheckbox = function(parentobj){ parentobj.addclass("multi-checkbox"); //娣诲姞鏍峰紡 parentobj.children().hide(); //闅愯棌鍐呭 var divobj = $('
').prependto(parentobj); //鍓嶆彃鍏ヤ竴涓狣iv parentobj.find(":checkbox").each(function(){ var indexnum = parentobj.find(":checkbox").index(this); //褰撳墠绱㈠紩 var newobj = $('' + parentobj.find('label').eq(indexnum).text() + '').appendto(divobj); //鏌ユ壘瀵瑰簲label鍒涘缓閫夐」 if($(this).prop("checked") == true){ newobj.addclass("selected"); //榛樿閫変腑 } //妫€鏌ユ帶浠舵槸鍚﹀惎鐢� if($(this).prop("disabled") == true){ newobj.css("cursor","default"); return; } //缁戝畾浜嬩欢 $(newobj).click(function(){ if($(this).hasclass("selected")){ $(this).removeclass("selected"); //parentobj.find(':checkbox').eq(indexnum).prop("checked",false); }else{ $(this).addclass("selected"); //parentobj.find(':checkbox').eq(indexnum).prop("checked",true); } parentobj.find(':checkbox').eq(indexnum).trigger("click"); //瑙﹀彂瀵瑰簲鐨刢heckbox鐨刢lick浜嬩欢 //alert(parentobj.find(':checkbox').eq(indexnum).prop("checked")); }); }); }; return $(this).each(function() { multicheckbox($(this)); }); } //澶氶」閫夐」prop $.fn.rulemultiporp = function() { var multiporp = function(parentobj){ parentobj.addclass("multi-porp"); //娣诲姞鏍峰紡 parentobj.children().hide(); //闅愯棌鍐呭 var divobj = $('