/** * 通用模块 * */ var $win = $(window), $doc = $(document), $body = $('body', $doc), winw = $win.width(); $(window).resize(function() { winw = $win.width(); }) /** * 图片加载 */ $(function() { if (!$.fn.lazyload) return; $("img.lazy", $body).lazyload({ effect: "fadein", threshold: 200, failure_limit: 0 }); }); $(function() { if ($win.width() > 992) { if (!(/msie [6|7|8|9]/i.test(navigator.useragent))) { new wow().init(); }; } }); // 下拉菜单 $(function() { var $nav_li = $(".nav .nav-list1>li"); $nav_li.hover(function() { $(this).find('.nav-list2').stop(true, true).slidedown(200); }, function() { $(this).find('.nav-list2').slideup(200); }); }); $(function() { $(window).on("scroll", function() { var t = document.documentelement.scrolltop || document.body.scrolltop; if (screen.width > 0) { if (t >= 100) { //鍒ゆ柇 $(".header").addclass("fixed-header"); } else { $(".header").removeclass("fixed-header"); } } }) }); // 视频 $(function() { var $box = $(".video", $body); if (!$box.length) return; $box.on('click', '.video-box .play', function(event) { event.preventdefault(); var me = $(this); var $iframe = me.next('.iframe'), url = $iframe.data('src'); if ($win.width() > 1200) { $.fancybox.open([url], { type: 'iframe', padding: 10, }); } else { var height = me.find('.img-responsive').length ? me.height() : $box.height(); height = math.max(height, 170); if (!$iframe.attr('src')) $iframe.attr('src', url); $iframe.height(height); $iframe.css('display', 'block'); me.hide(); } }); }); /** * 幻灯切换 */ $(function() { if (!$.fn.owlcarousel) return; // 首页 banner $('#owl-index').owlcarousel({ autoplay: 4000, autoplay: true, autoheight: false, stoponhover: false, lazyload: true, singleitem: true, slidespeed: 300, autoplay: true, navigation: true, navigationtext: false, paginationspeed: 400, transitionstyle: "fade", }); }); $(function() { if (!$.fn.owlcarousel) return; $('#owl-news').owlcarousel({ autoplay: 4000, autoplay: true, autoheight: false, stoponhover: false, lazyload: true, singleitem: true, slidespeed: 300, autoplay: true, navigation: true, navigationtext: false, paginationspeed: 400, transitionstyle: "fade", }); }); $(function() { if (!$.fn.owlcarousel) return; $('#owl-product').owlcarousel({ autoplay: 4000, autoplay: true, autoheight: false, stoponhover: false, lazyload: true, singleitem: true, slidespeed: 300, autoplay: true, navigation: true, navigationtext: false, paginationspeed: 400, transitionstyle: "fade", }); }); // $(function() { // //判断控制页面初始时左右的高度一致 // var hl = $(".product-show .info-1 .left").outerheight(); //获取左侧left层的高度 // var hr = $(".product-show .info-1 .right").outerheight(); //获取右侧right层的高度 // var mh = math.max(hl, hr); //比较hl与hr的高度,并将最大值赋给变量mh // $(".product-show .info-1 .left").height(mh); //将left层高度设为最大高度mh // $(".product-show .info-1 .right").height(mh); //将right层高度设为最大高度 // }); $(".company ul li .c-title").click(function() { var par = $(this).parent(); if (par.attr("class") == "on") { $(".company ul li .c-title").parent().addclass("on").children('.text').slideup(); par.children('.text').slidedown(); par.removeclass("on").addclass("current").siblings().removeclass('current'); } else { par.children('.text').slideup(); par.addclass("on").removeclass("current"); } }); $(function() { if ($("#left").height() > $("#right").height()) { $("#right").css("height", $("#left").height()); } else { $("#left").css("height", $("#right").height()); } }) // 单选框 $(function() { $(".js-check").find("input").ioncheckradio(); }); // 放大 $(function() { $("a[rel=fancybox-product]").fancybox({ 'overlayshow': true, 'overlaycolor': '#000', 'overlayopacity': 0.9, 'opacity': 0.5, 'transitionin': 'elastic', 'transitionout': 'none', 'titleposition': 'over', 'showclosebutton': false, 'titleformat': function(title, currentarray, currentindex, currentopts) { return '' + (currentindex + 1) + ' / ' + currentarray.length + (title.length ? '   ' + title : '') + ' '; } }); }); // 返回顶部 $(function() { $('.backtop').click(function() { $("html, body").animate({ scrolltop: 0 }, 400); }); }); // 表格 $(function() { var otable = $("table"); if (otable.length !== 0) { var otr = otable.find('tr'), otd = otable.find('td'); otable.wrap("
"); otr.attr("style", ""); otd.each(function(index) { if (typeof($(this).attr("style")) !== "undefined") { if ($(this).attr("style").indexof("text-align: center") >= 0) { $(this).attr("style", "text-align: center"); } else { $(this).attr("style", ""); } } }) } }); $(function() { if (!placeholdersupport()) { // 判断浏览器是否支持 placeholder $('[placeholder]').focus(function() { var input = $(this); if (input.val() == input.attr('placeholder')) { input.val(''); input.removeclass('placeholder'); } }).blur(function() { var input = $(this); if (input.val() == '' || input.val() == input.attr('placeholder')) { input.addclass('placeholder'); input.val(input.attr('placeholder')); } }).blur(); }; }) function placeholdersupport() { return 'placeholder' in document.createelement('input'); }