Refactor slightly to improve readability
This commit is contained in:
parent
f69e39dc8b
commit
0958915021
@ -269,13 +269,11 @@
|
|||||||
|
|
||||||
renderRegistrationRequest (cancel_label) {
|
renderRegistrationRequest (cancel_label) {
|
||||||
const form = this.el.querySelector('#converse-register');
|
const form = this.el.querySelector('#converse-register');
|
||||||
utils.createElementsFromString(
|
const markup = tpl_registration_request({
|
||||||
form,
|
'cancel': cancel_label,
|
||||||
tpl_registration_request({
|
'info_message': _converse.__('Requesting a registration form from the XMPP server')
|
||||||
cancel: cancel_label,
|
});
|
||||||
info_message: _converse.__('Requesting a registration form from the XMPP server')
|
form.appendChild(utils.createFragmentFromText(markup));
|
||||||
})
|
|
||||||
);
|
|
||||||
if (!_converse.registration_domain) {
|
if (!_converse.registration_domain) {
|
||||||
const cancel_button = document.querySelector('button.button-cancel');
|
const cancel_button = document.querySelector('button.button-cancel');
|
||||||
cancel_button.addEventListener('click', this.cancelRegistration.bind(this));
|
cancel_button.addEventListener('click', this.cancelRegistration.bind(this));
|
||||||
|
14
src/utils.js
14
src/utils.js
@ -589,18 +589,20 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
utils.createElementsFromString = function (element, html) {
|
utils.createFragmentFromText = function (markup) {
|
||||||
|
/* Returns a DocumentFragment containing DOM nodes based on the
|
||||||
|
* passed-in markup text.
|
||||||
|
*/
|
||||||
// http://stackoverflow.com/questions/9334645/create-node-from-markup-string
|
// http://stackoverflow.com/questions/9334645/create-node-from-markup-string
|
||||||
var frag = document.createDocumentFragment(),
|
var frag = document.createDocumentFragment(),
|
||||||
tmp = document.createElement('body'), child;
|
tmp = document.createElement('body'), child;
|
||||||
tmp.innerHTML = html;
|
tmp.innerHTML = markup;
|
||||||
// Append elements in a loop to a DocumentFragment, so that the browser does
|
// Append elements in a loop to a DocumentFragment, so that the
|
||||||
// not re-render the document for each node
|
// browser does not re-render the document for each node.
|
||||||
while (child = tmp.firstChild) { // eslint-disable-line no-cond-assign
|
while (child = tmp.firstChild) { // eslint-disable-line no-cond-assign
|
||||||
frag.appendChild(child);
|
frag.appendChild(child);
|
||||||
}
|
}
|
||||||
element.appendChild(frag); // Now, append all elements at once
|
return frag
|
||||||
frag = tmp = null;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
utils.addEmoji = function (_converse, emojione, text) {
|
utils.addEmoji = function (_converse, emojione, text) {
|
||||||
|
Loading…
Reference in New Issue
Block a user