Formatting

This commit is contained in:
JC Brand 2018-10-05 04:43:00 +02:00
parent d426d79702
commit 5836e9d805
2 changed files with 19 additions and 30 deletions

View File

@ -135,36 +135,28 @@
renderBookmarkForm () { renderBookmarkForm () {
const { _converse } = this.__super__, const { _converse } = this.__super__,
{ __ } = _converse, { __ } = _converse,
body = this.el.querySelector('.chatroom-body'); body = this.el.querySelector('.chatroom-body');
_.each(body.children, function (child) { _.each(body.children, child => child.classList.add('hidden'));
child.classList.add('hidden');
});
// Remove any existing forms
_.each(body.querySelectorAll('.chatroom-form-container'), u.removeElement); _.each(body.querySelectorAll('.chatroom-form-container'), u.removeElement);
body.insertAdjacentHTML( body.insertAdjacentHTML(
'beforeend', 'beforeend',
tpl_chatroom_bookmark_form({ tpl_chatroom_bookmark_form({
heading: __('Bookmark this groupchat'), 'default_nick': this.model.get('nick'),
label_name: __('The name for this bookmark:'), 'heading': __('Bookmark this groupchat'),
label_autojoin: __('Would you like this groupchat to be automatically joined upon startup?'), 'label_autojoin': __('Would you like this groupchat to be automatically joined upon startup?'),
label_nick: __('What should your nickname for this groupchat be?'), 'label_cancel': __('Cancel'),
default_nick: this.model.get('nick'), 'label_name': __('The name for this bookmark:'),
label_submit: __('Save'), 'label_nick': __('What should your nickname for this groupchat be?'),
label_cancel: __('Cancel') 'label_submit': __('Save'),
'name': this.model.get('name')
}) })
); );
const form = body.querySelector('form.chatroom-form'); const form = body.querySelector('form.chatroom-form');
form.addEventListener( form.addEventListener('submit', ev => this.onBookmarkFormSubmitted(ev));
'submit', form.querySelector('.button-cancel').addEventListener('click', () => this.closeForm());
this.onBookmarkFormSubmitted.bind(this)
);
form.querySelector('.button-cancel').addEventListener(
'click',
this.closeForm.bind(this)
);
}, },
onBookmarkFormSubmitted (ev) { onBookmarkFormSubmitted (ev) {

View File

@ -343,10 +343,7 @@
}, },
roomStanzaItemToHTMLElement (groupchat) { roomStanzaItemToHTMLElement (groupchat) {
const name = Strophe.unescapeNode( const name = Strophe.unescapeNode(groupchat.getAttribute('name') || groupchat.getAttribute('jid'));
groupchat.getAttribute('name') ||
groupchat.getAttribute('jid')
);
const div = document.createElement('div'); const div = document.createElement('div');
div.innerHTML = tpl_room_item({ div.innerHTML = tpl_room_item({
'name': Strophe.xmlunescape(name), 'name': Strophe.xmlunescape(name),
@ -1309,14 +1306,14 @@
container_el.insertAdjacentHTML('beforeend', container_el.insertAdjacentHTML('beforeend',
tpl_chatroom_password_form({ tpl_chatroom_password_form({
heading: __('This groupchat requires a password'), 'heading': __('This groupchat requires a password'),
label_password: __('Password: '), 'label_password': __('Password: '),
label_submit: __('Submit') 'label_submit': __('Submit')
})); }));
this.model.save('connection_status', converse.ROOMSTATUS.PASSWORD_REQUIRED); this.model.save('connection_status', converse.ROOMSTATUS.PASSWORD_REQUIRED);
this.el.querySelector('.chatroom-form').addEventListener( this.el.querySelector('.chatroom-form')
'submit', this.submitPassword.bind(this), false); .addEventListener('submit', ev => this.submitPassword(ev), false);
}, },
showDisconnectMessages (msgs) { showDisconnectMessages (msgs) {