2020-04-10 11:18:26 +00:00
|
|
|
/**
|
|
|
|
* Calls window
|
|
|
|
*
|
|
|
|
* @author Pierre Hubert
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2020-04-10 11:51:36 +00:00
|
|
|
class CallWindow extends CustomEvents {
|
2020-04-10 11:18:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new call window
|
|
|
|
*
|
|
|
|
* @param {Conversation} conv Information about the target conversation
|
|
|
|
*/
|
|
|
|
constructor(conv) {
|
2020-04-10 11:51:36 +00:00
|
|
|
super()
|
2020-04-10 11:18:26 +00:00
|
|
|
this.construct(conv);
|
|
|
|
}
|
|
|
|
|
|
|
|
async construct(conv) {
|
|
|
|
// Check if calls target exists or not
|
|
|
|
if(!byId("callsTarget"))
|
|
|
|
createElem2({
|
|
|
|
appendTo: byId("wrapper"),
|
|
|
|
type: "div",
|
|
|
|
id: "callsTarget",
|
|
|
|
})
|
|
|
|
|
|
|
|
this.conv = conv;
|
|
|
|
|
|
|
|
this.rootEl = createElem2({
|
|
|
|
appendTo: byId("callsTarget"),
|
|
|
|
type: "div",
|
|
|
|
class: "call-window"
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// Construct head
|
|
|
|
const windowHead = createElem2({
|
|
|
|
appendTo: this.rootEl,
|
|
|
|
type: "div",
|
|
|
|
class: "head",
|
|
|
|
innerHTML: "<i class='fa fa-phone'></i>" +
|
|
|
|
await getConvName(conv) +
|
|
|
|
" <span class='pull-right'></span>"
|
|
|
|
})
|
|
|
|
|
|
|
|
// Close button
|
|
|
|
this.closeButton = createElem2({
|
|
|
|
appendTo: windowHead.querySelector(".pull-right"),
|
|
|
|
type: "a",
|
2020-04-10 11:57:43 +00:00
|
|
|
innerHTML: "<i class='fa fa-times'></i>",
|
2020-04-10 11:51:36 +00:00
|
|
|
onclick: () => this.Close()
|
2020-04-10 11:18:26 +00:00
|
|
|
})
|
2020-04-10 11:51:36 +00:00
|
|
|
|
2020-04-10 11:18:26 +00:00
|
|
|
}
|
|
|
|
|
2020-04-10 11:51:36 +00:00
|
|
|
/**
|
|
|
|
* Close this window & cancel the call
|
|
|
|
*
|
|
|
|
* @param {boolean} propagate Set to true to propagate
|
|
|
|
* the event
|
|
|
|
*/
|
|
|
|
Close(propagate = true) {
|
|
|
|
this.rootEl.remove();
|
|
|
|
|
|
|
|
if(propagate)
|
2020-04-10 11:57:43 +00:00
|
|
|
this.emitEvent("close");
|
2020-04-10 11:51:36 +00:00
|
|
|
}
|
2020-04-10 11:18:26 +00:00
|
|
|
}
|