function layer_navbar_ready_func(params, callback){ var layerid = params.layerid; $('#'+layerid).layer_ready(function(){ var $curlayer = $('#'+layerid); if ($.isFunction(callback)) callback(); if (params.isedit) $curlayer.data("menudata", params.menudata); // 修复样式未渲染完成之前的显示问题 var shwtimer = setTimeout(function(){ $curlayer.children('.wp-navbar_content').css("visibility", 'visible'); clearTimeout(shwtimer); if(params.skin_style == 'horizontal_h01'){ var fontSize=parseInt($('#'+layerid+' nav.mtree li a').css('font-size'))||0; var actualFont=params.fontsize; if(actualFont>10 &&fontSize-actualFont>0.5){ var w=$('#'+layerid+' nav.mtree li a').width(); $('#'+layerid+' nav.mtree li a').css('max-width',(w*actualFont/fontSize-2)+'px'); }else{ var w=$('#'+layerid+' nav.mtree li a').width(); if(actualFont>10&&actualFont-fontSize>0.5) $('#'+layerid+' nav.mtree li a').css('max-width',(w*actualFont/fontSize-2)+'px'); } } }, 50); // 编辑模式 if(params.isedit){ // 局部刷新时调整模块尺寸 if (params.isrefresh == 'true') { var $content = $curlayer.children('.wp-navbar_content'),modsize = $.padborder_logic($content), bwidth = $._parseFloat($curlayer.css("borderLeftWidth")) + $._parseFloat($curlayer.css("borderRightWidth")), bheight = $._parseFloat($curlayer.css("borderTopWidth")) + $._parseFloat($curlayer.css("borderBottomWidth")), modleft = $._parseFloat($curlayer.css("left")),canvaswidth = canv.width(),modwidth = modheight = 0; modwidth = window.modmaxwidth - bwidth;modheight = window.modmaxheight - bheight; if (canvaswidth < modleft + modwidth) modwidth -= modleft; $content.width(modwidth).height(modheight);$curlayer.width(modwidth + modsize.width).height(modheight + modsize.height); var tmptimer = setTimeout(function(){ var conheight = $content.children('.menubtn,nav.mtree').outerHeight(true); conheight = Math.max(conheight, $content.height()); $content.height(conheight);$curlayer.height(conheight + modsize.height); window.modmaxwidth = window.modmaxheight = $content = modsize = null;clearTimeout(tmptimer); }, 100); bwidth = modleft = canvaswidth = modwidth = modheight = null; } // 保存配置项 $curlayer.mod_property(params.options); // 禁用标签 $curlayer.find('li>a.mtitle').attr("href", 'javascript:;'); } }); }; function layer_media_ready_func(layerid){ var userAgent = navigator.userAgent.toLowerCase(); if (!/iphone/i.test(userAgent)){ var imgover=$('#wp-media-image_'+layerid).closest('.img_over'); imgover.children('.imgloading').width(imgover.width()).height(imgover.height()); } $('#'+layerid).layer_ready(function(){ if(typeof(layer_img_lzld)=="function"){ layer_img_lzld(layerid); } }); } function layer_media_lazyload_func(layerid, iswx){ var imgwidth = $('#'+layerid+' .wp-media_content').width(); var imgheight = $('#'+layerid+' .wp-media_content').height(); var imgtop = ($('#wp-media-image_'+layerid)); if(parseInt(imgtop.css('top'))<-600&&imgtop.attr('src').indexOf('blank.gif')>0){imgtop.attr('src',imgtop.attr('data-original'));} if(iswx){ if(imgtop.offset().top0){ imgtop.attr('src',imgtop.attr('data-original')); } setTimeout(function(){ var imgdisplay = imgtop.css('display'); if(imgdisplay&&imgdisplay=='inline') imgtop.css('display','inline-block'); },1200); } // bug#4119 - 模块自适应高度导致的留白 $('#'+layerid).bind("wrapmodheightadapt", function(){ $('.img_over, img.paragraph_image', this).height($(this).height()); }); }; function layer_article_detail_init_func(params){ var $artdetailayer = $('#'+params.layerid); $artdetailayer.find('.mask').css({'width':$artdetailayer.width(),height:$artdetailayer.height()}); $artdetailayer.mod_property(params.artdetailstyle); $artdetailayer.data('article_id', params['article_id']); } function layer_article_detail_onevent_func(params){ var $artdetailayer = $('#'+params.layerid); if(params.txtalign != "center") $artdetailayer.find('.sourcedata').css("text-align", params.txtalign); if (! params.isedit && /\b(micromessenger|windows phone)\b/i.test(navigator.userAgent) && params.manageinf>2) { function wxShare(){ /* 获取微信粉丝进行分享及转发时的响应事件方法 */ var appid = params.appid,timestamp = params.timestamp; var noncestr = params.noncestr,signature = params.signature; var signature1 = params.signature1,article_id = params['article_id']; var article_img = params.article_img; var desc = params.webdesc; var wxdesc= params.wxsharedesc; var wxsharepic = params.wxsharepic; if(wxdesc)desc = wxdesc if(wxsharepic)article_img = wxsharepic; if(/^\/\//.test(article_img)) article_img =document.location.protocol+article_img; if (typeof wx === 'undefined') return false; //防止全局中将微信右上角的按钮隐藏,这里采用延迟设置按钮可见的方式,因微信现没有提供检测按钮状态的接口所以采用固定延迟时间 setTimeout(function(){wx.showOptionMenu();},3000); wx.config({ debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。 appId: appid, // 必填,公众号的唯一标识 timestamp: timestamp, // 必填,生成签名的时间戳 nonceStr: noncestr, // 必填,生成签名的随机串 signature: signature,// 必填,签名,见附录1 jsApiList: ["onMenuShareTimeline","onMenuShareAppMessage","onMenuShareQQ","onMenuShareWeibo"] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2 }); wx.ready(function(){ //分享到朋友圈 //config信息验证后会执行ready方法,所有接口调用都必须在config接口获得结果之后,config是一个客户端的异步操作,所以如果需要在页面加载时就调用相关接口,则须把相关接口放在ready函数中调用来确保正确执行。对于用户触发时才调用的接口,则可以直接调用,不需要放在ready函数中。 wx.onMenuShareTimeline({ title: params.webname,link: params.curlink,imgUrl: article_img, success:function(){ var url=parseToURL("article_detail","setUserShare",{'types':'share','article_id':article_id}); $.ajax({type : 'post',url : url,success : function(json_result){ var o_result = $.parseJSON(json_result); if(o_result.result == 'ERROR'){ alert(o_result.errmsg);return false; }else if(o_result.result == 'OK'){ alert(o_result.custom_errmsg);return false; } } }).error(function(eobject,einfo,errobject){}); } }); //分享给朋友 wx.onMenuShareAppMessage({ title: params.webname,desc:desc,link: params.curlink,imgUrl: article_img,type: '',dataUrl: '', // 如果type是music或video,则要提供数据链接,默认为空 success:function(){ var url=parseToURL("article_detail","setUserShare",{'types':'retransmission','article_id':article_id}); $.ajax({type : 'post',url : url,success : function(json_result){ var o_result = $.parseJSON(json_result); if(o_result.result == 'ERROR'){ alert(o_result.errmsg);return false; }else if(o_result.result == 'OK'){ alert(o_result.custom_errmsg);return false; } } }).error(function(eobject,einfo,errobject){}); } }); }); } window.wxShare=wxShare; wxShare(); } $('#'+params.layerid).find("iframe").each(function(){ var widthv = $(this).attr("width"); var typedata= $(this).attr("data") if(widthv>300 && typedata=="_iframe_"){ var heightv = $(this).attr("height"); $(this).attr("width","100%"); var curw=$(this).width(); $(this).attr("height","auto"); if(heightv>100){ var curh=parseInt(curw/widthv*heightv); if(curh>$(this).height()+20){ $(this).attr("height",curh); } } } }); if (params.isedit) return false; $(function(){ //bug(3053) var $layerid = $('#'+params.layerid); $layerid.css('height','auto'); $layerid.find('.artview_detail img').css("max-width",$layerid.find('.artview_detail').width()+"px"); //bug2666 用户在文章详情设置了图片大小后,结果还是自适应 if($layerid.find('.artview_detail img').width()==0){ $layerid.find('.artview_detail img').css("width",$layerid.find('.artview_detail').width()+"px");} if($layerid.find('.artview_detail img').height()==0){ $layerid.find('.artview_detail img').css("height","auto");} var alldefers=[]; var supportimgs=[]; $layerid.find('.artview_detail img').each(function(){ var deferred=new $.Deferred() var imgsrc=$(this).prop('src'); var img=new Image(); img.onload=function(){ if(img.width>300){ supportimgs.push(imgsrc); } } img.onerror=function(){} img.src=imgsrc; alldefers.push(deferred); }) $layerid.find('.artview_detail img').filter(function(){ if($(this).closest('a').length>0) return false; return true; }).click(function(){ var imgsrc=$(this).prop('src'); if($.inArray(imgsrc,supportimgs)==-1) return; var obj = { urls : [imgsrc], current : imgsrc }; previewImage.start(obj); }) //bug(3705) setTimeout(function(){ var $artdetai = $layerid.find('div.wp-article_detail_content'); var artdetaibortop = parseInt($artdetai.css('border-top-width')); var artdetaiborbot = parseInt($artdetai.css('border-bottom-width')); if(artdetaibortop == 0 && artdetaiborbot == 0){return false;} $layerid.find('.artview_detail img').css("max-width",$layerid.find('.artview_detail').width()+"px"); $layerid.find('.artview_detail img').css("height","auto"); var $site_footer = $('#site_footer'); var artdetailayerhei = parseInt($layerid.height()); var artdetaihei = parseInt($artdetai.height()); var site_footertop = parseInt($site_footer.css('top')); var artdetaiall = artdetaihei + artdetaibortop + artdetaiborbot; var $html = $('html'); var htmlhei = $html.height(); var $scroll_container = $('#scroll_container'); var scroll_containerhei = $scroll_container.height(); var $wp_mobile_navhandler = $('#wp-mobile_navhandler'); $artdetai.height(artdetaiall); $layerid.height(artdetailayerhei + artdetaiborbot + artdetaibortop); $site_footer.css('top',(site_footertop+artdetaibortop+artdetaiborbot)+'px'); $scroll_container.height(scroll_containerhei+artdetaibortop+artdetaiborbot); $wp_mobile_navhandler.click(function(){ var $wp_mobile_navtab = $('#wp-mobile_navtab'); var wp_mobile_navtabhei = $wp_mobile_navtab.height(); var htmlheinew = $html.height(); if(parseInt($wp_mobile_navtab.css('bottom')) < 0){ $html.height(htmlheinew+wp_mobile_navtabhei); $scroll_container.height(htmlheinew+wp_mobile_navtabhei); } else{ $html.height(htmlheinew-wp_mobile_navtabhei); $scroll_container.height(htmlheinew-wp_mobile_navtabhei); } }); wp_heightAdapt($layerid); },1000); }); }; (function(){ var fillcolor='#198ede'; var strcolor='#666'; var nw=150; var nh=100; var c; var cxt; var linepx=10; //默认边框 var shape_params; var zw=nw-(linepx/2); //减去边框后宽度 var zh=nh-(linepx/2); //减去边框后高度 var zx=linepx/2; //减去边框顶点位置 var Shapes={} /*矩形--*/ Shapes['rectan']=function() { cxt.save(); cxt.beginPath(); if(fillcolor!='transparent') cxt.fillStyle=fillcolor; cxt.strokeStyle=strcolor; if(linepx!=0) cxt.lineWidth = linepx; //边框大小 if(fillcolor!='transparent') cxt.fillRect(zx,zx,zw*2,zh*2); if(linepx!=0) cxt.strokeRect(zx,zx,zw*2,zh*2); if(fillcolor!='transparent') cxt.fill(); if(linepx!=0) cxt.stroke(); } /*圆形--*/ Shapes['circle']=function() { cxt.save(); var r = (zw > zh) ? zw : zh; var ratioX = zw / r; var ratioY = zh / r; cxt.translate(zx, zx); cxt.scale(ratioX, ratioY); cxt.beginPath(); cxt.arc(zw/ratioX, zh/ratioY, r, 0, 2 * Math.PI, true); cxt.closePath(); cxt.restore(); if(fillcolor!='transparent') cxt.fillStyle=fillcolor; cxt.strokeStyle=strcolor; if(linepx!=0) cxt.lineWidth = linepx; //边框大小 if(fillcolor!='transparent') cxt.fill(); if(linepx!=0) cxt.stroke(); } /*五角星*/ Shapes['pentagram']=function(){ cxt.save(); var r = (zw > zh) ? zh : zw; cxt.translate(0, zx); cxt.beginPath(); //设置是个顶点的坐标,根据顶点制定路径 for (var i = 0; i < 5; i++) { cxt.lineTo(Math.cos((18+i*72)/180*Math.PI)*r+r+zx, -Math.sin((18+i*72)/180*Math.PI)*r+r+zx); cxt.lineTo(Math.cos((54+i*72)/180*Math.PI)*(r/2)+r+zx, -Math.sin((54+i*72)/180*Math.PI)*(r/2)+r+zx); } cxt.closePath(); if(fillcolor!='transparent') cxt.fillStyle = fillcolor; if(strcolor!='transparent') cxt.strokeStyle = strcolor; if(linepx!=0) cxt.lineWidth =linepx; if(fillcolor!='transparent') cxt.fill(); if(linepx!=0 && strcolor!='transparent') cxt.stroke(); cxt.restore();//返回原始状态 } /*三角形--*/ Shapes['triangle']=function(){ cxt.save(); cxt.beginPath(); cxt.moveTo(zx*2, zh*2+zx); cxt.lineTo(zw+zx, zx*2); cxt.lineTo(zw*2,zh*2+zx); cxt.closePath(); if(fillcolor!='transparent') cxt.fillStyle = fillcolor; if(strcolor!='transparent') cxt.strokeStyle = strcolor; if(linepx!=0) cxt.lineWidth =linepx; if(fillcolor!='transparent') cxt.fill(); if(linepx!=0 && strcolor!='transparent') cxt.stroke(); } /*平行四边形--*/ Shapes['parallelo']=function(){ cxt.save(); cxt.beginPath(); cxt.moveTo(zx*2, zh*2+zx); cxt.lineTo(zw*1.4, zh*2+zx); cxt.lineTo(zw*2, zx); cxt.lineTo(zw*0.6+linepx, zx); cxt.lineTo(zx*2, zh*2+zx); cxt.closePath(); if(fillcolor!='transparent') cxt.fillStyle = fillcolor; if(strcolor!='transparent') cxt.strokeStyle = strcolor; if(linepx!=0) cxt.lineWidth =linepx; if(fillcolor!='transparent') cxt.fill(); if(linepx!=0 && strcolor!='transparent') cxt.stroke(); } /*梯形--*/ Shapes['trapezium']=function() { cxt.save(); cxt.beginPath(); cxt.moveTo(zx*2, zh*2+zx); cxt.lineTo(zw*2, zh*2+zx); cxt.lineTo(zw*1.5+zx, zx); cxt.lineTo(zw*0.5+zx, zx); cxt.lineTo(zx*2, zh*2+zx); cxt.closePath(); if(fillcolor!='transparent') cxt.fillStyle = fillcolor; if(strcolor!='transparent') cxt.strokeStyle = strcolor; if(linepx!=0) cxt.lineWidth =linepx; if(fillcolor!='transparent') cxt.fill(); if(linepx!=0 && strcolor!='transparent') cxt.stroke(); } /*提示框形__左*/ Shapes['roundtip_left']=function(){ var radius=parseInt(zw)*0.075; //圆角大小 if(radius<12){ radius=12; } //圆角最小值 var rjh= zh*0.75; cxt.beginPath(); cxt.arc( radius+zx, radius+zx, radius, Math.PI, Math.PI * 3 / 2); cxt.lineTo(zw*2+zx - radius , zx); cxt.arc(zw*2+zx - radius , radius +zx, radius, Math.PI * 3 / 2, Math.PI * 2); cxt.lineTo(zw*2+zx , rjh*2 - radius); cxt.arc(zw*2+zx - radius , rjh*2 - radius , radius, 0, Math.PI * 1 / 2); cxt.lineTo(radius*2.2+zx , rjh*2); //左下箭头 cxt.lineTo(radius*0.9 +zx, rjh*2+radius); //左下箭头*/ cxt.arc(radius+zx , rjh*2- radius , radius, Math.PI * 1 / 2, Math.PI); cxt.closePath(); if(fillcolor!='transparent') cxt.fillStyle = fillcolor; if(strcolor!='transparent') cxt.strokeStyle = strcolor; if(linepx!=0) cxt.lineWidth = linepx; if(fillcolor!='transparent') cxt.fill(); if(linepx!=0 && strcolor!='transparent') cxt.stroke(); cxt.restore();//返回原始状态 } /*提示框形__右*/ Shapes['roundtip_right']=function() { var radius=parseInt(zw)*0.075; //圆角大小 if(radius<12){ radius=12; } //圆角最小值 var rjh= zh*0.75; cxt.beginPath(); cxt.arc( radius+zx, radius+zx, radius, Math.PI, Math.PI * 3 / 2); cxt.lineTo(zw*2+zx - radius , zx); cxt.arc(zw*2+zx - radius , radius +zx, radius, Math.PI * 3 / 2, Math.PI * 2); cxt.lineTo(zw*2+zx , rjh*2 - radius); cxt.arc(zw*2+zx - radius , rjh*2 - radius , radius, 0, Math.PI * 1 / 2); cxt.lineTo(zw*2+zx-radius*0.9 , rjh*2+radius); //右下箭头 cxt.lineTo(zw*2+zx-radius*2.2 , rjh*2); //右下箭头 cxt.arc(radius+zx , rjh*2- radius , radius, Math.PI * 1 / 2, Math.PI); cxt.closePath(); if(fillcolor!='transparent') cxt.fillStyle = fillcolor; if(strcolor!='transparent') cxt.strokeStyle = strcolor; if(linepx!=0) cxt.lineWidth = linepx; if(fillcolor!='transparent') cxt.fill(); if(linepx!=0 && strcolor!='transparent') cxt.stroke(); cxt.restore();//返回原始状态 } /*箭头--*/ Shapes['arrow']=function() { cxt.save(); cxt.beginPath(); cxt.moveTo(zx, zh*0.65+zx); cxt.lineTo(zx, zh*1.35+zx); cxt.lineTo(zw*1.04, zh*1.35+zx); cxt.lineTo(zw*1.04, zh*2); cxt.lineTo(zw*2,zh+zx); cxt.lineTo(zw*1.04, zx*2); cxt.lineTo(zw*1.04,zh*0.65+zx); cxt.closePath(); if(fillcolor!='transparent') cxt.fillStyle = fillcolor; if(strcolor!='transparent') cxt.strokeStyle = strcolor; if(linepx!=0) cxt.lineWidth =linepx; if(fillcolor!='transparent') cxt.fill(); if(linepx!=0 && strcolor!='transparent') cxt.stroke(); } /*钻石形--*/ Shapes['diamond']=function() { cxt.save(); cxt.beginPath(); cxt.moveTo(zx*2, zh*0.9); cxt.lineTo(zw+zx, zh*2); cxt.lineTo(zw*2, zh*0.9); cxt.lineTo(zw*1.55+zx,zh*0.38); cxt.lineTo(zw*0.45+zx,zh*0.38); cxt.closePath(); if(fillcolor!='transparent') cxt.fillStyle = fillcolor; if(strcolor!='transparent') cxt.strokeStyle = strcolor; if(linepx!=0) cxt.lineWidth =linepx; if(fillcolor!='transparent') cxt.fill(); if(linepx!=0 && strcolor!='transparent') cxt.stroke(); } /*正多边形*/ Shapes['isogon']=function(){ var ib=5; if(shape_params.ib>2) ib=shape_params.ib; var i,ang; var dzw=zw+zx*1.8-linepx; var dzh=zh+zx*1.8-linepx; var r = (dzw > dzh) ? dzh : dzw; ang = Math.PI*2/ib; //旋转的角度 cxt.save();//保存状态 cxt.translate(nw, nh);//原点移到x,y处,即要画的多边形中心 cxt.moveTo(0, -r);//据中心r距离处画点 cxt.beginPath(); for(i = 0;i < ib; i ++) { cxt.rotate(ang)//旋转 cxt.lineTo(0, -r);//据中心r距离处连线 } cxt.closePath(); if(fillcolor!='transparent') cxt.fillStyle = fillcolor; if(strcolor!='transparent') cxt.strokeStyle = strcolor; if(linepx!=0) cxt.lineWidth = linepx;//设置线宽 if(fillcolor!='transparent') cxt.fill(); if(linepx!=0 && strcolor!='transparent') cxt.stroke(); cxt.restore();//返回原始状态 } function ClearCanvas(){ cxt.clearRect(0, 0, nw*2, nh*2); } function layer_mshapes_draw_func(params){ var layerid=params.layerid; var shapetype=params.shape_type; var canvasel=$('#'+layerid).find('canvas'); var w=$('#'+layerid).find('.wp-mshapes_content').width(); var h=$('#'+layerid).find('.wp-mshapes_content').height(); canvasel.attr('width',w); canvasel.attr('height',h); if(params.fillcolor) fillcolor=params.fillcolor; if(params.strcolor) strcolor=params.strcolor; if(params.borderline != null) linepx=parseInt(params.borderline); shape_params=params; c = canvasel[0]; cxt = c.getContext("2d"); nw=parseInt(w/2); nh=parseInt(h/2); zw=nw-parseInt(linepx/2); //减去边框后宽度 zh=nh-parseInt(linepx/2); //减去边框后高度 zx=parseInt(linepx/2); //减去边框顶点位置 ClearCanvas(); if(Shapes[shapetype]) Shapes[shapetype](); } window.layer_mshapes_draw_func=layer_mshapes_draw_func })();