@@ -27,7 +27,7 @@ import tpl_chatroom_features from "templates/chatroom_features.html";
27
27
import tpl_chatroom_form from "templates/chatroom_form.html" ;
28
28
import tpl_chatroom_head from "templates/chatroom_head.html" ;
29
29
import tpl_chatroom_invite from "templates/chatroom_invite.html" ;
30
- import tpl_chatroom_nickname_form from "templates/chatroom_nickname_form .html" ;
30
+ import tpl_chatroom_nickname_form_modal from "templates/chatroom_nickname_form_modal .html" ;
31
31
import tpl_chatroom_password_form from "templates/chatroom_password_form.html" ;
32
32
import tpl_chatroom_sidebar from "templates/chatroom_sidebar.html" ;
33
33
import tpl_info from "templates/info.html" ;
@@ -1028,7 +1028,7 @@ converse.plugins.add('converse-muc-views', {
1028
1028
onConnectionStatusChanged ( ) {
1029
1029
const conn_status = this . model . get ( 'connection_status' ) ;
1030
1030
if ( conn_status === converse . ROOMSTATUS . NICKNAME_REQUIRED ) {
1031
- this . renderNicknameForm ( ) ;
1031
+ this . renderNicknameButton ( ) ;
1032
1032
} else if ( conn_status === converse . ROOMSTATUS . PASSWORD_REQUIRED ) {
1033
1033
this . renderPasswordForm ( ) ;
1034
1034
} else if ( conn_status === converse . ROOMSTATUS . CONNECTING ) {
@@ -1471,29 +1471,34 @@ converse.plugins.add('converse-muc-views', {
1471
1471
} ,
1472
1472
1473
1473
hideChatRoomContents ( ) {
1474
- const container_el = this . el . querySelector ( '.chatroom-body' ) ;
1475
- if ( container_el !== null ) {
1476
- [ ] . forEach . call ( container_el . children , child => child . classList . add ( 'hidden' ) ) ;
1477
- }
1474
+ return ;
1478
1475
} ,
1479
1476
1480
- renderNicknameForm ( ) {
1481
- /* Render a form which allows the user to choose theirnickname.
1477
+ renderNicknameButton ( ) {
1478
+ this . el . querySelector ( '.setNicknameButtonForm' ) . classList . remove ( 'hidden' ) ;
1479
+ this . el . querySelector ( '.sendXMPPMessage' ) . classList . add ( 'hidden' ) ;
1480
+ this . el . querySelector ( '.setNicknameButtonForm' ) . addEventListener ( 'submit' , this . renderNicknameModal . bind ( this ) , false ) ;
1481
+ } ,
1482
+
1483
+ renderNicknameModal ( ev ) {
1484
+ /* Render a button which allows the user to get a modal to set their nickname.
1482
1485
*/
1486
+ ev . preventDefault ( ) ;
1483
1487
const message = this . model . get ( 'nickname_validation_message' ) ;
1484
1488
this . model . save ( 'nickname_validation_message' , undefined ) ;
1485
- this . hideChatRoomContents ( ) ;
1486
- if ( ! this . nickname_form ) {
1487
- this . nickname_form = new _converse . MUCNicknameForm ( {
1488
- 'model' : new Backbone . Model ( { 'validation_message' : message } ) ,
1489
+ if ( this . nickname_form_modal === undefined ) {
1490
+ this . nickname_form_modal = new _converse . NicknameFormModal ( {
1491
+ //'model': new Backbone.Model({'validation_message': message}),
1492
+ 'model' : this . model ,
1489
1493
'chatroomview' : this ,
1490
1494
} ) ;
1491
1495
const container_el = this . el . querySelector ( '.chatroom-body' ) ;
1492
- container_el . insertAdjacentElement ( 'beforeend' , this . nickname_form . el ) ;
1496
+ container_el . insertAdjacentElement ( 'beforeend' , this . nickname_form_modal . el ) ;
1493
1497
} else {
1494
- this . nickname_form . model . set ( 'validation_message' , message ) ;
1498
+ this . nickname_form_modal . model . set ( 'validation_message' , message ) ;
1495
1499
}
1496
- u . showElement ( this . nickname_form . el ) ;
1500
+ this . nickname_form_modal . show ( ev ) ;
1501
+ console . log ( this . nickname_form_modal ) ;
1497
1502
u . safeSave ( this . model , { 'connection_status' : converse . ROOMSTATUS . NICKNAME_REQUIRED } ) ;
1498
1503
} ,
1499
1504
@@ -1778,7 +1783,7 @@ converse.plugins.add('converse-muc-views', {
1778
1783
* form has been submitted and removed.
1779
1784
*/
1780
1785
if ( this . model . get ( 'connection_status' ) == converse . ROOMSTATUS . NICKNAME_REQUIRED ) {
1781
- this . renderNicknameForm ( ) ;
1786
+ this . renderNicknameButton ( ) ;
1782
1787
} else if ( this . model . get ( 'connection_status' ) == converse . ROOMSTATUS . PASSWORD_REQUIRED ) {
1783
1788
this . renderPasswordForm ( ) ;
1784
1789
} else if ( this . model . get ( 'connection_status' ) == converse . ROOMSTATUS . ENTERED ) {
@@ -1956,21 +1961,23 @@ converse.plugins.add('converse-muc-views', {
1956
1961
} ) ;
1957
1962
1958
1963
1959
- _converse . MUCNicknameForm = Backbone . VDOMView . extend ( {
1960
- className : 'muc-nickname-form' ,
1964
+ _converse . NicknameFormModal = _converse . BootstrapModal . extend ( {
1965
+
1961
1966
events : {
1962
1967
'submit form' : 'submitNickname' ,
1963
1968
} ,
1964
1969
1965
1970
initialize ( attrs ) {
1971
+ _converse . BootstrapModal . prototype . initialize . apply ( this , arguments ) ;
1966
1972
this . chatroomview = attrs . chatroomview ;
1967
1973
this . listenTo ( this . model , 'change:validation_message' , this . render ) ;
1968
1974
this . render ( ) ;
1969
1975
} ,
1970
1976
1971
1977
toHTML ( ) {
1972
1978
const err_msg = this . model . get ( 'validation_message' ) ;
1973
- return tpl_chatroom_nickname_form ( {
1979
+ return tpl_chatroom_nickname_form_modal ( {
1980
+ '__' : __ ,
1974
1981
'heading' : __ ( 'Please choose your nickname' ) ,
1975
1982
'label_nickname' : __ ( 'Nickname' ) ,
1976
1983
'label_join' : __ ( 'Enter groupchat' ) ,
@@ -1998,9 +2005,11 @@ converse.plugins.add('converse-muc-views', {
1998
2005
'validation_message' : __ ( 'You need to provide a nickname' )
1999
2006
} ) ;
2000
2007
}
2008
+ this . modal . hide ( ) ;
2001
2009
}
2002
2010
} ) ;
2003
2011
2012
+
2004
2013
_converse . ChatRoomOccupantView = Backbone . VDOMView . extend ( {
2005
2014
tagName : 'li' ,
2006
2015
initialize ( ) {
0 commit comments