function detectZoom (){ var ratio = 0, screen = window.screen, ua = navigator.userAgent.toLowerCase() || ''; if (window.devicePixelRatio !== undefined) { ratio = window.devicePixelRatio; }else if (~ua.indexOf('msie')) { if (screen.deviceXDPI && screen.logicalXDPI) { ratio = screen.deviceXDPI / screen.logicalXDPI; } }else if (window.outerWidth !== undefined && window.innerWidth !== undefined) { ratio = window.outerWidth / window.innerWidth; } if (ratio){ ratio = Math.round(ratio * 100); } return ratio; } function layer_unslider_heightAdapt_func(dom,params){ var wsize=params.wsize; if(params.unslideradapt!='1') return; if(!wsize || !wsize.width) return; if(params.editMode) return; var lastW=dom.data('lastW'); var winW=dom.find('.wp-unslider_content').width(); dom.data('lastW',winW); if(winW==lastW) return; var curH=dom.height(); var editH=parseInt(wsize.height) if(wsize.width>=winW && curH<=editH) return; var curH=editH; if(wsize.width right_boundray) return true; if(dom.attr('id') == $(this).attr('id')) return true;//自己除外 //包在高度自适应模块外面的模块也要改变高度 if((tmp_left <= left_boundray && tmp_left+tmp_width >= right_boundray) && (tmp_top <= moduleTop && tmp_top+tmp_height >= moduleTop+moduleLayerHeight)) { wrapList.push($(this).attr('id')); return true; } } if($(this).parent().hasClass('full_content') || $(this).parent().hasClass('footer_content') || $(this).parent().hasClass('drop_box')) return true;//通栏和底部元素暂时不考虑 if(tmp_top >= (moduleTop + moduleLayerHeight)) { pressList.push($(this).attr('id')); if(minTop == 0) {minTop = tmp_top;minId = $(this).attr('id');} else { if(minTop > tmp_top) {minTop = tmp_top;minId = $(this).attr('id');} } } }); //ceshi offsetY = $("#"+minId).ab_pos_cnter('top') - (moduleTop + moduleLayerHeight); if(pressList.length > 0 && (moduleTop + moduleHeight) >= minTop) { diffY = moduleTop + moduleHeight + offsetY - minTop; for(var i = 0;i < pressList.length;i++) { var theel=$("#"+pressList[i]); var eltop=parseInt(theel.ab_pos_cnter('top'))+diffY-sameTopDiff; theel.css('top',eltop+'px'); //bug 5996 自适应导致模块style变化了,动画出错 if(theel.data('wopop_effect_oristyle')){ var style=theel.data('wopop_effect_oristyle'); style=style.replace(/((?:^|;)\s*top\s*:\s*)\d+px;/,'$1'+eltop+'px;'); theel.data('wopop_effect_oristyle',style); } var pressArrOld=theel.data('adaptpress'); if(!pressArrOld) pressArrOld=[]; var pressArr=[]; for(var j=0;j 0) { for(var i = 0;i < wrapList.length;i++) { var diffH=moduleHeight-moduleLayerHeight; var theel=$("#"+wrapList[i]); theel.height($("#"+wrapList[i]).height()+(diffH)); var wrapListPadding = parseInt(layer_first_div(theel).css('padding-top')) + parseInt(layer_first_div($("#"+wrapList[i])).css('padding-bottom')); var wrapListBorder = parseInt(layer_first_div(theel).css('border-top-width')) + parseInt(layer_first_div($("#"+wrapList[i])).css('border-bottom-width')); layer_first_div(theel).height(theel.height() - wrapListPadding - wrapListBorder); var wrapArrOld=theel.data('adaptwrap'); if(!wrapArrOld) wrapArrOld=[]; var wrapArr=[]; for(var j=0;j= 0 && !$target.hasClass('now_effecting')) { var timer = setTimeout(function(){ $target.showEffects(); _duration = -1; clearTimeout(timer); }, _tt); } }); var imgover=$('#wp-media-image_'+layerid).closest('.img_over'); imgover.children('.imgloading').width(imgover.width()).height(imgover.height()); imgover.css('position','relative'); $('#'+layerid).layer_ready(function(){ layer_img_lzld(layerid); }); if(!params.isedit && !params.has_effects){ if ($('#'+$('#'+layerid).attr('fatherid')).attr('type') == 'pop_up') { $('#wp-media-image_'+layerid).attr('src',params.img_src); $('#wp-media-image_'+layerid).parents('.img_over:first').children('.imgloading').remove(); } } }; function wp_getdefaultHoverCss(layer_id) { var getli=''; var geta=''; var cssstyle=''; var navStyle = wp_get_navstyle(layer_id,'datasty_'); if(navStyle.length > 0) { var patt1 = new RegExp("#nav_layer[0-9|a-z|A-Z]+\\s+li\.wp_subtop:\\s*hover\\s*{[^}]+}",'i'); var tmp = patt1.exec(navStyle); if(tmp) { var tmp1 = tmp[0].match(/{[^}]+}/)[0]; tmp1=tmp1.replace('{','').replace('}',''); getli=getli+tmp1; } patt1 = new RegExp("#nav_layer[0-9|a-z|A-Z]+\\s+li\.wp_subtop>a:\\s*hover\\s*{[^}]+}",'i'); tmp = patt1.exec(navStyle); if(tmp) { var tmp2 = tmp[0].match(/{[^}]+}/)[0]; tmp2=tmp2.replace('{','').replace('}',''); geta=geta+tmp2; } } navStyle = wp_get_navstyle(layer_id,'datastys_'); var getlia=''; if(navStyle.length > 0) { var layidlow=('#nav_'+layer_id+' li.wp_subtop>a:hover').toLowerCase(); if( ('a'+navStyle).toLowerCase().indexOf(layidlow)>0){ var parstr="#nav_"+ layer_id +" li.wp_subtop>a:hover"; getlia = navStyle.split(new RegExp(parstr,"i")); var combilestr=''; for(key in getlia){ var ervervalue=''; if(('a'+getlia[key]).indexOf('{')<3 && ('a'+getlia[key]).indexOf('{')>0 ){ var parvalue=getlia[key].split('{'); if(('a'+parvalue[1]).indexOf('}')>0){ ervervalue=parvalue[1].split('}')[0]; } } combilestr=combilestr+ervervalue; } geta=geta+combilestr; } layidlow=('#nav_'+layer_id+' li.wp_subtop:hover').toLowerCase(); if( ('a'+navStyle).toLowerCase().indexOf(layidlow)>0){ var parstr="#nav_"+ layer_id +" li.wp_subtop:hover"; getlia = navStyle.split(new RegExp(parstr,"i")); var combilestrs=''; for(var key in getlia){ var ervervalue=''; if(('a'+getlia[key]).indexOf('{')<3 && ('a'+getlia[key]).indexOf('{')>0 ){ var parvalue=getlia[key].split('{'); if(('a'+parvalue[1]).indexOf('}')>0){ ervervalue=parvalue[1].split('}')[0]; } } combilestrs=combilestrs+ervervalue; } getli=getli+combilestrs; } } if(getli.length>0){ getli="#"+layer_id+" li.lihover{"+getli+"} "; } if(geta.length>0){ geta="#"+layer_id+" li>a.ahover{"+geta+"} "; } cssstyle=getli+geta; if(cssstyle.length>0 && ($('#canvas #'+layer_id).length>0 || $('#site_footer #'+layer_id).length>0)){ cssstyle=""+cssstyle+""; cssstyle=cssstyle.replace(/[\r\n]/g, " ").replace(/\s+/g, " "); var doms=$('#'+layer_id); var oldcssstyle=doms.data('get_layer_hover_css'); if(oldcssstyle != cssstyle){ $("#hover"+layer_id+"").text(""+cssstyle+""); doms.data('get_layer_hover_css',cssstyle); get_plugin_css("H"+ layer_id +"H",cssstyle); } } } function wp_showdefaultHoverCss(layer_id){ var layertype=$('#'+layer_id).attr('type'); if(layertype && window['wp_showdefaultHoverCss_'+layertype]){ return window['wp_showdefaultHoverCss_'+layertype](layer_id); } return false; } function wp_showdefaultHoverCss_new_navigation(layer_id) { var plugin_name=$("#"+layer_id).attr('type'); var hover=$("#"+layer_id).find('.nav1').attr('hover'); if(hover!=1){ return;} wp_getdefaultHoverCss(layer_id); var n=0; var rootpid=0; if(plugin_name=='new_navigation'){ var page_id=$("#page_id").val(); rootpid=$("#page_id").attr("rpid")*1; }else{ var page_id=$('#'+layer_id+'').find(".default_pid").html(); if(page_id==0 || page_id.length==0){ page_id=$('#nav_'+layer_id+'').children('li:first').attr('pid'); } } $('#nav_'+layer_id+'').children('li').each(function(){ var type_pid=$(this).attr('pid'); if( (type_pid==page_id ) && plugin_name=='new_navigation' ){ $(this).addClass("lihover").children('a').addClass("ahover"); } if(type_pid==rootpid && rootpid>0){ $(this).addClass('rootlihover'); } var t_bool = false; var whref = window.location.href.replace(/^https?:/,'').replace(/&brd=1$/,'');; var t_href= $(this).find("a").attr("href").replace(/^https?:/,'').replace(/&brd=1$/,'');; var $nav1 = $('#'+layer_id).children('.wp-new_navigation_content').children('.nav1'); var sethomeurl = $nav1.attr("sethomeurl"); if(sethomeurl) sethomeurl = sethomeurl.replace(/^https?:/,''); var cururl = window.location.href.replace(/^https?:/,''); if( (whref.indexOf("&menu_id=")>0 && t_href.indexOf("id=")>0 && whref.indexOf(t_href)>-1) || t_href == sethomeurl && sethomeurl.indexOf(cururl)>-1 ){ t_bool = true; } if(whref == t_href || whref== t_href+"&brd=1" || t_bool){ $(this).addClass("lihover").children('a').addClass("ahover"); } n++; }); if(!$('#nav_'+layer_id+'').children('li.lihover').length){ $('#nav_'+layer_id+'').children('li.rootlihover:first').addClass("lihover").children('a').addClass("ahover"); } $('#nav_'+layer_id+' .rootlihover').removeClass('rootlihover'); } function wp_nav_addMoreButton(layer_id) { var type_style=$("#"+layer_id).find('.wp-new_navigation_content').attr('type'); var index=0; var func=function(){ if(!$('#scroll_container #'+layer_id+':visible').length){ if(index<=20){ setTimeout(func,500); index++; } return; } var firstLiTop = 0; var hasMore = false; $('#scroll_container #nav_'+layer_id).children('li.wp_subtop').each(function(i){ if(i == 0) {firstLiTop = $(this).offset().top;return true;} if($(this).offset().top > firstLiTop) { if(i==1){ var twice=$("#"+layer_id).data('twiced'); if(!twice){ $("#"+layer_id).data('twiced',true); setTimeout(func,1500); return false; } } if(type_style==2){ $(this).remove(); }else{ $('#'+layer_id).data('hasMore','yes');//配置逻辑获取 var more = $.trim($('#'+layer_id).children('.wp-new_navigation_content').children('.nav1').attr('more')); var doms = $(this).prev().prev().nextAll().clone(); var objA = $(this).prev().children('a'); if(objA.children('span').length > 0) objA.children('span').html(more); else objA.html(more); if(objA.hasClass('sub')) { objA.next('ul').empty(); doms.appendTo(objA.next('ul')); } else { objA.after('
    '); doms.appendTo(objA.next('ul')); objA.addClass('sub'); } objA.addClass('nav_more_link'); $(this).prev().nextAll().remove(); objA.next('ul').children('li').removeClass('wp_subtop').removeClass('lihover').children('a').removeClass("ahover"); hasMore = true; objA.attr('href','javascript:void(0);'); //点击"更多"弹出全站导航 if($("#"+layer_id).find('.nav1').attr('moreshow') == 1) { $(document).undelegate("#"+layer_id+" .nav_more_link",'click').delegate("#"+layer_id+" .nav_more_link",'click',function (e){ var func=function(){ $('#'+layer_id).find('#basic-modal-content_'+layer_id).modal({ containerId:'wp-new_navigation-simplemodal-container_'+layer_id, zIndex:9999, close:false, onOpen:function(dialog){ dialog.overlay.fadeIn('slow', function(){ dialog.container.slideDown('slow',function(){ dialog.data.fadeIn('slow','swing',function(){ $('.wp_menus').not('.wp_thirdmenu0').each(function(){ var left = $(this).parent().parent().children('a').eq(0).outerWidth()+5; $(this).css({position:'relative',left:left+'px'}); }); }); }); }); }, onClose:function(dialog){ dialog.data.fadeOut('slow',function (){ dialog.container.slideUp('slow', function () { dialog.overlay.fadeOut('slow', function () { $.modal.close(); }); }); }); } }); } if($('#'+layer_id).find('#basic-modal-content_'+layer_id).length){ func(); }else{ var morediv=$('#'+layer_id).find('.navigation_more'); var more_color=morediv.attr('data-more'); var typeval=morediv.attr('data-typeval'); var menudata=morediv.attr('data-menudata'); $.ajax({ type: "POST", url: parseToURL("new_navigation", "windowpopup"), data: {layer_id:layer_id,color:more_color,typeval:typeval,menudata:menudata}, success: function (response) { if (response == 'Session expired') window.location.href = getSessionExpiredUrl(); morediv.replaceWith(response); func(); }, error: function (xhr, textStatus, errorThrown) { wp_alert(xhr.readyState + ',' + xhr.status + ' - ' + (errorThrown || textStatus) + "(get nav).
    " + translate("Request failed!")); return false; } }); } return false; }); } return false; } } }); if(!hasMore) $('#'+layer_id).data('hasMore','no'); wp_showdefaultHoverCss(layer_id); }; func(); } //编辑模式水平拖动动态刷新修改More按钮 function wp_updateMoreButton(layer_id) { var $layer = $('#'+layer_id); var $nav1 = $layer.children('.wp-new_navigation_content').children('.nav1'); var tmp_css = $.trim($("#datastys_"+layer_id).text()); var tmp_cssa = $.trim($("#datasty_"+layer_id).text()); $.post(parseToURL("new_navigation","refreshNavigator",{menustyle:$.trim($nav1.attr('skin')),saveCss:'yes',page_id:$("#page_id").val(),blockid:layer_id,typeval:$.trim($layer.find(".wp-new_navigation_content").attr('type')),colorstyle:$.trim($nav1.attr('colorstyle')),direction:$.trim($nav1.attr('direction')),more:$.trim($nav1.attr('more')),hover:$.trim($nav1.attr('hover')),hover_scr:$.trim($nav1.attr('hover_scr')),umenu:$.trim($nav1.attr('umenu')),dmenu:$.trim($nav1.attr('dmenu')),moreshow:$.trim($nav1.attr('moreshow')),morecolor:$.trim($nav1.attr('morecolor')),smcenter:$.trim($nav1.attr('smcenter'))}),{"addopts": $layer.mod_property("addopts")||{},menudata:$("#"+layer_id).data("menudata")},function(data){ $layer.find('.wp-new_navigation_content').html(data); $("#datastys_"+layer_id).text(tmp_css); get_plugin_css(layer_id,tmp_cssa+" "+tmp_css); }); wp_showdefaultHoverCss(layer_id); } function wp_removeLoading(layer_id) { var $nav1 = $('#'+layer_id).find(".nav1"); var ishorizon=$nav1.attr("ishorizon"); if(ishorizon=='1'){ $("#"+layer_id).find('.wp-new_navigation_content').css({height:'auto',overflow:'hidden'}); }else{ $("#"+layer_id).find('.wp-new_navigation_content').css({width:'auto',overflow:'hidden'}); } // 修复IE浏览器部分版本导航无法显示问题 2013/12/26 var temptimer = setTimeout(function(){ $("#"+layer_id).find('.wp-new_navigation_content').css("overflow", 'visible'); clearTimeout(temptimer); }, 50); } function richtxt(layer_id) { var type=$("#"+layer_id).find('.wp-new_navigation_content').attr('type'); if(type==2){ var baseloop = 0; $("#"+layer_id).find('.ddli').each(function(){ $(this).addClass("setdiff"+baseloop); baseloop++; }); } } function wp_createNavigationgetSubMenuHoverCssFunc(param){ var layer_id=param.layer_id; var editmode=param.editmode; function getSubMenuHoverCss(css_pro,type){ var typeval=type; if(typeval==1){ var regex = "#nav_layer[0-9|a-z|A-Z]+\\s+ul+\\s+li+\\s+a:\\s*hover\\s*{\\s*"+css_pro+"\\s*:[^;]+"; }else{ var regex = "#nav_layer[0-9|a-z|A-Z]+\\s+li\.wp_subtop>a:\\s*hover\\s*{\\s*"+css_pro+"\\s*:[^;]+"; } if(editmode){ var navStyle = $.trim($("#datastys_"+layer_id).text()); }else{ var navStyle = $.trim($("#"+layer_id).data("datastys_")); } if(navStyle.length > 0){ var patt1 =new RegExp(regex,'i'); var tmp = patt1.exec($.trim(navStyle)); if(tmp) { return $.trim((tmp[0].match(/{[^:]+:[^;]+/)[0]).match(/:[^;]+/)[0].replace(':','')); } } if(editmode){ navStyle = $.trim($("#datasty_"+layer_id).text()); }else{ navStyle = $.trim($("#"+layer_id).data("datasty_")); } if(navStyle.length > 0) { if(typeval==1){ var patt1 = new RegExp("#nav_layer[0-9|a-z|A-Z]+\\s+ul+\\s+li+\\s+a:\\s*hover\\s*{[^}]+}",'i'); }else{ var patt1 = new RegExp("#nav_layer[0-9|a-z|A-Z]+\\s+li\.wp_subtop>a:\\s*hover\\s*{[^}]+}",'i'); } var tmp = patt1.exec(navStyle); if(tmp) { var tmp1 = tmp[0].match(/{[^}]+}/)[0]; var patt2 = new RegExp(css_pro+"\\s*:\\s*[^;]+;",'i'); tmp = patt2.exec(tmp1); if(tmp) return $.trim(tmp[0].replace(/[^:]+:/,'').replace(';','')); } } return $.trim($("#nav_"+layer_id+" ul li a").css(css_pro)); } window[layer_id+'_getSubMenuHoverCss']=getSubMenuHoverCss; } function layer_new_navigation_content_func(params){ var layer_id = params['layer_id']; $("#"+layer_id).find('.menu_hs11').css('visibility','hidden'); var contentfunc=function(){ if($("#"+layer_id).is(':visible')){ $("#"+layer_id).find('.wp-new_navigation_content').each(function(){ var wid = $(this).width(); var liwid = $(this).find('li:eq(0)'); var lipadd = parseInt(liwid.css('padding-right'))+parseInt(liwid.css('padding-left')); var isEmptyMenu=false; if($(this).find('li.wp_subtop').length==1){ var menulinktxt=$(this).find('li.wp_subtop a').text(); if(menulinktxt=='No menu!'){ isEmptyMenu=true; } } if (!isEmptyMenu && $.inArray(params.menustyle, ['hs7','hs9','hs11','hs12']) != -1) { var bwidth = parseFloat(liwid.css("borderRightWidth") || '0'); if(bwidth>0) bwidth=parseInt(bwidth + 0.1); else bwidth =0; if(bwidth > 0) $('li.wp_subtop', this).width(function(i, h){return h - bwidth - 1}); else if(!$("#canvas").data('changewidth_'+layer_id)){ $("#canvas").data('changewidth_'+layer_id,true); if(params.menustyle=='hs12'){ $('li.wp_subtop', this).width(function(i, h){return h - 1}) }else{ var totalw=0; $('li.wp_subtop', this).width(function(i, h){totalw+=h;return h}) var ulwidth=$(this).find('#nav_'+layer_id).width(); if(totalw>ulwidth){ for(var i=0;i(wid-lipadd)){ $(this).find('li.wp_subtop').css('width',wid-lipadd); } }); $("#"+layer_id).find('.menu_hs11,.menu_hs7,.menu_hs12').css('visibility',''); var contenth=$("#"+layer_id+" .wp-new_navigation_content").height(); if(contenth==0){ $("#"+layer_id+" .wp-new_navigation_content").css('height',''); } }else{ setTimeout(contentfunc,60); } } contentfunc(); if(params.isedit){$('#'+layer_id).mod_property({"addopts": params.addopts});} if((params.addopts||[]).length > 0 && /^hs/i.test(params.menustyle)){$('#nav_'+layer_id+' li.wp_subtop:last').css("border-right", 'none');} if(! params.isedit){ if($.inArray(params.menustyle, ['vertical_vs6','vertical_vs7']) != -1){ var $layer=$('#'+layer_id).find(".wp-new_navigation_content"); var vswidth=$layer.width(); var $ul=$layer.find('ul.navigation'); $ul.css({width:vswidth+'px'}); $ul.find("li.wp_subtop").css({width:(vswidth-14)+'px'}); } } }; function layer_breadcrumb_ready_func(layerid, showorder){ if (showorder == '2') { var $span_home=$("#"+layerid).find(".breadcrumb_plugin span").eq(0).clone(); var $span_fuhao=$("#"+layerid).find(".breadcrumb_plugin span").eq(1).clone(); $("#"+layerid).find(".breadcrumb_plugin span").eq(0).remove(); $("#"+layerid).find(".breadcrumb_plugin span").eq(0).remove(); $("#"+layerid).find(".breadcrumb_plugin").append($span_fuhao).append($span_home); } var fuhao1=['>>','※','◇','→','—','∷','⊙','☆','》','~','>','&','★','¦','#','≡']; var fuhao2=['<<','※','◇','←','—','∷','⊙','☆','《','~','<','&','★','¦','#','≡']; window['ShowOrder'] = function(gzfuhao,plugin_id){ $span_html=$($("#"+plugin_id).find(".breadcrumb_plugin").html()).clone(); $("#"+plugin_id).find(".breadcrumb_plugin").html(''); $.each($span_html,function(i,n){ $("#"+plugin_id).find(".breadcrumb_plugin").prepend($(n)); }); $("#"+plugin_id).find(".breadcrumb_plugin").find("span:odd").html(gzfuhao); }; window['ShowOrder2'] = function(plugin_id){ if($("#"+plugin_id).find(".breadcrumb_plugin").find('span').last().attr('gzdata')!='gzorder') { ShowOrder(fuhao2[$('#'+plugin_id).find(".breadcrumbfuhao").attr("gz")],plugin_id); } }; window['ShowOrder1'] = function(plugin_id){ if($("#"+plugin_id).find(".breadcrumb_plugin").find('span').last().attr('gzdata')=='gzorder') { ShowOrder(fuhao1[$('#'+plugin_id).find(".breadcrumbfuhao").attr("gz")],plugin_id); } }; //隐藏当前页 var ShowCpage = $("#"+layerid).find('.wp-breadcrumb_content').attr('ShowCpage'); if (ShowCpage == 0) { var pos = (showorder == 2)?'first':'last'; $("#"+layerid).find('.breadcrumbtext:not(.home):'+pos).hide(); $("#"+layerid).find('.breadcrumbfuhao:'+pos).hide(); } }; function layer_sitesearch_init_func(param,urllist,searchFlag){ var wp_productsearchcache=param.wp_productsearchcache; var langs=param.langs; var layerid=param.layer_id; var curseachtype='product'; var resswitch = param.sswitch?param.sswitch:'1'; function getCacheType(searchtype){ var dfd=$.Deferred(); if(searchtype=='article' && resswitch == '1'){ if(window.wp_articlesearchcache != null){ dfd.resolve(window.wp_articlesearchcache) }else{ $.ajax({ url:parseToURL("sitesearch","article_titlesearch",{'layerid':layerid}), success:function(data){ window.wp_articlesearchcache = eval(data); $('body').data('wp_searchcache',window.wp_articlesearchcache); dfd.resolve(window.wp_articlesearchcache); } }); } }else{ if(resswitch == '1'){ if(window.wp_productsearchcache != null){ dfd.resolve(window.wp_productsearchcache) }else{ $.ajax({ url:parseToURL("sitesearch","product_autocomplete",{'layerid':layerid}), success:function(data){ var res=$.parseJSON(data); if(res.result=='OK'){ window.wp_productsearchcache = res.data; $('body').data('wp_searchcache',window.wp_productsearchcache); dfd.resolve(window.wp_productsearchcache); } } }); } } } return dfd; } $('#'+layerid).layer_ready(function(){ var vskin =param.skin,$curlayer = $('#'+layerid); if(vskin=='skin4' || vskin=='skin5' || vskin=='skin6' || vskin=='skin7' || vskin=='skin8' || vskin=='skin9'){ $curlayer.find('.searchtype').css({'display':'none'}); }else $curlayer.find('.searchtype').css({'display':'block'}); if(vskin=='skin4' || vskin=='skin5'){ //adapt extend skin width 2014.4.27 $curlayer.bind("fixedsearchwidth",function(e,width){ var $target = $(this),$targetwidth = $target.find('.searchbox'); var this_btn_width = $target.find('.searchbox_btn').outerWidth(true); var this_txt_width = $target.find('.searchbox_txt').outerWidth(true); $targetwidth.css({'width':this_btn_width+this_txt_width}); }).triggerHandler("fixedsearchwidth"); //<<0){ dom.find('.sright').off('click').on('click',function(){ //explain:此处不知道为什么从dom对象中获取不到输入框的值,先改为$全局对象,author:fpf,date:2015-01-27,action:modify; //修改bug(1694) if(vskin == 'skin8'){ var keywords=$.trim($(this).parent().parent().parent().find('input[name="keywords"]').val()); } else if(vskin == 'skin9'){ var keywords=$.trim($(this).parent().parent().find('input[name="keywords"]').val()); }else { var keywords=$.trim($(this).parent().find('input[name="keywords"]').val()); } if(keywords.length == 0&&vskin!='skin8') {dom.find('input[name="keywords"]').focus();return false;} if(vskin=='skin8'){ var lowprice=$.trim(dom.find('input[name="lowprice"]').val().replace(/[^0-9]/ig,"")); if(lowprice.length == 0) {dom.find('input[name="lowprice"]').focus();return false;} var highprice=$.trim(dom.find('input[name="highprice"]').val().replace(/[^0-9]/ig,"")); if(highprice.length == 0) {dom.find('input[name="highprice"]').focus();return false;} } // 根据skin4,5,6,7,8,9的设置项进行搜索 if(searchFlag != 0 && searchFlag != 4){ if(vskin=='skin4' || vskin=='skin5' || vskin=='skin6' || vskin=='skin7' || vskin=='skin8' || vskin=='skin9'){ if(searchFlag == 1){ str = 'title'; }else if(searchFlag == 2){ str = 'intro'; }else if(searchFlag == 3){ str = 'content'; } } }else{ var selid=new Array(); var i=0; dom.find(".catetype").each(function(){ if($(this).prop("checked")){ selid[i]=$(this).val(); i++;} }); var str=''; if(selid.length>0){ str=selid.join(','); } if(str.length==0){ str='all'; } } var infotype=0; var sourcecotent=parent.$('#'+layerid).find('input[name=searchcontent]').val(); if(sourcecotent !='article' &&sourcecotent !='product'){ if(dom.find('.type_title').html()!=langs['Search Pro']){ infotype=1; } if(vskin=='skin4' || vskin=='skin5' || vskin=='skin6' || vskin=='skin8' || vskin=='skin9'){ infotype=0; } }else if(sourcecotent=='article'){ infotype=1; }else if(sourcecotent=='product'){ infotype=0; } dom.attr('infotype',infotype); $('body').data('wp_searchcache1','1'); var search_type = dom.data('search_type'); var searchskin = 2; if(vskin=='skin4' || vskin=='skin5' || vskin=='skin6' || vskin=='skin7' || vskin=='skin8' || vskin=='skin9'){ if(searchFlag != 0 && searchFlag != 4){ searchskin = 2; }else{ searchskin = 1; } } var open = $.trim(dom.find('.wp-sitesearch_container').attr('opn')); if(vskin=='skin8'){ //add high low price var url=parseToURL('sitesearch','search',{search_listNum:dom.data('search_listNum'),openProductUrl:dom.data('openProductUrl'),search_type:dom.data('search_type'),sswitch:dom.data('sswitch'),wordsplist:dom.data('wordsplist'),openArticleUrl:dom.data('openArticleUrl'),article_page:article_page,product_page:product_page,keywords:keywords,searchskin:searchskin,lowprice:lowprice,highprice:highprice,type:str,infotype:infotype,layerid:layerid,"searchFlag":searchFlag}); }else{ var url=parseToURL('sitesearch','search',{search_listNum:dom.data('search_listNum'),openProductUrl:dom.data('openProductUrl'),search_type:dom.data('search_type'),sswitch:dom.data('sswitch'),wordsplist:dom.data('wordsplist'),openArticleUrl:dom.data('openArticleUrl'),article_page:article_page,product_page:product_page,keywords:keywords,searchskin:searchskin,type:str,infotype:infotype,layerid:layerid,"searchFlag":searchFlag}); } var murl = '#'; if(search_type==1){ keywords = encodeURIComponent(keywords); if(infotype==1){ if(urllist['sitesearch_artlist']) murl = urllist['sitesearch_artlist']; }else{ if(urllist['sitesearch_prolist']) murl = urllist['sitesearch_prolist']; } url = murl; if(url!="#"){ if(url.indexOf("?")>0){ url = url+"&page=1&search_txt="+keywords+"&type="+str+"&searchskin="+searchskin+'&word_s='+dom.data('wordsplist'); }else{ url = url+"?page=1&search_txt="+keywords+"&type="+str+"&searchskin="+searchskin+'&word_s='+dom.data('wordsplist'); } if(vskin=='skin8'){ url = url+"&lowprice="+lowprice+"&highprice="+highprice; } url +='&fromid='+layerid; } } if(open=='1'){ window.open(url,'_blank'); }else{ if(search_type==1){ if((infotype==0 && param.openProductUrl=='1') || (infotype==1 && param.openArticleUrl=='1')){ window.open(url,'_blank'); }else{ window.location.href= url; } }else{ $LAB .script(relativeToAbsoluteURL("sitesearch_browser.html")) .wait(function(){ wp_sitesearch(url,{ title:langs['Search Result'], width: 791, top:60 }); }) } } }); dom.find('input[name="keywords"]').keydown(function(event){ if(event.keyCode==13){ dom.find('.sright').trigger('click'); } }); dom.find('.type_select span').unbind('click.searchspan').bind('click.searchspan',function(){ dom.find('.type_title').html($(this).html()); dom.find('.type_select').hide(); if($(this).html() ==langs['Search Pro']){ dom.find('.s_title').html(langs['Name']); dom.find('.s_description').html(langs['Description']); $(this).html(langs['Search Art']); dom.find("input[name='keywords']").autocomplete("option","source",[]); curseachtype='product'; getCacheType('product').done(function(arr){ if(curseachtype=='product') dom.find("input[name='keywords']").autocomplete("option","source",arr); }); }else{ dom.find('.s_title').html(langs['Search Title']); dom.find('.s_description').html(langs['Search Summary']); $(this).html(langs['Search Pro']); dom.find("input[name='keywords']").autocomplete("option","source",[]); curseachtype='article'; getCacheType('article').done(function(arr){ if(curseachtype=='article') dom.find("input[name='keywords']").autocomplete("option","source",arr); }); } }); dom.find('.nsearch').hover(function(){ dom.find('.type_select').show(); dom.find('input[name="keywords"]').autocomplete("close"); },function(){ dom.find('.type_select').hide(); }); var width_xz=0; if($.browser.msie && $.browser.version>=9){ width_xz=4;} var additionwidth=0; var funci=0; var func=function(){ if(dom.width()>dom.find('.sleft').outerWidth(true)||funci>=3){ var domFidType = $('#'+dom.attr('fatherid')).attr('type'); var domFidDly = $('#'+dom.attr('fatherid')+'_pop_up').css('display'); var domFidVsl = $('#'+dom.attr('fatherid')+'_pop_up').css('visibility'); if(param.editmode==1){ if(domFidType == 'pop_up' && domFidDly == 'none'){ $('#'+dom.attr('fatherid')+'_pop_up').css({'display':'block','visibility':'hidden'}); } }else{ $('#'+dom.attr('fatherid')+'_pop_up').css({'display':'block','visibility':'hidden'}); } if(dom.find('.sright2').length) additionwidth+=dom.find('.sright2').outerWidth(true); dom.find('.ninput').css({'width':(dom.width()-dom.find('.sleft').outerWidth(true)-dom.find('.sright').outerWidth(true)-additionwidth-dom.find('.nsearch').outerWidth(true)-width_xz)-4+'px'}); dom.find('.ninput input').width(dom.find('.ninput').width()); if(param.editmode==1){ if(domFidType == 'pop_up' && domFidDly == 'block' && domFidVsl == 'hidden'){ $('#'+dom.attr('fatherid')+'_pop_up').css({'display':'none','visibility':'visible'}); } }else{ $('#'+dom.attr('fatherid')+'_pop_up').css({'display':'none','visibility':'visible'}); } }else{ funci+=1; setTimeout(func,300); } } func(); //搜索按钮文字设置 if (vskin == 'default'||vskin == 'skin4'||vskin == 'skin7'||vskin == 'skin8' ) { var extcont = dom.data('extend_content'); var seatext = extcont.sitesearchbuttext; var pattern = /[\u4e00-\u9fa5]+/; if(typeof(seatext) != 'undefined'){ var sealent = seatext.length; $curlayer.find('.searchbox .bcenter').text(seatext); $curlayer.find('.searchbox .searchbox_btn').text(seatext); if(pattern.test(seatext)) { if(vskin == 'default') { var sealent1 = (sealent>2?10*(sealent-2)+(sealent-2):0); var width = $curlayer.find('.searchbox .ninput').css('width'); $curlayer.find('.searchbox .ninput').css({width:(parseInt(width)-sealent1)+'px'}); $curlayer.find('.searchbox input').css({width:(parseInt(width)-sealent1)+'px'}); } if(vskin == 'skin7') { var sealent1 = (sealent>3?10*(sealent-3)+1:0); var width = $curlayer.find('.searchbox input').css('width'); $curlayer.find('.searchbox input').css({width:(parseInt(width)-sealent1)+'px'}); var width = $curlayer.find('.searchbox .searchbox_btn').css('width'); $curlayer.find('.searchbox .searchbox_btn').css({width:(parseInt(width)+sealent1)+'px'}); } if(vskin == 'skin8') { var sealent1 = (sealent>3?10*(sealent-3)+1:0); var width = $curlayer.find('.searchbox .searchbox_btn').css('width'); $curlayer.find('.searchbox .searchbox_btn').css({width:(parseInt(width)+sealent1)+'px'}); } } } } } if(!param.editmode){ var autocomplete_width,autocomplete_date; if(vskin=='default' || vskin=='skin1' || vskin=='skin2' || vskin=='skin3'){ autocomplete_width = dom.find("input[name='keywords']").parent().outerWidth()+dom.find('.searchbox').children('.sleft').outerWidth()+dom.find('.nsearch').outerWidth() }else{autocomplete_width = dom.find('.searchbox_txt').parent().outerWidth() } var wp_searchdefalut =param.sshdefalutshow; if(wp_searchdefalut==1){ curseachtype='article'; }else{ curseachtype='product'; } dom.data('wp_searchcache',autocomplete_date); // 数据量超过一千会有明显卡顿,此处现取前一千来比对 by lsf 2015/01/15 dom.find("input[name='keywords']").autocomplete({ source:[], appendTo:dom, width:autocomplete_width, open:function(event,ui){ if(vskin == 'skin9'){ var contentWidth = dom.find('.showcontent').width(); var inputBorderWidth = parseInt(dom.find('.showcontent').css('border-width')); var contentHeight = dom.find('.showcontent').height()+2+inputBorderWidth; // 22是左右内边距之和 $('.ui-autocomplete').css( { 'width':contentWidth+22+inputBorderWidth*2+'px', 'left':-contentWidth-inputBorderWidth+'px', 'top':contentHeight+'px' } ); }else{ $('.ui-autocomplete').css('left','0'); } }, select:function(event,ui){ dom.find('.searchtype').prop('checked','false'); dom.find("input[value='title']").prop('checked',true); } }); dom.find("input[name='keywords']").one('focus',function(){ getCacheType(curseachtype).done(function(arr){ dom.find("input[name='keywords']").autocomplete("option","source",arr); }); }) } dom.data('interface_locale',getSiteCurLang()); //explain:修复bug(1601)搜索插件的输入框在浏览器器缩放时因其宽度问题导致后面的搜索按钮不在同一行显示,现在手动减去5px以解决该问题,author:fpf,date:2015-01-20,action:modify; function detectZoom (){ var ratio = 0, screen = window.screen, ua = navigator.userAgent.toLowerCase() || ''; if (window.devicePixelRatio !== undefined) { ratio = window.devicePixelRatio; }else if (~ua.indexOf('msie')) { if (screen.deviceXDPI && screen.logicalXDPI) { ratio = screen.deviceXDPI / screen.logicalXDPI; } }else if (window.outerWidth !== undefined && window.innerWidth !== undefined) { ratio = window.outerWidth / window.innerWidth; } if (ratio){ ratio = Math.round(ratio * 100); } return ratio; }; var devicePixelRatios = detectZoom(); var ischrome = navigator.userAgent.toLowerCase() || ''; if(devicePixelRatios != 100 && ischrome.match(/chrome/)){ var $search = dom.find('input.searchbox_txt'); var search_width = parseFloat($search.width()).toFixed(2); if(search_width && search_width > 5){$search.width(search_width - 5);} } }); } ; function layer_article_list_checkid_func(params){ $(function(){ var layer_id = "#"+params.layer_id; $(layer_id+' .articleid:not(.memberoff)').unbind('click.list_check').bind('click.list_check',function(event){ event.preventDefault(); var gourl = $(this).attr('href'); var targettype = $(this).attr('target'); _this = $(this); $.ajax({ type: "POST", url: parseToURL('article_list','checkarticleid'), data: {id:$(this).attr('articleid')}, dataType: "json", async:false, success: function(r){ var islogin = params.islogin; if(r.code == -2 && !islogin){ //是会员 if(!islogin){ event.preventDefault(); $LAB .script(relativeToAbsoluteURL("custom_dialog.html")) .wait(function(){ show_custom_panel(parseToURL('userlogin','login_dialog'),{ title:'Login', overlay:true, id:'wp_user_info' }); }); } return false; }else if(r.code == -1){ //不是会员 ismember = false; } if(targettype == undefined && gourl != 'javascript:void(0);'){ location.href=gourl; }else if(targettype != undefined && gourl != 'javascript:void(0);'){ window.open(gourl,'','',true); } } }) }) }) } function layer_article_list_init_func(param){ if(!getSystemSession()){ var $window=$(window); var layerid=param.layer_id; if($('#'+layerid).length&&$('#'+layerid).closest('#canvas,#site_footer').length){ // var $body = $('#scroll_container'); // var scrolTop = Math.max($(window).scrollTop(), $body.scrollTop()); } } var layerid=param.layer_id; var articleStyle=param.articleStyle; window['set_thumb_'+layerid]=function(obj) { var callback=function(img){ img.fadeIn('slow',function(){ img.closest('li').find('.imgloading').remove(); }); } $(obj).each(function() { var img=$(this); callback(img); }); } if(articleStyle=='two_column'){ $("#"+layerid).layer_ready(function(){ var $p = $('ul:first li p', "#"+layerid); $p.width('auto'); var maxW = Math.max.apply(Math, $p.map(function(){ return $(this).outerWidth(true); }).toArray()); $p.width(maxW); }); }else{ if (articleStyle === "skin3" || articleStyle === "ulist3") { $(function(){ var maxliheight = 0,tmplayerid = "#"+layerid; if (tmplayerid.length == 1) return;var $tmpnode = $(tmplayerid+' li > .wp-new-article-style-c'); maxliheight = Math.max.apply(null,$tmpnode.map(function(){return $(this).outerHeight();}).toArray()); if (maxliheight) $tmpnode.height(maxliheight); // 右间距 2014/03/17 $(tmplayerid).bind("fixedmarginright", function(e, margin){ var $target = $(this),$li = $target.find('li'); if(margin != undefined) $li.css("margin-right", margin+'px'); var $first = $li.filter(':first'),liwidth = $first.outerWidth(), mgnright = $._parseFloat($first.css("marginRight")), maxwidth = $target.children('.wp-article_list_content').width(), maxcols = Math.floor(maxwidth / (liwidth + mgnright)); if(maxwidth >= maxcols * (liwidth + mgnright) + liwidth) maxcols += 1; for(var i = 1,licnt = $li.length; i <= licnt; i++){ if (i % maxcols != 0) continue; if ((maxcols == 1) && (2*liwidth <= maxwidth)) continue; $li.filter(':eq('+(i - 1)+')').css("margin-right", '0'); } $li = null; }).triggerHandler("fixedmarginright"); // < .wp-new-article-style-01-left').outerWidth(true); $PL.find('li > .wp-new-article-style-01-right').css({"width": (MAXW - LW)+'px',"overflow": 'hidden',"word-wrap": 'break-word'}); //set li width var self=$(this);var leftwidth=self.find('.wp-new-article-style-01-left').outerWidth(); var rightwidth=self.find('.wp-new-article-style-01-right').outerWidth(); //设置时间日期容器的宽度,设置之后无法添加文章浏览量 if(articleStyle == "ylist2") $PL.find('li .time').parent('.tinubox').css({"width": (MAXW - LW)+'px'}); $PL = null; if(articleStyle != "ylist2") self.css('width',(leftwidth+rightwidth+350)+'px'); }) }).triggerHandler("fixedliwidth"); }); } } } function layer_article_list_pager_func(param){ $(function(){ var ua = navigator.userAgent.toLowerCase() || ''; var layerid = param.layer_id,$cstlayer = $('#'+layerid), $pglnker = $cstlayer.find('.wp-article_list_content .wp-pager_link'); $pglnker.find('a').click(function(e,page){ var urlhrf = $(this).attr("href"); if(urlhrf.indexOf("##")>-1){ e.preventDefault(); var pageid = page||$(this).attr("href").replace("###",''); if(param.editmode == "1") $.method.article_list.refreshArticleList({"page":pageid,"layerid":layerid}); else { var dom = $cstlayer.find('.article_list_save_itemList'), params = { }; var liststyle={"artliststyle":param.artliststyle} $.ajax({ type: "GET", url: parseToURL("article_list","get_page"), data: {article_category:param.article_category_param,layer_id: layerid,page: pageid,article_category_more:param.article_category_more}, success: function(data){ var $layer = $("#"+layerid); var oldHeight = $layer.find('.article_list-'+layerid).height(); $layer.children('.wp-article_list_content').hide().before(data).remove(); if(!ua.match(/chrome\/46/)){ var this_dom = $('#'+layerid); this_dom.find(".wp-pager_link").css({'position':'relative','bottom':'auto','width':'100%'}); if(!this_dom.data('not_need_heightadapt')) wp_heightAdapt($layer); var cheight = this_dom.find(".wp-article_content").height(); var oulheight = this_dom.find(".article_list-"+layerid).height(); var olkheight = this_dom.find(".wp-pager_link").outerHeight(); var fcontent = this_dom.find(".wp-article_list_content"); var botmag = parseInt(fcontent.css("border-bottom-width"))+parseInt(fcontent.css("padding-bottom")); if(cheight>oulheight+olkheight &&!$layer.data('not_need_heightadapt')){ this_dom.find(".wp-pager_link").css({'position':'absolute','bottom':botmag+'px','width':'100%'}) } /** * #修复“分页”后高度出现异常问题(bug#4316)2015/11/17 * #插件内容高度实际上没有问题,只因“分页”区域定位问题而导致的错觉 * bug(#4515)发现模块高度小于内容高度导致分页隐藏 */ var $C = $layer.children('.wp-article_list_content'),$W = $C.children('.article_list-'+layerid); var c_h = $C.height(),w_h = $W.height(); if(c_h-1){ $pglnker.find('a').triggerHandler('click',[Math.min(pgid,maxpg)]); }else{ urlhrf=urlhrf.replace(/\d+$/,Math.min(pgid,maxpg)) location.href=urlhrf; } } } } function _int(numString){ var number = parseInt(numString); if(isNaN(number)) return 0; return number; } return false; }; break; case "button": ent = 'click'; fnc = function(){ if (pgid.length && /^[1-9]{1}\d*$/.test(pgid)) { var maxpg = _int($pglnker.find('span.total').html()); if(!maxpg) maxpg = 1; var pagelink=$pglnker.find('a:first'); var urlhrf = pagelink.attr("href"); if(urlhrf.indexOf("##")>-1){ $pglnker.find('a').triggerHandler('click',[Math.min(pgid,maxpg)]); }else{ urlhrf=urlhrf.replace(/\d+$/,Math.min(pgid,maxpg)) location.href=urlhrf; } } function _int(numString){ var number = parseInt(numString); if(isNaN(number)) return 0; return number; } return false; }; break; } if(fnc && $.isFunction(fnc)) $input[ent](fnc); }); }); }; function layer_tb_product_list_init_func(param){ var layerid=param.layer_id; var productStyle=param.productStyle; window['set_thumb_'+layerid]=function(obj){ var callback=function(img){ img.fadeIn('slow',function(){ img.closest('.img,.wp-new-product-style-01-left').children('.imgloading').remove(); }); } $(obj).each(function() { var img=$(this); callback(img); }); } $(function(){ setTimeout(function(){ if(productStyle=== "03"||productStyle=== "04"){ $(".tb_product_list-"+layerid+" li").each(function(){ var tmph = parseInt($('.productsmallfloating img').eq(0).height()); var mrt = $(this).find('.productlistid').height()-10-tmph; var mrtw = ($(this).find('.productlistid').width()-$(this).find('.productsmallfloating').width())/2; $(this).find('.productsmallfloating').css({'marginTop':mrt+'px','marginLeft':mrtw+'px'}) }) } },300) }) if (productStyle === "01"||productStyle === "03") { $("#"+layerid).bind("fixedmarginright", function(e, margin){ var $target = $(this),$li = $target.find('.tb_product_list-'+layerid+' > ul > li'); if(margin != undefined) {$li.css("margin-right", margin+'px');} else { var limargin=$li.filter(':first').css("margin-right"); if(parseInt(limargin)>0){ $li.css("margin-right", $li.filter(':first').css("margin-right")); }else{ setTimeout(function(){ $li.css("margin-right", $li.filter(':first').css("margin-right")); },300) } } // 2014/04/23 leiminglin 修改为动态获取li的padding 和 border var $first = $li.filter(':first'); var paddingLeft = $first.css("padding-left")||'0'; var paddingRight = $first.css("padding-right")||'0'; var liwidth = $first.width() + parseInt( paddingLeft.match(/\d+/) ) + parseInt( paddingRight.match(/\d+/) ) + parseInt( $first.css("border-left-width") ) * 2, //30、6 li的padding和border mgnright = $._parseFloat($first.css("marginRight")), maxwidth = $target.children('.wp-tb_product_list_content').width(), maxcols = Math.floor(maxwidth / (liwidth + mgnright)); if(maxwidth >= maxcols * (liwidth + mgnright) + liwidth) maxcols += 1; for(var i = 1,licnt = $li.length; i <= licnt; i++){ if (i % maxcols != 0) continue; if ((maxcols == 1) && (2*liwidth <= maxwidth)) continue; $li.filter(':eq('+(i - 1)+')').css("margin-right", '0'); } if(!$("#"+layerid).find('.wp-pager_link:visible').length){ var firstcol=($li.length % maxcols != 0)?(parseInt($li.length/maxcols)*maxcols+1):(($li.length/maxcols-1)*maxcols+1); for(var i = 1,licnt = $li.length; i <= licnt; i++){ if(i>=firstcol) $li.filter(':eq('+(i - 1)+')').css("margin-bottom", '7px'); } } layer_img_lzld(layerid); }) $(function(){ var maxliheight = 0,tmplayerid = "#"+layerid; if (tmplayerid.length == 1) return;var $tmpnode = $(tmplayerid+' li .wp-new-article-style-c'); $tmpnode.css('height',''); // fix bug 8231, setTimeout(function(){ maxliheight = Math.max.apply(null,$tmpnode.map(function(){return $(this).outerHeight();}).toArray()); if (productStyle == '01' && param.prdbacheight != '0') { maxliheight = param.prdbacheight; } if (maxliheight) { $tmpnode.height(maxliheight); if(!$(tmplayerid).data('not_need_heightadapt')) wp_heightAdapt($(tmplayerid)); } },0); // 右间距 2014/03/17 $(tmplayerid).triggerHandler("fixedmarginright"); // <-1){ var pageid = page||$(this).attr("href").replace("###",''); if(param.editmode == "1") $.method.tb_product_list.refreshProductList({"page":pageid,"layerid":layerid,"orderby":param.orderby,"ordertype":param.sortby}); else { var dom = $cstlayer.find('.tb_product_list_save_itemList'), params = {}; var liststyle={"prdliststyle":param.prdliststyle} var search_txt = $.trim($("#"+layerid).find('.search-input').val()); var startprice = $.trim($(".price-input").eq(0).val()); //取搜索开始价格值 var endprice = $.trim($(".price-input").eq(1).val()); //取搜索结束价格值 var product_category = $("#"+layerid).find("input[name='get_product_category']").val(); //分类产品分页丢失 if($("#"+layerid).find(".wp-pager_link").length){ var pagerlink=$("#"+layerid).find(".wp-pager_link"); if(pagerlink.css('position')=='relative'){ var pageparent=pagerlink.offsetParent(); var firstpageofpos2=pagerlink.offset().top-pageparent.offset().top; var oripagepos=$("#"+layerid).data('firstpageofpos'); if(oripagepos){ if(Math.abs(firstpageofpos2-oripagepos)<20) firstpageofpos2=oripagepos } $("#"+layerid).data('firstpageofpos',firstpageofpos2); } } $.ajax({ type: "GET", url: parseToURL("tb_product_list","get_page"), data: {product_category:param.product_category,layer_id: layerid,page: pageid,search_txt:search_txt,start_price:startprice,end_price:endprice,"orderby":param.orderby,"ordertype":param.sortby,"filter_arr":param.filter_arr}, success: function(data){ var $layer = $("#"+layerid); var oldHeight = $layer.find('.tb_product_list-'+layerid).height(); $layer.children('.wp-tb_product_list_content').before(data).remove(); var maxliheight = 0,tmplayerid = "#"+layerid; if (tmplayerid.length == 1) return;var $tmpnode = $(tmplayerid+' li .wp-new-article-style-c'); maxliheight = Math.max.apply(null,$tmpnode.map(function(){return $(this).outerHeight();}).toArray()); if (maxliheight) $tmpnode.height(maxliheight); // 右间距 2014/03/17 $(tmplayerid).triggerHandler("fixedmarginright"); // <0 && this_dom.find(".wp_filter_attr").css("display") !='none'){ old_attr = this_dom.find(".wp_filter_attr").outerHeight(); } var old_searchbox = 0; if(this_dom.find(".wp-tb_product_list_searchbox").length>0 && this_dom.find(".wp-tb_product_list_searchbox").css("display") !='none'){ old_searchbox = this_dom.find(".wp-tb_product_list_searchbox").outerHeight(); } if(cheight>oulheight+olkheight+old_attr+old_searchbox){ if(!this_dom.data('firstpageofpos')){ this_dom.find(".wp-pager_link").css({'position':'absolute','bottom':'0px','top':'','width':'100%','line-height':'23px'}) this_dom.find('.mCSB_container').css('min-height','100%'); }else{ var firstpageofpos=this_dom.data('firstpageofpos'); this_dom.find(".wp-pager_link").css({'position':'absolute','bottom':'','top':firstpageofpos+'px','width':'100%','line-height':'23px'}) this_dom.find('.mCSB_container').css('min-height','100%'); } } //explain:产品列表模块刷新后将页面定位到该模块距离浏览器顶部的距离,author:fpf,date:2014-12-18,action:modify; //1/定位到网站页首2/定位到产品列表页首 if(pageskips == 1){ $('#scroll_container').scrollTop(0); } else if(pageskips == 2){ var product_listtop = $cstlayer.css('top').replace('px',''); var father = $cstlayer.attr('fatherid')||''; if(father){ var father_top = $('#'+father).css('top').replace('px',''); product_listtop = parseInt(product_listtop)+parseInt(father_top); if($("#"+father).length>0){ var fathers = $("#"+father).attr('fatherid')||''; if(fathers){ var father_tops = $('#'+fathers).css('top').replace('px',''); product_listtop = parseInt(product_listtop)+parseInt(father_tops); } } } if(product_listtop){$('#scroll_container').scrollTop(product_listtop);} } } }); } return false; } }); if(param.editmode != "1"){ if($.cookie('wp_layer_page_'+layerid) && $.cookie('wp_layer_page_'+layerid) != param.curpage){ $pglnker.find('a:first').trigger('click',$.cookie('wp_layer_page_'+layerid)); } } // About input $pglnker.find('.pttypeinput').each(function(i,dom){ var $input = $(this),ent = pgid = '',fnc; switch($input.attr("type")) { case "text": ent = 'keyup'; fnc = function(){ pgid = this.value = this.value.replace(/(?:\b0|[^\d+])/i,''); //分页的style4样式的skin4皮肤,点击回车跳转到指定页面 var keycode = event.keyCode; if (keycode == 13) { var pagerstyle = $pglnker.parent().nextAll('.tb_product_list_save_itemList').attr('pagerstyle'); var pstarr = pagerstyle.split('index.html'),pstyle = pstarr[0],pskin = pstarr[1]; if (pstyle == 'style4' && pskin == 'skin4') { if (pgid.length && /^[1-9]{1}\d*$/.test(pgid)) { var maxpg = _int($pglnker.find('span.total').html()); if(!maxpg) maxpg = 1; var pagelink=$pglnker.find('a:first'); var urlhrf = pagelink.attr("href"); if(urlhrf.indexOf("##")>-1){ $pglnker.find('a').triggerHandler('click',[Math.min(pgid,maxpg)]); }else{ urlhrf=urlhrf.replace(/\d+$/,Math.min(pgid,maxpg)) location.href=urlhrf; } } } } function _int(numString){ var number = parseInt(numString); if(isNaN(number)) return 0; return number; } return false; }; break; case "button": ent = 'click'; fnc = function(){ if (pgid.length && /^[1-9]{1}\d*$/.test(pgid)) { var maxpg = _int($pglnker.find('span.total').html()); if(!maxpg) maxpg = 1; var pagelink=$pglnker.find('a:first'); var urlhrf = pagelink.attr("href"); if(urlhrf.indexOf("##")>-1){ $pglnker.find('a').triggerHandler('click',[Math.min(pgid,maxpg)]); }else{ urlhrf=urlhrf.replace(/\d+$/,Math.min(pgid,maxpg)) location.href=urlhrf; } } function _int(numString){ var number = parseInt(numString); if(isNaN(number)) return 0; return number; } return false; }; break; } if(fnc && $.isFunction(fnc)) $input[ent](fnc); }); }); } function layer_tb_product_list_refreshOrder_func(param){ var layerid=param.layer_id; window['refreshOrderby_'+layerid]=function(obj,flag) { var start_price = $.trim($('#'+layerid+' .price-input').eq(0).val()); var end_price = $.trim($('#'+layerid+' .price-input').eq(1).val()); var search_txt = $.trim($('#'+layerid).find('.search-input').val()); var search_name= $.trim($('#'+layerid).find('input[name="cityname"]').val()); var tmp_obj = {layer_id:layerid,search_name:search_name,location:$.trim($("#"+layerid).find("input[name='location']").val()),start_price:start_price,end_price:end_price,search_txt:search_txt,product_category:$.trim($("#"+layerid).find("input[name='get_product_category']").val() ||param.product_category)} //筛选属性 var attr_loop_str=[]; var filter_show = []; $('#'+layerid+' .wp_filter_attr .sorting').each(function(i){ var attr_loop = ''; attr_loop = $(this).find('.pttypeinput').val(); if(attr_loop) attr_loop_str.push(attr_loop); if ($(this).attr('isshow') == '1') { filter_show.push(i); } }); var attrid = obj; if($.isPlainObject(obj)){ attrid = obj.rm_attrid; delete obj.rm_attrid; } var isShow = $('#'+layerid+' .wp_filter_attr').data('show'); if(isShow){ var showContions = []; var j = 0; for(var n = 0; n < attr_loop_str.length; n++){ var tempArr = []; var tempStr = ''; var attrName = ''; var attrKey = ''; if(tempArr = attr_loop_str[n].split(',')){ if(tempArr.length > 1){ for(var m = 0; m < tempArr.length; m++){ attrName = $('#'+layerid+' .wp_filter_attr .sorting').find('a[attrval="'+tempArr[m]+'"]').text(); if(m == tempArr.length - 1){ tempStr += attrName; }else{ tempStr += attrName+','; } } attrName = tempStr; }else{ attrName = $('#'+layerid+' .wp_filter_attr .sorting').find('a[attrval="'+attr_loop_str[n]+'"]').text(); } attrKey = attr_loop_str[n]; showContions[j] = {'attrkey' : attrKey,'attrname': attrName}; j++; } } if(flag == 2){ showContions = showContions.filter(function (item) { return item.attrkey != attrid; }); } var vHtml = ''; for(var i = 0; i < showContions.length; i++){ vHtml += '
    '; vHtml += '
    '+showContions[i].attrname+'
    '; vHtml += ''; vHtml += '
    '; } } if(flag == 2){ attr_loop_str = attr_loop_str.filter(function (item) { return item != attrid; }); } attr_loop_str=attr_loop_str.join('$$$'); $("#"+layerid).find("input[name='filter_arr']").val(attr_loop_str); var filter_obj = {filter_arr:$.trim($("#"+layerid).find("input[name='filter_arr']").val())}; $.extend(tmp_obj,obj,filter_obj); var contentheight=$("#"+layerid+" .wp-tb_product_list_content").css('height'); tmp_obj.filter_show = filter_show.length>0?filter_show.join(','):''; $.ajax({ type:'POST', url:parseToURL('tb_product_list','orderby'), data:tmp_obj, success:function(data){ $("#"+layerid).html(data); if(isShow){ if(showContions.length > 0){ var chain = $('#'+layerid+' .wp_filter_attr .cont .selattrs'); chain.find('.nocondition').hide(); chain.prepend(vHtml); } } if(flag == 3){ $("#"+layerid).find('a[attrval="'+attrid+'"]').addClass('noHover'); $("#"+layerid).find('a[attrval="'+attrid+'"]').one('mouseleave',function(){ $(this).removeClass('noHover'); }); } if(contentheight && contentheight!='') $("#"+layerid+" .wp-tb_product_list_content").css('height',contentheight); $("#"+layerid).triggerHandler("fixedmarginright"); if (param.productStyle=== "01") { var maxliheight = 0,tmplayerid = "#"+layerid; var thisdom = $("#"+layerid).find(".img_lazy_load"); thisdom.each(function(){ $(this).fadeOut().fadeIn(100); $(this).attr("src",$(this).attr("data-original")); }); // fix bug 8231 和上边调用的代码重复,不用调用两遍 } var this_dom = $('#'+layerid); this_dom.find(".wp-pager_link").css({'position':'relative','bottom':'auto','width':'100%'}); setTimeout(function(){ if(!this_dom.data('not_need_heightadapt')) wp_heightAdapt(this_dom); var cheight = this_dom.find(".wp-product_content").height(); var oulheight = this_dom.find(".tb_product_list-"+layerid).height(); var olkheight = this_dom.find(".wp-pager_link").outerHeight(); var old_attr = 0; if(this_dom.find(".wp_filter_attr").length>0 && this_dom.find(".wp_filter_attr").css("display") !='none'){ old_attr = this_dom.find(".wp_filter_attr").outerHeight(); } var old_searchbox = 0; if(this_dom.find(".wp-tb_product_list_searchbox").length>0 && this_dom.find(".wp-tb_product_list_searchbox").css("display") !='none'){ old_searchbox = this_dom.find(".wp-tb_product_list_searchbox").outerHeight(); } if(cheight>oulheight+olkheight+old_attr+old_searchbox){ if(!this_dom.data('firstpageofpos')){ this_dom.find(".wp-pager_link").css({'position':'absolute','bottom':'0px','top':'','width':'100%','line-height':'23px'}) }else{ var firstpageofpos=this_dom.data('firstpageofpos'); this_dom.find(".wp-pager_link").css({'position':'absolute','bottom':'','top':firstpageofpos+'px','width':'100%','line-height':'23px'}) } } },200) } }); } }