firm.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /**
  2. @Name: layuiNetCompany - 大气风格的网络公司企业模版
  3. @Author: xuxingyu
  4. @Copyright: layui.com
  5. */
  6. layui.define(['jquery', 'element', 'carousel', 'laypage'], function(exports){
  7. var $ = layui.jquery
  8. ,element = layui.element
  9. ,carousel = layui.carousel
  10. ,laypage = layui.laypage;
  11. //轮播渲染
  12. carousel.render({
  13. elem: '#banner'
  14. ,width: '100%'
  15. ,height: '258px'
  16. ,arrow: 'always'
  17. });
  18. //滚动监听
  19. $(window).scroll(function() {
  20. var scr=$(document).scrollTop();
  21. scr > 0 ? $(".nav").addClass('scroll') : $(".nav").removeClass('scroll');
  22. });
  23. //轮播文字
  24. $(function(){
  25. $('.banner').children('.title').addClass('active');
  26. })
  27. //导航切换
  28. var btn = $('.nav').find('.nav-list').children('button')
  29. ,spa = btn.children('span')
  30. ,ul = $('.nav').find('.nav-list').children('.layui-nav');
  31. btn.on('click', function(){
  32. if(!$(spa[0]).hasClass('spa1')){
  33. spa[0].className = 'spa1';
  34. spa[1].style.display = 'none';
  35. spa[2].className = 'spa3';
  36. $('.nav')[0].style.height = 90 + ul[0].offsetHeight + 'px';
  37. }else{
  38. spa[0].className = '';
  39. spa[1].style.display = 'block';
  40. spa[2].className = '';
  41. $('.nav')[0].style.height = 80 + 'px';
  42. }
  43. });
  44. //关于内容
  45. $('.main-about').find('.aboutab').children('li').each(function(index){
  46. $(this).on('click', function(){
  47. $(this).addClass('layui-this').siblings().removeClass('layui-this');
  48. $('.aboutab').siblings().fadeOut("fast");
  49. $('.aboutab').siblings().eq(index).fadeIn("");
  50. });
  51. });
  52. //动态分页
  53. /*
  54. laypage.render({
  55. elem: 'newsPage'
  56. ,count: 50
  57. ,theme: '#2db5a3'
  58. ,layout: ['page', 'next']
  59. });
  60. //案例分页
  61. laypage.render({
  62. elem: 'casePage'
  63. ,count: 50
  64. ,theme: '#2db5a3'
  65. ,layout: ['page', 'next']
  66. });
  67. */
  68. //新闻字段截取
  69. $(function(){
  70. $(".main-news").find(".content").each(function(){
  71. var span = $(this).find(".detail").children("span")
  72. ,spanTxt = span.html();
  73. if(document.body.clientWidth > 463){
  74. span.html(spanTxt);
  75. }else{
  76. span.html(span.html().substring(0, 42)+ '...')
  77. };
  78. $(window).resize(function(){
  79. if(document.body.clientWidth > 463){
  80. span.html(spanTxt);
  81. }else{
  82. span.html(span.html().substring(0, 42)+ '...')
  83. };
  84. });
  85. });
  86. });
  87. exports('firm', {});
  88. });