From b8c6b41a5017915e33ff3499e332271cda90bf4a Mon Sep 17 00:00:00 2001 From: Fomafix Date: Sun, 29 Mar 2015 13:57:37 +0000 Subject: [PATCH] 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 --- .../mediawiki.action/mediawiki.action.edit.preview.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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 !== '' ) { -- 2.20.1