You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.3 KiB
JavaScript
56 lines
1.3 KiB
JavaScript
5 years ago
|
/* global Whisper */
|
||
|
|
||
|
// eslint-disable-next-line func-names
|
||
|
(function() {
|
||
|
'use strict';
|
||
|
|
||
|
window.Whisper = window.Whisper || {};
|
||
|
|
||
|
Whisper.SessionConfirmView = Whisper.View.extend({
|
||
|
initialize(options) {
|
||
|
this.props = {
|
||
|
title: options.title,
|
||
|
message: options.message,
|
||
|
onClickOk: this.ok.bind(this),
|
||
|
onClickClose: this.cancel.bind(this),
|
||
|
resolve: options.resolve,
|
||
|
reject: options.reject,
|
||
|
okText: options.okText,
|
||
|
cancelText: options.cancelText,
|
||
|
hideCancel: options.hideCancel,
|
||
|
};
|
||
|
},
|
||
|
|
||
|
render() {
|
||
|
this.$('.session-confirm-wrapper').remove();
|
||
|
|
||
|
this.confirmView = new Whisper.ReactWrapperView({
|
||
|
className: 'session-confirm-wrapper',
|
||
|
Component: window.Signal.Components.SessionConfirm,
|
||
|
props: this.props,
|
||
|
});
|
||
|
|
||
|
this.$el.append(this.confirmView.el);
|
||
|
},
|
||
|
|
||
|
ok() {
|
||
|
this.$('.session-confirm-wrapper').remove();
|
||
|
if (this.props.resolve){
|
||
|
this.props.resolve()
|
||
|
}
|
||
|
},
|
||
|
cancel() {
|
||
|
this.$('.session-confirm-wrapper').remove();
|
||
|
if (this.props.reject) {
|
||
|
this.props.reject()
|
||
|
}
|
||
|
},
|
||
|
onKeyup(event) {
|
||
|
if (event.key === 'Escape' || event.key === 'Esc') {
|
||
|
this.cancel();
|
||
|
}
|
||
|
},
|
||
|
|
||
|
});
|
||
|
})();
|