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. $('body').append(result);
  38. if(isSignUp == undefined){
  39. $('#modal-sign-in').modal();
  40. }else{
  41. $('#modal-sign-up').modal();
  42. }
  43. }
  44. });
  45. }
  46. });
  47. });
  48. function open_login_g(){
  49. var curUrl = $('#current-url').val();
  50. if(curUrl == undefined){
  51. curUrl = "";
  52. }
  53. fb_login=window.open(getUrl("login-google?l="+curUrl),'name','width='+screen.width+',height='+screen.height+',top=0,left=0'+',fullscreen=yes');
  54. };
  55. function open_login_f(){
  56. var curUrl = $('#current-url').val();
  57. if(curUrl == undefined){
  58. curUrl = "";
  59. }
  60. fb_login=window.open(getUrl("login-facebook?l="+curUrl),'name','width='+screen.width+',height='+screen.height+',top=0,left=0'+',fullscreen=yes');
  61. }
  62. function open_f_login(){
  63. var curUrl = $('#current-url').val();
  64. if(curUrl == undefined){
  65. curUrl = "";
  66. }
  67. fb_login=window.open(getUrl("facebook-login?l="+curUrl),'name','width='+screen.width+',height='+screen.height+',top=0,left=0'+',fullscreen=yes');
  68. }
  69. function redirect()
  70. {
  71. fb_login.close();
  72. self.location = getUrl('library');
  73. }
  74. function redirectFacebook(link)
  75. {
  76. fb_login.close();
  77. open_f_login();
  78. }
  79. $(document).on('click', '.main-header-cover .header-language .dropdown-menu li a', function(){
  80. var lang = $(this).attr('val');
  81. $('#input-set-language').val(lang);
  82. $('#form-set-language').submit();
  83. });
  84. $(document).on('click', '.header-middle', function(){
  85. amimateUpDown($('.main-header-cover .header-menu'));
  86. // amimateUpDown($('.main-header-cover .header-right'));
  87. });
  88. function amimateUpDown(element){
  89. if($(element).hasClass('menu-show')){
  90. $(element).slideUp('fast',function(){
  91. $(element).removeClass('menu-show');
  92. });
  93. }else{
  94. $(element).slideDown('fast',function(){
  95. $(element).addClass('menu-show');
  96. });
  97. }
  98. }