common.1.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. $(function () {
  2. // logout
  3. $("#logoutBtn").click(function () {
  4. layer.confirm(I18n.logout_confirm, {
  5. icon: 3,
  6. title: I18n.system_tips,
  7. btn: [I18n.system_ok, I18n.system_cancel]
  8. }, function (index) {
  9. layer.close(index);
  10. $.post(base_url + "/logout", function (data, status) {
  11. if (data.code == "200") {
  12. layer.msg(I18n.logout_success);
  13. setTimeout(function () {
  14. window.location.href = base_url + "/";
  15. }, 500);
  16. } else {
  17. layer.open({
  18. title: I18n.system_tips,
  19. btn: [I18n.system_ok],
  20. content: (data.msg || I18n.logout_fail),
  21. icon: '2'
  22. });
  23. }
  24. });
  25. });
  26. });
  27. // slideToTop
  28. var slideToTop = $("<div />");
  29. slideToTop.html('<i class="fa fa-chevron-up"></i>');
  30. slideToTop.css({
  31. position: 'fixed',
  32. bottom: '20px',
  33. right: '25px',
  34. width: '40px',
  35. height: '40px',
  36. color: '#eee',
  37. 'font-size': '',
  38. 'line-height': '40px',
  39. 'text-align': 'center',
  40. 'background-color': '#222d32',
  41. cursor: 'pointer',
  42. 'border-radius': '5px',
  43. 'z-index': '99999',
  44. opacity: '.7',
  45. 'display': 'none'
  46. });
  47. slideToTop.on('mouseenter', function () {
  48. $(this).css('opacity', '1');
  49. });
  50. slideToTop.on('mouseout', function () {
  51. $(this).css('opacity', '.7');
  52. });
  53. $('.wrapper').append(slideToTop);
  54. $(window).scroll(function () {
  55. if ($(window).scrollTop() >= 150) {
  56. if (!$(slideToTop).is(':visible')) {
  57. $(slideToTop).fadeIn(500);
  58. }
  59. } else {
  60. $(slideToTop).fadeOut(500);
  61. }
  62. });
  63. $(slideToTop).click(function () {
  64. $("html,body").animate({ // firefox ie not support body, chrome support body. but found that new version chrome not support body too.
  65. scrollTop: 0
  66. }, 100);
  67. });
  68. // left menu status v: js + server + cookie
  69. $('.sidebar-toggle').click(function () {
  70. var xxljob_adminlte_settings = $.cookie('xxljob_adminlte_settings'); // on=open,off=close
  71. if ('off' == xxljob_adminlte_settings) {
  72. xxljob_adminlte_settings = 'on';
  73. } else {
  74. xxljob_adminlte_settings = 'off';
  75. }
  76. $.cookie('xxljob_adminlte_settings', xxljob_adminlte_settings, {expires: 7}); //$.cookie('the_cookie', '', { expires: -1 });
  77. });
  78. // left menu status v1: js + cookie
  79. /*
  80. var xxljob_adminlte_settings = $.cookie('xxljob_adminlte_settings');
  81. if (xxljob_adminlte_settings == 'off') {
  82. $('body').addClass('sidebar-collapse');
  83. }
  84. */
  85. });