Fossil SCM

wikiedit now relabels the Save button while save is in progress, per forum feedback.

stephan 2020-08-08 12:41 trunk
Commit 9f3747d8a5542a06e666a33f92ef82836e603137fd2b3cef7ccbf7668999bc35
--- src/fossil.fetch.js
+++ src/fossil.fetch.js
@@ -87,11 +87,13 @@
8787
function with the same name, e.g. fossil.fetch.onload(). The
8888
default onload/onerror implementations route the data through the
8989
dev console and (for onerror()) through fossil.error(). The default
9090
beforesend/aftersend are no-ops. Individual pages may overwrite
9191
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?).
9395
9496
Note that this routine may add properties to the 2nd argument, so
9597
that instance should not be kept around for later use.
9698
9799
Returns this object, noting that the XHR request is asynchronous,
98100
--- 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
--- src/fossil.page.wikiedit.js
+++ src/fossil.page.wikiedit.js
@@ -912,11 +912,11 @@
912912
"To really discard this page,",
913913
"first clear its content",
914914
"then use the Discard button.");
915915
return;
916916
}
917
- P.unstashContent()
917
+ P.unstashContent();
918918
if(w.version || w.type==='sandbox'){
919919
P.loadPage(w);
920920
}else{
921921
WikiList.removeEntry(w.name);
922922
delete P.winfo;
@@ -932,11 +932,21 @@
932932
const w = P.winfo;
933933
if(!w){
934934
F.error("No page loaded.");
935935
return;
936936
}
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
+ );
938948
},
939949
ticks: F.config.confirmerButtonTicks
940950
});
941951
942952
P.e.taEditor.addEventListener(
@@ -1012,11 +1022,11 @@
10121022
P.wikiContent(winfo.content || '');
10131023
WikiList.e.select.value = winfo.name;
10141024
if(!winfo.version && winfo.type!=='sandbox'){
10151025
F.message('You are editing a new, unsaved page:',winfo.name);
10161026
}
1017
- P.updatePageTitle();
1027
+ P.updatePageTitle().updateSaveButton(/* b/c save() routes through here */);
10181028
},
10191029
false
10201030
);
10211031
/* These init()s need to come after P's event handlers are registered */
10221032
WikiList.init( P.e.tabs.pageList.firstElementChild );
@@ -1326,13 +1336,13 @@
13261336
Saves the current wiki page and re-populates the editor
13271337
with the saved state.
13281338
*/
13291339
P.save = function callee(){
13301340
if(!affirmPageLoaded()) return this;
1331
- const self = this;
13321341
const content = this.wikiContent();
13331342
if(!callee.onload){
1343
+ const self = this;
13341344
callee.onload = function(w){
13351345
const oldWinfo = self.winfo;
13361346
self.unstashContent(oldWinfo);
13371347
self.dispatchEvent('wiki-page-loaded', w);
13381348
F.message("Saved page: ["+w.name+"].");
@@ -1346,10 +1356,15 @@
13461356
F.message(
13471357
"Saving page..."
13481358
).fetch('wikiajax/save',{
13491359
payload: fd,
13501360
responseType: 'json',
1361
+ beforesend: function(){
1362
+ D.disable(P.e.btnSave);
1363
+ P.e.btnSave.innerText = "Saving...";
1364
+ F.fetch.beforesend();
1365
+ },
13511366
onload: callee.onload
13521367
});
13531368
return this;
13541369
};
13551370
13561371
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button