window.Base = window.Base || function() {}; window.console = window.console || { log: function() {}, warn: function() {}, error: function() {}, info: function() {} } // 2017/12废弃 //使用jquery能获å–éšè—å…ƒç´ çš„å®½é«˜ï¼ŒèŽ·å–æ–¹æ³•$(å…ƒç´ ).actual('width') ; (function($) { $.fn.addBack = $.fn.addBack || $.fn.andSelf; $.fn.extend({ actual: function(method, options) { // check if the jQuery method exist if (!this[method]) { throw '$.actual => The jQuery method "' + method + '" you called does not exist'; } var defaults = { absolute: false, clone: false, includeMargin: false }; var configs = $.extend(defaults, options); var $target = this.eq(0); var fix, restore; if (configs.clone === true) { fix = function() { var style = 'position: absolute !important; top: -1000 !important; '; // this is useful with css3pie $target = $target. clone(). attr('style', style). appendTo('body'); }; restore = function() { // remove DOM element after getting the width $target.remove(); }; } else { var tmp = []; var style = ''; var $hidden; fix = function() { // get all hidden parents $hidden = $target.parents().addBack().filter(':hidden'); style += 'visibility: hidden !important; display: block !important; '; if (configs.absolute === true) style += 'position: absolute !important; '; // save the origin style props // set the hidden el css to be got the actual value later $hidden.each(function() { var $this = $(this); // Save original style. If no style was set, attr() returns undefined tmp.push($this.attr('style')); $this.attr('style', style); }); }; restore = function() { // restore origin style values $hidden.each(function(i) { var $this = $(this); var _tmp = tmp[i]; if (_tmp === undefined) { $this.removeAttr('style'); } else { $this.attr('style', _tmp); } }); }; } fix(); // get the actual value with user specific methed // it can be 'width', 'height', 'outerWidth', 'innerWidth'... etc // configs.includeMargin only works for 'outerWidth' and 'outerHeight' var actual = /(outer)/.test(method) ? $target[method](configs.includeMargin) : $target[method](); restore(); // IMPORTANT, this plugin only return the value of the first element return actual; } }); })(jQuery); // 2017/12废弃 //计算ç‰é«˜,傿•°(外框,规律åå…ƒç´ ,需è¦è®¡ç®—ç‰é«˜çš„å…ƒç´ ,该宽度以下ä¸è®¡ç®—ç‰é«˜) Base.prototype.contourFun = function(box, element, obj, resolution) { var box_set = $(box), win_w = $(window).width(); if (box_set.length > 0) { if (resolution == undefined || win_w > resolution) { $.each(box_set, function(i, box_o) { box_o = $(box_o); var element_o = box_o.find(element), obj_o = element_o.find(obj), box_w = box_o.actual('outerWidth'), element_w = element_o.actual('width') - 1, oneRowNum = Math.floor(box_w / element_w), arr = [], max_height; if (box_w > 0 && oneRowNum > 0) { var rowNum = Math.ceil(element_o.length / oneRowNum); obj_o.height('auto'); for (var y = 0; y < rowNum; y++) { arr = []; for (var x = oneRowNum * y; x < oneRowNum * (y + 1); x++) { arr.push(obj_o.eq(x).actual('height')); } max_height = Math.max.apply(null, arr); for (var x = oneRowNum * y; x < oneRowNum * (y + 1); x++) { obj_o.eq(x).height(max_height) } } } }); } else { box_set.find(element).find(obj).height("auto"); } } } Base.prototype.promptIncident = function() { $(".prompt-popup").on("click", function() { var showClass = "." + $(this).data("vaule"); (showClass && showClass == ".map-reveal-module") && $(showClass).addClass("map-reveal-module-bg"); var nowscroll_length = $(document).scrollTop(); $("body").addClass("position-fix").css("margin-top", -nowscroll_length); $(showClass).fadeIn("fast").css("overflow-y", "auto"); }); $(".prompt-clock").on("click", function(event) { var e = event || window.event; e.stopPropagation(); var nowscroll_length = Math.abs(parseInt($("body").css("margin-top"))); $("body").removeClass("position-fix").css("margin-top", 0); $("html,body").scrollTop(nowscroll_length); $(this).parents(".prompt-box").fadeOut("fast"); }); } Base.prototype.v2PromptIncident = function() { $(".v2-prompt-popup").on("click", function() { var showClass = "." + $(this).data("vaule"); var nowscroll_length = $(document).scrollTop(); $("body").addClass("position-fix").css("margin-top", -nowscroll_length); $(showClass).fadeIn("fast").css("overflow-y", "auto"); }); $(".v2-prompt-clock").on("click", function(event) { var e = event || window.event; e.stopPropagation(); var nowscroll_length = Math.abs(parseInt($("body").css("margin-top"))); $("body").removeClass("position-fix").css("margin-top", 0); $("html,body").scrollTop(nowscroll_length); $(this).parents(".v2-prompt-box").fadeOut("fast"); }); } //PC端设置二级导航在一级导航的æ£ä¸‹æ–¹æ¯”,PC端设置二级èœå•çš„åŒçº§ç‰é«˜ Base.prototype.navigationIncident = function() { //PC端设置二级导航在一级导航的æ£ä¸‹æ–¹æ¯” var box_width = 0, li_width = 0, left_length = 0, right_length = 0, win_widht = $(window).width(); var test_html = ""; $(".nav-subset-module").each(function() { box_width = $(this).actual('width'); //二级盒å的宽度 li_width = $(this).parents(".nav-list").outerWidth(); //一级æ 目的宽度 left_length = $(this).parents(".nav-list").offset().left; //一级è·ç¦»æµè§ˆå™¨å·¦ä¾§çš„宽度 right_length = win_widht - li_width - left_length; if (left_length < (box_width - li_width) / 2) { $(this).css("margin-left", -left_length); } else { if (right_length < (box_width - li_width) / 2) { $(this).css("margin-left", -(box_width - li_width - right_length + 1)); } else { $(this).css("margin-left", (li_width - box_width) / 2); } } }); //登录æç¤ºæ¡†ç›¸å…³äº‹ä»¶ $(".login").on("hover", function() { if ($('#noshow_myspace').prop('checked')) { $.cookie('SpaceTimes', "no_notice", { expires: 90, path: '/' }); } if ($(".logined-tip").length > 0) $(".logined-tip").hide(); }); $("body").on("click", function() { if ($('#noshow_myspace').prop('checked')) { $.cookie('SpaceTimes', "no_notice", { expires: 90, path: '/' }); } if ($(".logined-tip").length > 0) $(".logined-tip").hide(); }); $(".nav-quick").on("hover", function() { if ($('#noshow_myspace').prop('checked')) { $.cookie('SpaceTimes', "no_notice", { expires: 90, path: '/' }); } if ($(".logined-tip").length > 0) $(".logined-tip").hide(); }); $(".logined-tip").on("click", function(event) { event.stopPropagation(); }); //处ç†IE下æœç´¢æ¡†ç„¦ç‚¹é—®é¢˜ $(".nav-section .nav-list").hover(function() {}, function() { if ($(".nav-section .nav-searchbit-text").length > 0) { $(".nav-section .nav-searchbit-text").blur(); } }); //PC端设置二级èœå•çš„åŒçº§ç‰é«˜ $(".nav-subset-height").each(function() { var max_height = 0; for (var i = 0; i < $(this).find(".nav-tabel-cell").length; i++) { var box_obj = $(this).find(".nav-tabel-cell").eq(i).find(".nav-subset-box").eq(0); if (i == 0) { max_height = box_obj.actual('outerHeight'); } else { if (max_height < box_obj.actual('outerHeight')) { max_height = box_obj.actual('outerHeight'); } } } for (var i = 0; i < $(this).find(".nav-tabel-cell").length; i++) { $(this).find(".nav-tabel-cell").eq(i).find(".nav-subset-box").eq(0).outerHeight(max_height); } }); $(".nav-subset-module").removeClass("nav-subset-height"); //处ç†PCç«¯é¡¶éƒ¨å¯¼èˆªçš„çŠ¶æ€ function resetNavStatus() { if ($('.nav-section').length > 0) { if ($(window).scrollTop() < $('.nav-section').offset().top) { $(".nav-section .nav").css("position", "relative"); } else { $(".nav-section .nav").css("position", "fixed"); } } } resetNavStatus(); $(window).scroll(function() { resetNavStatus(); }); } //IE8以下æç¤º Base.prototype.BrowseHappyFun = function() { var cookie_name = "browsehappy"; var lang = $("#gLanguageCurrent").val(); if (lang == "en" || lang == "en-gb" || lang == "fr-fr" || lang == "de" || lang == "it" || lang == "es") { cookie_name = "browsehappy_other"; } if ($.cookie(cookie_name)) { return false; } else { $('.browsehappy').slideDown(function() { $(this).trigger("slideEnd") $(window).trigger("scroll") }); } $('.browsehappy a.close').click(function() { $(this).parents('.browsehappy').slideUp( function() { $(this).trigger("slideEnd"); $(window).trigger("scroll") $.cookie(cookie_name, 'browsehappy', { expires: 30, path: '/', domain: 'huawei.com' }) } ); }) } //绑定PCç«¯å’Œç§»åŠ¨ç«¯å¯¼èˆªæ æœç´¢æ¡†éšè—显示事件 Base.prototype.searchIncident = function() { //PC端 $(".search").on("click", function(e) { $(this).find(".search-box").addClass("on").find(".search-text").focus(); $(document).on("click", function() { $(".search-box").removeClass("on"); }); //if ($(".logined-tip").length > 0) $(".logined-tip").hide(); e.stopPropagation(); }); $(".search-box").on("click", function(e) { e.stopPropagation(); }); $(".search .search-close").on("click", function(e) { $(this).parents(".search-box").removeClass("on"); e.stopPropagation(); }); //移动端 $(".mobile-search .mobile-search-a").on("click", function(e) { $(this).parents(".mobile-search").find(".mobile-search-box").slideToggle(100).find(".mobile-search-text").focus(); $(document).on("click", function() { $(".mobile-search-box").slideUp(100); }); e.stopPropagation(); }); $(".mobile-search-box").on("click", function(e) { e.stopPropagation(); }); $(".mobile-search-box span").on("click", function() { $(this).parents(".mobile-search-box").slideUp(100); }); } //ä¸åŒåŒºåŸŸåˆ·æ–° Base.prototype.resizeStackLock = false; Base.prototype.resizeStack = []; Base.prototype.resizeChangeScreen = function() { // åˆ¤æ–æ˜¯å¦æœ‰å·²å…¨å±çš„å…ƒç´ var resizeTimer; var that = this; var perWinWidth = $(window).width(); function getLevel(w) { if (w <= 750) { return 0; } else if (w <= 1200) { return 1; } else { return 2; } } function hasFullScreenElement() { return document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement } //è§†é¢‘æ’æ”¾ä¸åˆ·æ–°é¡µé¢ function checkVideoPlaying(){ var fullScreenElement = hasFullScreenElement(); return (fullScreenElement && $(fullScreenElement).attr("id") == "jWVideoFrameId")||$("#jWVideoFrameId").hasClass("vjs-playing")||$(".mudu-state-playing").length } $(window).on("resize", function() { clearTimeout(resizeTimer); resizeTimer = setTimeout(function() { var winw = $(window).width() //视频ä¸åœ¨æ’放状æ€ï¼Œä¸åœ¨å…¨å±çжæ€,åª’ä½“æŸ¥è¯¢æ²¡æœ‰åˆ‡æ¢ if (getLevel(perWinWidth) != getLevel(winw) && !checkVideoPlaying()) { location.reload(); } else { //处ç†éœ€è¦resize的函数 that.resizeStackLock = true $.each(that.resizeStack, function(idx, val) { if (val && val.fn) { val.fn.apply(this, val.params); } }) that.resizeStackLock = false } }, 400); }) } //移动端èœå•事件 Base.prototype.wapManuNav = function() { //设置èœå•高度 var window_H = $(window).height(); $(".wap-navbox").height(window_H); $(".wap-nav").height(window_H); //为展开èœå•æ·»åŠ ç‚¹å‡»äº‹ä»¶ $("#wap-menubtn").on("click", function() { var sroll_length = $(document).scrollTop(); $("body").addClass("position-fix").css("marginTop", -sroll_length); $("#wap-menu").fadeIn(100); $('#top').fadeOut(); }); //为关é—èœå•æ·»åŠ ç‚¹å‡»äº‹ä»¶ $(".wap-menuclose").on("click", function() { if ($("#wap-menuprev").attr("data-prev") != "" && $("#wap-menuprev").attr("data-prev") != undefined) { $('#wap-menuprev').trigger('click'); } var sroll_length = Math.abs(parseInt($("body").css("marginTop"))); $("body").removeClass("position-fix").css("marginTop", 0); $("html,body").scrollTop(sroll_length); $("#wap-menu").fadeOut(100); $(".mob-nav-corporate").find('a[aria-expanded="true"]').trigger("click"); }); //为返回èœå•æ·»åŠ ç‚¹å‡»äº‹ä»¶ $("#wap-menuprev").on("click", function() { var This = $(this); var pre_class = $('.' + This.attr("data-prev")); if (This.attr("data-prev") == "opened1") { pre_class.removeClass("wap-rollout opened1"); $(".wap-navmain ul").removeClass("wap-putaway"); $("#wap-menutitle").html("").removeClass("wap-show"); $("#wap-menuprev").removeClass("wap-show").attr("data-prev", ""); $(".wap-navbox").scrollTop(0); } if (This.attr("data-prev") == "opened2") { var pre_title = $(".opened1").parents("li").find(".wap_firstcolumn span").text(); pre_class.removeClass("wap-rollout opened2"); $("#wap-menutitle").html(pre_title); $("#wap-menuprev").attr("data-prev", "opened1"); $(".opened1").removeClass("wap-overflow-hide"); $(".opened1").find("dl").first().removeClass("wap-putaway"); $(".wap-navbox").scrollTop(0); } }); //为一级èœå•æ·»åŠ ç‚¹å‡»äº‹ä»¶ $(".wap-navmain .wap_firstcolumn").on("click", function() { if ($(this).parents("li").find(".wap-navbox").length > 0) { var head_title = $(this).find("span").text(); $("#wap-menutitle").html(head_title).addClass("wap-show"); $("#wap-menuprev").addClass("wap-show").attr("data-prev", "opened1"); $(".wap-navmain ul").addClass("wap-putaway"); $(this).parents("li").find(".wap-navbox").first().addClass("wap-rollout opened1"); } }); //为二级èœå•有三级æ ç›®çš„æ·»åŠ ç‚¹å‡»äº‹ä»¶ $(".wap-navmain .wap_secondcolumn").on("click", function() { var head_title = $(this).find("span").text(); $("#wap-menutitle").html(head_title).addClass("wap-show"); $("#wap-menuprev").addClass("wap-show").attr("data-prev", "opened2"); $(".wap-navbox").scrollTop(0); $(".opened1").addClass("wap-overflow-hide"); $(".opened1").find("dl").first().addClass("wap-putaway"); $(this).parents("dd").find(".wap-navbox").first().addClass("wap-rollout opened2"); }); } // 2017/12废弃 // 大å±å°å±çš„æ›¿æ¢å›¾ç‰‡ Base.prototype.replaceImg = function() { if ($('.replaceimg').length > 0) { var win_w = $(window).width(); if (win_w > 768) { $('.replaceimg').each(function(index, el) { var pcsrc = $(this).data('pcsrc'); $(this).attr('src', pcsrc); }); } else { $('.replaceimg').each(function(index, el) { var wapsrc = $(this).data('wapsrc'); $(this).attr('src', wapsrc); }); }; }; } // 2017/12废弃 // 大å±å°å±çš„æ›¿æ¢å›¾ç‰‡(éœ€è¦æ‡’åŠ è½½) Base.prototype.replaceImglazyload = function() { if ($('.replaceimglazyload').length > 0) { var win_w = $(window).width(); var replaceimg = $('.replaceimglazyload'); if (win_w > 768) { var pcsrc = replaceimg.data('pcsrc'); replaceimg.attr('data-original', pcsrc); } else { var wapsrc = replaceimg.data('wapsrc'); replaceimg.attr('data-original', wapsrc); }; }; } // 大å±å°å±çš„æ›¿æ¢å›¾ç‰‡ Base.prototype.V2ReplaceImg = function() { if ($('.J-V2ReplaceImg').length > 0) { var win_w = $(window).width(); $('.J-V2ReplaceImg').each(function() { var replaceimg = $(this); if (replaceimg.data('ipadsrc') != undefined) { if (win_w > 1200) { var pcsrc = replaceimg.data('pcsrc'); if (replaceimg.is('img')) { replaceimg.attr('src', pcsrc); } else { replaceimg.css('backgroundImage', 'url(' + pcsrc + ')'); } } else if (1200 > win_w && win_w > 750) { var ipadsrc = replaceimg.data('ipadsrc'); if (replaceimg.is('img')) { replaceimg.attr('src', ipadsrc); } else { replaceimg.css('backgroundImage', 'url(' + ipadsrc + ')'); } } else { var wapsrc = replaceimg.data('wapsrc'); if (replaceimg.is('img')) { replaceimg.attr('src', wapsrc); } else { replaceimg.css('backgroundImage', 'url(' + wapsrc + ')'); } }; } else { if (win_w > 750) { var pcsrc = replaceimg.data('pcsrc'); if (replaceimg.is('img')) { replaceimg.attr('src', pcsrc); } else { replaceimg.css('backgroundImage', 'url(' + pcsrc + ')'); } } else { var wapsrc = replaceimg.data('wapsrc'); if (replaceimg.is('img')) { replaceimg.attr('src', wapsrc); } else { replaceimg.css('backgroundImage', 'url(' + wapsrc + ')'); } }; } }) }; } // 大å±å°å±çš„æ›¿æ¢å›¾ç‰‡(éœ€è¦æ‡’åŠ è½½) V2 Base.prototype.V2ReplaceImglazyload = function() { if ($('.J-V2Replaceimglazyload').length > 0) { var win_w = $(window).width(); $('.J-V2Replaceimglazyload').each(function() { var replaceimg = $(this); if (replaceimg.data('ipadsrc') != undefined) { if (win_w > 1200) { var pcsrc = replaceimg.data('pcsrc'); replaceimg.attr('data-original', pcsrc); } else if (1200 > win_w && win_w > 750) { var ipadsrc = replaceimg.data('ipadsrc'); replaceimg.attr('data-original', ipadsrc); } else { var wapsrc = replaceimg.data('wapsrc'); replaceimg.attr('data-original', wapsrc); }; } else { if (win_w > 750) { var pcsrc = replaceimg.data('pcsrc'); replaceimg.attr('data-original', pcsrc); } else { var wapsrc = replaceimg.data('wapsrc'); replaceimg.attr('data-original', wapsrc); }; } }) }; } // æœ‰æ‡’åŠ è½½ï¼Œå¤§å±å°å±çš„æ›¿æ¢å›¾ç‰‡ Base.prototype.ebgReplaceImgLazyLoad = function() { function init() { if ($('.J-ebg-replace-img-lazyload').length > 0) { var win_w = $(window).width(); $('.J-ebg-replace-img-lazyload').each(function() { var $this = $(this); var src = $this.attr("src"); var img1920 = $this.data("pc-l"); var img1600 = $this.data("pc-s"); var img1200 = $this.data("ipad-h"); var img992 = $this.data("ipad-v"); var img750 = $this.data("wap"); if (win_w > 1600) { $this.attr('data-original', img1920 || img1600 || img1200 || img992 || img750 || src); } else if (win_w > 1200) { $this.attr('data-original', img1600 || img1920 || img1200 || img992 || img750 || src); } else if (win_w > 992) { $this.attr('data-original', img1200 || img1600 || img1920 || img992 || img750 || src); } else if (win_w > 750) { $this.attr('data-original', img992 || img750 || img1200 || img1600 || img1920 || src); } else { $this.attr('data-original', img750 || img992 || img1200 || img1600 || img1920 || src); } }); }; } //坹外釿–°åˆå§‹åŒ– $("body").on("ebgReplaceImgLazyLoad", function() { init(); }); init(); } // æ²¡æœ‰æ‡’åŠ è½½ï¼Œå¤§å±å°å±çš„æ›¿æ¢å›¾ç‰‡ Base.prototype.ebgReplaceImg = function() { function init() { if ($('.J-ebg-replace-img').length > 0) { var win_w = $(window).width(); $('.J-ebg-replace-img').each(function() { var $this = $(this); var src = $this.attr("src"); var img1920 = $this.data("pc-l"); var img1600 = $this.data("pc-s"); var img1200 = $this.data("ipad-h"); var img992 = $this.data("ipad-v"); var img750 = $this.data("wap"); if (win_w > 1600) { $this.attr('src', img1920 || img1600 || img1200 || img992 || img750 || src); } else if (win_w > 1200) { $this.attr('src', img1600 || img1920 || img1200 || img992 || img750 || src); } else if (win_w > 992) { $this.attr('src', img1200 || img1600 || img1920 || img992 || img750 || src); } else if (win_w > 750) { $this.attr('src', img992 || img1200 || img1600 || img1920 || img750 || src); } else { $this.attr('src', img750 || img992 || img1200 || img1600 || img1920 || src); } }); }; } //坹外釿–°åˆå§‹åŒ– $("body").on("ebgReplaceImg", function() { init(); }); init(); } // 检测æµè§ˆå™¨çš„版本 Base.prototype.browserVersion = function() { var userAgent = navigator.userAgent; //å–å¾—æµè§ˆå™¨çš„userAgentå—符串 if ((userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))) { var isIos = !!userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //判æ–移动端æµè§ˆå™¨ var isAndroid = userAgent.indexOf('Android') > -1 || userAgent.indexOf('Adr') > -1; //判æ–移动端æµè§ˆå™¨ if (isIos) { return "ios"; } if (isAndroid) { if (userAgent.match(/HUAWEI/i) && userAgent.match(/MQQBrowser/i)) { return "huawei"; } else if (userAgent.match(/HONOR/i) && userAgent.match(/MQQBrowser/i)) { return "honor"; } else { return "android"; } } } else { var isOpera = userAgent.indexOf("Opera") > -1; //åˆ¤æ–æ˜¯å¦Operaæµè§ˆå™¨ var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera; //åˆ¤æ–æ˜¯å¦IEæµè§ˆå™¨ var isIE11 = userAgent.indexOf("rv:11") > -1; var isEdge = userAgent.indexOf("Edge") > -1 && !isIE; //åˆ¤æ–æ˜¯å¦IEçš„Edgeæµè§ˆå™¨ var isFF = userAgent.indexOf("Firefox") > -1; //åˆ¤æ–æ˜¯å¦Firefoxæµè§ˆå™¨ var isSafari = userAgent.indexOf("Safari") > -1 && userAgent.indexOf("Chrome") == -1; //åˆ¤æ–æ˜¯å¦Safariæµè§ˆå™¨ var isChrome = userAgent.indexOf("Chrome") > -1 && userAgent.indexOf("Safari") > -1 && userAgent.indexOf("Edge") == -1; //判æ–Chromeæµè§ˆå™¨ if (isIE) { var reIE = new RegExp("MSIE (\\d+\\.\\d+);"); reIE.test(userAgent); var fIEVersion = parseFloat(RegExp["$1"]); switch (fIEVersion) { case 6: return "6"; case 7: return "7"; case 8: return "8"; case 9: return "9"; case 10: return "10"; case 11: return "11"; default: return "0"; //IE版本过低 } } if (isFF) { return "FF"; } if (isOpera) { return "Opera"; } if (isSafari) { return "Safari"; } if (isChrome) { return "Chrome"; } if (isEdge) { return "Edge"; } if (isIE11) { return '11' } } } // 计算åŒè¡Œç‰é«˜æ–¹æ³•,åªç”¨åœ¨IE10以下,其他的用属性控制 Base.prototype.v2SetHeight = function(obj, obj2, obj3) { if (!this.resizeStackLock && this.resizeStack) { this.resizeStack.push({ fn: this.v2SetHeight, params: arguments }); } if (baseLib.browserVersion() < 11) { var This = $(obj); This.each(function() { var _this = $(this), oList = _this.find(obj2), oList_len = oList.length, oBox_w = _this.outerWidth(true) + 10, oList_w = oList.outerWidth(true), oColumn_len = Math.floor(oBox_w / oList_w), oRow_len = Math.ceil(oList_len / oColumn_len), oList_H = 0, oList_obj = null; oList.find(obj3).height('auto'); for (var i = 0; i < oRow_len; i++) { for (var j = i * oColumn_len; j < oColumn_len * (i + 1); j++) { oList.eq(j).addClass('oList_obj'); var H = oList.eq(j).find(obj3).height(); H > oList_H ? oList_H = H : oList_H; oList_obj = $('.oList_obj'); } oList_obj.find(obj3).height(oList_H); oList_obj.removeClass('oList_obj'); oList_H = 0; } }); } } Base.prototype.lineLimit = function() { function getWord($text, line, word) { var text = $text.text(); if ($text.data("org-text")) { text = $text.data("org-text"); } else { $text.data("org-text", text); } line = line || 1; var $testWord = $("#J-line-limit-text"); if ($testWord.length == 0) { $("body").append('
'); // $("body").append(''); } $testWord = $("#J-line-limit-text").css({ fontSize: $text.css("font-size"), lineHeight: $text.css("line-height"), width: $text.width(), wordBreak: $text.css("word-break"), }) var maxHeight = $testWord.html("...").height() * line; //按å•è¯æ¥è®¡ç®— if (word) { text = text.split(/([^x00-xff]|\s+)/ig); } var len = text.length; var over = false; while (len--) { var sliceText; if (text[len] == "") { continue; } if (typeof text == "object") { sliceText = text.slice(0, len + 1).join(""); } else { sliceText = text.slice(0, len + 1); } $testWord.html(sliceText + "..."); if ($testWord.height() > maxHeight) { over = true; continue; } if (over) { return sliceText.slice(0, sliceText.length - 1) + "..."; } else { return text; } } return ""; } //事件 $(document).off("limit", ".J-line-limit").on("limit", ".J-line-limit", function() { var win_w = $(window).width(); var $this = $(this); if ($this.data("init-limit") || $this.is(":hidden")) { return; } $this.data("init-limit", true) var line = $this.data("limit"); var limit1600 = $this.data("limit-pc-s"); var limit1200 = $this.data("limit-ipad-h"); var limit992 = $this.data("limit-ipad-s"); var limit750 = $this.data("limit-wap"); var allow = false; if (limit1600 && win_w > 1600) { allow = true; } if (limit1200 && win_w > 1200) { allow = true; } if (limit992 && win_w > 992) { allow = true; } if (limit750 && win_w > 750) { allow = true; } if (!allow && !(limit1600 || limit1200 || limit992 || limit750)) { allow = true; } if (allow) { $this.html(getWord($this, line, $this.data("limit-type"))); } }) $(".J-line-limit").trigger("limit"); setTimeout(function() { $(".J-line-limit").data("init-limit", false) $(".J-line-limit").trigger("limit"); }, 1000) } // 计算åŒè¡Œç‰é«˜æ–¹æ³•,优化版 // å¦‚æžœå±‚çº§åªæœ‰ä¸¤çº§ï¼Œä¼ 2ä¸ªå‚æ•°ï¼Œå¦‚æžœå±‚çº§æœ‰ä¸‰çº§ï¼Œä¼ 3ä¸ªå‚æ•°ï¼Œ Base.prototype.v3SetHeight = function(obj, obj2, obj3) { if (!this.resizeStackLock && this.resizeStack) { this.resizeStack.push({ fn: this.v3SetHeight, params: arguments }); } var This = $(obj); var args = arguments; This.each(function() { var _this = $(this), oList = _this.find(obj2), oList_len = oList.length, oBox_w = _this.width() + 10, oList_w = oList.width(), oColumn_len = Math.floor(oBox_w / oList_w), oRow_len = Math.ceil(oList_len / oColumn_len), oList_H = 0, oList_obj = null; if (args.length == 2) { oList.height('auto'); } else { oList.find(obj3).height('auto'); } for (var i = 0; i < oRow_len; i++) { for (var j = i * oColumn_len; j < oColumn_len * (i + 1); j++) { oList.eq(j).addClass('oList_obj'); if (args.length == 2) { var H = oList.eq(j).height(); } else { var H = oList.eq(j).find(obj3).height(); } H > oList_H ? oList_H = H : oList_H; oList_obj = $('.oList_obj'); } if (args.length == 2) { oList_obj.height(oList_H); } else { oList_obj.find(obj3).height(oList_H); } oList_obj.removeClass('oList_obj'); oList_H = 0; } }); } // v2版底部 (废弃2019/05/15 z270868) Base.prototype.v2FooterFun = function() { $('.foot-nav-cell').on('click', function() { var _this = $(this); if (!_this.hasClass('current')) { $('.foot-nav-cell').removeClass('current'); $('.foot-nav-cell').find('dd').removeClass('current'); $('.foot-nav-cell').find('.iconfont').addClass('icon-expansion').removeClass('icon-collapse'); _this.addClass('current'); _this.find('dd').addClass('current'); _this.find('.iconfont').removeClass('icon-expansion').addClass('icon-collapse'); } else { _this.removeClass('current'); _this.find('dd').removeClass('current'); _this.find('.iconfont').addClass('icon-expansion').removeClass('icon-collapse'); } }); } //ä¾§è¾¹æ 动画效果 Base.prototype.globalToolbar = function() { // 20171219 zhangle var globalToolbarH = null; var objGlobalToolbar = $('.global_toolbar'); var toolbarBtnH = $('.toolbar_btn').height(); //åˆå§‹åŒ– if ($('.bannar-breadcrumbs-wrap').height() > 100) { globalToolbarH = $('.bannar-breadcrumbs-wrap').height() + $('.zl-pc-header').height() + 50; $('.toolbar_btn').css({ 'top': globalToolbarH, 'marginTop': 0 }); } else { $('.global_toolbar').removeClass('default'); $('.toolbar_btn').css({ 'top': '50%', 'marginTop': -toolbarBtnH / 2 }); } // æ»šåŠ¨æ¡æ»šåŠ¨æ—¶ $(window).on('scroll.toolbar', function() { var scrTop = $(window).scrollTop(); var winH = $(window).height() if (objGlobalToolbar.hasClass('default')) { if (scrTop + winH / 2 >= globalToolbarH + toolbarBtnH / 2) { $('.global_toolbar').removeClass('default opacity'); $('.toolbar_btn').removeClass('default').css({ 'top': '50%', 'marginTop': -toolbarBtnH / 2 }); } } else { if (scrTop > 10) { $('.global_toolbar').removeClass('opacity'); $('.toolbar_btn').removeClass('default'); } } }) // 针对页é¢å†…éƒ¨æœ‰æ»šåŠ¨æ¡ $('.reading_container').on('scroll.readingcontainer', function() { $('.global_toolbar').removeClass('opacity'); $('.toolbar_btn').removeClass('default'); $('.reading_container').off("scroll.readingcontainer"); $('.global_toolbar').removeClass('default'); }); // å½“é¼ æ ‡ç§»å…¥åœ¨ç§»å‡ºçš„æ—¶å€™ï¼Œæ”¶èµ· $('.global_toolbar').on('mouseleave', '.toolbar_btn', function() { $('.global_toolbar').removeClass('opacity'); $('.toolbar_btn').removeClass('default'); }); } // æ·»åŠ å…¨ç«™ç½®é¡¶æŒ‰é’® 2019/05/16 zwx270868 Base.prototype.globalTopButton = function() { var win_w = $(window).width(); // 去除è€ç‰ˆæœ¬çš„置顶按钮 if ($('div#top').length > 0 || $('a#top').length > 0) { $('#top').detach(); }; // 创建新的置顶按钮 $('', { 'id': 'global-top-button', 'class': 'iconfont icon-up', 'style': 'display:none;border:1px solid #eee;border-radius:2px;background:#fff;position:fixed;bottom:190px;right:20px;width:40px;height:40px;text-align:center;padding-top:7px;font-size:24px;color: #999;cursor:pointer;z-index:1001;line-height:1;' }).appendTo('body'); var objBtn = $('#global-top-button'); var perScrollTop = 0; // 移动端改å˜å¤§å° if ($(window).width() < 750) { objBtn.css({ 'bottom': 165, 'right': 15 }); } else if (750 < $(window).width() && $(window).width() < 1200) { objBtn.css({ 'bottom': 180, 'right': 15 }); } else { // hoverçŠ¶æ€æ¢å›¾ objBtn.hover(function() { objBtn.css('color', '#333'); }, function() { objBtn.css('color', '#666'); }) } // 针对åŽä¸ºæ‰‹æœºå¤„ç†å®šä½é—®é¢˜ if (baseLib.browserVersion() == 'huawei' && win_w < 750) { objBtn.css('bottom', 165); } //else if (baseLib.browserVersion() == 'honor' && win_w < 750) { // objBtn.css('bottom', 115); // } // 滚动事件,显示éšè— $(window).scroll(function() { var scrollTop = $(window).scrollTop(); if (scrollTop > 700) { objBtn.show(); } else { objBtn.hide(); } }) // 点击滚动到最顶部 objBtn.on('click', function() { $('body,html').animate({ 'scrollTop': 0 }); }) } var baseLib = new Base(); // baseLib.wapManuNav(); //åŠ è½½å¯¼èˆªç§»åŠ¨ç«¯èœå• baseLib.navigationIncident(); //åŠ è½½å¤„ç†PC端二级导航对é½å¹¶ä¸”二级èœå•åŒçº§ç‰é«˜ baseLib.promptIncident(); //åŠ è½½å¼¹å‡ºæ¡†å¤„ç†äº‹ä»¶ // baseLib.searchIncident(); //åŠ è½½æœç´¢æ¡†äº‹ä»¶ baseLib.contourFun(".subset-industry-I", "dd", "span"); //设置PC二级导航类别ç‰é«˜ baseLib.BrowseHappyFun(); //IEæ³¨é‡Šå…³é— baseLib.resizeChangeScreen(); //刷新 baseLib.replaceImg(); //大å±å°å±çš„å›¾ç‰‡æ›¿æ¢ baseLib.replaceImglazyload(); //大å±å°å±çš„å›¾ç‰‡æ›¿æ¢ baseLib.ebgReplaceImgLazyLoad() // æœ‰æ‡’åŠ è½½5ç§å°ºå¯¸å›¾ç‰‡çš„å›¾ç‰‡æ›¿æ¢ baseLib.ebgReplaceImg() // æ²¡æœ‰æ‡’åŠ è½½5ç§å°ºå¯¸å›¾ç‰‡çš„å›¾ç‰‡æ›¿æ¢ baseLib.browserVersion(); //v2版 baseLib.lineLimit(); //baseLib.v2SetHeight();//v2版设置高度仅é™IE10以下 baseLib.v2FooterFun(); //v2版底部 baseLib.v2PromptIncident(); baseLib.V2ReplaceImglazyload(); // 17/11/27 æ‡’åŠ è½½å¦‚æžœæœ‰3å¼ å›¾çš„è¯æˆ–è€…ä¸¤å¼ å›¾éƒ½è¡Œã€‚ç§»åŠ¨ç«¯èŠ‚ç‚¹æ”¹æˆäº†750 baseLib.V2ReplaceImg(); // 17/11/27 æ‡’åŠ è½½å¦‚æžœæœ‰3å¼ å›¾çš„è¯æˆ–è€…ä¸¤å¼ å›¾éƒ½è¡Œã€‚ç§»åŠ¨ç«¯èŠ‚ç‚¹æ”¹æˆäº†750 baseLib.globalToolbar(); baseLib.globalTopButton(); // 全站置顶按钮 var win_W = $(window).width(); $(window).resize(function() { var curWin_W = $(window).width(); if (curWin_W != win_W) { win_W = curWin_W; baseLib.replaceImg(); //大å±å°å±çš„å›¾ç‰‡æ›¿æ¢ baseLib.replaceImglazyload(); //大å±å°å±çš„图片替æ¢(éœ€è¦æ‡’åŠ è½½) }; }); // åˆ¤æ–æµè§ˆå™¨æ˜¯å¦æ˜¯IE8åŠä»¥ä¸‹ï¼Œæ˜¯çš„è¯å¼¹å‡ºæç¤ºå‡çº§æ¡† switch (baseLib.browserVersion()) { case '6': case '7': case '8': case '0': var cook = $.cookie('browserVersionie8'); if (cook == null) { $.cookie('browserVersionie8', "ok", { expires: 1, path: '/' }); $('.prompt-ie8').fadeIn(); } break; default: break; } //æ‡’åŠ è½½æ‹“å±•jqueryæ’ä»¶ $.fn.extend({ 'setWidthHeight': function(options) { //é»˜è®¤å‚æ•° var defaluts = { 'scale': 4 / 3 // ä¼ å›¾ç‰‡æ¯”ä¾‹ }; //使用jQuery.extent覆盖æ’ä»¶é»˜è®¤å‚æ•° var opts = $.extend({}, defaluts, options); var This = $(this); var w = This.width(); var h = w / opts.scale; This.css('height', h); $(window).resize(function() { This.each(function() { if (!$(this).hasClass('over')) { w = This.width(); h = w * opts.h / opts.w; This.css('height', h); }; }) }) } }); if ($('.lazyload img,.lazyload-v2 img').lazyload != undefined) { // 将带有lazyload下的imgæ‡’åŠ è½½ // 另傿•°(é…置对象),下é¢é…置对象ä¸çš„å„个属性值都是默认的 if ($('.lazyload img').length > 0) { $('.lazyload img').lazyload({ threshold: 100, //临界值,这个值是针对container容器的,å³è·ç¦»container容器视å£çš„临界值 failure_limit: 100, //最åŽä¸€ä¸ªé…置属性failure_limit event: 'scroll', //触å‘内部appear事件 effect: "fadeIn", //显示方法,默认为show,也å¯ä»¥è®¾ç½®ä¸ºfadeIn container: window, data_attribute: "original", //imgå…ƒç´ çš„ä¸€ä¸ªdataå±žæ€§ï¼Œç”¨äºŽå˜æ”¾å›¾ç‰‡çš„çœŸå®žåœ°å€ skip_invisible: true, //忽略éšè—çš„imgå…ƒç´ appear: function () { var $lazyload = $(this).parents(".lazyload"); if ($lazyload.parents(".ebg-bg").length && $lazyload.parents(".ebg-bg").data("replace") != "not") { $lazyload.parents(".ebg-bg").css("background-image", "url(" + $(this).data("original") + ")"); $(this).data("original", ""); $lazyload.hide(); } }, //在img触å‘appear事件时执行的回调 load: function () { var $lazyload = $(this).parents(".lazyload"); if ($lazyload.parents(".ebg-bg").length && $lazyload.parents(".ebg-bg").data("replace") != "not") { // $lazyload.parents(".ebg-bg").css("background-image","url("+$(this).attr("src")+")"); // $lazyload.hide(); } else { $lazyload.css({ 'height': 'auto', 'background': 'none' }).addClass('over'); } } //在img触å‘load事件时执行的回调 }); } // 将带有lazyload下的imgæ‡’åŠ è½½ // 另傿•°(é…置对象),下é¢é…置对象ä¸çš„å„个属性值都是默认的 if ($('.lazyload-v2 img').length > 0) { $('.lazyload-v2 img').lazyload({ threshold: 100, //临界值,这个值是针对container容器的,å³è·ç¦»container容器视å£çš„临界值 failure_limit: 100, //最åŽä¸€ä¸ªé…置属性failure_limit event: 'scroll', //触å‘内部appear事件 effect: "fadeIn", //显示方法,默认为show,也å¯ä»¥è®¾ç½®ä¸ºfadeIn container: window, data_attribute: "original", //imgå…ƒç´ çš„ä¸€ä¸ªdataå±žæ€§ï¼Œç”¨äºŽå˜æ”¾å›¾ç‰‡çš„çœŸå®žåœ°å€ skip_invisible: true, //忽略éšè—çš„imgå…ƒç´ appear: null, //在img触å‘appear事件时执行的回调 load: function () { $(this).parents(".lazyload-v2").css({ 'height': 'auto', 'background': 'none' }).addClass('over'); } //在img触å‘load事件时执行的回调 }); } } else { // 将带有lazyload下的imgæ‡’åŠ è½½ function lazyloadClearBg(obj, className) { var _this = $(obj); if (_this.parents(".ebg-bg").length && _this.parents(".ebg-bg").data("replace") != "not") { //请é¿å…路径ä¸å˜åœ¨ç©ºæ ¼ _this.parents(".ebg-bg").css("background-image", "url(" + _this.data("original") + ")"); // _this.data("original", ""); _this.parents(className).hide(); } if (_this.parents(className)) { _this.parents(className).css('background', 'none'); } } if ($('.lazyload img').length > 0) { var lazyLazy = new LazyLoad({ elements_selector: ".lazyload img", data_src: "original", callback_loaded: function (obj) { lazyloadClearBg(obj, ".lazyload"); }, callback_enter: function (obj) { lazyloadClearBg(obj, ".lazyload"); } }); } if ($('.lazyload-v2 img').length > 0) { var lazyLazy = new LazyLoad({ elements_selector: ".lazyload-v2 img", data_src: "original", callback_loaded: function (obj) { lazyloadClearBg(obj, ".lazyload-v2"); }, callback_enter: function (obj) { lazyloadClearBg(obj, ".lazyload-v2"); } }); } } // å°è¯ç§ä¾§è¾¹æ 事件 (function($) { // æ»šåŠ¨æ¡æ»šåŠ¨æ—¶ï¼Œä¾§è¾¹æ æ˜¾ç¤ºéšè—功能 if ($('#need_help_desktop').length > 0) { var contactUsAnimate = 0; $(window).scroll(function() { if (contactUsAnimate == 0) { if ($(document).scrollTop() > 100 && $(window).width() > 767) { $("#need_help_desktop").fadeIn(330); contactUsAnimate = 1; } } }); // 点击展开侧边æ 功能 var $needHelpContHeight = $("#need_help_popup ul").height() + 40; $("#need_help_desktop").click(function(e) { e.stopPropagation(); }) $("#need_help_desktop .tab_help_open").click(function(e) { e.stopPropagation(); if ($(window).width() <= 767) { $("#need_help_popup").css('top', '132px').show(); } else { if ($(this).hasClass('close')) { if ($("#gLanguageCurrent").val() == 'ar-sa') { $("#need_help_desktop").animate({ 'left': -250 }, 330); } else { $("#need_help_desktop").animate({ 'right': -250 }, 330); } var $needHelpHeight = $("#need_help_desktop .tab_help_open img").height() + 16; $("#need_help_desktop #need_help_popup,#need_help_desktop .tab_help_open").animate({ 'height': $needHelpHeight }, function() { $('#need_help_desktop .tab_help_open').removeClass('close clickopen').addClass("clickclose"); }) } else { if ($("#gLanguageCurrent").val() == 'ar-sa') { $("#need_help_desktop").animate({ 'left': 0 }); } else { $("#need_help_desktop").animate({ 'right': 0 }); } $("#need_help_desktop #need_help_popup,#need_help_desktop .tab_help_open").animate({ 'height': 330 }, function() { $('#need_help_desktop .tab_help_open').addClass('close clickopen').removeClass("clickclose"); }); } } }); $("#footer_nav_mobile_back_to_top").click(function() { window.scrollTo(0, 0); }); $("body").click(function() { if ($("#gLanguageCurrent").val() == 'ar-sa') { $("#need_help_desktop").animate({ 'left': -250 }, 330); } else { $("#need_help_desktop").animate({ 'right': -250 }, 330); } var $needHelpHeight = $("#need_help_desktop .tab_help_open img").height() + 16; $("#need_help_desktop #need_help_popup,#need_help_desktop .tab_help_open").animate({ 'height': $needHelpHeight }) $('#need_help_desktop .tab_help_open').removeClass('close clickopen').addClass("clickclose"); }); } })(jQuery);