From: Fomafix Date: Sun, 29 Mar 2015 13:57:37 +0000 (+0000) Subject: mediawiki.action.edit.preview: Disable if there is no #wpTextbox1 X-Git-Tag: 1.31.0-rc.0~11950 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/%7B%7B%20url_for%28%27admin_users%27%29%20%7D%7D?a=commitdiff_plain;h=b8c6b41a5017915e33ff3499e332271cda90bf4a;p=lhc%2Fweb%2Fwiklou.git mediawiki.action.edit.preview: Disable if there is no #wpTextbox1 ProofreadPage has custom editforms for Index pages, which are not supported by the API. These editforms have no #wpTextbox1, so disable live preview in that case. Make this check on click avoid T94089. Bug: T78709 Change-Id: I628d3b226a4294f2878fc4175080a975fd86e507 --- diff --git a/resources/src/mediawiki.action/mediawiki.action.edit.preview.js b/resources/src/mediawiki.action/mediawiki.action.edit.preview.js index 4aa839cbf1..f24703af29 100644 --- a/resources/src/mediawiki.action/mediawiki.action.edit.preview.js +++ b/resources/src/mediawiki.action/mediawiki.action.edit.preview.js @@ -9,15 +9,20 @@ */ function doLivePreview( e ) { var isDiff, api, request, postData, copySelectors, section, - $wikiPreview, $wikiDiff, $editform, $copyElements, $spinner, $errorBox; + $wikiPreview, $wikiDiff, $editform, $textbox, $summary, $copyElements, $spinner, $errorBox; isDiff = ( e.target.name === 'wpDiff' ); $wikiPreview = $( '#wikiPreview' ); $wikiDiff = $( '#wikiDiff' ); $editform = $( '#editform' ); + $textbox = $editform.find( '#wpTextbox1' ); + $summary = $editform.find( '#wpSummary' ); $errorBox = $( '.errorbox' ); section = $editform.find( '[name="wpSection"]' ).val(); + if ( $textbox.length === 0 ) { + return; + } // Show changes for a new section is not yet supported if ( isDiff && section === 'new' ) { return; @@ -68,8 +73,8 @@ action: 'parse', uselang: mw.config.get( 'wgUserLanguage' ), title: mw.config.get( 'wgPageName' ), - text: $editform.find( '#wpTextbox1' ).textSelection( 'getContents' ), - summary: $editform.find( '#wpSummary' ).textSelection( 'getContents' ) + text: $textbox.textSelection( 'getContents' ), + summary: $summary.textSelection( 'getContents' ) }; if ( section !== '' ) {