global.js 3.3 KB

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