widgets_right_panel_widget.js.html 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>JSDoc: Source: widgets/right_panel_widget.js</title>
  6. <script src="scripts/prettify/prettify.js"> </script>
  7. <script src="scripts/prettify/lang-css.js"> </script>
  8. <!--[if lt IE 9]>
  9. <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
  10. <![endif]-->
  11. <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
  12. <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
  13. </head>
  14. <body>
  15. <div id="main">
  16. <h1 class="page-title">Source: widgets/right_panel_widget.js</h1>
  17. <section>
  18. <article>
  19. <pre class="prettyprint source linenums"><code>import NoteContextAwareWidget from "./note_context_aware_widget.js";
  20. const WIDGET_TPL = `
  21. &lt;div class="card widget">
  22. &lt;div class="card-header">
  23. &lt;div class="card-header-title">&lt;/div>
  24. &lt;div class="card-header-buttons">&lt;/div>
  25. &lt;/div>
  26. &lt;div id="[to be set]" class="body-wrapper">
  27. &lt;div class="card-body">&lt;/div>
  28. &lt;/div>
  29. &lt;/div>`;
  30. /**
  31. * This widget manages rendering panels in the right-hand pane.
  32. * @extends {NoteContextAwareWidget}
  33. */
  34. class RightPanelWidget extends NoteContextAwareWidget {
  35. /** Title to show in the panel. */
  36. get widgetTitle() { return "Untitled widget"; }
  37. get widgetButtons() { return []; }
  38. get help() { return {}; }
  39. constructor() {
  40. super();
  41. this.child(...this.widgetButtons);
  42. }
  43. /**
  44. * Do not override this method unless you know what you're doing.
  45. * Do not override this method unless you know what you're doing.
  46. */
  47. doRender() {
  48. this.$widget = $(WIDGET_TPL);
  49. this.contentSized();
  50. this.$widget.find('[data-target]').attr('data-target', `#${this.componentId}`);
  51. this.$bodyWrapper = this.$widget.find('.body-wrapper');
  52. this.$bodyWrapper.attr('id', this.componentId); // for toggle to work we need id
  53. this.$body = this.$bodyWrapper.find('.card-body');
  54. this.$title = this.$widget.find('.card-header .card-header-title');
  55. this.$title.text(this.widgetTitle);
  56. this.$buttons = this.$widget.find('.card-header .card-header-buttons');
  57. this.$buttons.empty();
  58. for (const buttonWidget of this.children) {
  59. this.$buttons.append(buttonWidget.render());
  60. }
  61. this.initialized = this.doRenderBody();
  62. }
  63. /**
  64. * Method used for rendering the body of the widget (via existing this.$body)
  65. *
  66. * Your class should override this method.
  67. * @returns {Promise|undefined} if widget needs async operation to initialize, it can return a Promise
  68. */
  69. async doRenderBody() {}
  70. }
  71. export default RightPanelWidget;
  72. </code></pre>
  73. </article>
  74. </section>
  75. </div>
  76. <nav>
  77. <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="BasicWidget.html">BasicWidget</a></li><li><a href="FAttachment.html">FAttachment</a></li><li><a href="FAttribute.html">FAttribute</a></li><li><a href="FBranch.html">FBranch</a></li><li><a href="FNote.html">FNote</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li><li><a href="NoteContextAwareWidget.html">NoteContextAwareWidget</a></li><li><a href="RightPanelWidget.html">RightPanelWidget</a></li></ul><h3>Global</h3><ul><li><a href="global.html#api">api</a></li><li><a href="global.html#getJsonContent">getJsonContent</a></li><li><a href="global.html#getJsonContentSafely">getJsonContentSafely</a></li></ul>
  78. </nav>
  79. <br class="clear">
  80. <footer>
  81. Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a>
  82. </footer>
  83. <script> prettyPrint(); </script>
  84. <script src="scripts/linenumber.js"> </script>
  85. </body>
  86. </html>