X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=resources%2Fsrc%2Fmediawiki.action%2Fmediawiki.action.edit.preview.js;h=c26d9153a2298d598d15fa367e52de043cfebde3;hp=53c1fbbe4bcc72c6e6fe0eced759f38ebc72c215;hb=1e8f417f3d6d648e19c03465890b58a331514362;hpb=fb742a3a8eb951c91544e70fe09b63b1bac6aec5 diff --git a/resources/src/mediawiki.action/mediawiki.action.edit.preview.js b/resources/src/mediawiki.action/mediawiki.action.edit.preview.js index 53c1fbbe4b..c26d9153a2 100644 --- a/resources/src/mediawiki.action/mediawiki.action.edit.preview.js +++ b/resources/src/mediawiki.action/mediawiki.action.edit.preview.js @@ -3,12 +3,14 @@ */ ( function ( mw, $ ) { + var oojsuieditform; + /** * @ignore * @param {jQuery.Event} e */ function doLivePreview( e ) { - var isDiff, api, parseRequest, diffRequest, postData, copySelectors, section, + var isDiff, api, parseRequest, diffRequest, postData, copySelectors, section, summary, $wikiPreview, $wikiDiff, $editform, $textbox, $summary, $copyElements, $spinner, $errorBox; isDiff = ( e.target.name === 'wpDiff' ); @@ -16,7 +18,13 @@ $wikiDiff = $( '#wikiDiff' ); $editform = $( '#editform' ); $textbox = $editform.find( '#wpTextbox1' ); - $summary = $editform.find( '#wpSummary' ); + + if ( oojsuieditform ) { + summary = OO.ui.infuse( $( '#wpSummaryWidget' ) ); + } else { + $summary = $editform.find( '#wpSummary' ); + } + $spinner = $( '.mw-spinner-preview' ); $errorBox = $( '.errorbox' ); section = $editform.find( '[name="wpSection"]' ).val(); @@ -78,7 +86,7 @@ formatversion: 2, action: 'parse', title: mw.config.get( 'wgPageName' ), - summary: $summary.textSelection( 'getContents' ), + summary: oojsuieditform ? summary.getValue() : $summary.val(), prop: '' }; @@ -150,7 +158,7 @@ newList.push( $( '
' ) .addClass( 'mw-indicator' ) - .attr( 'id', mw.util.escapeId( 'mw-indicator-' + name ) ) + .attr( 'id', mw.util.escapeIdForAttribute( 'mw-indicator-' + name ) ) .html( indicator ) .get( 0 ), // Add a whitespace between the
s because @@ -281,6 +289,8 @@ } $( function () { + oojsuieditform = $( '#editform' ).hasClass( 'mw-editform-ooui' ); + // Do not enable on user .js/.css pages, as there's no sane way of "previewing" // the scripts or styles without reloading the page. if ( $( '#mw-userjsyoucanpreview' ).length || $( '#mw-usercssyoucanpreview' ).length ) { @@ -301,13 +311,13 @@ role: 'navigation', 'aria-labelledby': 'p-lang-label' } ) - .append( $( '

' ).attr( 'id', 'p-lang-label' ).text( mw.msg( 'otherlanguages' ) ) ) - .append( $( '
' ).addClass( 'body' ).append( '
    ' ) ) + .append( $( '

    ' ).attr( 'id', 'p-lang-label' ).text( mw.msg( 'otherlanguages' ) ) ) + .append( $( '
    ' ).addClass( 'body' ).append( '
      ' ) ) ); } if ( !$( '.mw-summary-preview' ).length ) { - $( '#wpSummary' ).after( + $( oojsuieditform ? '#wpSummaryWidget' : '#wpSummary' ).after( $( '
      ' ).addClass( 'mw-summary-preview' ) ); }