Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

127 linhas
3.3 KiB

há 3 anos
  1. $(function() {
  2. hljs.initHighlightingOnLoad();
  3. var EditormdView = editormd.markdownToHTML("page_md_content", {
  4. htmlDecode: "style,script,iframe", // you can filter tags decode
  5. emoji: true,
  6. taskList: true,
  7. tex: true, // 默认不解析
  8. flowChart: true, // 默认不解析
  9. sequenceDiagram: true, // 默认不解析
  10. });
  11. //为所有table标签添加bootstap支持的表格类
  12. $("table").addClass("table table-bordered table-hover");
  13. //当表格列数过长时将自动出现滚动条
  14. $.each($('table'), function() {
  15. $(this).prop('outerHTML', '<div style="width: 100%;overflow-x: auto;">' + $(this).prop('outerHTML') + '</div>');
  16. });
  17. //超链接都在新窗口打开
  18. $('a[href^="http"]').each(function() {
  19. $(this).attr('target', '_blank');
  20. });
  21. if (!isMobile()) {
  22. $("th").css("min-width", "77px");
  23. };
  24. //lightbox
  25. //增加返回顶部按钮
  26. $.goup({
  27. trigger: 100,
  28. bottomOffset: 150,
  29. locationOffset: 100,
  30. title: lang["back_to_top"],
  31. titleAsText: true,
  32. containerColor: "#08c",
  33. });
  34. if (isMobile() || $(window).width() < 1000) {
  35. AdaptToMobile();
  36. }
  37. $(window).resize(function() {
  38. if (isMobile()) {
  39. AdaptToMobile();
  40. } else if ($(window).width() < 1000) {
  41. AdaptToMobile();
  42. } else {
  43. window.location.reload();
  44. }
  45. });
  46. history.replaceState(null, null, $("#share-item-link").html());
  47. //分享项目
  48. $("#share").click(function() {
  49. $("#share-modal").modal();
  50. //延迟绑定分享事件
  51. setTimeout(function() {
  52. $('#copy-item-link').zclip({
  53. path: DocConfig.pubile + '/jquery.zclip/ZeroClipboard.swf',
  54. copy: function() {
  55. return $('#share-item-link').html();
  56. },
  57. afterCopy: function() {
  58. show_top_msg("已经成功复制到剪切板", 2000);
  59. }
  60. });
  61. }, 500);
  62. return false;
  63. });
  64. $("table thead tr").css({
  65. "background-color": "#08c",
  66. "color": "#fff"
  67. });
  68. $("table tr").each(function() {
  69. if ($(this).find("td").eq(1).html() == "object" || $(this).find("td").eq(1).html() == "array[object]") {
  70. $(this).css({
  71. "background-color": "#99CC99",
  72. "color": "#000"
  73. });
  74. }
  75. });
  76. function AdaptToMobile() {
  77. $(".doc-container").css("width", "90%");
  78. $("#doc-body").css("width", "90%");
  79. $("#header").css("height", "20px");
  80. $(".doc-title-box").css("margin", "20px 20px 0px 20px");
  81. $("#footer").css("font-size", "11pt");
  82. $(".tool-bar").hide();
  83. }
  84. //图片点击放大
  85. $("#page_md_content img").click(function() {
  86. var img_url = $(this).attr("src");
  87. //如果不在iframe里,则直接当前窗口打开
  88. if (self == top) {
  89. var json = {
  90. "title": "", //相册标题
  91. "id": 123, //相册id
  92. "start": 0, //初始显示的图片序号,默认0
  93. "data": [ //相册包含的图片,数组格式
  94. {
  95. "alt": "",
  96. "pid": 666, //图片id
  97. "src": img_url, //原图地址
  98. "thumb": img_url //缩略图地址
  99. }
  100. ]
  101. }
  102. $.photos({
  103. photos: json,
  104. anim: 5 //0-6的选择,指定弹出图片动画类型,默认随机(请注意,3.0之前的版本用shift参数)
  105. });
  106. } else {
  107. //如果在iframe里,则直接传url给父窗口
  108. top.postMessage(img_url, '*');
  109. }
  110. });
  111. });