product-intro.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. $(document).ready(function(){
  2. //view more topic
  3. $('.view-more-topic a').click(function(){
  4. $('.content-middle-topics').css('max-height','20000px');
  5. //$(this).css('display','none');
  6. var quantity = $('.lesson-item').length;
  7. var link = $(this).attr('link')
  8. $.ajax({
  9. url: link,
  10. data: {
  11. start: quantity
  12. },
  13. type: "POST"
  14. }).success(function(data) {
  15. if(data != ''){
  16. $('.content-middle-topics').append(data);
  17. }else{
  18. $('.view-more-topic a').css('display','none');
  19. }
  20. });
  21. });
  22. //view more product intro
  23. $('.view-more-intro a').click(function(){
  24. $('.middle-intro-group-content').css('max-height','20000px');
  25. $(this).css('display','none');
  26. });
  27. //change product type
  28. $('.product-item-check').click(function(){
  29. var val = $(this).attr('val');
  30. $('.product-type').val(val);
  31. $('.product-item-check').removeClass('check-active');
  32. $(this).addClass('check-active');
  33. });
  34. // Scroll spy
  35. $('.header-scroll[scroll-target]').click(function(event) {
  36. $('.header-scroll[scroll-target].tab-active').removeClass('tab-active');
  37. $(this).addClass('tab-active');
  38. var target = $(this).attr('scroll-target');
  39. var positionTop = parseInt($(this).attr('scroll-position-top'));
  40. var position = $("#" + target).offset().top;
  41. $('html,body').animate({
  42. scrollTop: position - positionTop
  43. });
  44. });
  45. // Scroll
  46. $(document).scroll(function(){
  47. var docViewTop = $(window).scrollTop();
  48. for (var i = $('.header-scroll[scroll-target]').length - 1; i >= 0; i--) {
  49. var el = $('.header-scroll[scroll-target]')[i];
  50. var target = $(el).attr('scroll-target');
  51. var positionTop = parseInt($(el).attr('scroll-position-top'));
  52. var position = $("#" + target).offset().top;
  53. if( (position - positionTop - 100) <= docViewTop ){
  54. $('.header-scroll[scroll-target].tab-active').removeClass('tab-active');
  55. $(el).addClass('tab-active');
  56. break;
  57. }
  58. };
  59. var contentPos = $('.library-content-middle').offset().top;
  60. var footerPos = $('.footer-container').offset().top;
  61. if(docViewTop >= contentPos && docViewTop < (footerPos - 450)){
  62. $('.library-detail-content').addClass('scroll-active');
  63. }else{
  64. $('.library-detail-content').removeClass('scroll-active');
  65. }
  66. });
  67. });
  68. var tUser;
  69. var isStoped = false;
  70. function stopGetUserProduct() {
  71. isStoped = true;
  72. clearTimeout(tUser);
  73. }
  74. function getUserProduct(){
  75. if(!isStoped){
  76. tUser = setTimeout(function(){
  77. var link = $('.product-user').attr('link')
  78. $.ajax({
  79. url: link,
  80. data: {
  81. },
  82. type: "POST"
  83. }).success(function(data) {
  84. if(data != ''){
  85. $('.product-user').css({'bottom':'-200px','opacity':0});
  86. $('.product-user').html(data);
  87. $('.product-user').animate({'bottom':'15px','opacity':0.9}, 1300);
  88. setTimeout(function(){
  89. $('.product-user').animate({'bottom':'-200px','opacity':0}, 1300);
  90. getUserProduct();
  91. },15000)
  92. }
  93. });
  94. },15000);
  95. }
  96. }