common.js 887 B

12345678910111213141516171819202122232425262728293031323334
  1. $(function() {
  2. 'use strict';
  3. function main() {
  4. $(window).scroll(showGotoTop);
  5. $(window).resize(showGotoTop);
  6. $('.goto-top').click(function() {
  7. document.body.scrollTop = 0;
  8. document.documentElement.scrollTop = 0;
  9. return false;
  10. });
  11. showGotoTop();
  12. showBaiduShare();
  13. }
  14. function showGotoTop() {
  15. var $gotoTop = $('.goto-top'),
  16. $bdshare = $('#bdshare');
  17. if ($(document).scrollTop() > 0) {
  18. $gotoTop.fadeIn('slow');
  19. $bdshare.fadeOut('slow');
  20. } else {
  21. $gotoTop.fadeOut('slow');
  22. $bdshare.fadeIn('slow');
  23. }
  24. }
  25. function showBaiduShare() {
  26. $('#bdshell_js').attr('src', 'http://bdimg.share.baidu.com/static/js/shell_v2.js?cdnversion=" + Math.ceil(new Date()/3600000');
  27. }
  28. main();
  29. });