Fossil SCM
Code duplication reduction.
Commit
f107854c97654ee802a3235ad0de088a9b1cf4a90ae11453df83b73fc3e4823e
Parent
145546623455ccc…
3 files changed
+1
-8
+4
-7
+10
+1
-8
| --- src/fossil.page.fileedit.js | ||
| +++ src/fossil.page.fileedit.js | ||
| @@ -687,18 +687,11 @@ | ||
| 687 | 687 | }else{ |
| 688 | 688 | P.e.taComment = P.e.taCommentSmall; |
| 689 | 689 | D.addClass(P.e.taCommentBig, 'hidden'); |
| 690 | 690 | } |
| 691 | 691 | D.removeClass(P.e.taComment, 'hidden'); |
| 692 | - P.tabs.e.container.insertBefore( | |
| 693 | - /* Move the status bar between the tab buttons and | |
| 694 | - tab panels. Seems to be the best fit in terms of | |
| 695 | - functionality and visibility. */ | |
| 696 | - E('#fossil-status-bar'), P.tabs.e.tabs | |
| 697 | - ); | |
| 698 | - P.tabs.e.container.insertBefore(P.e.editStatus, P.tabs.e.tabs); | |
| 699 | - | |
| 692 | + P.tabs.addCustomWidget( E('#fossil-status-bar') ).addCustomWidget(P.e.editStatus); | |
| 700 | 693 | P.tabs.addEventListener( |
| 701 | 694 | /* Set up auto-refresh of the preview tab... */ |
| 702 | 695 | 'before-switch-to', function(ev){ |
| 703 | 696 | if(ev.detail===P.e.tabs.preview){ |
| 704 | 697 | P.baseHrefForFile(); |
| 705 | 698 |
| --- src/fossil.page.fileedit.js | |
| +++ src/fossil.page.fileedit.js | |
| @@ -687,18 +687,11 @@ | |
| 687 | }else{ |
| 688 | P.e.taComment = P.e.taCommentSmall; |
| 689 | D.addClass(P.e.taCommentBig, 'hidden'); |
| 690 | } |
| 691 | D.removeClass(P.e.taComment, 'hidden'); |
| 692 | P.tabs.e.container.insertBefore( |
| 693 | /* Move the status bar between the tab buttons and |
| 694 | tab panels. Seems to be the best fit in terms of |
| 695 | functionality and visibility. */ |
| 696 | E('#fossil-status-bar'), P.tabs.e.tabs |
| 697 | ); |
| 698 | P.tabs.e.container.insertBefore(P.e.editStatus, P.tabs.e.tabs); |
| 699 | |
| 700 | P.tabs.addEventListener( |
| 701 | /* Set up auto-refresh of the preview tab... */ |
| 702 | 'before-switch-to', function(ev){ |
| 703 | if(ev.detail===P.e.tabs.preview){ |
| 704 | P.baseHrefForFile(); |
| 705 |
| --- src/fossil.page.fileedit.js | |
| +++ src/fossil.page.fileedit.js | |
| @@ -687,18 +687,11 @@ | |
| 687 | }else{ |
| 688 | P.e.taComment = P.e.taCommentSmall; |
| 689 | D.addClass(P.e.taCommentBig, 'hidden'); |
| 690 | } |
| 691 | D.removeClass(P.e.taComment, 'hidden'); |
| 692 | P.tabs.addCustomWidget( E('#fossil-status-bar') ).addCustomWidget(P.e.editStatus); |
| 693 | P.tabs.addEventListener( |
| 694 | /* Set up auto-refresh of the preview tab... */ |
| 695 | 'before-switch-to', function(ev){ |
| 696 | if(ev.detail===P.e.tabs.preview){ |
| 697 | P.baseHrefForFile(); |
| 698 |
+4
-7
| --- src/fossil.page.wikiedit.js | ||
| +++ src/fossil.page.wikiedit.js | ||
| @@ -863,17 +863,14 @@ | ||
| 863 | 863 | misc: E('#wikiedit-tab-misc') |
| 864 | 864 | //commit: E('#wikiedit-tab-commit') |
| 865 | 865 | } |
| 866 | 866 | }; |
| 867 | 867 | P.tabs = new F.TabManager(D.clearElement(P.e.tabContainer)); |
| 868 | - P.tabs.e.container.insertBefore( | |
| 869 | - /* Move the status bar between the tab buttons and | |
| 870 | - tab panels. Seems to be the best fit in terms of | |
| 871 | - functionality and visibility. */ | |
| 872 | - E('#fossil-status-bar'), P.tabs.e.tabs | |
| 873 | - ); | |
| 874 | - P.tabs.e.container.insertBefore(P.e.editStatus, P.tabs.e.tabs); | |
| 868 | + /* Move the status bar between the tab buttons and | |
| 869 | + tab panels. Seems to be the best fit in terms of | |
| 870 | + functionality and visibility. */ | |
| 871 | + P.tabs.addCustomWidget( E('#fossil-status-bar') ).addCustomWidget(P.e.editStatus); | |
| 875 | 872 | P.tabs.addEventListener( |
| 876 | 873 | /* Set up some before-switch-to tab event tasks... */ |
| 877 | 874 | 'before-switch-to', function(ev){ |
| 878 | 875 | const theTab = ev.detail, btnSlot = theTab.querySelector('.save-button-slot'); |
| 879 | 876 | if(btnSlot){ |
| 880 | 877 |
| --- src/fossil.page.wikiedit.js | |
| +++ src/fossil.page.wikiedit.js | |
| @@ -863,17 +863,14 @@ | |
| 863 | misc: E('#wikiedit-tab-misc') |
| 864 | //commit: E('#wikiedit-tab-commit') |
| 865 | } |
| 866 | }; |
| 867 | P.tabs = new F.TabManager(D.clearElement(P.e.tabContainer)); |
| 868 | P.tabs.e.container.insertBefore( |
| 869 | /* Move the status bar between the tab buttons and |
| 870 | tab panels. Seems to be the best fit in terms of |
| 871 | functionality and visibility. */ |
| 872 | E('#fossil-status-bar'), P.tabs.e.tabs |
| 873 | ); |
| 874 | P.tabs.e.container.insertBefore(P.e.editStatus, P.tabs.e.tabs); |
| 875 | P.tabs.addEventListener( |
| 876 | /* Set up some before-switch-to tab event tasks... */ |
| 877 | 'before-switch-to', function(ev){ |
| 878 | const theTab = ev.detail, btnSlot = theTab.querySelector('.save-button-slot'); |
| 879 | if(btnSlot){ |
| 880 |
| --- src/fossil.page.wikiedit.js | |
| +++ src/fossil.page.wikiedit.js | |
| @@ -863,17 +863,14 @@ | |
| 863 | misc: E('#wikiedit-tab-misc') |
| 864 | //commit: E('#wikiedit-tab-commit') |
| 865 | } |
| 866 | }; |
| 867 | P.tabs = new F.TabManager(D.clearElement(P.e.tabContainer)); |
| 868 | /* Move the status bar between the tab buttons and |
| 869 | tab panels. Seems to be the best fit in terms of |
| 870 | functionality and visibility. */ |
| 871 | P.tabs.addCustomWidget( E('#fossil-status-bar') ).addCustomWidget(P.e.editStatus); |
| 872 | P.tabs.addEventListener( |
| 873 | /* Set up some before-switch-to tab event tasks... */ |
| 874 | 'before-switch-to', function(ev){ |
| 875 | const theTab = ev.detail, btnSlot = theTab.querySelector('.save-button-slot'); |
| 876 | if(btnSlot){ |
| 877 |
+10
| --- src/fossil.tabs.js | ||
| +++ src/fossil.tabs.js | ||
| @@ -204,10 +204,20 @@ | ||
| 204 | 204 | */ |
| 205 | 205 | addEventListener: function(eventName, callback){ |
| 206 | 206 | this.e.container.addEventListener(eventName, callback, false); |
| 207 | 207 | return this; |
| 208 | 208 | }, |
| 209 | + | |
| 210 | + /** | |
| 211 | + Inserts the given DOM element immediately after the tab bar. | |
| 212 | + Intended for a status bar or similar always-visible component. | |
| 213 | + Returns this object. | |
| 214 | + */ | |
| 215 | + addCustomWidget: function(e){ | |
| 216 | + this.e.container.insertBefore(e, this.e.tabs); | |
| 217 | + return this; | |
| 218 | + }, | |
| 209 | 219 | |
| 210 | 220 | /** |
| 211 | 221 | If the given DOM element, unique selector, or integer (0-based |
| 212 | 222 | tab number) is one of this object's tabs, the UI makes that tab |
| 213 | 223 | the currently-visible one, firing any relevant events. Returns |
| 214 | 224 |
| --- src/fossil.tabs.js | |
| +++ src/fossil.tabs.js | |
| @@ -204,10 +204,20 @@ | |
| 204 | */ |
| 205 | addEventListener: function(eventName, callback){ |
| 206 | this.e.container.addEventListener(eventName, callback, false); |
| 207 | return this; |
| 208 | }, |
| 209 | |
| 210 | /** |
| 211 | If the given DOM element, unique selector, or integer (0-based |
| 212 | tab number) is one of this object's tabs, the UI makes that tab |
| 213 | the currently-visible one, firing any relevant events. Returns |
| 214 |
| --- src/fossil.tabs.js | |
| +++ src/fossil.tabs.js | |
| @@ -204,10 +204,20 @@ | |
| 204 | */ |
| 205 | addEventListener: function(eventName, callback){ |
| 206 | this.e.container.addEventListener(eventName, callback, false); |
| 207 | return this; |
| 208 | }, |
| 209 | |
| 210 | /** |
| 211 | Inserts the given DOM element immediately after the tab bar. |
| 212 | Intended for a status bar or similar always-visible component. |
| 213 | Returns this object. |
| 214 | */ |
| 215 | addCustomWidget: function(e){ |
| 216 | this.e.container.insertBefore(e, this.e.tabs); |
| 217 | return this; |
| 218 | }, |
| 219 | |
| 220 | /** |
| 221 | If the given DOM element, unique selector, or integer (0-based |
| 222 | tab number) is one of this object's tabs, the UI makes that tab |
| 223 | the currently-visible one, firing any relevant events. Returns |
| 224 |