1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-25 23:03:15 +00:00

Make "tc-dirty" update also on external windows (#5129)

* Update windows.js

* Update saver-handler.js

* Update saver-handler.js
This commit is contained in:
Simon Huber 2020-11-28 22:24:01 +01:00 committed by GitHub
parent b3cbd7d733
commit eb7f59a855
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View File

@ -197,8 +197,12 @@ SaverHandler.prototype.isDirty = function() {
Update the document body with the class "tc-dirty" if the wiki has unsaved/unsynced changes Update the document body with the class "tc-dirty" if the wiki has unsaved/unsynced changes
*/ */
SaverHandler.prototype.updateDirtyStatus = function() { SaverHandler.prototype.updateDirtyStatus = function() {
var self = this;
if($tw.browser) { if($tw.browser) {
$tw.utils.toggleClass(document.body,"tc-dirty",this.isDirty()); $tw.utils.toggleClass(document.body,"tc-dirty",this.isDirty());
$tw.utils.each($tw.windows,function(win) {
$tw.utils.toggleClass(win.document.body,"tc-dirty",self.isDirty());
});
} }
}; };

View File

@ -19,7 +19,7 @@ exports.after = ["startup"];
exports.synchronous = true; exports.synchronous = true;
// Global to keep track of open windows (hashmap by title) // Global to keep track of open windows (hashmap by title)
var windows = {}; $tw.windows = {};
exports.startup = function() { exports.startup = function() {
// Handle open window message // Handle open window message
@ -44,7 +44,7 @@ exports.startup = function() {
catch(e) { catch(e) {
return; return;
} }
windows[title] = srcWindow; $tw.windows[title] = srcWindow;
// Check for reopening the same window // Check for reopening the same window
if(srcWindow.haveInitialisedWindow) { if(srcWindow.haveInitialisedWindow) {
return; return;
@ -54,7 +54,7 @@ exports.startup = function() {
srcDocument.close(); srcDocument.close();
srcDocument.title = windowTitle; srcDocument.title = windowTitle;
srcWindow.addEventListener("beforeunload",function(event) { srcWindow.addEventListener("beforeunload",function(event) {
delete windows[title]; delete $tw.windows[title];
$tw.wiki.removeEventListener("change",refreshHandler); $tw.wiki.removeEventListener("change",refreshHandler);
},false); },false);
// Set up the styles // Set up the styles
@ -90,7 +90,7 @@ exports.startup = function() {
}); });
// Close open windows when unloading main window // Close open windows when unloading main window
$tw.addUnloadTask(function() { $tw.addUnloadTask(function() {
$tw.utils.each(windows,function(win) { $tw.utils.each($tw.windows,function(win) {
win.close(); win.close();
}); });
}); });