extends.html 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <!DOCTYPE html>
  2. <html lang="zh">
  3. <head>
  4. <meta charset="utf-8" />
  5. <title>Expanded Editor.md - Editor.md examples</title>
  6. <link rel="stylesheet" href="css/style.css" />
  7. <link rel="stylesheet" href="../css/editormd.css" />
  8. <link rel="shortcut icon" href="https://pandao.github.io/editor.md/favicon.ico" type="image/x-icon" />
  9. </head>
  10. <body>
  11. <div id="layout">
  12. <header>
  13. <h1>Expanded Editor.md</h1>
  14. <p>Expanded of member methods and properties</p>
  15. </header>
  16. <div id="test-editormd">
  17. <textarea style="display:none;">### Expanded Editor.md
  18. ```javascript
  19. var testEditor;
  20. function EditormdExtend() {
  21. this.extend("methodC", function() {
  22. console.log("methodC");
  23. });
  24. // or
  25. testEditor.extend("methodA", function() {
  26. console.log("methodA");
  27. });
  28. // one by one setting
  29. this.set("propertyA", "propertyA");
  30. this.set("methodE", function() {
  31. console.log("mothodE", this);
  32. });
  33. // mutil
  34. this.extend({
  35. propertyA : "propertyAAAA", // override, you can override other default method.
  36. propertyB : "propertyB",
  37. methodD : function() {
  38. console.log("methodD");
  39. }
  40. });
  41. this.methodB = function() {
  42. console.log("methodB");
  43. };
  44. testEditor.methodA();
  45. testEditor.methodB();
  46. this.methodC();
  47. this.methodE();
  48. editormd.methodOne();
  49. console.log(this, this.propertyA);
  50. }
  51. editormd.fn.customMethod = function(){
  52. console.log("customMethod", this);
  53. };
  54. $(function() {
  55. editormd.methodOne = function(){
  56. console.log("editormd.methodOne");
  57. };
  58. testEditor = editormd("test-editormd", {
  59. width : "90%",
  60. height : 720,
  61. path : '../lib/',
  62. onload : function() {
  63. this.customMethod();
  64. $.proxy(EditormdExtend, this)();
  65. }
  66. });
  67. editormd.methodOne();
  68. });
  69. ```
  70. </textarea>
  71. </div>
  72. </div>
  73. <script src="js/jquery.min.js"></script>
  74. <script src="../editormd.js"></script>
  75. <script type="text/javascript">
  76. var testEditor;
  77. function EditormdExtend() {
  78. this.extend("methodC", function() {
  79. console.log("methodC");
  80. });
  81. // or
  82. testEditor.extend("methodA", function() {
  83. console.log("methodA");
  84. });
  85. // one by one setting
  86. this.set("propertyA", "propertyA");
  87. this.set("methodE", function() {
  88. console.log("mothodE", this);
  89. });
  90. // mutil
  91. this.extend({
  92. propertyA : "propertyAAAA", // override, you can override other default method.
  93. propertyB : "propertyB",
  94. methodD : function() {
  95. console.log("methodD");
  96. }
  97. });
  98. this.methodB = function() {
  99. console.log("methodB");
  100. };
  101. testEditor.methodA();
  102. testEditor.methodB();
  103. this.methodC();
  104. this.methodE();
  105. editormd.methodOne();
  106. console.log(this, this.propertyA);
  107. }
  108. editormd.fn.customMethod = function() {
  109. console.log("customMethod", this);
  110. };
  111. $(function() {
  112. editormd.methodOne = function() {
  113. console.log("editormd.methodOne");
  114. };
  115. testEditor = editormd("test-editormd", {
  116. width : "90%",
  117. height : 720,
  118. path : '../lib/',
  119. onload : function() {
  120. this.customMethod();
  121. $.proxy(EditormdExtend, this)();
  122. }
  123. });
  124. editormd.methodOne();
  125. });
  126. </script>
  127. </body>
  128. </html>