Fossil SCM

The save button now is now moved to the current tab when switching tabs, for the save/preview/diff tabs.

stephan 2020-07-31 09:57 ajax-wiki-editor
Commit acdd76539ca6f9efc5607ecbf86bf625f6b0040a1d71ae9131f5aad69bfe431d
--- src/fossil.page.wikiedit.js
+++ src/fossil.page.wikiedit.js
@@ -526,11 +526,11 @@
526526
527527
D.append(parentElem, btn);
528528
btn.addEventListener('click', ()=>this.loadList(), false);
529529
this.loadList();
530530
sel.addEventListener('change', (e)=>P.loadPage(e.target.value), false);
531
- F.page.addEventListener('wiki-stash-updated', ()=>this.refreshStashMarks(), false);
531
+ F.page.addEventListener('wiki-stash-updated', ()=>this.refreshStashMarks());
532532
delete this.init;
533533
}
534534
};
535535
536536
/**
@@ -610,35 +610,42 @@
610610
E('#fossil-status-bar'), P.tabs.e.tabs
611611
);
612612
P.tabs.addEventListener(
613613
/* Set up some before-switch-to tab event tasks... */
614614
'before-switch-to', function(ev){
615
- if(ev.detail===P.e.tabs.preview){
616
- P.baseHrefForWiki();
615
+ const theTab = ev.detail, btnSlot = theTab.querySelector('.save-button-slot');
616
+ if(btnSlot){
617
+ /* Several places make sense for a save button, so we'll
618
+ move that button around to those tabs where it makes sense. */
619
+ btnSlot.parentNode.insertBefore( P.e.btnSave, btnSlot );
617620
P.updateSaveButton();
621
+ }
622
+ if(theTab===P.e.tabs.preview){
623
+ P.baseHrefForWiki();
618624
if(P.previewNeedsUpdate && P.e.cbAutoPreview.checked) P.preview();
619
- }else if(ev.detail===P.e.tabs.diff){
625
+ }else if(theTab===P.e.tabs.diff){
620626
/* Work around a weird bug where the page gets wider than
621627
the window when the diff tab is NOT in view and the
622628
current SBS diff widget is wider than the window. When
623629
the diff IS in view then CSS overflow magically reduces
624630
the page size again. Weird. Maybe FF-specific. Note that
625631
this weirdness happens even though P.e.diffTarget's parent
626632
is hidden (and therefore P.e.diffTarget is also hidden).
627633
*/
628634
D.removeClass(P.e.diffTarget, 'hidden');
629
- }else if(ev.detail===P.e.tabs.misc){
635
+ }else if(theTab===P.e.tabs.misc){
630636
P.updateAttachmentView();
631637
}
632638
}
633639
);
634640
P.tabs.addEventListener(
635641
/* Set up auto-refresh of the preview tab... */
636642
'before-switch-from', function(ev){
637
- if(ev.detail===P.e.tabs.preview){
643
+ const theTab = ev.detail;
644
+ if(theTab===P.e.tabs.preview){
638645
P.baseHrefRestore();
639
- }else if(ev.detail===P.e.tabs.diff){
646
+ }else if(theTab===P.e.tabs.diff){
640647
/* See notes in the before-switch-to handler. */
641648
D.addClass(P.e.diffTarget, 'hidden');
642649
}
643650
}
644651
);
@@ -767,11 +774,12 @@
767774
}
768775
P.updatePageTitle();
769776
},
770777
false
771778
);
772
- P.updatePageTitle().updateAttachmentView();
779
+ P.addEventListener('wiki-stash-updated', ()=>P.updateSaveButton())
780
+ .updatePageTitle().updateAttachmentView().updateSaveButton();
773781
}/*F.onPageLoad()*/);
774782
775783
/**
776784
Returns true if fossil.page.winfo is set, indicating that a page
777785
has been loaded, else it reports an error and returns false.
778786
--- src/fossil.page.wikiedit.js
+++ src/fossil.page.wikiedit.js
@@ -526,11 +526,11 @@
526
527 D.append(parentElem, btn);
528 btn.addEventListener('click', ()=>this.loadList(), false);
529 this.loadList();
530 sel.addEventListener('change', (e)=>P.loadPage(e.target.value), false);
531 F.page.addEventListener('wiki-stash-updated', ()=>this.refreshStashMarks(), false);
532 delete this.init;
533 }
534 };
535
536 /**
@@ -610,35 +610,42 @@
610 E('#fossil-status-bar'), P.tabs.e.tabs
611 );
612 P.tabs.addEventListener(
613 /* Set up some before-switch-to tab event tasks... */
614 'before-switch-to', function(ev){
615 if(ev.detail===P.e.tabs.preview){
616 P.baseHrefForWiki();
 
 
 
617 P.updateSaveButton();
 
 
 
618 if(P.previewNeedsUpdate && P.e.cbAutoPreview.checked) P.preview();
619 }else if(ev.detail===P.e.tabs.diff){
620 /* Work around a weird bug where the page gets wider than
621 the window when the diff tab is NOT in view and the
622 current SBS diff widget is wider than the window. When
623 the diff IS in view then CSS overflow magically reduces
624 the page size again. Weird. Maybe FF-specific. Note that
625 this weirdness happens even though P.e.diffTarget's parent
626 is hidden (and therefore P.e.diffTarget is also hidden).
627 */
628 D.removeClass(P.e.diffTarget, 'hidden');
629 }else if(ev.detail===P.e.tabs.misc){
630 P.updateAttachmentView();
631 }
632 }
633 );
634 P.tabs.addEventListener(
635 /* Set up auto-refresh of the preview tab... */
636 'before-switch-from', function(ev){
637 if(ev.detail===P.e.tabs.preview){
 
638 P.baseHrefRestore();
639 }else if(ev.detail===P.e.tabs.diff){
640 /* See notes in the before-switch-to handler. */
641 D.addClass(P.e.diffTarget, 'hidden');
642 }
643 }
644 );
@@ -767,11 +774,12 @@
767 }
768 P.updatePageTitle();
769 },
770 false
771 );
772 P.updatePageTitle().updateAttachmentView();
 
