From 2546622da3cc61c994322727323212468a43b50e Mon Sep 17 00:00:00 2001 From: JC Brand Date: Thu, 25 Jul 2019 06:46:05 +0200 Subject: [PATCH] Trigger events when resizing starts --- src/converse-dragresize.js | 31 +++++++++++++++++++++++++++---- src/converse-minimize.js | 2 +- src/headless/converse-core.js | 4 +++- 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/src/converse-dragresize.js b/src/converse-dragresize.js index 5d9d5f20f..3e01bbe17 100644 --- a/src/converse-dragresize.js +++ b/src/converse-dragresize.js @@ -251,7 +251,7 @@ converse.plugins.add('converse-dragresize', { } }, - onStartVerticalResize (ev) { + onStartVerticalResize (ev, trigger=true) { if (!_converse.allow_dragresize) { return true; } // Record element attributes for mouseMove(). const flyout = this.el.querySelector('.box-flyout'), @@ -262,9 +262,17 @@ converse.plugins.add('converse-dragresize', { 'direction': 'top' }; this.prev_pageY = ev.pageY; + if (trigger) { + /** + * Triggered once the user starts to vertically resize a {@link _converse.ChatBoxView} + * @event _converse#startVerticalResize + * @example _converse.api.listen.on('startVerticalResize', (view) => { ... }); + */ + _converse.api.trigger('startVerticalResize', this); + } }, - onStartHorizontalResize (ev) { + onStartHorizontalResize (ev, trigger=true) { if (!_converse.allow_dragresize) { return true; } const flyout = this.el.querySelector('.box-flyout'), style = window.getComputedStyle(flyout); @@ -274,12 +282,27 @@ converse.plugins.add('converse-dragresize', { 'direction': 'left' }; this.prev_pageX = ev.pageX; + if (trigger) { + /** + * Triggered once the user starts to horizontally resize a {@link _converse.ChatBoxView} + * @event _converse#startHorizontalResize + * @example _converse.api.listen.on('startHorizontalResize', (view) => { ... }); + */ + _converse.api.trigger('startHorizontalResize', this); + } + }, onStartDiagonalResize (ev) { - this.onStartHorizontalResize(ev); - this.onStartVerticalResize(ev); + this.onStartHorizontalResize(ev, false); + this.onStartVerticalResize(ev, false); _converse.resizing.direction = 'topleft'; + /** + * Triggered once the user starts to diagonally resize a {@link _converse.ChatBoxView} + * @event _converse#startDiagonalResize + * @example _converse.api.listen.on('startDiagonalResize', (view) => { ... }); + */ + _converse.api.trigger('startDiagonalResize', this); }, }; Object.assign(_converse.ChatBoxView.prototype, dragResizable); diff --git a/src/converse-minimize.js b/src/converse-minimize.js index cf9b64253..1c957b6c0 100644 --- a/src/converse-minimize.js +++ b/src/converse-minimize.js @@ -315,7 +315,7 @@ converse.plugins.add('converse-minimize', { * to create space. * @private * @method _converse.ChatBoxViews#trimChats - * @param { [ChatBoxView|ChatRoomView|ControlBoxView|HeadlinesBoxView] } newchat + * @param { _converse.ChatBoxView|_converse.ChatRoomView|_converse.ControlBoxView|_converse.HeadlinesBoxView } [newchat] */ async trimChats (newchat) { if (_converse.no_trimming || !_converse.connection.connected || _converse.view_mode !== 'overlayed') { diff --git a/src/headless/converse-core.js b/src/headless/converse-core.js index 78874e0a0..8c38c4136 100644 --- a/src/headless/converse-core.js +++ b/src/headless/converse-core.js @@ -94,9 +94,11 @@ const CORE_PLUGINS = [ /** * A private, closured object containing the private api (via {@link _converse.api}) * as well as private methods and internal data-structures. - * + * @global * @namespace _converse */ +// XXX: Strictly speaking _converse is not a global, but we need to set it as +// such to get JSDoc to create the correct document site strucure. const _converse = { 'templates': {}, 'promises': {}