Digital Office Automation System Backend
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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. // update pwd
  86. $('#updatePwd').on('click', function(){
  87. $('#updatePwdModal').modal({backdrop: false, keyboard: false}).modal('show');
  88. });
  89. var updatePwdModalValidate = $("#updatePwdModal .form").validate({
  90. errorElement : 'span',
  91. errorClass : 'help-block',
  92. focusInvalid : true,
  93. rules : {
  94. password : {
  95. required : true ,
  96. rangelength:[4,50]
  97. }
  98. },
  99. messages : {
  100. password : {
  101. required : '请输入密码' ,
  102. rangelength : "密码长度限制为4~50"
  103. }
  104. },
  105. highlight : function(element) {
  106. $(element).closest('.form-group').addClass('has-error');
  107. },
  108. success : function(label) {
  109. label.closest('.form-group').removeClass('has-error');
  110. label.remove();
  111. },
  112. errorPlacement : function(error, element) {
  113. element.parent('div').append(error);
  114. },
  115. submitHandler : function(form) {
  116. $.post(base_url + "/user/updatePwd", $("#updatePwdModal .form").serialize(), function(data, status) {
  117. if (data.code == 200) {
  118. $('#updatePwdModal').modal('hide');
  119. layer.msg( I18n.change_pwd_suc_to_logout );
  120. setTimeout(function(){
  121. $.post(base_url + "/logout", function(data, status) {
  122. if (data.code == 200) {
  123. window.location.href = base_url + "/";
  124. } else {
  125. layer.open({
  126. icon: '2',
  127. content: (data.msg|| I18n.logout_fail)
  128. });
  129. }
  130. });
  131. }, 500);
  132. } else {
  133. layer.open({
  134. icon: '2',
  135. content: (data.msg|| I18n.change_pwd + I18n.system_fail )
  136. });
  137. }
  138. });
  139. }
  140. });
  141. $("#updatePwdModal").on('hide.bs.modal', function () {
  142. $("#updatePwdModal .form")[0].reset();
  143. updatePwdModalValidate.resetForm();
  144. $("#updatePwdModal .form .form-group").removeClass("has-error");
  145. });
  146. });