Commit 9fb2d279 authored by JC Brand's avatar JC Brand

Replace VDOMView with HTMLView

parent 393a96cf
...@@ -197,12 +197,6 @@ converse.plugins.add('converse-bookmark-views', { ...@@ -197,12 +197,6 @@ converse.plugins.add('converse-bookmark-views', {
_converse.BookmarksView = HTMLView.extend({ _converse.BookmarksView = HTMLView.extend({
tagName: 'span', tagName: 'span',
events: {
'click .add-bookmark': 'addBookmark',
'click .bookmarks-toggle': 'toggleBookmarksList',
'click .remove-bookmark': 'removeBookmark',
'click .open-room': 'openRoom',
},
initialize () { initialize () {
this.listenTo(this.model, 'add', this.render); this.listenTo(this.model, 'add', this.render);
...@@ -223,14 +217,16 @@ converse.plugins.add('converse-bookmark-views', { ...@@ -223,14 +217,16 @@ converse.plugins.add('converse-bookmark-views', {
}, },
toHTML () { toHTML () {
const is_hidden = b => !!(_converse.hide_open_bookmarks && _converse.chatboxes.get(b.get('jid')));
return tpl_bookmarks_list({ return tpl_bookmarks_list({
'_converse': _converse, '_converse': _converse,
'bookmarks': this.model, 'bookmarks': this.model,
'toggle_state': this.list_model.get('toggle-state'), 'hidden': this.model.getUnopenedBookmarks().length && true,
'is_bookmark_hidden': b => { 'is_hidden': is_hidden,
return !!(_converse.hide_open_bookmarks && _converse.chatboxes.get(b.get('jid'))) 'openRoom': ev => this.openRoom(ev),
}, 'removeBookmark': ev => this.removeBookmark(ev),
'hidden': this.model.getUnopenedBookmarks().length && true 'toggleBookmarksList': ev => this.toggleBookmarksList(ev),
'toggle_state': this.list_model.get('toggle-state')
}); });
}, },
...@@ -253,7 +249,6 @@ converse.plugins.add('converse-bookmark-views', { ...@@ -253,7 +249,6 @@ converse.plugins.add('converse-bookmark-views', {
}, },
removeBookmark: _converse.removeBookmarkViaEvent, removeBookmark: _converse.removeBookmarkViaEvent,
addBookmark: _converse.addBookmarkViaEvent,
toggleBookmarksList (ev) { toggleBookmarksList (ev) {
if (ev && ev.preventDefault) { ev.preventDefault(); } if (ev && ev.preventDefault) { ev.preventDefault(); }
......
...@@ -12,6 +12,7 @@ import { get, head, isString, isUndefined, pick } from "lodash"; ...@@ -12,6 +12,7 @@ import { get, head, isString, isUndefined, pick } from "lodash";
import { Model } from 'skeletor.js/src/model.js'; import { Model } from 'skeletor.js/src/model.js';
import { OrderedListView } from "skeletor.js/src/overview"; import { OrderedListView } from "skeletor.js/src/overview";
import { View } from "skeletor.js/src/view"; import { View } from "skeletor.js/src/view";
import { __ } from '@converse/headless/i18n';
import converse from "@converse/headless/converse-core"; import converse from "@converse/headless/converse-core";
import log from "@converse/headless/log"; import log from "@converse/headless/log";
import tpl_add_chatroom_modal from "templates/add_chatroom_modal.js"; import tpl_add_chatroom_modal from "templates/add_chatroom_modal.js";
...@@ -92,8 +93,7 @@ converse.plugins.add('converse-muc-views', { ...@@ -92,8 +93,7 @@ converse.plugins.add('converse-muc-views', {
}, },
initialize () { initialize () {
const { _converse } = this, const { _converse } = this;
{ __ } = _converse;
_converse.api.promises.add(['roomsPanelRendered']); _converse.api.promises.add(['roomsPanelRendered']);
......
...@@ -9,10 +9,11 @@ ...@@ -9,10 +9,11 @@
import "@converse/headless/converse-muc"; import "@converse/headless/converse-muc";
import { Model } from 'skeletor.js/src/model.js'; import { Model } from 'skeletor.js/src/model.js';
import { HTMLView } from 'skeletor.js/src/htmlview.js'; import { HTMLView } from 'skeletor.js/src/htmlview.js';
import { __ } from '@converse/headless/i18n';
import converse from "@converse/headless/converse-core"; import converse from "@converse/headless/converse-core";
import tpl_rooms_list from "templates/rooms_list.js"; import tpl_rooms_list from "templates/rooms_list.js";
const { Strophe, } = converse.env; const { Strophe } = converse.env;
const u = converse.env.utils; const u = converse.env.utils;
......
...@@ -9,17 +9,25 @@ const open_title = __('Click to open this groupchat'); ...@@ -9,17 +9,25 @@ const open_title = __('Click to open this groupchat');
const bookmark_item = (o) => html` const bookmark_item = (o) => html`
<div class="list-item controlbox-padded room-item available-chatroom d-flex flex-row ${ (o.is_bookmark_hidden(o.bm)) ? 'hidden' : ''}" data-room-jid="${o.bm.get('jid')}"> <div class="list-item controlbox-padded room-item available-chatroom d-flex flex-row ${ (o.is_hidden(o.bm)) ? 'hidden' : ''}" data-room-jid="${o.bm.get('jid')}">
<a class="list-item-link open-room w-100" data-room-jid="${o.bm.get('jid')}" title="${open_title}" href="#">${o.bm.getDisplayName()}</a> <a class="list-item-link open-room w-100" data-room-jid="${o.bm.get('jid')}"
title="${open_title}"
@click=${o.openRoom}>${o.bm.getDisplayName()}</a>
<a class="list-item-action remove-bookmark fa fa-bookmark align-self-center ${ o.bm.get('bookmarked') ? 'button-on' : '' }" <a class="list-item-action remove-bookmark fa fa-bookmark align-self-center ${ o.bm.get('bookmarked') ? 'button-on' : '' }"
data-room-jid="${o.bm.get('jid')}" data-bookmark-name="${o.bm.getDisplayName()}" data-room-jid="${o.bm.get('jid')}"
title="${info_remove_bookmark}" href="#"></a> data-bookmark-name="${o.bm.getDisplayName()}"
title="${info_remove_bookmark}"
@click=${o.removeBookmark}></a>
</div> </div>
`; `;
export default (o) => html` export default (o) => html`
<div class="list-container list-container--bookmarks ${ !o.hidden && 'hidden' || '' }"> <div class="list-container list-container--bookmarks ${ !o.hidden && 'hidden' || '' }">
<a href="#" class="list-toggle bookmarks-toggle controlbox-padded" title="${desc_bookmarks}"> <a class="list-toggle bookmarks-toggle controlbox-padded"
title="${desc_bookmarks}"
@click=${o.toggleBookmarksList}>
<span class="fa ${(o.toggle_state === o._converse.OPENED) ? 'fa-caret-down' : 'fa-caret-right' }"> <span class="fa ${(o.toggle_state === o._converse.OPENED) ? 'fa-caret-down' : 'fa-caret-right' }">
</span> ${label_bookmarks}</a> </span> ${label_bookmarks}</a>
<div class="items-list bookmarks rooms-list ${ (o.toggle_state !== o._converse.OPENED) ? 'hidden' : '' }"> <div class="items-list bookmarks rooms-list ${ (o.toggle_state !== o._converse.OPENED) ? 'hidden' : '' }">
......
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