m.home-voca.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. //Slider
  2. $(document).ready(function(){
  3. var width = $(".home-student-list").width();
  4. $("#home-student-slider").css('width', width);
  5. $("#home-student-slider .slider-container-cover").css('width', width);
  6. var options = { $AutoPlay: 1,
  7. $SlideSpacing: 25
  8. };
  9. if($("#home-student-slider").length > 0){
  10. var jssor_slider1 = new $JssorSlider$('home-student-slider', options);
  11. }
  12. });
  13. //Slider
  14. $(document).ready(function(){
  15. var itemWidth = 260;
  16. var maxCol = 3;
  17. var spacing = 30;
  18. var width = $(".home-product-list").width();
  19. var number = $("#home-product-slider .slider-container-cover .home-library-product").length;
  20. var colSuggest = Math.min(Math.ceil(width/(itemWidth + 30)), maxCol);
  21. var col = Math.min(Math.floor(width/(itemWidth + 30)), maxCol)
  22. var colSlider = colSuggest;
  23. if(number == 1 && col == 0){
  24. $('.home-library-product').css({
  25. 'margin-left': '0px',
  26. 'margin-right': '0px'
  27. });
  28. }else if(number == 1 && col == 1){
  29. colSuggest = 1;
  30. colSlider = 1;
  31. }else if(number <= col){
  32. colSuggest = number;
  33. colSlider = number;
  34. }else if(number == colSuggest){
  35. colSlider = number - 1;
  36. if(colSlider == 1){
  37. colSuggest = 1;
  38. }
  39. }
  40. console.log(colSlider);
  41. width = Math.min(itemWidth*colSuggest + spacing*colSuggest, width);
  42. $("#home-product-slider").css('width', width);
  43. $("#home-product-slider .slider-container-cover").css('width', width);
  44. var options2 = { $AutoPlay: 1,
  45. $SlideWidth: itemWidth,
  46. $SlideHeight: 340,
  47. $SlideSpacing: 30,
  48. $Cols: colSlider,
  49. $Align: width/2 - itemWidth/2 - 15,
  50. $BulletNavigatorOptions: {
  51. $Class: $JssorBulletNavigator$,
  52. $SpacingX: 10
  53. }
  54. };
  55. if($("#home-product-slider").length > 0){
  56. var jssor_slider2 = new $JssorSlider$('home-product-slider', options2);
  57. }
  58. var textHeight = $('.home-project-info-cover').innerHeight();
  59. $('.home-project-info-cover').css('height', '210px');
  60. $('.home-project-container .button-more').click(function(event) {
  61. if($('.home-project-info-cover').hasClass('cover-show')){
  62. $('.home-project-info-cover').animate({height: '210px'}, 400);
  63. $('.home-project-info-cover').removeClass('cover-show');
  64. $(this).find('.button-text').text($(this).find('.button-text').attr('langmore'));
  65. $(this).find('i').css({transform: 'rotate(0deg)'});
  66. }else{
  67. $('.home-project-info-cover').animate({height: textHeight + 'px'}, 400);
  68. $('.home-project-info-cover').addClass('cover-show');
  69. $(this).find('.button-text').text($(this).find('.button-text').attr('langless'));
  70. $(this).find('i').css({transform: 'rotate(180deg)'});
  71. }
  72. });
  73. });
  74. // Video
  75. // 2. This code loads the IFrame Player API code asynchronously.
  76. var tag = document.createElement('script');
  77. tag.src = "https://www.youtube.com/iframe_api";
  78. var firstScriptTag = document.getElementsByTagName('script')[0];
  79. firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
  80. // 3. This function creates an <iframe> (and YouTube player)
  81. // after the API code downloads.
  82. var player;
  83. var playerWidth = 470;
  84. function onYouTubeIframeAPIReady() {
  85. player = new YT.Player('player-video', {
  86. height: '100%',
  87. width: '100%',
  88. videoId: "Ixkd3pLIlY4",
  89. playerVars: {
  90. autoplay: 0,
  91. controls: 0,
  92. showinfo: 0,
  93. playsinline: 1,
  94. rel: 0
  95. },
  96. events: {
  97. // 'onReady': onPlayerReady,
  98. // 'onStateChange': onPlayerStateChange
  99. }
  100. });
  101. }
  102. $(document).on('click', '#home-video .layout-video', function(){
  103. if( isFunction(player.getPlayerState) ){
  104. if(player.getPlayerState() == 1){
  105. player.pauseVideo();
  106. $("#home-video .layout-video").removeClass('hide-layout');
  107. }else{
  108. player.playVideo();
  109. $("#home-video .layout-video").addClass('hide-layout');
  110. }
  111. }
  112. });
  113. function isFunction(functionToCheck) {
  114. return functionToCheck && {}.toString.call(functionToCheck) === '[object Function]';
  115. }