Commit b6b00887 authored by JC Brand's avatar JC Brand

Export BootstrapModal

parent c9f29f76
......@@ -6,8 +6,9 @@
import "converse-chatboxviews";
import "converse-message-view";
import "converse-modal";
import { debounce, get, isString } from "lodash";
import { BootstrapModal } from "./converse-modal.js";
import { Overview } from "skeletor.js/src/overview";
import { debounce, get, isString } from "lodash";
import { html, render } from "lit-html";
import converse from "@converse/headless/converse-core";
import log from "@converse/headless/log";
......@@ -72,7 +73,7 @@ converse.plugins.add('converse-chatview', {
});
_converse.UserDetailsModal = _converse.BootstrapModal.extend({
_converse.UserDetailsModal = BootstrapModal.extend({
id: "user-details-modal",
events: {
......@@ -81,7 +82,7 @@ converse.plugins.add('converse-chatview', {
},
initialize () {
_converse.BootstrapModal.prototype.initialize.apply(this, arguments);
BootstrapModal.prototype.initialize.apply(this, arguments);
this.model.rosterContactAdded.then(() => this.registerContactEventHandlers());
this.listenTo(this.model, 'change', this.render);
this.registerContactEventHandlers();
......
......@@ -7,7 +7,9 @@ import "./utils/html";
import "@converse/headless/converse-emoji";
import URI from "urijs";
import converse from "@converse/headless/converse-core";
import { BootstrapModal } from "./converse-modal.js";
import { debounce } from 'lodash'
import { render } from "lit-html";
import filesize from "filesize";
import log from "@converse/headless/log";
import tpl_csn from "templates/csn.html";
......@@ -69,7 +71,7 @@ converse.plugins.add('converse-message-view', {
'allow_message_retraction': 'all'
});
_converse.MessageVersionsModal = _converse.BootstrapModal.extend({
_converse.MessageVersionsModal = BootstrapModal.extend({
id: "message-versions-modal",
toHTML () {
return tpl_message_versions_modal(this.model.toJSON());
......
......@@ -7,6 +7,7 @@ import { View } from 'skeletor.js/src/view.js';
import { Model } from 'skeletor.js/src/model.js';
import { isString } from "lodash";
import { render } from 'lit-html';
import { __ } from '@converse/headless/i18n';
import bootstrap from "bootstrap.native";
import converse from "@converse/headless/converse-core";
import log from "@converse/headless/log";
......@@ -17,14 +18,10 @@ import tpl_prompt from "templates/prompt.js";
const { sizzle } = converse.env;
const u = converse.env.utils;
let _converse;
converse.plugins.add('converse-modal', {
initialize () {
const { _converse } = this;
const { __ } = _converse;
_converse.BootstrapModal = View.extend({
export const BootstrapModal = View.extend({
className: "modal",
events: {
'click .nav-item .nav-link': 'switchTab'
......@@ -88,16 +85,17 @@ converse.plugins.add('converse-modal', {
}
this.modal.show();
}
});
});
_converse.Confirm = _converse.BootstrapModal.extend({
export const Confirm = BootstrapModal.extend({
events: {
'submit .confirm': 'onConfimation'
},
initialize () {
this.confirmation = u.getResolveablePromise();
_converse.BootstrapModal.prototype.initialize.apply(this, arguments);
BootstrapModal.prototype.initialize.apply(this, arguments);
this.listenTo(this.model, 'change', this.render)
this.el.addEventListener('closed.bs.modal', () => this.confirmation.reject(), false);
},
......@@ -122,10 +120,10 @@ converse.plugins.add('converse-modal', {
this.confirmation.resolve(true);
this.modal.hide();
}
});
});
_converse.Prompt = _converse.Confirm.extend({
export const Prompt = Confirm.extend({
toHTML () {
return tpl_prompt(this.model.toJSON());
},
......@@ -136,21 +134,26 @@ converse.plugins.add('converse-modal', {
this.confirmation.resolve(form_data.get('reason'));
this.modal.hide();
}
});
});
_converse.Alert = _converse.BootstrapModal.extend({
export const Alert = BootstrapModal.extend({
initialize () {
_converse.BootstrapModal.prototype.initialize.apply(this, arguments);
BootstrapModal.prototype.initialize.apply(this, arguments);
this.listenTo(this.model, 'change', this.render)
},
toHTML () {
return tpl_alert_modal(Object.assign({__}, this.model.toJSON()));
}
});
});
converse.plugins.add('converse-modal', {
initialize () {
_converse = this._converse
/************************ BEGIN Event Listeners ************************/
_converse.api.listen.on('disconnect', () => {
const container = document.querySelector("#converse-modals");
......@@ -182,7 +185,7 @@ converse.plugins.add('converse-modal', {
'messages': messages,
'type': 'confirm'
})
confirm = new _converse.Confirm({model});
confirm = new Confirm({model});
} else {
confirm.confirmation = u.getResolveablePromise();
confirm.model.set({
......@@ -219,7 +222,7 @@ converse.plugins.add('converse-modal', {
'placeholder': placeholder,
'type': 'prompt'
})
prompt = new _converse.Prompt({model});
prompt = new Prompt({model});
} else {
prompt.confirmation = u.getResolveablePromise();
prompt.model.set({
......@@ -263,7 +266,7 @@ converse.plugins.add('converse-modal', {
'level': level,
'type': 'alert'
})
alert = new _converse.Alert({model});
alert = new Alert({model});
} else {
alert.model.set({
'title': title,
......
......@@ -9,6 +9,7 @@ import "@converse/headless/utils/muc";
import { Model } from 'skeletor.js/src/model.js';
import { View } from 'skeletor.js/src/view.js';
import { get, head, isString, isUndefined } from "lodash";
import { BootstrapModal } from "./converse-modal.js";
import { render } from "lit-html";
import { __ } from '@converse/headless/i18n';
import converse from "@converse/headless/converse-core";
......@@ -223,12 +224,12 @@ converse.plugins.add('converse-muc-views', {
}
_converse.ModeratorToolsModal = _converse.BootstrapModal.extend({
_converse.ModeratorToolsModal = BootstrapModal.extend({
id: "converse-modtools-modal",
initialize (attrs) {
this.chatroomview = attrs.chatroomview;
_converse.BootstrapModal.prototype.initialize.apply(this, arguments);
BootstrapModal.prototype.initialize.apply(this, arguments);
this.listenTo(this.model, 'change:role', () => {
this.users_with_role = this.getUsersWithRole();
......@@ -412,7 +413,7 @@ converse.plugins.add('converse-muc-views', {
});
_converse.ListChatRoomsModal = _converse.BootstrapModal.extend({
_converse.ListChatRoomsModal = BootstrapModal.extend({
id: "list-chatrooms-modal",
events: {
......@@ -424,7 +425,7 @@ converse.plugins.add('converse-muc-views', {
},
initialize () {
_converse.BootstrapModal.prototype.initialize.apply(this, arguments);
BootstrapModal.prototype.initialize.apply(this, arguments);
if (_converse.muc_domain && !this.model.get('muc_domain')) {
this.model.save('muc_domain', _converse.muc_domain);
}
......@@ -544,7 +545,7 @@ converse.plugins.add('converse-muc-views', {
});
_converse.AddChatRoomModal = _converse.BootstrapModal.extend({
_converse.AddChatRoomModal = BootstrapModal.extend({
id: 'add-chatroom-modal',
events: {
......@@ -554,7 +555,7 @@ converse.plugins.add('converse-muc-views', {
},
initialize () {
_converse.BootstrapModal.prototype.initialize.apply(this, arguments);
BootstrapModal.prototype.initialize.apply(this, arguments);
this.listenTo(this.model, 'change:muc_domain', this.render);
this.muc_roomid_policy_error_msg = null;
},
......@@ -637,11 +638,11 @@ converse.plugins.add('converse-muc-views', {
});
_converse.RoomDetailsModal = _converse.BootstrapModal.extend({
_converse.RoomDetailsModal = BootstrapModal.extend({
id: "room-details-modal",
initialize () {
_converse.BootstrapModal.prototype.initialize.apply(this, arguments);
BootstrapModal.prototype.initialize.apply(this, arguments);
this.listenTo(this.model, 'change', this.render);
this.listenTo(this.model.features, 'change', this.render);
this.listenTo(this.model.occupants, 'add', this.render);
......@@ -2224,11 +2225,11 @@ converse.plugins.add('converse-muc-views', {
});
_converse.MUCInviteModal = _converse.BootstrapModal.extend({
_converse.MUCInviteModal = BootstrapModal.extend({
id: "muc-invite-modal",
initialize () {
_converse.BootstrapModal.prototype.initialize.apply(this, arguments);
BootstrapModal.prototype.initialize.apply(this, arguments);
this.listenTo(this.model, 'change', this.render);
this.initInviteWidget();
},
......
......@@ -6,6 +6,7 @@
import "@converse/headless/converse-status";
import "@converse/headless/converse-vcard";
import "converse-modal";
import { BootstrapModal } from "./converse-modal.js";
import bootstrap from "bootstrap.native";
import converse from "@converse/headless/converse-core";
import log from "@converse/headless/log";
......@@ -34,7 +35,7 @@ converse.plugins.add('converse-profile', {
});
_converse.ProfileModal = _converse.BootstrapModal.extend({
_converse.ProfileModal = BootstrapModal.extend({
id: "user-profile-modal",
events: {
'change input[type="file"': "updateFilePreview",
......@@ -44,7 +45,7 @@ converse.plugins.add('converse-profile', {
initialize () {
this.listenTo(this.model, 'change', this.render);
_converse.BootstrapModal.prototype.initialize.apply(this, arguments);
BootstrapModal.prototype.initialize.apply(this, arguments);
/**
* Triggered when the _converse.ProfileModal has been created and initialized.
* @event _converse#profileModalInitialized
......@@ -128,7 +129,7 @@ converse.plugins.add('converse-profile', {
});
_converse.ChatStatusModal = _converse.BootstrapModal.extend({
_converse.ChatStatusModal = BootstrapModal.extend({
id: "modal-status-change",
events: {
"submit form#set-xmpp-status": "onFormSubmitted",
......@@ -180,7 +181,7 @@ converse.plugins.add('converse-profile', {
}
});
_converse.ClientInfoModal = _converse.BootstrapModal.extend({
_converse.ClientInfoModal = BootstrapModal.extend({
id: "converse-client-info-modal",
toHTML () {
......
......@@ -7,6 +7,7 @@ import "@converse/headless/converse-chatboxes";
import "@converse/headless/converse-roster";
import "converse-modal";
import { compact, debounce, has, isString, uniq, without } from "lodash";
import { BootstrapModal } from "./converse-modal.js";
import { View } from 'skeletor.js/src/view.js';
import { Model } from 'skeletor.js/src/model.js';
import { OrderedListView } from "skeletor.js/src/overview";
......@@ -56,14 +57,14 @@ converse.plugins.add('converse-rosterview', {
};
_converse.AddContactModal = _converse.BootstrapModal.extend({
_converse.AddContactModal = BootstrapModal.extend({
id: "add-contact-modal",
events: {
'submit form': 'addContactFromForm'
},
initialize () {
_converse.BootstrapModal.prototype.initialize.apply(this, arguments);
BootstrapModal.prototype.initialize.apply(this, arguments);
this.listenTo(this.model, 'change', this.render);
},
......
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