show_single_page.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. }
  41. else if($(window).width() < 1000){
  42. AdaptToMobile();
  43. }else{
  44. window.location.reload();
  45. }
  46. });
  47. history.replaceState(null, null, $("#share-item-link").html());
  48. //分享项目
  49. $("#share").click(function(){
  50. $("#share-modal").modal();
  51. //延迟绑定分享事件
  52. setTimeout(function(){
  53. $('#copy-item-link').zclip(
  54. {
  55. path: DocConfig.pubile +'/jquery.zclip/ZeroClipboard.swf',
  56. copy:function()
  57. {
  58. return $('#share-item-link').html();
  59. },
  60. afterCopy: function() {
  61. show_top_msg("已经成功复制到剪切板",2000);
  62. }
  63. });
  64. },500);
  65. return false;
  66. });
  67. $("table thead tr").css({"background-color":"#08c","color":"#fff"});
  68. $("table tr").each(function(){
  69. if($(this).find("td").eq(1).html()=="object" || $(this).find("td").eq(1).html()=="array[object]")
  70. {
  71. $(this).css({"background-color":"#99CC99","color":"#000"});
  72. }
  73. });
  74. });
  75. function AdaptToMobile(){
  76. $(".doc-container").css("width","90%");
  77. $("#doc-body").css("width","90%");
  78. $("#header").css("height","20px");
  79. $(".doc-title-box").css("margin","20px 20px 0px 20px");
  80. $("#footer").css("font-size","11pt");
  81. $(".tool-bar").hide();
  82. }