From 56945d91d327489478fc44dce5234ece35a01abb Mon Sep 17 00:00:00 2001 From: Jermolene Date: Wed, 30 Jul 2014 16:46:13 +0100 Subject: [PATCH 1/2] Add unsaved changes indicator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The “save” icon changes to red to indicate that there are unsaved changes. --- core/language/en-GB/Docs/PaletteColours.multids | 1 + core/modules/syncer.js | 14 ++++++++++++++ core/palettes/Blanca.tid | 1 + core/palettes/Blue.tid | 1 + core/palettes/BrightMute.tid | 1 + core/palettes/Contrast.tid | 1 + core/palettes/Rocker.tid | 1 + core/palettes/Vanilla.tid | 1 + core/ui/PageControls/savewiki.tid | 2 ++ themes/tiddlywiki/vanilla/base.tid | 8 ++++++++ 10 files changed, 31 insertions(+) diff --git a/core/language/en-GB/Docs/PaletteColours.multids b/core/language/en-GB/Docs/PaletteColours.multids index db9548452..778b679c5 100644 --- a/core/language/en-GB/Docs/PaletteColours.multids +++ b/core/language/en-GB/Docs/PaletteColours.multids @@ -6,6 +6,7 @@ alert-highlight: Alert highlight alert-muted-foreground: Alert muted foreground background: General background blockquote-bar: Blockquote bar +dirty-indicator: Unsaved changes indicator code-background: Code background code-border: Code border code-foreground: Code foreground diff --git a/core/modules/syncer.js b/core/modules/syncer.js index 60caf0983..6600573fb 100644 --- a/core/modules/syncer.js +++ b/core/modules/syncer.js @@ -71,6 +71,7 @@ Syncer.prototype.throttleInterval = 1 * 1000; // Defer saving tiddlers if they'v Syncer.prototype.fallbackInterval = 10 * 1000; // Unless the task is older than 10s Syncer.prototype.pollTimerInterval = 60 * 1000; // Interval for polling for changes from the adaptor + /* Read (or re-read) the latest tiddler info from the store */ @@ -155,6 +156,7 @@ Syncer.prototype.saveWiki = function(options) { if(method !== "download") { this.readTiddlerInfo(); this.taskQueue = {}; + this.updateDirtyStatus(); } return true; } @@ -169,6 +171,15 @@ Syncer.prototype.isDirty = function() { return (this.numTasksInQueue() > 0) || (this.numTasksInProgress() > 0); }; +/* +Update the document body with the class "tw-dirty" if the wiki has unsaved/unsynced changes +*/ +Syncer.prototype.updateDirtyStatus = function() { + if($tw.browser) { + $tw.utils.toggleClass(document.body,"tw-dirty",this.isDirty()); + } +}; + /* Save an incoming tiddler in the store, and updates the associated tiddlerInfo */ @@ -401,6 +412,7 @@ Syncer.prototype.enqueueSyncTask = function(task) { // this.logger.log("Queuing up sync task with type:",task.type,"title:",task.title); // If it is not in the queue, insert it this.taskQueue[task.title] = task; + this.updateDirtyStatus(); } // Process the queue if(this.syncadaptor) { @@ -449,6 +461,7 @@ Syncer.prototype.processTaskQueue = function() { // Remove the task from the queue and add it to the in progress list delete this.taskQueue[task.title]; this.taskInProgress[task.title] = task; + this.updateDirtyStatus(); // Dispatch the task this.dispatchTask(task,function(err) { if(err) { @@ -456,6 +469,7 @@ Syncer.prototype.processTaskQueue = function() { } // Mark that this task is no longer in progress delete self.taskInProgress[task.title]; + self.updateDirtyStatus(); // Process the next task self.processTaskQueue.call(self); }); diff --git a/core/palettes/Blanca.tid b/core/palettes/Blanca.tid index 81cf33d11..74d4057fe 100644 --- a/core/palettes/Blanca.tid +++ b/core/palettes/Blanca.tid @@ -13,6 +13,7 @@ blockquote-bar: <> code-background: #f7f7f9 code-border: #e1e1e8 code-foreground: #dd1144 +dirty-indicator: #ff0000 download-background: #66cccc download-foreground: <> dragger-background: <> diff --git a/core/palettes/Blue.tid b/core/palettes/Blue.tid index 263bb6acc..183d3a951 100644 --- a/core/palettes/Blue.tid +++ b/core/palettes/Blue.tid @@ -13,6 +13,7 @@ blockquote-bar: <> code-background: #f7f7f9 code-border: #e1e1e8 code-foreground: #dd1144 +dirty-indicator: #ff0000 download-background: #34c734 download-foreground: <> dragger-background: <> diff --git a/core/palettes/BrightMute.tid b/core/palettes/BrightMute.tid index 186e0a3f9..3e292a5ad 100644 --- a/core/palettes/BrightMute.tid +++ b/core/palettes/BrightMute.tid @@ -13,6 +13,7 @@ blockquote-bar: <> code-background: #f7f7f9 code-border: #e1e1e8 code-foreground: #dd1144 +dirty-indicator: #ff0000 download-background: #34c734 download-foreground: <> dragger-background: <> diff --git a/core/palettes/Contrast.tid b/core/palettes/Contrast.tid index f7c57d100..4fc53d760 100644 --- a/core/palettes/Contrast.tid +++ b/core/palettes/Contrast.tid @@ -13,6 +13,7 @@ blockquote-bar: <> code-background: #f7f7f9 code-border: #e1e1e8 code-foreground: #dd1144 +dirty-indicator: #ff0000 download-background: #34c734 download-foreground: <> dragger-background: <> diff --git a/core/palettes/Rocker.tid b/core/palettes/Rocker.tid index 794cfd8c8..d84c2a3f5 100644 --- a/core/palettes/Rocker.tid +++ b/core/palettes/Rocker.tid @@ -13,6 +13,7 @@ blockquote-bar: <> code-background: #f7f7f9 code-border: #e1e1e8 code-foreground: #dd1144 +dirty-indicator: #ff0000 download-background: #34c734 download-foreground: <> dragger-background: <> diff --git a/core/palettes/Vanilla.tid b/core/palettes/Vanilla.tid index d8c661cc4..3dc470745 100644 --- a/core/palettes/Vanilla.tid +++ b/core/palettes/Vanilla.tid @@ -13,6 +13,7 @@ blockquote-bar: <> code-background: #f7f7f9 code-border: #e1e1e8 code-foreground: #dd1144 +dirty-indicator: #ff0000 download-background: #34c734 download-foreground: <> dragger-background: <> diff --git a/core/ui/PageControls/savewiki.tid b/core/ui/PageControls/savewiki.tid index 83a4abab2..d912f0301 100644 --- a/core/ui/PageControls/savewiki.tid +++ b/core/ui/PageControls/savewiki.tid @@ -4,7 +4,9 @@ caption: {{$:/core/images/save-button}} {{$:/language/Buttons/SaveWiki/Caption}} <$button message="tw-save-wiki" title={{$:/language/Buttons/SaveWiki/Hint}} aria-label={{$:/language/Buttons/SaveWiki/Caption}} class=<>> <$list filter="[prefix[yes]]"> + {{$:/core/images/save-button}} + <$list filter="[prefix[yes]]"> <$text text={{$:/language/Buttons/SaveWiki/Caption}}/> diff --git a/themes/tiddlywiki/vanilla/base.tid b/themes/tiddlywiki/vanilla/base.tid index 86d434828..1d111956f 100644 --- a/themes/tiddlywiki/vanilla/base.tid +++ b/themes/tiddlywiki/vanilla/base.tid @@ -1317,3 +1317,11 @@ canvas.tw-edit-bitmapeditor { font-size: 0.95em; font-weight: 200; } + +/* +** Dirty indicator +*/ + +body.tw-dirty .tw-dirty-indicator svg { + fill: <>; +} From 2a88ff9addb3402bf8fc69e03dead525570065e4 Mon Sep 17 00:00:00 2001 From: Xavier Cazin Date: Wed, 30 Jul 2014 18:13:14 +0200 Subject: [PATCH 2/2] fr-FR translation for the dirty-indicator description --- languages/fr-FR/Docs/PaletteColours.multids | 1 + 1 file changed, 1 insertion(+) diff --git a/languages/fr-FR/Docs/PaletteColours.multids b/languages/fr-FR/Docs/PaletteColours.multids index 03c813790..deb38e025 100644 --- a/languages/fr-FR/Docs/PaletteColours.multids +++ b/languages/fr-FR/Docs/PaletteColours.multids @@ -9,6 +9,7 @@ blockquote-bar: Barre de citation code-background: Fond pour le code code-border: Bordure pour le code code-foreground: Premier plan pour le code +dirty-indicator: Indicateur de modifications non sauvegardées download-background: Fond pour le bouton de téléchargement download-foreground: Premier plan pour le bouton de téléchargement dragger-background: Fond pour le glissé-déposé