Index: trunk/phase3/skins/common/preview.js |
— | — | @@ -4,15 +4,23 @@ |
5 | 5 | |
6 | 6 | function setupLivePreview() { |
7 | 7 | var livePreviewButton = $j('#wpLivePreview'); |
8 | | - |
| 8 | + |
| 9 | + $j('#wpPreview').hide(); |
| 10 | + livePreviewButton.show(); |
| 11 | + |
9 | 12 | livePreviewButton.click( doLivePreview ); |
10 | 13 | } |
11 | 14 | |
12 | 15 | function doLivePreview( e ) { |
13 | 16 | e.preventDefault(); |
14 | 17 | var previewText = $j('#wpTextbox1').val(); |
| 18 | + |
| 19 | + var editToken = $j( '[name="wpEditToken"]' ).attr( 'value' ); |
| 20 | + var editTime = $j( '[name="wpEdittime"]' ).attr( 'value' ); |
| 21 | + var startTime = $j( '[name="wpStarttime"]' ).attr( 'value' ); |
| 22 | + |
15 | 23 | var postData = { 'action' : 'submit', 'wpTextbox1' : previewText, 'wpPreview' : true, |
16 | | - 'title' : wgPageName }; |
| 24 | + 'wpEditToken' : editToken, 'wpEdittime': editTime, 'wpStarttime': startTime, 'title' : wgPageName }; |
17 | 25 | |
18 | 26 | // Hide active diff, used templates, old preview if shown |
19 | 27 | $j('#wikiDiff').slideUp(); |
Index: trunk/phase3/includes/EditPage.php |
— | — | @@ -2299,8 +2299,6 @@ |
2300 | 2300 | * @return array |
2301 | 2301 | */ |
2302 | 2302 | public function getEditButtons(&$tabindex) { |
2303 | | - global $wgLivePreview, $wgUser; |
2304 | | - |
2305 | 2303 | $buttons = array(); |
2306 | 2304 | |
2307 | 2305 | $temp = array( |
— | — | @@ -2315,7 +2313,7 @@ |
2316 | 2314 | $buttons['save'] = Xml::element('input', $temp, ''); |
2317 | 2315 | |
2318 | 2316 | ++$tabindex; // use the same for preview and live preview |
2319 | | - if ( $wgLivePreview && $wgUser->getOption( 'uselivepreview' ) ) { |
| 2317 | + if ( $this->useLivePreview() ) { |
2320 | 2318 | $this->doLivePreviewScript(); // Add to output |
2321 | 2319 | |
2322 | 2320 | $temp = array( |
— | — | @@ -2326,7 +2324,6 @@ |
2327 | 2325 | 'value' => wfMsg('showpreview'), |
2328 | 2326 | 'accesskey' => '', |
2329 | 2327 | 'title' => wfMsg( 'tooltip-preview' ).' ['.wfMsg( 'accesskey-preview' ).']', |
2330 | | - 'style' => 'display: none;', |
2331 | 2328 | ); |
2332 | 2329 | $buttons['preview'] = Xml::element('input', $temp, ''); |
2333 | 2330 | |
— | — | @@ -2338,6 +2335,7 @@ |
2339 | 2336 | 'value' => wfMsg('showlivepreview'), |
2340 | 2337 | 'accesskey' => wfMsg('accesskey-preview'), |
2341 | 2338 | 'title' => '', |
| 2339 | + 'style' => 'display: none;', |
2342 | 2340 | ); |
2343 | 2341 | |
2344 | 2342 | $buttons['live'] = Xml::element('input', $temp, ''); |
— | — | @@ -2371,6 +2369,21 @@ |
2372 | 2370 | } |
2373 | 2371 | |
2374 | 2372 | /** |
| 2373 | + * Whether to use live preview for this page |
| 2374 | + * This disables live preview when editing css/js user subpages so that the |
| 2375 | + * user can preview them (bug 3421) |
| 2376 | + * |
| 2377 | + * @return Boolean |
| 2378 | + */ |
| 2379 | + public function useLivePreview() { |
| 2380 | + global $wgLivePreview, $wgUser; |
| 2381 | + |
| 2382 | + return $wgLivePreview && $wgUser->getOption( 'uselivepreview' ) && |
| 2383 | + !( ( $this->mTitle->isCssSubpage() && $this->mTitle->userCanEditCssSubpage() ) || |
| 2384 | + ( $this->mTitle->isJsSubpage() && $this->mTitle->userCanEditCssSubpage() ) ); |
| 2385 | + } |
| 2386 | + |
| 2387 | + /** |
2375 | 2388 | * Output preview text only. This can be sucked into the edit page |
2376 | 2389 | * via JavaScript, and saves the server time rendering the skin as |
2377 | 2390 | * well as theoretically being more robust on the client (doesn't |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -535,6 +535,7 @@ |
536 | 536 | * (bug 20802) Fixed thumb.php redirect handling |
537 | 537 | * (bug 17747) Only display thumbnail column in file history if the image can |
538 | 538 | be rendered. |
| 539 | +* (bug 3421) Live preview no longer breaks user CSS/JS previews |
539 | 540 | |
540 | 541 | == API changes in 1.16 == |
541 | 542 | |