/* 评论 */ $(function() { if($(".form_comment").length>0){ $(".form_comment").validator({ stopOnError: true, theme: 'yellow_top', ignore: ':hidden', valid: function(form) { $.fn.tips({ type: 'loading', content: '数据提交中' }); $.ajax({ url: webroot + "plug/comment.asp?act=add&id=" + infoid, type: "post", data: $(form).serialize(), success: function(data) { data = jQuery.parseJSON(data); var type = "warn"; if (data.status == "y") { type = "ok" } $.fn.tips({ type: type, content: data.info }); if (data.status == "y") { $(".form_comment")[0].reset(); var act = data.info.substring(0, 1); var info = data.info.substring(1); $.fn.tips({ type: "ok", content: info }); if (act == 2) { setTimeout(function() { location.href = '' + contenturl + '' }, 1500) } } } }) } }) } }); /* 更多加载 */ var startHref; $(function() { if($(".c-moreAjax a").length>0){ $(".c-moreAjax a").click(function() { var href = $(this).attr("href"); startHref = href; if (href != undefined) { $.ajax({ type: "get", cache: false, url: startHref, success: function(data) { var $result = $(data).find(".c-ajax"); $(".c-commentAjax").append($result); var newHref = $(data).find(".c-moreAjax a").attr("href"); if (newHref != "") { $(".c-moreAjax a").attr("href", newHref) } else { $(".c-moreAjax").html('') } } }) } return false }) } }); /* 图片滚动放大 */ $(function() { if($("#c-imageMenu").length>0){ var count = $("#c-imageMenu li").length - 4; var interval = $("#c-imageMenu li:first").width(); var curIndex = 0; $('.c-scrollButton').click(function() { if ($(this).hasClass('disabled')) return false; if ($(this).hasClass('c-smallImgUp'))--curIndex; else++curIndex; $('.c-scrollButton').removeClass('disabled'); if (curIndex == 0) $('.c-smallImgUp').addClass('disabled'); if (curIndex == count - 1) $('.c-smallImgDown').addClass('disabled'); $("#c-imageMenu ul").stop(false, true).animate({ "marginLeft": -curIndex * interval + "px" }, 600) }); $.fn.decorateIframe = function(options) { if (!$.support.leadingWhitespace) { var opts = $.extend({}, $.fn.decorateIframe.defaults, options); $(this).each(function() { var $myThis = $(this); var divIframe = $(""); divIframe.attr("id", opts.iframeId); divIframe.css("position", "absolute"); divIframe.css("display", "none"); divIframe.css("display", "block"); divIframe.css("z-index", opts.iframeZIndex); divIframe.css("border"); divIframe.css("top", "0"); divIframe.css("left", "0"); if (opts.width == 0) { divIframe.css("width", $myThis.width() + parseInt($myThis.css("padding")) * 2 + "px") } if (opts.height == 0) { divIframe.css("height", $myThis.height() + parseInt($myThis.css("padding")) * 2 + "px") } divIframe.css("filter", "mask(color=#fff)"); $myThis.append(divIframe) }) } } $.fn.decorateIframe.defaults = { iframeId: "decorateIframe1", iframeZIndex: -1, width: 0, height: 0 } $("#bigView").decorateIframe(); var midChangeHandler = null; $("#c-imageMenu li img").bind("click", function() { if ($(this).attr("id") != "onlickImg") { midChange($(this).attr("src").replace("small", "mid")); $("#c-imageMenu li").removeAttr("id"); $(this).parent().attr("id", "onlickImg") } }).bind("mouseover", function() { if ($(this).attr("id") != "onlickImg") { window.clearTimeout(midChangeHandler); midChange($(this).attr("src").replace("small", "mid")); } }).bind("mouseout", function() { if ($(this).attr("id") != "onlickImg") { $(this).removeAttr("style"); midChangeHandler = window.setTimeout(function() { midChange($("#onlickImg img").attr("src").replace("small", "mid")) }, 1000) } }); function midChange(src) { $("#midimg").attr("src", src).load(function() { changeViewImg() }) } function mouseover(e) { if ($("#winSelector").css("display") == "none") { $("#winSelector,#bigView").show() } $("#winSelector").css(fixedPosition(e)); e.stopPropagation() } function mouseOut(e) { if ($("#winSelector").css("display") != "none") { $("#winSelector,#bigView").hide() } e.stopPropagation() } $("#midimg").mouseover(mouseover); $("#midimg,#winSelector").mousemove(mouseover).mouseout(mouseOut); var $divWidth = $("#winSelector").width(); var $divHeight = $("#winSelector").height(); var $imgWidth = $("#midimg").width(); var $imgHeight = $("#midimg").height(); var $viewImgWidth = $viewImgHeight = $height = null; function changeViewImg() { $("#bigView img").attr("src", $("#midimg").attr("src").replace("mid", "big")) } changeViewImg(); $("#bigView").scrollLeft(0).scrollTop(0); function fixedPosition(e) { if (e == null) { return } var $imgLeft = $("#midimg").offset().left; var $imgTop = $("#midimg").offset().top; X = e.pageX - $imgLeft - $divWidth / 2; Y = e.pageY - $imgTop - $divHeight / 2; X = X < 0 ? 0 : X; Y = Y < 0 ? 0 : Y; X = X + $divWidth > $imgWidth ? $imgWidth - $divWidth : X; Y = Y + $divHeight > $imgHeight ? $imgHeight - $divHeight : Y; if ($viewImgWidth == null) { $viewImgWidth = $("#bigView img").outerWidth(); $viewImgHeight = $("#bigView img").height(); if ($viewImgWidth < 200 || $viewImgHeight < 200) { $viewImgWidth = $viewImgHeight = 800 } $height = $divHeight * $viewImgHeight / $imgHeight; $("#bigView").width($divWidth * $viewImgWidth / $imgWidth); $("#bigView").height($height) } var scrollX = X * $viewImgWidth / $imgWidth; var scrollY = Y * $viewImgHeight / $imgHeight; $("#bigView img").css({ "left": scrollX * -1, "top": scrollY * -1 }); $("#bigView").css({ "top": 0, "left": $(".c-preView").width() + 15 }); return { left: X, top: Y } } } }); /* 画廊展示 */ if($(".c-proPic").length>0){ $(".c-proPic").slide({ mainCell: ".bd ul", trigger: "click", pnLoop: false }); } /* 搜索提示 */ function checksearch(the) { if ($.trim(the.key.value) == "") { alert("请输入关键字"); the.key.focus(); the.key.value = ""; return false } if ($.trim(the.key.value) == "请输入关键字") { alert("请输入关键字"); the.key.focus(); the.key.value = ""; return false } }