Fossil SCM
Removed the FORM element - it was superfluous and particularly stubborn in how it responded to every button.
Commit
7635d9345d0d7f0f8d54bc2be7511eee5bf74b03dce735681beff9b58cf58021
Parent
b48212f6ea83876…
2 files changed
-16
+4
-19
-16
| --- src/fileedit.c | ||
| +++ src/fileedit.c | ||
| @@ -1520,23 +1520,10 @@ | ||
| 1520 | 1520 | ********************************************************************/ |
| 1521 | 1521 | CX("<p>This page is <em>NEW AND EXPERIMENTAL</em>. " |
| 1522 | 1522 | "USE AT YOUR OWN RISK, preferably on a test " |
| 1523 | 1523 | "repo.</p>\n"); |
| 1524 | 1524 | |
| 1525 | - /* | |
| 1526 | - ** We don't strictly need a FORM because we manually cherry-pick and | |
| 1527 | - ** submit the form data, but it being in a form allows us to easily | |
| 1528 | - ** use the FormData type for serialization. | |
| 1529 | - ** | |
| 1530 | - ** TODO?: we can almost certainly replace this element with a plain | |
| 1531 | - ** DIV, which would eliminate the event-handling hassles of trying | |
| 1532 | - ** to suppress the submit... but it would also eliminate the option | |
| 1533 | - ** of using HTML form field validation. | |
| 1534 | - */ | |
| 1535 | - CX("<form action='#' method='POST' class='fileedit' " | |
| 1536 | - "id='fileedit-form'>"); | |
| 1537 | - | |
| 1538 | 1525 | /******* Hidden fields *******/ |
| 1539 | 1526 | CX("<input type='hidden' name='r' value='%s'>", |
| 1540 | 1527 | cimi.zParentUuid); |
| 1541 | 1528 | CX("<input type='hidden' name='file' value='%T'>", |
| 1542 | 1529 | zFilename); |
| @@ -1768,13 +1755,10 @@ | ||
| 1768 | 1755 | CX("<div id='fileedit-manifest'></div>\n"); |
| 1769 | 1756 | } |
| 1770 | 1757 | |
| 1771 | 1758 | CX("</div>"/*#fileedit-tab-commit*/); |
| 1772 | 1759 | |
| 1773 | - /******* End of form *******/ | |
| 1774 | - CX("</form>\n"); | |
| 1775 | - | |
| 1776 | 1760 | /* Dynamically populate the editor... */ |
| 1777 | 1761 | blob_appendf(&endScript, |
| 1778 | 1762 | "fossil.page.loadFile('%j','%j');", |
| 1779 | 1763 | zFilename, cimi.zParentUuid); |
| 1780 | 1764 | |
| 1781 | 1765 |
| --- src/fileedit.c | |
| +++ src/fileedit.c | |
| @@ -1520,23 +1520,10 @@ | |
| 1520 | ********************************************************************/ |
| 1521 | CX("<p>This page is <em>NEW AND EXPERIMENTAL</em>. " |
| 1522 | "USE AT YOUR OWN RISK, preferably on a test " |
| 1523 | "repo.</p>\n"); |
| 1524 | |
| 1525 | /* |
| 1526 | ** We don't strictly need a FORM because we manually cherry-pick and |
| 1527 | ** submit the form data, but it being in a form allows us to easily |
| 1528 | ** use the FormData type for serialization. |
| 1529 | ** |
| 1530 | ** TODO?: we can almost certainly replace this element with a plain |
| 1531 | ** DIV, which would eliminate the event-handling hassles of trying |
| 1532 | ** to suppress the submit... but it would also eliminate the option |
| 1533 | ** of using HTML form field validation. |
| 1534 | */ |
| 1535 | CX("<form action='#' method='POST' class='fileedit' " |
| 1536 | "id='fileedit-form'>"); |
| 1537 | |
| 1538 | /******* Hidden fields *******/ |
| 1539 | CX("<input type='hidden' name='r' value='%s'>", |
| 1540 | cimi.zParentUuid); |
| 1541 | CX("<input type='hidden' name='file' value='%T'>", |
| 1542 | zFilename); |
| @@ -1768,13 +1755,10 @@ | |
| 1768 | CX("<div id='fileedit-manifest'></div>\n"); |
| 1769 | } |
| 1770 | |
| 1771 | CX("</div>"/*#fileedit-tab-commit*/); |
| 1772 | |
| 1773 | /******* End of form *******/ |
| 1774 | CX("</form>\n"); |
| 1775 | |
| 1776 | /* Dynamically populate the editor... */ |
| 1777 | blob_appendf(&endScript, |
| 1778 | "fossil.page.loadFile('%j','%j');", |
| 1779 | zFilename, cimi.zParentUuid); |
| 1780 | |
| 1781 |
| --- src/fileedit.c | |
| +++ src/fileedit.c | |
| @@ -1520,23 +1520,10 @@ | |
| 1520 | ********************************************************************/ |
| 1521 | CX("<p>This page is <em>NEW AND EXPERIMENTAL</em>. " |
| 1522 | "USE AT YOUR OWN RISK, preferably on a test " |
| 1523 | "repo.</p>\n"); |
| 1524 | |
| 1525 | /******* Hidden fields *******/ |
| 1526 | CX("<input type='hidden' name='r' value='%s'>", |
| 1527 | cimi.zParentUuid); |
| 1528 | CX("<input type='hidden' name='file' value='%T'>", |
| 1529 | zFilename); |
| @@ -1768,13 +1755,10 @@ | |
| 1755 | CX("<div id='fileedit-manifest'></div>\n"); |
| 1756 | } |
| 1757 | |
| 1758 | CX("</div>"/*#fileedit-tab-commit*/); |
| 1759 | |
| 1760 | /* Dynamically populate the editor... */ |
| 1761 | blob_appendf(&endScript, |
| 1762 | "fossil.page.loadFile('%j','%j');", |
| 1763 | zFilename, cimi.zParentUuid); |
| 1764 | |
| 1765 |
+4
-19
| --- src/fossil.page.fileedit.js | ||
| +++ src/fossil.page.fileedit.js | ||
| @@ -11,11 +11,10 @@ | ||
| 11 | 11 | P.tabs = new fossil.TabManager('#fileedit-tabs'); |
| 12 | 12 | P.e = { |
| 13 | 13 | taEditor: E('#fileedit-content-editor'), |
| 14 | 14 | taComment: E('#fileedit-comment'), |
| 15 | 15 | ajaxContentTarget: E('#ajax-target'), |
| 16 | - form: E('#fileedit-form'), | |
| 17 | 16 | btnCommit: E("#fileedit-btn-commit"), |
| 18 | 17 | btnReload: E("#fileedit-tab-content > .fileedit-options > " |
| 19 | 18 | +"button.fileedit-content-reload"), |
| 20 | 19 | selectPreviewModeWrap: E('#select-preview-mode'), |
| 21 | 20 | selectHtmlEmsWrap: E('#select-preview-html-ems'), |
| @@ -37,32 +36,17 @@ | ||
| 37 | 36 | //e.preventDefault(); |
| 38 | 37 | //e.stopPropagation(); |
| 39 | 38 | return P; |
| 40 | 39 | }; |
| 41 | 40 | |
| 42 | - P.e.form.addEventListener("submit", function(e) { | |
| 43 | - e.target.checkValidity(); | |
| 44 | - /* All of this is needed to keep the form from submitting every | |
| 45 | - time any button in the form is clicked: */ | |
| 46 | - e.preventDefault(); | |
| 47 | - e.stopPropagation(); | |
| 48 | - return false; | |
| 49 | - }, false); | |
| 50 | 41 | //P.tabs.getButtonForTab(P.e.tabs.preview) |
| 51 | 42 | P.e.tabs.preview.querySelector( |
| 52 | 43 | 'button' |
| 53 | 44 | ).addEventListener( |
| 54 | 45 | "click",(e)=>P.preview(), false |
| 55 | 46 | ); |
| 56 | 47 | |
| 57 | - document.querySelector('#fileedit-form').addEventListener( | |
| 58 | - "click",function(e){ | |
| 59 | - stopEvent(e); | |
| 60 | - return false; | |
| 61 | - } | |
| 62 | - ); | |
| 63 | - | |
| 64 | 48 | const diffButtons = E('#fileedit-tab-diff-buttons'); |
| 65 | 49 | diffButtons.querySelector('button.sbs').addEventListener( |
| 66 | 50 | "click",(e)=>P.diff(true), false |
| 67 | 51 | ); |
| 68 | 52 | diffButtons.querySelector('button.unified').addEventListener( |
| @@ -178,12 +162,13 @@ | ||
| 178 | 162 | }); |
| 179 | 163 | return this; |
| 180 | 164 | }; |
| 181 | 165 | |
| 182 | 166 | /** |
| 183 | - Fetches the page preview based on the contents and settings of this | |
| 184 | - page's form, and updates the UI with with the preview. | |
| 167 | + Fetches the page preview based on the contents and settings of | |
| 168 | + this page's input fields, and updates the UI with with the | |
| 169 | + preview. | |
| 185 | 170 | |
| 186 | 171 | Returns this object, noting that the operation is async. |
| 187 | 172 | */ |
| 188 | 173 | F.page.preview = function(switchToTab){ |
| 189 | 174 | if(!this.finfo){ |
| @@ -221,11 +206,11 @@ | ||
| 221 | 206 | return this; |
| 222 | 207 | }; |
| 223 | 208 | |
| 224 | 209 | /** |
| 225 | 210 | Fetches the content diff based on the contents and settings of this |
| 226 | - page's form, and updates the UI with the diff view. | |
| 211 | + page's input fields, and updates the UI with the diff view. | |
| 227 | 212 | |
| 228 | 213 | Returns this object, noting that the operation is async. |
| 229 | 214 | */ |
| 230 | 215 | F.page.diff = function(sbs){ |
| 231 | 216 | if(!this.finfo){ |
| 232 | 217 |
| --- src/fossil.page.fileedit.js | |
| +++ src/fossil.page.fileedit.js | |
| @@ -11,11 +11,10 @@ | |
| 11 | P.tabs = new fossil.TabManager('#fileedit-tabs'); |
| 12 | P.e = { |
| 13 | taEditor: E('#fileedit-content-editor'), |
| 14 | taComment: E('#fileedit-comment'), |
| 15 | ajaxContentTarget: E('#ajax-target'), |
| 16 | form: E('#fileedit-form'), |
| 17 | btnCommit: E("#fileedit-btn-commit"), |
| 18 | btnReload: E("#fileedit-tab-content > .fileedit-options > " |
| 19 | +"button.fileedit-content-reload"), |
| 20 | selectPreviewModeWrap: E('#select-preview-mode'), |
| 21 | selectHtmlEmsWrap: E('#select-preview-html-ems'), |
| @@ -37,32 +36,17 @@ | |
| 37 | //e.preventDefault(); |
| 38 | //e.stopPropagation(); |
| 39 | return P; |
| 40 | }; |
| 41 | |
| 42 | P.e.form.addEventListener("submit", function(e) { |
| 43 | e.target.checkValidity(); |
| 44 | /* All of this is needed to keep the form from submitting every |
| 45 | time any button in the form is clicked: */ |
| 46 | e.preventDefault(); |
| 47 | e.stopPropagation(); |
| 48 | return false; |
| 49 | }, false); |
| 50 | //P.tabs.getButtonForTab(P.e.tabs.preview) |
| 51 | P.e.tabs.preview.querySelector( |
| 52 | 'button' |
| 53 | ).addEventListener( |
| 54 | "click",(e)=>P.preview(), false |
| 55 | ); |
| 56 | |
| 57 | document.querySelector('#fileedit-form').addEventListener( |
| 58 | "click",function(e){ |
| 59 | stopEvent(e); |
| 60 | return false; |
| 61 | } |
| 62 | ); |
| 63 | |
| 64 | const diffButtons = E('#fileedit-tab-diff-buttons'); |
| 65 | diffButtons.querySelector('button.sbs').addEventListener( |
| 66 | "click",(e)=>P.diff(true), false |
| 67 | ); |
| 68 | diffButtons.querySelector('button.unified').addEventListener( |
| @@ -178,12 +162,13 @@ | |
| 178 | }); |
| 179 | return this; |
| 180 | }; |
| 181 | |
| 182 | /** |
| 183 | Fetches the page preview based on the contents and settings of this |
| 184 | page's form, and updates the UI with with the preview. |
| 185 | |
| 186 | Returns this object, noting that the operation is async. |
| 187 | */ |
| 188 | F.page.preview = function(switchToTab){ |
| 189 | if(!this.finfo){ |
| @@ -221,11 +206,11 @@ | |
| 221 | return this; |
| 222 | }; |
| 223 | |
| 224 | /** |
| 225 | Fetches the content diff based on the contents and settings of this |
| 226 | page's form, and updates the UI with the diff view. |
| 227 | |
| 228 | Returns this object, noting that the operation is async. |
| 229 | */ |
| 230 | F.page.diff = function(sbs){ |
| 231 | if(!this.finfo){ |
| 232 |
| --- src/fossil.page.fileedit.js | |
| +++ src/fossil.page.fileedit.js | |
| @@ -11,11 +11,10 @@ | |
| 11 | P.tabs = new fossil.TabManager('#fileedit-tabs'); |
| 12 | P.e = { |
| 13 | taEditor: E('#fileedit-content-editor'), |
| 14 | taComment: E('#fileedit-comment'), |
| 15 | ajaxContentTarget: E('#ajax-target'), |
| 16 | btnCommit: E("#fileedit-btn-commit"), |
| 17 | btnReload: E("#fileedit-tab-content > .fileedit-options > " |
| 18 | +"button.fileedit-content-reload"), |
| 19 | selectPreviewModeWrap: E('#select-preview-mode'), |
| 20 | selectHtmlEmsWrap: E('#select-preview-html-ems'), |
| @@ -37,32 +36,17 @@ | |
| 36 | //e.preventDefault(); |
| 37 | //e.stopPropagation(); |
| 38 | return P; |
| 39 | }; |
| 40 | |
| 41 | //P.tabs.getButtonForTab(P.e.tabs.preview) |
| 42 | P.e.tabs.preview.querySelector( |
| 43 | 'button' |
| 44 | ).addEventListener( |
| 45 | "click",(e)=>P.preview(), false |
| 46 | ); |
| 47 | |
| 48 | const diffButtons = E('#fileedit-tab-diff-buttons'); |
| 49 | diffButtons.querySelector('button.sbs').addEventListener( |
| 50 | "click",(e)=>P.diff(true), false |
| 51 | ); |
| 52 | diffButtons.querySelector('button.unified').addEventListener( |
| @@ -178,12 +162,13 @@ | |
| 162 | }); |
| 163 | return this; |
| 164 | }; |
| 165 | |
| 166 | /** |
| 167 | Fetches the page preview based on the contents and settings of |
| 168 | this page's input fields, and updates the UI with with the |
| 169 | preview. |
| 170 | |
| 171 | Returns this object, noting that the operation is async. |
| 172 | */ |
| 173 | F.page.preview = function(switchToTab){ |
| 174 | if(!this.finfo){ |
| @@ -221,11 +206,11 @@ | |
| 206 | return this; |
| 207 | }; |
| 208 | |
| 209 | /** |
| 210 | Fetches the content diff based on the contents and settings of this |
| 211 | page's input fields, and updates the UI with the diff view. |
| 212 | |
| 213 | Returns this object, noting that the operation is async. |
| 214 | */ |
| 215 | F.page.diff = function(sbs){ |
| 216 | if(!this.finfo){ |
| 217 |