You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

102 lines
2.6 KiB

3 years ago
  1. /*!
  2. * Help dialog plugin for Editor.md
  3. *
  4. * @file help-dialog.js
  5. * @author pandao
  6. * @version 1.2.0
  7. * @updateTime 2015-03-08
  8. * {@link https://github.com/pandao/editor.md}
  9. * @license MIT
  10. */
  11. (function() {
  12. var factory = function (exports) {
  13. var $ = jQuery;
  14. var pluginName = "help-dialog";
  15. exports.fn.helpDialog = function() {
  16. var _this = this;
  17. var lang = this.lang;
  18. var editor = this.editor;
  19. var settings = this.settings;
  20. var path = settings.pluginPath + pluginName + "/";
  21. var classPrefix = this.classPrefix;
  22. var dialogName = classPrefix + pluginName, dialog;
  23. var dialogLang = lang.dialog.help;
  24. if (editor.find("." + dialogName).length < 1)
  25. {
  26. var dialogContent = "<div class=\"markdown-body\" style=\"font-family:微软雅黑, Helvetica, Tahoma, STXihei,Arial;height:390px;overflow:auto;font-size:14px;border-bottom:1px solid #ddd;padding:0 20px 20px 0;\"></div>";
  27. dialog = this.createDialog({
  28. name : dialogName,
  29. title : dialogLang.title,
  30. width : 840,
  31. height : 540,
  32. mask : settings.dialogShowMask,
  33. drag : settings.dialogDraggable,
  34. content : dialogContent,
  35. lockScreen : settings.dialogLockScreen,
  36. maskStyle : {
  37. opacity : settings.dialogMaskOpacity,
  38. backgroundColor : settings.dialogMaskBgColor
  39. },
  40. buttons : {
  41. close : [lang.buttons.close, function() {
  42. this.hide().lockScreen(false).hideMask();
  43. return false;
  44. }]
  45. }
  46. });
  47. }
  48. dialog = editor.find("." + dialogName);
  49. this.dialogShowMask(dialog);
  50. this.dialogLockScreen();
  51. dialog.show();
  52. var helpContent = dialog.find(".markdown-body");
  53. if (helpContent.html() === "")
  54. {
  55. $.get(path + "help.md", function(text) {
  56. var md = exports.$marked(text);
  57. helpContent.html(md);
  58. helpContent.find("a").attr("target", "_blank");
  59. });
  60. }
  61. };
  62. };
  63. // CommonJS/Node.js
  64. if (typeof require === "function" && typeof exports === "object" && typeof module === "object")
  65. {
  66. module.exports = factory;
  67. }
  68. else if (typeof define === "function") // AMD/CMD/Sea.js
  69. {
  70. if (define.amd) { // for Require.js
  71. define(["editormd"], function(editormd) {
  72. factory(editormd);
  73. });
  74. } else { // for Sea.js
  75. define(function(require) {
  76. var editormd = require("./../../editormd");
  77. factory(editormd);
  78. });
  79. }
  80. }
  81. else
  82. {
  83. factory(window.editormd);
  84. }
  85. })();