presentation.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /**
  2. * An object for managing the blob of text at the top of a problem describing it.
  3. * This isn't a very busy component.
  4. *
  5. * TODO: Isn't most of this redundant now?
  6. *
  7. * @constructor
  8. * @this {BlockPyEditor}
  9. * @param {Object} main - The main BlockPy instance
  10. * @param {HTMLElement} tag - The HTML object this is attached to.
  11. */
  12. function BlockPyPresentation(main, tag) {
  13. this.main = main;
  14. this.tag = tag;
  15. var presentationEditor = this;
  16. //this.main.model.settings.instructor.subscribe(function() {presentationEditor.setVisible()});
  17. }
  18. /**
  19. * Removes the editor when it's not in use.
  20. * DEPRECATED
  21. */
  22. BlockPyPresentation.prototype.closeEditor = function() {
  23. this.tag.destroy();
  24. };
  25. /**
  26. * Updates the contents of the presentation blob, possibly updating the
  27. * editor's size too.
  28. *
  29. * @param {String} content - The new text of the presentation blob.
  30. */
  31. BlockPyPresentation.prototype.setBody = function(content) {
  32. this.main.model.assignment.introduction(content);
  33. this.main.components.editor.blockly.resize();
  34. };
  35. /**
  36. * Makes the editor available or not.
  37. * DEPRECATED.
  38. */
  39. BlockPyPresentation.prototype.setVisible = function() {
  40. if (this.main.model.settings.instructor()) {
  41. this.startEditor();
  42. } else {
  43. this.closeEditor();
  44. }
  45. }
  46. /**
  47. * Creates the Summer Note editor for the presentation blob.
  48. * DEPRECATED.
  49. */
  50. BlockPyPresentation.prototype.startEditor = function() {
  51. var presentationEditor = this;
  52. this.tag.summernote({
  53. codemirror: { // codemirror options
  54. theme: 'monokai'
  55. },
  56. onChange: function(content) {presentationEditor.setBody(content)},
  57. toolbar: [
  58. ['style', ['bold', 'italic', 'underline', 'clear']],
  59. ['font', ['fontname', 'fontsize']],
  60. ['insert', ['link', 'table', 'ul', 'ol']],
  61. ['misc', ['codeview', 'help']]
  62. ]
  63. });
  64. this.tag.code(this.main.model.assignment.introduction());
  65. //this.name.tag();
  66. };