Set parent window for about/new version, escape to close (#1795)

* Set parent window for about/new version, escape to close

* Exclude jquery from jshint run
This commit is contained in:
Scott Nonnenberg 2017-11-21 15:23:18 -08:00 committed by GitHub
parent 158b575885
commit 1c455c83e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 9241 additions and 6 deletions

View File

@ -96,6 +96,7 @@ module.exports = function(grunt) {
files: [
'Gruntfile.js',
'js/**/*.js',
'!js/jquery.js',
'!js/libtextsecure.js',
'!js/WebAudioRecorderMp3.js',
'!js/Mp3LameEncoder.min.js',
@ -131,6 +132,9 @@ module.exports = function(grunt) {
}, {
src: 'components/webaudiorecorder/lib/WebAudioRecorderMp3.js',
dest: 'js/WebAudioRecorderMp3.js'
}, {
src: 'components/jquery/dist/jquery.js',
dest: 'js/jquery.js'
}],
},
res: {

View File

@ -34,6 +34,16 @@ a {
<a href="https://signal.org">signal.org</a>
</div>
<script type='text/javascript' src='js/jquery.js'></script>
<script>
$(document).on('keyup', function(e) {
if (e.keyCode === 27) {
window.closeAbout();
}
});
</script>
</body>
</html>

View File

@ -19,7 +19,7 @@ function checkForUpdates() {
}
var showingDialog = false;
function showUpdateDialog(messages) {
function showUpdateDialog(mainWindow, messages) {
if (showingDialog) {
return;
}
@ -38,7 +38,7 @@ function showUpdateDialog(messages) {
cancelId: LATER_BUTTON
}
dialog.showMessageBox(options, function(response) {
dialog.showMessageBox(mainWindow, options, function(response) {
if (response == RESTART_BUTTON) {
windowState.markShouldQuit();
autoUpdater.quitAndInstall();
@ -52,7 +52,7 @@ function onError(error) {
console.log("Got an error while updating: ", error.stack);
}
function initialize(messages) {
function initialize(getMainWindow, messages) {
if (!messages) {
throw new Error('auto-update initialize needs localized messages');
}
@ -62,7 +62,7 @@ function initialize(messages) {
}
autoUpdater.addListener('update-downloaded', function() {
showUpdateDialog(messages);
showUpdateDialog(getMainWindow(), messages);
});
autoUpdater.addListener('error', onError);

9205
js/jquery.js vendored Normal file

File diff suppressed because it is too large Load Diff

16
main.js
View File

@ -22,6 +22,10 @@ app.setAppUserModelId('org.whispersystems.signal-desktop')
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow;
function getMainWindow() {
return mainWindow;
}
const config = require("./app/config");
if (config.environment === 'production' && !process.mas) {
@ -241,7 +245,8 @@ function showAbout() {
webPreferences: {
nodeIntegration: false,
preload: path.join(__dirname, 'preload.js')
}
},
parent: mainWindow,
};
aboutWindow = new BrowserWindow(options);
@ -269,7 +274,7 @@ app.on('ready', function() {
locale = loadLocale();
}
autoUpdate.initialize(locale.messages);
autoUpdate.initialize(getMainWindow, locale.messages);
createWindow();
@ -342,3 +347,10 @@ ipc.on("set-auto-hide-menu-bar", function(event, autoHide) {
ipc.on("set-menu-bar-visibility", function(event, visibility) {
mainWindow.setMenuBarVisibility(visibility);
});
ipc.on("close-about", function() {
if (aboutWindow) {
aboutWindow.close();
}
});

View File

@ -31,6 +31,10 @@
console.log('restart');
ipc.send('restart');
};
window.closeAbout = function() {
ipc.send('close-about');
};
ipc.on('debug-log', function() {
Whisper.events.trigger('showDebugLog');
});