global.js 2.9 KB

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