Built files from Bizgaze WebServer
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

summernote-ext-hello.js 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. (function(factory) {
  2. /* global define */
  3. if (typeof define === 'function' && define.amd) {
  4. // AMD. Register as an anonymous module.
  5. define(['jquery'], factory);
  6. } else if (typeof module === 'object' && module.exports) {
  7. // Node/CommonJS
  8. module.exports = factory(require('jquery'));
  9. } else {
  10. // Browser globals
  11. factory(window.jQuery);
  12. }
  13. }(function($) {
  14. // Extends plugins for adding hello.
  15. // - plugin is external module for customizing.
  16. $.extend($.summernote.plugins, {
  17. /**
  18. * @param {Object} context - context object has status of editor.
  19. */
  20. 'hello': function(context) {
  21. var self = this;
  22. // ui has renders to build ui elements.
  23. // - you can create a button with `ui.button`
  24. var ui = $.summernote.ui;
  25. // add hello button
  26. context.memo('button.hello', function() {
  27. // create button
  28. var button = ui.button({
  29. contents: '<i class="fa fa-child"/> Hello',
  30. tooltip: 'hello',
  31. click: function() {
  32. self.$panel.show();
  33. self.$panel.hide(500);
  34. // invoke insertText method with 'hello' on editor module.
  35. context.invoke('editor.insertText', 'hello');
  36. },
  37. });
  38. // create jQuery object from button instance.
  39. var $hello = button.render();
  40. return $hello;
  41. });
  42. // This events will be attached when editor is initialized.
  43. this.events = {
  44. // This will be called after modules are initialized.
  45. 'summernote.init': function(we, e) {
  46. console.log('summernote initialized', we, e);
  47. },
  48. // This will be called when user releases a key on editable.
  49. 'summernote.keyup': function(we, e) {
  50. console.log('summernote keyup', we, e);
  51. },
  52. };
  53. // This method will be called when editor is initialized by $('..').summernote();
  54. // You can create elements for plugin
  55. this.initialize = function() {
  56. this.$panel = $('<div class="hello-panel"/>').css({
  57. position: 'absolute',
  58. width: 100,
  59. height: 100,
  60. left: '50%',
  61. top: '50%',
  62. background: 'red',
  63. }).hide();
  64. this.$panel.appendTo('body');
  65. };
  66. // This methods will be called when editor is destroyed by $('..').summernote('destroy');
  67. // You should remove elements on `initialize`.
  68. this.destroy = function() {
  69. this.$panel.remove();
  70. this.$panel = null;
  71. };
  72. },
  73. });
  74. }));