// Converse.js (A browser based XMPP chat client) // http://conversejs.org // // Copyright (c) 2012-2017, Jan-Carel Brand // Licensed under the Mozilla Public License (MPLv2) // /*global define */ (function (root, factory) { define(["converse-core", "tpl!change_status_message", "tpl!chat_status", "tpl!choose_status", "tpl!status_option", "converse-vcard" ], factory); }(this, function ( converse, tpl_change_status_message, tpl_chat_status, tpl_choose_status, tpl_status_option ) { "use strict"; const { Strophe, Backbone, Promise, utils, _, moment } = converse.env; converse.plugins.add('converse-profile', { initialize () { /* The initialize function gets called as soon as the plugin is * loaded by converse.js's plugin machinery. */ const { _converse } = this, { __ } = _converse; _converse.XMPPStatusView = Backbone.View.extend({ el: "form#set-xmpp-status", events: { "click a.choose-xmpp-status": "toggleOptions", "click #fancy-xmpp-status-select a.change-xmpp-status-message": "renderStatusChangeForm", "submit": "setStatusMessage", "click .dropdown dd ul li a": "setStatus" }, initialize () { this.model.on("change:status", this.updateStatusUI, this); this.model.on("change:status_message", this.updateStatusUI, this); this.model.on("update-status-ui", this.updateStatusUI, this); }, render () { // Replace the default dropdown with something nicer const select = this.el.querySelector('select#select-xmpp-status') const chat_status = this.model.get('status') || 'offline'; this.el.innerHTML = tpl_choose_status(); this.el.querySelector('#fancy-xmpp-status-select') .innerHTML = tpl_chat_status({ 'status_message': this.model.get('status_message') || __("I am %1$s", this.getPrettyStatus(chat_status)), 'chat_status': chat_status, 'desc_custom_status': __('Click here to write a custom status message'), 'desc_change_status': __('Click to change your chat status') }); // iterate through all the