Fossil SCM
Consolidate some duplicate code. Minor spacing tweak to keep the Status selection widget from overlapping the editor's top border.
Commit
45896a35fdd6fe9e4da132d6e5c0ac967eaa8eb99e647f1333f63235cae3a2f7
Parent
308405f0429ea82…
2 files changed
+14
-13
+1
+14
-13
| --- src/fossil.page.forumpost.js | ||
| +++ src/fossil.page.forumpost.js | ||
| @@ -77,11 +77,11 @@ | ||
| 77 | 77 | } |
| 78 | 78 | const e = this.#e = F.nu({ |
| 79 | 79 | mimetype: F.nu(), |
| 80 | 80 | button: F.nu() |
| 81 | 81 | }); |
| 82 | - console.debug("Setting up FPE opt =",opt); | |
| 82 | + //console.debug("Setting up FPE opt =",opt); | |
| 83 | 83 | const wrapper = e.widget = D.addClass(D.div(), 'ForumPostEditor'); |
| 84 | 84 | D.clearElement(wrapper); |
| 85 | 85 | |
| 86 | 86 | if( !opt.inReplyTo ){ |
| 87 | 87 | /* Title... */ |
| @@ -875,10 +875,20 @@ | ||
| 875 | 875 | }); |
| 876 | 876 | }); |
| 877 | 877 | } |
| 878 | 878 | |
| 879 | 879 | F.user.isIndividual = ['anonymous','nobody'].indexOf(F.user.name)<0; |
| 880 | + | |
| 881 | + /* Page-specific style tweaks for a ForumPostEditor instance. */ | |
| 882 | + const initFPEWidget = (ePost, fpe)=>{ | |
| 883 | + const w = fpe.widget; | |
| 884 | + w.style.borderTop = '1px dotted'; | |
| 885 | + //w.style.marginTop = '0.35em'; | |
| 886 | + /* Adding an "Editing..." <h3> here adds way too much space */ | |
| 887 | + ePost.append(w); | |
| 888 | + w.scrollIntoView(); | |
| 889 | + }; | |
| 880 | 890 | |
| 881 | 891 | const eForumNew = ( |
| 882 | 892 | document.body.classList.contains('cpage-forumnew') |
| 883 | 893 | || document.body.classList.contains('cpage-forume1') |
| 884 | 894 | ) |
| @@ -963,15 +973,11 @@ | ||
| 963 | 973 | draft does not disapper if firt is later edited |
| 964 | 974 | (giving us a new firt value here). */ |
| 965 | 975 | || fpid |
| 966 | 976 | ).substr(0,12) |
| 967 | 977 | }); |
| 968 | - const w = fpe.widget; | |
| 969 | - w.style.borderTop = '2px dotted'; | |
| 970 | - /* Adding an "Editing..." <h3> here adds way too much space */ | |
| 971 | - ePost.append(w); | |
| 972 | - w.scrollIntoView(); | |
| 978 | + initFPEWidget(ePost, fpe); | |
| 973 | 979 | }/*replyClicked()*/; |
| 974 | 980 | |
| 975 | 981 | const editClicked = (form, ePost, eBtnEdit, eToDisable)=>{ |
| 976 | 982 | const fpid = setupEditReplyElement(ePost, eBtnEdit, eToDisable); |
| 977 | 983 | const firt = ePost.dataset.firt; |
| @@ -999,17 +1005,11 @@ | ||
| 999 | 1005 | draftKey: 'draft-forumedit-'+(fEditHead || fpid).substr(0,12), |
| 1000 | 1006 | edit: artifact, |
| 1001 | 1007 | status: eStatusSelect?.value, |
| 1002 | 1008 | inReplyTo: firt |
| 1003 | 1009 | }); |
| 1004 | - const w = fpe.widget; | |
| 1005 | - w.style.borderTop = '2px dotted'; | |
| 1006 | - //w.style.height = '0px'; | |
| 1007 | - /* Adding an "Editing..." <h3> here adds way too much space */ | |
| 1008 | - ePost.append(w); | |
| 1009 | - w.scrollIntoView(); | |
| 1010 | - //w.style.height = ''; | |
| 1010 | + initFPEWidget(ePost, fpe); | |
| 1011 | 1011 | }); |
| 1012 | 1012 | }/*editClicked()*/; |
| 1013 | 1013 | |
| 1014 | 1014 | document.body.querySelectorAll( |
| 1015 | 1015 | '.forumpost-single-controls > form' |
| @@ -1048,10 +1048,11 @@ | ||
| 1048 | 1048 | const eStatusChange = eThePost.querySelector( |
| 1049 | 1049 | ':scope > fieldset.forum-status-selection' |
| 1050 | 1050 | ); |
| 1051 | 1051 | if( eStatusChange ) eToDisable.push(eStatusChange); |
| 1052 | 1052 | })/*for-each form*/; |
| 1053 | + | |
| 1053 | 1054 | }/* /forumpost and /forumthread */ |
| 1054 | 1055 | |
| 1055 | 1056 | document.body.querySelectorAll('.initially-hidden').forEach(e=>{ |
| 1056 | 1057 | /* This is a workaround for a span.help-buttonlet which we need |
| 1057 | 1058 | to start hidden so that it does not show up for no-JS |
| 1058 | 1059 |
| --- src/fossil.page.forumpost.js | |
| +++ src/fossil.page.forumpost.js | |
| @@ -77,11 +77,11 @@ | |
| 77 | } |
| 78 | const e = this.#e = F.nu({ |
| 79 | mimetype: F.nu(), |
| 80 | button: F.nu() |
| 81 | }); |
| 82 | console.debug("Setting up FPE opt =",opt); |
| 83 | const wrapper = e.widget = D.addClass(D.div(), 'ForumPostEditor'); |
| 84 | D.clearElement(wrapper); |
| 85 | |
| 86 | if( !opt.inReplyTo ){ |
| 87 | /* Title... */ |
| @@ -875,10 +875,20 @@ | |
| 875 | }); |
| 876 | }); |
| 877 | } |
| 878 | |
| 879 | F.user.isIndividual = ['anonymous','nobody'].indexOf(F.user.name)<0; |
| 880 | |
| 881 | const eForumNew = ( |
| 882 | document.body.classList.contains('cpage-forumnew') |
| 883 | || document.body.classList.contains('cpage-forume1') |
| 884 | ) |
| @@ -963,15 +973,11 @@ | |
| 963 | draft does not disapper if firt is later edited |
| 964 | (giving us a new firt value here). */ |
| 965 | || fpid |
| 966 | ).substr(0,12) |
| 967 | }); |
| 968 | const w = fpe.widget; |
| 969 | w.style.borderTop = '2px dotted'; |
| 970 | /* Adding an "Editing..." <h3> here adds way too much space */ |
| 971 | ePost.append(w); |
| 972 | w.scrollIntoView(); |
| 973 | }/*replyClicked()*/; |
| 974 | |
| 975 | const editClicked = (form, ePost, eBtnEdit, eToDisable)=>{ |
| 976 | const fpid = setupEditReplyElement(ePost, eBtnEdit, eToDisable); |
| 977 | const firt = ePost.dataset.firt; |
| @@ -999,17 +1005,11 @@ | |
| 999 | draftKey: 'draft-forumedit-'+(fEditHead || fpid).substr(0,12), |
| 1000 | edit: artifact, |
| 1001 | status: eStatusSelect?.value, |
| 1002 | inReplyTo: firt |
| 1003 | }); |
| 1004 | const w = fpe.widget; |
| 1005 | w.style.borderTop = '2px dotted'; |
| 1006 | //w.style.height = '0px'; |
| 1007 | /* Adding an "Editing..." <h3> here adds way too much space */ |
| 1008 | ePost.append(w); |
| 1009 | w.scrollIntoView(); |
| 1010 | //w.style.height = ''; |
| 1011 | }); |
| 1012 | }/*editClicked()*/; |
| 1013 | |
| 1014 | document.body.querySelectorAll( |
| 1015 | '.forumpost-single-controls > form' |
| @@ -1048,10 +1048,11 @@ | |
| 1048 | const eStatusChange = eThePost.querySelector( |
| 1049 | ':scope > fieldset.forum-status-selection' |
| 1050 | ); |
| 1051 | if( eStatusChange ) eToDisable.push(eStatusChange); |
| 1052 | })/*for-each form*/; |
| 1053 | }/* /forumpost and /forumthread */ |
| 1054 | |
| 1055 | document.body.querySelectorAll('.initially-hidden').forEach(e=>{ |
| 1056 | /* This is a workaround for a span.help-buttonlet which we need |
| 1057 | to start hidden so that it does not show up for no-JS |
| 1058 |
| --- src/fossil.page.forumpost.js | |
| +++ src/fossil.page.forumpost.js | |
| @@ -77,11 +77,11 @@ | |
| 77 | } |
| 78 | const e = this.#e = F.nu({ |
| 79 | mimetype: F.nu(), |
| 80 | button: F.nu() |
| 81 | }); |
| 82 | //console.debug("Setting up FPE opt =",opt); |
| 83 | const wrapper = e.widget = D.addClass(D.div(), 'ForumPostEditor'); |
| 84 | D.clearElement(wrapper); |
| 85 | |
| 86 | if( !opt.inReplyTo ){ |
| 87 | /* Title... */ |
| @@ -875,10 +875,20 @@ | |
| 875 | }); |
| 876 | }); |
| 877 | } |
| 878 | |
| 879 | F.user.isIndividual = ['anonymous','nobody'].indexOf(F.user.name)<0; |
| 880 | |
| 881 | /* Page-specific style tweaks for a ForumPostEditor instance. */ |
| 882 | const initFPEWidget = (ePost, fpe)=>{ |
| 883 | const w = fpe.widget; |
| 884 | w.style.borderTop = '1px dotted'; |
| 885 | //w.style.marginTop = '0.35em'; |
| 886 | /* Adding an "Editing..." <h3> here adds way too much space */ |
| 887 | ePost.append(w); |
| 888 | w.scrollIntoView(); |
| 889 | }; |
| 890 | |
| 891 | const eForumNew = ( |
| 892 | document.body.classList.contains('cpage-forumnew') |
| 893 | || document.body.classList.contains('cpage-forume1') |
| 894 | ) |
| @@ -963,15 +973,11 @@ | |
| 973 | draft does not disapper if firt is later edited |
| 974 | (giving us a new firt value here). */ |
| 975 | || fpid |
| 976 | ).substr(0,12) |
| 977 | }); |
| 978 | initFPEWidget(ePost, fpe); |
| 979 | }/*replyClicked()*/; |
| 980 | |
| 981 | const editClicked = (form, ePost, eBtnEdit, eToDisable)=>{ |
| 982 | const fpid = setupEditReplyElement(ePost, eBtnEdit, eToDisable); |
| 983 | const firt = ePost.dataset.firt; |
| @@ -999,17 +1005,11 @@ | |
| 1005 | draftKey: 'draft-forumedit-'+(fEditHead || fpid).substr(0,12), |
| 1006 | edit: artifact, |
| 1007 | status: eStatusSelect?.value, |
| 1008 | inReplyTo: firt |
| 1009 | }); |
| 1010 | initFPEWidget(ePost, fpe); |
| 1011 | }); |
| 1012 | }/*editClicked()*/; |
| 1013 | |
| 1014 | document.body.querySelectorAll( |
| 1015 | '.forumpost-single-controls > form' |
| @@ -1048,10 +1048,11 @@ | |
| 1048 | const eStatusChange = eThePost.querySelector( |
| 1049 | ':scope > fieldset.forum-status-selection' |
| 1050 | ); |
| 1051 | if( eStatusChange ) eToDisable.push(eStatusChange); |
| 1052 | })/*for-each form*/; |
| 1053 | |
| 1054 | }/* /forumpost and /forumthread */ |
| 1055 | |
| 1056 | document.body.querySelectorAll('.initially-hidden').forEach(e=>{ |
| 1057 | /* This is a workaround for a span.help-buttonlet which we need |
| 1058 | to start hidden so that it does not show up for no-JS |
| 1059 |
+1
| --- src/style.forum.css | ||
| +++ src/style.forum.css | ||
| @@ -2,10 +2,11 @@ | ||
| 2 | 2 | |
| 3 | 3 | fieldset.forum-status-selection { |
| 4 | 4 | max-width: max-content; |
| 5 | 5 | border-radius: 0.5em; |
| 6 | 6 | padding: 0 0.5em; |
| 7 | + margin-bottom: 0.35em; | |
| 7 | 8 | } |
| 8 | 9 | |
| 9 | 10 | .ForumPostEditor { |
| 10 | 11 | display: flex; |
| 11 | 12 | flex-direction: column; |
| 12 | 13 |
| --- src/style.forum.css | |
| +++ src/style.forum.css | |
| @@ -2,10 +2,11 @@ | |
| 2 | |
| 3 | fieldset.forum-status-selection { |
| 4 | max-width: max-content; |
| 5 | border-radius: 0.5em; |
| 6 | padding: 0 0.5em; |
| 7 | } |
| 8 | |
| 9 | .ForumPostEditor { |
| 10 | display: flex; |
| 11 | flex-direction: column; |
| 12 |
| --- src/style.forum.css | |
| +++ src/style.forum.css | |
| @@ -2,10 +2,11 @@ | |
| 2 | |
| 3 | fieldset.forum-status-selection { |
| 4 | max-width: max-content; |
| 5 | border-radius: 0.5em; |
| 6 | padding: 0 0.5em; |
| 7 | margin-bottom: 0.35em; |
| 8 | } |
| 9 | |
| 10 | .ForumPostEditor { |
| 11 | display: flex; |
| 12 | flex-direction: column; |
| 13 |