Ticket #25473: 25473.diff
File 25473.diff, 13.5 KB (added by , 6 years ago) |
---|
-
src/js/_enqueues/wp/revisions.js
626 626 model: tooltip 627 627 }) ); 628 628 629 // Add the visually hidden slider help view. 630 this.views.add( new revisions.view.SliderHelp() ); 631 629 632 // Add the slider view 630 633 this.views.add( new revisions.view.Slider({ 631 634 model: slider … … 727 730 // Add the 'from' view 728 731 this.views.add( new revisions.view.MetaFrom({ 729 732 model: this.model, 730 className: 'diff-meta diff-meta-from' 733 className: 'diff-meta diff-meta-from', 731 734 }) ); 732 735 733 736 // Add the 'to' view … … 802 805 } 803 806 }); 804 807 808 // The slider visually hidden help view. 809 revisions.view.SliderHelp = wp.Backbone.View.extend({ 810 className: 'revisions-slider-hidden-help', 811 template: wp.template( 'revisions-slider-hidden-help' ) 812 }); 813 805 814 // The tooltip view. 806 815 // Encapsulates the tooltip. 807 816 revisions.view.Tooltip = wp.Backbone.View.extend({ … … 941 950 ready: function() { 942 951 this.$el.css('width', ( this.model.revisions.length * 50 ) + 'px'); 943 952 this.$el.slider( _.extend( this.model.toJSON(), { 953 create: function() { 954 var handles = $( '.ui-slider-handle' ); 955 handles.first().attr( { 956 role: 'button', 957 'aria-labelledby': 'diff-title-from', 958 'aria-describedby': 'revisions-slider-hidden-help', 959 } ); 960 handles.last().attr( { 961 role: 'button', 962 'aria-labelledby': 'diff-title-to', 963 'aria-describedby': 'revisions-slider-hidden-help', 964 } ); 965 }, 944 966 start: this.start, 945 967 slide: this.slide, 946 968 stop: this.stop -
src/wp-admin/css/revisions.css
179 179 box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); 180 180 } 181 181 182 .revisions-diff h3:first-child { 182 .revisions-diff .diff-field-heading { 183 margin-left: 6px; 184 } 185 186 .revisions-diff .diff-field-heading:first-child { 183 187 margin-top: 0; 184 188 } 185 189 … … 189 193 vertical-align: middle; 190 194 } 191 195 192 table.diff tbody tr td:nth-child(2) {193 width: 4%;194 }195 196 196 table.diff { 197 197 table-layout: fixed; 198 198 width: 100%; 199 border-collapse: collapse; 199 200 white-space: pre-wrap; 200 201 } 201 202 202 table.diff col.content{203 table.diff td { 203 204 width: auto; 204 205 } 205 206 206 table.diff col.content.diffsplit { 207 width: 48%; 207 table.diff.is-split-view th:first-child, 208 table.diff.is-split-view td:first-child { 209 width: 50%; 210 border-right: 50px solid transparent; 208 211 } 209 212 210 table.diff col.diffsplit.middle { 211 width: auto; 213 table.diff.is-split-view th:last-child, 214 table.diff.is-split-view td:last-child { 215 width: 50%; 216 border-left: 50px solid transparent; 212 217 } 213 218 214 table.diff col.ltype {215 width: 30px;216 }217 218 219 table.diff tr { 219 220 background-color: transparent; 220 221 } 221 222 222 table.diff td,223 223 table.diff th { 224 font-size: inherit; 225 line-height: inherit; 226 padding: 0 6px 1em; 227 text-align: left; 228 vertical-align: top; 229 } 230 231 table.diff td { 224 232 font-family: Consolas, Monaco, monospace; 225 233 font-size: 14px; 226 line-height: 1. 618;227 padding: .5em;234 line-height: 1.5714; 235 padding: 6px; 228 236 vertical-align: top; 229 237 word-wrap: break-word; 238 background-clip: padding-box; 230 239 } 231 240 232 241 table.diff td h1, … … 457 466 touch-action: none; 458 467 } 459 468 460 .wp-slider .ui-slider-handle, 461 .wp-slider .ui-slider-handle.focus { 469 .wp-slider .ui-slider-handle { 462 470 background: #f7f7f7; 463 471 border: 1px solid #ccc; 464 472 box-shadow: 0 1px 0 #cccccc; … … 470 478 border-color: #999; 471 479 } 472 480 481 .wp-slider .ui-slider-handle:focus, 482 .wp-slider .ui-slider-handle.ui-state-focus { 483 background: #fafafa; 484 border-color: #999; 485 box-shadow: 0 0 0 2px #5b9dd9; 486 /* Only visible in Windows High Contrast mode */ 487 outline: 2px solid transparent; 488 } 489 473 490 .wp-slider .ui-slider-handle:active, 474 491 .wp-slider .ui-slider-handle.ui-state-active { 475 492 background: #eee; -
src/wp-admin/includes/revision.php
84 84 85 85 $args = array( 86 86 'show_split_view' => true, 87 'title_left' => __( 'Base revision' ), 88 'title_right' => __( 'Compared revision' ), 87 89 ); 88 90 89 91 /** … … 107 109 108 110 $diff = wp_text_diff( $content_from, $content_to, $args ); 109 111 112 $is_split_view = ! empty( $args['show_split_view'] ); 113 $is_split_view_class = $is_split_view ? ' is-split-view' : ''; 114 115 // Handle the post title when there's no diff. 110 116 if ( ! $diff && 'post_title' === $field ) { 111 // It's a better user experience to still show the Title, even if it didn't change. 112 // No, you didn't see this. 113 $diff = '<table class="diff"><colgroup><col class="content diffsplit left"><col class="content diffsplit middle"><col class="content diffsplit right"></colgroup><tbody><tr>'; 117 $diff = "<table class='diff$is_split_view_class'><tbody>"; 114 118 119 if ( $args['title_left'] || $args['title_right'] ) { 120 $th_or_td_left = empty( $args['title_left'] ) ? 'td' : 'th'; 121 $th_or_td_right = empty( $args['title_right'] ) ? 'td' : 'th'; 122 123 $diff .= "<tr class='diff-sub-title'>\n"; 124 $diff .= "\t<$th_or_td_left>$args[title_left]</$th_or_td_left>\n"; 125 if ( $is_split_view ) { 126 $diff .= "\t<$th_or_td_right>$args[title_right]</$th_or_td_right>\n"; 127 } 128 $diff .= "</tr>\n"; 129 } 130 131 $diff .= "<tr>\n"; 132 115 133 // In split screen mode, show the title before/after side by side. 116 134 if ( true === $args['show_split_view'] ) { 117 $diff .= '<td>' . esc_html( $compare_from->post_title ) . '</td><td> </td><td>' . esc_html( $compare_to->post_title ) . '</td>';135 $diff .= '<td>' . esc_html( $compare_from->post_title ) . '</td><td>' . esc_html( $compare_to->post_title ) . '</td>'; 118 136 } else { 119 137 $diff .= '<td>' . esc_html( $compare_from->post_title ) . '</td>'; 120 138 … … 364 382 </div> 365 383 </script> 366 384 385 <script id="tmpl-revisions-slider-hidden-help" type="text/html"> 386 <h2 class="screen-reader-text"><?php esc_html_e( 'Select a revision' ); ?></h2> 387 <p id="revisions-slider-hidden-help" hidden><?php esc_html_e( 'Change revision by using the left and arrow keys' ); ?></p> 388 </script> 389 367 390 <script id="tmpl-revisions-checkbox" type="text/html"> 368 391 <div class="revision-toggle-compare-mode"> 369 392 <label> … … 381 404 382 405 <script id="tmpl-revisions-meta" type="text/html"> 383 406 <# if ( ! _.isUndefined( data.attributes ) ) { #> 384 <div class="diff-title" >407 <div class="diff-title" id="diff-title-{{ data.type }}"> 385 408 <# if ( 'from' === data.type ) { #> 386 409 <strong><?php _ex( 'From:', 'Followed by post revision info' ); ?></strong> 387 410 <# } else if ( 'to' === data.type ) { #> … … 398 421 '<span class="author-name">{{ data.attributes.author.name }}</span>' 399 422 ); 400 423 ?> 401 424 </span> 402 425 <# } else if ( data.attributes.current ) { #> 403 426 <span class="byline"> 404 427 <?php … … 407 430 '<span class="author-name">{{ data.attributes.author.name }}</span>' 408 431 ); 409 432 ?> 410 433 </span> 411 434 <# } else { #> 412 435 <span class="byline"> 413 436 <?php … … 416 439 '<span class="author-name">{{ data.attributes.author.name }}</span>' 417 440 ); 418 441 ?> 419 442 </span> 420 443 <# } #> 421 444 <span class="time-ago">{{ data.attributes.timeAgo }}</span> 422 445 <span class="date">({{ data.attributes.dateShort }})</span> 423 446 </div> 424 <# if ( 'to' === data.type && data.attributes.restoreUrl ) { #> 425 <input <?php if ( wp_check_post_lock( $post->ID ) ) { ?> 447 </div> 448 </div> 449 <# if ( 'to' === data.type && data.attributes.restoreUrl ) { #> 450 <input <?php if ( wp_check_post_lock( $post->ID ) ) { ?> 451 disabled="disabled" 452 <?php } else { ?> 453 <# if ( data.attributes.current ) { #> 426 454 disabled="disabled" 427 <?php } else { ?>428 <# if ( data.attributes.current ) { #>429 disabled="disabled"430 <# } #>431 <?php } ?>432 <# if ( data.attributes.autosave ) { #>433 type="button" class="restore-revision button button-primary" value="<?php esc_attr_e( 'Restore This Autosave' ); ?>" />434 <# } else { #>435 type="button" class="restore-revision button button-primary" value="<?php esc_attr_e( 'Restore This Revision' ); ?>" />436 455 <# } #> 456 <?php } ?> 457 <# if ( data.attributes.autosave ) { #> 458 type="button" class="restore-revision button button-primary" value="<?php esc_attr_e( 'Restore This Autosave' ); ?>" /> 459 <# } else { #> 460 type="button" class="restore-revision button button-primary" value="<?php esc_attr_e( 'Restore This Revision' ); ?>" /> 437 461 <# } #> 438 </div> 439 <# if ( 'tooltip' === data.type ) { #> 440 <div class="revisions-tooltip-arrow"><span></span></div> 462 <# } #> 463 <# if ( 'tooltip' === data.type ) { #> 464 <div class="revisions-tooltip-arrow"><span></span></div> 465 <# } #> 441 466 <# } #> 442 <# } #>443 467 </script> 444 468 445 469 <script id="tmpl-revisions-diff" type="text/html"> … … 447 471 <div class="diff-error"><?php _e( 'Sorry, something went wrong. The requested comparison could not be loaded.' ); ?></div> 448 472 <div class="diff"> 449 473 <# _.each( data.fields, function( field ) { #> 450 <h 3>{{ field.name }}</h3>474 <h2 class="diff-field-heading">{{ field.name }}</h2> 451 475 {{{ field.diff }}} 452 476 <# }); #> 453 477 </div> -
src/wp-includes/class-wp-text-diff-renderer-table.php
176 176 } 177 177 178 178 if ( $this->_show_split_view ) { 179 $r .= '<tr>' . $this->emptyLine() . $this-> emptyLine() . $this->addedLine( $line ) . "</tr>\n";179 $r .= '<tr>' . $this->emptyLine() . $this->addedLine( $line ) . "</tr>\n"; 180 180 } else { 181 181 $r .= '<tr>' . $this->addedLine( $line ) . "</tr>\n"; 182 182 } … … 201 201 $line = apply_filters( 'process_text_diff_html', $processed_line, $line, 'deleted' ); 202 202 } 203 203 if ( $this->_show_split_view ) { 204 $r .= '<tr>' . $this->deletedLine( $line ) . $this->emptyLine() . $this->emptyLine() ."</tr>\n";204 $r .= '<tr>' . $this->deletedLine( $line ) . $this->emptyLine() . "</tr>\n"; 205 205 } else { 206 206 $r .= '<tr>' . $this->deletedLine( $line ) . "</tr>\n"; 207 207 } … … 226 226 $line = apply_filters( 'process_text_diff_html', $processed_line, $line, 'unchanged' ); 227 227 } 228 228 if ( $this->_show_split_view ) { 229 $r .= '<tr>' . $this->contextLine( $line ) . $this-> emptyLine() . $this->contextLine( $line ) . "</tr>\n";229 $r .= '<tr>' . $this->contextLine( $line ) . $this->contextLine( $line ) . "</tr>\n"; 230 230 } else { 231 231 $r .= '<tr>' . $this->contextLine( $line ) . "</tr>\n"; 232 232 } … … 317 317 $r .= $this->_deleted( array( $orig_line ), false ); 318 318 } else { // A true changed row. 319 319 if ( $this->_show_split_view ) { 320 $r .= '<tr>' . $this->deletedLine( $orig_line ) . $this-> emptyLine() . $this->addedLine( $final_line ) . "</tr>\n";320 $r .= '<tr>' . $this->deletedLine( $orig_line ) . $this->addedLine( $final_line ) . "</tr>\n"; 321 321 } else { 322 322 $r .= '<tr>' . $this->deletedLine( $orig_line ) . '</tr><tr>' . $this->addedLine( $final_line ) . "</tr>\n"; 323 323 } -
src/wp-includes/pluggable.php
2689 2689 */ 2690 2690 function wp_text_diff( $left_string, $right_string, $args = null ) { 2691 2691 $defaults = array( 2692 'title' => '', 2693 'title_left' => '', 2694 'title_right' => '', 2692 'title' => '', 2693 'title_left' => '', 2694 'title_right' => '', 2695 'show_split_view' => true, 2695 2696 ); 2696 $args = wp_parse_args( $args, $defaults );2697 2697 2698 $args = wp_parse_args( $args, $defaults ); 2699 2698 2700 if ( ! class_exists( 'WP_Text_Diff_Renderer_Table', false ) ) { 2699 2701 require( ABSPATH . WPINC . '/wp-diff.php' ); 2700 2702 } … … 2712 2714 return ''; 2713 2715 } 2714 2716 2715 $r = "<table class='diff'>\n"; 2717 $is_split_view = ! empty( $args['show_split_view'] ); 2718 $is_split_view_class = $is_split_view ? ' is-split-view' : ''; 2716 2719 2717 if ( ! empty( $args['show_split_view'] ) ) {2718 $r .= "<col class='content diffsplit left' /><col class='content diffsplit middle' /><col class='content diffsplit right' />"; 2719 } else{2720 $r .= "<c ol class='content' />";2720 $r = "<table class='diff$is_split_view_class'>\n"; 2721 2722 if ( $args['title'] ) { 2723 $r .= "<caption class='diff-title'>$args[title]</caption>\n"; 2721 2724 } 2722 2725 2723 if ( $args['title '] || $args['title_left'] || $args['title_right'] ) {2726 if ( $args['title_left'] || $args['title_right'] ) { 2724 2727 $r .= '<thead>'; 2725 2728 } 2726 if ( $args['title'] ) { 2727 $r .= "<tr class='diff-title'><th colspan='4'>$args[title]</th></tr>\n"; 2728 } 2729 2729 2730 if ( $args['title_left'] || $args['title_right'] ) { 2731 $th_or_td_left = empty( $args['title_left'] ) ? 'td' : 'th'; 2732 $th_or_td_right = empty( $args['title_right'] ) ? 'td' : 'th'; 2733 2730 2734 $r .= "<tr class='diff-sub-title'>\n"; 2731 $r .= "\t<td></td><th>$args[title_left]</th>\n"; 2732 $r .= "\t<td></td><th>$args[title_right]</th>\n"; 2735 $r .= "\t<$th_or_td_left>$args[title_left]</$th_or_td_left>\n"; 2736 if ( $is_split_view ) { 2737 $r .= "\t<$th_or_td_right>$args[title_right]</$th_or_td_right>\n"; 2738 } 2733 2739 $r .= "</tr>\n"; 2734 2740 } 2735 if ( $args['title'] || $args['title_left'] || $args['title_right'] ) { 2741 2742 if ( $args['title_left'] || $args['title_right'] ) { 2736 2743 $r .= "</thead>\n"; 2737 2744 } 2738 2745 … … 2742 2749 return $r; 2743 2750 } 2744 2751 endif; 2745