global.js 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*全局自适应高度*/
  2. function autoFlashHeight(){
  3. var headerHeight = $(".header").height();
  4. var topContentHeight = $('#rationSearchResult').is(':visible') ? 0 : $('.top-content').height();
  5. var toolsBar = $(".toolsbar").height();
  6. var toolsBarHeightQ = $(".tools-bar-height-q").height();
  7. $(".content").height($(window).height()-headerHeight);
  8. $(".main-side-top").height(($(window).height()-headerHeight) * 0.85);
  9. $(".main-side-bottom").height(($(window).height()-headerHeight) * 0.15);
  10. $('.main-side-bottom').find('textarea').height($('.main-side-bottom').height() - 20);
  11. $('.main-side-bottom').find('textarea').width($('.main-side-bottom').width() - 25);
  12. $(".fluid-content").height($(window).height()-headerHeight-1);
  13. $(".side-content").height($(window).height()-headerHeight);
  14. $(".poj-list").height($(window).height()-headerHeight);
  15. $(".form-list").height($(window).height()-headerHeight-50);
  16. $('.main-top-content').height(($(window).height()-headerHeight-toolsBar)*0.85);
  17. $('.main-bottom-content').height(($(window).height()-headerHeight-toolsBar)*0.15);
  18. $('.main-bottom-content').find('textarea').height($('.main-bottom-content').height() - 20);
  19. $('.main-bottom-content').find('textarea').width($('.main-bottom-content').width() - 25);
  20. $(".main-data").height($('.main-top-content').height());
  21. $(".main-data-full").height($(window).height()-headerHeight);
  22. $(".main-data-bottom").height($(window).height()-headerHeight-toolsBarHeightQ-topContentHeight-$('#rationSearchResult').height() + 30);
  23. $('.bottom-content').height($('.main-data-bottom').height());
  24. if (typeof billsGuidance !== 'undefined') {
  25. billsGuidance.initSlideSize();
  26. }
  27. };
  28. $(window).resize(autoFlashHeight);
  29. /*全局自适应高度结束*/
  30. $(function(){
  31. /*侧滑*/
  32. $(".open-sidebar").click(function(){
  33. $(".slide-sidebar").animate({width:"800"}).addClass("open");
  34. });
  35. $("body").click(function(event){
  36. var e = event || window.event; //浏览器兼容性
  37. if(!$(event.target).is('a')) {
  38. var elem = event.target || e.srcElement;
  39. while (elem) { //循环判断至跟节点,防止点击的是div子元素
  40. if (elem.className == "open-sidebar" || elem.className == 'slide-sidebar open') {
  41. return false;
  42. }
  43. elem = elem.parentNode;
  44. }
  45. $(".slide-sidebar").animate({width:"0"}).removeClass("open")// 关闭处理
  46. }
  47. });
  48. /*侧滑*/
  49. /*工具提示*/
  50. $('*[data-toggle=tooltip]').mouseover(function() {
  51. $(this).tooltip('show');
  52. });
  53. /*工具提示*/
  54. });
  55. function setLocalCache(key, value) {
  56. const storage = window.localStorage;
  57. if (!storage || key === '' || value === '') {
  58. return;
  59. }
  60. storage.setItem(key, value);
  61. }
  62. function getLocalCache(key) {
  63. const storage = window.localStorage;
  64. if (!storage || key === '') {
  65. return null;
  66. }
  67. return storage.getItem(key);
  68. }
  69. function removeLocalCache(key) {
  70. const storage = window.localStorage;
  71. if (!storage || key === '') {
  72. return null;
  73. }
  74. return storage.removeItem(key);
  75. }
  76. function replaceAll(FindText, RepText,str) {
  77. let regExp = new RegExp(FindText, "g");
  78. return str.replace(regExp, RepText);
  79. };