main.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. function getUrl(value)
  2. {
  3. return location.protocol + '//' + location.host + '/' + value;
  4. }
  5. $(document).ready(function(){
  6. $(window).scroll(function(){
  7. var pos = $(window).scrollTop();
  8. if(pos >= 30){
  9. $('.main-header').css('position','fixed');
  10. $('.main-header').css('top','0');
  11. }else{
  12. $('.main-header').css('position','relative');
  13. $('.main-header').css('top','0');
  14. }
  15. });
  16. //login
  17. $('.login-system, .btn-login-system, .signup-system').click(function(){
  18. var isSignUp = $(this).attr('signup');
  19. if( $('#modal-sign-in').length ) {
  20. if(isSignUp == undefined){
  21. $('#modal-sign-in').modal();
  22. }else{
  23. $('#modal-sign-up').modal();
  24. }
  25. }else{
  26. $.ajaxSetup({
  27. headers: {
  28. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  29. }
  30. });
  31. $.ajax({
  32. url: getUrl('get-login'),
  33. type: "POST",
  34. data: {
  35. },
  36. success: function(result){
  37. console.log(result);
  38. $('body').append(result);
  39. if(isSignUp == undefined){
  40. $('#modal-sign-in').modal();
  41. }else{
  42. $('#modal-sign-up').modal();
  43. }
  44. }
  45. });
  46. }
  47. });
  48. });
  49. function open_login_g(){
  50. var curUrl = $('#current-url').val();
  51. if(curUrl == undefined){
  52. curUrl = "";
  53. }
  54. fb_login=window.open(getUrl("login-google?l="+curUrl),'name','width='+screen.width+',height='+screen.height+',top=0,left=0'+',fullscreen=yes');
  55. };
  56. function open_login_f(){
  57. var curUrl = $('#current-url').val();
  58. if(curUrl == undefined){
  59. curUrl = "";
  60. }
  61. fb_login=window.open(getUrl("login-facebook?l="+curUrl),'name','width='+screen.width+',height='+screen.height+',top=0,left=0'+',fullscreen=yes');
  62. }
  63. function open_f_login(){
  64. var curUrl = $('#current-url').val();
  65. if(curUrl == undefined){
  66. curUrl = "";
  67. }
  68. fb_login=window.open(getUrl("facebook-login?l="+curUrl),'name','width='+screen.width+',height='+screen.height+',top=0,left=0'+',fullscreen=yes');
  69. }
  70. function redirect()
  71. {
  72. fb_login.close();
  73. self.location = getUrl('library');
  74. }
  75. function redirectFacebook(link)
  76. {
  77. fb_login.close();
  78. open_f_login();
  79. }
  80. $(document).on('click', '.main-header-cover .header-language .dropdown-menu li a', function(){
  81. var lang = $(this).attr('val');
  82. $('#input-set-language').val(lang);
  83. $('#form-set-language').submit();
  84. });
  85. $(document).on('click', '.header-middle', function(){
  86. amimateUpDown($('.main-header-cover .header-menu'));
  87. amimateUpDown($('.main-header-cover .header-right'));
  88. });
  89. function amimateUpDown(element){
  90. if($(element).hasClass('menu-show')){
  91. $(element).slideUp('fast',function(){
  92. $(element).removeClass('menu-show');
  93. });
  94. }else{
  95. $(element).slideDown('fast',function(){
  96. $(element).addClass('menu-show');
  97. });
  98. }
  99. }