From b2da583a618234085842a29114ab62c44476990a Mon Sep 17 00:00:00 2001 From: Daniel Friesen Date: Thu, 28 Aug 2008 21:16:46 +0000 Subject: [PATCH] Replace the


inserted between the toolbar and the preview area with a ontop class. In shared.css we give this a bottom margin of 1em to add the space between the toolbar and preview. As a bonus, because display: none; is now used when the preview area is not used, ajax/live previews actually get the spacing instead of it not showing up. preview.js has also been tweaked to remove the display: none; when previewing. --- includes/EditPage.php | 31 ++++++++++++++++++++++++++----- skins/common/preview.js | 1 + skins/common/shared.css | 4 ++++ 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/includes/EditPage.php b/includes/EditPage.php index 25c3d4c30a..a7892f246a 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -1515,19 +1515,40 @@ END protected function displayPreviewArea( $previewOutput, $isOnTop = false ) { global $wgOut; - if ( $this->formtype == 'preview') { + $classes = array( 'wikiPreview' ); + if( $isOnTop ) $classes[] = 'ontop'; + $attribs = array( 'class' => implode( ' ', $classes ) ); + if( $this->formtype != 'preview' ) $attribs['style'] = 'display: none;'; + $wgOut->addHTML( Xml::openElement( 'div', $attribs ) ); + if ( $this->formtype == 'preview' ) { $this->showPreview( $previewOutput ); - // Spacer for the edit toolbar - $wgOut->addHTML( '


' ); - } else { - $wgOut->addHTML( '
' ); } + $wgOut->addHTML( '' ); if ( $this->formtype == 'diff') { $this->showDiff(); } } + /** + * Append preview output to $wgOut. + * Includes category rendering if this is a category page. + * + * @param string $text The HTML to be output for the preview. + */ + protected function showPreview( $text ) { + global $wgOut; + + if($this->mTitle->getNamespace() == NS_CATEGORY) { + $this->mArticle->openShowCategory(); + } + wfRunHooks( 'OutputPageBeforeHTML',array( &$wgOut, &$text ) ); + $wgOut->addHTML( $text ); + if($this->mTitle->getNamespace() == NS_CATEGORY) { + $this->mArticle->closeShowCategory(); + } + } + /** * Append preview output to $wgOut. * Includes category rendering if this is a category page. diff --git a/skins/common/preview.js b/skins/common/preview.js index 8c5c07d3dd..faf611f071 100644 --- a/skins/common/preview.js +++ b/skins/common/preview.js @@ -87,6 +87,7 @@ function lpStatusUpdate() { var previewContainer = document.getElementById( lpIdPreview ); if ( previewContainer && previewElement ) { previewContainer.innerHTML = previewElement.firstChild.data; + previewContainer.style.display = 'block'; } else { /* Should never happen */ window.alert(i18n(wgLivepreviewMessageFailed)); diff --git a/skins/common/shared.css b/skins/common/shared.css index a357e6d393..9da982161f 100644 --- a/skins/common/shared.css +++ b/skins/common/shared.css @@ -9,6 +9,10 @@ img.tex { vertical-align: middle; } span.texhtml { font-family: serif; } +/* add a bit of margin space between the preview and the toolbar */ +/* this replaces the ugly


we used to insert into the page source */ +.wikiPreview.ontop { margin-bottom: 1em; } + /* Stop floats from intruding into edit area in previews */ #toolbar, #wpTextbox1 { clear: both; } -- 2.20.1