global.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*全局自适应高度*/
  2. function autoFlashHeight(){
  3. var headerHeight = $(".header").height();
  4. var bottomContentHeight = $(".bottom-content").height();
  5. var toolsBar = $(".tools-bar").height();
  6. $(".content").height($(window).height()-headerHeight);
  7. $(".main-side").height($(window).height()-headerHeight-2);
  8. $(".fluid-content").height($(window).height()-headerHeight-1);
  9. $(".side-content").height($(window).height()-headerHeight );
  10. $(".poj-list").height($(window).height()-headerHeight);
  11. $(".form-list").height($(window).height()-headerHeight-50 );
  12. $(".main-data-top").height($(window).height()-headerHeight-toolsBar-bottomContentHeight-2);
  13. $(".main-data").height($(window).height()-headerHeight);
  14. $(".main-side .tab-content").height($(window).height()-headerHeight-38);
  15. };
  16. $(window).resize(autoFlashHeight);
  17. /*全局自适应高度结束*/
  18. $(function(){
  19. /*侧滑*/
  20. $(".open-sidebar").click(function(){
  21. $(".slide-sidebar").animate({width:"800"}).addClass("open");
  22. });
  23. $("body").click(function(event){
  24. var e = event || window.event; //浏览器兼容性
  25. if(!$(event.target).is('a')) {
  26. var elem = event.target || e.srcElement;
  27. while (elem) { //循环判断至跟节点,防止点击的是div子元素
  28. if (elem.className == "open-sidebar" || elem.className == 'slide-sidebar open') {
  29. return false;
  30. }
  31. elem = elem.parentNode;
  32. }
  33. $(".slide-sidebar").animate({width:"0"}).removeClass("open")// 关闭处理
  34. }
  35. });
  36. /*侧滑*/
  37. /*工具提示*/
  38. $('*[data-toggle=tooltip]').mouseover(function() {
  39. $(this).tooltip('show');
  40. });
  41. /*工具提示*/
  42. });
  43. /**
  44. * 设置本地缓存
  45. *
  46. * @param {String} key
  47. * @param {String|Number} value
  48. * @return {void}
  49. */
  50. function setLocalCache(key, value) {
  51. const storage = window.localStorage;
  52. if (!storage || key === '' || value === '') {
  53. return;
  54. }
  55. storage.setItem(key, value);
  56. }
  57. /**
  58. * 获取本地缓存
  59. *
  60. * @param {String} key
  61. * @return {String}
  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. }