function layer_adv_navbar_inits4_func(options){ var layerid = options.layerid, $L = $('#'+layerid); $L.find('.advnavbar-enter-icon').click(function(){/*开启「浮动」窗口*/ var $C = $('#scroll_container'),_t = Math.max($(window).scrollTop(), $C.scrollTop()),_l = options['popup_left'], slipstr = options['slip_effect'],mx = (slipstr=='right')?-320:320; if (! $C.children('#'+layerid+'_popup').length) { var inH = Math.min($C.height(), $(window).height()); var $mbtmnav=$("#mphone_btmnav"); if($mbtmnav.length && $mbtmnav.css("visibility")!="hidden"){ $('.sitestar-mobile-re-nav').find("ul:first").css('margin','0'); } $L.find('.sitestar-mobile-re-nav').clone().attr("id", layerid+'_popup').css({ "display": 'block',"height": inH+'px' }).appendTo('#scroll_container').animate({"left": _l+'px'}, 1000); // 「浮动窗口」蒙层 $('
').css({ "display": 'none',"height": inH+'px' }).appendTo('#scroll_container').animate({opacity: 'show'}, 1000); } var $P = $C.children('#'+layerid+'_popup'),fixedH = 20 * 2,/* 直接取样式表中的固定尺寸以免动态计算 */ ismobile = (typeof window.ontouchstart !== 'undefined'); // 绑定RESIZE事件以更新「浮动」窗口及「菜单」展示区高度 $(window).bind('resize.mbarpopup', function(e, p){ var $wrapper = $P.children('ul'),maxH = Math.min($C.height(), $(window).height()); $C.children('.wphone-bna_mask').add($P).css("height", maxH+'px'); $wrapper.css("height", Math.max(150, maxH - fixedH)+'px'); if (p == 'scrolltrigger') return false; if (ismobile == false) {/* PC端绑定JSCROLL事件 */ $LAB.script(relativeToAbsoluteURL('script/jscroll.js')).wait(function(){ var stimer = setTimeout(function(){$wrapper.jscroll();clearTimeout(stimer)},1000); }); } else { $wrapper.css({"overflow-x": 'hidden',"overflow-y": 'auto'}); // Fixed bug#5508(「高级导航」浮动层在全屏滚动页无法滚动) (function(win){win.advbarscroll=function(){return $wrapper.is(':visible')}})(window); } }).triggerHandler("resize.mbarpopup"); // 重新定位「浮动」窗口 $C.add(window).bind('scroll.mbarpopup', function(){ $(this).triggerHandler("resize.mbarpopup", ['scrolltrigger']); //$C.children('.wphone-bna_mask').add($P).css("top", $(this).scrollTop()+'px'); }); // 展开「二级菜单」项 $P.find('li.mtop > a.showsub').click(function(){ var $a = $(this),$li = $a.parent(),expanim = function(){ $li.children('ul.center-txt,.sitestar-mobile-re-nav-close').slideDown(1000); if (ismobile == false) {/* PC端重新绑定JSCROLL事件 */ $LAB.script(relativeToAbsoluteURL('script/jscroll.js')).wait(function(){ $P.children('ul').jscroll().children('.jscroll-c').css("top", '0px'); }); } $a.bind('click.cstredirect', function(){ var href = $(this).attr("data-href")||""; if (href.length > 0) location.href = href; }); }; var $siblies = $li.siblings();$li.addClass('local'); if ($siblies.length > 0) $siblies.hide(1000, expanim); else expanim(); return false; }).siblings('.sitestar-mobile-re-nav-close').children('span').click(function(){ // 关闭「二级菜单」项 var $li = $(this).closest('li.mtop'); $li.children('a.showsub').unbind('.cstredirect'); $li.children('ul.center-txt,.sitestar-mobile-re-nav-close').slideUp(function(){ $li.removeClass('local').siblings().show(1000, function(){ if (ismobile == false) {/* PC端重新绑定JSCROLL事件 */ $LAB.script(relativeToAbsoluteURL('script/jscroll.js')).wait(function(){ $P.children('ul').jscroll().children('.jscroll-c').css("top", '0px'); }); } }); }); }); // 关闭「浮动」窗口 $C.children('.wphone-bna_mask').click(function(){ var $target = $(this); if ($P.is(':animated')) $P.stop(); $C.add(window).unbind('.mbarpopup'); $P.animate({"left": (_l + mx)+'px'}, 100, function(){$(this).remove()}); if ($target.is(':animated')) $target.stop(); $target.animate({opacity: 'hide'}, 100, function(){$(this).remove()}); }); $C.children('.sitestar-mobile-re-nav').find(".close").click(function(){ $C.children('.wphone-bna_mask').triggerHandler("click"); }); }); }; 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_mslider_preload_func(layerid){ window['preload_'+layerid] = function(url, callback){ var img = new Image(); img.onload = function(){ callback(img.width, img.height); img.onload = null; }; img.src = url; }; } function layer_mslider_ready_func(params){ var $mscontent = $('#'+params.layerid+' > .wp-mslider_content'), $mswrap = $mscontent.children('ul.mslider_wrapper'),maxln = $._parseFloat(params.framecnt); // Images adaptive var width = $mscontent.width()||300,maxwidth = (maxln + 2) * width; var ua = navigator.userAgent.toLowerCase() || ''; if(ua.match(/\sucbrowser\/.+\s+mobile/g)){ $mswrap.children('li:last').css({position: 'relative'}); } else{ $mswrap.children('li:last').css({left: (0 - maxwidth)+'px',position: 'relative'}); } $mswrap.css('visibility','visible'); $mswrap.width(maxwidth).find('img').each(function(i, node){ var $img = $(this),imgsrc = $img.attr("data-src")||''; if ($.trim(imgsrc).length == 0) return; window['preload_'+params.layerid](imgsrc, function(imgwidth, imgheight){ var tmpw = 0,tmph = 0,height = $mscontent.height(); $img.attr('src',imgsrc); if ((imgwidth >= width) || (imgheight >= height)) { var direct = (imgwidth >= width) ? (imgwidth >= imgheight) : (imgheight < imgwidth); if (direct) { // Horizontal $img.width(width).height("auto");tmph = $img.height(); $img.css("margin", ((height - tmph) / 2)+'px 0'); } else { // Vertical $img.height(height).width("auto");tmpw = $img.width(); $img.css("margin", '0 '+((width - tmpw) / 2)+'px'); } } else $img.css("margin", ((height - imgheight) / 2)+'px '+((width - imgwidth) / 2)+'px'); $img.css("visibility", 'visible') .closest('li').css({background: 'none',width: width+'px',height: height+'px'}); }); }); // Images switch var duration = $._parseFloat(params.interval) * 1000; window['autoplay_'+params.layerid] = function(status){ if (params.autoplay != '1') { if ($mswrap.is(':animated')) $mswrap.stop(true, false); var interid = window['interid_'+params.layerid]; if (interid != undefined) clearInterval(interid); return; } var $msbar = $mscontent.find('> .mslider_bar'),curindex = $msbar.children('a.local').index(); if (status == undefined) curindex = Math.min(curindex + 1, maxln); if(window['interid_'+params.layerid]) clearInterval(window['interid_'+params.layerid]); window['interid_'+params.layerid] = setInterval(function(){ if (curindex > maxln - 1) { $mswrap.animate({left: (0 - curindex*width)+'px'}, function(){ $(this).css("left", '0px'); $msbar.children('a:eq(0)').addClass("local") .siblings().removeClass("local"); $msbar.children('a:eq(0)').find("span").addClass("local"); $msbar.children('a:eq(0)').siblings().find("span").removeClass("local"); }); curindex = 0; } else { $mscontent.find('> .mslider_bar > a:eq('+curindex+')').triggerHandler(mclick,[curindex]); } curindex++; }, duration); } if (window.ontouchstart !== undefined) { (function(){ var target = $mswrap[0];var pagex = 0; var pagey = 0; var curleft = 0; var need_stopPropagation=false; if(!window['is_touch_bind_'+params.layerid]){ target.addEventListener("touchstart", function(e){ var $target = $(this); $target.find('li.li_last').remove(); pagex = e.touches[0].pageX; pagey = e.touches[0].pageY; curleft = $._parseFloat($target.css("left")); need_stopPropagation=false; }, false); target.addEventListener("touchmove", function(e){ if ($mswrap.is(':animated')) $mswrap.stop(true, false); if(curleft>=0){ var lastli=$mswrap.find('li:last'); var interid = window['interid_'+params.layerid]; if (interid != undefined) clearInterval(interid); if(lastli.length>0){ var cpli=lastli.clone().addClass('li_last').css('left',''); var liw=0-width; $mswrap.find('li:first').before(cpli); $mswrap.css("left",liw+'px'); curleft =liw; } } // init var movex = e.touches[0].pageX - pagex, movey = e.touches[0].pageY - pagey,newleft = curleft + movex; if(need_stopPropagation){ e.stopPropagation(); e.preventDefault(); } // fixed touchmove if (Math.abs(movey) < 10 && Math.abs(movex) > 5) { e.preventDefault(); e.stopPropagation(); need_stopPropagation=true; // animated $mswrap.css("left", newleft+'px') .find('li>a').bind('click',function(e){e.preventDefault()});/*Disabled */ } }, false); target.addEventListener("touchend", function(e){ var interid = window['interid_'+params.layerid]; need_stopPropagation=false; if (interid != undefined) clearInterval(interid); var newleft = index = 0,movex = e.changedTouches[0].pageX - pagex,moveln = 30/*moved length*/, curindex = $mscontent.find('> .mslider_bar > a.local').index(),moved = false; if (Math.abs(movex) >= moveln) { moved = true; index = (movex < 0)?(curindex + 1):(curindex - 1); if (index < 0) { newleft = width; index = maxln - 1; } else { newleft = 0 - index * width; if((movex < 0)&&(curindex == maxln - 1)) index = 0; } } else { index = curindex; newleft = 0 - curindex * width; } if($mswrap.find('li.li_last').length){ newleft -= width; } $mswrap.animate({left: newleft+'px'}, function(){ $('li>a', this).unbind('click')/*Enabled */ $mscontent.find('> .mslider_bar > a:eq('+index+')').addClass("local") .siblings().removeClass("local"); $mscontent.find('> .mslider_bar > a:eq('+index+')').find("span").addClass("local"); $mscontent.find('> .mslider_bar > a:eq('+index+')').siblings().find("span").removeClass("local"); if($mswrap.find('li.li_last').length){ $mswrap.find('li.li_last').remove(); $(this).css("left", (newleft+width)+'px'); } if (moved == false){ window['autoplay_'+params.layerid](); return; } if (index == 0) $(this).css("left", '0px'); if (index == maxln - 1) $(this).css("left", (0 - index*width)+'px'); window['autoplay_'+params.layerid](); }); }, false); window['is_touch_bind_'+params.layerid]=true; } })(); } else { $mswrap.bind('mousedown.mslider', function(e){ e.preventDefault(); var $target = $(this),pagex = e.pageX,curleft = $._parseFloat($target.css("left")); if ($target.is(':animated')) $target.stop(true, false); var interid = window['interid_'+params.layerid]; if (interid != undefined) clearInterval(interid); $(document).bind('mousemove.mslider', function(e){ e.preventDefault(); $target.css("left", (curleft + e.pageX - pagex)+'px') .find('li>a').bind('click',function(e){e.preventDefault()});/*Disabled */ }).bind('mouseup.mslider', function(e){ e.preventDefault(); $(document).unbind('.mslider'); var newleft = index = 0,movex = e.pageX - pagex,moveln = 30/*moved length*/, curindex = $mscontent.find('> .mslider_bar > a.local').index(),moved = false; if (Math.abs(movex) >= moveln) { moved = true; index = (movex < 0)?(curindex + 1):(curindex - 1); if (index < 0) { newleft = width; index = maxln - 1; } else { newleft = 0 - index * width; if((movex < 0)&&(curindex == maxln - 1)) index = 0; } } else { index = curindex; newleft = 0 - curindex * width; } $target.animate({left: newleft+'px'}, function(){ $('li>a', this).unbind('click')/*Enabled */ $mscontent.find('> .mslider_bar > a:eq('+index+')').addClass("local") .siblings().removeClass("local"); $mscontent.find('> .mslider_bar > a:eq('+index+')').find("span").addClass("local"); $mscontent.find('> .mslider_bar > a:eq('+index+')').siblings().find("span").removeClass("local"); if (moved == false) return; if (index == 0) $(this).css("left", '0px'); if (index == maxln - 1) $(this).css("left", (0 - index*width)+'px'); window['autoplay_'+params.layerid](); }); }); }); } // Pager $mscontent.find('> .mslider_bar > a').bind(mclick, function(e, n){ var $target = $(this),index = n||$target.index(); if ($mswrap.is(':animated')) $mswrap.stop(true, false); var interid = window['interid_'+params.layerid]; if ((n == undefined) && (interid != undefined)) clearInterval(interid); $target.addClass("local").siblings().removeClass("local"); $target.find("span").addClass("local"); $target.siblings().find("span").removeClass("local"); $mswrap.animate({left: (0 - index * width)+'px'}, function(){ (n == undefined) && window['autoplay_'+params.layerid](); }); }); // Autoplay if (params.isrefresh) { var interid = window['interid_'+params.layerid]; if (interid != undefined) clearInterval(interid); window['autoplay_'+params.layerid]();return; } window['autoplay_'+params.layerid]('init'); }; var btnFloat =function(data,layid){ $layid = $('#'+layid) var btf_right = data.float_right?data.float_right:1 var btf_bottom = data.float_bottom?data.float_bottom:1 btf_right=parseInt(btf_right)||0; btf_bottom =parseInt(btf_bottom)||0; if(data.float_enable=='show'){ $layid.hide() var offsetright=($("body").width()-$('#scroll_container').width())/2; $layid.removeClass('cstlayer').appendTo('body').attr('style','') .css({"position":"fixed","right":(btf_right+offsetright)+"px","z-index": "999","bottom":btf_bottom+"px"}).show() } }