773 }/*F.onPageLoad()*/);
774
775 /**
776 Returns true if fossil.page.winfo is set, indicating that a page
777 has been loaded, else it reports an error and returns false.
778
--- src/fossil.page.wikiedit.js
+++ src/fossil.page.wikiedit.js
@@ -526,11 +526,11 @@
526
527 D.append(parentElem, btn);
528 btn.addEventListener('click', ()=>this.loadList(), false);
529 this.loadList();
530 sel.addEventListener('change', (e)=>P.loadPage(e.target.value), false);
531 F.page.addEventListener('wiki-stash-updated', ()=>this.refreshStashMarks());
532 delete this.init;
533 }
534 };
535
536 /**
@@ -610,35 +610,42 @@
610 E('#fossil-status-bar'), P.tabs.e.tabs
611 );
612 P.tabs.addEventListener(
613 /* Set up some before-switch-to tab event tasks... */
614 'before-switch-to', function(ev){
615 const theTab = ev.detail, btnSlot = theTab.querySelector('.save-button-slot');
616 if(btnSlot){
617 /* Several places make sense for a save button, so we'll
618 move that button around to those tabs where it makes sense. */
619 btnSlot.parentNode.insertBefore( P.e.btnSave, btnSlot );
620 P.updateSaveButton();
621 }
622 if(theTab===P.e.tabs.preview){
623 P.baseHrefForWiki();
624 if(P.previewNeedsUpdate && P.e.cbAutoPreview.checked) P.preview();
625 }else if(theTab===P.e.tabs.diff){
626 /* Work around a weird bug where the page gets wider than
627 the window when the diff tab is NOT in view and the
628 current SBS diff widget is wider than the window. When
629 the diff IS in view then CSS overflow magically reduces
630 the page size again. Weird. Maybe FF-specific. Note that
631 this weirdness happens even though P.e.diffTarget's parent
632 is hidden (and therefore P.e.diffTarget is also hidden).
633 */
634 D.removeClass(P.e.diffTarget, 'hidden');
635 }else if(theTab===P.e.tabs.misc){
636 P.updateAttachmentView();
637 }
638 }
639 );
640 P.tabs.addEventListener(
641 /* Set up auto-refresh of the preview tab... */
642 'before-switch-from', function(ev){
643 const theTab = ev.detail;
644 if(theTab===P.e.tabs.preview){
645 P.baseHrefRestore();
646 }else if(theTab===P.e.tabs.diff){
647 /* See notes in the before-switch-to handler. */
648 D.addClass(P.e.diffTarget, 'hidden');
649 }
650 }
651 );
@@ -767,11 +774,12 @@
774 }
775 P.updatePageTitle();
776 },
777 false
778 );
779 P.addEventListener('wiki-stash-updated', ()=>P.updateSaveButton())
780 .updatePageTitle().updateAttachmentView().updateSaveButton();
781 }/*F.onPageLoad()*/);
782
783 /**
784 Returns true if fossil.page.winfo is set, indicating that a page
785 has been loaded, else it reports an error and returns false.
786
--- src/style.wikiedit.css
+++ src/style.wikiedit.css
@@ -104,5 +104,12 @@
104104
margin: 0;
105105
}
106106
body.wikiedit span.mini-tip {
107107
font-size: 80%;
108108
}
109
+
110
+body.wikiedit span.save-button-slot {
111
+ /* These invisible placeholders mark spots in the UI
112
+ (max. 1 per tab) to where the save button gets
113
+ relocated as we switch between tabs. */
114
+ display: none;
115
+}
109116
--- src/style.wikiedit.css
+++ src/style.wikiedit.css
@@ -104,5 +104,12 @@
104 margin: 0;
105 }
106 body.wikiedit span.mini-tip {
107 font-size: 80%;
108 }
 
 
 
 
 
 
 
