// Header position // jQuery(window).on('scroll', function() { if ($(this).scrollTop() > 200) { $('#header .header-inner').addClass("sticky"); } else { $('#header .header-inner').removeClass("sticky"); } }); // Mobile Menu // $(function(){ $('#nav').slicknav({ 'label' : '', 'prependTo': '.mobile-menu', }); }); // Testimonial Slider // $('.testimonial-slider').owlCarousel({ items:1, autoplay:true, autoplayTimeout:3500, smartSpeed: 1000, autoplayHoverPause:true, loop:true, merge:true, nav:false, dots:true, }); // Portfolio // $('.single-pf').owlCarousel({ items:1, autoplay:false, autoplayTimeout:4500, smartSpeed: 1000, autoplayHoverPause:true, margin:15, loop:true, merge:true, nav:true, dots:false, navText: ['PREVIOUS', 'NEXT'], }); // Client Slider // $('.clients-slider').owlCarousel({ autoplay:true, autoplayTimeout:3000, margin:15, smartSpeed: 1000, autoplayHoverPause:true, loop:true, nav:false, dots:false, responsive:{ 300: { items:2, }, 480: { items:3, }, 768: { items:4, }, 1170: { items:6, } } }); // Popup JS // $('.popup').magnificPopup({ type: 'image', gallery:{ enabled:true } }); // stellar // $.stellar({ horizontalOffset: 0, verticalOffset: 0 }); // Wow Animate // var wow = new WOW( { boxClass: 'wow', // animated element css class (default is wow) animateClass: 'animated', // animation css class (default is animated) offset: 0, // distance to the element when triggering the animation (default is 0) mobile: false, // trigger animations on mobile devices (default is true) live: true, // act on asynchronously loaded content (default is true) callback: function(box) { // the callback is fired every time an animation is started // the argument that is passed in is the DOM node being animated }, scrollContainer: null // optional scroll container selector, otherwise use window } ); wow.init(); /*==================================== Isotop ======================================*/ $(window).on('load', function() { if ($.fn.isotope) { $(".isotop-active").isotope({ filter: '*', }); $('.works-menu ul li').on('click', function() { $(".works-menu ul li").removeClass("active"); $(this).addClass("active"); var selector = $(this).attr('data-filter'); $(".isotop-active").isotope({ filter: selector, animationOptions: { duration: 750, easing: 'linear', queue: true, } }); return false; }); } }); // onePageNav // $('#nav').onePageNav({ changeHash: false, scrollSpeed: 1000, filter: '', }); // Scroll Up JS // // $(function () { // $.scrollUp({ // scrollName: 'scrollUp', // Element ID // topDistance: '300', // Distance from top before showing element (px) // topSpeed: 300, // Speed back to top (ms) // animation: 'fade', // Fade, slide, none // animationInSpeed: 200, // Animation in speed (ms) // animationOutSpeed: 200, // Animation out speed (ms) // scrollText: [""], // Text for element // activeOverlay: false, // Set CSS color to display scrollUp active point, e.g '#00FFFF' // }); // }); // counterUp // $('.counter').counterUp({ delay: 10, time: 2500, }); // Preloader $(window).on('load', function() { $('.loader').fadeOut('slow', function(){ $(this).remove(); }); }); /* @ 首页topbar轮播数据渲染 */ var mySwiper = new Swiper ('#swiper-container-index', { direction: 'horizontal', loop: true, speed: 500, //设置轮播时长 可以不设置 会有个默认值 autoplay: true,//可选选项,自动滑动 // 如果需要分页器 pagination: { el: '.swiper-pagination', clickable:true }, autoplay: { disableOnInteraction: false, //点击后继续轮播(这个很重要) delay: 3000, //自动轮播的每次的时间 可以不设置 会有个默认值 }, // 如果需要前进后退按钮 }); /* @ chenbiao @ 2018-01-23 @ 首页新闻图片轮播数据渲染 */ function indexImgSlide(){ var indexSlideList = $('.index_slide_list'); var imgList= []; //直接使用ajax访问 $.ajax({ type:'get', url:'newsdata/swipernewsdata.json', dataType:'json', success:function(data){ $.each(data, function(i, obj){ imgList.push( '
', '', '
', '

' + obj.newsTitle + '

', '
', '', '
', '
' ) }); indexSlideList.html(imgList.join(' ')); var mySwipernews = new Swiper ('#swiper-container-news', { direction: 'horizontal', loop: true, speed: 500, //设置轮播时长 可以不设置 会有个默认值 autoplay: true,//可选选项,自动滑动 // 如果需要分页器 pagination: { el: '.swiper-pagination', clickable:true }, autoplay: { disableOnInteraction: false, //点击后继续轮播(这个很重要) delay: 3000, //自动轮播的每次的时间 可以不设置 会有个默认值 }, // 如果需要前进后退按钮 }); } }); } indexImgSlide(); /* @ chenbiao @ 2018-01-23 @ 首页新闻列表 右侧 */ function indexNewsList(){ var newslist = $('.newslist ul'); var list= []; //直接使用ajax访问 $.ajax({ type:'get', url:'newsdata/newslistdata.json', dataType:'json', success:function(data){ $.each(data, function(i, obj){ list.push( '
  • ', '

    ', '' + obj.newsTitle , ''+obj.time+'', '', '

    ', '
  • ' ) }); newslist.html(list.join(' ')); } }) } indexNewsList(); /* @ chenbiao @ 2018-01-23 @ 打开新窗口 新闻 */ $(document).on('click','.red-slide a',function () { var link = $(this).attr('data-href'); window.open(link) }); /* @ chenbiao @ 2018-01-23 @ 切割字符串方法 commonStrandNum.cutString(str, 25) */ var commonStrandNum = { /* @切割字符串 @str原字符串 @num字符位数 */ cutString: function (str, num) { var _str = ""; if (str.length >= num) { var strN = str.substring(0, num); strN += "..."; _str = strN; } else { _str = str; } return _str; }, }