Replace the <p><br /></p> inserted between the toolbar and the preview area with...
authorDaniel Friesen <dantman@users.mediawiki.org>
Thu, 28 Aug 2008 21:16:46 +0000 (21:16 +0000)
committerDaniel Friesen <dantman@users.mediawiki.org>
Thu, 28 Aug 2008 21:16:46 +0000 (21:16 +0000)
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
skins/common/preview.js
skins/common/shared.css

index 25c3d4c..a7892f2 100644 (file)
@@ -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( '<p><br /></p>' );
-               } else {
-                       $wgOut->addHTML( '<div id="wikiPreview"></div>' );
                }
+               $wgOut->addHTML( '</div>' );
 
                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.
index 8c5c07d..faf611f 100644 (file)
@@ -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));
index a357e6d..9da9821 100644 (file)
@@ -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 <p><br /></p> 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; }