|
@@ -2052,6 +2052,9 @@ converse.plugins.add('converse-muc-views', {
|
|
|
listItems: 'model',
|
|
|
sortEvent: 'change:role',
|
|
|
listSelector: '.occupant-list',
|
|
|
+ events: {
|
|
|
+ 'mousedown .dragresize-occupants-left': 'onStartHorizontalResizeOccupants',
|
|
|
+ },
|
|
|
|
|
|
ItemView: _converse.ChatRoomOccupantView,
|
|
|
|
|
@@ -2081,6 +2084,12 @@ converse.plugins.add('converse-muc-views', {
|
|
|
_converse.api.waitUntil('rosterContactsFetched').then(() => this.renderInviteWidget());
|
|
|
}
|
|
|
this.setVisibility();
|
|
|
+
|
|
|
+ this.renderDragResizeHandles();
|
|
|
+
|
|
|
+ this.is_maximum = false;
|
|
|
+ this.is_minimum = false;
|
|
|
+
|
|
|
return this.renderRoomFeatures();
|
|
|
},
|
|
|
|
|
@@ -2207,7 +2216,78 @@ converse.plugins.add('converse-muc-views', {
|
|
|
this.invite_auto_complete.on('suggestion-box-open', () => {
|
|
|
this.invite_auto_complete.ul.setAttribute('style', `max-height: calc(${this.el.offsetHeight}px - 80px);`);
|
|
|
});
|
|
|
- }
|
|
|
+ },
|
|
|
+
|
|
|
+ renderDragResizeHandles () {
|
|
|
+ const flyout = this.el;
|
|
|
+ const div = document.createElement('div');
|
|
|
+ div.innerHTML = '<div class="dragresize dragresize-occupants-left"></div>';
|
|
|
+ flyout.insertBefore(
|
|
|
+ div,
|
|
|
+ flyout.firstChild
|
|
|
+ );
|
|
|
+ },
|
|
|
+
|
|
|
+ onStartHorizontalResizeOccupants (ev) {
|
|
|
+ const flyout = this.el,
|
|
|
+ style = window.getComputedStyle(flyout);
|
|
|
+ this.width = parseInt(style.width.replace(/px$/, ''), 10);
|
|
|
+ _converse.resizing = {
|
|
|
+ 'chatbox': this,
|
|
|
+ 'direction': 'left'
|
|
|
+ };
|
|
|
+ this.prev_pageX = ev.pageX;
|
|
|
+ },
|
|
|
+
|
|
|
+ resize (ev) {
|
|
|
+ if (_.includes(_converse.resizing.direction, 'left')) {
|
|
|
+ this.change_in_pixel = (this.prev_pageX - ev.pageX);
|
|
|
+ this.resizeOccupantsView(this.change_in_pixel, ev.pageX);
|
|
|
+ this.prev_pageX = ev.pageX;
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ resizeOccupantsView (change_in_pixel, current_mouse_position) {
|
|
|
+ const element_position = this.el.getBoundingClientRect();
|
|
|
+
|
|
|
+ // has mouse reached the minimum to the right
|
|
|
+ if (this.is_minimum) {
|
|
|
+ this.is_minimum = element_position.left < current_mouse_position;
|
|
|
+ } // has mouse reached the maximum to the left
|
|
|
+ else if (this.is_maximum) {
|
|
|
+ this.is_maximum = element_position.left > current_mouse_position;
|
|
|
+ } // Scale is within the boundaries
|
|
|
+ else {
|
|
|
+ const occupants_width_pixel = this.calculateOccupantsWithInPixel(element_position, change_in_pixel);
|
|
|
+ this.el.style.flex = "0 0 " + occupants_width_pixel + "px";
|
|
|
+ _converse.resizing.width_occupants = occupants_width_pixel;
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ calculateOccupantsWithInPixel (element_position, change_in_pixel) {
|
|
|
+ let occupants_width_pixel = element_position.width + change_in_pixel;
|
|
|
+ const chatroom_width_pixel = this.el.parentElement.clientWidth;
|
|
|
+
|
|
|
+ // keeping display in boundaries
|
|
|
+ if (occupants_width_pixel < (chatroom_width_pixel * 0.20)) {
|
|
|
+ // set pixel to 20% width
|
|
|
+ occupants_width_pixel = (chatroom_width_pixel * 0.20);
|
|
|
+ this.is_minimum = true;
|
|
|
+ } else if (occupants_width_pixel > (chatroom_width_pixel * 0.75)) {
|
|
|
+ // set pixel to 75% width
|
|
|
+ occupants_width_pixel = (chatroom_width_pixel * 0.75);
|
|
|
+ this.is_maximum = true;
|
|
|
+ } else if ((chatroom_width_pixel - occupants_width_pixel) < 250) {
|
|
|
+ // resize occupants if chat-area becomes smaller than 250px (min-width property set in css)
|
|
|
+ occupants_width_pixel = chatroom_width_pixel - 250;
|
|
|
+ this.is_maximum = true;
|
|
|
+ } else {
|
|
|
+ this.is_maximum = false;
|
|
|
+ this.is_minimum = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ return occupants_width_pixel;
|
|
|
+ },
|
|
|
});
|
|
|
|
|
|
|
|
@@ -2289,6 +2369,15 @@ converse.plugins.add('converse-muc-views', {
|
|
|
fetchAndSetMUCDomain(view);
|
|
|
view.model.on('change:connected', () => fetchAndSetMUCDomain(view));
|
|
|
});
|
|
|
+
|
|
|
+
|
|
|
+ _converse.api.listen.on('beforeShowingChatView', (chatroomview) => {
|
|
|
+ const occupants_width_pixel = chatroomview.model.get('width_occupants');
|
|
|
+ const occupants_view = chatroomview.el.querySelector('.occupants');
|
|
|
+ if (occupants_view && occupants_width_pixel !== undefined) {
|
|
|
+ occupants_view.style.flex = "0 0 " + occupants_width_pixel + "px";
|
|
|
+ }
|
|
|
+ });
|
|
|
/************************ END Event Handlers ************************/
|
|
|
|
|
|
|