109
--- src/style.wikiedit.css
+++ src/style.wikiedit.css
@@ -104,5 +104,12 @@
104 margin: 0;
105 }
106 body.wikiedit span.mini-tip {
107 font-size: 80%;
108 }
109
110 body.wikiedit span.save-button-slot {
111 /* These invisible placeholders mark spots in the UI
112 (max. 1 per tab) to where the save button gets
113 relocated as we switch between tabs. */
114 display: none;
115 }
116
+7 -3
--- src/wiki.c
+++ src/wiki.c
@@ -1131,11 +1131,11 @@
11311131
11321132
/******* Content tab *******/
11331133
{
11341134
CX("<div id='wikiedit-tab-content' "
11351135
"data-tab-parent='wikiedit-tabs' "
1136
- "data-tab-label='Wiki Editor' "
1136
+ "data-tab-label='Editor' "
11371137
"class='hidden'"
11381138
">");
11391139
CX("<div class='flex-container flex-row child-gap-small'>");
11401140
CX("<span class='input-with-label'>"
11411141
"<label>Mime type</label>");
@@ -1152,10 +1152,13 @@
11521152
"title='Reload the file from the server, discarding "
11531153
"any local edits. To help avoid accidental loss of "
11541154
"edits, it requires confirmation (a second click) within "
11551155
"a few seconds or it will not reload.'"
11561156
">Discard &amp; Reload</button>");
1157
+ CX("<button class='wikiedit-save' disabled='disabled'>"
1158
+ "Save</button>"/*will get moved around dynamically*/);
1159
+ CX("<span class='save-button-slot'></span>");
11571160
CX("</div>");
11581161
CX("<div class='flex-container flex-column stretch'>");
11591162
CX("<textarea name='content' id='wikiedit-content-editor' "
11601163
"class='wikiedit' "
11611164
"rows='25' cols='80'>");
@@ -1165,11 +1168,11 @@
11651168
}
11661169
/****** Preview tab ******/
11671170
{
11681171
CX("<div id='wikiedit-tab-preview' "
11691172
"data-tab-parent='wikiedit-tabs' "
1170
- "data-tab-label='Preview &amp; Save' "
1173
+ "data-tab-label='Preview' "
11711174
"class='hidden'"
11721175
">");
11731176
CX("<div class='wikiedit-options flex-container flex-row'>");
11741177
CX("<button id='btn-preview-refresh' "
11751178
"data-f-preview-from='wikiContent' "
@@ -1179,18 +1182,18 @@
11791182
"data-f-preview-via='_postPreview' "
11801183
/* ^^^ fossil.page[methodName](content, callback) */
11811184
"data-f-preview-to='#wikiedit-tab-preview-wrapper' "
11821185
/* ^^^ dest elem ID */
11831186
">Refresh</button>");
1184
- CX("<button class='wikiedit-save'>Save</button>");
11851187
/* Toggle auto-update of preview when the Preview tab is selected. */
11861188
style_labeled_checkbox("cb-preview-autoupdate",
11871189
NULL,
11881190
"Auto-refresh?",
11891191
"1", 1,
11901192
"If on, the preview will automatically "
11911193
"refresh when this tab is selected.");
1194
+ CX("<span class='save-button-slot'></span>");
11921195
CX("</div>"/*.wikiedit-options*/);
11931196
CX("<div id='wikiedit-tab-preview-wrapper'></div>");
11941197
CX("</div>"/*#wikiedit-tab-preview*/);
11951198
}
11961199
@@ -1204,10 +1207,11 @@
12041207
12051208
CX("<div class='wikiedit-options flex-container flex-row' "
12061209
"id='wikiedit-tab-diff-buttons'>");
12071210
CX("<button class='sbs'>Side-by-side</button>"
12081211
"<button class='unified'>Unified</button>");
1212
+ CX("<span class='save-button-slot'></span>");
12091213
CX("</div>");
12101214
CX("<div id='wikiedit-tab-diff-wrapper'>"
12111215
"Diffs will be shown here."
12121216
"</div>");
12131217
CX("</div>"/*#wikiedit-tab-diff*/);
12141218
--- src/wiki.c
+++ src/wiki.c
@@ -1131,11 +1131,11 @@
1131
1132 /******* Content tab *******/
1133 {
1134 CX("<div id='wikiedit-tab-content' "
1135 "data-tab-parent='wikiedit-tabs' "
1136 "data-tab-label='Wiki Editor' "
1137 "class='hidden'"
1138 ">");
1139 CX("<div class='flex-container flex-row child-gap-small'>");
1140 CX("<span class='input-with-label'>"
1141 "<label>Mime type</label>");
@@ -1152,10 +1152,13 @@
1152 "title='Reload the file from the server, discarding "
1153 "any local edits. To help avoid accidental loss of "
1154 "edits, it requires confirmation (a second click) within "
1155 "a few seconds or it will not reload.'"
1156 ">Discard &amp; Reload</button>");
 
 
 
1157 CX("</div>");
1158 CX("<div class='flex-container flex-column stretch'>");
1159 CX("<textarea name='content' id='wikiedit-content-editor' "
1160 "class='wikiedit' "
1161 "rows='25' cols='80'>");
@@ -1165,11 +1168,11 @@
1165 }
1166 /****** Preview tab ******/
1167 {
1168 CX("<div id='wikiedit-tab-preview' "
1169 "data-tab-parent='wikiedit-tabs' "
1170 "data-tab-label='Preview &amp; Save' "
1171 "class='hidden'"
1172 ">");
1173 CX("<div class='wikiedit-options flex-container flex-row'>");
1174 CX("<button id='btn-preview-refresh' "
1175 "data-f-preview-from='wikiContent' "
@@ -1179,18 +1182,18 @@
1179 "data-f-preview-via='_postPreview' "
1180 /* ^^^ fossil.page[methodName](content, callback) */
1181 "data-f-preview-to='#wikiedit-tab-preview-wrapper' "
1182 /* ^^^ dest elem ID */
1183 ">Refresh</button>");
1184 CX("<button class='wikiedit-save'>Save</button>");
1185 /* Toggle auto-update of preview when the Preview tab is selected. */
1186 style_labeled_checkbox("cb-preview-autoupdate",
1187 NULL,
1188 "Auto-refresh?",
1189 "1", 1,
1190 "If on, the preview will automatically "
1191 "refresh when this tab is selected.");
 
1192 CX("</div>"/*.wikiedit-options*/);
1193 CX("<div id='wikiedit-tab-preview-wrapper'></div>");
1194 CX("</div>"/*#wikiedit-tab-preview*/);
1195 }
1196
@@ -1204,10 +1207,11 @@
1204
1205 CX("<div class='wikiedit-options flex-container flex-row' "
1206 "id='wikiedit-tab-diff-buttons'>");
1207 CX("<button class='sbs'>Side-by-side</button>"
1208 "<button class='unified'>Unified</button>");
 
1209 CX("</div>");
1210 CX("<div id='wikiedit-tab-diff-wrapper'>"
1211 "Diffs will be shown here."
1212 "</div>");
1213 CX("</div>"/*#wikiedit-tab-diff*/);
1214
--- src/wiki.c
+++ src/wiki.c
@@ -1131,11 +1131,11 @@
1131
1132 /******* Content tab *******/
1133 {
1134 CX("<div id='wikiedit-tab-content' "
1135 "data-tab-parent='wikiedit-tabs' "
1136 "data-tab-label='Editor' "
1137 "class='hidden'"
1138 ">");
1139 CX("<div class='flex-container flex-row child-gap-small'>");
1140 CX("<span class='input-with-label'>"
1141 "<label>Mime type</label>");
@@ -1152,10 +1152,13 @@
1152 "title='Reload the file from the server, discarding "
1153 "any local edits. To help avoid accidental loss of "
1154 "edits, it requires confirmation (a second click) within "
1155 "a few seconds or it will not reload.'"
1156 ">Discard &amp; Reload</button>");
1157 CX("<button class='wikiedit-save' disabled='disabled'>"
1158 "Save</button>"/*will get moved around dynamically*/);
1159 CX("<span class='save-button-slot'></span>");
1160 CX("</div>");
1161 CX("<div class='flex-container flex-column stretch'>");
1162 CX("<textarea name='content' id='wikiedit-content-editor' "
1163 "class='wikiedit' "
1164 "rows='25' cols='80'>");
@@ -1165,11 +1168,11 @@
1168 }
1169 /****** Preview tab ******/
1170 {
1171 CX("<div id='wikiedit-tab-preview' "
1172 "data-tab-parent='wikiedit-tabs' "
1173 "data-tab-label='Preview' "
1174 "class='hidden'"
1175 ">");
1176 CX("<div class='wikiedit-options flex-container flex-row'>");
1177 CX("<button id='btn-preview-refresh' "
1178 "data-f-preview-from='wikiContent' "
@@ -1179,18 +1182,18 @@
1182 "data-f-preview-via='_postPreview' "
1183 /* ^^^ fossil.page[methodName](content, callback) */
1184 "data-f-preview-to='#wikiedit-tab-preview-wrapper' "
1185 /* ^^^ dest elem ID */
1186 ">Refresh</button>");
 
1187 /* Toggle auto-update of preview when the Preview tab is selected. */
1188 style_labeled_checkbox("cb-preview-autoupdate",
1189 NULL,
1190 "Auto-refresh?",
1191 "1", 1,
1192 "If on, the preview will automatically "
1193 "refresh when this tab is selected.");
1194 CX("<span class='save-button-slot'></span>");
1195 CX("</div>"/*.wikiedit-options*/);
1196 CX("<div id='wikiedit-tab-preview-wrapper'></div>");
1197 CX("</div>"/*#wikiedit-tab-preview*/);
1198 }
1199
@@ -1204,10 +1207,11 @@
1207
1208 CX("<div class='wikiedit-options flex-container flex-row' "
1209 "id='wikiedit-tab-diff-buttons'>");
1210 CX("<button class='sbs'>Side-by-side</button>"
1211 "<button class='unified'>Unified</button>");
1212 CX("<span class='save-button-slot'></span>");
1213 CX("</div>");
1214 CX("<div id='wikiedit-tab-diff-wrapper'>"
1215 "Diffs will be shown here."
1216 "</div>");
1217 CX("</div>"/*#wikiedit-tab-diff*/);
1218

Keyboard Shortcuts

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