$.fn.extend({ limitinput: function () { $(this).keydown(function (event) { if ((45 < event.keycode && event.keycode < 58) || (95 < event.keycode && event.keycode < 106) || event.keycode == 17 || event.keycode == 16 || event.keycode == 8 || (32 < event.keycode && event.keycode < 41)) { return } event.preventdefault() }) }, createinput: function (type, id, name, value, appendtarget) { if (type == null) return; var hdninput = $("#" + id); if (hdninput.length == 0) { var inputstr = '' } if (appendtarget != null) { $(inputstr).appendto(appendtarget) } else { return inputstr } } else { hdninput.val(value) } }, removeinput: function (name) { $(name).remove() } }); string.prototype.replaceall = function (reallydo, replacewith, ignorecase) { if (!regexp.prototype.isprototypeof(reallydo)) { return this.replace(new regexp(reallydo, (ignorecase ? "gi" : "g")), replacewith) } else { return this.replace(reallydo, replacewith) } } string.prototype.trim = function () { return this.replace(/^\s+|\s+$/g, ""); }; string.prototype.format = function (args) { var result = this; if (arguments.length > 0) { if (arguments.length == 1 && typeof (args) == "object") { for (var key in args) { if (args[key] != undefined) { var reg = new regexp("({" + key + "})", "g"); result = result.replace(reg, args[key]) } } } else { for (var i = 0; i < arguments.length; i++) { if (arguments[i] != undefined) { var reg = new regexp("({)" + i + "(})", "g"); result = result.replace(reg, arguments[i]) } } } } return result }; string.prototype.updateparams = function (pstr, vstr) { var query = this.substring(this.indexof("?")); var newquery = ""; if (pstr && vstr) { var str = (query.substring(0, 1) == "?") ? query.substring(1) : query; var array = (str.indexof("&")!=-1)?str.split('&'):[]; for (var i = 0; i < array.length; i++) { if (pstr.indexof(array[i].split('=')[0]) == -1) { newquery += ((newquery.indexof("?") != -1) ? "&" : "?") + array[i] } } var pstrarray = pstr.split(','); var vstrarray = vstr.split(','); if (pstrarray.length == vstrarray.length) { for (var i = 0; i < pstrarray.length; i++) { newquery += (newquery.indexof("?") != -1) ? "&" : "?"; newquery += pstrarray[i] + "=" + vstrarray[i] } } var url = this; if (url.indexof("?") == -1) { return (url + newquery); } else { return (url.substring(0, url.indexof("?")) + newquery); } } return null }; (function ($) { $.fn.jdmarquee = function (option, callback) { if (typeof option == "function") { callback = option; option = {}; }; var s = $.extend({ deriction: "up", speed: 10, auto: false, width: null, height: null, step: 1, control: false, _front: null, _back: null, _stop: null, _continue: null, wrapstyle: "", stay: 5000, delay: 20, dom: "div>ul>li".split(">"), maintimer: null, subtimer: null, tag: false, convert: false, btn: null, disabled: "disabled", pos: { ojbect: null, clone: null } }, option || {}); var object = this.find(s.dom[1]); var subobject = this.find(s.dom[2]); var clone; if (s.deriction == "up" || s.deriction == "down") { var height = object.eq(0).outerheight(); var step = s.step * subobject.eq(0).outerheight(); object.css({ width: s.width + "px", overflow: "hidden" }); }; if (s.deriction == "left" || s.deriction == "right") { var width = subobject.length * subobject.eq(0).outerwidth(); object.css({ width: width + "px", overflow: "hidden" }); var step = s.step * subobject.eq(0).outerwidth(); }; var init = function () { var wrap = "
"; object.css({ position: "absolute", left: 0, top: 0 }).wrap(wrap); s.pos.object = 0; clone = object.clone(); object.after(clone); switch (s.deriction) { default: case "up": object.css({ marginleft: 0, margintop: 0 }); clone.css({ marginleft: 0, margintop: height + "px" }); s.pos.clone = height; break; case "down": object.css({ marginleft: 0, margintop: 0 }); clone.css({ marginleft: 0, margintop: -height + "px" }); s.pos.clone = -height; break; case "left": object.css({ margintop: 0, marginleft: 0 }); clone.css({ margintop: 0, marginleft: width + "px" }); s.pos.clone = width; break; case "right": object.css({ margintop: 0, marginleft: 0 }); clone.css({ margintop: 0, marginleft: -width + "px" }); s.pos.clone = -width; break; }; if (s.auto) { initmaintimer(); object.hover(function () { clear(s.maintimer); }, function () { initmaintimer(); }); clone.hover(function () { clear(s.maintimer); }, function () { initmaintimer(); }); }; if (callback) { callback(); }; if (s.control) { initcontrols(); } }; var initmaintimer = function (delay) { clear(s.maintimer); s.stay = delay ? delay : s.stay; s.maintimer = setinterval(function () { initsubtimer() }, s.stay); }; var initsubtimer = function () { clear(s.subtimer); s.subtimer = setinterval(function () { roll() }, s.delay); }; var clear = function (timer) { if (timer != null) { clearinterval(timer); } }; var discontrol = function (a) { if (a) { $(s._front).unbind("click"); $(s._back).unbind("click"); $(s._stop).unbind("click"); $(s._continue).unbind("click"); } else { initcontrols(); } }; var initcontrols = function () { if (s._front != null) { $(s._front).click(function () { $(s._front).addclass(s.disabled); discontrol(true); clear(s.maintimer); s.convert = true; s.btn = "front"; if (!s.auto) { s.tag = true; }; convert(); }); }; if (s._back != null) { $(s._back).click(function () { $(s._back).addclass(s.disabled); discontrol(true); clear(s.maintimer); s.convert = true; s.btn = "back"; if (!s.auto) { s.tag = true; }; convert(); }); }; if (s._stop != null) { $(s._stop).click(function () { clear(s.maintimer); }); }; if (s._continue != null) { $(s._continue).click(function () { initmaintimer(); }); } }; var convert = function () { if (s.tag && s.convert) { s.convert = false; if (s.btn == "front") { if (s.deriction == "down") { s.deriction = "up"; }; if (s.deriction == "right") { s.deriction = "left"; } }; if (s.btn == "back") { if (s.deriction == "up") { s.deriction = "down"; }; if (s.deriction == "left") { s.deriction = "right"; } }; if (s.auto) { initmaintimer(); } else { initmaintimer(4 * s.delay); } } }; var setpos = function (y1, y2, x) { if (x) { clear(s.subtimer); s.pos.object = y1; s.pos.clone = y2; s.tag = true; } else { s.tag = false; }; if (s.tag) { if (s.convert) { convert(); } else { if (!s.auto) { clear(s.maintimer); } } }; if (s.deriction == "up" || s.deriction == "down") { object.css({ margintop: y1 + "px" }); clone.css({ margintop: y2 + "px" }); }; if (s.deriction == "left" || s.deriction == "right") { object.css({ marginleft: y1 + "px" }); clone.css({ marginleft: y2 + "px" }); } }; var roll = function () { var y_object = (s.deriction == "up" || s.deriction == "down") ? parseint(object.get(0).style.margintop) : parseint(object.get(0).style.marginleft); var y_clone = (s.deriction == "up" || s.deriction == "down") ? parseint(clone.get(0).style.margintop) : parseint(clone.get(0).style.marginleft); var y_add = math.max(math.abs(y_object - s.pos.object), math.abs(y_clone - s.pos.clone)); var y_ceil = math.ceil((step - y_add) / s.speed); switch (s.deriction) { case "up": if (y_add == step) { setpos(y_object, y_clone, true); $(s._front).removeclass(s.disabled); discontrol(false); } else { if (y_object <= -height) { y_object = y_clone + height; s.pos.object = y_object; }; if (y_clone <= -height) { y_clone = y_object + height; s.pos.clone = y_clone; }; setpos((y_object - y_ceil), (y_clone - y_ceil)); }; break; case "down": if (y_add == step) { setpos(y_object, y_clone, true); $(s._back).removeclass(s.disabled); discontrol(false); } else { if (y_object >= height) { y_object = y_clone - height; s.pos.object = y_object; }; if (y_clone >= height) { y_clone = y_object - height; s.pos.clone = y_clone; }; setpos((y_object + y_ceil), (y_clone + y_ceil)); }; break; case "left": if (y_add == step) { setpos(y_object, y_clone, true); $(s._front).removeclass(s.disabled); discontrol(false); } else { if (y_object <= -width) { y_object = y_clone + width; s.pos.object = y_object; }; if (y_clone <= -width) { y_clone = y_object + width; s.pos.clone = y_clone; }; setpos((y_object - y_ceil), (y_clone - y_ceil)); }; break; case "right": if (y_add == step) { setpos(y_object, y_clone, true); $(s._back).removeclass(s.disabled); discontrol(false); } else { if (y_object >= width) { y_object = y_clone - width; s.pos.object = y_object; }; if (y_clone >= width) { y_clone = y_object - width; s.pos.clone = y_clone; }; setpos((y_object + y_ceil), (y_clone + y_ceil)); }; break; } }; if (s.deriction == "up" || s.deriction == "down") { if (height >= s.height && height >= s.step) { init(); } }; if (s.deriction == "left" || s.deriction == "right") { if (width >= s.width && width >= s.step) { init(); } } } })(jquery); (function () { if (!window.air) { window.air = {}; }; window.air = { versions: function () { var u = navigator.useragent, app = navigator.appversion; return {//移动终端浏览器版本信息 trident: u.indexof('trident') > -1, //ie内核 presto: u.indexof('presto') > -1, //opera内核 webkit: u.indexof('applewebkit') > -1, //苹果、谷歌内核 gecko: u.indexof('gecko') > -1 && u.indexof('khtml') == -1, //火狐内核 mobile: !!u.match(/applewebkit.*mobile.*/) || !!u.match(/applewebkit/), //是否为移动终端 ios: !!u.match(/\(i[^;]+;( u;)? cpu.+mac os x/), //ios终端 android: u.indexof('android') > -1 || u.indexof('linux') > -1, //android终端或者uc浏览器 iphone: u.indexof('iphone') > -1 || u.indexof('mac') > -1, //是否为iphone或者qqhd浏览器 ipad: u.indexof('ipad') > -1, //是否ipad webapp: u.indexof('safari') == -1,//是否web应该程序,没有头部与底部 google: u.indexof('chrome') > -1 }; }(), base: function () { if (typeof (basepath) == 'undefined') { return null; } return basepath; }, ajaxurl:function() { return (this.base() + '/ajax.do'); }, undef: function (val,defaultval) { if(typeof (defaultval) != "string"){ return (val === undefined || isnan(val) || val<=0) ? defaultval : val; }else{ return val === undefined ? defaultval : val; } }, submitform: function (formid, actionurl, target) { var form = $(formid); if (actionurl != null) { form.attr("target", target) } if (actionurl != null) { form.attr("action", actionurl) } settimeout(function () { form.submit(); }, 50); }, formtojson:function(form) { var o = {}; var a = form.serializearray(); $.each(a, function () { if (o[this.name] !== undefined) { if (!o[this.name].push) { o[this.name] = [o[this.name]]; } o[this.name].push(this.value || ''); } else { o[this.name] = this.value || ''; } }); return o; }, createinput: function (type, id, name, value, target) { if (!type) return; var hdninput = $("#" + id); if (hdninput.length == 0) { var inputstr = ''} if (target) {$(inputstr).appendto(target) }else {return inputstr} } else { hdninput.val(value); } }, eval:function(fn) { var fn = function; return new fn('return ' + fn)(); }, getvc:function(t) { $(t).attr({ src: this.base() + '/verify_code.do?id=' + math.random() }); return false; }, initselectbyid:function(id, value) { $(id).find("option").each(function(i, n) { n.selected = (n.value != value) ? false : true }) }, initselectbyname:function(name, value) { $("select[name='" + name + "']").find("option").each(function(i, n) { n.selected = (n.value != value) ? false : true }) }, initcheckboxbyid:function(id, value) { $(id).attr("checked", (value == 0) ? false : true) }, initcheckbox:function(name, value) { $("input:checkbox[name='" + name + "']").each(function(i, n) { n.checked = (n.value != value) ? false : true }) }, initcheckboxgourp:function(name, value) { var valuesp = ',' + value + ','; $("input:checkbox[name='" + name + "']").each(function(i, n) { n.checked = (valuesp.indexof("," + n.value + ",") >= 0) ? true : false }) }, initradiobyname:function(name, value) { $("input:radio[name='" + name + "']").each(function(i, n) { n.checked = (n.value != value) ? false : true }) }, isnull:function(val) { switch (typeof(val)) { case "string": return val.trim().length == 0 ? true : false; break; case "number": return val == 0; break; case "object": return val == null; break; case "array": return val.length == 0; break; default: return true } }, isnumber:function(value,minvalue) { return ((typeof value === 'number' && isfinite(value)) && value > minvalue) ? true : false; }, isarray:function(obj) { return object.prototype.tostring.call(obj) === '[object array]'; }, ismobile: function () { return (this.versions.android || this.versions.ios) ? true : false; }, isiswechat: function () { var ua = window.navigator.useragent.tolowercase(); if (ua.match(/micromessenger/i) == 'micromessenger') { return true; } else { return false; } }, asynccheckbox:function(postname, appendtarget) { $("input[type=hidden][name='" + postname + "']").remove(); $("input[type=checkbox][postname='" + postname + "']:checked").each(function(i, n) { this.createinput("hidden", null, postname, $(this).attr("postvalue"), appendtarget) }) }, querystring:function(name) { var reg = new regexp("(^|&)" + name + "=([^&]*)(&|$)", "i"); var r = window.location.search.substr(1).match(reg); if (r != null) return unescape(r[2]); return null }, switchtab:function(id_prefix, index, on) { $("#tab_" + id_prefix + "_" + index).addclass(on).siblings().removeclass(on); $("#list_" + id_prefix + "_" + index).fadein("fast").siblings().hide() }, setexpiretime: function (obj, callback) { //倒计时 var ele = obj, time = ele.attr('left_time_int'); if (isnan(time) || math.floor(time) <= 0) { ele.find("em").text("0"); if (typeof(callback) != "undefined") { settimeout(callback, 0) } } else { var dd = math.floor(time / (60 * 60 * 24)); var hh = math.floor(time / (60 * 60)) % 24; var mm = math.floor(time / 60) % 60; var ss = math.floor(time % 60); var ee = 0; var check_dd = dd; dd = dd > 9 ? dd : '0' + dd; hh = hh > 9 ? hh : '0' + hh; mm = mm > 9 ? mm : '0' + mm; ss = ss > 9 ? ss : '0' + ss; var time_str = time + ''; ele.children(":eq(0)").text(dd); ele.children(":eq(1)").text(hh); ele.children(":eq(2)").text(mm); ele.children(":eq(3)").text(ss); time = time - 1; time = time.tofixed(1); ele.attr('left_time_int', time); settimeout(function() { this.setexpiretime(obj, callback) }, 1000) } }, shake: function (ele, cls, times) { //闪动 ele = $(ele); var i = 0, t = false, o = ele.attr("class") + " ", c = "", times = times || 2; if (t) return; t = setinterval(function() { i++; c = i % 2 ? o + cls : o; ele.attr("class", c); if (i == 2 * times) { clearinterval(t); ele.removeclass(cls) } }, 200) }, hashtable:function() { this.objarr = {}, this.count = 0, this.add = function(e, t) { return this.objarr.hasownproperty(e) ? !1 : (this.objarr[e] = t, this.count++, !0) }, this.contains = function(e) { return this.objarr.hasownproperty(e) }, this.getvalue = function(e) { if (this.contains(e)) return this.objarr[e]; throw error("hashtable not cotains the key: " + string(e)) }, this.remove = function(e) { this.contains(e) && (delete this.objarr[e], this.count--) }, this.clear = function() { this.objarr = {}, this.count = 0 } }, changsendtime: function (time_flg, flag) { //时间段选择 // // var sid = flag ? '#o_' : '#'; var send_start_time = $(sid + 'send_start_time').find("option:selected").val(); var send_end_time = $(sid + 'send_end_time').find("option:selected").val(); if (send_start_time < send_end_time) { if (time_flg == 2 && send_start_time == "") { if (parseint(send_end_time.substring(2)) == 3000) { $(sid + "send_start_time").val(parseint(send_end_time) - 7000); } else { var temp = parseint(send_end_time.substring(0, 2)); $(sid + "send_start_time").val(parseint(send_end_time) - 3000); } } return false; } if (time_flg == 1) { if (send_start_time.substring(2) == "3000") { $(sid + "send_end_time").val(parseint(send_start_time) + 7000); } else { var temp = parseint(send_start_time.substring(0, 2)); /*if((temp >= 10 && temp< 13) || (temp >= 16 && temp< 18)) { $("#send_end_time").val(parseint(send_start_time) + 10000); } else {*/ $(sid + "send_end_time").val(parseint(send_start_time) + 3000); /*}*/ } } else { if (send_end_time) { if (parseint(send_end_time.substring(2)) == 3000) { $(sid + "send_start_time").val(parseint(send_end_time) - 3000); } else { var temp = parseint(send_end_time.substring(0, 2)); $(sid + "send_start_time").val(parseint(send_end_time) - 7000); } } else $(sid + "send_start_time").find("option").eq(0).attr("selected", true); } }, resetmodeltag:function(modehtml) { if (typeof(modehtml) != "undefined" && modehtml != "") { return modehtml.replace("", "").replaceall("mtr", "tr").replaceall("mtd", "td"); } return null; }, appendmodel:function(e, modelitem, modelcenter, maxcount) { modelcenter = $(modelcenter), modelcurcount = modelcenter.children().length; if (maxcount - modelcurcount > 0) { if (modelcurcount + 1 == maxcount) { $(e).hide().children("span").addclass("dis"); } $(this.resetmodeltag($(modelitem).html()).replace(/{i}/g, modelcurcount + 1)).appendto(modelcenter); } }, removemodel:function(e, appendmodel, delname, delid, target) { $(e).remove(); if (delid != null && !isnan(delid) && number(delid) > 0) { this.createinput("hidden", (delname + delid), delname, delid, (typeof(target) == "undefined") ? document.forms[0] : target); } $(appendmodel).show().children("span").removeclass("dis"); }, parseurl: function (url) { //调用方法 //var myurl = this.parseurl('http://abc.com:8080/dir/index.html?id=255&m=hello#top'); //myurl.file; // = 'index.html' //myurl.hash; // = 'top' //myurl.host; // = 'abc.com' //myurl.query; // = '?id=255&m=hello' //myurl.params; // = object = { id: 255, m: hello } //myurl.path; // = '/dir/index.html' //myurl.segments; // = array = ['dir', 'index.html'] //myurl.port; // = '8080' //myurl.protocol; // = 'http' //myurl.source; // = 'http://abc.com:8080/dir/index.html?id=255&m=hello#top' var a = document.createelement('a'); a.href = url; return { source: url, protocol: a.protocol.replace(':', ''), host: a.hostname, port: a.port, query: a.search, params: (function () { var ret = {}, seg = a.search.replace(/^\?/, '').split('&'), len = seg.length, i = 0, s; for (; i < len; i++) { if (!seg[i]) { continue; } s = seg[i].split('='); ret[s[0]] = s[1]; } return ret; })(), file: (a.pathname.match(/\/([^\/?#]+)$/i) || [, ''])[1], hash: a.hash.replace('#', ''), path: a.pathname.replace(/^([^\/])/, '/$1'), relative: (a.href.match(/tps?:\/\/[^\/]+(.+)/) || [, ''])[1], segments: a.pathname.replace(/^\//, '').split('/') }; }, setcookie:function(name, value) { var days = 30; var exp = new date(); exp.settime(exp.gettime() + days * 24 * 60 * 60 * 1000); document.cookie = name + "=" + escape(value) + ";expires=" + exp.togmtstring(); }, getcookie:function(name) { var arr, reg = new regexp("(^| )" + name + "=([^;]*)(;|$)"); if (arr = document.cookie.match(reg)) return unescape(arr[2]); else return null; }, pager: { //
// init: function (container,params) { this.container = $(container); this.params = params; this.change(1); }, change: function (page) { var container = this.container; $.ajax({ type: "post", url: air.ajaxurl(), data:$.extend(this.params, { page: page }), datatype: 'json', beforesend: function (xhr) { container.html("
评论数据载入中,请稍候..
"); }, success: function (data) { if (data.state != 0) { container.html(unescape(data.response)); } else { container.empty(); } } }); if (page > 1) { $("html,body").scrolltop(0).animate({ scrolltop: (container.offset().top + container.height()) }, 1); } } }, date: { head: function () { return [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; }, init: function (year, month, day, yval, mval, dval) { var y = document.getelementbyid(year); var m = document.getelementbyid(month); var d = document.getelementbyid(day); var fy = new date().getfullyear(); for (var i = (fy - 60) ; i < (fy + 60) ; i++) { this.appendoption(y, i) } this.selectvalue(y, yval); if (m != null) { this.writemonth(m); this.selectvalue(m, mval) } if (d != null) { var n = this.head()[m.value - 1]; if (m.value == 2 && this.ispinyear(y.value)) n++; this.writeday(d, n); this.selectvalue(d, dval) } }, selectvalue: function (target, value) { if (typeof (value) != "undefined") { target.value = value } }, appendoption: function (target, value) { target.options.add(new option(value, value)) }, ispinyear: function (year) { return (0 == year % 4 && (year % 100 != 0 || year % 400 == 0)) }, writemonth: function (e) { this.optionsclear(e); for (var i = 1; i < 13; i++) { this.appendoption(e, i) } }, writeday: function (e, n) { this.optionsclear(e); for (var i = 1; i < (n + 1) ; i++) { this.appendoption(e, i) } }, changeyear: function (year, month, day) { var y = document.getelementbyid(year); var m = document.getelementbyid(month); var d = document.getelementbyid(day); if (m != null) { var yyyyvalue = y.options[y.selectedindex].value; if (yyyyvalue == "") { this.optionsclear(m); return } this.writemonth(m) } if (d != null) { var mmvalue = m.options[m.selectedindex].value; this.optionsclear(d); var n = this.head()[mmvalue - 1]; if (mmvalue == 2 && this.ispinyear(y.value)) n++; this.writeday(d, n) } }, changemonth: function (year, month, day) { var y = document.getelementbyid(year); var m = document.getelementbyid(month); var d = document.getelementbyid(day); if (d != null) { var yyyyvalue = y.options[y.selectedindex].value; if (yyyyvalue == "") { this.optionsclear(d); return } var n = this.head()[m.value - 1]; if (m.value == 2 && this.ispinyear(y.value)) n++; this.writeday(d, n) } }, optionsclear: function (e) { e.options.length = 1 } } }; })(); $(function () { //全选/反选 .closest("tr") $("input[type='checkbox'][checkedall]").change(function () { var checkedall = $(this); $("input[type=checkbox][isitem='true'][groupnum=" + checkedall.attr("groupnum") + "]").not(":disabled").each(function () { var self = $(this), itemid = self.val(), currow = $(".maintable tr[id='item_" + itemid + "']"); if (!checkedall.attr("checked")) { self.removeattr("checked"); currow.removeclass("on"); } else { self.attr("checked", "checked"); currow.addclass("on"); } }) }); //隔行变色 $(" tbody[islist] tr").hover(function () { $(this).addclass("hover"); }, function () { $(this).removeclass("hover"); }); //初始化,选中下拉 $("select[initval]").each(function (i, n) { $(this).val(n.getattribute("initval")) }); //初始化,选中单选 $("input[type=radio][initval]").each(function (i, n) { $("input[name='" + n.getattribute("name") + "'][value='" + n.getattribute("initval") + "']").attr("checked", "checked"); }); //初始化,选中复选框 $("input[type='checkbox'][initval]").each(function () { var selfa = $(this), initval = selfa.attr("initval"), cval = 1, uval = 0; if (initval != "undef") { valarray = initval.split(","); if (valarray && valarray.length > 1) { cval = valarray[0]; uval = valarray[1] } } selfa.click(function () { var selfb = $(this); selfb.val(selfb.prop("checked") ? cval : uval) }).prop("checked", (selfa.val() != "0") ? true : false) }); //单选或复选元素框点击后跳转到指定地址 $("[clickskip]").click(function () { var self = $(this), url = self.attr("href"); if (typeof (url) != "undefined") { document.location.href = url; } }); //下拉选择后跳转到指定地址 $("select[clickskip]").change(function () { var self = $(this), url = self.attr("href"); if (typeof (url) != "undefined") { location.href = url.replace('{0}', self.val()); } }); //设置元素背景 $("[setbg]").each(function (i, n) { var self = $(this); var bgurl = self.attr("bgurl"); var repeat = self.attr("repeat"); var x = self.attr("x"); var y = self.attr("y"); self.css({ "background": "url(" + bgurl + ") " + repeat + " " + x + " " + y + " " }); }); //元素获得焦点后改变样式 $("input[focus-class]").focus(function () { var self = $(this), focusclass = self.attr("focus-class"); self.addclass(focusclass); }).blur(function () { var self = $(this), focusclass = self.attr("focus-class"); self.removeclass(focusclass); }); //设置百分比 $("[rate='true'] span").each(function () { var self = $(this), s1 = self.attr("r1"), s2 = self.attr("r2"); self.css({ "width": (number(s2) / number(s1) * 100).tofixed(2) + "%" }); }); //初始化倒计时 $(".expire_time").each(function (i, n) { this.setexpiretime($(n)); }); //最多可输入字数 $("[maxlimit]").keyup(function () { var self = $(this), maxlimit = number(self.attr("maxlimit")); var len = self.val().length; if (len > maxlimit) { self.val(self.val().substring(0, maxlimit)); } self.siblings(".word").text(((maxlimit + 1) - len)); }); //通用操作 $(".op").click(function () { var self = $(this), mod = self.attr("mod"), act = self.attr("act"), itemid = air.undef(self.attr("itemid"), 0), msg = air.undef(self.attr("msg"), "确定执行该操作?"); if (mod && act) { if (self.hasclass("iv") && $("input[name='itemid']:checked").length <= 0) { var options = { type: 2, msg: "尚未选中任何项" }; top.msgbox.tips(options); return; } var actionurl = location.href.updateparams("mod,act", "{0},{1}").format(mod, act); if (itemid) { actionurl = actionurl.updateparams("itemid", "{0}").format(itemid); } var submitform = self.parents("form").attr("action", actionurl); if (self.hasclass("nc")) { air.submitform(submitform); } else { //var options = { // type: 3, // msg: msg, // successcallback: function () { air.submitform(submitform) } //}; //msgbox.confirm(options); if (confirm(msg)) { air.submitform(submitform); } } } }); //几秒后跳转 var seconds = $(".seconds[skipurl]"); if (seconds && seconds.length > 0) { var skipurl = seconds.attr("skipurl"); if (skipurl) { var timerseconds = seconds.text(); var interval = setinterval(function () { if (timerseconds <= 0) { clearinterval(interval); } seconds.html(timerseconds); if (timerseconds <= 0) { settimeout(function () { location.href = skipurl; }, 300); } timerseconds--; }, 1000); } } //提示确认后再跳转 $("a[confirm]").click(function () { var self = $(this), info = self.attr("confirm"); if (info && confirm(info)) { return true; } return false; }); $(".submit-form").click(function () { var self = $(this), action = self.attr("action"), form = self.parents("form"); if (form && form.length > 0) { if (typeof (action) != "undefined" && action != "") { form.attr("action",action); } form.submit(); } }); });