//字号放大缩小 function fontresizer(smallfont, medfont, largefont) { $(".medfont").addclass("curfont"); function clearselected() { $(".smallfont").removeclass("curfont"); $(".medfont").removeclass("curfont"); $(".largefont").removeclass("curfont"); } function savestate(cursize) { var date = new date(); date.settime(date.gettime() + (7 * 24 * 60 * 60 * 1000)); var expires = "; expires=" + date.togmtstring(); document.cookie = "fontsizer" + "=" + cursize + expires + "; path=/"; } $(".smallfont").click(function() {//放大 changefontsize("#zoom,#zoom p[style*='font-size'],#zoom span[style*='font-size'],#zoom font[style*='font-size']","-"); clearselected(); $(".smallfont").addclass("curfont"); //savestate(smallfont); }); $(".medfont").click(function() {//还原 $("#zoom,#zoom p,#zoom span,#zoom font").each(function(){ if($(this).attr("old-size")){ $(this).css("font-size",$(this).attr("old-size")); } }) clearselected(); $(".medfont").addclass("curfont"); //savestate(medfont); }); $(".largefont").click(function() {//缩小 changefontsize("#zoom,#zoom p[style*='font-size'],#zoom span[style*='font-size'],#zoom font[style*='font-size']","+"); clearselected(); $(".largefont").addclass("curfont"); //savestate(largefont); }); function changefontsize(demo,type){ $(demo).each(function(){ var size = $(this).css("font-size"); if(!$(this).attr("old-size")){ $(this).attr("old-size",size); } if(type=="+"){ size = (parseint(size)+2)+"px"; if($(this).attr("old-size")){ if(parseint(size) - parseint($(this).attr("old-size")) > 10){ size = (parseint(size)-2)+"px"; } } }else if(type == "-"){ size = (parseint(size)-2)+"px"; if($(this).attr("old-size")){ if(parseint($(this).attr("old-size")) - parseint(size) > 10){ size = (parseint(size)+2)+"px"; } } } $(this).css("font-size",size); }); } /* function getcookie(c_name) { if(document.cookie.length > 0) { c_start = document.cookie.indexof(c_name + "="); if(c_start != -1) { c_start = c_start + c_name.length + 1; c_end = document.cookie.indexof(";", c_start); if(c_end == -1) c_end = document.cookie.length; return unescape(document.cookie.substring(c_start, c_end)); } } return ""; } */ var savedsize = getcookie('fontsizer'); if(savedsize != "") { $('#zoom').css('font-size', savedsize); switch(savedsize) { case smallfont: $(".smallfont").addclass("curfont"); break; case medfont: $(".medfont").addclass("curfont"); break; case largefont: $(".largefont").addclass("curfont"); break; default: $(".medfont").addclass("curfont"); } } else { $('#zoom').css('font-size', medfont); $(".medfont").addclass("curfont"); } } /* function changecolor(colorname) { document.getelementbyid("c").style.background = colorname; $("#zoom *").css("background","none"); } */ // 生成二维码 function setqrcode(dome){ $(dome).qrcode({ render: "canvas", //也可以替换为table width: 180, height: 180, foreground: "#000", background: "#fff", text: document.url }); } // 获取文章访问量 function getdocvisits(demo,docid){ $.ajax({ timeout : 5000, //超时时间设置,单位毫秒 url:"/mgta/doc", type:'get', data:{docid:docid}, datatype: "json", success:function(result){ if(result.success){ $(demo).html("浏览次数:"+result.data.totalpv+"次"); }else{ $(demo).remove(); } } }); } //设置左右高度 function setoverviewheight(){ if(!ismobile){ var lh = $(".warp .doctextbox").innerheight(); var rh = $(".warp .relateddoc").innerheight(); if(lh>rh){ $(".relateddoc").css("min-height",lh+"px"); }else{ $(".doctextbox").css("min-height",rh+"px"); } } } function ifream_video(thesrc){ layer.open({ id: "lzsp", type: 2, title: false, area: ['630px', '356px'], shade: 0.8, closebtn: 1, shadeclose: true, content: thesrc }); } // 相关文档 重置 function setreldocreset(){ $(".relateddoc .relcard").each(function(){ if($(this).find(".tit").length < 1){ $(this).remove(); } }); if($(".relateddoc .relcard").length < 1){ $(".relateddoc").remove(); $(".doctextbox").removeclass("f_l"); }else{ setoverviewheight(); } } // 设置标题字体 function settitlefontfamily(){ var nrypathname = window.location.pathname; if(nrypathname.indexof('/zwgk/zcjd/')==0 || nrypathname.indexof('/zwgk/zcfg/')==0){ $(".doctextbox .doctitle").css({"font-family": "fzxbsjw"}); } } $(function() { fontresizer('14px', '16px', '18px'); // 设置字体缩放 settitlefontfamily(); // 设置标题字体 });