Merge "Fix editing of non-mobile-formatted pages"

This commit is contained in:
jenkins-bot 2018-01-29 21:05:31 +00:00 committed by Gerrit Code Review
commit fcc759ee19
1 changed files with 7 additions and 3 deletions

View File

@ -46,6 +46,7 @@
}
/**
* Prepend an edit page button to the container
* Remove any existing links in the container
* @method
* @ignore
* @param {number} section number
@ -53,6 +54,7 @@
* @return {jQuery.Object} newly created edit page button
*/
function addEditButton( section, container ) {
$( container ).find( 'a' ).remove();
return $( '<a class="edit-page">' )
.attr( {
href: '#/editor/' + section,
@ -256,15 +258,17 @@
// FIXME: split the selector and cache it
if ( $caEdit.find( '.edit-page' ).length === 0 ) {
$( '.nojs-edit' ).removeClass( 'nojs-edit' );
$( '#ca-edit a' ).remove();
if ( isNewPage ||
( leadSection && leadSection.text() ) || page.getSections().length === 0 ) {
// if lead section is not empty, open editor with lead section
// In some namespaces (controlled by MFNamespacesWithoutCollapsibleSections)
// sections are not marked. Use the lead section for such cases.
addEditButton( 0, '#ca-edit' );
} else {
// if lead section is empty or does not exist, open editor with first section
} else if ( leadSection !== null ) {
// if lead section is empty open editor with first section
// be careful not to do this when leadSection is null as this means MobileFormatter has not
// been run and thus we could not identify the lead
addEditButton( 1, '#ca-edit' );
}
}