var YC = { /** Tab切换 * */ switchTab: function(tit, con, currClass, evt) { $(tit).each(function() { switch (evt) { case "click": $(this).click(function() { $(tit).removeClass(currClass); $(this).addClass(currClass); $(con).hide(); $(con).eq($(this).index()).show(); }); break; case "mouseover": $(this).mouseover(function() { $(tit).removeClass(currClass); $(this).addClass(currClass); $(con).hide(); $(con).eq($(this).index()).show(); }); break; } }); }, /** 隔行换色 * */ changeColor: function(o, c1, c2) { for (var i = 0, len = $(o).length; i < len; i++) { if (i % 2 == 0) { $(o).eq(i).css("background", c1); } else { $(o).eq(i).css("background", c2); } } }, /** 弹窗+背景遮层 * */ // 若需设置多个关闭按钮,则将closeBtn作为数组传入 overlayPosition: function(overlay, overWin, closeBtn, color, opacity) { $(overlay).attr("style", "background:" + color + ";opacity:" + opacity + ";-moz-opacity:" + opacity + ";filter:alpha(opacity=" + (opacity * 100) + ")").width($(document).width()).height($(document).height()).show(); var oldStyle = ("" + $(overWin).attr("style")) ? ("" + $(overWin).attr("style") + ";") : ""; $(overWin).attr("style", oldStyle + "left:" + ($(window).width() - $(overWin).width()) / 2 + "px;top:" + ($(window).height() - $(overWin).height()) / 2 + "px;visibility:visible;_top:expression(documentElement.scrollTop+50)").show(); if (typeof closeBtn == "object") { for (var i = 0, len = closeBtn.length; i < len; i++) { $(closeBtn[i]).click(function() { $(overlay).hide(); $(overWin).hide(); $(window).unbind("resize"); }); } } else { $(closeBtn).click(function() { $(overlay).hide(); $(overWin).hide(); $(window).unbind("resize"); }); } $(window).resize(function() { $(overlay).width(Math.max($(document).width(),$(window).width())).height(Math.max($(document).height(),$(window).height())); $(overWin).css({ "left": ($(window).width() - $(overWin).width()) / 2 + "px", "top": ($(window).height() - $(overWin).height()) / 2 + "px" }); }); }, /** 弹窗(相对定位) * */ relativePosition: function(overWin, closeBtn) { $(overWin).show(); $(closeBtn).click(function() { $(overWin).hide(); }); }, /** 输入框内容清除(可放置多个输入框选择器作为参数) * */ inputClear: function() { for (var i = 0, len = arguments.length; i < len; i++) { $(arguments[i]).val(""); } }, /** 图片显示器 * */ picShow: function(overlay, overWin, closeBtn, color, opacity) { $("html").css({ "overflow-x": "hidden","overflow-y": "hidden" }); $(overlay).attr("style", "background:" + color + ";opacity:" + opacity + ";-moz-opacity:" + opacity + ";filter:alpha(opacity=" + (opacity * 100) + ")").show(); $(overWin).css({ "visibility": "visible" }); $(closeBtn).css("display","block"); function winResize() { var img = $(overWin).find("img"), winW = $(window).width(), winH = $(window).height(), imgW = img.width(), imgH = img.height(); $(window).scrollTop(0); $(overlay).width(winW).height(winH); $(overWin).css({ "width": winW + "px", "height": winH + "px" }); if (imgW <= winW) { img.css({ "left": (winW - imgW) / 2 + "px" }); } else { img.css({ "left": "0" }); } if (imgH <= winH) { img.css({ "top": ((winH - imgH) / 2-10>0?(winH - imgH) / 2-10:0) + "px" }); } else { img.css({ "top": "0" }); } } winResize(); $(window).resize(function() { winResize(); }); $(closeBtn).click(function() { $(overlay).hide(); $(overWin).css({ "visibility": "hidden" }); $(closeBtn).hide(); $("html").css({ "overflow-x":"auto","overflow-y":"scroll" }); winResize(); $(window).unbind("resize"); }); }, /** 输入框提示信息效果 * */ inputShow: function(boxId, inputObj, tipObj, inputFocusClass, tipFocusClass, tipHideClass) { if (boxId != "") { var obj = "#" + boxId + " "; } else { var obj = ""; } function inputShowStart() { if ($(obj + inputObj).val() != "") { $(obj + tipObj).removeClass(tipFocusClass).addClass(tipHideClass); } else { $(obj + tipObj).removeClass(tipHideClass).removeClass(tipFocusClass); } } inputShowStart(); $(obj + tipObj).click(function() { $(this).blur; $(obj + inputObj).focus(); }); $(obj + inputObj).focus(function() { $(obj + tipObj).blur().addClass(tipFocusClass); }).keyup(function() { if ($(obj + inputObj).val() != "") { $(obj + tipObj).removeClass(tipFocusClass).addClass(tipHideClass); } else { $(obj + tipObj).removeClass(tipHideClass).addClass(tipFocusClass); } }).blur(function() { inputShowStart(); }); }, /** 输入框剩余字数提示 * */ // obj:输入框选择器;tipObj:剩余数字提示选择器;allLen:允许输入的最大字符数 strLenTip: function(obj, tipObj, allLen) { $(obj).keyup(function() { $(tipObj).html(allLen - $(this).val().length); }); $(obj).blur(function() { $(tipObj).html(allLen - $(this).val().length); }); }, /** 联想输入框 * */ // input:输入框对象;callbackFun:用以获取联想提示数据的回调函数 assInput: function(input, callbackFun) { if (typeof input == "object") { var inputs = input; } else { var inputs = $(input); } var parentBoxPos = 0, keyupRun; inputs.each(function() { $(this).keyup(function() { var input = $(this), inputVal = input.val(), assBox = input.siblings(".assBox"); var keyupRunCode = function() { if (inputVal.length > 0) { // 回调函数获取联想提示内容 var hasVal=0; if (typeof callbackFun == "function") { hasVal=callbackFun(inputVal);//返回值为1表示有数据,为0为空 } if(hasVal==1){ var inputParents=input.parents(); assBox.css({"height":"auto"}); for(var i=0,len=inputParents.length;i boxHeight) { conH = boxHeight; $(boxId + ".dropdownCon").css("overflow-y", "scroll"); } else { $(boxId + ".dropdownCon").css("overflow-y", ""); } $(boxId + ".dropdownCon").css("height", conH); $(boxId + ".dropdownCon .dropdownItem").eq(itemLen - 1).css("height", "22px").find("a").css("border-bottom", "none"); var parentBox = $(this).parents("dl"), parentBoxPos = parentBox.css("position"); if ($(this).attr("class") == "dropdownTit down") { if ($(".up").length > 0) { $(".up").attr("class", "dropdownTit down").siblings(".dropdownCon").stop().hide(); $(".up").parents("ul.twoBars").css({"position": "","z-index": ""}); $(".up").parents(".multiDropBox").css({"position": "","z-index": ""}); var parentBox = $(".up").parents("dl"), parentBoxOldPosition = $(".up").parents(".parentBoxOldPosition"); if (parentBoxOldPosition.length > 0) { parentBoxOldPosition.css("position", "static").removeClass("parentBoxOldPosition"); } parentBox.css("z-index", "0"); } if (parentBoxPos == "static") { parentBox.css("position", "relative").addClass("parentBoxOldPosition"); } parentBox.css("z-index", "1000"); $(this).attr("class", "dropdownTit up").parents("ul.twoBars").css({ "position": "relative", "z-index": "1000" }); $(this).parents(".multiDropBox").css({ "position": "relative", "z-index": "1000" }); $(boxId + ".dropdownCon").stop().slideDown().find(".dropdownItem").click(function() { var itemVal = $(this).find("a span").html(); $(boxId + ".dropdownTit").attr("class", "dropdownTit down").html(itemVal); $(boxId + ".dropdownCon").stop().slideUp(); setTimeout(function(){ $(boxId + ".dropdownTit").parents("ul.twoBars").css({ "position": "", "z-index": "" }); $(boxId + ".dropdownTit").parents(".multiDropBox").css({ "position": "", "z-index": "" }); var parentBoxOldPosition = $(".parentBoxOldPosition"); if (parentBoxOldPosition.length > 0) { parentBoxOldPosition.css("position", "static").removeClass("parentBoxOldPosition"); } parentBox.css("z-index", "0"); },500); }); } else { $(boxId + ".dropdownCon").stop().slideUp(); setTimeout(function(){ var parentBoxOldPosition = $(".parentBoxOldPosition"); if (parentBoxOldPosition.length > 0) { parentBoxOldPosition.css("position", "static").removeClass("parentBoxOldPosition"); } parentBox.css("z-index", "0"); $(boxId + ".dropdownTit").attr("class", "dropdownTit down"); $(boxId + ".dropdownCon").parents("ul.twoBars").css({ "position": "", "z-index": "" }); $(boxId + ".dropdownCon").parents(".multiDropBox").css({ "position": "", "z-index": "" }); },500); } $(document).unbind("click").click(function(e) { var e = e ? e: window.event; var tar = e.srcElement || e.target; if ($(tar).attr("class") != "dropdownTit down" && $(tar).attr("class") != "dropdownTit up") { $(boxId + ".dropdownTit").attr("class", "dropdownTit down"); $(boxId + ".dropdownCon").stop().slideUp(); setTimeout(function(){ $(boxId + ".dropdownCon").parents("ul.twoBars").css({ "position": "", "z-index": "" }); $(".multiDropBox").css({ "position": "", "z-index": "" }); var parentBox = $(boxId + ".dropdownTit").parents("dl"), parentBoxOldPosition = $(boxId + ".dropdownTit").parents(".parentBoxOldPosition"); if (parentBoxOldPosition.length > 0) { parentBoxOldPosition.css("position", "static").removeClass("parentBoxOldPosition"); } parentBox.css("z-index", "0"); },500); } }); }); }, /** 下载 * */ downloadClick: function(id) { if (id) { var id = id + " "; } else { var id = ""; } $(id + ".downBtn").click(function(event) { $(id + ".downList").toggle("fast"); event.stopPropagation(); }); $(id + ".downList li").click(function(event) { $(id + ".downList").hide(); event.stopPropagation(); }); $(id + ".downList li").mouseover(function() { $(this).addClass("downLiHover"); }); $(id + ".downList li").mouseout(function() { $(this).removeClass("downLiHover"); }); $(document).click(function() { $(id + ".downList").hide(); }); }, /** 定时轮播图片 * */ // picSelector为单个滚动图片的选择器元素,btnSelector为单个滚动图片对应按钮的选择器元素,currentClass为btnSelector被选中的样式,time为滚动间隔时间 scrollPic: function(picSelector, btnSelector, currentClass, time) { var intervalRunCount = 0, time=time?time:5000, $picSelector = $(picSelector), $btnSelector = $(btnSelector), len = $picSelector.length; function intervalRunCode() { if (intervalRunCount >= len) { intervalRunCount = 0; } $picSelector.stop().fadeOut().eq(intervalRunCount).fadeIn("slow"); $btnSelector.stop().css("background-position", "0 0").removeClass(currentClass).eq(intervalRunCount).addClass(currentClass).css("background-position", "0 -20px"); intervalRunCount++; } intervalRunCode(); var intervalRun_inner; var intervalRun = setTimeout(function() { intervalRunCode(); intervalRun_inner = setTimeout(arguments.callee, time); }, time); $picSelector.mouseover(function() { clearTimeout(intervalRun); clearTimeout(intervalRun_inner); }).mouseleave(function() { intervalRun = setTimeout(function() { intervalRunCode(); intervalRun_inner = setTimeout(arguments.callee, time); }, time); }); $btnSelector.mouseover(function() { var index = $btnSelector.index($(this)); clearTimeout(intervalRun); clearTimeout(intervalRun_inner); $picSelector.stop().fadeOut().eq(index).fadeIn("slow"); $btnSelector.stop().css("background-position", "0 0").removeClass(currentClass).eq(index).addClass(currentClass).css("background-position", "0 -20px"); }).mouseleave(function() { intervalRunCount = $btnSelector.index($(this)); intervalRunCount++; intervalRun = setTimeout(function() { intervalRunCode(); intervalRun_inner = setTimeout(arguments.callee, time); }, time); }); }, /** 信息定时滚动 * */ // selector为单个滚动信息的选择器元素,correctVal为滚动修正值,time为滚动间隔时间 scrollInfo: function(selector, correctVal, time) { var intervalRunCode = function() { var runCon = $(selector).eq(0), runConHtml = runCon.clone(), runConHeight = runCon.height() + correctVal; $(selector).stop().animate({ "top": "-" + runConHeight + "px" }, 1500); setTimeout(function() { $(selector).parent().append(runConHtml); runCon.remove(); $(selector).css({ "top": "0" }); }, 2000); }; var selectorAllHeight = 0; for (var i = 0,len = $(selector).length; i < len; i++) { selectorAllHeight += $(selector).eq(i).height()+parseInt($(selector).eq(i).css("padding-top"))+parseInt($(selector).eq(i).css("padding-bottom")); } if (selectorAllHeight > $(selector).parent().height()) { var scrollRun = setInterval(intervalRunCode, time); } $(selector).parent().mouseover(function() { clearInterval(scrollRun); }).mouseleave(function() { if (selectorAllHeight > $(selector).parent().height()) { scrollRun = setInterval(intervalRunCode, time); } }); }, /** 添加删除新节点 * */ // addBtn:添加按钮;addBox:在该容器中添加新对象;addHtml:添加的节点html;num:添加新对象的开始编号;delBtn:删除按钮;subBtn:提交按钮(将输入框内容提交);isAssInput:是否联想输入("1"为是,其他为否);callbackFun:联想输入获取数据的回调函数; addAndDelNode: function(addBtn, addBox, addHtml, num, delBtn, subBtn, isAssInput, assFunc, subCheckFunc) { $(addBox).empty(); var n = num; $(delBtn).unbind("click").click(function() { $(this).parents(".oneItem").remove(); }); $(addBtn).click(function() { if (delBtn && !subBtn) { var itemHtml = addHtml.replace(/\[\]/g, "[" + n + "]"); $(addBox).append(itemHtml); n++; $(delBtn).click(function() { $(this).parent().remove(); }); } if (delBtn && subBtn) { if ($(addBtn).attr("class") != "addItem noAddItem") { var itemHtml = addHtml.replace(/\[\]/g, "[" + n + "]"); $(addBox).append(itemHtml); n++; $(addBtn).attr("class", "addItem noAddItem"); if (isAssInput && isAssInput == "1") { var input = $(addBox).find(".oneItem input"); input.unbind("keyup"); YC.assInput(input, assFunc); } $(subBtn).click(function() { var itemInput = $(this).siblings("input"), itemVal = itemInput.val(), itemTip = $(this).siblings("i"); if (itemVal.length > 5) { itemTip.html('长度至多为5').show(); $(this).siblings("input").focus(); setTimeout(function() { itemTip.fadeOut(); },3000); return; } else if(itemVal.length==0) { itemTip.html('请输入内容').show(); $(this).siblings("input").focus(); setTimeout(function() { itemTip.fadeOut(); },3000); return; } if(subCheckFunc && typeof subCheckFunc=="function"){ var subRes=subCheckFunc(); if(subRes.state==0){ itemTip.html(subRes.info).show(); $(this).siblings("input").focus(); setTimeout(function() { itemTip.fadeOut(); },3000); return; } } $(this).hide().siblings("input").hide().siblings("i").hide().siblings(".deltxt").hide().siblings("p").show().find("font").html(itemVal); if ($(this).siblings(".assBox").length > 0) { $(this).siblings(".assBox").css("visibility", "hidden"); } $(addBtn).attr("class", "addItem"); $(delBtn).unbind("click").click(function() { $(this).parents(".oneItem").remove(); }); }); if ($(".deltxt").length > 0) { $(".deltxt").unbind("click").click(function() { $(this).parents(".oneItem").remove(); $(addBtn).attr("class", "addItem"); }); } } } }); }, /** checkbox全选 * */ // clickCheckbox:全选的checkbox;allCheckbox:全选的checkbox被点击后,allCheckbox均被选中或被清除选择 checkboxAllCheck: function(clickCheckbox, allCheckbox) { $(clickCheckbox).click(function() { if ($(this).is(":checked")) { $(allCheckbox).attr("checked", true); } else { $(allCheckbox).attr("checked", false); } }); }, /** 换一批 * */ // clickBtn:点击按钮;contentItem:显示的内容条块;showNum:每次显示数 changeContent: function(clickBtn, contentItem, showNum) { var contentItemCount = $(contentItem).length, contentPageCount = Math.ceil(contentItemCount / showNum), currentPageNum = 1; if (contentItemCount < 2) { $(clickBtn).attr("class", "gray"); } $(clickBtn).click(function() { if (++currentPageNum > contentPageCount) { currentPageNum = 1; } $(contentItem).hide(); for (var i = (currentPageNum - 1) * showNum; i < currentPageNum * showNum; i++) { $(contentItem).eq(i).show(); } }); }, /** 柱状图 * */ // boxId:柱状id(不带#),如无为空"";color:柱状颜色(如:#ff6600);dataParam:数据参数,形式为数组[[名称,数值],["商户",198],["用户",253]] // 页面需引用highcharts.js drawColumnChart: function(boxId, color, dataParam) { var chart, categories = [], data = [], name = ' ', boxId = boxId; if (/#/.test(boxId)) { boxId = boxId.replace(/#/, ""); } for (var i = 0, len = dataParam.length; i < len; i++) { categories[i] = dataParam[i][0]; var dataObj = {}; dataObj.y = dataParam[i][1]; dataObj.color = color; data[i] = dataObj; } chart = new Highcharts.Chart({ chart: { renderTo: boxId, type: 'column' }, title: { text: '' }, subtitle: { text: '' }, xAxis: { categories: categories }, yAxis: { title: { text: '' } }, plotOptions: { column: { cursor: 'default', point: {}, dataLabels: { enabled: true, color: color, style: { fontWeight: 'bold' }, formatter: function() { return this.y; } } } }, tooltip: { formatter: function() { var point = this.point, s = this.x + ':' + this.y + '
'; return s; } }, series: [{ name: name, data: data, color: 'white' }], exporting: { enabled: false } }); $("#"+boxId).show(); $(".highcharts-legend").remove(); // 删除白色背景 $("defs").siblings("rect").remove(); }, /** 限定对象尺寸(宽高),等比缩放 * */ setSize: function(obj, maxWidth, maxHeight,isImg) { if (typeof obj == "object") { var obj = obj; } else { var obj = $(obj); } var w = obj.width(), h = obj.height(), rateW = w / maxWidth, rateH = h / maxHeight; if (rateW / rateH > 1) { obj.width(maxWidth).height(h / rateW); } else { obj.width(w / rateH).height(maxHeight); } if(!isImg||isImg!=1){ obj.css({ "left": (maxWidth - obj.width()) / 2 + "px", "top": (maxHeight - obj.height()) / 2 + "px" }); } }, /** 头像裁剪 * */ // bigImg:大图片;bigImgW:大图片的最大宽度;bigImgH:大图片的最大高度;prevImg:预览图片;prevImgW:预览图片宽度;prevImgH:预览图片高度; imgCut: function(bigImg, bigImgW, bigImgH, prevImg, prevImgW, prevImgH, closeBtn) { var bigImgRealW = $(bigImg).width(), bigImgRealH = $(bigImg).height(), oldPrevImgW=prevImgW, oldPrevImgH=prevImgH; YC.setSize(bigImg, bigImgW, bigImgH); var bigImgW = $(bigImg).width(), bigImgH = $(bigImg).height(); $(prevImg).hide(); if(Math.max(prevImgW,prevImgH)<64){ $(prevImg).parent().width(prevImgW).height(prevImgH); YC.setSize($(prevImg).parent(),64,64*prevImgH/prevImgW,1); var prevImgW=$(prevImg).parent().width(), prevImgH=$(prevImg).parent().height(); }else if(Math.max(prevImgW,prevImgH)>90){ $(prevImg).parent().width(prevImgW).height(prevImgH); YC.setSize($(prevImg).parent(),90,90*prevImgH/prevImgW,1); var prevImgW=$(prevImg).parent().width(), prevImgH=$(prevImg).parent().height(); }else{ $(prevImg).parent().width(prevImgW).height(prevImgH); } if ($(bigImg).siblings(".backlay").length == 0) { $(bigImg).parent().prepend('
'); } else { $(bigImg).siblings(".backlay").show(); } $(bigImg).addClass("opc").siblings(".backlay").width(bigImgW).height(bigImgH).css({ "left": $(bigImg).css("left"), "top": $(bigImg).css("top") }); $(bigImg).mousedown(function() { $(this).removeClass("opc"); $(bigImg).siblings(".backlay").fadeOut(); $('.imgareaselect-outer').show(); $('.imgareaselect-selection').show().siblings().show().parent().show(); $(".uploadImgWin .uploadImgWinCon .subTip").hide(); }); function preview(img, selection) { var scaleX = prevImgW / (selection.width || 1); var scaleY = prevImgH / (selection.height || 1); $(prevImg).css({ width: Math.round(scaleX * bigImgW) + 'px', height: Math.round(scaleY * bigImgH) + 'px', marginLeft: '-' + Math.round(scaleX * selection.x1) + 'px', marginTop: '-' + Math.round(scaleY * selection.y1) + 'px' }).show(); bigImgCut = selection; bigImgCut.bigImgRealW = bigImgRealW; bigImgCut.bigImgRealH = bigImgRealH; bigImgCut.scaleRate = bigImgW / bigImgRealW; bigImgCut.x1 = Math.round(bigImgCut.x1 / bigImgCut.scaleRate); bigImgCut.y1 = Math.round(bigImgCut.y1 / bigImgCut.scaleRate); bigImgCut.x2 = Math.round(bigImgCut.x2 / bigImgCut.scaleRate); bigImgCut.y2 = Math.round(bigImgCut.y2 / bigImgCut.scaleRate); bigImgCut.width = bigImgCut.x2 - bigImgCut.x1; bigImgCut.height = bigImgCut.y2 - bigImgCut.y1; bigImgCut.finalWidth=oldPrevImgW; bigImgCut.finalHeight=oldPrevImgH; } $(bigImg).imgAreaSelect({ aspectRatio: '' + prevImgW + ':' + prevImgH + "", onSelectChange: preview }); if (typeof closeBtn == "object") { for (var i = 0, len = closeBtn.length; i < len; i++) { $(closeBtn[i]).click(function() { $(bigImg).attr("src", "").removeAttr("style"); $(prevImg).hide(); $('.imgareaselect-outer').hide().width("0").height("0"); $('.imgareaselect-selection').hide().width("0").height("0").siblings().hide().width("0").height("0").parent().hide().width("0").height("0"); $(".uploadImgWin .uploadImgWinCon .subTip").hide(); }); } } else { $(closeBtn).click(function() { $(bigImg).attr("src", "").removeAttr("style"); $(prevImg).hide(); $('.imgareaselect-outer').hide().width("0").height("0"); $('.imgareaselect-selection').hide().width("0").height("0").siblings().hide().width("0").height("0").parent().hide().width("0").height("0"); $(".uploadImgWin .uploadImgWinCon .subTip").hide(); }); } }, /** 设置空头像 **/ //img:需设置src的图片;imgType:图片类型(1和2) setNoImg:function(img,imgType){ if(imgType==0){ $(img).attr("src","../images/uimg_tx.png"); }else{ $(img).attr("src","../images/uimg_pic.png"); } }, /** 提交信息提示 * */ // subTipObj:提示框;left:提示框绝对定位的left位置,top:提示框绝对定位的top位置;classType:成功为1失败为0;width:宽度值(须为number类型,默认100,当大于100时起作用);tipInfo:提示的文字信息 subTip: function(subTipObj, left, top, classType, tipInfo, width, speed) { if (typeof subTipObj == "object") { var subTipObj = subTipObj; } else { var subTipObj = $(subTipObj); } var subTipParentObj = subTipObj.parent(), subTipParentObjPositionFalg, subTipParentObjOverflowFalg; if (subTipParentObj.css("position") != "absolute" && subTipParentObj.css("position") != "relative") { subTipParentObj.css({ "position": "relative" }); subTipParentObjPositionFalg = 1; } if (subTipParentObj.css("overflow") == "hidden") { subTipParentObj.css({ "overflow": "visible" }); subTipParentObjOverflowFalg = 1; } var width = width ? (width > 100 ? width: 100) : 100, speed = speed ? speed: 5000; className = (classType == 0) ? "errTip": "sucTip"; subTipObj.css({ "left": left, "top": top, "visibility": "visible" }).show().find("div").css({ "width": width }).attr("class", className).find("span").html(tipInfo); setTimeout(function() { subTipObj.fadeOut("slow"); setTimeout(function() { subTipObj.css("visibility", "hidden"); if (subTipParentObjPositionFalg == 1) { subTipParentObj.css("position", ""); } if (subTipParentObjOverflowFalg == 1) { subTipParentObj.css("overflow", "hidden"); } }, 500); }, speed); }, /** 单行提示信息 * */ // overlay:遮罩层;overWin:提示框;classType:样式种类(类型为nuber数值,0为错误,1为正确,2为一般提示);tipInfo:提示信息内容;width:宽度(类型为number数值);speed:隐藏滞后时间,默认3000; showTipInfo: function(classType, tipInfo, width, speed) { if ($(".overlay").length == 0) { $("body").append('
'); } if ($(".tiplay").length == 0) { var addHtml = '
'; $("body").append(addHtml); } var tipFlag = 1, width = width ? width: 320, speed = speed ? speed: 3000, className; switch (classType) { case 0: className = "tip_err"; break; case 1: className = "tip_suc"; break; default: className = "tip_info"; } $(".tiplay").css("width", width + "px").find(".tiplay_info").html(tipInfo); $(".tiplay .tipBox").attr("class", "tipBox " + className); YC.overlayPosition(".overlay", ".tiplay", [".overlay", ".tiplay"], "#000", "0.5"); var hideTip = setTimeout(function() { $(".tiplay").fadeOut(); $(".overlay").fadeOut(); tipFlag = 0; }, speed); $(".overlay").unbind("click").click(function() { if (tipFlag == 1) { clearTimeout(hideTip); $(".tiplay").fadeOut(); $(".overlay").fadeOut(); tipFlag = 0; } }); $(".tiplay").unbind("click").click(function() { if (tipFlag == 1) { clearTimeout(hideTip); $(".tiplay").fadeOut(); $(".overlay").fadeOut(); tipFlag = 0; } }); }, /** 查看详情弹出框 * */ // overlay:遮罩层;overWin:内容弹出框;itemNum:内容列数;closeBtn:关闭按钮(可为数组);color:遮罩层颜色;opacity:遮罩层透明度; detailOverWin: function(overlay, overWin, itemNum, closeBtn, color, opacity) { $(overWin).css({ "width": (226 + 71 * itemNum) + "px" }); YC.overlayPosition(overlay, overWin, closeBtn, color, opacity); }, /** loading按钮 * */ // instruction:打开或关闭指令,number类型(1为开启,0为关闭);clickBtn:在点击时触发的指定按钮(不要使用id,因需要复制);btnSize:按钮高度,number类型(1为22px,2为28px),选填,默认为1;left:左定位,string类型如“150px”,选填;top:上定位,string类型,选填; loadingBtn: function(instruction, clickBtn, btnSize, left, top) { var btnParent = $(clickBtn).eq(1).parent(), btnParentOldPos = btnParent.css("position") ? btnParent.css("position") : ""; if (instruction == 1) { $(clickBtn).parent().append($(clickBtn).clone()); var oldStyle = $(clickBtn).eq(1).attr("style") ? $(clickBtn).eq(1).attr("style") : "", btnSize = btnSize ? btnSize: 1, left = left ? left: 0, top = top ? top: 0, backImg = $(clickBtn).eq(1).css("background-image"); if (btnSize == 1) { var imgH = "22px", imgPos = "-271px"; } else if (btnSize == 2) { var imgH = "28px", imgPos = "-293px"; } if (btnParentOldPos != "relative" && btnParentOldPos != "absolute") { btnParent.css("position", "relative"); } $(clickBtn).eq(1).attr("style", "position:absolute;left:" + left + ";top:" + top + ";background:" + backImg + " 0 " + imgPos + " no-repeat;cursor:text;" + oldStyle).html('').find("span").attr("style", "background:" + backImg + " right " + imgPos + " no-repeat;cursor:text;").html('').find("i").attr("style", "display:block;width:100%;height:" + imgH + ";background:url(../images/loading_s.gif) center center no-repeat;"); } else { $(clickBtn).eq(1).remove(); btnParent.css("position", btnParentOldPos); } } }; function setLight(o, n, c, p) { $(o).removeClass(c); $(o).eq(n).addClass(c); if (p) { $(p).attr("src", $(o).eq(n).attr("src")); } } function inputShow(o_1, o_2, attr, attrVal_1, attrVal_2) { if (o_1.val() != '') { o_2.attr(attr, attrVal_1); } else { o_2.attr(attr, attrVal_2); } } // 鼠标悬停内容块滚动 function hoverScrollAnimate(obj, subObj, newPosition, oldPosition, speed) { $(obj).each(function() { $(this).mouseover(function() { $(this).find(subObj).stop().animate(newPosition, speed); }).mouseleave(function() { $(this).find(subObj).stop().animate(oldPosition, speed); }); }); } // 分页 // boxId为分页内容的大容器Id,如果只有一个分页,则可以为空(""),如有多个,写该id时需带上#号 function getPageCount(pCount, boxId, getPageDataFun) { var obj; if (boxId) { obj = boxId + " "; } else { obj = ""; } if (pCount == undefined || pCount == 0 || pCount == 1) { $(obj + ".pageCountBox").hide(); return false; } $(obj + ".pageCountBox").show(); var pageCount = pCount, currentPage = 1, currentPageList = 1, pageCountHeight = 20 * pageCount, addHtml = ''; for (var i = pageCount; i > 0; i--) { addHtml += '
  • 第 ' + i + ' 页
  • '; } $(obj + ".pageCountBox .pageNumBox").html('').append(addHtml); $(obj + ".pageCountBox .pageNum .pageNumBox").height(pageCountHeight); setPageFun(); pageListFun(); function setPageFun() { if (currentPage == 1) { $(obj + ".pageCountBox .pagePrev").attr("class", "pagePrev pagePrevNo"); } else { $(obj + ".pageCountBox .pagePrev").attr("class", "pagePrev pagePrevYes"); } if (currentPage == pageCount) { $(obj + ".pageCountBox .pageNext").attr("class", "pageNext pageNextNo"); } else { $(obj + ".pageCountBox .pageNext").attr("class", "pageNext pageNextYes"); } $(obj + ".pageCountBox .pageCurr").html("第 " + currentPage + " 页"); $(obj + ".pageCountBox .pageNum .pageNumBox li").removeAttr("class").eq(pageCount - currentPage).attr("class", "sec"); } function pageListFun() { if (currentPageList == 1) { $(obj + ".pageCountBox .pageNumDown").attr("class", "pageNumDown pageNumDownNo"); } else { $(obj + ".pageCountBox .pageNumDown").attr("class", "pageNumDown pageNumDownYes"); } if (currentPageList == Math.ceil(pageCount / 10)) { $(obj + ".pageCountBox .pageNumUp").attr("class", "pageNumUp pageNumUpNo"); } else { $(obj + ".pageCountBox .pageNumUp").attr("class", "pageNumUp pageNumUpYes"); } } $(obj + ".pageCountBox .pagePrev").unbind("click").click(function() { if (currentPage > 1) { currentPage--; setPageFun(); if (typeof getPageDataFun == "function") { getPageDataFun(boxId, currentPage); } } }); $(obj + ".pageCountBox .pageNext").unbind("click").click(function() { if (currentPage < pageCount) { currentPage++; setPageFun(); if (typeof getPageDataFun == "function") getPageDataFun(boxId, currentPage); } }); $(obj + ".pageCountBox .pageNumDown").unbind("click").click(function() { if (currentPageList > 1) { currentPageList--; $(obj + ".pageCountBox .pageNum .pageNumBox").stop().animate({ "bottom": (parseInt($(".pageCountBox .pageNum .pageNumBox").css("bottom")) + 200) + "px" }); pageListFun(); } }); $(obj + ".pageCountBox .pageNumUp").unbind("click").click(function() { if (currentPageList < Math.ceil(pageCount / 10)) { currentPageList++; $(obj + ".pageCountBox .pageNum .pageNumBox").stop().animate({ "bottom": (parseInt($(".pageCountBox .pageNum .pageNumBox").css("bottom")) - 200) + "px" }); pageListFun(); } }); $(obj + ".pageCountBox .pageCurr").unbind("click").click(function() { var opBtnBox = $(this).parents(".opBtnBox"), opBtnBoxPos = opBtnBox.css("position"); if (opBtnBoxPos == "static") { opBtnBox.css("position", "relative").addClass("opBtnBoxOldPosition"); } opBtnBox.css("z-index", "1000"); currentPageList = Math.ceil(currentPage / 10); pageListFun(); $(obj + ".pageCountBox .pageNum .pageNumBox").css("bottom", ( - (currentPageList - 1) * 200) + "px"); $(obj + ".pageCountBox .pageNum").stop().slideDown(); }); $(obj + ".pageCountBox .pageNumBox li").unbind("click").click(function() { var opBtnBox = $(this).parents(".opBtnBox"), opBtnBoxPos = $(this).parents(".opBtnBoxOldPosition"); if (opBtnBoxPos.length > 0) { opBtnBoxPos.css("position", "static").removeClass("opBtnBoxOldPosition"); } opBtnBox.css("z-index", "0"); currentPage = (pageCount - $(this).index()); setPageFun(); if (typeof getPageDataFun == "function") getPageDataFun(boxId, currentPage); }); $(document).click(function(e) { var e = e ? e: window.event; var tar = e.srcElement || e.target; // e.stopPropagation(); if ($(tar).attr("class") != "pageCountBox" && $(tar).attr("class") != "pagePrev" && $(tar).attr("class") != "pageCurr" && $(tar).attr("class") != "pageNext" && $(tar).attr("class") != "pageNum" && $(tar).attr("class") != "pageNumH" && $(tar).attr("class") != "pageNumUp pageNumUpYes" && $(tar).attr("class") != "pageNumUp pageNumUpNo" && $(tar).attr("class") != "pageNumDown pageNumDownYes" && $(tar).attr("class") != "pageNumDown pageNumDownNo" && $(tar).attr("class") != "pageNumBox" && $(tar).attr("class") != "pageNumH") { $(obj + ".pageCountBox .pageNum").hide(); var opBtnBox = $(obj + ".pageCountBox .pageCurr").parents(".opBtnBox"), opBtnBoxPos = $(obj + ".pageCountBox .pageCurr").parents(".opBtnBoxOldPosition"); if (opBtnBoxPos.length > 0) { opBtnBoxPos.css("position", "static").removeClass("opBtnBoxOldPosition"); } opBtnBox.css("z-index", "0"); } }); } // boxId为分页内容的大容器Id,如果只有一个分页,则可以为空(""),如有多个,写该id时需带上#号 function getPageCountExt(pCount, rCount, boxId, rSelect, getPageDataFun) { var obj; if (boxId) { obj = boxId + " "; } else { obj = ""; } $(obj + ".pageCountBox").show(); if (pCount == undefined || pCount == 0 || pCount == 1) { if (pCount == undefined || pCount == 0) { $(rSelect).html(""); $(obj + ".pageCountBox").html(""); } else { $(obj + ".pageCountBox").html("
    总共" + rCount + "条记录,已全部显示
    "); } return false; } else { $(obj + ".pageCountBox").html("上一页下一页
      "); } var pageCount = pCount, currentPage = 1, currentPageList = 1, pageCountHeight = 20 * pageCount, boxH = 200, addHtml = ''; for (var i = pageCount; i > 0; i--) { addHtml += '
    • 第 ' + i + ' 页
    • '; } $(obj + ".pageCountBox .pageNumBox").html('').append(addHtml); $(obj + ".pageCountBox .pageNum .pageNumBox").height(pageCountHeight); setPageFun(); pageListFun(); function setPageFun() { if (currentPage == 1) { $(obj + ".pageCountBox .pagePrev").attr("class", "pagePrev pagePrevNo"); } else { $(obj + ".pageCountBox .pagePrev").attr("class", "pagePrev pagePrevYes"); } if (currentPage == pageCount) { $(obj + ".pageCountBox .pageNext").attr("class", "pageNext pageNextNo"); } else { $(obj + ".pageCountBox .pageNext").attr("class", "pageNext pageNextYes"); } $(obj + ".pageCountBox .pageCurr").html("第 " + currentPage + " 页"); $(obj + ".pageCountBox .pageNum .pageNumBox li").removeAttr("class").eq(pageCount - currentPage).attr("class", "sec"); } function pageListFun() { if (currentPageList == 1) { $(obj + ".pageCountBox .pageNumDown").attr("class", "pageNumDown pageNumDownNo").unbind("hover"); } else { $(obj + ".pageCountBox .pageNumDown").attr("class", "pageNumDown pageNumDownYes").hover(function() { $(this).attr("class", "pageNumDown pageNumDownYesHover"); }, function() { $(this).attr("class", "pageNumDown pageNumDownYes"); });; } if (currentPageList == Math.ceil(pageCount / 10)) { $(obj + ".pageCountBox .pageNumUp").attr("class", "pageNumUp pageNumUpNo").unbind("hover"); } else { $(obj + ".pageCountBox .pageNumUp").attr("class", "pageNumUp pageNumUpYes").hover(function() { $(this).attr("class", "pageNumUp pageNumUpYesHover"); }, function() { $(this).attr("class", "pageNumUp pageNumUpYes"); });; } var currBigH = pageCountHeight - (parseInt($(".pageCountBox .pageNum .pageNumBox").css("bottom")) + 200); $(obj + ".pageNum").css("height", (currBigH < 200 ? currBigH: 200) + "px").find(".pageNumH").css("height", (currBigH < 200 ? currBigH: 200) + "px"); } $(obj + ".pageCountBox .pagePrev").unbind("click").click(function() { if (currentPage > 1) { currentPage--; setPageFun(); if (typeof getPageDataFun == "function") { getPageDataFun(boxId, currentPage); } } }); $(obj + ".pageCountBox .pageNext").unbind("click").click(function() { if (currentPage < pageCount) { currentPage++; setPageFun(); if (typeof getPageDataFun == "function") getPageDataFun(boxId, currentPage); } }); $(obj + ".pageCountBox .pageNumDown").unbind("click").click(function() { if (currentPageList > 1) { currentPageList--; pageListFun(); var currBigH = pageCountHeight + (parseInt($(".pageCountBox .pageNum .pageNumBox").css("bottom")) + 200); $(obj + ".pageNum").css("height", (currBigH < 200 ? currBigH: 200) + "px").find(".pageNumH").css("height", (currBigH < 200 ? currBigH: 200) + "px"); $(obj + ".pageCountBox .pageNum .pageNumBox").stop().animate({ "bottom": (parseInt($(".pageCountBox .pageNum .pageNumBox").css("bottom")) + 200) + "px" }); } }); $(obj + ".pageCountBox .pageNumUp").unbind("click").click(function() { if (currentPageList < Math.ceil(pageCount / 10)) { currentPageList++; pageListFun(); var currBigH = pageCountHeight + (parseInt($(".pageCountBox .pageNum .pageNumBox").css("bottom")) - 200); $(obj + ".pageNum").css("height", (currBigH < 200 ? currBigH: 200) + "px").find(".pageNumH").css("height", (currBigH < 200 ? currBigH: 200) + "px"); $(obj + ".pageCountBox .pageNum .pageNumBox").stop().animate({ "bottom": (parseInt($(".pageCountBox .pageNum .pageNumBox").css("bottom")) - 200) + "px" }); } }); $(obj + ".pageCountBox .pageCurr").unbind("click").click(function() { var opBtnBox = $(this).parents(".opBtnBox"), opBtnBoxPos = opBtnBox.css("position"); if (opBtnBoxPos == "static") { opBtnBox.css("position", "relative").addClass("opBtnBoxOldPosition"); } opBtnBox.css("z-index", "1000"); currentPageList = Math.ceil(currentPage / 10); pageListFun(); var currBigH = pageCountHeight - (currentPageList - 1) * 200; $(obj + ".pageNum").css("height", (currBigH < 200 ? currBigH: 200) + "px").find(".pageNumH").css("height", (currBigH < 200 ? currBigH: 200) + "px"); $(obj + ".pageCountBox .pageNum .pageNumBox").css("bottom", ( - (currentPageList - 1) * 200) + "px"); $(obj + ".pageCountBox .pageNum").stop().slideDown(); }); $(obj + ".pageCountBox .pageNumBox li").unbind("click").click(function() { var opBtnBox = $(this).parents(".opBtnBox"), opBtnBoxPos = $(this).parents(".opBtnBoxOldPosition"); if (opBtnBoxPos.length > 0) { opBtnBoxPos.css("position", "static").removeClass("opBtnBoxOldPosition"); } currentPage = (pageCount - $(this).index()); setPageFun(); if (typeof getPageDataFun == "function") getPageDataFun(boxId, currentPage); }); $(document).click(function(e) { var e = e ? e: window.event; var tar = e.srcElement || e.target; // e.stopPropagation(); if ($(tar).attr("class") != "pageCountBox" && $(tar).attr("class") != "pagePrev" && $(tar).attr("class") != "pageCurr" && $(tar).attr("class") != "pageNext" && $(tar).attr("class") != "pageNum" && $(tar).attr("class") != "pageNumH" && $(tar).attr("class") != "pageNumUp pageNumUpYes" && $(tar).attr("class") != "pageNumUp pageNumUpNo" && $(tar).attr("class") != "pageNumDown pageNumDownYes" && $(tar).attr("class") != "pageNumDown pageNumDownNo" && $(tar).attr("class") != "pageNumBox" && $(tar).attr("class") != "pageNumH") { $(obj + ".pageCountBox .pageNum").hide(); var opBtnBox = $(obj + ".pageCountBox .pageCurr").parents(".opBtnBox"), opBtnBoxPos = $(obj + ".pageCountBox .pageCurr").parents(".opBtnBoxOldPosition"); if (opBtnBoxPos.length > 0) { opBtnBoxPos.css("position", "static").removeClass("opBtnBoxOldPosition"); } opBtnBox.css("z-index", "0"); } }); } /* * //分页 //boxId为分页内容的大容器Id,如果只有一个分页,则可以为空(""),如有多个,写该id时需带上#号 function * getPageCount(pageCount,boxId,getPageDataFun){ if(boxId){ var obj=boxId+" "; * }else{ var obj=""; } var pageCount=pageCount?pageCount:15, currentPage=1, * currentPageList=1, pageCountHeight=20*pageCount, addHtml=''; for(var * i=pageCount;i>0;i--){ addHtml+='
    • 第 '+i+' 页
    • '; } * $(obj+".pageCountBox .pageNumBox").html('').append(addHtml); * $(obj+".pageCountBox .pageNum .pageNumBox").height(pageCountHeight); * setPageFun(); pageListFun(); function setPageFun(){ if(typeof * getPageDataFun=="function"){ getPageDataFun(boxId,currentPage); } * if(currentPage==1){ $(obj+".pageCountBox .pagePrev").attr("class","pagePrev * pagePrevNo"); }else{ $(obj+".pageCountBox .pagePrev").attr("class","pagePrev * pagePrevYes"); } if(currentPage==pageCount){ $(obj+".pageCountBox * .pageNext").attr("class","pageNext pageNextNo"); }else{ $(obj+".pageCountBox * .pageNext").attr("class","pageNext pageNextYes"); } $(obj+".pageCountBox * .pageCurr").html("第 "+currentPage+" 页"); $(obj+".pageCountBox .pageNum * .pageNumBox * li").removeAttr("class").eq(pageCount-currentPage).attr("class","sec"); } * function pageListFun(){ if(currentPageList==1){ $(obj+".pageCountBox * .pageNumDown").attr("class","pageNumDown pageNumDownNo"); }else{ * $(obj+".pageCountBox .pageNumDown").attr("class","pageNumDown * pageNumDownYes"); } if(currentPageList==Math.ceil(pageCount/10)){ * $(obj+".pageCountBox .pageNumUp").attr("class","pageNumUp pageNumUpNo"); * }else{ $(obj+".pageCountBox .pageNumUp").attr("class","pageNumUp * pageNumUpYes"); } } $(obj+".pageCountBox .pagePrev").click(function(){ * if(currentPage>1){ currentPage--; setPageFun(); } }); $(obj+".pageCountBox * .pageNext").click(function(){ if(currentPage1){ currentPageList--; $(obj+".pageCountBox .pageNum * .pageNumBox").stop().animate({"bottom":(parseInt($(".pageCountBox .pageNum * .pageNumBox").css("bottom"))+200)+"px"}); pageListFun(); } }); * $(obj+".pageCountBox .pageNumUp").click(function(){ if(currentPageList