Skip to content

TagSpaces is an offline, open source, document manager with tagging support

adding confirmation by closing while file edited

uggrockb47cba75ac24
diff --git a/data/js/fileopener.js b/data/js/fileopener.js
index 55111dafa..39ec885e9 100644
--- a/data/js/fileopener.js
+++ b/data/js/fileopener.js
@@ -17,6 +17,12 @@ define(function(require, exports, module) {
// If a file is currently opened for editing, this var should be true
var _isEditMode = false;
+ window.onbeforeunload = function() {
+ if (_isFileChanged) {
+ return "Confirm close";
+ }
+ };
+
function initUI() {
$('#editDocument').click(function() {
editFile(_openedFilePath);
diff --git a/data/node-webkit/node-webkit.api.js b/data/node-webkit/node-webkit.api.js
index 156ffb265..642949b00 100644
--- a/data/node-webkit/node-webkit.api.js
+++ b/data/node-webkit/node-webkit.api.js
@@ -15,6 +15,31 @@ define(function(require, exports, module) {
var TSPOSTIO = require("tspostioapi");
var win = gui.Window.get();
+
+ /* var splashwin = gui.Window.open('splashscreen.html', {
+ 'frame': false,
+ 'toolbar': false,
+ 'position': 'center',
+ 'always-on-top': true,
+ "width": 400,
+ "height": 200
+ }); */
+
+ var showMainWindow = function() {
+ splashwin.hide();
+ win.show();
+ };
+
+ win.on('close', function() {
+ if (TSCORE.FileOpener.isFileChanged()) {
+ if (confirm($.i18n.t("ns.common:confirmApplicationClose"))) {
+ win.close(true);
+ }
+ } else {
+ win.close(true);
+ }
+ });
+
var rootMenu = new gui.Menu({
type: 'menubar'
});
@@ -623,5 +648,6 @@ define(function(require, exports, module) {
exports.handleStartParameters = handleStartParameters;
exports.handleTray = handleTray;
exports.focusWindow = focusWindow;
+ exports.showMainWindow = showMainWindow;
});