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: https://develop.svn.wordpress.org/trunk@12500 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
a01ed1f445
commit
ca583c9b1a
@ -9,6 +9,8 @@
|
||||
/** WordPress Administration Bootstrap */
|
||||
require_once('admin.php');
|
||||
|
||||
wp_enqueue_script('list-revisions');
|
||||
|
||||
wp_reset_vars(array('revision', 'left', 'right', 'diff', 'action'));
|
||||
$revision_id = absint($revision);
|
||||
$diff = absint($diff);
|
||||
|
24
wp-includes/js/wp-list-revisions.dev.js
Normal file
24
wp-includes/js/wp-list-revisions.dev.js
Normal file
@ -0,0 +1,24 @@
|
||||
(function(w) {
|
||||
var init = function() {
|
||||
var pr = document.getElementById('post-revisions'),
|
||||
inputs = pr ? pr.getElementsByTagName('input') : [];
|
||||
pr.onclick = function() {
|
||||
var i, checkCount = 0, side;
|
||||
for ( i = 0; i < inputs.length; i++ ) {
|
||||
checkCount += inputs[i].checked ? 1 : 0;
|
||||
side = inputs[i].getAttribute('name');
|
||||
if ( ! inputs[i].checked &&
|
||||
( 'left' == side && 1 > checkCount || 'right' == side && 1 < checkCount && ( ! inputs[i-1] || ! inputs[i-1].checked ) ) &&
|
||||
! ( inputs[i+1] && inputs[i+1].checked && 'right' == inputs[i+1].getAttribute('name') ) )
|
||||
inputs[i].style.visibility = 'hidden';
|
||||
else if ( 'left' == side || 'right' == side )
|
||||
inputs[i].style.visibility = 'visible';
|
||||
}
|
||||
}
|
||||
pr.onclick();
|
||||
}
|
||||
if ( w && w.addEventListener )
|
||||
w.addEventListener('load', init, false);
|
||||
else if ( w && w.attachEvent )
|
||||
w.attachEvent('onload', init);
|
||||
})(window);
|
1
wp-includes/js/wp-list-revisions.js
Normal file
1
wp-includes/js/wp-list-revisions.js
Normal file
@ -0,0 +1 @@
|
||||
(function(a){var b=function(){var d=document.getElementById("post-revisions"),c=d?d.getElementsByTagName("input"):[];d.onclick=function(){var g,f=0,e;for(g=0;g<c.length;g++){f+=c[g].checked?1:0;e=c[g].getAttribute("name");if(!c[g].checked&&("left"==e&&1>f||"right"==e&&1<f&&(!c[g-1]||!c[g-1].checked))&&!(c[g+1]&&c[g+1].checked&&"right"==c[g+1].getAttribute("name"))){c[g].style.visibility="hidden"}else{if("left"==e||"right"==e){c[g].style.visibility="visible"}}}};d.onclick()};if(a&&a.addEventListener){a.addEventListener("load",b,false)}else{if(a&&a.attachEvent){a.attachEvent("onload",b)}}})(window);
|
@ -1299,7 +1299,8 @@ function wp_list_post_revisions( $post_id = 0, $args = null ) {
|
||||
$actions = '';
|
||||
|
||||
$rows .= "<tr$class>\n";
|
||||
$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";
|
||||
$rows .= "\t<th style='white-space: nowrap' scope='row'><input type='radio' name='left' value='$revision->ID'$left_checked />\n";
|
||||
$rows .= "\t<th style='white-space: nowrap' scope='row'><input type='radio' name='right' value='$revision->ID'$right_checked /></th>\n";
|
||||
$rows .= "\t<td>$date</td>\n";
|
||||
$rows .= "\t<td>$name</td>\n";
|
||||
$rows .= "\t<td class='action-links'>$actions</td>\n";
|
||||
@ -1323,14 +1324,16 @@ function wp_list_post_revisions( $post_id = 0, $args = null ) {
|
||||
|
||||
<br class="clear" />
|
||||
|
||||
<table class="widefat post-revisions" cellspacing="0">
|
||||
<table class="widefat post-revisions" cellspacing="0" id="post-revisions">
|
||||
<col />
|
||||
<col />
|
||||
<col style="width: 33%" />
|
||||
<col style="width: 33%" />
|
||||
<col style="width: 33%" />
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col"></th>
|
||||
<th scope="col"><?php _e( 'Old' ); ?></th>
|
||||
<th scope="col"><?php _e( 'New' ); ?></th>
|
||||
<th scope="col"><?php _e( 'Date Created' ); ?></th>
|
||||
<th scope="col"><?php _e( 'Author' ); ?></th>
|
||||
<th scope="col" class="action-links"><?php _e( 'Actions' ); ?></th>
|
||||
|
@ -373,6 +373,8 @@ function wp_default_scripts( &$scripts ) {
|
||||
$scripts->add( 'hoverIntent', "/wp-includes/js/hoverIntent$suffix.js", array('jquery'), '20090102' );
|
||||
$scripts->add_data( 'hoverIntent', 'group', 1 );
|
||||
|
||||
$scripts->add( 'list-revisions', "/wp-includes/js/wp-list-revisions$suffix.js", null, '20091223' );
|
||||
|
||||
$scripts->add( 'media', "/wp-admin/js/media$suffix.js", array( 'jquery-ui-draggable' ), '20090415' );
|
||||
$scripts->add_data( 'media', 'group', 1 );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user