Fossil

Check-in [9f3747d8]
Login

Check-in [9f3747d8]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:wikiedit now relabels the Save button while save is in progress, per forum feedback.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 9f3747d8a5542a06e666a33f92ef82836e603137fd2b3cef7ccbf7668999bc35
User & Date: stephan 2020-08-08 12:41:01
Context
2020-08-08
15:01
More improvements to "fossil open": Make sure the --repodir is converted into a full pathname so that it is unaffected by --workdir. Report an error with --nested if the new repo would be rooted in the same directory as another repository. ... (check-in: 15a7b1fd user: drh tags: trunk)
12:41
wikiedit now relabels the Save button while save is in progress, per forum feedback. ... (check-in: 9f3747d8 user: stephan tags: trunk)
12:11
Reverted a recent modernization in sbsdiff.js because the MSIE<=11 family of browsers do not support NodeList.forEach. ... (check-in: 7f416ef1 user: stephan tags: trunk)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/fossil.fetch.js.

85
86
87
88
89
90
91
92


93
94
95
96
97
98
99
   onload/onerror/beforesend/aftersend handlers of its own, this
   function falls to defaults which are member properties of this
   function with the same name, e.g. fossil.fetch.onload(). The
   default onload/onerror implementations route the data through the
   dev console and (for onerror()) through fossil.error(). The default
   beforesend/aftersend are no-ops. Individual pages may overwrite
   those members to provide default implementations suitable for the
   page's use, e.g. keeping track of how many in-flight



   Note that this routine may add properties to the 2nd argument, so
   that instance should not be kept around for later use.

   Returns this object, noting that the XHR request is asynchronous,
   and still in transit (or has yet to be sent) when that happens.
*/







|
>
>







85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
   onload/onerror/beforesend/aftersend handlers of its own, this
   function falls to defaults which are member properties of this
   function with the same name, e.g. fossil.fetch.onload(). The
   default onload/onerror implementations route the data through the
   dev console and (for onerror()) through fossil.error(). The default
   beforesend/aftersend are no-ops. Individual pages may overwrite
   those members to provide default implementations suitable for the
   page's use, e.g. keeping track of how many in-flight ajax requests
   are pending. Any exceptions thrown in an beforesend/aftersend
   handler are current ignored (feature or bug?).

   Note that this routine may add properties to the 2nd argument, so
   that instance should not be kept around for later use.

   Returns this object, noting that the XHR request is asynchronous,
   and still in transit (or has yet to be sent) when that happens.
*/

Changes to src/fossil.page.wikiedit.js.

910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936

937









938
939
940
941
942
943
944
           && P.wikiContent()){
          F.error("This new/unsaved page has content.",
                  "To really discard this page,",
                  "first clear its content",
                  "then use the Discard button.");
          return;
        }
        P.unstashContent()
        if(w.version || w.type==='sandbox'){
          P.loadPage(w);
        }else{
          WikiList.removeEntry(w.name);
          delete P.winfo;
          P.updatePageTitle();
          F.message("Discarded new page ["+w.name+"].");
        }
      },
      ticks: F.config.confirmerButtonTicks
    });
    F.confirmer(P.e.btnSave, {
      confirmText: "Really save changes?",
      onconfirm: function(e){
        const w = P.winfo;
        if(!w){
          F.error("No page loaded.");
          return;
        }

        P.save();









      },
      ticks: F.config.confirmerButtonTicks
    });

    P.e.taEditor.addEventListener(
      'change', ()=>P.stashContentChange(), false
    );







|



















>
|
>
>
>
>
>
>
>
>
>







