|
|
|
@ -1,6 +1,10 @@
|
|
|
|
|
/*
|
|
|
|
|
* vim: ts=4:sw=4:expandtab
|
|
|
|
|
*/
|
|
|
|
|
/* global ConversationController: false */
|
|
|
|
|
/* global extension: false */
|
|
|
|
|
/* global getInboxCollection: false */
|
|
|
|
|
/* global i18n: false */
|
|
|
|
|
/* global Whisper: false */
|
|
|
|
|
|
|
|
|
|
// eslint-disable-next-line func-names
|
|
|
|
|
(function () {
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
@ -8,86 +12,88 @@
|
|
|
|
|
|
|
|
|
|
Whisper.ConversationStack = Whisper.View.extend({
|
|
|
|
|
className: 'conversation-stack',
|
|
|
|
|
open: function(conversation) {
|
|
|
|
|
var id = 'conversation-' + conversation.cid;
|
|
|
|
|
open(conversation) {
|
|
|
|
|
const id = `conversation-${conversation.cid}`;
|
|
|
|
|
if (id !== this.el.firstChild.id) {
|
|
|
|
|
this.$el.first().find('video, audio').each(function() {
|
|
|
|
|
this.$el.first().find('video, audio').each(function pauseMedia() {
|
|
|
|
|
this.pause();
|
|
|
|
|
});
|
|
|
|
|
var $el = this.$('#'+id);
|
|
|
|
|
let $el = this.$(`#${id}`);
|
|
|
|
|
if ($el === null || $el.length === 0) {
|
|
|
|
|
var view = new Whisper.ConversationView({
|
|
|
|
|
const view = new Whisper.ConversationView({
|
|
|
|
|
model: conversation,
|
|
|
|
|
window: this.model.window
|
|
|
|
|
window: this.model.window,
|
|
|
|
|
});
|
|
|
|
|
// eslint-disable-next-line prefer-destructuring
|
|
|
|
|
$el = view.$el;
|
|
|
|
|
}
|
|
|
|
|
$el.prependTo(this.el);
|
|
|
|
|
conversation.trigger('opened');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Whisper.FontSizeView = Whisper.View.extend({
|
|
|
|
|
defaultSize: 14,
|
|
|
|
|
maxSize: 30,
|
|
|
|
|
minSize: 14,
|
|
|
|
|
initialize: function() {
|
|
|
|
|
initialize() {
|
|
|
|
|
this.currentSize = this.defaultSize;
|
|
|
|
|
this.render();
|
|
|
|
|
},
|
|
|
|
|
events: { 'keydown': 'zoomText' },
|
|
|
|
|
zoomText: function(e) {
|
|
|
|
|
events: { keydown: 'zoomText' },
|
|
|
|
|
zoomText(e) {
|
|
|
|
|
if (!e.ctrlKey) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
var keyCode = e.which || e.keyCode;
|
|
|
|
|
var maxSize = 22; // if bigger text goes outside send-message textarea
|
|
|
|
|
var minSize = 14;
|
|
|
|
|
if (keyCode === 189 || keyCode == 109) {
|
|
|
|
|
const keyCode = e.which || e.keyCode;
|
|
|
|
|
const maxSize = 22; // if bigger text goes outside send-message textarea
|
|
|
|
|
const minSize = 14;
|
|
|
|
|
if (keyCode === 189 || keyCode === 109) {
|
|
|
|
|
if (this.currentSize > minSize) {
|
|
|
|
|
this.currentSize--;
|
|
|
|
|
this.currentSize -= 1;
|
|
|
|
|
}
|
|
|
|
|
} else if (keyCode === 187 || keyCode == 107) {
|
|
|
|
|
} else if (keyCode === 187 || keyCode === 107) {
|
|
|
|
|
if (this.currentSize < maxSize) {
|
|
|
|
|
this.currentSize++;
|
|
|
|
|
this.currentSize += 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.render();
|
|
|
|
|
},
|
|
|
|
|
render: function() {
|
|
|
|
|
this.$el.css('font-size', this.currentSize + 'px');
|
|
|
|
|
}
|
|
|
|
|
render() {
|
|
|
|
|
this.$el.css('font-size', `${this.currentSize}px`);
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Whisper.AppLoadingScreen = Whisper.View.extend({
|
|
|
|
|
templateName: 'app-loading-screen',
|
|
|
|
|
className: 'app-loading-screen',
|
|
|
|
|
updateProgress: function(count) {
|
|
|
|
|
updateProgress(count) {
|
|
|
|
|
if (count > 0) {
|
|
|
|
|
var message = i18n('loadingMessages', count.toString());
|
|
|
|
|
const message = i18n('loadingMessages', count.toString());
|
|
|
|
|
this.$('.message').text(message);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
render_attributes: {
|
|
|
|
|
message: i18n('loading')
|
|
|
|
|
}
|
|
|
|
|
message: i18n('loading'),
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Whisper.InboxView = Whisper.View.extend({
|
|
|
|
|
templateName: 'two-column',
|
|
|
|
|
className: 'inbox index',
|
|
|
|
|
initialize: function (options) {
|
|
|
|
|
options = options || {};
|
|
|
|
|
|
|
|
|
|
initialize(options = {}) {
|
|
|
|
|
this.ready = false;
|
|
|
|
|
this.render();
|
|
|
|
|
this.$el.attr('tabindex', '1');
|
|
|
|
|
|
|
|
|
|
// eslint-disable-next-line no-new
|
|
|
|
|
new Whisper.FontSizeView({ el: this.$el });
|
|
|
|
|
|
|
|
|
|
this.conversation_stack = new Whisper.ConversationStack({
|
|
|
|
|
el: this.$('.conversation-stack'),
|
|
|
|
|
model: { window: options.window }
|
|
|
|
|
model: { window: options.window },
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (!options.initialLoadComplete) {
|
|
|
|
@ -97,15 +103,15 @@
|
|
|
|
|
this.startConnectionListener();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var inboxCollection = getInboxCollection();
|
|
|
|
|
const inboxCollection = getInboxCollection();
|
|
|
|
|
|
|
|
|
|
inboxCollection.on('messageError', function() {
|
|
|
|
|
inboxCollection.on('messageError', () => {
|
|
|
|
|
this.networkStatusView.render();
|
|
|
|
|
}.bind(this));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.inboxListView = new Whisper.ConversationListView({
|
|
|
|
|
el : this.$('.inbox'),
|
|
|
|
|
collection : inboxCollection
|
|
|
|
|
el: this.$('.inbox'),
|
|
|
|
|
collection: inboxCollection,
|
|
|
|
|
}).render();
|
|
|
|
|
|
|
|
|
|
this.inboxListView.listenTo(
|
|
|
|
@ -120,45 +126,49 @@
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
this.searchView = new Whisper.ConversationSearchView({
|
|
|
|
|
el : this.$('.search-results'),
|
|
|
|
|
input : this.$('input.search')
|
|
|
|
|
el: this.$('.search-results'),
|
|
|
|
|
input: this.$('input.search'),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.searchView.$el.hide();
|
|
|
|
|
|
|
|
|
|
this.listenTo(this.searchView, 'hide', function() {
|
|
|
|
|
this.listenTo(this.searchView, 'hide', function toggleVisibility() {
|
|
|
|
|
this.searchView.$el.hide();
|
|
|
|
|
this.inboxListView.$el.show();
|
|
|
|
|
});
|
|
|
|
|
this.listenTo(this.searchView, 'show', function() {
|
|
|
|
|
this.listenTo(this.searchView, 'show', function toggleVisibility() {
|
|
|
|
|
this.searchView.$el.show();
|
|
|
|
|
this.inboxListView.$el.hide();
|
|
|
|
|
});
|
|
|
|
|
this.listenTo(this.searchView, 'open',
|
|
|
|
|
this.openConversation.bind(this, null));
|
|
|
|
|
this.listenTo(
|
|
|
|
|
this.searchView,
|
|
|
|
|
'open',
|
|
|
|
|
this.openConversation.bind(this, null)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
this.networkStatusView = new Whisper.NetworkStatusView();
|
|
|
|
|
this.$el.find('.network-status-container').append(this.networkStatusView.render().el);
|
|
|
|
|
this.$el.find('.network-status-container')
|
|
|
|
|
.append(this.networkStatusView.render().el);
|
|
|
|
|
|
|
|
|
|
extension.windows.onClosed(function() {
|
|
|
|
|
extension.windows.onClosed(() => {
|
|
|
|
|
this.inboxListView.stopListening();
|
|
|
|
|
}.bind(this));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (extension.expired()) {
|
|
|
|
|
var banner = new Whisper.ExpiredAlertBanner().render();
|
|
|
|
|
const banner = new Whisper.ExpiredAlertBanner().render();
|
|
|
|
|
banner.$el.prependTo(this.$el);
|
|
|
|
|
this.$el.addClass('expired');
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
render_attributes: {
|
|
|
|
|
welcomeToSignal : i18n('welcomeToSignal'),
|
|
|
|
|
selectAContact : i18n('selectAContact'),
|
|
|
|
|
searchForPeopleOrGroups : i18n('searchForPeopleOrGroups'),
|
|
|
|
|
settings : i18n('settings'),
|
|
|
|
|
restartSignal : i18n('restartSignal'),
|
|
|
|
|
welcomeToSignal: i18n('welcomeToSignal'),
|
|
|
|
|
selectAContact: i18n('selectAContact'),
|
|
|
|
|
searchForPeopleOrGroups: i18n('searchForPeopleOrGroups'),
|
|
|
|
|
settings: i18n('settings'),
|
|
|
|
|
restartSignal: i18n('restartSignal'),
|
|
|
|
|
},
|
|
|
|
|
events: {
|
|
|
|
|
'click': 'onClick',
|
|
|
|
|
click: 'onClick',
|
|
|
|
|
'click #header': 'focusHeader',
|
|
|
|
|
'click .conversation': 'focusConversation',
|
|
|
|
|
'click .global-menu .hamburger': 'toggleMenu',
|
|
|
|
@ -168,10 +178,10 @@
|
|
|
|
|
'click .restart-signal': window.restart,
|
|
|
|
|
'show .lightbox': 'showLightbox',
|
|
|
|
|
},
|
|
|
|
|
startConnectionListener: function() {
|
|
|
|
|
this.interval = setInterval(function() {
|
|
|
|
|
var status = window.getSocketStatus();
|
|
|
|
|
switch(status) {
|
|
|
|
|
startConnectionListener() {
|
|
|
|
|
this.interval = setInterval(() => {
|
|
|
|
|
const status = window.getSocketStatus();
|
|
|
|
|
switch (status) {
|
|
|
|
|
case WebSocket.CONNECTING:
|
|
|
|
|
break;
|
|
|
|
|
case WebSocket.OPEN:
|
|
|
|
@ -186,23 +196,29 @@
|
|
|
|
|
// if we failed to connect, we pretend we got an empty event
|
|
|
|
|
this.onEmpty();
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
console.log(
|
|
|
|
|
'Whisper.InboxView::startConnectionListener:',
|
|
|
|
|
'Unknown web socket status:', status
|
|
|
|
|
);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}.bind(this), 1000);
|
|
|
|
|
}, 1000);
|
|
|
|
|
},
|
|
|
|
|
onEmpty: function() {
|
|
|
|
|
var view = this.appLoadingScreen;
|
|
|
|
|
onEmpty() {
|
|
|
|
|
const view = this.appLoadingScreen;
|
|
|
|
|
if (view) {
|
|
|
|
|
this.appLoadingScreen = null;
|
|
|
|
|
view.remove();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
onProgress: function(count) {
|
|
|
|
|
var view = this.appLoadingScreen;
|
|
|
|
|
onProgress(count) {
|
|
|
|
|
const view = this.appLoadingScreen;
|
|
|
|
|
if (view) {
|
|
|
|
|
view.updateProgress(count);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
focusConversation: function(e) {
|
|
|
|
|
focusConversation(e) {
|
|
|
|
|
if (e && this.$(e.target).closest('.placeholder').length) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@ -210,24 +226,24 @@
|
|
|
|
|
this.$('#header, .gutter').addClass('inactive');
|
|
|
|
|
this.$('.conversation-stack').removeClass('inactive');
|
|
|
|
|
},
|
|
|
|
|
focusHeader: function() {
|
|
|
|
|
focusHeader() {
|
|
|
|
|
this.$('.conversation-stack').addClass('inactive');
|
|
|
|
|
this.$('#header, .gutter').removeClass('inactive');
|
|
|
|
|
this.$('.conversation:first .menu').trigger('close');
|
|
|
|
|
},
|
|
|
|
|
reloadBackgroundPage: function() {
|
|
|
|
|
reloadBackgroundPage() {
|
|
|
|
|
window.location.reload();
|
|
|
|
|
},
|
|
|
|
|
showSettings: function() {
|
|
|
|
|
var view = new Whisper.SettingsView();
|
|
|
|
|
showSettings() {
|
|
|
|
|
const view = new Whisper.SettingsView();
|
|
|
|
|
view.$el.appendTo(this.el);
|
|
|
|
|
},
|
|
|
|
|
filterContacts: function(e) {
|
|
|
|
|
filterContacts(e) {
|
|
|
|
|
this.searchView.filterContacts(e);
|
|
|
|
|
var input = this.$('input.search');
|
|
|
|
|
const input = this.$('input.search');
|
|
|
|
|
if (input.val().length > 0) {
|
|
|
|
|
input.addClass('active');
|
|
|
|
|
var textDir = window.getComputedStyle(input[0]).direction;
|
|
|
|
|
const textDir = window.getComputedStyle(input[0]).direction;
|
|
|
|
|
if (textDir === 'ltr') {
|
|
|
|
|
input.removeClass('rtl').addClass('ltr');
|
|
|
|
|
} else if (textDir === 'rtl') {
|
|
|
|
@ -237,47 +253,46 @@
|
|
|
|
|
input.removeClass('active');
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
openConversation: function(e, conversation) {
|
|
|
|
|
openConversation(e, conversation) {
|
|
|
|
|
this.searchView.hideHints();
|
|
|
|
|
if (conversation) {
|
|
|
|
|
conversation = ConversationController.get(conversation.id);
|
|
|
|
|
this.conversation_stack.open(conversation);
|
|
|
|
|
this.conversation_stack.open(ConversationController.get(conversation.id));
|
|
|
|
|
this.focusConversation();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
toggleMenu: function() {
|
|
|
|
|
toggleMenu() {
|
|
|
|
|
this.$('.global-menu .menu-list').toggle();
|
|
|
|
|
},
|
|
|
|
|
showLightbox: function(e) {
|
|
|
|
|
showLightbox(e) {
|
|
|
|
|
this.$el.append(e.target);
|
|
|
|
|
},
|
|
|
|
|
closeRecording: function(e) {
|
|
|
|
|
if (e && this.$(e.target).closest('.capture-audio').length > 0 ) {
|
|
|
|
|
closeRecording(e) {
|
|
|
|
|
if (e && this.$(e.target).closest('.capture-audio').length > 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.$('.conversation:first .recorder').trigger('close');
|
|
|
|
|
},
|
|
|
|
|
closeMenu: function(e) {
|
|
|
|
|
if (e && this.$(e.target).parent('.global-menu').length > 0 ) {
|
|
|
|
|
closeMenu(e) {
|
|
|
|
|
if (e && this.$(e.target).parent('.global-menu').length > 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.$('.global-menu .menu-list').hide();
|
|
|
|
|
},
|
|
|
|
|
onClick: function(e) {
|
|
|
|
|
onClick(e) {
|
|
|
|
|
this.closeMenu(e);
|
|
|
|
|
this.closeRecording(e);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Whisper.ExpiredAlertBanner = Whisper.View.extend({
|
|
|
|
|
templateName: 'expired_alert',
|
|
|
|
|
className: 'expiredAlert clearfix',
|
|
|
|
|
render_attributes: function() {
|
|
|
|
|
render_attributes() {
|
|
|
|
|
return {
|
|
|
|
|
expiredWarning: i18n('expiredWarning'),
|
|
|
|
|
upgrade: i18n('upgrade'),
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
})();
|
|
|
|
|
}());
|
|
|
|
|