Fossil SCM
Re-enabled the discard-all-edits button in wikiedit and made it look the same in both wikiedit and fileedit.
Commit
39a5289b9b7c20affe5c37b476723ef64929a66610d82bccdc46acac14df3f34
Parent
c09949e5e469f28…
2 files changed
+2
-2
+31
-22
+2
-2
| --- src/fossil.page.fileedit.js | ||
| +++ src/fossil.page.fileedit.js | ||
| @@ -465,11 +465,11 @@ | ||
| 465 | 465 | D.attr(D.div(),'id','fileedit-stash-selector'), |
| 466 | 466 | 'input-with-label' |
| 467 | 467 | ); |
| 468 | 468 | const sel = this.e.select = D.select(); |
| 469 | 469 | const btnClear = this.e.btnClear |
| 470 | - = D.button("Clear"); | |
| 470 | + = D.button("Discard Edits"); | |
| 471 | 471 | D.append(wrapper, "Local edits (", |
| 472 | 472 | D.append(D.code(), |
| 473 | 473 | F.storage.storageImplName()), |
| 474 | 474 | "):", |
| 475 | 475 | sel, btnClear); |
| @@ -495,11 +495,11 @@ | ||
| 495 | 495 | } |
| 496 | 496 | domInsertPoint.parentNode.insertBefore(wrapper, domInsertPoint); |
| 497 | 497 | F.confirmer(btnClear, { |
| 498 | 498 | /* must come after insertion into the DOM for the pinSize option to work. */ |
| 499 | 499 | pinSize: true, |
| 500 | - confirmText: "DELETE all local edits?", | |
| 500 | + confirmText: "DISCARD all local edits?", | |
| 501 | 501 | onconfirm: function(e){ |
| 502 | 502 | if(P.finfo){ |
| 503 | 503 | const stashed = P.getStashedFinfo(P.finfo); |
| 504 | 504 | P.clearStash(); |
| 505 | 505 | if(stashed) P.loadFile(/*reload after discarding edits*/); |
| 506 | 506 |
| --- src/fossil.page.fileedit.js | |
| +++ src/fossil.page.fileedit.js | |
| @@ -465,11 +465,11 @@ | |
| 465 | D.attr(D.div(),'id','fileedit-stash-selector'), |
| 466 | 'input-with-label' |
| 467 | ); |
| 468 | const sel = this.e.select = D.select(); |
| 469 | const btnClear = this.e.btnClear |
| 470 | = D.button("Clear"); |
| 471 | D.append(wrapper, "Local edits (", |
| 472 | D.append(D.code(), |
| 473 | F.storage.storageImplName()), |
| 474 | "):", |
| 475 | sel, btnClear); |
| @@ -495,11 +495,11 @@ | |
| 495 | } |
| 496 | domInsertPoint.parentNode.insertBefore(wrapper, domInsertPoint); |
| 497 | F.confirmer(btnClear, { |
| 498 | /* must come after insertion into the DOM for the pinSize option to work. */ |
| 499 | pinSize: true, |
| 500 | confirmText: "DELETE all local edits?", |
| 501 | onconfirm: function(e){ |
| 502 | if(P.finfo){ |
| 503 | const stashed = P.getStashedFinfo(P.finfo); |
| 504 | P.clearStash(); |
| 505 | if(stashed) P.loadFile(/*reload after discarding edits*/); |
| 506 |
| --- src/fossil.page.fileedit.js | |
| +++ src/fossil.page.fileedit.js | |
| @@ -465,11 +465,11 @@ | |
| 465 | D.attr(D.div(),'id','fileedit-stash-selector'), |
| 466 | 'input-with-label' |
| 467 | ); |
| 468 | const sel = this.e.select = D.select(); |
| 469 | const btnClear = this.e.btnClear |
| 470 | = D.button("Discard Edits"); |
| 471 | D.append(wrapper, "Local edits (", |
| 472 | D.append(D.code(), |
| 473 | F.storage.storageImplName()), |
| 474 | "):", |
| 475 | sel, btnClear); |
| @@ -495,11 +495,11 @@ | |
| 495 | } |
| 496 | domInsertPoint.parentNode.insertBefore(wrapper, domInsertPoint); |
| 497 | F.confirmer(btnClear, { |
| 498 | /* must come after insertion into the DOM for the pinSize option to work. */ |
| 499 | pinSize: true, |
| 500 | confirmText: "DISCARD all local edits?", |
| 501 | onconfirm: function(e){ |
| 502 | if(P.finfo){ |
| 503 | const stashed = P.getStashedFinfo(P.finfo); |
| 504 | P.clearStash(); |
| 505 | if(stashed) P.loadFile(/*reload after discarding edits*/); |
| 506 |
+31
-22
| --- src/fossil.page.wikiedit.js | ||
| +++ src/fossil.page.wikiedit.js | ||
| @@ -277,11 +277,13 @@ | ||
| 277 | 277 | } |
| 278 | 278 | }; |
| 279 | 279 | |
| 280 | 280 | /** |
| 281 | 281 | Internal helper to get an edit status indicator for the given |
| 282 | - winfo object. | |
| 282 | + winfo object. Pass it a winfo object or one of the "constants" | |
| 283 | + which are assigned as member properties of this function (see | |
| 284 | + below its definition). | |
| 283 | 285 | */ |
| 284 | 286 | const getEditMarker = function f(winfo, textOnly){ |
| 285 | 287 | const esm = F.config.editStateMarkers; |
| 286 | 288 | if(f.NEW===winfo){ /* force is-new */ |
| 287 | 289 | return textOnly ? esm.isNew : |
| @@ -313,15 +315,17 @@ | ||
| 313 | 315 | getEditMarker.NEW = 1; |
| 314 | 316 | getEditMarker.MODIFIED = 2; |
| 315 | 317 | getEditMarker.DELETED = 3; |
| 316 | 318 | |
| 317 | 319 | /** |
| 318 | - Returns true if the given winfo object appears to be "new", else | |
| 319 | - returns false. | |
| 320 | + Returns undefined if winfo is falsy, true if the given winfo | |
| 321 | + object appears to be "new", else returns false. | |
| 320 | 322 | */ |
| 321 | 323 | const winfoIsNew = function(winfo){ |
| 322 | - return 'sandbox'===winfo.type ? false : !winfo.version; | |
| 324 | + if(!winfo) return undefined; | |
| 325 | + else if('sandbox' === winfo.type) return false; | |
| 326 | + else return !winfo.version; | |
| 323 | 327 | }; |
| 324 | 328 | |
| 325 | 329 | /** |
| 326 | 330 | Sets up and maintains the widgets for the list of wiki pages. |
| 327 | 331 | */ |
| @@ -679,12 +683,11 @@ | ||
| 679 | 683 | const wrapper = D.addClass( |
| 680 | 684 | D.attr(D.div(),'id','wikiedit-stash-selector'), |
| 681 | 685 | 'input-with-label' |
| 682 | 686 | ); |
| 683 | 687 | const sel = this.e.select = D.select(); |
| 684 | - const btnClear = this.e.btnClear | |
| 685 | - = D.addClass(D.button("Clear"),'hidden'); | |
| 688 | + const btnClear = this.e.btnClear = D.button("Discard Edits"); | |
| 686 | 689 | D.append(wrapper, "Local edits (", |
| 687 | 690 | D.append(D.code(), |
| 688 | 691 | F.storage.storageImplName()), |
| 689 | 692 | "):", |
| 690 | 693 | sel, btnClear); |
| @@ -698,27 +701,31 @@ | ||
| 698 | 701 | P.addEventListener('wiki-page-loaded',(e)=>this.updateList($stash, e.detail)); |
| 699 | 702 | sel.addEventListener('change',function(e){ |
| 700 | 703 | const opt = this.selectedOptions[0]; |
| 701 | 704 | if(opt && opt._winfo) P.loadPage(opt._winfo); |
| 702 | 705 | }); |
| 703 | - if(P.config.useConfirmerButtons.discardStash){ | |
| 704 | - F.confirmer(btnClear, { | |
| 705 | - confirmText: "REALLY delete ALL local edits?", | |
| 706 | - onconfirm: ()=>P.clearStash(), | |
| 707 | - ticks: F.config.confirmerButtonTicks | |
| 708 | - }); | |
| 709 | - }else{ | |
| 710 | - btnClear.addEventListener('click', ()=>P.clearStash(), false); | |
| 711 | - } | |
| 712 | 706 | if(F.storage.isTransient()){/*Warn if our storage is particularly transient...*/ |
| 713 | 707 | D.append(wrapper, D.append( |
| 714 | 708 | D.addClass(D.span(),'warning'), |
| 715 | 709 | "Warning: persistent storage is not available, "+ |
| 716 | 710 | "so uncomitted edits will not survive a page reload." |
| 717 | 711 | )); |
| 718 | 712 | } |
| 719 | 713 | domInsertPoint.parentNode.insertBefore(wrapper, domInsertPoint); |
| 714 | + if(P.config.useConfirmerButtons.discardStash){ | |
| 715 | + /* Must come after btnClear is in the DOM AND the button must | |
| 716 | + not be hidden, else pinned sizing won't work. */ | |
| 717 | + F.confirmer(btnClear, { | |
| 718 | + pinSize: true, | |
| 719 | + confirmText: "DISCARD all local edits?", | |
| 720 | + onconfirm: ()=>P.clearStash(), | |
| 721 | + ticks: F.config.confirmerButtonTicks | |
| 722 | + }); | |
| 723 | + }else{ | |
| 724 | + btnClear.addEventListener('click', ()=>P.clearStash(), false); | |
| 725 | + } | |
| 726 | + D.addClass(btnClear,'hidden'); | |
| 720 | 727 | $stash._fireStashEvent(/*read the page-load-time stash*/); |
| 721 | 728 | delete this.init; |
| 722 | 729 | }, |
| 723 | 730 | /** |
| 724 | 731 | Regenerates the edit selection list. |
| @@ -746,15 +753,15 @@ | ||
| 746 | 753 | D.addClass(this.e.btnClear, 'hidden'); |
| 747 | 754 | D.option(D.disable(this.e.select),"No local edits"); |
| 748 | 755 | return; |
| 749 | 756 | } |
| 750 | 757 | D.enable(this.e.select); |
| 751 | - if(false){ | |
| 752 | - /* The problem with this Clear button is that it allows the user | |
| 753 | - to nuke a non-empty newly-added page without the failsafe confirmation | |
| 754 | - we have if they use P.e.btnReload. Not yet sure how best to resolve that, | |
| 755 | - so we'll leave the button hidden for the time being. */ | |
| 758 | + if(true){ | |
| 759 | + /* The problem with this Clear button is that it allows the | |
| 760 | + user to nuke a non-empty newly-added page without the | |
| 761 | + failsafe confirmation we have if they use | |
| 762 | + P.e.btnReload. Not yet sure how best to resolve that. */ | |
| 756 | 763 | D.removeClass(this.e.btnClear, 'hidden'); |
| 757 | 764 | } |
| 758 | 765 | D.disable(D.option(this.e.select,0,"Select a local edit...")); |
| 759 | 766 | const currentWinfo = theWinfo || P.winfo || {name:''}; |
| 760 | 767 | ilist.sort(f.compare).forEach(function(winfo,n){ |
| @@ -1127,12 +1134,14 @@ | ||
| 1127 | 1134 | Change the save button depending on whether we have stuff to save |
| 1128 | 1135 | or not. |
| 1129 | 1136 | */ |
| 1130 | 1137 | P.updateSaveButton = function(){ |
| 1131 | 1138 | /** |
| 1132 | - // Current disabled, per forum feedback and MSIE compatibility, but | |
| 1133 | - // might be revisited... | |
| 1139 | + // Currently disabled, per forum feedback and platform-level | |
| 1140 | + // event-handling compatibility, but might be revisited. We now | |
| 1141 | + // use an is-dirty flag instead to prevent saving when no change | |
| 1142 | + // event has fired for the current doc. | |
| 1134 | 1143 | if(!this.winfo || !this.getStashedWinfo(this.winfo)){ |
| 1135 | 1144 | D.disable(this.e.btnSave).innerText = |
| 1136 | 1145 | "No changes to save"; |
| 1137 | 1146 | D.disable(this.e.btnSaveClose); |
| 1138 | 1147 | }else{ |
| 1139 | 1148 |
| --- src/fossil.page.wikiedit.js | |
| +++ src/fossil.page.wikiedit.js | |
| @@ -277,11 +277,13 @@ | |
| 277 | } |
| 278 | }; |
| 279 | |
| 280 | /** |
| 281 | Internal helper to get an edit status indicator for the given |
| 282 | winfo object. |
| 283 | */ |
| 284 | const getEditMarker = function f(winfo, textOnly){ |
| 285 | const esm = F.config.editStateMarkers; |
| 286 | if(f.NEW===winfo){ /* force is-new */ |
| 287 | return textOnly ? esm.isNew : |
| @@ -313,15 +315,17 @@ | |
| 313 | getEditMarker.NEW = 1; |
| 314 | getEditMarker.MODIFIED = 2; |
| 315 | getEditMarker.DELETED = 3; |
| 316 | |
| 317 | /** |
| 318 | Returns true if the given winfo object appears to be "new", else |
| 319 | returns false. |
| 320 | */ |
| 321 | const winfoIsNew = function(winfo){ |
| 322 | return 'sandbox'===winfo.type ? false : !winfo.version; |
| 323 | }; |
| 324 | |
| 325 | /** |
| 326 | Sets up and maintains the widgets for the list of wiki pages. |
| 327 | */ |
| @@ -679,12 +683,11 @@ | |
| 679 | const wrapper = D.addClass( |
| 680 | D.attr(D.div(),'id','wikiedit-stash-selector'), |
| 681 | 'input-with-label' |
| 682 | ); |
| 683 | const sel = this.e.select = D.select(); |
| 684 | const btnClear = this.e.btnClear |
| 685 | = D.addClass(D.button("Clear"),'hidden'); |
| 686 | D.append(wrapper, "Local edits (", |
| 687 | D.append(D.code(), |
| 688 | F.storage.storageImplName()), |
| 689 | "):", |
| 690 | sel, btnClear); |
| @@ -698,27 +701,31 @@ | |
| 698 | P.addEventListener('wiki-page-loaded',(e)=>this.updateList($stash, e.detail)); |
| 699 | sel.addEventListener('change',function(e){ |
| 700 | const opt = this.selectedOptions[0]; |
| 701 | if(opt && opt._winfo) P.loadPage(opt._winfo); |
| 702 | }); |
| 703 | if(P.config.useConfirmerButtons.discardStash){ |
| 704 | F.confirmer(btnClear, { |
| 705 | confirmText: "REALLY delete ALL local edits?", |
| 706 | onconfirm: ()=>P.clearStash(), |
| 707 | ticks: F.config.confirmerButtonTicks |
| 708 | }); |
| 709 | }else{ |
| 710 | btnClear.addEventListener('click', ()=>P.clearStash(), false); |
| 711 | } |
| 712 | if(F.storage.isTransient()){/*Warn if our storage is particularly transient...*/ |
| 713 | D.append(wrapper, D.append( |
| 714 | D.addClass(D.span(),'warning'), |
| 715 | "Warning: persistent storage is not available, "+ |
| 716 | "so uncomitted edits will not survive a page reload." |
| 717 | )); |
| 718 | } |
| 719 | domInsertPoint.parentNode.insertBefore(wrapper, domInsertPoint); |
| 720 | $stash._fireStashEvent(/*read the page-load-time stash*/); |
| 721 | delete this.init; |
| 722 | }, |
| 723 | /** |
| 724 | Regenerates the edit selection list. |
| @@ -746,15 +753,15 @@ | |
| 746 | D.addClass(this.e.btnClear, 'hidden'); |
| 747 | D.option(D.disable(this.e.select),"No local edits"); |
| 748 | return; |
| 749 | } |
| 750 | D.enable(this.e.select); |
| 751 | if(false){ |
| 752 | /* The problem with this Clear button is that it allows the user |
| 753 | to nuke a non-empty newly-added page without the failsafe confirmation |
| 754 | we have if they use P.e.btnReload. Not yet sure how best to resolve that, |
| 755 | so we'll leave the button hidden for the time being. */ |
| 756 | D.removeClass(this.e.btnClear, 'hidden'); |
| 757 | } |
| 758 | D.disable(D.option(this.e.select,0,"Select a local edit...")); |
| 759 | const currentWinfo = theWinfo || P.winfo || {name:''}; |
| 760 | ilist.sort(f.compare).forEach(function(winfo,n){ |
| @@ -1127,12 +1134,14 @@ | |
| 1127 | Change the save button depending on whether we have stuff to save |
| 1128 | or not. |
| 1129 | */ |
| 1130 | P.updateSaveButton = function(){ |
| 1131 | /** |
| 1132 | // Current disabled, per forum feedback and MSIE compatibility, but |
| 1133 | // might be revisited... |
| 1134 | if(!this.winfo || !this.getStashedWinfo(this.winfo)){ |
| 1135 | D.disable(this.e.btnSave).innerText = |
| 1136 | "No changes to save"; |
| 1137 | D.disable(this.e.btnSaveClose); |
| 1138 | }else{ |
| 1139 |
| --- src/fossil.page.wikiedit.js | |
| +++ src/fossil.page.wikiedit.js | |
| @@ -277,11 +277,13 @@ | |
| 277 | } |
| 278 | }; |
| 279 | |
| 280 | /** |
| 281 | Internal helper to get an edit status indicator for the given |
| 282 | winfo object. Pass it a winfo object or one of the "constants" |
| 283 | which are assigned as member properties of this function (see |
| 284 | below its definition). |
| 285 | */ |
| 286 | const getEditMarker = function f(winfo, textOnly){ |
| 287 | const esm = F.config.editStateMarkers; |
| 288 | if(f.NEW===winfo){ /* force is-new */ |
| 289 | return textOnly ? esm.isNew : |
| @@ -313,15 +315,17 @@ | |
| 315 | getEditMarker.NEW = 1; |
| 316 | getEditMarker.MODIFIED = 2; |
| 317 | getEditMarker.DELETED = 3; |
| 318 | |
| 319 | /** |
| 320 | Returns undefined if winfo is falsy, true if the given winfo |
| 321 | object appears to be "new", else returns false. |
| 322 | */ |
| 323 | const winfoIsNew = function(winfo){ |
| 324 | if(!winfo) return undefined; |
| 325 | else if('sandbox' === winfo.type) return false; |
| 326 | else return !winfo.version; |
| 327 | }; |
| 328 | |
| 329 | /** |
| 330 | Sets up and maintains the widgets for the list of wiki pages. |
| 331 | */ |
| @@ -679,12 +683,11 @@ | |
| 683 | const wrapper = D.addClass( |
| 684 | D.attr(D.div(),'id','wikiedit-stash-selector'), |
| 685 | 'input-with-label' |
| 686 | ); |
| 687 | const sel = this.e.select = D.select(); |
| 688 | const btnClear = this.e.btnClear = D.button("Discard Edits"); |
| 689 | D.append(wrapper, "Local edits (", |
| 690 | D.append(D.code(), |
| 691 | F.storage.storageImplName()), |
| 692 | "):", |
| 693 | sel, btnClear); |
| @@ -698,27 +701,31 @@ | |
| 701 | P.addEventListener('wiki-page-loaded',(e)=>this.updateList($stash, e.detail)); |
| 702 | sel.addEventListener('change',function(e){ |
| 703 | const opt = this.selectedOptions[0]; |
| 704 | if(opt && opt._winfo) P.loadPage(opt._winfo); |
| 705 | }); |
| 706 | if(F.storage.isTransient()){/*Warn if our storage is particularly transient...*/ |
| 707 | D.append(wrapper, D.append( |
| 708 | D.addClass(D.span(),'warning'), |
| 709 | "Warning: persistent storage is not available, "+ |
| 710 | "so uncomitted edits will not survive a page reload." |
| 711 | )); |
| 712 | } |
| 713 | domInsertPoint.parentNode.insertBefore(wrapper, domInsertPoint); |
| 714 | if(P.config.useConfirmerButtons.discardStash){ |
| 715 | /* Must come after btnClear is in the DOM AND the button must |
| 716 | not be hidden, else pinned sizing won't work. */ |
| 717 | F.confirmer(btnClear, { |
| 718 | pinSize: true, |
| 719 | confirmText: "DISCARD all local edits?", |
| 720 | onconfirm: ()=>P.clearStash(), |
| 721 | ticks: F.config.confirmerButtonTicks |
| 722 | }); |
| 723 | }else{ |
| 724 | btnClear.addEventListener('click', ()=>P.clearStash(), false); |
| 725 | } |
| 726 | D.addClass(btnClear,'hidden'); |
| 727 | $stash._fireStashEvent(/*read the page-load-time stash*/); |
| 728 | delete this.init; |
| 729 | }, |
| 730 | /** |
| 731 | Regenerates the edit selection list. |
| @@ -746,15 +753,15 @@ | |
| 753 | D.addClass(this.e.btnClear, 'hidden'); |
| 754 | D.option(D.disable(this.e.select),"No local edits"); |
| 755 | return; |
| 756 | } |
| 757 | D.enable(this.e.select); |
| 758 | if(true){ |
| 759 | /* The problem with this Clear button is that it allows the |
| 760 | user to nuke a non-empty newly-added page without the |
| 761 | failsafe confirmation we have if they use |
| 762 | P.e.btnReload. Not yet sure how best to resolve that. */ |
| 763 | D.removeClass(this.e.btnClear, 'hidden'); |
| 764 | } |
| 765 | D.disable(D.option(this.e.select,0,"Select a local edit...")); |
| 766 | const currentWinfo = theWinfo || P.winfo || {name:''}; |
| 767 | ilist.sort(f.compare).forEach(function(winfo,n){ |
| @@ -1127,12 +1134,14 @@ | |
| 1134 | Change the save button depending on whether we have stuff to save |
| 1135 | or not. |
| 1136 | */ |
| 1137 | P.updateSaveButton = function(){ |
| 1138 | /** |
| 1139 | // Currently disabled, per forum feedback and platform-level |
| 1140 | // event-handling compatibility, but might be revisited. We now |
| 1141 | // use an is-dirty flag instead to prevent saving when no change |
| 1142 | // event has fired for the current doc. |
| 1143 | if(!this.winfo || !this.getStashedWinfo(this.winfo)){ |
| 1144 | D.disable(this.e.btnSave).innerText = |
| 1145 | "No changes to save"; |
| 1146 | D.disable(this.e.btnSaveClose); |
| 1147 | }else{ |
| 1148 |