Commit 7199e63f authored by JC Brand's avatar JC Brand

Move converse-profile plugin into folder

parent 85bd192f
......@@ -23,7 +23,7 @@ import "./plugins/muc-views/index.js"; // Views related to MUC
import "./plugins/headlines-view/index.js";
import "./plugins/notifications.js";
import "./plugins/omemo.js";
import "./plugins/profile.js";
import "./plugins/profile/index.js";
import "./plugins/push.js"; // XEP-0357 Push Notifications
import "./plugins/register/index.js"; // XEP-0077 In-band registration
import "./plugins/roomslist/index.js"; // Show currently open chat rooms
......
......@@ -5,7 +5,7 @@
*/
/* global libsignal */
import "./profile.js";
import "./profile/index.js";
import '../modals/user-details.js';
import log from "@converse/headless/log";
import { Collection } from "@converse/skeletor/src/collection";
......
/**
* @module converse-profile
* @copyright The Converse.js contributors
* @license Mozilla Public License (MPLv2)
*/
import "../modals/chat-status.js";
import "../modals/profile.js";
import "./modal.js";
import "@converse/headless/plugins/status";
import "@converse/headless/plugins/vcard";
import UserSettingsModal from "../modals/user-settings";
import tpl_profile from "../templates/profile.js";
import { __ } from '../i18n';
import { _converse, api, converse } from "@converse/headless/core";
converse.plugins.add('converse-profile', {
dependencies: ["converse-status", "converse-modal", "converse-vcard", "converse-chatboxviews"],
initialize () {
/* The initialize function gets called as soon as the plugin is
* loaded by converse.js's plugin machinery.
*/
api.settings.extend({
'allow_adhoc_commands': true,
'show_client_info': true
});
_converse.XMPPStatusView = _converse.ViewWithAvatar.extend({
tagName: "div",
events: {
"click a.show-profile": "showProfileModal",
"click a.change-status": "showStatusChangeModal",
"click .logout": "logOut"
},
initialize () {
this.listenTo(this.model, "change", this.render);
this.listenTo(this.model.vcard, "change", this.render);
},
toHTML () {
const chat_status = this.model.get('status') || 'offline';
return tpl_profile(Object.assign(
this.model.toJSON(),
this.model.vcard.toJSON(), {
chat_status,
'fullname': this.model.vcard.get('fullname') || _converse.bare_jid,
"showUserSettingsModal": ev => this.showUserSettingsModal(ev),
'status_message': this.model.get('status_message') ||
__("I am %1$s", this.getPrettyStatus(chat_status)),
}));
},
afterRender () {
this.renderAvatar();
},
showProfileModal (ev) {
ev.preventDefault();
api.modal.show(_converse.ProfileModal, {model: this.model}, ev);
},
showStatusChangeModal (ev) {
ev.preventDefault();
api.modal.show(_converse.ChatStatusModal, {model: this.model}, ev);
},
showUserSettingsModal(ev) {
ev.preventDefault();
api.modal.show(UserSettingsModal, {model: this.model, _converse}, ev);
},
logOut (ev) {
ev.preventDefault();
const result = confirm(__("Are you sure you want to log out?"));
if (result === true) {
api.user.logout();
}
},
getPrettyStatus (stat) {
if (stat === 'chat') {
return __('online');
} else if (stat === 'dnd') {
return __('busy');
} else if (stat === 'xa') {
return __('away for long');
} else if (stat === 'away') {
return __('away');
} else if (stat === 'offline') {
return __('offline');
} else {
return __(stat) || __('online');
}
}
});
/******************** Event Handlers ********************/
api.listen.on('controlBoxPaneInitialized', async view => {
await api.waitUntil('VCardsInitialized');
_converse.xmppstatusview = new _converse.XMPPStatusView({'model': _converse.xmppstatus});
view.el.insertAdjacentElement('afterBegin', _converse.xmppstatusview.render().el);
});
}
});
/**
* @copyright The Converse.js contributors
* @license Mozilla Public License (MPLv2)
*/
import "modals/chat-status.js";
import "modals/profile.js";
import "../modal.js";
import "@converse/headless/plugins/status";
import "@converse/headless/plugins/vcard";
import XMPPStatusView from './statusview.js';
import { _converse, api, converse } from "@converse/headless/core";
converse.plugins.add('converse-profile', {
dependencies: ["converse-status", "converse-modal", "converse-vcard", "converse-chatboxviews"],
initialize () {
api.settings.extend({
'allow_adhoc_commands': true,
'show_client_info': true
});
_converse.XMPPStatusView = XMPPStatusView;
/******************** Event Handlers ********************/
api.listen.on('controlBoxPaneInitialized', async view => {
await api.waitUntil('VCardsInitialized');
_converse.xmppstatusview = new _converse.XMPPStatusView({'model': _converse.xmppstatus});
view.el.insertAdjacentElement('afterBegin', _converse.xmppstatusview.render().el);
});
}
});
import UserSettingsModal from "modals/user-settings";
import ViewWithAvatar from 'shared/avatar.js';
import tpl_profile from "./templates/profile.js";
import { __ } from 'i18n';
import { _converse, api } from "@converse/headless/core";
const XMPPStatusView = ViewWithAvatar.extend({
tagName: "div",
events: {
"click a.show-profile": "showProfileModal",
"click a.change-status": "showStatusChangeModal",
"click .logout": "logOut"
},
initialize () {
this.listenTo(this.model, "change", this.render);
this.listenTo(this.model.vcard, "change", this.render);
},
toHTML () {
const chat_status = this.model.get('status') || 'offline';
return tpl_profile(Object.assign(
this.model.toJSON(),
this.model.vcard.toJSON(), {
chat_status,
'fullname': this.model.vcard.get('fullname') || _converse.bare_jid,
"showUserSettingsModal": ev => this.showUserSettingsModal(ev),
'status_message': this.model.get('status_message') ||
__("I am %1$s", this.getPrettyStatus(chat_status)),
}));
},
afterRender () {
this.renderAvatar();
},
showProfileModal (ev) {
ev.preventDefault();
api.modal.show(_converse.ProfileModal, {model: this.model}, ev);
},
showStatusChangeModal (ev) {
ev.preventDefault();
api.modal.show(_converse.ChatStatusModal, {model: this.model}, ev);
},
showUserSettingsModal(ev) {
ev.preventDefault();
api.modal.show(UserSettingsModal, {model: this.model, _converse}, ev);
},
logOut (ev) {
ev.preventDefault();
const result = confirm(__("Are you sure you want to log out?"));
if (result === true) {
api.user.logout();
}
},
getPrettyStatus (stat) {
if (stat === 'chat') {
return __('online');
} else if (stat === 'dnd') {
return __('busy');
} else if (stat === 'xa') {
return __('away for long');
} else if (stat === 'away') {
return __('away');
} else if (stat === 'offline') {
return __('offline');
} else {
return __(stat) || __('online');
}
}
});
export default XMPPStatusView;
import { __ } from '../i18n';
import { __ } from 'i18n';
import { api } from "@converse/headless/core";
import { html } from "lit-html";
......
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