Commit 6c3aa34c authored by JC Brand's avatar JC Brand

Some work on removing jquery from converse-bookmarks

parent 1c80fa41
...@@ -81,7 +81,8 @@ ...@@ -81,7 +81,8 @@
$form.find('input[name="name"]').val('Play's the Thing'); $form.find('input[name="name"]').val('Play's the Thing');
$form.find('input[name="autojoin"]').prop('checked', true); $form.find('input[name="autojoin"]').prop('checked', true);
$form.find('input[name="nick"]').val('JC'); $form.find('input[name="nick"]').val('JC');
$form.submit(); view.$el.find('.button-primary').click();
expect(view.model.get('bookmarked')).toBeTruthy(); expect(view.model.get('bookmarked')).toBeTruthy();
expect($bookmark.hasClass('on-button'), true); expect($bookmark.hasClass('on-button'), true);
......
...@@ -101,10 +101,11 @@ ...@@ -101,10 +101,11 @@
}, },
onBookmarked () { onBookmarked () {
const icon = this.el.querySelector('.icon-pushpin');
if (this.model.get('bookmarked')) { if (this.model.get('bookmarked')) {
this.$('.icon-pushpin').addClass('button-on'); icon.classList.add('button-on');
} else { } else {
this.$('.icon-pushpin').removeClass('button-on'); icon.classList.remove('button-on');
} }
}, },
...@@ -125,11 +126,18 @@ ...@@ -125,11 +126,18 @@
renderBookmarkForm () { renderBookmarkForm () {
const { _converse } = this.__super__, const { _converse } = this.__super__,
{ __ } = _converse, { __ } = _converse,
$body = this.$('.chatroom-body'); body = this.el.querySelector('.chatroom-body');
$body.children().addClass('hidden');
_.each(body.children, function (child) {
child.classList.add('hidden');
});
// Remove any existing forms // Remove any existing forms
$body.find('form.chatroom-form').remove(); let form = body.querySelector('form.chatroom-form');
$body.append( if (!_.isNull(form)) {
form.parentNode.removeChild(form);
}
body.insertAdjacentHTML(
'beforeend',
tpl_chatroom_bookmark_form({ tpl_chatroom_bookmark_form({
heading: __('Bookmark this room'), heading: __('Bookmark this room'),
label_name: __('The name for this bookmark:'), label_name: __('The name for this bookmark:'),
...@@ -138,9 +146,17 @@ ...@@ -138,9 +146,17 @@
default_nick: this.model.get('nick'), default_nick: this.model.get('nick'),
label_submit: __('Save'), label_submit: __('Save'),
label_cancel: __('Cancel') label_cancel: __('Cancel')
})); })
this.$('.chatroom-form').submit(this.onBookmarkFormSubmitted.bind(this)); );
this.$('.chatroom-form .button-cancel').on('click', this.cancelConfiguration.bind(this)); form = body.querySelector('form.chatroom-form');
form.addEventListener(
'submit',
this.onBookmarkFormSubmitted.bind(this)
);
form.querySelector('.button-cancel').addEventListener(
'click',
this.cancelConfiguration.bind(this)
);
}, },
onBookmarkFormSubmitted (ev) { onBookmarkFormSubmitted (ev) {
...@@ -173,7 +189,7 @@ ...@@ -173,7 +189,7 @@
_.forEach(models, function (model) { _.forEach(models, function (model) {
model.destroy(); model.destroy();
}); });
this.$('.icon-pushpin').removeClass('button-on'); this.el.querySelector('.icon-pushpin').classList.remove('button-on');
} }
} }
} }
......
// Converse.js (A browser based XMPP chat client) // Converse.js (A browser based XMPP chat client)
// http://conversejs.org // http://conversejs.org
// //
// Copyright (c) 2012-2016, Jan-Carel Brand <jc@opkode.com> // Copyright (c) JC Brand <jc@opkode.com>
// Licensed under the Mozilla Public License (MPLv2) // Licensed under the Mozilla Public License (MPLv2)
// //
/*global define */ /*global define */
......
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