global.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. };
  25. $(window).resize(autoFlashHeight);
  26. /*全局自适应高度结束*/
  27. $(function(){
  28. /*侧滑*/
  29. $(".open-sidebar").click(function(){
  30. $(".slide-sidebar").animate({width:"800"}).addClass("open");
  31. });
  32. $("body").click(function(event){
  33. var e = event || window.event; //浏览器兼容性
  34. if(!$(event.target).is('a')) {
  35. var elem = event.target || e.srcElement;
  36. while (elem) { //循环判断至跟节点,防止点击的是div子元素
  37. if (elem.className == "open-sidebar" || elem.className == 'slide-sidebar open') {
  38. return false;
  39. }
  40. elem = elem.parentNode;
  41. }
  42. $(".slide-sidebar").animate({width:"0"}).removeClass("open")// 关闭处理
  43. }
  44. });
  45. /*侧滑*/
  46. /*工具提示*/
  47. $('*[data-toggle=tooltip]').mouseover(function() {
  48. $(this).tooltip('show');
  49. });
  50. /*工具提示*/
  51. });
  52. function setLocalCache(key, value) {
  53. const storage = window.localStorage;
  54. if (!storage || key === '' || value === '') {
  55. return;
  56. }
  57. storage.setItem(key, value);
  58. }
  59. function getLocalCache(key) {
  60. const storage = window.localStorage;
  61. if (!storage || key === '') {
  62. return null;
  63. }
  64. return storage.getItem(key);
  65. }
  66. function removeLocalCache(key) {
  67. const storage = window.localStorage;
  68. if (!storage || key === '') {
  69. return null;
  70. }
  71. return storage.removeItem(key);
  72. }
  73. function replaceAll(FindText, RepText,str) {
  74. let regExp = new RegExp(FindText, "g");
  75. return str.replace(regExp, RepText);
  76. };