+function ($) { "use strict"; $.format = function(o) { var newObj = { success: 0 }, str = o; if (typeof str == "undefined") { return newObj; } if (str.indexOf("{") != -1) { str = str.substring(str.indexOf("{"), str.lastIndexOf("}") + 1); newObj = $.extend({}, newObj, str.toJSON()); newObj.success = 1; } return newObj; }; $.fn.Options = function(options) { return options == null ? $.format($(this).attr("class")) : (typeof(options) == "object" ? options : $.format($(this).attr(options))); }; }($); (function(){ String.prototype.trim = function() { return this.replace(/^\s+/, "").replace(/\s+$/, ""); }; String.prototype.isEmpty = function() { var s = this.trim(); return s.length == 0; }; String.prototype.toText = function() { var str = this; str = str.replace(//g, ">"); str = str.replace(/\n\r/g, "
"); str = str.replace(/\n/g, "
"); str = str.replace(/\r/g, "
"); return str; }; String.prototype.toHtml = function() { var str = this; str = str.replace(/</g, "<"); str = str.replace(/>/g, ">"); str = str.replace(/\n\r/g, "
"); str = str.replace(/\n/g, "
"); str = str.replace(/\r/g, "
"); return str; }; 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 regStr = "", num = i.toString(); for (j = 0; j < num.length; j++) { regStr += "[" + num.substr(j, 1) + "]{1}"; } var reg = new RegExp("{" + regStr + "}", "g"); result = result.replace(reg, arguments[i]); } } } } return result; }; String.prototype.formatMoney = function(s) { var num = this.toString().replace(/[^\d.]/g, "").split("."), s = s || ""; num.length = 2; num = num.join("."); if (isNaN(num)) { num = "0"; } var sign = (num == (num = Math.abs(num))); num = Math.floor(num * 100 + 0.50000000001); var cents = num % 100; num = Math.floor(num / 100).toString(); if (cents < 10) { cents = "0" + cents; } for (var i = 0, j = Math.floor((num.length - (1 + i)) / 3); i < j; i++) { num = num.substring(0, num.length - (4 * i + 3)) + s + num.substring(num.length - (4 * i + 3)); } return (((sign) ? '' : '-') + num + '.' + cents); }; String.prototype.toMoney = function(s) { var str = this.toString().replace(/[^\d.]/g, "").split("."); str.length = 2, s = s || "", num = ((str[0] || 0) * 1000 / 1000).toString(); str[1] = str[1] || 0; str[1] = Number("0." + str[1]).toString().substring(2, str[1].length + 2); var nums = this.toString().substr(0, 1) == '-' ? true : false; if (str[1].length < 2) { for (var i = str[1].length; i < 2; i++) { str[1] += "0"; } } for (var i = 0, j = Math.floor((num.length - (1 + i)) / 3); i < j; i++) { num = num.substring(0, num.length - (4 * i + 3)) + s + num.substring(num.length - (4 * i + 3)); } str[0] = num; return (nums ? "-" : "") + str.join("."); }; Number.prototype.toMoney = String.prototype.toMoney; Number.prototype.formatMoney = String.prototype.formatMoney; Date.prototype.Format = function(format) { var format = format || "yyyy-MM-dd hh:mm:ss", o = { "M+": this.getMonth() + 1, "d+": this.getDate(), "h+": this.getHours(), "m+": this.getMinutes(), "s+": this.getSeconds(), "q+": Math.floor((this.getMonth() + 3) / 3), "S": this.getMilliseconds() }; if (/(y+)/.test(format)) { format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)) } for (var k in o) { if (new RegExp("(" + k + ")").test(format)) { format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length)) } } return format; }; String.prototype.toDate = function(f) { return new Date(parseInt(this) * 1000).Format(f || "yyyy-MM-dd hh:mm:ss"); }; Date.prototype.add = function(milliseconds){ var m = this.getTime() + milliseconds; return new Date(m); }; Date.prototype.addSeconds = function(second){ return this.add(second * 1000); }; Date.prototype.addHours = function(hour){ return this.addMinutes(hour*60); }; Date.prototype.addMinutes = function(minute){ return this.addSeconds(minute*60); }; Date.prototype.addDate = function(format) { var format = parseInt(format, 10) || 0, time = 0; time = this.getTime() + (format * 60 * 60 * 24 * 1000); return new Date(time); }; String.prototype.dateDiff = function(date, interval) { var objInterval = { 'D': 1000 * 60 * 60 * 24, 'H': 1000 * 60 * 60, 'M': 1000 * 60, 'S': 1000, 'T': 1 }, Time = (interval || "D").toUpperCase(), start = new Date(this.replace(/-/g, "/")), end = new Date(date.replace(/-/g, "/")); try { return Math.round((end.getTime() - start.getTime()) / parseInt(eval("objInterval." + Time), 10)); } catch (e) { return e.message; } }; String.prototype.decode = function(args) { var result = this; if (arguments.length > 0) { if (arguments.length == 1) { result = args; } else { for (var i = 0; i < arguments.length; i = i + 2) { if (arguments[i] != undefined) { if (arguments[i + 1] != undefined) { if (result == arguments[i]) { result = arguments[i + 1]; break; } } else { result = arguments[i]; } } } } } return result; } String.prototype.toJSON = function() { return new Function("return " + this.toText())(); }; String.prototype.unhtml = function(reg) { return this ? this.replace(reg || /[&<">'](?:(amp|lt|quot|gt|#39|nbsp|#\d+);)?/g, function (a, b) { if (b) { return a; } else { return { '<':'<', '&':'&', '"':'"', '>':'>', "'":''' }[a] } }) : ''; }; String.prototype.html = function() { return this ? this.replace(/&((g|l|quo)t|amp|#39|nbsp);/g, function (m) { return { '<':'<', '&':'&', '"':'"', '>':'>', ''':"'", ' ':' ' }[m] }) : ''; }; $.showIndicator = function () { $(document.body).append('
'); }; $.hideIndicator = function () { $('.preloader-indicator-overlay, .preloader-indicator-modal').remove(); }; })(jQuery); +function ($) { "use strict"; $.cookie = { set:function(name, value, iDay){ iDay = iDay || 1; var oDate=new Date(); oDate.setDate(oDate.getDate()+iDay); document.cookie=name+'='+encodeURIComponent(value)+';expires='+oDate; }, get:function(name){ var arr=document.cookie.split('; '); var i=0; for(i=0;ia").live("click",function(){ var $this = $(this), childNode = $this.parent().children("ul"); if(childNode.length > 0){ $("ul",_this).addClass("contentTxt"); $(_this).find(">li>a").removeClass("active"); childNode.removeClass("contentTxt"); $($this).addClass("active"); } }); } }($); +function ($) { "use strict"; $.fn.serializeJSON = function(options){ var $this = $(this), opts = $.fn.Options.call(this, options), data = opts.data || $this.serializeArray(), list = []; $.each(data, function(i, filed){ list.push('"'+filed.name+'":"'+filed.value.trim().unhtml()+'"'); }); var newdata = "{" + list.join(',') + "}"; return newdata.toJSON(); } }($); /*input tip检测下拉*/ +function ($) { "use strict"; $.fn.autocomplete = function(urlOrData, options) { var isUrl = typeof urlOrData == "string"; options = jQuery.extend({}, jQuery.Autocompleter.defaults, { url: isUrl ? urlOrData : null, data: isUrl ? null : urlOrData, delay: isUrl ? jQuery.Autocompleter.defaults.delay : 10, max: options && !options.scroll ? 10 : 150 }, options); // if highlight is set to false, replace it with a do-nothing function options.highlight = options.highlight || function(value) { return value; }; // if the formatMatch option is not specified, then use formatItem for backwards compatibility options.formatMatch = options.formatMatch || options.formatItem; return this.each(function() { new jQuery.Autocompleter(this, options); }); } $.fn.result = function(handler) { return this.bind("result", handler); } $.fn.search = function(handler) { return this.trigger("search", [handler]); } $.fn.flushCache = function() { return this.trigger("flushCache"); } $.fn.setOptions = function(options) { return this.trigger("setOptions", [options]); }, $.fn.unautocomplete = function() { return this.trigger("unautocomplete"); } }($); /* url -- ajax查询数据地址 length -- 输入的字符长度搜索 returnId -- 接收返回数据ID width -- 下拉列表的宽度 fun -- 回调方法 是否展示可输的下拉菜单 */ +function ($) { "use strict"; $.fn.inputTips = function(url, len, back, width, fun, clickStatus) { var url = url || "", back = back || "", len = len || 2, width = width || 166, clickStatus = clickStatus == null ? false : clickStatus; if (url == "") { return false; } $(this).unbind(); $(this).autocomplete(url, { "max": 30, "minChars": len, "clickStatus":clickStatus, "width": width, "dataType": "json", parse: function(data) { return $.map(data.d.list, function(item, row) { return { data: item, value: item.value, result: item.text } }); }, formatItem: function(item, i, max) { return item.text; } }).result(function(e, data, formatted) { if (back != "") { $(back).val(data.id); } if (fun != null) { fun.call(this, data); } }).focusout(function() { var val = $(this).val().trim(); if (back != "" && val == "") { $(back).val(""); } if (fun != null && val == "") { fun.call(this, {}); } }).keyup(function() { var val = $(this).val().trim(); if (back != "" && val == "") { $(back).val(""); } }); } }($); /*输入强制转换数字类型*/ +function ($) { "use strict"; $.fn.number = function(options) { if (typeof options === 'function') { var opts = { fun: options }; } else { var opts = $.fn.Options.call(this, options); opts = $.extend({}, { fun: null }, opts); }; $(this).bind('keyup afterpaste focusout', function(e) { var oldVal = this.value, val = oldVal.replace(/[^\d.]/g, '').replace(/^\./g, "").replace(/\.{2,}/g, ".").replace(".", "$#$").replace(/\./g, "").replace("$#$", "."); opts.place && val > opts.place ? this.value = "":""; if (e.type == 'focusout') { if (typeof opts.fun === 'function') { var val = this.value * 1; opts.fun.call(this, val); }; }; if (oldVal != val) { this.value = val; }; }); } }($); +function ($) { "use strict"; $.fn.hoverTable = function(tr) { var $Class = $(this), tr = tr || false; $Class.find("tbody").find("tr").removeClass("trSplit").off("click mouseenter mouseleave"); if (tr) { $Class.each(function(index, element) { $(this).find("thead").find("th").last().addClass("lastTh"); $Class.eq(index).find("tbody").find("tr").each(function(i, element) { if (i % 2 == 1) { $(this).addClass("trSplit"); } }); }); } $Class.find("tbody").find("tr").bind({ mouseenter: function() { $(this).addClass("trHover"); }, mouseleave: function() { $(this).removeClass("trHover"); } }); } }($); /*没有数据时显示提示*/ +function ($) { "use strict"; $.fn.info = function(msg, type) { var $this = $(this), msg = msg || '', $thead = $this.closest("table").find("thead"); if(type == 1){ $this.addClass("noInfo").html(""+msg); }else{ if($thead.length > 0) $this.html(""+msg+""); else $this.html(""+msg+""); } } }($); /*获取地址栏参数值*/ +function ($) { "use strict"; $.getParam = function(name){ var url = window.location.href, urlArr = url.split("?"); var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)"); if(urlArr.length > 1){ var r = urlArr[1].match(reg); if (r != null) return unescape(encodeURIComponent(r[2])); return null; }else return null; } }($); +function ($) { "use strict"; uiAlert.MyAlert = function(json, flag, fun) { var fun = fun || null, flag = flag || (json != undefined && json.flag || 0); uiAlert.first(new uiAlert.Tostring(typeof(json) != "object" ? "" + json + "" : json), flag, fun); }; window.alert = uiAlert.MyAlert; $.fn.alert = function(options) { return this.each(function(e) { var name = new uiAlert.Tostring(options); uiAlert.first(name, e); }); } }($); function uiAlert(data, flag) { this.data = data; this.flag = flag || data.flag; if (typeof uiAlert._initialized == "undefined") { uiAlert.prototype.Append = function() { // 创建弹出 // $(".Uialert_Bbox").length > 0 ? $(".Uialert_Bbox").remove() : ""; uiAlert.Close(); $("body").append("
"); // 创建盒子 var $Box = $(".Uialert_box"); //$Box.append("
" + this.data.title + "关闭
"); // 创建title $Box.append("
"+(this.data.title != "" ? "
" + this.data.title + "
":"") + this.data.nav + "
"); // 创建正文 $Box.append("
"); // 创建底部按钮 $(".Uialert_bj").fadeTo(0, this.data.opacity); // 更改遮挡层透明度 $(".Uialert_Bbox").show(); $Box.fadeIn(300); uiAlert.ChangeCss(); // 更改css this.B_Click(); // 绑定点击事件 this.Auto(); // 绑定自动关闭事件 uiAlert.next = this.data.next; // 光标焦点处于按钮上 $(".Uialert_button>input").focus(); }; uiAlert.prototype.Auto = function() { // 自动 if (this.data.close) { var AutoT = null; AutoT = setTimeout(function() { clearTimeout(AutoT); uiAlert.GoNext(); }, this.data.time); } }; uiAlert.prototype.B_Click = function() { // 点击遮挡层 var z = $(".Uialert_title").css("background-color"); $(".Uialert_Bbox,#TB_HideSelect body").bind({ click: function() { $(".Uialert_Binput").focus(); } }); }; uiAlert._initialized = true; } } uiAlert._object = function(){ var obj = {box:document.body}; obj.type = false; obj.height = $(obj.box).outerHeight(); obj.width = $(obj.box).outerWidth(); obj.top = $(obj.box).offset().top; obj.left = $(obj.box).offset().left; uiAlert.object = obj; } uiAlert.Tostring = function(o) { this.nav = typeof o == "object" ? o.nav.replace(/\n\r/g, "
").replace(/\n/g, "
").replace(/\r/g, "
") : o.replace(/\n\r/g, "
").replace(/\n/g, "
").replace(/\r/g, "
"); // 替换\n为
this.close = o.close || false; this.time = o.time || 3000; this.title = o.title || "提示"; this.opacity = o.opacity || 0.3; this.next = o.next || function() {}; this.flag = o.flag || false; return { "nav": this.nav, "close": this.close, "time": this.time, "title": this.title, "opacity": this.opacity, "next": this.next, "flag": this.flag }; }; uiAlert.first = function(data, n, fun) { // 添加和执行处理 if (typeof fun == "function") { data.next = fun; } var Alert = new uiAlert(data, n); Alert.Append(); }; uiAlert.GoNext = function() { uiAlert.Close(); uiAlert.next(); }; uiAlert.ChangeCss = function() { // 更改css $(window).resize(uiAlert.ChangeCss); // 当window窗口变化时 if (typeof uiAlert.object == "undefined" || uiAlert.object.type) { var $Box = $(".Uialert_box"); $(".Uialert_Bbox,.Uialert_bj").css({ "height": $(window).height() }); $Box.css({ // 重置提示框位置 "top": ((window.screen.availHeight - $Box.height()) / 2), "left": (($(window).width() - $Box.width()) / 2) }); } else { $(".Uialert_Bbox").css({ position: "absolute", top: uiAlert.object.top, left: uiAlert.object.left, height: uiAlert.object.height, width: uiAlert.object.width }); } }; uiAlert.ie = function() { var userAgent = navigator.userAgent.toLowerCase(); $.browser = { version: (userAgent.match( /.+(?:rv|it|ra|ie)[/: ]([d.]+)/ ) || [])[1], safari: /webkit/.test( userAgent ), opera: /opera/.test( userAgent ), msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ), mozilla: /mozilla/.test(userAgent)&&!/(compatible|webkit)/.test(userAgent) }; !$.browser.msie ? "" : ($.browser.version == 6.0 ? uiAlert.scroll() : ""); // 当ie6时绑定 }; uiAlert.B_Click_ = function(x, y, z) { // 更改背景色触发 var x = x, y = y, T = null, z = z; clearInterval(T); T = setInterval(function() { if (x <= y) { uiAlert.Change_b(); x++; } else { $(".Uialert_title").css({ "background-color": z }); clearInterval(T); } }, 100); }; uiAlert.Change_b = function() { // 更改背景颜色 $(".Uialert_title").css({ "background-color": "rgb(" + uiAlert.B_Click_B() + "," + uiAlert.B_Click_B() + "," + uiAlert.B_Click_B() + ")" }); }; uiAlert.B_Click_B = function() { // 随机数字_背景色 return Math.round(Math.random() * 255); }; uiAlert.Close = function() { // 关闭 $(".Uialert_Bbox").remove(); if (typeof uiAlert.scroll._init != "undefined") { $("html").css("overflow", ""); delete uiAlert.scroll._init; } $(window).unbind("resize scroll"); typeof uiAlert.object != "undefined" ? delete uiAlert.object : ""; if (typeof CollectGarbage != "undefined") { CollectGarbage(); } }; uiAlert.scroll = function() { // 绑定滚动条滚动事件 if (typeof uiAlert.scroll._init == "undefined") { // iframe to hide select elements in ie6 // $("html").css("overflow","hidden"); $(".Uialert_Bbox").append(""); uiAlert.scroll._init = true; } uiAlert.scroll.css(); $(window).bind({ scroll: function() { uiAlert.scroll.css(); } }); }; uiAlert.scroll.css = function() { $(".Uialert_Bbox").css({ "top": $(window).scrollTop() }); }; +function ($) { "use strict"; uiConfirm.MyConfirm = function(n, fun, o) { var o = o || true; if (typeof fun == "undefined") { top.uiConfirm.type = false; } else if (typeof fun == "function") { uiConfirm.type = true; uiConfirm.fun = fun; } o == true ? uiConfirm.call(this, uiConfirm.toJson(n, name)) : _confirm(n); }; window.confirm = uiConfirm.MyConfirm; $.fn.uiConfirm = function(options) { return this.each(function(e) { var name = uiConfirm.toJson(options); uiConfirm(name, e); }); } $.fn.uiConfirm.defaults = { title: "温馨提示", // 标题 content: "", // 确认提示内容 width: 350, data: null, // 开放自定义接口,为方法之间数据传输 opacity: 0.1, button: 0, // 确认回调方法 0/1,0表示取消,1表示确认 flag:1, fontcolor:"#434343", alertsubmit:'确认', alertcancle:'取消', fun: false // 用户选择后回调方法 }; }($); function uiConfirm(n) { var data = n || $.fn.uiConfirm.defaults; uiConfirm.data = data; this._init = function() { uiAlert.Close(); var $Uialert_Bbox = $("
"); // 创建盒子 var $Box = $Uialert_Bbox.find(".Uialert_box"); // 创建title $Box.append("
"+(data.title != "" ? "
" + data.title + "
":"") + data.content + "
"); // 创建正文 $Box.append("
"); // 创建底部按钮 $("body").append($Uialert_Bbox); $(".Uialert_bj").fadeTo(0, data.opacity); // 更改遮挡层透明度 $(".Uialert_Bbox").show(); $Box.fadeIn(300); this.ChangeCss(); // 光标焦点处于取消按钮上 $(".Uialert_button>input").eq(0).focus(); }; this.ChangeCss = function() { // 更改css $(window).resize(this.ChangeCss); // 当window窗口变化时 var $Box = $(".Uialert_box"); $(".Uialert_Bbox,.Uialert_bj").css({ "height": $(window).height() }); $Box.css({ // 重置提示框位置 "top": (($(window).height() - $Box.height()) / 2), "left": (($(window).width() - $Box.width()) / 2) }); uiAlert.ie(); }; this._init(); } uiConfirm.data = {}; uiConfirm.close = function(type) { this.data.button = type || 0; uiAlert.Close(); if (uiConfirm.type && this.data.button) { uiConfirm.fun(); return false; } else if (uiConfirm.data.fun) { uiConfirm.data.fun.call(this.data, this.data.button); } }; uiConfirm.toJson = function(n, name) { if (typeof n == "object") { $.fn.uiConfirm.defaults = $.extend({}, $.fn.uiConfirm.defaults, n); } else { $.fn.uiConfirm.defaults.content = n; } $.fn.uiConfirm.defaults.content = $.fn.uiConfirm.defaults.content.toHtml(); return $.fn.uiConfirm.defaults; }; /* 错误提示 */ +function ($) { "use strict"; $.fn.tips = function(msg, callback){ var $this = $(this), text = "
\n\ \n\ "+msg+"\n\
"; $this.html(text); $(".errorTips").fadeIn("last"); typeof callback == "function" ? callback.call(this) : ""; $(".errorTips .owClose").live("click",$.closeTips); } $.closeTips = function(){ $(this).closest(".errorTips").fadeOut('fast',function(){ $(this).remove(); }); }; }($); /* 设置input提示语 */ +function ($) { "use strict"; $.fn.input = function(options) { return this.each(function(e) { var opts = $.fn.Options.call(this, options); opts = $.extend({}, {text: "", color: "#c5c5c5"}, opts); new fInput(this, opts); }); } function fInput(o, opts) { var $this = $(o), padding = parseInt(getCss(o, "paddingLeft")), width = $this.outerWidth() - padding, height = $this.outerHeight(), top = $this.position().top, left = $this.position().left + parseInt(getCss(o, "marginLeft")), vid = $this.attr("id") || ""; if (typeof fInput._init == "undefined") { fInput.num = 0; fInput._init = true; } else { fInput.num++; } if (vid == "") { vid = "input" + fInput.num; $this.attr("id", vid); } $this.attr("data-input", "lInput" + fInput.num).after(""); if ($this.val() != "") { $("#lInput" + fInput.num).hide().text(""); } $this.bind({ keyup: function() { var length = o.value.length, id = "#" + $this.attr("data-input"); if (length > 0) { $(id).hide().text(""); } else { $(id).show().text(opts.text); } }, click: function() { var id = "#" + $this.attr("data-input"), length = o.value.length; if (length <= 0) $(id).hide().text(""); }, blur: function() { var id = "#" + $this.attr("data-input"), length = o.value.length; if (length <= 0) $(id).show().text(opts.text); } }); } function getCss(o, key) { return o.currentStyle ? o.currentStyle[key] : document.defaultView.getComputedStyle(o, false)[key]; }; }($); /* 初始化所有input textarea文件框 */ +function ($) { "use strict"; var resetText = function(o){ var o = o || ".text,.textarea"; $(o).each(function(i, item) { var $this = $(this), attr = $this.attr("icon") ? $this.attr("icon") : "", Class = attr != "" ? " " + attr + "Lable" : "", type = $this.attr("type") || "", clone = $this.attr("copy") || false, name = parseInt(Math.random() * 100000); Class += type == "button" || type == "submit" ? " labelButton" : ""; if ($this.hasClass("textarea")) { Class = " textareaRadius"; } if (typeof $this.data("cache") == "undefined") { $this.data("cache", "true"); if(clone){ var $obj = $this.parent().find("input[icon=" + clone + "]"), $search = $(""); $obj.hide(); $this.wrap($("")).after($search).attr("autocomplete", "off"); $search.click(function() { $obj.click(); }); new resetText.inputEnter({ input: this, func: function() { $obj.click(); } }); }else{ $this.wrap(function() { return "