Commit 392a7e8a authored by JC Brand's avatar JC Brand

Don't use the bootstrap responsive grid for chats in overlay mode

parent 849d6b26
...@@ -4451,17 +4451,17 @@ body.reset { ...@@ -4451,17 +4451,17 @@ body.reset {
#conversejs { #conversejs {
padding-left: env(safe-area-inset-left); padding-left: env(safe-area-inset-left);
padding-right: env(safe-area-inset-right); padding-right: env(safe-area-inset-right);
bottom: 0;
height: auto;
width: 100vw;
color: #777; color: #777;
direction: ltr;
display: block;
font-family: "Helvetica", "Arial", sans-serif; font-family: "Helvetica", "Arial", sans-serif;
font-size: 14px; font-size: 14px;
direction: ltr;
display: block;
z-index: 1031; }
#conversejs .converse-chatboxes {
position: fixed; position: fixed;
z-index: 1031; bottom: 0;
margin-left: -15px; } height: auto;
width: 100vw; }
#conversejs ::-webkit-input-placeholder { #conversejs ::-webkit-input-placeholder {
/* Chrome/Opera/Safari */ /* Chrome/Opera/Safari */
color: #A8ABA1; } color: #A8ABA1; }
...@@ -4875,7 +4875,7 @@ body.reset { ...@@ -4875,7 +4875,7 @@ body.reset {
border-radius: 25%; border-radius: 25%;
border: none; border: none;
cursor: pointer; cursor: pointer;
font-size: 12px; font-size: 16px;
margin: 0 0.2em; margin: 0 0.2em;
padding: 0.3em; padding: 0.3em;
text-decoration: none; } text-decoration: none; }
...@@ -5358,28 +5358,12 @@ body.reset { ...@@ -5358,28 +5358,12 @@ body.reset {
border-top-right-radius: 0; } } border-top-right-radius: 0; } }
#converse-embedded-chat .chatbox, #converse-embedded-chat .chatbox,
#conversejs:not(.fullscreen) .chatbox { #conversejs:not(.fullscreen) .chatbox {
position: relative; min-width: 250px !important;
width: 100%; width: 250px; }
min-height: 1px; #converse-embedded-chat .chatbox .box-flyout,
padding-right: 15px; #conversejs:not(.fullscreen) .chatbox .box-flyout {
padding-left: 15px; min-width: 250px !important;
flex: 0 0 100%; width: 250px; }
max-width: 100%; }
@media (min-width: 576px) {
#converse-embedded-chat .chatbox,
#conversejs:not(.fullscreen) .chatbox {
flex: 0 0 33.3333333333%;
max-width: 33.3333333333%; } }
@media (min-width: 768px) {
#converse-embedded-chat .chatbox,
#conversejs:not(.fullscreen) .chatbox {
flex: 0 0 25%;
max-width: 25%; } }
@media (min-width: 992px) {
#converse-embedded-chat .chatbox,
#conversejs:not(.fullscreen) .chatbox {
flex: 0 0 16.6666666667%;
max-width: 16.6666666667%; } }
#converse-embedded-chat .chatbox .chat-body .chat-message, #converse-embedded-chat .chatbox .chat-body .chat-message,
#conversejs:not(.fullscreen) .chatbox .chat-body .chat-message { #conversejs:not(.fullscreen) .chatbox .chat-body .chat-message {
padding: 0.3em; padding: 0.3em;
...@@ -5737,29 +5721,11 @@ body.reset { ...@@ -5737,29 +5721,11 @@ body.reset {
display: block; } } display: block; } }
#conversejs:not(.fullscreen) #controlbox { #conversejs:not(.fullscreen) #controlbox {
order: -1; order: -1;
position: relative; min-width: 250px !important;
width: 100%; width: 250px; }
min-height: 1px; #conversejs:not(.fullscreen) #controlbox .box-flyout {
padding-right: 15px; min-width: 250px !important;
padding-left: 15px; width: 250px; }
flex: 0 0 100%;
max-width: 100%; }
@media (min-width: 576px) {
#conversejs:not(.fullscreen) #controlbox {
flex: 0 0 33.3333333333%;
max-width: 33.3333333333%; } }
@media (min-width: 768px) {
#conversejs:not(.fullscreen) #controlbox {
flex: 0 0 25%;
max-width: 25%; } }
@media (min-width: 992px) {
#conversejs:not(.fullscreen) #controlbox {
flex: 0 0 16.6666666667%;
max-width: 16.6666666667%; } }
@media (min-width: 1200px) {
#conversejs:not(.fullscreen) #controlbox {
flex: 0 0 16.6666666667%;
max-width: 16.6666666667%; } }
#conversejs:not(.fullscreen) #controlbox .controlbox-head { #conversejs:not(.fullscreen) #controlbox .controlbox-head {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
...@@ -5970,7 +5936,7 @@ body.reset { ...@@ -5970,7 +5936,7 @@ body.reset {
margin: 0.3em 0; } margin: 0.3em 0; }
#converse-embedded-chat .chatroom, #converse-embedded-chat .chatroom,
#conversejs .chatroom { #conversejs .chatroom {
width: 300px; } width: 400px; }
@media screen and (max-height: 450px) { @media screen and (max-height: 450px) {
#converse-embedded-chat .chatroom, #converse-embedded-chat .chatroom,
#conversejs .chatroom { #conversejs .chatroom {
...@@ -6044,7 +6010,7 @@ body.reset { ...@@ -6044,7 +6010,7 @@ body.reset {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
word-wrap: break-word; word-wrap: break-word;
min-width: 200px; } min-width: 250px; }
#converse-embedded-chat .chatroom .box-flyout .chatroom-body .chat-area .new-msgs-indicator, #converse-embedded-chat .chatroom .box-flyout .chatroom-body .chat-area .new-msgs-indicator,
#conversejs .chatroom .box-flyout .chatroom-body .chat-area .new-msgs-indicator { #conversejs .chatroom .box-flyout .chatroom-body .chat-area .new-msgs-indicator {
background-color: #E77051; background-color: #E77051;
...@@ -6206,20 +6172,13 @@ body.reset { ...@@ -6206,20 +6172,13 @@ body.reset {
border: 1px solid #999; } border: 1px solid #999; }
#conversejs .chatbox.chatroom { #conversejs .chatbox.chatroom {
flex: 0 0 100%; min-width: 400px !important;
max-width: 100%; } width: 400px; }
@media (min-width: 576px) { #conversejs .chatbox.chatroom .box-flyout {
#conversejs .chatbox.chatroom { min-width: 400px !important;
flex: 0 0 66.6666666667%; width: 400px; }
max-width: 66.6666666667%; } } #conversejs .chatbox.chatroom .chatroom-body .occupants .chatroom-features .feature {
@media (min-width: 768px) { font-size: 12px; }
#conversejs .chatbox.chatroom {
flex: 0 0 50%;
max-width: 50%; } }
@media (min-width: 992px) {
#conversejs .chatbox.chatroom {
flex: 0 0 33.3333333333%;
max-width: 33.3333333333%; } }
#conversejs .chatbox.headlines .chat-head.chat-head-chatbox { #conversejs .chatbox.headlines .chat-head.chat-head-chatbox {
background-color: #E7A151; } background-color: #E7A151; }
...@@ -6234,27 +6193,13 @@ body.reset { ...@@ -6234,27 +6193,13 @@ body.reset {
#conversejs:not(.fullscreen) #minimized-chats { #conversejs:not(.fullscreen) #minimized-chats {
order: 100; order: 100;
position: relative; width: 130px;
width: 100%;
min-height: 1px;
padding-right: 15px;
padding-left: 15px;
flex: 0 0 16.6666666667%;
max-width: 16.6666666667%;
margin-bottom: -1em; margin-bottom: -1em;
border-top-left-radius: 4px; border-top-left-radius: 4px;
border-top-right-radius: 4px; border-top-right-radius: 4px;
color: white; color: white;
margin-right: 0.5em; margin-right: 0.5em;
padding: 0; } padding: 0; }
@media (min-width: 576px) {
#conversejs:not(.fullscreen) #minimized-chats {
flex: 0 0 16.6666666667%;
max-width: 16.6666666667%; } }
@media (min-width: 992px) {
#conversejs:not(.fullscreen) #minimized-chats {
flex: 0 0 8.3333333333%;
max-width: 8.3333333333%; } }
#conversejs:not(.fullscreen) #minimized-chats .badge { #conversejs:not(.fullscreen) #minimized-chats .badge {
bottom: 8px; bottom: 8px;
border: 1px solid #818479; } border: 1px solid #818479; }
...@@ -6286,8 +6231,8 @@ body.reset { ...@@ -6286,8 +6231,8 @@ body.reset {
color: white; } color: white; }
#conversejs:not(.fullscreen) #minimized-chats .minimized-chats-flyout { #conversejs:not(.fullscreen) #minimized-chats .minimized-chats-flyout {
flex-direction: column-reverse; flex-direction: column-reverse;
width: 100%; bottom: 34px;
bottom: 48px; } width: 130px; }
#conversejs:not(.fullscreen) #minimized-chats .minimized-chats-flyout .chat-head { #conversejs:not(.fullscreen) #minimized-chats .minimized-chats-flyout .chat-head {
padding: 0.3em; padding: 0.3em;
border-radius: 4px; border-radius: 4px;
......
...@@ -4451,17 +4451,17 @@ body.reset { ...@@ -4451,17 +4451,17 @@ body.reset {
#conversejs { #conversejs {
padding-left: env(safe-area-inset-left); padding-left: env(safe-area-inset-left);
padding-right: env(safe-area-inset-right); padding-right: env(safe-area-inset-right);
bottom: 0;
height: auto;
width: 100vw;
color: #777; color: #777;
direction: ltr;
display: block;
font-family: "Helvetica", "Arial", sans-serif; font-family: "Helvetica", "Arial", sans-serif;
font-size: 16px; font-size: 16px;
direction: ltr;
display: block;
z-index: 1031; }
#conversejs .converse-chatboxes {
position: fixed; position: fixed;
z-index: 1031; bottom: 0;
margin-left: -15px; } height: auto;
width: 100vw; }
#conversejs ::-webkit-input-placeholder { #conversejs ::-webkit-input-placeholder {
/* Chrome/Opera/Safari */ /* Chrome/Opera/Safari */
color: #A8ABA1; } color: #A8ABA1; }
...@@ -4884,7 +4884,9 @@ body { ...@@ -4884,7 +4884,9 @@ body {
padding-right: 10%; padding-right: 10%;
font-size: 120%; } font-size: 120%; }
#conversejs.fullscreen form.converse-form { #conversejs.fullscreen {
margin-left: -15px; }
#conversejs.fullscreen form.converse-form {
margin: 1em; } margin: 1em; }
#conversejs.fullscreen form.converse-form input[type=checkbox] { #conversejs.fullscreen form.converse-form input[type=checkbox] {
margin-left: 1em; margin-left: 1em;
...@@ -5805,6 +5807,9 @@ body { ...@@ -5805,6 +5807,9 @@ body {
#conversejs.fullscreen #controlbox { #conversejs.fullscreen #controlbox {
flex: 0 0 16.6666666667%; flex: 0 0 16.6666666667%;
max-width: 16.6666666667%; } } max-width: 16.6666666667%; } }
#conversejs.fullscreen #controlbox.logged-out {
flex: 0 0 100%;
max-width: 100%; }
#conversejs.fullscreen #controlbox .controlbox-pane { #conversejs.fullscreen #controlbox .controlbox-pane {
border-radius: 0; } border-radius: 0; }
#conversejs.fullscreen #controlbox .flyout { #conversejs.fullscreen #controlbox .flyout {
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
<body class="reset"> <body class="reset">
<div id="conversejs" class="fullscreen"> <div id="conversejs" class="fullscreen">
<div class="sidebar"></div> <div class="sidebar"></div>
<div class="row no-gutters"> <div class="converse-chatboxes row no-gutters">
<div id="controlbox" class="chatbox"> <div id="controlbox" class="chatbox">
<div class="flyout box-flyout"> <div class="flyout box-flyout">
<div class="controlbox-panes"> <div class="controlbox-panes">
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
<body class="reset"> <body class="reset">
<div id="conversejs" class="fullscreen"> <div id="conversejs" class="fullscreen">
<div class="sidebar"></div> <div class="sidebar"></div>
<div class="row no-gutters"> <div class="converse-chatboxes row no-gutters">
<div id="controlbox" class="chatbox"> <div id="controlbox" class="chatbox">
<div class="flyout box-flyout"> <div class="flyout box-flyout">
<div class="controlbox-panes"> <div class="controlbox-panes">
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
</div> </div>
<div id="conversejs"> <div id="conversejs">
<div class="row no-gutters"> <div class="converse-chatboxes row no-gutters">
<div id="controlbox" class="chatbox"> <div id="controlbox" class="chatbox">
<div class="flyout box-flyout"> <div class="flyout box-flyout">
<div class="controlbox-panes"> <div class="controlbox-panes">
......
...@@ -15,8 +15,8 @@ ...@@ -15,8 +15,8 @@
</div> </div>
<div id="conversejs" class="fullscreen"> <div id="conversejs" class="fullscreen">
<div class="row no-gutters"> <div class="converse-chatboxes row no-gutters">
<div id="controlbox" class="chatbox"> <div id="controlbox" class="chatbox logged-out">
<div class="flyout box-flyout"> <div class="flyout box-flyout">
<div class="controlbox-panes"> <div class="controlbox-panes">
<div class="row"> <div class="row">
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
</div> </div>
<div id="conversejs"> <div id="conversejs">
<div class="row no-gutters"> <div class="converse-chatboxes row no-gutters">
<div id="controlbox" class="chatbox"> <div id="controlbox" class="chatbox">
<div class="flyout box-flyout"> <div class="flyout box-flyout">
<div class="chat-head controlbox-head"> <div class="chat-head controlbox-head">
......
...@@ -42,18 +42,19 @@ body.reset { ...@@ -42,18 +42,19 @@ body.reset {
#conversejs { #conversejs {
padding-left: env(safe-area-inset-left); padding-left: env(safe-area-inset-left);
padding-right: env(safe-area-inset-right); padding-right: env(safe-area-inset-right);
bottom: 0;
height: auto;
width: 100vw;
color: $text-color; color: $text-color;
direction: ltr;
display: block;
font-family: "Helvetica", "Arial", sans-serif; font-family: "Helvetica", "Arial", sans-serif;
font-size: $font-size; font-size: $font-size;
position: fixed; direction: ltr;
display: block;
z-index: 1031; // One more than bootstrap navbar z-index: 1031; // One more than bootstrap navbar
margin-left: -15px; // XXX: why is this necessary? .converse-chatboxes {
position: fixed;
bottom: 0;
height: auto;
width: 100vw;
}
::-webkit-input-placeholder { /* Chrome/Opera/Safari */ ::-webkit-input-placeholder { /* Chrome/Opera/Safari */
color: $subdued-color; color: $subdued-color;
......
...@@ -13,18 +13,12 @@ ...@@ -13,18 +13,12 @@
} }
} }
.chatbox { .chatbox {
@include make-col-ready(); min-width: $chat-width!important;
@include media-breakpoint-up(xs) { width: $chat-width;
@include make-col(12);
} .box-flyout {
@include media-breakpoint-up(sm) { min-width: $chat-width!important;
@include make-col(4); width: $chat-width;
}
@include media-breakpoint-up(md) {
@include make-col(3);
}
@include media-breakpoint-up(lg) {
@include make-col(2);
} }
.chat-body { .chat-body {
......
#conversejs { #conversejs {
.chatbox { .chatbox {
&.chatroom { &.chatroom {
@include media-breakpoint-up(xs) { min-width: $chatroom-width !important;
@include make-col(12); width: $chatroom-width;
.box-flyout {
min-width: $chatroom-width !important;
width: $chatroom-width;
}
.chatroom-body {
.occupants {
.chatroom-features {
.feature {
font-size: $font-size-small;
} }
@include media-breakpoint-up(sm) {
@include make-col(8);
} }
@include media-breakpoint-up(md) {
@include make-col(6);
} }
@include media-breakpoint-up(lg) {
@include make-col(4);
} }
} }
} }
......
#conversejs:not(.fullscreen) { #conversejs:not(.fullscreen) {
#controlbox { #controlbox {
order: -1; order: -1;
@include make-col-ready(); min-width: $controlbox-width !important;
@include media-breakpoint-up(xs) { width: $controlbox-width;
@include make-col(12); .box-flyout {
} min-width: $controlbox-width !important;
@include media-breakpoint-up(sm) { width: $controlbox-width;
@include make-col(4);
}
@include media-breakpoint-up(md) {
@include make-col(3);
} }
@include media-breakpoint-up(lg) {
@include make-col(2);
}
@include media-breakpoint-up(xl) {
@include make-col(2);
}
.controlbox-head { .controlbox-head {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
......
#conversejs:not(.fullscreen) { #conversejs:not(.fullscreen) {
#minimized-chats { #minimized-chats {
order: 100; order: 100;
@include make-col-ready();
@include media-breakpoint-up(xs) {
@include make-col(2);
}
@include media-breakpoint-up(sm) {
@include make-col(2);
}
@include media-breakpoint-up(lg) {
@include make-col(1);
}
width: $minimized-chats-width;
margin-bottom: -2*$chat-gutter; margin-bottom: -2*$chat-gutter;
border-top-left-radius: $chatbox-border-radius; border-top-left-radius: $chatbox-border-radius;
border-top-right-radius: $chatbox-border-radius; border-top-right-radius: $chatbox-border-radius;
...@@ -59,8 +50,8 @@ ...@@ -59,8 +50,8 @@
.minimized-chats-flyout { .minimized-chats-flyout {
flex-direction: column-reverse; flex-direction: column-reverse;
width: 100%; bottom: 34px;
bottom: 48px; width: $minimized-chats-width;
.chat-head { .chat-head {
padding: 0.3em; padding: 0.3em;
......
...@@ -109,8 +109,8 @@ $line-height-small: 14px !default; ...@@ -109,8 +109,8 @@ $line-height-small: 14px !default;
$line-height: 16px !default; $line-height: 16px !default;
$line-height-large: 20px !default; $line-height-large: 20px !default;
$controlbox-width: 200px !default; $controlbox-width: 250px !default;
$chat-width: 200px !default; $chat-width: 250px !default;
$chat-height: 450px !default; $chat-height: 450px !default;
$chat-gutter: 0.5em !default; $chat-gutter: 0.5em !default;
$minimized-chats-width: 130px !default; $minimized-chats-width: 130px !default;
...@@ -121,7 +121,7 @@ $small-mobile-chat-height: 300px !default; ...@@ -121,7 +121,7 @@ $small-mobile-chat-height: 300px !default;
$font-path: "../fonticons/fonts/" !default; $font-path: "../fonticons/fonts/" !default;
$chatroom-width: 300px !default; $chatroom-width: 400px !default;
$chatroom-head-color: $red !default; $chatroom-head-color: $red !default;
$chatroom-color-light: $light-red !default; $chatroom-color-light: $light-red !default;
$chatroom-color-lightest: $light-red !default; $chatroom-color-lightest: $light-red !default;
...@@ -135,4 +135,4 @@ $box-close-button-padding-top: 4px !default; ...@@ -135,4 +135,4 @@ $box-close-button-padding-top: 4px !default;
$box-close-button-padding-bottom: 4px !default; $box-close-button-padding-bottom: 4px !default;
$box-close-button-padding-left: 4px !default; $box-close-button-padding-left: 4px !default;
$box-close-button-padding-right: 4px !default; $box-close-button-padding-right: 4px !default;
$box-close-font-size: 12px !default; $box-close-font-size: 16px !default;
...@@ -8,6 +8,10 @@ ...@@ -8,6 +8,10 @@
@include make-col(2); @include make-col(2);
} }
&.logged-out {
@include make-col(12);
}
margin: 0; margin: 0;
.controlbox-pane { .controlbox-pane {
......
...@@ -36,6 +36,9 @@ body { ...@@ -36,6 +36,9 @@ body {
#conversejs.fullscreen { #conversejs.fullscreen {
// XXX: why is this neccessary?
margin-left: -15px;
form { form {
&.converse-form { &.converse-form {
margin: 1em; margin: 1em;
......
...@@ -305,8 +305,6 @@ ...@@ -305,8 +305,6 @@
renderLoginPanel () { renderLoginPanel () {
this.el.classList.add("logged-out"); this.el.classList.add("logged-out");
this.el.classList.remove("col-xl-2");
this.el.classList.remove("col-md-3");
if (_.isNil(this.loginpanel)) { if (_.isNil(this.loginpanel)) {
this.loginpanel = new _converse.LoginPanel({ this.loginpanel = new _converse.LoginPanel({
'model': new _converse.LoginPanelModel() 'model': new _converse.LoginPanelModel()
...@@ -332,9 +330,6 @@ ...@@ -332,9 +330,6 @@
delete this.loginpanel; delete this.loginpanel;
} }
this.el.classList.remove("logged-out"); this.el.classList.remove("logged-out");
this.el.classList.add("col-xl-2");
this.el.classList.add("col-md-3");
this.controlbox_pane = new _converse.ControlBoxPane(); this.controlbox_pane = new _converse.ControlBoxPane();
this.el.querySelector('.controlbox-panes').insertAdjacentElement( this.el.querySelector('.controlbox-panes').insertAdjacentElement(
'afterBegin', 'afterBegin',
......
...@@ -67,10 +67,16 @@ ...@@ -67,10 +67,16 @@
that.resizing.chatbox.height, that.resizing.chatbox.height,
that.resizing.chatbox.model.get('default_height') that.resizing.chatbox.model.get('default_height')
); );
const width = that.applyDragResistance(
that.resizing.chatbox.width,
that.resizing.chatbox.model.get('default_width')
);
if (that.connection.connected) { if (that.connection.connected) {
that.resizing.chatbox.model.save({'height': height}); that.resizing.chatbox.model.save({'height': height});
that.resizing.chatbox.model.save({'width': width});
} else { } else {
that.resizing.chatbox.model.set({'height': height}); that.resizing.chatbox.model.set({'height': height});
that.resizing.chatbox.model.set({'width': width});
} }
that.resizing = null; that.resizing = null;
}); });
...@@ -82,9 +88,12 @@ ...@@ -82,9 +88,12 @@
initialize () { initialize () {
const { _converse } = this.__super__; const { _converse } = this.__super__;
const result = this.__super__.initialize.apply(this, arguments), const result = this.__super__.initialize.apply(this, arguments),
height = this.get('height'), height = this.get('height'), width = this.get('width'),
save = this.get('id') === 'controlbox' ? this.set.bind(this) : this.save.bind(this); save = this.get('id') === 'controlbox' ? this.set.bind(this) : this.save.bind(this);
save('height', _converse.applyDragResistance(height, this.get('default_height'))); save({
'height': _converse.applyDragResistance(height, this.get('default_height')),
'width': _converse.applyDragResistance(width, this.get('default_width')),
});
return result; return result;
} }
}, },
...@@ -92,6 +101,8 @@ ...@@ -92,6 +101,8 @@
ChatBoxView: { ChatBoxView: {
events: { events: {
'mousedown .dragresize-top': 'onStartVerticalResize', 'mousedown .dragresize-top': 'onStartVerticalResize',
'mousedown .dragresize-left': 'onStartHorizontalResize',
'mousedown .dragresize-topleft': 'onStartDiagonalResize'
}, },
initialize () { initialize () {
...@@ -102,9 +113,18 @@ ...@@ -102,9 +113,18 @@
render () { render () {
const result = this.__super__.render.apply(this, arguments); const result = this.__super__.render.apply(this, arguments);
renderDragResizeHandles(this.__super__._converse, this); renderDragResizeHandles(this.__super__._converse, this);
this.setWidth();
return result; return result;
}, },
setWidth () {
// If a custom width is applied (due to drag-resizing),
// then we need to set the width of the .chatbox element as well.
if (this.model.get('width')) {
this.el.style.width = this.model.get('width');
}
},
_show () { _show () {
this.initDragResize().setDimensions(); this.initDragResize().setDimensions();
this.__super__._show.apply(this, arguments); this.__super__._show.apply(this, arguments);
...@@ -119,25 +139,32 @@ ...@@ -119,25 +139,32 @@
style = window.getComputedStyle(flyout); style = window.getComputedStyle(flyout);
if (_.isUndefined(this.model.get('height'))) { if (_.isUndefined(this.model.get('height'))) {
const height = parseInt(style.height.replace(/px$/, ''), 10); const height = parseInt(style.height.replace(/px$/, ''), 10),
width = parseInt(style.width.replace(/px$/, ''), 10);
this.model.set('height', height); this.model.set('height', height);
this.model.set('default_height', height); this.model.set('default_height', height);
this.model.set('width', width);
this.model.set('default_width', width);
} }
const min_width = style['min-width'];
const min_height = style['min-height']; const min_height = style['min-height'];
this.model.set('min_width', min_width.endsWith('px') ? Number(min_width.replace(/px$/, '')) :0);
this.model.set('min_height', min_height.endsWith('px') ? Number(min_height.replace(/px$/, '')) :0); this.model.set('min_height', min_height.endsWith('px') ? Number(min_height.replace(/px$/, '')) :0);
// Initialize last known mouse position // Initialize last known mouse position
this.prev_pageY = 0; this.prev_pageY = 0;
this.prev_pageX = 0; this.prev_pageX = 0;
if (_converse.connection.connected) { if (_converse.connection.connected) {
this.height = this.model.get('height'); this.height = this.model.get('height');
this.width = this.model.get('width');
} }
return this; return this;
}, },
setDimensions () { setDimensions () {
// Make sure the chat box has the right height // Make sure the chat box has the right height and width.
this.adjustToViewport(); this.adjustToViewport();
this.setChatBoxHeight(this.model.get('height')); this.setChatBoxHeight(this.model.get('height'));
this.setChatBoxWidth(this.model.get('width'));
}, },
setChatBoxHeight (height) { setChatBoxHeight (height) {
...@@ -153,10 +180,32 @@ ...@@ -153,10 +180,32 @@
} }
}, },
setChatBoxWidth (width) {
const { _converse } = this.__super__;
if (width) {
width = _converse.applyDragResistance(width, this.model.get('default_width'))+'px';
} else {
width = "";
}
this.el.style.width = width;
const flyout_el = this.el.querySelector('.box-flyout');
if (!_.isNull(flyout_el)) {
flyout_el.style.width = width;
}
},
adjustToViewport () { adjustToViewport () {
/* Event handler called when viewport gets resized. We remove the custom height from chat boxes. */ /* Event handler called when viewport gets resized. We remove
* custom width/height from chat boxes.
*/
const viewport_width = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
const viewport_height = Math.max(document.documentElement.clientHeight, window.innerHeight || 0); const viewport_height = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
if (viewport_height <= this.model.get('height')) { if (viewport_width <= 480) {
this.model.set('height', undefined);
this.model.set('width', undefined);
} else if (viewport_width <= this.model.get('width')) {
this.model.set('width', undefined);
} else if (viewport_height <= this.model.get('height')) {
this.model.set('height', undefined); this.model.set('height', undefined);
} }
}, },
...@@ -175,6 +224,26 @@ ...@@ -175,6 +224,26 @@
this.prev_pageY = ev.pageY; this.prev_pageY = ev.pageY;
}, },
onStartHorizontalResize (ev) {
const { _converse } = this.__super__;
if (!_converse.allow_dragresize) { return true; }
const flyout = this.el.querySelector('.box-flyout'),
style = window.getComputedStyle(flyout);
this.width = parseInt(style.width.replace(/px$/, ''), 10);
_converse.resizing = {
'chatbox': this,
'direction': 'left'
};
this.prev_pageX = ev.pageX;
},
onStartDiagonalResize (ev) {
const { _converse } = this.__super__;
this.onStartHorizontalResize(ev);
this.onStartVerticalResize(ev);
_converse.resizing.direction = 'topleft';
},
resizeChatBox (ev) { resizeChatBox (ev) {
let diff; let diff;
const { _converse } = this.__super__; const { _converse } = this.__super__;
...@@ -186,12 +255,22 @@ ...@@ -186,12 +255,22 @@
this.setChatBoxHeight(this.height); this.setChatBoxHeight(this.height);
} }
} }
if (_.includes(_converse.resizing.direction, 'left')) {
diff = this.prev_pageX - ev.pageX;
if (diff) {
this.width = ((this.width+diff) > (this.model.get('min_width') || 0)) ? (this.width+diff) : this.model.get('min_width');
this.prev_pageX = ev.pageX;
this.setChatBoxWidth(this.width);
}
}
} }
}, },
HeadlinesBoxView: { HeadlinesBoxView: {
events: { events: {
'mousedown .dragresize-top': 'onStartVerticalResize', 'mousedown .dragresize-top': 'onStartVerticalResize',
'mousedown .dragresize-left': 'onStartHorizontalResize',
'mousedown .dragresize-topleft': 'onStartDiagonalResize'
}, },
initialize () { initialize () {
...@@ -202,6 +281,7 @@ ...@@ -202,6 +281,7 @@
render () { render () {
const result = this.__super__.render.apply(this, arguments); const result = this.__super__.render.apply(this, arguments);
renderDragResizeHandles(this.__super__._converse, this); renderDragResizeHandles(this.__super__._converse, this);
this.setWidth();
return result; return result;
} }
}, },
...@@ -210,6 +290,7 @@ ...@@ -210,6 +290,7 @@
events: { events: {
'mousedown .dragresize-top': 'onStartVerticalResize', 'mousedown .dragresize-top': 'onStartVerticalResize',
'mousedown .dragresize-left': 'onStartHorizontalResize', 'mousedown .dragresize-left': 'onStartHorizontalResize',
'mousedown .dragresize-topleft': 'onStartDiagonalResize'
}, },
initialize () { initialize () {
...@@ -220,6 +301,7 @@ ...@@ -220,6 +301,7 @@
render () { render () {
const result = this.__super__.render.apply(this, arguments); const result = this.__super__.render.apply(this, arguments);
renderDragResizeHandles(this.__super__._converse, this); renderDragResizeHandles(this.__super__._converse, this);
this.setWidth();
return result; return result;
}, },
...@@ -239,6 +321,8 @@ ...@@ -239,6 +321,8 @@
ChatRoomView: { ChatRoomView: {
events: { events: {
'mousedown .dragresize-top': 'onStartVerticalResize', 'mousedown .dragresize-top': 'onStartVerticalResize',
'mousedown .dragresize-left': 'onStartHorizontalResize',
'mousedown .dragresize-topleft': 'onStartDiagonalResize'
}, },
initialize () { initialize () {
...@@ -249,6 +333,7 @@ ...@@ -249,6 +333,7 @@
render () { render () {
const result = this.__super__.render.apply(this, arguments); const result = this.__super__.render.apply(this, arguments);
renderDragResizeHandles(this.__super__._converse, this); renderDragResizeHandles(this.__super__._converse, this);
this.setWidth();
return result; return result;
} }
} }
......
<div class="row no-gutters"></div> <div class="converse-chatboxes row no-gutters"></div>
<div id="converse-modals" class="modals"></div> <div id="converse-modals" class="modals"></div>
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
<li class="feature" title="{{{ o.tt_persistent }}}"><span class="fa fa-save"></span>{{{ o.label_persistent }}}</li> <li class="feature" title="{{{ o.tt_persistent }}}"><span class="fa fa-save"></span>{{{ o.label_persistent }}}</li>
{[ } ]} {[ } ]}
{[ if (o.temporary) { ]} {[ if (o.temporary) { ]}
<li class="feature" title="{{{ o.tt_temporary }}}"><span class="fa fa-snowflake"></span>{{{ o.label_temporary }}}</li> <li class="feature" title="{{{ o.tt_temporary }}}"><span class="fa fa-snowflake-o"></span>{{{ o.label_temporary }}}</li>
{[ } ]} {[ } ]}
{[ if (o.nonanonymous) { ]} {[ if (o.nonanonymous) { ]}
<li class="feature" title="{{{ o.tt_nonanonymous }}}"><span class="fa fa-idcard-dark"></span>{{{ o.label_nonanonymous }}}</li> <li class="feature" title="{{{ o.tt_nonanonymous }}}"><span class="fa fa-idcard-dark"></span>{{{ o.label_nonanonymous }}}</li>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment