Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Experimentally added '?' help buttons in wikiedit. Experimentally emit all fossil.XYZ APIs, rather than selected ones, to test whether that reduces overall transmission together with caching. DOM init-time timing workarounds to get confirmer buttons to pin their sizes properly. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | misc-js-experiments |
| Files: | files | file ages | folders |
| SHA3-256: |
9edbb7eab1b0fe489d79cbdfbf8d9394 |
| User & Date: | stephan 2020-08-24 20:49:12.059 |
Context
|
2020-08-24
| ||
| 22:20 | Moved C routines which emit fossil.XYZ JS APIs from style.c to builtin.c, and renamed appropriately. Added flag to output_text_with_line_numbers() to disable emit of JS (needed for fileedit preview, at a minimum). The experimental emitting of all fossil.XYZ APIs at once is now limited to bundled mode, as that's the only place it's potentially of benefit. ... (check-in: c515e5fd9f user: stephan tags: misc-js-experiments) | |
| 20:49 | Experimentally added '?' help buttons in wikiedit. Experimentally emit all fossil.XYZ APIs, rather than selected ones, to test whether that reduces overall transmission together with caching. DOM init-time timing workarounds to get confirmer buttons to pin their sizes properly. ... (check-in: 9edbb7eab1 user: stephan tags: misc-js-experiments) | |
| 20:24 | Changed how fossil.confirmer pinSize option computes element width to be more robust in the face of CSS 'auto' width values. ... (check-in: 1f4143ba28 user: stephan tags: trunk) | |
Changes
Changes to src/default.css.
| ︙ | ︙ | |||
1098 1099 1100 1101 1102 1103 1104 |
font-size: 175%;
}
.font-size-200 {
font-size: 200%;
}
/**
| | | | | | > | 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 |
font-size: 175%;
}
.font-size-200 {
font-size: 200%;
}
/**
.input-with-label is intended to be a wrapper element which contain
both a LABEL tag and an INPUT or SELECT control. The wrapper is
"necessary", as opposed to placing the INPUT in the LABEL, so that
we can include multiple INPUT elements (e.g. a set of radio
buttons). Note that these elements must sometimes be BLOCK elements
(e.g. DIV) so that certain nesting constructs are legal.
*/
.input-with-label {
border: 1px inset #808080;
border-radius: 0.25em;
padding: 0.25em 0.4em;
margin: 0 0.5em;
display: inline-block;
|
| ︙ | ︙ | |||
1291 1292 1293 1294 1295 1296 1297 |
color: black;
}
blockquote.file-content {
/* file content block in the /file page */
margin: 0 1em;
}
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 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 |
color: black;
}
blockquote.file-content {
/* file content block in the /file page */
margin: 0 1em;
}
/**
Circular "help" buttons intended to be placed to the right of
another element and hold text text for it. These get initialized
automatically at page startup via fossil.popupwidget.js. All child
content gets moved out of the DOM and shown in a popup when they
are clicked. They may be SPAN elements if their children are all
inline elements, otherwise they must be DIVs (block elements)
so that nesting of block elements is legal.
*/
.help-buttonlet {
display: inline-block;
min-width: 1rem;
max-width: 1rem;
min-height: 1rem;
max-height: 1rem;
font-size: 0.9em;
border-radius: 0.5rem;
background-color: rgba(54, 54, 255,0.4);
color: rgb(255, 255, 255);
cursor: pointer;
font-family: monspace;
text-align: center;
margin: 0 0 0 0.35em;
border-width: 1px;
border-style: outset;
font-weight: 700;
overflow: hidden;
}
.help-buttonlet::before {
content: "?";
}
/**
We really want to hide all help text via CSS but CSS cannot select
TEXT nodes. Thus we move them out of the way programmatically
during initialization.
*/
.help-buttonlet > *{}
/**
CSS class for PopupWidget which wraps .help-buttonlet content.
They also have class fossil-tooltip. We need an overly-exact
selector here to be certain that this class's style overrides
that of fossil-tooltip.
*/
.fossil-tooltip.help-buttonlet-content {
cursor: default;
text-align: left;
border-style: outset;
}
|
Changes to src/fileedit.c.
| ︙ | ︙ | |||
1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 |
"committing or force-reloading a file, local edits to that "
"file/check-in combination are discarded.</li>");
CX("</ul>");
}
CX("</div>"/*#fileedit-tab-help*/);
builtin_request_js("sbsdiff.js");
style_emit_fossil_js_apis(0, "fetch", "dom", "tabs", "confirmer",
"storage", 0);
builtin_fulfill_js_requests();
/*
** Set up a JS-side mapping of the AJAX_RENDER_xyz values. This is
** used for dynamically toggling certain UI components on and off.
** Must come after window.fossil has been intialized and before
** fossil.page.fileedit.js. Potential TODO: move this into the
** window.fossil bootstrapping so that we don't have to "fulfill"
| > > > > > > | 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 |
"committing or force-reloading a file, local edits to that "
"file/check-in combination are discarded.</li>");
CX("</ul>");
}
CX("</div>"/*#fileedit-tab-help*/);
builtin_request_js("sbsdiff.js");
#if 0
style_emit_fossil_js_apis(0, "fetch", "dom", "tabs", "confirmer",
"storage", 0);
#else
style_emit_all_fossil_js_apis();
builtin_fulfill_js_requests();
builtin_request_js("fossil.page.fileedit.js");
#endif
builtin_fulfill_js_requests();
/*
** Set up a JS-side mapping of the AJAX_RENDER_xyz values. This is
** used for dynamically toggling certain UI components on and off.
** Must come after window.fossil has been intialized and before
** fossil.page.fileedit.js. Potential TODO: move this into the
** window.fossil bootstrapping so that we don't have to "fulfill"
|
| ︙ | ︙ |
Changes to src/fossil.bootstrap.js.
| ︙ | ︙ | |||
326 327 328 329 330 331 332 333 334 335 336 337 338 339 |
Convenience wrapper which adds an onload event listener to the
window object. Returns this.
*/
F.onPageLoad = function(callback){
window.addEventListener('load', callback, false);
return this;
};
/**
Assuming name is a repo-style filename, this function returns
a shortened form of that name:
.../LastDirectoryPart/FilenamePart
| > > > > > > > > | 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 |
Convenience wrapper which adds an onload event listener to the
window object. Returns this.
*/
F.onPageLoad = function(callback){
window.addEventListener('load', callback, false);
return this;
};
/**
Convenience wrapper which adds a DOMContentLoadedevent listener
to the window object. Returns this.
*/
F.onDOMContentLoaded = function(callback){
window.addEventListener('DOMContentLoaded', callback, false);
return this;
};
/**
Assuming name is a repo-style filename, this function returns
a shortened form of that name:
.../LastDirectoryPart/FilenamePart
|
| ︙ | ︙ |
Changes to src/fossil.numbered-lines.js.
1 2 3 4 5 6 7 8 9 10 |
(function callee(arg){
/*
JS counterpart of info.c:output_text_with_line_numbers()
which ties an event handler to the line numbers to allow
selection of individual lines or ranges.
Requires: fossil.bootstrap, fossil.dom, fossil.popupwidget,
fossil.copybutton
*/
var tbl = arg || document.querySelectorAll('table.numbered-lines');
| < | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
(function callee(arg){
/*
JS counterpart of info.c:output_text_with_line_numbers()
which ties an event handler to the line numbers to allow
selection of individual lines or ranges.
Requires: fossil.bootstrap, fossil.dom, fossil.popupwidget,
fossil.copybutton
*/
var tbl = arg || document.querySelectorAll('table.numbered-lines');
if(tbl && !arg){
if(tbl.length>1){ /* multiple query results: recurse */
tbl.forEach( (t)=>callee(t) );
return;
}else{/* single query result */
tbl = tbl[0];
}
}
if(!tbl) return /* no matching elements */;
const F = window.fossil, D = F.dom;
const tdLn = tbl.querySelector('td.line-numbers');
const lineState = {
urlArgs: (window.location.search||'?')
.replace(/&?\budc=[^&]*/,'') /* "update display prefs cookie" */
.replace(/&?\bln=[^&]*/,'') /* inbound line number/range */
.replace('?&','?'),
|
| ︙ | ︙ |
Changes to src/fossil.page.fileedit.js.
| ︙ | ︙ | |||
490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 |
D.append(wrapper, D.append(
D.addClass(D.span(),'warning'),
"Warning: persistent storage is not available, "+
"so uncomitted edits will not survive a page reload."
));
}
domInsertPoint.parentNode.insertBefore(wrapper, domInsertPoint);
F.confirmer(btnClear, {
/* must come after insertion into the DOM for the pinSize option to work. */
pinSize: true,
confirmText: "DISCARD all local edits?",
onconfirm: function(e){
if(P.finfo){
const stashed = P.getStashedFinfo(P.finfo);
P.clearStash();
if(stashed) P.loadFile(/*reload after discarding edits*/);
}else{
P.clearStash();
}
},
ticks: F.config.confirmerButtonTicks
});
D.addClass(this.e.btnClear,'hidden' /* must not be set until after confirmer is set up!*/);
$stash._fireStashEvent(/*read the page-load-time stash*/);
delete this.init;
},
/**
Regenerates the edit selection list.
*/
updateList: function f(stasher,theFinfo){
if(!f.compare){
| > > | 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 |
D.append(wrapper, D.append(
D.addClass(D.span(),'warning'),
"Warning: persistent storage is not available, "+
"so uncomitted edits will not survive a page reload."
));
}
domInsertPoint.parentNode.insertBefore(wrapper, domInsertPoint);
P.tabs.switchToTab(1/*DOM visibility workaround*/);
F.confirmer(btnClear, {
/* must come after insertion into the DOM for the pinSize option to work. */
pinSize: true,
confirmText: "DISCARD all local edits?",
onconfirm: function(e){
if(P.finfo){
const stashed = P.getStashedFinfo(P.finfo);
P.clearStash();
if(stashed) P.loadFile(/*reload after discarding edits*/);
}else{
P.clearStash();
}
},
ticks: F.config.confirmerButtonTicks
});
D.addClass(this.e.btnClear,'hidden' /* must not be set until after confirmer is set up!*/);
$stash._fireStashEvent(/*read the page-load-time stash*/);
P.tabs.switchToTab(0/*DOM visibility workaround*/);
delete this.init;
},
/**
Regenerates the edit selection list.
*/
updateList: function f(stasher,theFinfo){
if(!f.compare){
|
| ︙ | ︙ | |||
735 736 737 738 739 740 741 742 743 744 745 746 747 748 |
);
diffButtons.querySelector('button.unified').addEventListener(
"click",(e)=>P.diff(false), false
);
P.e.btnCommit.addEventListener(
"click",(e)=>P.commit(), false
);
F.confirmer(P.e.btnReload, {
pinSize: true,
confirmText: "Really reload, losing edits?",
onconfirm: (e)=>P.unstashContent().loadFile(),
ticks: F.config.confirmerButtonTicks
});
E('#comment-toggle').addEventListener(
| > | 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 |
);
diffButtons.querySelector('button.unified').addEventListener(
"click",(e)=>P.diff(false), false
);
P.e.btnCommit.addEventListener(
"click",(e)=>P.commit(), false
);
P.tabs.switchToTab(1/*DOM visibility workaround*/);
F.confirmer(P.e.btnReload, {
pinSize: true,
confirmText: "Really reload, losing edits?",
onconfirm: (e)=>P.unstashContent().loadFile(),
ticks: F.config.confirmerButtonTicks
});
E('#comment-toggle').addEventListener(
|
| ︙ | ︙ |
Changes to src/fossil.page.wikiedit.js.
1 2 3 4 5 6 |
(function(F/*the fossil object*/){
"use strict";
/**
Client-side implementation of the /wikiedit app. Requires that
the fossil JS bootstrapping is complete and that several fossil
JS APIs have been installed: fossil.fetch, fossil.dom,
| | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
(function(F/*the fossil object*/){
"use strict";
/**
Client-side implementation of the /wikiedit app. Requires that
the fossil JS bootstrapping is complete and that several fossil
JS APIs have been installed: fossil.fetch, fossil.dom,
fossil.tabs, fossil.storage, fossil.confirmer, fossil.popupwidget.
Custom events which can be listened for via
fossil.page.addEventListener():
- Event 'wiki-page-loaded': passes on information when it
loads a wiki (whether from the network or its internal local-edit
cache), in the form of an "winfo" object:
|
| ︙ | ︙ | |||
555 556 557 558 559 560 561 |
sel)
);
D.attr(sel, 'size', 12);
D.option(D.disable(D.clearElement(sel)), "Loading...");
/** Set up filter checkboxes for the various types
of wiki pages... */
| | | 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 |
sel)
);
D.attr(sel, 'size', 12);
D.option(D.disable(D.clearElement(sel)), "Loading...");
/** Set up filter checkboxes for the various types
of wiki pages... */
const fsFilter = D.addClass(D.fieldset("Page types"),"page-types-list"),
fsFilterBody = D.div(),
filters = ['normal', 'branch/...', 'tag/...', 'checkin/...']
;
D.append(fsFilter, fsFilterBody);
D.addClass(fsFilterBody, 'flex-container', 'flex-column', 'stretch');
// Add filters by page type...
|
| ︙ | ︙ | |||
595 596 597 598 599 600 601 |
lbl = D.attr(D.append(D.label(),
getEditMarker(getEditMarker.DELETED,false),
'deleted'),
'for', cbId),
cb = D.attr(D.input('checkbox'), 'id', cbId);
cb.checked = false;
D.addClass(parentElem,'hide-deleted');
| | > > | > | > > | 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 |
lbl = D.attr(D.append(D.label(),
getEditMarker(getEditMarker.DELETED,false),
'deleted'),
'for', cbId),
cb = D.attr(D.input('checkbox'), 'id', cbId);
cb.checked = false;
D.addClass(parentElem,'hide-deleted');
D.attr(lbl);
const deletedTip = F.helpButtonlets.create(
D.span(),
'Fossil considers empty pages to be "deleted" in some contexts.'
);
D.append(fsFilterBody, D.append(
D.span(), cb, lbl, deletedTip
));
cb.addEventListener(
'change',
function(ev){
if(ev.target.checked) D.removeClass(parentElem,'hide-deleted');
else D.addClass(parentElem,'hide-deleted');
},
false);
|
| ︙ | ︙ | |||
680 681 682 683 684 685 686 |
P.stashWidget = {
e:{/*DOM element(s)*/},
init: function(domInsertPoint/*insert widget BEFORE this element*/){
const wrapper = D.addClass(
D.attr(D.div(),'id','wikiedit-stash-selector'),
'input-with-label'
);
| | | > > > > > > > > | | < < < < | 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 |
P.stashWidget = {
e:{/*DOM element(s)*/},
init: function(domInsertPoint/*insert widget BEFORE this element*/){
const wrapper = D.addClass(
D.attr(D.div(),'id','wikiedit-stash-selector'),
'input-with-label'
);
const sel = this.e.select = D.select(),
btnClear = this.e.btnClear = D.button("Discard Edits"),
btnHelp = D.append(
D.addClass(D.div(), "help-buttonlet"),
'Locally-edited wiki pages. Timestamps are the last local edit time. ',
'Only the ',P.config.defaultMaxStashSize,' most recent pages ',
'are retained. Saving or reloading a file removes it from this list. ',
D.append(D.code(),'localStorage'),' uses browser-local persistent storage. ',
D.append(D.code(),'sessionStorage'),' uses storage local to this browser tab.'
);
D.append(wrapper, "Local edits (",
D.append(D.code(),
F.storage.storageImplName()),
"):",
btnHelp, sel, btnClear);
F.helpButtonlets.setup(btnHelp);
D.option(D.disable(sel), "(empty)");
P.addEventListener('wiki-stash-updated',(e)=>this.updateList(e.detail));
P.addEventListener('wiki-page-loaded',(e)=>this.updateList($stash, e.detail));
sel.addEventListener('change',function(e){
const opt = this.selectedOptions[0];
if(opt && opt._winfo) P.loadPage(opt._winfo);
});
|
| ︙ | ︙ | |||
833 834 835 836 837 838 839 |
document.body.classList.add('wikiedit');
P.base = {tag: E('base'), wikiUrl: F.repoUrl('wiki')};
P.base.originalHref = P.base.tag.href;
P.e = { /* various DOM elements we work with... */
taEditor: E('#wikiedit-content-editor'),
btnReload: E("#wikiedit-tab-content button.wikiedit-content-reload"),
btnSave: E("button.wikiedit-save"),
| | < < | 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 |
document.body.classList.add('wikiedit');
P.base = {tag: E('base'), wikiUrl: F.repoUrl('wiki')};
P.base.originalHref = P.base.tag.href;
P.e = { /* various DOM elements we work with... */
taEditor: E('#wikiedit-content-editor'),
btnReload: E("#wikiedit-tab-content button.wikiedit-content-reload"),
btnSave: E("button.wikiedit-save"),
btnSaveClose: E("button.wikiedit-save-close"),
selectMimetype: E('select[name=mimetype]'),
selectFontSizeWrap: E('#select-font-size'),
// selectDiffWS: E('select[name=diff_ws]'),
cbAutoPreview: E('#cb-preview-autoupdate > input[type=checkbox]'),
previewTarget: E('#wikiedit-tab-preview-wrapper'),
diffTarget: E('#wikiedit-tab-diff-wrapper'),
editStatus: E('#wikiedit-edit-status'),
|
| ︙ | ︙ | |||
868 869 870 871 872 873 874 |
P.tabs.addEventListener(
/* Set up some before-switch-to tab event tasks... */
'before-switch-to', function(ev){
const theTab = ev.detail, btnSlot = theTab.querySelector('.save-button-slot');
if(btnSlot){
/* Several places make sense for a save button, so we'll
move that button around to those tabs where it makes sense. */
| | | | 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 |
P.tabs.addEventListener(
/* Set up some before-switch-to tab event tasks... */
'before-switch-to', function(ev){
const theTab = ev.detail, btnSlot = theTab.querySelector('.save-button-slot');
if(btnSlot){
/* Several places make sense for a save button, so we'll
move that button around to those tabs where it makes sense. */
btnSlot.parentNode.insertBefore( P.e.btnSave.parentNode, btnSlot );
btnSlot.parentNode.insertBefore( P.e.btnSaveClose.parentNode, btnSlot );
P.updateSaveButton();
}
if(theTab===P.e.tabs.preview){
P.baseHrefForWiki();
if(P.previewNeedsUpdate && P.e.cbAutoPreview.checked) P.preview();
}else if(theTab===P.e.tabs.diff){
/* Work around a weird bug where the page gets wider than
|
| ︙ | ︙ | |||
956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 |
delete P.winfo;
P.updatePageTitle();
F.message("Discarded new page ["+w.name+"].");
}
};
if(P.config.useConfirmerButtons.reload){
F.confirmer(P.e.btnReload, {
pinSize: true,
confirmText: "Really reload, losing edits?",
onconfirm: doReload,
ticks: F.config.confirmerButtonTicks
});
}else{
P.e.btnReload.addEventListener('click', doReload, false);
}
if(P.config.useConfirmerButtons.save){
F.confirmer(P.e.btnSave, {
pinSize: true,
confirmText: "Really save changes?",
onconfirm: ()=>doSave(),
ticks: F.config.confirmerButtonTicks
});
F.confirmer(P.e.btnSaveClose, {
| > > | 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 |
delete P.winfo;
P.updatePageTitle();
F.message("Discarded new page ["+w.name+"].");
}
};
if(P.config.useConfirmerButtons.reload){
P.tabs.switchToTab(1/*DOM visibility workaround*/);
F.confirmer(P.e.btnReload, {
pinSize: true,
confirmText: "Really reload, losing edits?",
onconfirm: doReload,
ticks: F.config.confirmerButtonTicks
});
}else{
P.e.btnReload.addEventListener('click', doReload, false);
}
if(P.config.useConfirmerButtons.save){
P.tabs.switchToTab(1/*DOM visibility workaround*/);
F.confirmer(P.e.btnSave, {
pinSize: true,
confirmText: "Really save changes?",
onconfirm: ()=>doSave(),
ticks: F.config.confirmerButtonTicks
});
F.confirmer(P.e.btnSaveClose, {
|
| ︙ | ︙ | |||
1067 1068 1069 1070 1071 1072 1073 |
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
);
| | > > > > > > | 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 |
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.
The tab-switching is a workaround for the pinSize option of the confirmer widgets:
it does not work if the confirmer button being initialized is in a hidden
part of the DOM :/. */
P.tabs.switchToTab(0);
WikiList.init( P.e.tabs.pageList.firstElementChild );
P.tabs.switchToTab(1);
P.stashWidget.init(P.e.tabs.content.lastElementChild);
P.tabs.switchToTab(0);
//P.$wikiList = WikiList/*only for testing/debugging*/;
}/*F.onPageLoad()*/);
/**
Returns true if fossil.page.winfo is set, indicating that a page
has been loaded, else it reports an error and returns false.
|
| ︙ | ︙ |
Changes to src/fossil.popupwidget.js.
| ︙ | ︙ | |||
262 263 264 265 266 267 268 269 |
displays for twice as long as a normal toast.
*/
error: function(/*...*/){
return toastImpl('error',2,arguments);
}
}/*F.toast*/;
})(window.fossil);
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 |
displays for twice as long as a normal toast.
*/
error: function(/*...*/){
return toastImpl('error',2,arguments);
}
}/*F.toast*/;
F.helpButtonlets = {
/**
Initializes one or more "help buttonlets". It may be passed any of:
- A string: CSS selector (multiple matches are legal)
- A single DOM element.
- A forEach-compatible container of DOM elements.
- No arguments, which is equivalent to passing the string
".help-buttonlet:not(.processed)".
Passing the same element(s) more than once is a no-op: during
initialization, each elements get the class'processed' added to
it, and any elements with that class are skipped.
All child nodes of a help buttonlet are removed from the button
during initialization and stashed away for use in a PopupWidget
when the botton is clicked.
*/
setup: function f(){
if(!f.clickHandler){
f.clickHandler = function fch(ev){
if(!fch.popup){
fch.popup = new F.PopupWidget({
cssClass: ['fossil-tooltip', 'help-buttonlet-content'],
refresh: function(){
}
});
const hide = ()=>fch.popup.hide();
fch.popup.e.addEventListener('click', hide, false);
document.body.addEventListener('click', hide, true);
document.body.addEventListener('keydown', function(ev){
if(fch.popup.isShown() && 27===ev.which){
fch.popup.hide();
}
}, true);
}
D.append(D.clearElement(fch.popup.e), ev.target.$helpContent);
const rect1 = ev.target.getClientRects()[0];
var x = rect1.left, y = rect1.top;
if(x<0) x = 0;
if(y<0) y = 0;
/* shift help to the left 1/2 the width of fch.popup.e. However,
fch.popup.e.getClientRects() is empty until the popup is shown,
so we have to show it, calculate that size, then move it. */
fch.popup.show(x, y);
const rect2 = fch.popup.e.getClientRects()[0];
x -= rect2.width/2;
if(x<0) x = 0;
fch.popup.show(x, y);
};
}
var elems;
if(!arguments.length){
arguments[0] = '.help-buttonlet:not(.processed)';
arguments.length = 1;
}
if(arguments.length){
if('string'===typeof arguments[0]){
elems = document.querySelectorAll(arguments[0]);
}else if(arguments[0] instanceof HTMLElement){
elems = [arguments[0]];
}else{/* assume DOM element list or array */
elems = arguments[0];
}
}
if(!elems) return;
elems.forEach(function(e){
if(e.classList.contains('processed')) return;
e.classList.add('processed');
e.$helpContent = [];
/* We have to move all child nodes out of the way because we
cannot hide TEXT nodes via CSS (which cannot select TEXT
nodes). We have to do it in two steps to avoid invaliding
the list during traversal. */
e.childNodes.forEach((ch)=>e.$helpContent.push(ch));
e.$helpContent.forEach((ch)=>ch.remove());
e.addEventListener('click', f.clickHandler, false);
});
},
/**
Sets up the given element as a "help buttonlet", adding the CSS
class help-buttonlet to it. Any (optional) arguments after the
first are appended to the element using fossil.dom.append(), so
that they become the content for the buttonlet's popup help.
The element is then passed to this.setup() before it
is returned from this function.
*/
create: function(elem/*...body*/){
D.addClass(elem, 'help-buttonlet');
if(arguments.length>1){
const args = Array.prototype.slice.call(arguments,1);
D.append(elem, args);
}
this.setup(elem);
return elem;
}
}/*helpButtonlets*/;
F.onDOMContentLoaded( ()=>F.helpButtonlets.setup() );
})(window.fossil);
|
Changes to src/info.c.
| ︙ | ︙ | |||
2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 |
cgi_append_content("<code>", -1);
}
cgi_printf("%z", htmlize(z, nZ));
CX("</code></pre></td></tr></tbody></table>\n");
if( db_int(0, "SELECT EXISTS(SELECT 1 FROM lnos)") ){
builtin_request_js("scroll.js");
}
style_emit_fossil_js_apis(0, "dom", "copybutton", "popupwidget",
"numbered-lines", 0);
}
/*
** COMMAND: test-line-numbers
**
** Usage: %fossil test-line-numbers FILE ?LN-SPEC?
**
| > > > > | 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 |
cgi_append_content("<code>", -1);
}
cgi_printf("%z", htmlize(z, nZ));
CX("</code></pre></td></tr></tbody></table>\n");
if( db_int(0, "SELECT EXISTS(SELECT 1 FROM lnos)") ){
builtin_request_js("scroll.js");
}
#if 0
style_emit_fossil_js_apis(0, "dom", "copybutton", "popupwidget",
"numbered-lines", 0);
#else
style_emit_all_fossil_js_apis();
#endif
}
/*
** COMMAND: test-line-numbers
**
** Usage: %fossil test-line-numbers FILE ?LN-SPEC?
**
|
| ︙ | ︙ |
Changes to src/style.c.
| ︙ | ︙ | |||
1228 1229 1230 1231 1232 1233 1234 | ** the optional value for the checkbox. zTip is an optional tooltip, ** which gets set as the "title" attribute of the outermost ** element. If isChecked is true, the checkbox gets the "checked" ** attribute set, else it is not. ** ** Resulting structure: ** | | | | | | 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 |
** the optional value for the checkbox. zTip is an optional tooltip,
** which gets set as the "title" attribute of the outermost
** element. If isChecked is true, the checkbox gets the "checked"
** attribute set, else it is not.
**
** Resulting structure:
**
** <div class='input-with-label' title={{zTip}} id={{zWrapperId}}>
** <input type='checkbox' name={{zFieldName}} value={{zValue}}
** id='A RANDOM VALUE'
** {{isChecked ? " checked : ""}}/>
** <label for='ID OF THE INPUT FIELD'>{{zLabel}}</label>
** </div>
**
** zLabel, and zValue are required. zFieldName, zWrapperId, and zTip
** are may be NULL or empty.
**
** Be sure that the input-with-label CSS class is defined sensibly, in
** particular, having its display:inline-block is useful for alignment
** purposes.
*/
void style_labeled_checkbox(const char * zWrapperId,
const char *zFieldName, const char * zLabel,
const char * zValue, int isChecked,
const char * zTip){
char * zLabelID = style_next_input_id();
CX("<div class='input-with-label'");
if(zTip && *zTip){
CX(" title='%h'", zTip);
}
if(zWrapperId && *zWrapperId){
CX(" id='%s'",zWrapperId);
}
CX("><input type='checkbox' id='%s' ", zLabelID);
if(zFieldName && *zFieldName){
CX("name='%s' ",zFieldName);
}
CX("value='%T'%s/>",
zValue ? zValue : "", isChecked ? " checked" : "");
CX("<label for='%s'>%h</label></div>", zLabelID, zLabel);
fossil_free(zLabelID);
}
/*
** Outputs a SELECT list from a compile-time list of integers.
** The vargs must be a list of (const char *, int) pairs, terminated
** with a single NULL. Each pair is interpreted as...
|
| ︙ | ︙ | |||
1294 1295 1296 1297 1298 1299 1300 | ** zLabel is an optional string to use as a "label" for the element ** (see below). ** ** zTooltip is an optional value for the SELECT's title attribute. ** ** The structure of the emitted HTML is: ** | | | | | 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 |
** zLabel is an optional string to use as a "label" for the element
** (see below).
**
** zTooltip is an optional value for the SELECT's title attribute.
**
** The structure of the emitted HTML is:
**
** <div class='input-with-label' title={{zToolTip}} id={{zWrapperId}}>
** <label for='SELECT ELEMENT ID'>{{zLabel}}</label>
** <select id='RANDOM ID' name={{zFieldName}}>...</select>
** </div>
**
** Example:
**
** style_select_list_int("my-grapes", "my_grapes", "Grapes",
** "Select the number of grapes",
** atoi(PD("my_field","0")),
** "", 1, "2", 2, "Three", 3,
** NULL);
**
*/
void style_select_list_int(const char * zWrapperId,
const char *zFieldName, const char * zLabel,
const char * zToolTip, int selectedVal,
... ){
char * zLabelID = style_next_input_id();
va_list vargs;
va_start(vargs,selectedVal);
CX("<div class='input-with-label'");
if(zToolTip && *zToolTip){
CX(" title='%h'",zToolTip);
}
if(zWrapperId && *zWrapperId){
CX(" id='%s'",zWrapperId);
}
CX(">");
|
| ︙ | ︙ | |||
1345 1346 1347 1348 1349 1350 1351 |
CX("%s", zOption);
}else{
CX("%d",v);
}
CX("</option>\n");
}
CX("</select>\n");
| | | 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 |
CX("%s", zOption);
}else{
CX("%d",v);
}
CX("</option>\n");
}
CX("</select>\n");
CX("</div>\n");
va_end(vargs);
fossil_free(zLabelID);
}
/*
** The C-string counterpart of style_select_list_int(), this variant
** differs only in that its variadic arguments are C-strings in pairs
|
| ︙ | ︙ | |||
1380 1381 1382 1383 1384 1385 1386 |
char * zLabelID = style_next_input_id();
va_list vargs;
va_start(vargs,zSelectedVal);
if(!zSelectedVal){
zSelectedVal = __FILE__/*some string we'll never match*/;
}
| | | 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 |
char * zLabelID = style_next_input_id();
va_list vargs;
va_start(vargs,zSelectedVal);
if(!zSelectedVal){
zSelectedVal = __FILE__/*some string we'll never match*/;
}
CX("<div class='input-with-label'");
if(zToolTip && *zToolTip){
CX(" title='%h'",zToolTip);
}
if(zWrapperId && *zWrapperId){
CX(" id='%s'",zWrapperId);
}
CX(">");
|
| ︙ | ︙ | |||
1409 1410 1411 1412 1413 1414 1415 |
CX("%s", zLabel);
}else{
CX("%h",zVal);
}
CX("</option>\n");
}
CX("</select>\n");
| | | 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 |
CX("%s", zLabel);
}else{
CX("%h",zVal);
}
CX("</option>\n");
}
CX("</select>\n");
CX("</div>\n");
va_end(vargs);
fossil_free(zLabelID);
}
/*
** The first time this is called, it emits code to install and
|
| ︙ | ︙ | |||
1558 1559 1560 1561 1562 1563 1564 |
while( (zArg = va_arg (vargs, const char *))!=0 ){
zName = mprintf("fossil.%s.js", zArg);
builtin_request_js(zName);
fossil_free(zName);
}
va_end(vargs);
}
| > > > > > > > > > > > > > > > | 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 |
while( (zArg = va_arg (vargs, const char *))!=0 ){
zName = mprintf("fossil.%s.js", zArg);
builtin_request_js(zName);
fossil_free(zName);
}
va_end(vargs);
}
/*
** Emits, via builtin_request_js(), all JS fossil.XYZ APIs which are
** not strictly specific to a single page. The idea is that we can get
** better bundle caching and reduced HTTP requests by including all
** JS, rather than creating separate bundles on a per-page basis.
*/
void style_emit_all_fossil_js_apis(void){
style_emit_fossil_js_apis(0,
"dom", "fetch",
"storage", "tabs",
"confirmer", "popupwidget",
"copybutton", "numbered-lines",
0);
}
|
Changes to src/style.wikiedit.css.
| ︙ | ︙ | |||
182 183 184 185 186 187 188 |
margin: 0.25em;
display: flex;
flex-direction: row;
flex-wrap: wrap;
align-items: baseline;
}
body.wikiedit #wikiedit-stash-selector select {
| | > > > > > > > | 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
margin: 0.25em;
display: flex;
flex-direction: row;
flex-wrap: wrap;
align-items: baseline;
}
body.wikiedit #wikiedit-stash-selector select {
margin: 0 1em 0 0.5em;
height: initial;
font-family: monospace;
flex: 10 1 auto;
}
body.wikiedit fieldset.page-types-list > div > span {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
align-items: center;
}
|
Changes to src/wiki.c.
| ︙ | ︙ | |||
1160 1161 1162 1163 1164 1165 1166 |
{
CX("<div id='wikiedit-tab-content' "
"data-tab-parent='wikiedit-tabs' "
"data-tab-label='Editor' "
"class='hidden'"
">");
CX("<div class='flex-container flex-row child-gap-small'>");
| | | > | | > | | > > > > > > | > > | | > > | | 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 |
{
CX("<div id='wikiedit-tab-content' "
"data-tab-parent='wikiedit-tabs' "
"data-tab-label='Editor' "
"class='hidden'"
">");
CX("<div class='flex-container flex-row child-gap-small'>");
CX("<div class='input-with-label'>"
"<label>Mime type</label>");
mimetype_option_menu(0);
CX("</div>");
style_select_list_int("select-font-size",
"editor_font_size", "Editor font size",
NULL/*tooltip*/,
100,
"100%", 100, "125%", 125,
"150%", 150, "175%", 175,
"200%", 200, NULL);
CX("<div class='input-with-label'>"
"<button class='wikiedit-save'>"
"Save</button>"
"</div>" /*will get moved around dynamically*/);
CX("<div class='input-with-label'>"
"<button class='wikiedit-save-close'>"
"Save & Close</button>"
"<div class='help-buttonlet'>"
"Saves edits to this page and returns to the wiki page viewer."
"</div>"
"</div>" /*will get moved around dynamically*/);
CX("<span class='save-button-slot'></span>");
CX("<div class='input-with-label'>"
"<button class='wikiedit-content-reload' "
">Discard & Reload</button>"
"<div class='help-buttonlet'>"
"Reload the file from the server, discarding "
"any local edits. To help avoid accidental loss of "
"edits, it requires confirmation (a second click) within "
"a few seconds or it will not reload."
"</div>"
"</div>");
CX("</div>");
CX("<div class='flex-container flex-column stretch'>");
CX("<textarea name='content' id='wikiedit-content-editor' "
"class='wikiedit' rows='25'>");
CX("</textarea>");
CX("</div>"/*textarea wrapper*/);
CX("</div>"/*#tab-file-content*/);
|
| ︙ | ︙ | |||
1211 1212 1213 1214 1215 1216 1217 |
** the text editor with their own. */
"data-f-preview-via='_postPreview' "
/* ^^^ fossil.page[methodName](content, callback) */
"data-f-preview-to='#wikiedit-tab-preview-wrapper' "
/* ^^^ dest elem ID */
">Refresh</button>");
/* Toggle auto-update of preview when the Preview tab is selected. */
| > > | < | < > | | > > | 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 |
** the text editor with their own. */
"data-f-preview-via='_postPreview' "
/* ^^^ fossil.page[methodName](content, callback) */
"data-f-preview-to='#wikiedit-tab-preview-wrapper' "
/* ^^^ dest elem ID */
">Refresh</button>");
/* Toggle auto-update of preview when the Preview tab is selected. */
CX("<div class='input-with-label'>"
"<input type='checkbox' value='1' "
"id='cb-preview-autorefresh' checked=''>"
"<label for='cb-preview-autorefresh'>Auto-refresh?</label>"
"<div class='help-buttonlet'>"
"If on, the preview will automatically "
"refresh when this tab is selected."
"</div>"
"</div>");
CX("<span class='save-button-slot'></span>");
CX("</div>"/*.wikiedit-options*/);
CX("<div id='wikiedit-tab-preview-wrapper'></div>");
CX("</div>"/*#wikiedit-tab-preview*/);
}
/****** Diff tab ******/
|
| ︙ | ︙ | |||
1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 |
"sandbox page will fail.</p>");
CX("<h2>Wiki Name Rules</h2>");
well_formed_wiki_name_rules();
CX("</div>"/*#wikiedit-tab-save*/);
}
builtin_request_js("sbsdiff.js");
style_emit_fossil_js_apis(0, "fetch", "dom", "tabs", "confirmer",
"storage", "page.wikiedit", 0);
builtin_fulfill_js_requests();
/* Dynamically populate the editor... */
style_emit_script_tag(0,0);
{
/* Render the current page list to save us an XHR request
during page initialization. This must be OUTSIDE of
an onPageLoad() handler or else it does not get applied
| > > > > > > | 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 |
"sandbox page will fail.</p>");
CX("<h2>Wiki Name Rules</h2>");
well_formed_wiki_name_rules();
CX("</div>"/*#wikiedit-tab-save*/);
}
builtin_request_js("sbsdiff.js");
#if 0
style_emit_fossil_js_apis(0, "fetch", "dom", "tabs", "confirmer",
"storage", "page.wikiedit", 0);
#else
style_emit_all_fossil_js_apis();
builtin_fulfill_js_requests();
builtin_request_js("fossil.page.wikiedit.js");
#endif
builtin_fulfill_js_requests();
/* Dynamically populate the editor... */
style_emit_script_tag(0,0);
{
/* Render the current page list to save us an XHR request
during page initialization. This must be OUTSIDE of
an onPageLoad() handler or else it does not get applied
|
| ︙ | ︙ |