Browse Source

Added `modal:open` and `modal:close` events in the Modal module. Closes #1717

pull/1730/head
Artur Arseniev 8 years ago
parent
commit
414a0aee39
  1. 3
      src/editor/index.js
  2. 22
      src/modal_dialog/index.js

3
src/editor/index.js

@ -76,6 +76,9 @@
* ### RTE
* * `rte:enable` - RTE enabled. The view, on which RTE is enabled, is passed as an argument
* * `rte:disable` - RTE disabled. The view, on which RTE is disabled, is passed as an argument
* ### Modal
* * `modal:open` - Modal is opened
* * `modal:close` - Modal is closed
* ### Commands
* * `run:{commandName}` - Triggered when some command is called to run (eg. editor.runCommand('preview'))
* * `stop:{commandName}` - Triggered when some command is called to stop (eg. editor.stopCommand('preview'))

22
src/modal_dialog/index.js

@ -40,17 +40,22 @@ module.exports = () => {
*/
name: 'Modal',
getConfig() {
return c;
},
/**
* Initialize module. Automatically called with a new instance of the editor
* @param {Object} config Configurations
* @private
*/
init(config) {
c = config || {};
for (var name in defaults) {
if (!(name in c)) c[name] = defaults[name];
}
init(config = {}) {
c = {
...defaults,
...config
};
this.em = c.em;
var ppfx = c.pStylePrefix;
if (ppfx) c.stylePrefix = ppfx + c.stylePrefix;
@ -68,6 +73,11 @@ module.exports = () => {
this.render().appendTo(el);
},
triggerEvent(event) {
const { em } = this;
em && em.trigger(`modal:${event}`);
},
/**
* Open the modal window
* @param {Object} [opts={}] Options
@ -79,6 +89,7 @@ module.exports = () => {
opts.title && this.setTitle(opts.title);
opts.content && this.setContent(opts.content);
modal.show();
this.triggerEvent('open');
return this;
},
@ -88,6 +99,7 @@ module.exports = () => {
*/
close() {
modal.hide();
this.triggerEvent('close');
return this;
},

Loading…
Cancel
Save