910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
           && P.wikiContent()){
          F.error("This new/unsaved page has content.",
                  "To really discard this page,",
                  "first clear its content",
                  "then use the Discard button.");
          return;
        }
        P.unstashContent();
        if(w.version || w.type==='sandbox'){
          P.loadPage(w);
        }else{
          WikiList.removeEntry(w.name);
          delete P.winfo;
          P.updatePageTitle();
          F.message("Discarded new page ["+w.name+"].");
        }
      },
      ticks: F.config.confirmerButtonTicks
    });
    F.confirmer(P.e.btnSave, {
      confirmText: "Really save changes?",
      onconfirm: function(e){
        const w = P.winfo;
        if(!w){
          F.error("No page loaded.");
          return;
        }
        setTimeout(
          ()=>P.save(), 0
          /* timeout is a workaround to allow save() to update the
             button's text (per forum feedback).  The idea is to force
             the call of save() to happen *after* the confirmer
             callback returns so that we can change the button label
             without the confirmer setting it back to its
             pre-confirmed state. This is, however, no guaranty that
             save() will actually be called *after* the confirmer
             re-sets the button label. */
        );
      },
      ticks: F.config.confirmerButtonTicks
    });

    P.e.taEditor.addEventListener(
      'change', ()=>P.stashContentChange(), false
    );
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
        P.e.selectMimetype.value = winfo.mimetype;
        P.tabs.switchToTab(P.e.tabs.content);
        P.wikiContent(winfo.content || '');
        WikiList.e.select.value = winfo.name;
        if(!winfo.version && winfo.type!=='sandbox'){
          F.message('You are editing a new, unsaved page:',winfo.name);
        }
        P.updatePageTitle();
      },
      false
    );
    /* These init()s need to come after P's event handlers are registered */
    WikiList.init( P.e.tabs.pageList.firstElementChild );
    P.stashWidget.init(P.e.tabs.content.lastElementChild);
    //P.$wikiList = WikiList/*only for testing/debugging*/;







|







1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
        P.e.selectMimetype.value = winfo.mimetype;
        P.tabs.switchToTab(P.e.tabs.content);
        P.wikiContent(winfo.content || '');
        WikiList.e.select.value = winfo.name;
        if(!winfo.version && winfo.type!=='sandbox'){
          F.message('You are editing a new, unsaved page:',winfo.name);
        }
        P.updatePageTitle().updateSaveButton(/* b/c save() routes through here */);
      },
      false
    );
    /* These init()s need to come after P's event handlers are registered */
    WikiList.init( P.e.tabs.pageList.firstElementChild );
    P.stashWidget.init(P.e.tabs.content.lastElementChild);
    //P.$wikiList = WikiList/*only for testing/debugging*/;
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333

1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350





1351
1352
1353
1354
1355
1356
1357

  /**
     Saves the current wiki page and re-populates the editor
     with the saved state.
  */
  P.save = function callee(){
    if(!affirmPageLoaded()) return this;
    const self = this;
    const content = this.wikiContent();
    if(!callee.onload){

      callee.onload = function(w){
        const oldWinfo = self.winfo;
        self.unstashContent(oldWinfo);
        self.dispatchEvent('wiki-page-loaded', w);
        F.message("Saved page: ["+w.name+"].");
      }
    }
    const fd = new FormData(), w = P.winfo;
    fd.append('page',w.name);
    fd.append('mimetype', w.mimetype);
    fd.append('isnew', w.version ? 0 : 1);
    fd.append('content', P.wikiContent());
    F.message(
      "Saving page..."
    ).fetch('wikiajax/save',{
      payload: fd,
      responseType: 'json',





      onload: callee.onload
    });
    return this;
  };
  
  /**
     Updates P.winfo for certain state and stashes P.winfo, with the







<


>

















>
>
>
>
>







1334
1335
1336
1337
1338
1339
1340

1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372

  /**
     Saves the current wiki page and re-populates the editor
     with the saved state.
  */
  P.save = function callee(){
    if(!affirmPageLoaded()) return this;

    const content = this.wikiContent();
    if(!callee.onload){
      const self = this;
      callee.onload = function(w){
        const oldWinfo = self.winfo;
        self.unstashContent(oldWinfo);
        self.dispatchEvent('wiki-page-loaded', w);
        F.message("Saved page: ["+w.name+"].");
      }
    }
    const fd = new FormData(), w = P.winfo;
    fd.append('page',w.name);
    fd.append('mimetype', w.mimetype);
    fd.append('isnew', w.version ? 0 : 1);
    fd.append('content', P.wikiContent());
    F.message(
      "Saving page..."
    ).fetch('wikiajax/save',{
      payload: fd,
      responseType: 'json',
      beforesend: function(){
        D.disable(P.e.btnSave);
        P.e.btnSave.innerText = "Saving...";
        F.fetch.beforesend();
      },
      onload: callee.onload
    });
    return this;
  };
  
  /**
     Updates P.winfo for certain state and stashes P.winfo, with the