mediawiki.action.edit.preview: Fire "wikipage.content" mw.hook
authorTimo Tijhof <krinklemail@gmail.com>
Thu, 18 Jul 2013 00:57:59 +0000 (02:57 +0200)
committerTimo Tijhof <krinklemail@gmail.com>
Fri, 26 Jul 2013 00:16:32 +0000 (02:16 +0200)
The mw.hook framework was added in 2e97025 and it also added
an example event ("wikipage.content") but this was never
actually fired anywhere other than for the initial load.

This will finally make things like jquery.tablesorter and
jquery.makeCollapsible work in live preview.

Also:

* Deprecate non-standard jQuery events triggered on jQuery
  wrapper around the "mw" object.

Bug: 33399
Change-Id: Ic516b3a01b4c1510cbe5f2de2998ad8275ecc607

RELEASE-NOTES-1.22
resources/mediawiki.action/mediawiki.action.edit.preview.js

index 1d5ccae..318f592 100644 (file)
@@ -222,6 +222,8 @@ production.
 * (bug 13438) Special:MIMESearch no longer an expensive special page.
 * (bug 48342) Fixed a fatal error when $wgValidateAllHtml is set to true and
   the function apache_request_headers() function is not available.
+* (bug 33399) LivePreview: Re-run wikipage content handlers
+  (jquery.makeCollapsible, jquery.tablesorter) after preview content is loaded.
 
 === API changes in 1.22 ===
 * (bug 25553) The JSON output formatter now leaves forward slashes unescaped
@@ -349,6 +351,8 @@ changes to languages because of Bugzilla reports.
 * (bug 50785) A "null edit", that is, a save action in which no changes to the
   page text are made and no revision recorded, will no longer send refreshLinks
   jobs to the job table to update pages which use the edited page as a template.
+* The LivePreviewPrepare and LivePreviewDone events triggered on "jQuery( mw )"
+  have been deprecated in favour of using mw.hook.
 
 == Compatibility ==
 
index 0f95b62..0566a87 100644 (file)
@@ -12,6 +12,7 @@
 
                e.preventDefault();
 
+               // Deprecated: Use mw.hook instead
                $( mw ).trigger( 'LivePreviewPrepare' );
 
                $wikiPreview = $( '#wikiPreview' );
@@ -78,7 +79,7 @@
 
                // Load new preview data.
                // TODO: This should use the action=parse API instead of loading the entire page
-               // Though that requires figuring out how to conver that raw data into proper HTML.
+               // Though that requires figuring out how to convert that raw data into proper HTML.
                $previewDataHolder.load( targetUrl + ' ' + copySelectors.join( ',' ), postData, function () {
                        var i, $from;
                        // Copy the contents of the specified elements from the loaded page to the real page.
                                        .attr( 'class', $from.attr( 'class' ) );
                        }
 
+                       // Deprecated: Use mw.hook instead
+                       $( mw ).trigger( 'LivePreviewDone', [copySelectors] );
+
+                       mw.hook( 'wikipage.content' ).fire( $wikiPreview );
+
                        $spinner.remove();
                        $copyElements.animate( {
                                opacity: 1
                        }, 'fast' );
-
-                       $( mw ).trigger( 'LivePreviewDone', [copySelectors] );
                } );
        }