Skip to content

Commit 85f2f45

Browse files
author
westi
committed
Improve the revision comparison user interface to hilight that we compare "old on left" to "new on right". Includes some js to hide the radio buttons to stop you selecting reverse comparisions.
Fixes #11088 props filosofo. git-svn-id: http://core.svn.wordpress.org/trunk@12500 1a063a9b-81f0-0310-95a4-ce76da25c4cd
1 parent 25b5d1d commit 85f2f45

File tree

5 files changed

+35
-3
lines changed

5 files changed

+35
-3
lines changed

wp-admin/revision.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
/** WordPress Administration Bootstrap */
1010
require_once('admin.php');
1111

12+
wp_enqueue_script('list-revisions');
13+
1214
wp_reset_vars(array('revision', 'left', 'right', 'diff', 'action'));
1315
$revision_id = absint($revision);
1416
$diff = absint($diff);
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
(function(w) {
2+
var init = function() {
3+
var pr = document.getElementById('post-revisions'),
4+
inputs = pr ? pr.getElementsByTagName('input') : [];
5+
pr.onclick = function() {
6+
var i, checkCount = 0, side;
7+
for ( i = 0; i < inputs.length; i++ ) {
8+
checkCount += inputs[i].checked ? 1 : 0;
9+
side = inputs[i].getAttribute('name');
10+
if ( ! inputs[i].checked &&
11+
( 'left' == side && 1 > checkCount || 'right' == side && 1 < checkCount && ( ! inputs[i-1] || ! inputs[i-1].checked ) ) &&
12+
! ( inputs[i+1] && inputs[i+1].checked && 'right' == inputs[i+1].getAttribute('name') ) )
13+
inputs[i].style.visibility = 'hidden';
14+
else if ( 'left' == side || 'right' == side )
15+
inputs[i].style.visibility = 'visible';
16+
}
17+
}
18+
pr.onclick();
19+
}
20+
if ( w && w.addEventListener )
21+
w.addEventListener('load', init, false);
22+
else if ( w && w.attachEvent )
23+
w.attachEvent('onload', init);
24+
})(window);

wp-includes/js/wp-list-revisions.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

wp-includes/post-template.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,7 +1299,8 @@ function wp_list_post_revisions( $post_id = 0, $args = null ) {
12991299
$actions = '';
13001300

13011301
$rows .= "<tr$class>\n";
1302-
$rows .= "\t<th style='white-space: nowrap' scope='row'><input type='radio' name='left' value='$revision->ID'$left_checked /><input type='radio' name='right' value='$revision->ID'$right_checked /></th>\n";
1302+
$rows .= "\t<th style='white-space: nowrap' scope='row'><input type='radio' name='left' value='$revision->ID'$left_checked />\n";
1303+
$rows .= "\t<th style='white-space: nowrap' scope='row'><input type='radio' name='right' value='$revision->ID'$right_checked /></th>\n";
13031304
$rows .= "\t<td>$date</td>\n";
13041305
$rows .= "\t<td>$name</td>\n";
13051306
$rows .= "\t<td class='action-links'>$actions</td>\n";
@@ -1323,14 +1324,16 @@ function wp_list_post_revisions( $post_id = 0, $args = null ) {
13231324

13241325
<br class="clear" />
13251326

1326-
<table class="widefat post-revisions" cellspacing="0">
1327+
<table class="widefat post-revisions" cellspacing="0" id="post-revisions">
1328+
<col />
13271329
<col />
13281330
<col style="width: 33%" />
13291331
<col style="width: 33%" />
13301332
<col style="width: 33%" />
13311333
<thead>
13321334
<tr>
1333-
<th scope="col"></th>
1335+
<th scope="col"><?php _e( 'Old' ); ?></th>
1336+
<th scope="col"><?php _e( 'New' ); ?></th>
13341337
<th scope="col"><?php _e( 'Date Created' ); ?></th>
13351338
<th scope="col"><?php _e( 'Author' ); ?></th>
13361339
<th scope="col" class="action-links"><?php _e( 'Actions' ); ?></th>

wp-includes/script-loader.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,8 @@ function wp_default_scripts( &$scripts ) {
373373
$scripts->add( 'hoverIntent', "/wp-includes/js/hoverIntent$suffix.js", array('jquery'), '20090102' );
374374
$scripts->add_data( 'hoverIntent', 'group', 1 );
375375

376+
$scripts->add( 'list-revisions', "/wp-includes/js/wp-list-revisions$suffix.js", null, '20091223' );
377+
376378
$scripts->add( 'media', "/wp-admin/js/media$suffix.js", array( 'jquery-ui-draggable' ), '20090415' );
377379
$scripts->add_data( 'media', 'group', 1 );
378380

0 commit comments

Comments
 (0)