Commit 85bea600 authored by JC Brand's avatar JC Brand

Some of refactoring to avoid code duplication and jQuery

parent 292a75d3
......@@ -32,14 +32,14 @@
var jid = 'theplay@conference.shakespeare.lit';
var view = _converse.chatboxviews.get(jid);
spyOn(view, 'renderBookmarkForm').and.callThrough();
spyOn(view, 'cancelConfiguration').and.callThrough();
spyOn(view, 'closeForm').and.callThrough();
var $bookmark = view.$el.find('.icon-pushpin');
$bookmark.click();
expect(view.renderBookmarkForm).toHaveBeenCalled();
view.$el.find('.button-cancel').click();
expect(view.cancelConfiguration).toHaveBeenCalled();
expect(view.closeForm).toHaveBeenCalled();
expect($bookmark.hasClass('on-button'), false);
$bookmark.click();
......
......@@ -132,10 +132,8 @@
child.classList.add('hidden');
});
// Remove any existing forms
let form = body.querySelector('form.chatroom-form');
if (!_.isNull(form)) {
form.parentNode.removeChild(form);
}
_.each(body.querySelectorAll('.chatroom-form-container'), utils.removeElement);
body.insertAdjacentHTML(
'beforeend',
tpl_chatroom_bookmark_form({
......@@ -148,14 +146,14 @@
label_cancel: __('Cancel')
})
);
form = body.querySelector('form.chatroom-form');
const form = body.querySelector('form.chatroom-form');
form.addEventListener(
'submit',
this.onBookmarkFormSubmitted.bind(this)
);
form.querySelector('.button-cancel').addEventListener(
'click',
this.cancelConfiguration.bind(this)
this.closeForm.bind(this)
);
},
......
This diff is collapsed.
......@@ -6,7 +6,7 @@
<ul class="chat-toolbar no-text-select"></ul>
{[ } ]}
<textarea type="text" class="chat-textarea {[ if (o.show_send_button) { ]}chat-textarea-send-button{[ } ]}"
placeholder="{{{o.label_message}}}"/>
placeholder="{{{o.label_message}}}"></textarea>
{[ if (o.show_send_button) { ]}
<button type="submit" class="pure-button send-button">{{{ o.label_send }}}</button>
{[ } ]}
......
<div class="flyout box-flyout">
<div class="chat-head chat-head-chatroom"></div>
<div class="chat-body chatroom-body"><span class="spinner centered"/></div>
<div class="chat-body chatroom-body"></div>
</div>
......@@ -104,6 +104,18 @@
var u = {};
u.removeElement = function (el) {
if (!_.isNil(el) && !_.isNil(el.parentNode)) {
el.parentNode.removeChild(el);
}
}
u.hideElement = function (el) {
if (!_.isNil(el)) {
el.classList.add('hidden');
}
}
u.addHyperlinks = function (text) {
const list = text.match(URL_REGEX) || [];
var links = [];
......
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