Reproduce the new section behavior for the full submit preview.
Diffing will require a bit more additional work in Api.
Bug: T84877
Change-Id: Iec71fdc7ba09f91683214f3d65472ea2f72a06b1
'otherlanguages',
'tooltip-p-lang',
'summary-preview',
'otherlanguages',
'tooltip-p-lang',
'summary-preview',
var isDiff, api, request, postData, copySelectors, section,
$wikiPreview, $wikiDiff, $editform, $copyElements, $spinner;
var isDiff, api, request, postData, copySelectors, section,
$wikiPreview, $wikiDiff, $editform, $copyElements, $spinner;
isDiff = ( e.target.name === 'wpDiff' );
$wikiPreview = $( '#wikiPreview' );
$wikiDiff = $( '#wikiDiff' );
$editform = $( '#editform' );
section = $editform.find( '[name="wpSection"]' ).val();
isDiff = ( e.target.name === 'wpDiff' );
$wikiPreview = $( '#wikiPreview' );
$wikiDiff = $( '#wikiDiff' );
$editform = $( '#editform' );
section = $editform.find( '[name="wpSection"]' ).val();
+ // Show changes for a new section is not yet supported
+ if ( isDiff && section === 'new' ) {
+ return;
+ }
+ e.preventDefault();
+
// Show #wikiPreview if it's hidden to be able to scroll to it
// (if it is hidden, it's also empty, so nothing changes in the rendering)
$wikiPreview.show();
// Show #wikiPreview if it's hidden to be able to scroll to it
// (if it is hidden, it's also empty, so nothing changes in the rendering)
$wikiPreview.show();
summary: $editform.find( '#wpSummary' ).textSelection( 'getContents' )
};
summary: $editform.find( '#wpSummary' ).textSelection( 'getContents' )
};
+ if ( section !== '' ) {
+ postData.sectionpreview = '';
+ if ( section === 'new' ) {
+ postData.section = section;
+ postData.sectiontitle = postData.summary;
+ }
+ }
+
if ( isDiff ) {
$wikiPreview.hide();
if ( isDiff ) {
$wikiPreview.hide();
prop: 'text|displaytitle|modules|categorieshtml|templates|langlinks|limitreporthtml',
disableeditsection: true
} );
prop: 'text|displaytitle|modules|categorieshtml|templates|langlinks|limitreporthtml',
disableeditsection: true
} );
- if ( section !== '' ) {
- postData.sectionpreview = '';
- }
request = api.post( postData );
request.done( function ( response ) {
var li, newList, $content, $parent, $list;
request = api.post( postData );
request.done( function ( response ) {
var li, newList, $content, $parent, $list;
} );
}
request.done( function ( response ) {
} );
}
request.done( function ( response ) {
+ var isSubject = ( section === 'new' ),
+ summaryMsg = isSubject ? 'subject-preview' : 'summary-preview';
if ( response.parse.parsedsummary ) {
if ( response.parse.parsedsummary ) {
- // TODO implement special behavior for section === 'new'
$editform.find( '.mw-summary-preview' )
.empty()
.append(
$editform.find( '.mw-summary-preview' )
.empty()
.append(
- mw.message( 'summary-preview' ).parse(),
+ mw.message( summaryMsg ).parse(),
' ',
$( '<span>' ).addClass( 'comment' ).html(
// There is no equivalent to rawParams
' ',
$( '<span>' ).addClass( 'comment' ).html(
// There is no equivalent to rawParams
}
if ( !$( '.mw-summary-preview' ).length ) {
}
if ( !$( '.mw-summary-preview' ).length ) {
- $( '.editCheckboxes' ).before(
+ $( '#wpSummary' ).after(
$( '<div>' ).addClass( 'mw-summary-preview' )
);
}
$( '<div>' ).addClass( 'mw-summary-preview' )
);
}