Fossil SCM
wikiedit now relabels the Save button while save is in progress, per forum feedback.
Commit
9f3747d8a5542a06e666a33f92ef82836e603137fd2b3cef7ccbf7668999bc35
Parent
7f416ef1754dc71…
2 files changed
+3
-1
+19
-4
+3
-1
| --- src/fossil.fetch.js | ||
| +++ src/fossil.fetch.js | ||
| @@ -87,11 +87,13 @@ | ||
| 87 | 87 | function with the same name, e.g. fossil.fetch.onload(). The |
| 88 | 88 | default onload/onerror implementations route the data through the |
| 89 | 89 | dev console and (for onerror()) through fossil.error(). The default |
| 90 | 90 | beforesend/aftersend are no-ops. Individual pages may overwrite |
| 91 | 91 | those members to provide default implementations suitable for the |
| 92 | - page's use, e.g. keeping track of how many in-flight | |
| 92 | + page's use, e.g. keeping track of how many in-flight ajax requests | |
| 93 | + are pending. Any exceptions thrown in an beforesend/aftersend | |
| 94 | + handler are current ignored (feature or bug?). | |
| 93 | 95 | |
| 94 | 96 | Note that this routine may add properties to the 2nd argument, so |
| 95 | 97 | that instance should not be kept around for later use. |
| 96 | 98 | |
| 97 | 99 | Returns this object, noting that the XHR request is asynchronous, |
| 98 | 100 |
| --- src/fossil.fetch.js | |
| +++ src/fossil.fetch.js | |
| @@ -87,11 +87,13 @@ | |
| 87 | function with the same name, e.g. fossil.fetch.onload(). The |
| 88 | default onload/onerror implementations route the data through the |
| 89 | dev console and (for onerror()) through fossil.error(). The default |
| 90 | beforesend/aftersend are no-ops. Individual pages may overwrite |
| 91 | those members to provide default implementations suitable for the |
| 92 | page's use, e.g. keeping track of how many in-flight |
| 93 | |
| 94 | Note that this routine may add properties to the 2nd argument, so |
| 95 | that instance should not be kept around for later use. |
| 96 | |
| 97 | Returns this object, noting that the XHR request is asynchronous, |
| 98 |
| --- src/fossil.fetch.js | |
| +++ src/fossil.fetch.js | |
| @@ -87,11 +87,13 @@ | |
| 87 | function with the same name, e.g. fossil.fetch.onload(). The |
| 88 | default onload/onerror implementations route the data through the |
| 89 | dev console and (for onerror()) through fossil.error(). The default |
| 90 | beforesend/aftersend are no-ops. Individual pages may overwrite |
| 91 | those members to provide default implementations suitable for the |
| 92 | page's use, e.g. keeping track of how many in-flight ajax requests |
| 93 | are pending. Any exceptions thrown in an beforesend/aftersend |
| 94 | handler are current ignored (feature or bug?). |
| 95 | |
| 96 | Note that this routine may add properties to the 2nd argument, so |
| 97 | that instance should not be kept around for later use. |
| 98 | |
| 99 | Returns this object, noting that the XHR request is asynchronous, |
| 100 |
+19
-4
| --- src/fossil.page.wikiedit.js | ||
| +++ src/fossil.page.wikiedit.js | ||
| @@ -912,11 +912,11 @@ | ||
| 912 | 912 | "To really discard this page,", |
| 913 | 913 | "first clear its content", |
| 914 | 914 | "then use the Discard button."); |
| 915 | 915 | return; |
| 916 | 916 | } |
| 917 | - P.unstashContent() | |
| 917 | + P.unstashContent(); | |
| 918 | 918 | if(w.version || w.type==='sandbox'){ |
| 919 | 919 | P.loadPage(w); |
| 920 | 920 | }else{ |
| 921 | 921 | WikiList.removeEntry(w.name); |
| 922 | 922 | delete P.winfo; |
| @@ -932,11 +932,21 @@ | ||
| 932 | 932 | const w = P.winfo; |
| 933 | 933 | if(!w){ |
| 934 | 934 | F.error("No page loaded."); |
| 935 | 935 | return; |
| 936 | 936 | } |
| 937 | - P.save(); | |
| 937 | + setTimeout( | |
| 938 | + ()=>P.save(), 0 | |
| 939 | + /* timeout is a workaround to allow save() to update the | |
| 940 | + button's text (per forum feedback). The idea is to force | |
| 941 | + the call of save() to happen *after* the confirmer | |
| 942 | + callback returns so that we can change the button label | |
| 943 | + without the confirmer setting it back to its | |
| 944 | + pre-confirmed state. This is, however, no guaranty that | |
| 945 | + save() will actually be called *after* the confirmer | |
| 946 | + re-sets the button label. */ | |
| 947 | + ); | |
| 938 | 948 | }, |
| 939 | 949 | ticks: F.config.confirmerButtonTicks |
| 940 | 950 | }); |
| 941 | 951 | |
| 942 | 952 | P.e.taEditor.addEventListener( |
| @@ -1012,11 +1022,11 @@ | ||
| 1012 | 1022 | P.wikiContent(winfo.content || ''); |
| 1013 | 1023 | WikiList.e.select.value = winfo.name; |
| 1014 | 1024 | if(!winfo.version && winfo.type!=='sandbox'){ |
| 1015 | 1025 | F.message('You are editing a new, unsaved page:',winfo.name); |
| 1016 | 1026 | } |
| 1017 | - P.updatePageTitle(); | |
| 1027 | + P.updatePageTitle().updateSaveButton(/* b/c save() routes through here */); | |
| 1018 | 1028 | }, |
| 1019 | 1029 | false |
| 1020 | 1030 | ); |
| 1021 | 1031 | /* These init()s need to come after P's event handlers are registered */ |
| 1022 | 1032 | WikiList.init( P.e.tabs.pageList.firstElementChild ); |
| @@ -1326,13 +1336,13 @@ | ||
| 1326 | 1336 | Saves the current wiki page and re-populates the editor |
| 1327 | 1337 | with the saved state. |
| 1328 | 1338 | */ |
| 1329 | 1339 | P.save = function callee(){ |
| 1330 | 1340 | if(!affirmPageLoaded()) return this; |
| 1331 | - const self = this; | |
| 1332 | 1341 | const content = this.wikiContent(); |
| 1333 | 1342 | if(!callee.onload){ |
| 1343 | + const self = this; | |
| 1334 | 1344 | callee.onload = function(w){ |
| 1335 | 1345 | const oldWinfo = self.winfo; |
| 1336 | 1346 | self.unstashContent(oldWinfo); |
| 1337 | 1347 | self.dispatchEvent('wiki-page-loaded', w); |
| 1338 | 1348 | F.message("Saved page: ["+w.name+"]."); |
| @@ -1346,10 +1356,15 @@ | ||
| 1346 | 1356 | F.message( |
| 1347 | 1357 | "Saving page..." |
| 1348 | 1358 | ).fetch('wikiajax/save',{ |
| 1349 | 1359 | payload: fd, |
| 1350 | 1360 | responseType: 'json', |
| 1361 | + beforesend: function(){ | |
| 1362 | + D.disable(P.e.btnSave); | |
| 1363 | + P.e.btnSave.innerText = "Saving..."; | |
| 1364 | + F.fetch.beforesend(); | |
| 1365 | + }, | |
| 1351 | 1366 | onload: callee.onload |
| 1352 | 1367 | }); |
| 1353 | 1368 | return this; |
| 1354 | 1369 | }; |
| 1355 | 1370 | |
| 1356 | 1371 |
| --- src/fossil.page.wikiedit.js | |
| +++ src/fossil.page.wikiedit.js | |
| @@ -912,11 +912,11 @@ | |
| 912 | "To really discard this page,", |
| 913 | "first clear its content", |
| 914 | "then use the Discard button."); |
| 915 | return; |
| 916 | } |
| 917 | P.unstashContent() |
| 918 | if(w.version || w.type==='sandbox'){ |
| 919 | P.loadPage(w); |
| 920 | }else{ |
| 921 | WikiList.removeEntry(w.name); |
| 922 | delete P.winfo; |
| @@ -932,11 +932,21 @@ | |
| 932 | const w = P.winfo; |
| 933 | if(!w){ |
| 934 | F.error("No page loaded."); |
| 935 | return; |
| 936 | } |
| 937 | P.save(); |
| 938 | }, |
| 939 | ticks: F.config.confirmerButtonTicks |
| 940 | }); |
| 941 | |
| 942 | P.e.taEditor.addEventListener( |
| @@ -1012,11 +1022,11 @@ | |
| 1012 | P.wikiContent(winfo.content || ''); |
| 1013 | WikiList.e.select.value = winfo.name; |
| 1014 | if(!winfo.version && winfo.type!=='sandbox'){ |
| 1015 | F.message('You are editing a new, unsaved page:',winfo.name); |
| 1016 | } |
| 1017 | P.updatePageTitle(); |
| 1018 | }, |
| 1019 | false |
| 1020 | ); |
| 1021 | /* These init()s need to come after P's event handlers are registered */ |
| 1022 | WikiList.init( P.e.tabs.pageList.firstElementChild ); |
| @@ -1326,13 +1336,13 @@ | |
| 1326 | Saves the current wiki page and re-populates the editor |
| 1327 | with the saved state. |
| 1328 | */ |
| 1329 | P.save = function callee(){ |
| 1330 | if(!affirmPageLoaded()) return this; |
| 1331 | const self = this; |
| 1332 | const content = this.wikiContent(); |
| 1333 | if(!callee.onload){ |
| 1334 | callee.onload = function(w){ |
| 1335 | const oldWinfo = self.winfo; |
| 1336 | self.unstashContent(oldWinfo); |
| 1337 | self.dispatchEvent('wiki-page-loaded', w); |
| 1338 | F.message("Saved page: ["+w.name+"]."); |
| @@ -1346,10 +1356,15 @@ | |
| 1346 | F.message( |
| 1347 | "Saving page..." |
| 1348 | ).fetch('wikiajax/save',{ |
| 1349 | payload: fd, |
| 1350 | responseType: 'json', |
| 1351 | onload: callee.onload |
| 1352 | }); |
| 1353 | return this; |
| 1354 | }; |
| 1355 | |
| 1356 |
| --- src/fossil.page.wikiedit.js | |
| +++ src/fossil.page.wikiedit.js | |
| @@ -912,11 +912,11 @@ | |
| 912 | "To really discard this page,", |
| 913 | "first clear its content", |
| 914 | "then use the Discard button."); |
| 915 | return; |
| 916 | } |
| 917 | P.unstashContent(); |
| 918 | if(w.version || w.type==='sandbox'){ |
| 919 | P.loadPage(w); |
| 920 | }else{ |
| 921 | WikiList.removeEntry(w.name); |
| 922 | delete P.winfo; |
| @@ -932,11 +932,21 @@ | |
| 932 | const w = P.winfo; |
| 933 | if(!w){ |
| 934 | F.error("No page loaded."); |
| 935 | return; |
| 936 | } |
| 937 | setTimeout( |
| 938 | ()=>P.save(), 0 |
| 939 | /* timeout is a workaround to allow save() to update the |
| 940 | button's text (per forum feedback). The idea is to force |
| 941 | the call of save() to happen *after* the confirmer |
| 942 | callback returns so that we can change the button label |
| 943 | without the confirmer setting it back to its |
| 944 | pre-confirmed state. This is, however, no guaranty that |
| 945 | save() will actually be called *after* the confirmer |
| 946 | re-sets the button label. */ |
| 947 | ); |
| 948 | }, |
| 949 | ticks: F.config.confirmerButtonTicks |
| 950 | }); |
| 951 | |
| 952 | P.e.taEditor.addEventListener( |
| @@ -1012,11 +1022,11 @@ | |
| 1022 | P.wikiContent(winfo.content || ''); |
| 1023 | WikiList.e.select.value = winfo.name; |
| 1024 | if(!winfo.version && winfo.type!=='sandbox'){ |
| 1025 | F.message('You are editing a new, unsaved page:',winfo.name); |
| 1026 | } |
| 1027 | P.updatePageTitle().updateSaveButton(/* b/c save() routes through here */); |
| 1028 | }, |
| 1029 | false |
| 1030 | ); |
| 1031 | /* These init()s need to come after P's event handlers are registered */ |
| 1032 | WikiList.init( P.e.tabs.pageList.firstElementChild ); |
| @@ -1326,13 +1336,13 @@ | |
| 1336 | Saves the current wiki page and re-populates the editor |
| 1337 | with the saved state. |
| 1338 | */ |
| 1339 | P.save = function callee(){ |
| 1340 | if(!affirmPageLoaded()) return this; |
| 1341 | const content = this.wikiContent(); |
| 1342 | if(!callee.onload){ |
| 1343 | const self = this; |
| 1344 | callee.onload = function(w){ |
| 1345 | const oldWinfo = self.winfo; |
| 1346 | self.unstashContent(oldWinfo); |
| 1347 | self.dispatchEvent('wiki-page-loaded', w); |
| 1348 | F.message("Saved page: ["+w.name+"]."); |
| @@ -1346,10 +1356,15 @@ | |
| 1356 | F.message( |
| 1357 | "Saving page..." |
| 1358 | ).fetch('wikiajax/save',{ |
| 1359 | payload: fd, |
| 1360 | responseType: 'json', |
| 1361 | beforesend: function(){ |
| 1362 | D.disable(P.e.btnSave); |
| 1363 | P.e.btnSave.innerText = "Saving..."; |
| 1364 | F.fetch.beforesend(); |
| 1365 | }, |
| 1366 | onload: callee.onload |
| 1367 | }); |
| 1368 | return this; |
| 1369 | }; |
| 1370 | |
| 1371 |