| | @@ -591,11 +591,11 @@ |
| 591 | 591 | selectFontSizeWrap: E('#select-font-size'), |
| 592 | 592 | // selectDiffWS: E('select[name=diff_ws]'), |
| 593 | 593 | cbAutoPreview: E('#cb-preview-autoupdate > input[type=checkbox]'), |
| 594 | 594 | previewTarget: E('#wikiedit-tab-preview-wrapper'), |
| 595 | 595 | diffTarget: E('#wikiedit-tab-diff-wrapper'), |
| 596 | | - attachmentWrapper: E("#wikiedit-attachments"), |
| 596 | + editStatus: E('#wikiedit-edit-status'), |
| 597 | 597 | tabContainer: E('#wikiedit-tabs'), |
| 598 | 598 | tabs:{ |
| 599 | 599 | pageList: E('#wikiedit-tab-pages'), |
| 600 | 600 | content: E('#wikiedit-tab-content'), |
| 601 | 601 | preview: E('#wikiedit-tab-preview'), |
| | @@ -603,10 +603,11 @@ |
| 603 | 603 | misc: E('#wikiedit-tab-misc') |
| 604 | 604 | //commit: E('#wikiedit-tab-commit') |
| 605 | 605 | } |
| 606 | 606 | }; |
| 607 | 607 | P.tabs = new fossil.TabManager(D.clearElement(P.e.tabContainer)); |
| 608 | + P.tabs.e.container.insertBefore(P.e.editStatus, P.tabs.e.tabs); |
| 608 | 609 | P.tabs.e.container.insertBefore( |
| 609 | 610 | /* Move the status bar between the tab buttons and |
| 610 | 611 | tab panels. Seems to be the best fit in terms of |
| 611 | 612 | functionality and visibility. */ |
| 612 | 613 | E('#fossil-status-bar'), P.tabs.e.tabs |
| | @@ -632,12 +633,10 @@ |
| 632 | 633 | the page size again. Weird. Maybe FF-specific. Note that |
| 633 | 634 | this weirdness happens even though P.e.diffTarget's parent |
| 634 | 635 | is hidden (and therefore P.e.diffTarget is also hidden). |
| 635 | 636 | */ |
| 636 | 637 | D.removeClass(P.e.diffTarget, 'hidden'); |
| 637 | | - }else if(theTab===P.e.tabs.misc){ |
| 638 | | - P.updateAttachmentView(); |
| 639 | 638 | } |
| 640 | 639 | } |
| 641 | 640 | ); |
| 642 | 641 | P.tabs.addEventListener( |
| 643 | 642 | /* Set up auto-refresh of the preview tab... */ |
| | @@ -770,18 +769,18 @@ |
| 770 | 769 | P.e.selectMimetype.value = winfo.mimetype; |
| 771 | 770 | P.tabs.switchToTab(P.e.tabs.content); |
| 772 | 771 | P.wikiContent(winfo.content || ''); |
| 773 | 772 | WikiList.e.select.value = winfo.name; |
| 774 | 773 | if(!winfo.version && winfo.type!=='sandbox'){ |
| 775 | | - F.error('You are editing a new, unsaved page:',winfo.name); |
| 774 | + F.message('You are editing a new, unsaved page:',winfo.name); |
| 776 | 775 | } |
| 777 | 776 | P.updatePageTitle(); |
| 778 | 777 | }, |
| 779 | 778 | false |
| 780 | 779 | ); |
| 781 | 780 | P.addEventListener('wiki-stash-updated', ()=>P.updateSaveButton()) |
| 782 | | - .updatePageTitle().updateAttachmentView().updateSaveButton(); |
| 781 | + .updatePageTitle().updateSaveButton(); |
| 783 | 782 | }/*F.onPageLoad()*/); |
| 784 | 783 | |
| 785 | 784 | /** |
| 786 | 785 | Returns true if fossil.page.winfo is set, indicating that a page |
| 787 | 786 | has been loaded, else it reports an error and returns false. |
| | @@ -791,32 +790,58 @@ |
| 791 | 790 | */ |
| 792 | 791 | const affirmPageLoaded = function(quiet){ |
| 793 | 792 | if(!P.winfo && !quiet) F.error("No wiki page is loaded."); |
| 794 | 793 | return !!P.winfo; |
| 795 | 794 | }; |
| 795 | + |
| 796 | + /** Updates the in-tab title/edit status information */ |
| 797 | + P.updateEditStatus = function f(editFlag/*for use by updatePageTitle() only*/){ |
| 798 | + if(!f.eLinks){ |
| 799 | + f.eName = P.e.editStatus.querySelector('span.name'); |
| 800 | + f.eLinks = P.e.editStatus.querySelector('span.links'); |
| 801 | + } |
| 802 | + const wi = this.winfo; |
| 803 | + D.clearElement(f.eName, f.eLinks); |
| 804 | + if(!wi){ |
| 805 | + D.append(f.eName, '(no page loaded)'); |
| 806 | + return; |
| 807 | + } |
| 808 | + var marker = editFlag || ''; |
| 809 | + if(0===arguments){ |
| 810 | + if(!wi.version && 'sandbox'!==wi.type) marker = P.config.editStateMarkers.isNew; |
| 811 | + else if($stash.getWinfo(wi)) marker = P.config.editStateMarkers.isModified; |
| 812 | + } |
| 813 | + D.append(f.eName,marker,wi.name,); |
| 814 | + if(wi.version){ |
| 815 | + D.append( |
| 816 | + f.eLinks, |
| 817 | + D.a(F.repoUrl('whistory',{name:wi.name}),'[history]'), |
| 818 | + D.a(F.repoUrl('attachlist',{page:wi.name}),"[attachments]"), |
| 819 | + D.a(F.repoUrl('attachadd',{page:wi.name,from: F.repoUrl('wikiedit',{name: wi.name})}), "[attach]") |
| 820 | + ); |
| 821 | + } |
| 822 | + }; |
| 796 | 823 | |
| 797 | 824 | /** |
| 798 | 825 | Update the page title and header based on the state of |
| 799 | 826 | this.winfo. A no-op if this.winfo is not set. Returns this. |
| 800 | 827 | */ |
| 801 | 828 | P.updatePageTitle = function f(){ |
| 802 | 829 | if(!f.titleElement){ |
| 803 | 830 | f.titleElement = document.head.querySelector('title'); |
| 804 | | - f.pageTitleHeader = document.querySelector('#wikiedit-page-name > span'); |
| 805 | 831 | } |
| 806 | | - var title = []; |
| 832 | + var title, marker = ''; |
| 807 | 833 | const wi = P.winfo; |
| 808 | 834 | if(wi){ |
| 809 | | - if(!wi.version && 'sandbox'!==wi.type) title.push(P.config.editStateMarkers.isNew); |
| 810 | | - else if($stash.getWinfo(wi)) title.push(P.config.editStateMarkers.isModified) |
| 811 | | - title.push(wi.name); |
| 835 | + if(!wi.version && 'sandbox'!==wi.type) marker = P.config.editStateMarkers.isNew; |
| 836 | + else if($stash.getWinfo(wi)) marker = P.config.editStateMarkers.isModified; |
| 837 | + title = wi.name; |
| 812 | 838 | }else{ |
| 813 | | - title.push('(no page loaded)'); |
| 839 | + title = 'no page loaded'; |
| 814 | 840 | } |
| 815 | | - title = title.join(' '); |
| 816 | | - f.pageTitleHeader.innerText = title; |
| 817 | | - f.titleElement.innerText = 'Wiki Editor:' + title; |
| 841 | + f.titleElement.innerText = 'Wiki Editor: ' + marker + title; |
| 842 | + this.updateEditStatus(marker); |
| 818 | 843 | return this; |
| 819 | 844 | }; |
| 820 | 845 | |
| 821 | 846 | /** |
| 822 | 847 | Change the save button depending on whether we have stuff to save |
| | @@ -830,44 +855,10 @@ |
| 830 | 855 | D.enable(this.e.btnSave).innerText = "Save changes"; |
| 831 | 856 | } |
| 832 | 857 | return this; |
| 833 | 858 | }; |
| 834 | 859 | |
| 835 | | - /** Updates attachment-related links and returns this. */ |
| 836 | | - P.updateAttachmentView = function(){ |
| 837 | | - const wrapper = P.e.attachmentWrapper; |
| 838 | | - D.clearElement(wrapper); |
| 839 | | - const ul = D.ul(); |
| 840 | | - D.append(wrapper, ul); |
| 841 | | - if(!P.winfo){ |
| 842 | | - D.append(D.li(ul), |
| 843 | | - "Load a page to get access to its attachment-related pages."); |
| 844 | | - return this; |
| 845 | | - }else if(!P.winfo.version){ |
| 846 | | - D.append(D.li(ul), |
| 847 | | - "A new/unsaved page cannot have attachments. Save it first."); |
| 848 | | - return this; |
| 849 | | - } |
| 850 | | - const wi = P.winfo; |
| 851 | | - D.append( |
| 852 | | - D.li(ul), |
| 853 | | - D.a(F.repoUrl('attachadd',{ |
| 854 | | - page:wi.name, |
| 855 | | - from: F.repoUrl('wikiedit',{ |
| 856 | | - name: wi.name |
| 857 | | - }) |
| 858 | | - }), "Add attachments.") |
| 859 | | - ); |
| 860 | | - D.append( |
| 861 | | - D.li(ul), |
| 862 | | - D.a(F.repoUrl('attachlist',{page:wi.name}), |
| 863 | | - "List attachments"), |
| 864 | | - " (if any)." |
| 865 | | - ); |
| 866 | | - return this; |
| 867 | | - }; |
| 868 | | - |
| 869 | 860 | /** |
| 870 | 861 | Getter (if called with no args) or setter (if passed an arg) for |
| 871 | 862 | the current file content. |
| 872 | 863 | |
| 873 | 864 | The setter form sets the content, dispatches a |
| 874 | 865 | |