Ticket #23497: 23497.25.diff
File 23497.25.diff, 53.2 KB (added by , 12 years ago) |
---|
-
wp-includes/post-template.php
1315 1315 $date = date_i18n( $datef, strtotime( $revision->post_modified ) ); 1316 1316 if ( $link && current_user_can( 'edit_post', $revision->ID ) && $link = get_edit_post_link( $revision->ID ) ) 1317 1317 $date = "<a href='$link'>$date</a>"; 1318 1318 1319 1319 $revision_date_author = sprintf( 1320 1320 '%s %s, %s %s (%s)', 1321 1321 $gravatar, … … 1393 1393 if ( $parent ) 1394 1394 array_unshift( $revisions, $post ); 1395 1395 1396 //if ( wp_first_revision_matches_current_version( $post_id ) ) 1397 array_pop( $revisions ); 1398 1396 1399 $rows = $right_checked = ''; 1397 1400 $class = false; 1398 1401 $can_edit_post = current_user_can( 'edit_post', $post->ID ); … … 1479 1482 // if the post was previously restored from a revision 1480 1483 // show the restore event details 1481 1484 // 1482 if ( $restored_from_meta = get_post_meta( $post->ID, '_post_restored_from', true ) ) { 1483 $author = get_the_author_meta( 'display_name', $restored_from_meta[ 'restored_by_user' ] ); 1484 /* translators: revision date format, see http://php.net/date */ 1485 $datef = _x( 'j F, Y @ G:i:s', 'revision date format'); 1486 $date = date_i18n( $datef, strtotime( $restored_from_meta[ 'restored_time' ] ) ); 1487 $timesince = human_time_diff( $restored_from_meta[ 'restored_time' ], current_time( 'timestamp' ) ) . __( ' ago ' ); 1488 ?> 1485 if ( $restored_from_meta = get_post_meta( $post->ID, '_post_restored_from', true ) ) { 1486 $author = get_the_author_meta( 'display_name', $restored_from_meta[ 'restored_by_user' ] ); 1487 /* translators: revision date format, see http://php.net/date */ 1488 $datef = _x( 'j F, Y @ G:i:s', 'revision date format'); 1489 $date = date_i18n( $datef, strtotime( $restored_from_meta[ 'restored_time' ] ) ); 1490 $timesince = human_time_diff( $restored_from_meta[ 'restored_time' ], current_time( 'timestamp' ) ) . __( ' ago ' ); 1491 ?> 1489 1492 <hr /> 1490 <div id="revisions-meta-restored"> 1491 <?php 1492 printf( 'Previously restored from Revision ID %d, %s by %s (%s)', 1493 $restored_from_meta[ 'restored_revision_id'], 1494 $timesince, 1495 $author, 1496 $date ); 1497 ?> 1498 </div> 1499 <?php 1493 <div id="revisions-meta-restored"> 1494 <?php 1495 printf( 'Previously restored from Revision ID %d, %s by %s (%s)', 1496 $restored_from_meta[ 'restored_revision_id'], 1497 $timesince, 1498 $author, 1499 $date ); 1500 ?> 1501 </div> 1502 <?php 1500 1503 echo "</ul>"; 1501 } 1504 } 1502 1505 1503 1506 endif; 1504 1507 -
wp-includes/revision.php
62 62 /** 63 63 * Saves an already existing post as a post revision. 64 64 * 65 * Typically used immediately prior to post updates. 65 * Typically used immediately prior and after post updates. 66 * Prior to update checks for old revision data (latest revision != current post before update) and adds a copy of the current post as a revision if missing 67 * After update adds a copy of the current post as a revision, so latest revision always matches current post 66 68 * 67 69 * @package WordPress 68 70 * @subpackage Post_Revisions 69 71 * @since 2.6.0 70 72 * 71 73 * @uses _wp_put_post_revision() 74 * @uses wp_first_revision_matches_current_version() 72 75 * 73 76 * @param int $post_id The ID of the post to save as a revision. 74 77 * @return mixed Null or 0 if error, new revision ID, if success. 75 78 */ 76 function wp_save_post_revision( $post_id, $new_data = null ) { 77 // We do autosaves manually with wp_create_post_autosave() 79 function wp_save_post_revision( $post_id ) { 80 //check to see if the post's first revision already matches the post data 81 //should be true before post update, _except_ for old data which 82 //doesn't include a copy of the current post data in revisions 83 if ( wp_first_revision_matches_current_version( $post_id ) ) 84 return; 85 78 86 if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) 79 87 return; 80 88 … … 82 90 if ( ! WP_POST_REVISIONS ) 83 91 return; 84 92 85 if ( ! $post = get_post( $post_id, ARRAY_A ) )93 if ( ! $post = get_post( $post_id, ARRAY_A ) ) 86 94 return; 87 95 88 96 if ( 'auto-draft' == $post['post_status'] ) 89 97 return; 90 98 91 if ( ! post_type_supports($post['post_type'], 'revisions') )99 if ( ! post_type_supports( $post['post_type'], 'revisions' ) ) 92 100 return; 93 101 94 // if new data is supplied, check that it is different from last saved revision, unless a plugin tells us to always save regardless 95 if ( apply_filters( 'wp_save_post_revision_check_for_changes', true, $post, $new_data ) && is_array( $new_data ) ) { 96 $post_has_changed = false; 97 foreach ( array_keys( _wp_post_revision_fields() ) as $field ) { 98 if ( normalize_whitespace( $new_data[ $field ] ) != normalize_whitespace( $post[ $field ] ) ) { 99 $post_has_changed = true; 100 break; 102 // compare the proposed update with the last stored revision, verify 103 // different, unless a plugin tells us to always save regardless 104 if ( $revisions = wp_get_post_revisions( $post_id ) ) { // grab the last revision 105 $last_revision = array_shift( $revisions ); 106 107 if ( $last_revision_array = get_post( $last_revision->ID, ARRAY_A ) ) { //if no previous revisions, save one for sure 108 109 if ( apply_filters( 'wp_save_post_revision_check_for_changes', true, $last_revision_array, $post ) && is_array( $post ) ) { 110 $post_has_changed = false; 111 112 foreach ( array_keys( _wp_post_revision_fields() ) as $field ) { 113 114 if ( normalize_whitespace( $post[ $field ] ) != normalize_whitespace( $last_revision_array[ $field ] ) ) { 115 $post_has_changed = true; 116 break; 117 118 } 119 } 120 121 //don't save revision if post unchanged 122 if( ! $post_has_changed ) 123 return; 101 124 } 102 125 } 103 //don't save revision if post unchanged104 if( ! $post_has_changed )105 return;106 126 } 107 127 108 128 $return = _wp_put_post_revision( $post ); 109 129 110 130 // WP_POST_REVISIONS = true (default), -1 111 if ( ! is_numeric( WP_POST_REVISIONS ) || WP_POST_REVISIONS < 0 )131 if ( ! is_numeric( WP_POST_REVISIONS ) || WP_POST_REVISIONS < 0 ) 112 132 return $return; 113 133 114 134 // all revisions and (possibly) one autosave 115 135 $revisions = wp_get_post_revisions( $post_id, array( 'order' => 'ASC' ) ); 116 136 117 137 // WP_POST_REVISIONS = (int) (# of autosaves to save) 118 $delete = count( $revisions) - WP_POST_REVISIONS;138 $delete = count( $revisions ) - WP_POST_REVISIONS; 119 139 120 140 if ( $delete < 1 ) 121 141 return $return; … … 123 143 $revisions = array_slice( $revisions, 0, $delete ); 124 144 125 145 for ( $i = 0; isset($revisions[$i]); $i++ ) { 126 if ( false !== strpos( $revisions[ $i]->post_name, 'autosave' ) )146 if ( false !== strpos( $revisions[ $i ]->post_name, 'autosave' ) ) 127 147 continue; 128 wp_delete_post_revision( $revisions[ $i]->ID );148 wp_delete_post_revision( $revisions[ $i ]->ID ); 129 149 } 130 150 131 151 return $return; … … 418 438 add_filter('the_preview', '_set_preview'); 419 439 } 420 440 } 441 442 /** 443 * Determines if the specified post's most recent revision matches the post (by checking post_modified). 444 * 445 * @package WordPress 446 * @subpackage Post_Revisions 447 * @since 3.6.0 448 * 449 * @param int|object $post Post ID or post object. 450 * @return bool false if not a match, otherwise true. 451 */ 452 function wp_first_revision_matches_current_version( $post ) { 453 454 if ( ! $post = get_post( $post ) ) 455 return false; 456 457 if ( ! $revisions = wp_get_post_revisions( $post->ID ) ) 458 return false; 459 460 $last_revision = array_shift( $revisions ); 461 462 if ( ! ($last_revision->post_modified == $post->post_modified ) ) 463 return false; 464 465 return true; 466 } -
wp-includes/pluggable.php
1744 1744 return $r; 1745 1745 } 1746 1746 endif; 1747 1748 if ( !function_exists( 'wp_text_diff_with_count' ) ) : 1749 /** 1750 * Displays a human readable HTML representation of the difference between two strings. 1751 * similar to wp_text_diff, but tracks and returns could of lines added and removed 1752 * 1753 * @since 3.6 1754 * @see wp_parse_args() Used to change defaults to user defined settings. 1755 * @uses Text_Diff 1756 * @uses WP_Text_Diff_Renderer_Table 1757 * 1758 * @param string $left_string "old" (left) version of string 1759 * @param string $right_string "new" (right) version of string 1760 * @param string|array $args Optional. Change 'title', 'title_left', and 'title_right' defaults. 1761 * @return array contains html, linesadded & linesdeletd, empty string if strings are equivalent. 1762 */ 1763 function wp_text_diff_with_count( $left_string, $right_string, $args = null ) { 1764 $defaults = array( 'title' => '', 'title_left' => '', 'title_right' => '' ); 1765 $args = wp_parse_args( $args, $defaults ); 1766 1767 if ( !class_exists( 'WP_Text_Diff_Renderer_Table' ) ) 1768 require( ABSPATH . WPINC . '/wp-diff.php' ); 1769 1770 $left_string = normalize_whitespace( $left_string ); 1771 $right_string = normalize_whitespace( $right_string ); 1772 1773 $left_lines = explode( "\n", $left_string ); 1774 $right_lines = explode( "\n", $right_string) ; 1775 1776 $text_diff = new Text_Diff($left_lines, $right_lines ); 1777 $linesadded = $text_diff->countAddedLines(); 1778 $linesdeleted = $text_diff->countDeletedLines(); 1779 1780 $renderer = new WP_Text_Diff_Renderer_Table(); 1781 $diff = $renderer->render( $text_diff ); 1782 1783 if ( !$diff ) 1784 return ''; 1785 1786 $r = "<table class='diff'>\n"; 1787 1788 if ( ! empty( $args[ 'show_split_view' ] ) ) { 1789 $r .= "<col class='content diffsplit left' /><col class='content diffsplit middle' /><col class='content diffsplit right' />"; 1790 } else { 1791 $r .= "<col class='content' />"; 1792 } 1793 1794 if ( $args['title'] || $args['title_left'] || $args['title_right'] ) 1795 $r .= "<thead>"; 1796 if ( $args['title'] ) 1797 $r .= "<tr class='diff-title'><th colspan='4'>$args[title]</th></tr>\n"; 1798 if ( $args['title_left'] || $args['title_right'] ) { 1799 $r .= "<tr class='diff-sub-title'>\n"; 1800 $r .= "\t<td></td><th>$args[title_left]</th>\n"; 1801 $r .= "\t<td></td><th>$args[title_right]</th>\n"; 1802 $r .= "</tr>\n"; 1803 } 1804 if ( $args['title'] || $args['title_left'] || $args['title_right'] ) 1805 $r .= "</thead>\n"; 1806 1807 $r .= "<tbody>\n$diff\n</tbody>\n"; 1808 $r .= "</table>"; 1809 1810 return array( 'html' => $r, 'linesadded' => $linesadded, 'linesdeleted' => $linesdeleted ); 1811 } 1812 endif; -
wp-includes/script-loader.php
273 273 $scripts->add( 'template', "/wp-includes/js/template$suffix.js", array('underscore'), '1.4.4', 1 ); 274 274 $scripts->add( 'backbone', '/wp-includes/js/backbone.min.js', array('underscore','jquery', 'template'), '0.9.10', 1 ); 275 275 276 $scripts->add( 'revisions', "/wp-admin/js/revisions$suffix.js", array( 'backbone', 'jquery-ui-slider' ), false, 1 );276 $scripts->add( 'revisions', "/wp-admin/js/revisions$suffix.js", array( 'backbone', 'jquery-ui-slider', 'jquery-ui-tooltip' ), false, 1 ); 277 277 278 278 $scripts->add( 'imgareaselect', "/wp-includes/js/imgareaselect/jquery.imgareaselect$suffix.js", array('jquery'), '0.9.8', 1 ); 279 279 -
wp-admin/includes/ajax-actions.php
2153 2153 /* translators: revision date format, see http://php.net/date */ 2154 2154 $datef = _x( 'j F, Y @ G:i:s', 'revision date format'); 2155 2155 2156 $left_revision = get_post( $compare_to ); 2157 //error_log($left_revision); 2156 2158 //single model fetch mode 2159 //return the diff of a single revision comparison 2157 2160 if ( 0 != $single_revision_id ) { 2158 $left_revision = get_post( $compare_to );2159 2161 $right_revision = get_post( $single_revision_id ); 2160 2162 2161 if ( $compare_two_mode ) {2162 $compare_to_gravatar = get_avatar( $left_revision->post_author, 18 );2163 $compare_to_author = get_the_author_meta( 'display_name', $left_revision->post_author );2164 $compare_to_date = date_i18n( $datef, strtotime( $left_revision->post_modified ) );2165 2166 $revision_from_date_author = sprintf(2167 '%s %s, %s %s (%s)',2168 $compare_to_gravatar,2169 $compare_to_author,2170 human_time_diff( strtotime( $left_revision->post_modified ), current_time( 'timestamp' ) ),2171 __( ' ago ' ),2172 $compare_to_date2173 );2174 }2175 2176 2163 // 2177 2164 //make sure the left revision is the most recent 2178 2165 // … … 2182 2169 $right_revision = $temp; 2183 2170 } 2184 2171 2172 $linesadded=0; 2173 $linesdeleted=0; 2174 2185 2175 // 2186 2176 //compare from left to right, passed from application 2187 2177 // … … 2197 2187 if ( ! empty( $show_split_view ) ) 2198 2188 $args = array( 'show_split_view' => true ); 2199 2189 2200 $content .= wp_text_diff( $left_content, $right_content, $args ); 2190 $diff = wp_text_diff_with_count( $left_content, $right_content, $args ); 2191 2192 if ( isset( $diff[ 'html' ] ) ) 2193 $content .= $diff[ 'html' ]; 2194 2195 if ( isset( $diff[ 'linesadded' ] ) ) 2196 $linesadded = $linesadded + $diff[ 'linesadded' ]; 2197 2198 if ( isset( $diff[ 'linesdeleted' ] ) ) 2199 $linesdeleted = $linesdeleted + $diff[ 'linesdeleted' ]; 2200 2201 2201 2202 } 2202 $content = '' == $content ? __( 'No difference' ) : $content; 2203 $alltherevisions = array ( 2204 'revisiondiff' => $content 2205 ); 2203 $content = '' == $content ? __( 'No difference' ) : $content; 2204 2205 $alltherevisions = array ( 2206 'revisiondiff' => $content, 2207 'lines_deleted' => $linesdeleted, 2208 'lines_added' => $linesadded 2209 ); 2206 2210 echo json_encode( $alltherevisions ); 2207 2211 exit(); 2208 } 2212 } //end single model fetch 2209 2213 2214 //fetch the list of revisions available 2215 2210 2216 //if we are comparing two revisions, the first 'revision' represented by the leftmost 2211 2217 //slider position is the current revision, prepend a comparison to this revision 2212 if ( $compare_two_mode )2218 if ( $compare_two_mode && ! wp_first_revision_matches_current_version( $post_id ) ) //revisions don't have current version 2213 2219 array_unshift( $revisions, get_post( $post_id ) ); 2214 2220 2221 if ( $compare_two_mode) // && wp_first_revision_matches_current_version( $post_id ) ) //revisions already include current version 2222 array_shift( $revisions ); //remove the extra current revisions (comparing to current in one handle mode) 2223 2224 2215 2225 $count = -1; 2216 2226 2227 //reverse the list to start with oldes revision 2228 $revisions = array_reverse( $revisions ); 2229 2230 $previous_revision_id = 0; 2217 2231 foreach ( $revisions as $revision ) : 2218 if ( ! empty( $show_autosaves ) && wp_is_post_autosave( $revision ) ) 2232 //error_log( ( $show_autosaves )); 2233 if ( empty( $show_autosaves ) && wp_is_post_autosave( $revision ) ) 2219 2234 continue; 2220 2235 2221 2236 $revision_from_date_author = ''; 2222 2237 $count++; 2223 2238 // return blank data for diffs to the left of the left handle (for right handel model) 2224 2239 // or to the right of the right handle (for left handel model) 2225 if ( ( 0 != $left_handle_at && $count <= $left_handle_at ) || 2226 ( 0 != $right_handle_at && $count > $right_handle_at )) { 2240 if ( ( 0 != $left_handle_at && $count <= $left_handle_at ) || 2241 ( 0 != $right_handle_at && $count > $right_handle_at )) { 2227 2242 $alltherevisions[] = array ( 2228 2243 'ID' => $revision->ID, 2229 2244 ); 2230 2231 2245 continue; 2232 2246 } 2233 2247 2234 $gravatar = get_avatar( $revision->post_author, 18 ); 2248 if ( $compare_two_mode ) { 2249 $compare_to_gravatar = get_avatar( $left_revision->post_author, 24 ); 2250 $compare_to_author = get_the_author_meta( 'display_name', $left_revision->post_author ); 2251 $compare_to_date = date_i18n( $datef, strtotime( $left_revision->post_modified ) ); 2252 2253 $revision_from_date_author = sprintf( 2254 '%s %s, %s %s (%s)', 2255 $compare_to_gravatar, 2256 $compare_to_author, 2257 human_time_diff( strtotime( $left_revision->post_modified ), current_time( 'timestamp' ) ), 2258 __( ' ago ' ), 2259 $compare_to_date 2260 ); 2261 } 2262 2263 $gravatar = get_avatar( $revision->post_author, 24 ); 2235 2264 $author = get_the_author_meta( 'display_name', $revision->post_author ); 2236 2265 $date = date_i18n( $datef, strtotime( $revision->post_modified ) ); 2237 2266 $revision_date_author = sprintf( … … 2242 2271 __( ' ago ' ), 2243 2272 $date 2244 2273 ); 2274 $datef2 = __( 'j M @ G:i' ); 2275 $date2 = date_i18n( $datef2, strtotime( $revision->post_modified ) ); 2245 2276 2277 $revision_date_author_short = sprintf( 2278 '%s <strong>%s</strong><br />%s', 2279 $gravatar, 2280 $author, 2281 $date2 2282 ); 2283 2246 2284 $restoreaction = wp_nonce_url( 2247 2285 add_query_arg( 2248 2286 array( 'revision' => $revision->ID, … … 2252 2290 "restore-post_{$compare_to}|{$revision->ID}" 2253 2291 ); 2254 2292 2255 $alltherevisions[] = array ( 2293 if ( ( $compare_two_mode || 0 !== $previous_revision_id ) ) { 2294 $alltherevisions[] = array ( 2256 2295 'ID' => $revision->ID, 2257 2296 'revision_date_author' => $revision_date_author, 2258 2297 'revision_from_date_author' => $revision_from_date_author, 2298 'revision_date_author_short' => $revision_date_author_short, 2259 2299 'restoreaction' => urldecode( $restoreaction ), 2260 'revision_toload' => true 2300 'revision_toload' => true, 2301 'previous_revision_id' => $previous_revision_id 2261 2302 ); 2303 } 2304 $previous_revision_id = $revision->ID; 2262 2305 2263 2306 endforeach; 2264 2307 -
wp-admin/js/revisions.js
7 7 8 8 Model : Backbone.Model.extend({ 9 9 idAttribute : 'ID', 10 urlRoot : ajaxurl + '?action=revisions-data &compare_to=' + wpRevisionsSettings.post_id+11 '&show_autosaves= false&show_split_view=true&nonce=' + wpRevisionsSettings.nonce,10 urlRoot : ajaxurl + '?action=revisions-data' + 11 '&show_autosaves=true&show_split_view=true&nonce=' + wpRevisionsSettings.nonce, 12 12 defaults: { 13 13 ID : 0, 14 14 revision_date_author : '', 15 revision_date_author_short: '', 15 16 revisiondiff : '<div class="diff-loading"><div class="spinner"></div></div>', 16 17 restoreaction : '', 17 18 revision_from_date_author : '', 18 revision_toload : false 19 revision_toload : false, 20 lines_added : 0, 21 lines_deleted : 0, 22 scope_of_changes : 'none', 23 previous_revision_id : 0 19 24 }, 20 25 21 26 url : function() { 22 return this.urlRoot + '&single_revision_id=' + this.id; 27 if ( 1 === REVAPP._compareoneortwo ) { 28 return this.urlRoot + 29 '&single_revision_id=' + this.id + 30 '&compare_to=' + this.get( 'previous_revision_id' ) + 31 '&post_id=' + wpRevisionsSettings.post_id; 32 } else { 33 return this.urlRoot + 34 '&single_revision_id=' + this.id 35 } 36 23 37 } 24 38 25 39 }), … … 35 49 _revisionsOptions : null, 36 50 _left_diff : 0, 37 51 _right_diff : 1, 38 _autosaves : false,52 _autosaves : true, 39 53 _show_split_view : true, 40 54 _compareoneortwo : 1, 41 55 _left_model_loading : false, //keep track of model loads 42 56 _right_model_loading : false, //disallow slider interaction, also repeat loads, while loading 57 _tickmarkView : null, //the slider tickmarks 58 _keep_tooltip_open : false, 43 59 44 60 //TODO add ability to arrive on specific revision 45 61 routes : { … … 54 70 var revisions_to_load = model_collection.where( { revision_toload : true } ); 55 71 //console.log(revisions_to_load); 56 72 var delay=0; 57 _.each(revisions_to_load, function( the_model ) { 73 //match slider to passed revision_id 74 _.each( revisions_to_load, function( the_model ) { 75 if ( the_model.get( 'ID' ) == wpRevisionsSettings.revision_id ) { 76 //console.log ( the_model.get( 'ID' ) +'-' +wpRevisionsSettings.revision_id); 77 self._right_diff = self._revisions.indexOf( the_model ) + 1; 78 } 79 80 }); 81 _.each( revisions_to_load, function( the_model ) { 58 82 the_model.urlRoot = model_collection.url; 59 83 _.delay( function() { 60 84 the_model.fetch( { … … 63 87 remove : false, 64 88 //async : false, 65 89 success : function( model ) { 66 //console.log(model.get( 'ID' ) +'-'+self._revisions.at( self._right_diff ).get( 'ID' )); 67 if ( model.get( 'ID' ) === self._revisions.at( self._right_diff - 1 ).get( 'ID' ) ) { //reload if current model refreshed 90 model.set( 'revision_toload', 'false' ); 91 //console.log(model_collection.where( { revision_toload : true } ).length); 92 93 //stop spinner when all models are loaded 94 if ( 0 === model_collection.where( { revision_toload : true } ).length ) 95 self.stop_model_loading_spinner(); 96 97 self._tickmarkView.render(); 98 99 var total_changes = model.get( 'lines_added' ) + model.get( 'lines_deleted'); 100 // console.log(total_changes); 101 var scope_of_changes = 'vsmall'; 102 103 //hard coded scope of changes 104 //TODO change to dynamic based on range of values 105 if ( total_changes > 1 && total_changes <= 3 ) { 106 scope_of_changes = 'small'; 107 } else if(total_changes > 3 && total_changes <= 5 ) { 108 scope_of_changes = 'med'; 109 } else if(total_changes > 5 && total_changes <= 10 ) { 110 scope_of_changes = 'large'; 111 } else if(total_changes > 10 ) { 112 scope_of_changes = 'vlarge'; 113 } 114 model.set( 'scope_of_changes', scope_of_changes ); 115 //console.log (self._right_diff); 116 if ( 0 !== self._right_diff && 117 model.get( 'ID' ) === self._revisions.at( self._right_diff - 1 ).get( 'ID' ) ) { 118 //reload if current model refreshed 68 119 //console.log('render'); 69 120 self._revisionView.render(); 70 121 } 122 71 123 } 72 124 } ); 73 125 }, delay ) ; 74 delay = delay + 200; //stagger model loads by 200 ms to avoid hammering server with requests126 delay = delay + 150; //stagger model loads to avoid hammering server with requests 75 127 } 76 128 ); 77 129 }, … … 83 135 84 136 stop_left_model_loading : function() { 85 137 this._left_model_loading = false; 86 $('.revisiondiffcontainer').removeClass('leftmodelloading');87 138 }, 88 139 89 140 start_right_model_loading : function() { … … 93 144 94 145 stop_right_model_loading : function() { 95 146 this._right_model_loading = false; 147 }, 148 149 stop_model_loading_spinner : function() { 96 150 $('.revisiondiffcontainer').removeClass('rightmodelloading'); 151 $('.revisiondiffcontainer').removeClass('leftmodelloading'); 97 152 }, 98 153 99 154 reloadmodel : function() { … … 107 162 reloadmodelsingle : function() { 108 163 var self = this; 109 164 self._revisions.url = ajaxurl + '?action=revisions-data&compare_to=' + wpRevisionsSettings.post_id + 110 '&show_autosaves=' + self._autosaves +165 '&show_autosaves=' + REVAPP._autosaves + 111 166 '&show_split_view=' + REVAPP._show_split_view + 112 167 '&nonce=' + wpRevisionsSettings.nonce; 113 168 self.start_right_model_loading(); 114 this._revisions.fetch({ //reload revision data169 self._revisions.fetch({ //reload revision data 115 170 success : function() { 116 171 self.stop_right_model_loading(); 117 172 var revisioncount = self._revisions.length; 118 if ( self._right_diff > revisioncount ) //if right handle past rightmost, move 119 self._right_diff = revisioncount; 173 //if ( self._right_diff > revisioncount ) //if right handle past rightmost, move 120 174 175 // self._right_diff = revisioncount; 176 177 178 121 179 self._revisionView.render(); 122 180 self.reload_toload_revisions( self._revisions ); 123 181 124 182 $( '#slider' ).slider( 'option', 'max', revisioncount-1 ); //TODO test this, autsaves changed 183 $( '#slider' ).slider( 'value', REVAPP._right_diff - 1 ).trigger( 'slide' ); 184 REVAPP._tickmarkView.model = self._revisions; 185 REVAPP._tickmarkView.render(); 125 186 }, 126 187 127 188 error : function () { … … 136 197 var self = this; 137 198 self.start_left_model_loading(); 138 199 self._left_handle_revisions = new wp.revisions.Collection(); 200 //console.log( 'right - ' + self._right_diff ); 139 201 self._left_handle_revisions.url = 140 202 ajaxurl + 141 203 '?action=revisions-data&compare_to=' + self._revisions.at( self._right_diff - 1 ).get( 'ID' ) + 142 204 '&post_id=' + wpRevisionsSettings.post_id + 143 '&show_autosaves=' + self._autosaves +144 '&show_split_view=' + self._show_split_view +205 '&show_autosaves=' + REVAPP._autosaves + 206 '&show_split_view=' + REVAPP._show_split_view + 145 207 '&nonce=' + wpRevisionsSettings.nonce + 146 208 '&right_handle_at=' + ( self._right_diff ); 147 209 … … 150 212 success : function(){ 151 213 self.stop_left_model_loading(); 152 214 self.reload_toload_revisions( self._left_handle_revisions ); 215 self._tickmarkView.model = self._left_handle_revisions; 216 $( '#slider' ).slider( 'option', 'max', self._revisions.length ); 153 217 }, 154 218 155 219 error : function () { … … 163 227 var self = this; 164 228 self.start_right_model_loading(); 165 229 self._right_handle_revisions = new wp.revisions.Collection(); 166 if ( 0 === self._left_diff ) {167 230 self._right_handle_revisions.url = 168 231 ajaxurl + 169 '?action=revisions-data&compare_to=' + wpRevisionsSettings.post_id+232 '?action=revisions-data&compare_to=' + self._revisions.at( self._left_diff ).get( 'ID' )+ 170 233 '&post_id=' + wpRevisionsSettings.post_id + 171 '&show_autosaves=' + self._autosaves +172 '&show_split_view=' + self._show_split_view +234 '&show_autosaves=' + REVAPP._autosaves + 235 '&show_split_view=' + REVAPP._show_split_view + 173 236 '&nonce=' + wpRevisionsSettings.nonce; 174 } else {175 self._right_handle_revisions.url =176 ajaxurl +177 '?action=revisions-data&compare_to=' + self._revisions.at( self._left_diff - 1 ).get( 'ID' ) +178 '&post_id=' + wpRevisionsSettings.post_id +179 '&show_autosaves=' + self._autosaves +180 '&show_split_view=' + self._show_split_view +181 '&nonce=' + wpRevisionsSettings.nonce +182 '&left_handle_at=' + (self._left_diff ) ;183 }184 237 185 238 self._right_handle_revisions.fetch({ 186 239 187 240 success : function(){ 188 241 self.stop_right_model_loading(); 189 242 self.reload_toload_revisions( self._right_handle_revisions ); 243 self._tickmarkView.model = self._right_handle_revisions; 244 $( '#slider' ).slider( 'option', 'max', self._revisions.length ); 245 //REVAPP._revisionView.render(); 246 190 247 }, 191 248 192 249 error : function ( response ) { … … 208 265 initialize : function( options ) { 209 266 var self = this; //store the application instance 210 267 if (this._revisions === null) { 211 self._autosaves = '';212 268 self._revisions = new wp.revisions.Collection(); //set up collection 213 269 self.start_right_model_loading(); 214 270 self._revisions.fetch({ //load revision data 215 271 216 272 success : function() { 217 273 self.stop_right_model_loading(); 218 self. revisionDiffSetup();274 self.completeApplicationSetup(); 219 275 } 220 276 }); 221 277 } 222 278 return this; 223 279 }, 224 280 225 revisionDiffSetup : function() {281 completeApplicationSetup : function() { 226 282 this._revisionView = new wp.revisions.views.View({ 227 283 model : this._revisions 228 284 }); 229 285 this._revisionView.render(); 230 $( '#diff_max, #diff_maxof' ).html( this._revisions.length );231 $( '#diff_count' ).html( REVAPP._right_diff );232 286 $( '#slider' ).slider( 'option', 'max', this._revisions.length - 1 ); 233 287 234 288 this.reload_toload_revisions( this._revisions ); 289 235 290 this._revisionsInteractions = new wp.revisions.views.Interact({ 236 291 model : this._revisions 237 292 }); 238 293 this._revisionsInteractions.render(); 239 294 295 this._tickmarkView = new wp.revisions.views.Tickmarks({ 296 model : this._revisions 297 }); 298 this._tickmarkView.render(); 299 this._tickmarkView.resetticks(); 300 301 $( 'a.ui-slider-handle' ).attr( 'title', '' ).tooltip({ 302 track: false, 303 position: { 304 my: "top-80", 305 active: function( position, feedback ) { 306 $( this ).css( position ); 307 $( "<div>" ) 308 .addClass( "arrow" ) 309 .addClass( feedback.vertical ) 310 .addClass( feedback.horizontal ) 311 .appendTo( this ); 312 } 313 }, 314 show: false, 315 hide: false, 316 disabled: false 317 } ); 240 318 /* 319 .on( 'mouseup', function( event ) { 320 REVAPP._keep_tooltip_open = false; 321 $( this ).find('.ui-slider-tooltip').hide(); 322 } ).on( 'mousedown', function( event ) { 323 REVAPP._keep_tooltip_open = true; 324 } ).on( 'mouseout', function( event ) { 325 if ( REVAPP._keep_tooltip_open) 326 event.stopImmediatePropagation(); 327 }); 328 */ 329 /* 241 330 //Options hidden for now, moving to screen options 242 331 this._revisionsOptions = new wp.revisions.views.Options({ 243 332 model : this._revisions … … 252 341 wp.revisions.Collection = Backbone.Collection.extend({ 253 342 model : wp.revisions.Model, 254 343 url : ajaxurl + '?action=revisions-data&compare_to=' + wpRevisionsSettings.post_id + 255 '&show_autosaves= false&show_split_view=true&nonce=' + wpRevisionsSettings.nonce,344 '&show_autosaves=true&show_split_view=true&nonce=' + wpRevisionsSettings.nonce, 256 345 257 346 initialize : function() { 258 347 } 259 348 } ); 260 349 261 350 _.extend(wp.revisions.views, { 351 352 //Ticks inside slider view 262 353 // 354 Tickmarks : Backbone.View.extend({ 355 el : $('#diff-slider-ticks')[0], 356 tagName : 'diff-slider-ticks-view', 357 className : 'diff-slider-ticks-container', 358 template : wp.template('revision-ticks'), 359 model : wp.revisions.Model, 360 361 resetticks : function() { 362 var slider_max = $( '#slider' ).slider( 'option', 'max'); 363 var slider_width = $( '#slider' ).width(); 364 var adjust_max = ( 2 === REVAPP._compareoneortwo ) ? 1 : 0; 365 var tick_width = Math.floor( slider_width / ( slider_max - adjust_max ) ); 366 367 //TODO: adjust right margins for wider ticks so they stay centered on handle stop point 368 369 tick_width = (tick_width > 50 ) ? 50 : tick_width; 370 slider_width = tick_width * (slider_max - adjust_max ) +1; 371 372 $( '#slider' ).width( slider_width ); 373 $( '.diff-slider-ticks-wrapper' ).width( slider_width ); 374 $( '#diffslider' ).width( slider_width ); 375 $( '#diff-slider-ticks' ).width( slider_width ); 376 377 var a_tick_width = $( '.revision-tick' ).width(); 378 379 if ( tick_width !== a_tick_width ) { // is the width already set correctly? 380 $( '.revision-tick' ).each( function( ) { 381 $(this).css( 'margin-right', tick_width - 1 + 'px'); //space the ticks out using right margin 382 }); 383 384 if( 2 === REVAPP._compareoneortwo ) { 385 $( '.revision-tick' ).first().remove(); //TODO - remove thie check 386 } 387 $( '.revision-tick' ).last().css( 'margin-right', '0' ); // last tick gets no right margin 388 } 389 390 }, 391 392 //render the options view 393 render : function() { 394 var self = this; 395 396 if ( null !== self.model ) { 397 //TODO remove this initial model when ticket #16215 rolls because 398 //revisions will then include current version 399 var add_placeholder = ( 2 === REVAPP._compareoneortwo ) ? self.template('') : ''; 400 401 var addhtml = "";//add_placeholder; 402 _.each ( self.model.models, function ( the_model ) { 403 404 addhtml = addhtml + self.template ( the_model.toJSON() ); 405 406 }); 407 self.$el.html( addhtml ); 408 409 } 410 self.resetticks(); 411 return self; 412 } 413 }), 414 415 // 263 416 //primary revision diff view 264 417 // 265 418 View : Backbone.View.extend({ … … 271 424 comparetwochecked : '', 272 425 draggingleft : false, 273 426 274 initialize : function(){275 },276 277 427 // 278 428 //render the revisions 279 429 // 280 430 render : function() { 281 431 var addhtml = ''; 282 432 //compare two revisions mode? 433 283 434 if ( 2 === REVAPP._compareoneortwo ) { 284 435 this.comparetwochecked = 'checked'; 285 436 if ( this.draggingleft ) { … … 291 442 } 292 443 } else { //dragging right handle 293 444 var thediff = REVAPP._right_diff; 445 //console.log( thediff ) 294 446 if ( this.model.at( thediff ) ) { 295 447 addhtml = this.template( _.extend( 296 448 this.model.at( thediff ).toJSON(), … … 310 462 this.$el.html( addhtml ); 311 463 if ( this.model.length < 3 ) { 312 464 $( 'div#comparetworevisions' ).hide(); //don't allow compare two if fewer than three revisions 313 314 465 } 466 if ( this.model.length < 2 ) { 467 $( 'div#diffslider' ).hide(); //don't allow compare two if fewer than three revisions 468 $( 'div.diff-slider-ticks-wrapper' ).hide(); 469 } 315 470 //console.log ( (this.model.at( REVAPP._right_diff - 1 )).url()); 316 471 return this; 317 472 }, … … 326 481 // 327 482 clickcomparetwo : function(){ 328 483 self = this; 484 329 485 if ( $( 'input#comparetwo' ).is( ':checked' ) ) { 330 486 REVAPP._compareoneortwo = 2 ; 487 REVAPP._right_diff = ( 1 >= REVAPP._right_diff ) ? 1 : REVAPP._right_diff-1; //reset right handle 488 wpRevisionsSettings.revision_id = ''; // reset passed revision id so switching back to one handle mode doesn't re-select revision 331 489 REVAPP.reloadleftright(); 490 332 491 } else { 333 492 REVAPP._compareoneortwo = 1 ; 334 493 REVAPP._revisionView.draggingleft = false; 335 494 REVAPP._left_diff = 0; 495 REVAPP._right_diff = (REVAPP._revisions.length <= REVAPP._right_diff ) ? REVAPP._right_diff : REVAPP._right_diff +1; 336 496 REVAPP.reloadmodelsingle(); 337 497 } 338 498 REVAPP._revisionsInteractions.render(); 499 REVAPP._tickmarkView.render(); 500 REVAPP._revisionView.render(); 339 501 } 340 502 }), 341 503 342 504 // 343 505 //options view for show autosaves and show split view options 344 506 // 507 /* DISABLED for now 345 508 Options : Backbone.View.extend({ 346 509 el : $('#backbonerevisionsoptions')[0], 347 510 tagName : 'revisionoptionsview', 348 511 className : 'revisionoptions-container', 349 512 template : wp.template('revisionoptions'), 350 513 351 initialize : function() {352 },353 354 514 //render the options view 355 515 render : function() { 356 516 var addhtml = this.template; … … 396 556 REVAPP.reloadmodel(); 397 557 } 398 558 }), 399 559 */ 400 560 // 401 561 //main interactions view 402 562 // … … 405 565 tagName : 'revisionvinteract', 406 566 className : 'revisionvinteract-container', 407 567 template : wp.template('revisionvinteract'), 408 _restoreword : '',409 568 410 569 initialize : function() { 411 this._restoreword = $( 'input#restore' ).attr( 'value' );412 570 }, 413 571 414 reset_restore_button : function() {415 $( 'input#restore' ).attr( 'value', this._restoreword + ' ' + REVAPP._revisions.at( REVAPP._right_diff - 1 ).get( 'ID' ) );416 },417 418 572 render : function() { 419 573 var self = this; 420 574 421 575 var addhtml = this.template; 422 576 this.$el.html( addhtml ); 423 $( '#diff_max, #diff_maxof' ).html( this.model.length );424 $( '#diff_count' ).html( REVAPP._right_diff );425 $( '#diff_left_count_inner' ).html( 0 === REVAPP._left_diff ? '' : 'revision' + REVAPP._left_diff );426 self.reset_restore_button();427 577 428 578 var modelcount = REVAPP._revisions.length; 429 579 … … 431 581 if ( 1 === REVAPP._compareoneortwo ) { 432 582 //set up the slider with a single handle 433 583 slider.slider({ 434 value 435 min 436 max 437 step 584 value: REVAPP._right_diff-1, 585 min: 0, 586 max: modelcount-1, 587 step: 1, 438 588 589 439 590 //slide interactions for one handles slider 440 591 slide : function( event, ui ) { 441 if ( REVAPP._right_model_loading ) //left model stoll loading, prevent sliding left handle442 return false;443 592 444 REVAPP._right_diff =( ui.value+1 ); 445 $( '#diff_count' ).html( REVAPP._right_diff ); 593 REVAPP._right_diff = ( ui.value +1 ); 446 594 REVAPP._revisionView.render(); 447 self.reset_restore_button(); 448 } 595 /* 596 $( 'a.ui-slider-handle' ).tooltip( { 597 content: REVAPP._revisions.at( ui.value ).get( 'revision_date_author_short' ), 598 position: { 599 my: "top-65", 600 using: function( position, feedback ) { 601 $( this ).css( position ); 602 $( "<div>" ) 603 .addClass( "arrow" ) 604 .addClass( feedback.vertical ) 605 .addClass( feedback.horizontal ) 606 .appendTo( this ); 607 } 608 } 609 });//.trigger( 'close' ).trigger( 'open' ); 610 */ 611 } 449 612 }); 450 613 $( '.revisiondiffcontainer' ).removeClass( 'comparetwo' ); 614 451 615 } else { //comparing more than one, eg 2 452 616 //set up the slider with two handles 453 617 slider.slider({ … … 467 631 return false; 468 632 469 633 if ( REVAPP._revisionView.model !== REVAPP._left_handle_revisions && 470 null !== REVAPP._left_handle_revisions ) 634 null !== REVAPP._left_handle_revisions ) { 471 635 REVAPP._revisionView.model = REVAPP._left_handle_revisions; 472 636 REVAPP._tickmarkView.model = REVAPP._left_handle_revisions; 637 REVAPP._tickmarkView.render(); 638 } 473 639 REVAPP._revisionView.draggingleft = true; 474 640 REVAPP._left_diff_start = ui.values[ 0 ]; 475 641 break; 476 642 477 643 case 2: //right 478 if ( REVAPP._right_model_loading ) // right model stoll loading, prevent sliding right handle644 if ( REVAPP._right_model_loading ) //left model stoll loading, prevent sliding left handle 479 645 return false; 480 646 481 647 //one extra spot at left end when comparing two 482 648 if ( REVAPP._revisionView.model !== REVAPP._right_handle_revisions && 483 null !== REVAPP._right_handle_revisions ) 649 null !== REVAPP._right_handle_revisions ) { 484 650 REVAPP._revisionView.model = REVAPP._right_handle_revisions; 651 REVAPP._tickmarkView.model = REVAPP._right_handle_revisions; 652 REVAPP._tickmarkView.render(); 653 } 485 654 486 655 REVAPP._revisionView.draggingleft = false; 487 656 REVAPP._right_diff_start = ui.values[ 1 ]; … … 501 670 if ( REVAPP._left_model_loading ) //left model still loading, prevent sliding left handle 502 671 return false; 503 672 504 REVAPP._left_diff = ui.values[ 0 ] - 1; //one extra spot at left end when comparing two673 REVAPP._left_diff = ui.values[ 0 ]; //one extra spot at left end when comparing two 505 674 break; 506 675 507 676 case 2: //right 508 if ( REVAPP._right_model_loading ) //right model still loading, prevent sliding right handle509 return false;677 REVAPP._right_diff = ui.values[ 1 ]; 678 //console.log('setting ' + REVAPP._right_diff ); 510 679 511 REVAPP._right_diff = ui.values[ 1 ] - 1 ;512 680 break; 513 681 } 514 682 515 $( '#diff_count' ).html( REVAPP._right_diff );516 517 683 if ( 0 === REVAPP._left_diff ) { 518 684 $( '.revisiondiffcontainer' ).addClass( 'currentversion' ); 519 685 520 686 } else { 521 687 $( '.revisiondiffcontainer' ).removeClass( 'currentversion' ); 522 $( '#diff_left_count_inner' ).html( REVAPP._left_diff );523 688 } 524 689 525 REVAPP._revisionView.render(); //render the diff view526 self.reset_restore_button(); 690 REVAPP._revisionView.render(); 691 527 692 }, 528 693 529 694 //when the user stops sliding in 2 handle mode, recalculate diffs … … 537 702 switch ( index ) { 538 703 case 1: //left 539 704 //left handle dragged & changed, reload right handle model 540 if ( ! ( REVAPP._left_diff_start === ui.values[ 0 ] || REVAPP._left_model_loading ))705 if ( REVAPP._left_diff_start !== ui.values[ 0 ] ) 541 706 REVAPP.reloadright(); 542 707 543 708 break; 544 709 545 710 case 2: //right 546 711 //right handle dragged & changed, reload left handle model if changed 547 if ( ! ( REVAPP._right_diff_start === ui.values[ 1 ] || REVAPP._right_model_loading ) ) {712 if ( REVAPP._right_diff_start !== ui.values[ 1 ] ) 548 713 REVAPP.reloadleft(); 549 } 714 550 715 break; 551 716 } 552 717 } … … 571 736 572 737 REVAPP._revisionView.render(); 573 738 574 $( '#diff_count' ).html( REVAPP._right_diff );575 739 $( '#slider' ).slider( 'value', REVAPP._right_diff - 1 ).trigger( 'slide' ); 576 this.reset_restore_button();577 740 }, 578 741 579 742 //go the the previous revision … … 583 746 584 747 REVAPP._revisionView.render(); 585 748 586 $( '#diff_count' ).html( REVAPP._right_diff );587 749 $( '#slider' ).slider( 'value', REVAPP._right_diff - 1 ).trigger( 'slide' ); 588 this.reset_restore_button();589 750 } 590 751 }) 591 752 }); -
wp-admin/revision.php
80 80 $parent_file = $submenu_file = 'edit.php?post_type=' . $post->post_type; 81 81 else 82 82 $parent_file = $submenu_file = 'edit.php'; 83 84 83 wp_enqueue_script( 'revisions' ); 85 84 86 85 require_once( './admin-header.php' ); 87 86 88 87 //TODO - Some of the translations below split things into multiple strings that are contextually related and this makes it pretty impossible for RTL translation. 89 88 //TODO can we pass the context in a better way 89 $wpRevisionsSettings = array( 'post_id' => $post->ID, 90 'nonce' => wp_create_nonce( 'revisions-ajax-nonce' ), 91 'revision_id' => $revision_id ); 92 wp_localize_script( 'revisions', 'wpRevisionsSettings', $wpRevisionsSettings ); 93 94 $comparetworevisionslink = get_edit_post_link( $revision->ID ); 90 95 ?> 91 <script type="text/javascript">92 var wpRevisionsSettings = <?php echo json_encode( array( 'post_id' => $post->ID, 'nonce' => wp_create_nonce( 'revisions-ajax-nonce' ) ) ); ?>;93 </script>94 <?php95 $comparetworevisionslink = get_edit_post_link( $revision->ID );96 ?>97 96 98 <div id="backbonerevisionsoptions"></div> 97 <div id="backbonerevisionsoptions"> 98 </div> 99 99 <div class="wrap"> 100 <div class="icon32 icon32-posts-post" id="icon-edit"><br></div> 100 <div class="icon32 icon32-posts-post" id="icon-edit"> 101 <br> 102 </div> 101 103 <div class="revisiondiffcontainer diffsplit currentversion rightmodelloading"> 102 <div id="modelsloading" class="updated message"><span class="spinner" ></span> <?php _e( 'Calculating revision diffs' ); ?></div> 104 <div id="modelsloading" class="updated message"> 105 <span class="spinner" ></span> <?php _e( 'Calculating revision diffs' ); ?> 106 </div> 103 107 <h2 class="long-header"><?php echo $h2; ?></h2> 104 <div id="backbonerevisionsinteract"></div> 105 <div id="backbonerevisionsdiff"></div> 108 <div class="diff-slider-ticks-wrapper"> 109 <div id="diff-slider-ticks"> 110 </div> 111 </div> 112 <div id="backbonerevisionsinteract"> 113 </div> 114 <div id="backbonerevisionsdiff"> 115 </div> 106 116 <hr /> 107 117 </div> 108 118 </div> 109 119 110 120 <script id="tmpl-revision" type="text/html"> 121 <div id="diffsubheader" class="diff-left-hand-meta-row"> 122 <div id="diff_from_current_revision"> 123 <b><?php _e( 'Comparing from:' ); ?></b> <?php _e( 'the current version' ); ?> 124 </div> 125 <div id="difftitlefrom"><b><?php _e( 'Comparing from:' ); ?></b> <?php _e( 'revision by' ); ?> {{{ data.revision_from_date_author }}} </div> 126 </div> 127 111 128 <div id="diffsubheader"> 112 <span id="diff_from_current_revision"><?php _e( 'Current version' ); ?><?php _e( '- compared to -' ); ?></span> 113 <div id="difftitlefrom">{{{ data.revision_from_date_author }}} <?php _e( '- compared to -' ); ?></div> 114 <div id="difftitle">{{{ data.revision_date_author }}}</div> 115 <div id="diffcancel"><input class="button" onClick="document.location='<?php echo get_edit_post_link( $post->ID ); ?>'" type="submit" id="cancel" value="<?php esc_attr_e( 'Cancel' )?>" /></div> 116 <div id="diffrestore"><input class="button button-primary" onClick="document.location='{{{ data.restoreaction }}}'" type="submit" id="restore" value="<?php esc_attr_e( 'Restore revision ID' )?>" /></div> 117 <div id="comparetworevisions"><input type="checkbox" id="comparetwo" value="comparetwo" {{{ data.comparetwochecked }}} name="comparetwo"/> <label for="comparetwo"><?php esc_attr_e( 'Compare two revisions' ); ?></a></div> </div> 129 <div id="difftitle"> 130 <strong><?php _e( 'Comparing to:' ); ?></strong> <?php _e( 'revision by' ); ?> {{{ data.revision_date_author }}} 131 </div> 132 <div id="diffrestore"> 133 <input class="button button-primary" onClick="document.location='{{{ data.restoreaction }}}'" type="submit" id="restore" value="<?php esc_attr_e( 'Restore This Revision' )?>" /> 134 </div> 135 <div id="comparetworevisions"> 136 <input type="checkbox" id="comparetwo" value="comparetwo" {{{ data.comparetwochecked }}} name="comparetwo"/> 137 <label for="comparetwo"><?php esc_attr_e( 'Compare two revisions' ); ?></a></label> 138 </div> 139 </div> 140 118 141 <div id="removedandadded"> 119 142 <div id="removed"><?php _e( 'Removed -' ); ?></div> 120 143 <div id="added"><?php _e( 'Added +' ); ?></div> … … 124 147 125 148 <script id="tmpl-revisionvinteract" type="text/html"> 126 149 <div id="diffheader"> 127 <div id="diffprevious"><input class="button" type="submit" id="previous" value="<?php esc_attr_e( 'Previous' ); ?>" /></div> 128 <div id="diffnext"><input class="button" type="submit" id="next" value="<?php esc_attr_e( 'Next' ); ?>" /></div> 129 <div id="diffslider"> 130 <div id="revisioncount"> 131 <?php _e( 'Comparing' ); ?> 132 <span id="diff_left_count"> <?php _e( 'revision' ); ?></span> <span id="diff_left_count_inner"></span> 133 <span id="diff_left_current_revision"><?php _e( 'current version' ); ?></span> 134 <span id="diff_revision_from">{{{ data.diff_revision_from }}}</span> 135 <?php _e( ' to revision' ); ?> 136 <span id="diff_count">{{{ data.current_diff }}}</span> 137 <?php _e( ' of ' ); ?> 138 <span id="diff_max" ></span> 139 </div> 140 141 <div id="slider" class="wp-slider"></div> 150 <div id="diffprevious"><input class="button" type="submit" id="previous" value="<?php esc_attr_e( 'Previous' ); ?>" /> 142 151 </div> 152 <div id="diffnext"><input class="button" type="submit" id="next" value="<?php esc_attr_e( 'Next' ); ?>" /> 153 </div> 154 <div id="diffslider"> 155 <div id="slider" class="wp-slider"> 156 </div> 157 </div> 143 158 </div> 144 159 </script> 160 <script id="tmpl-revision-ticks" type="text/html"> 161 <div class="revision-tick revision-toload{{{ data.revision_toload }}} revision-scopeofchanges-{{{ data.scope_of_changes }}}"> 162 </div> 163 </script> 145 164 <?php 146 165 /* 147 166 TODO Convert these into screen options -
wp-admin/css/colors-fresh.css
175 175 .sidebar-name, 176 176 #nav-menu-header, 177 177 #nav-menu-footer, 178 .menu-item-handle, 179 .wp-slider .ui-slider-handle { 178 .menu-item-handle { 180 179 background: #f1f1f1; 181 180 background-image: -webkit-gradient(linear, left bottom, left top, from(#ececec), to(#f9f9f9)); 182 181 background-image: -webkit-linear-gradient(bottom, #ececec, #f9f9f9); … … 185 184 background-image: linear-gradient(to top, #ececec, #f9f9f9); 186 185 } 187 186 187 188 188 189 .widget .widget-top, 189 190 .postbox h3, 190 191 .stuffbox h3 { … … 1382 1383 background-color: #f7f7f7; 1383 1384 } 1384 1385 1386 .comparetwo#diffsubheader.diff-left-hand-meta-row { 1387 background-color: #fcfcfc; 1388 } 1389 1390 .revision-tick.revision-toloadtrue { 1391 background-color: #9999cc; 1392 background: url(../images/wpspin_light.gif) no-repeat; 1393 background-position: middle; 1394 background-size: 1px 10px; 1395 } 1396 1397 .revision-tick.revision-toloadfalse { 1398 background-color: #aaa; 1399 } 1400 1385 1401 #att-info { 1386 1402 background-color: #e4f2Fd; 1387 1403 } 1388 1404 1405 body .ui-tooltip { 1406 border-color: #d7d7d7; 1407 background-color: #fff; 1408 } 1409 1389 1410 /* jQuery UI Slider */ 1390 1411 .wp-slider.ui-slider { 1391 1412 border-color: #d7d7d7; … … 1393 1414 } 1394 1415 1395 1416 .wp-slider .ui-slider-handle { 1396 border-color: #d7d7d7;1417 border-color: none; 1397 1418 } 1398 1419 1420 .wp-slider .ui-slider-handle { 1421 /* Slider drag Triangle CSS */ 1422 background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAARCAMAAAAMs7fIAAAAA3NCSVQICAjb4U/gAAAA8FBMVEU2dZipwNBJl8VGmcX///+EpLlBgqpymrNFjru3ydNWiKs6eZzY4uuRrL08faPL3OZBjLSBqsCTssRHlMJEf59cj657o7xKl8OEqsE9gag2dJtEkb+ct8iZs8BHmMePq8BejKZAiK5llK5FjrlJl8c6dZdGl8avxdBJlcZ4nbc6ep6XrbpKgZ+Lqr5KmcdIkbqsws1Gk8E+f6c4dptaiadFirRKl8V8pblImcNIl8eGpruVscZCh7BMlsdIlcFImchEkbs9eJpCjbdGjbk8fJ84dp02dpo8gatMlsM2dps8faVAg61Ej71Ek75IksFIlcOaLCw7AAAAUHRSTlP/////AP///////////////////////////////////////////////////////////////////////////////////////////////////xB6m5UAAAAJcEhZcwAACxIAAAsSAdLdfvwAAAAUdEVYdENyZWF0aW9uIFRpbWUAMy85LzEzrdD8jAAAABx0RVh0U29mdHdhcmUAQWRvYmUgRmlyZXdvcmtzIENTNui8sowAAACaSURBVBiVVcxZD8FAGIXhjxzUVktQgqKmo7ZYhkgsiS1tQuj//zeomo736uS5OFSo2W6UXc/R5hxXW5foxDlXqUKZx0GFZpXynuM4kXhjgjgyJkGzQIjpvi9Fx1uQ0iQUh4GkR/Ini0CQ2IfQ24YC4X8T+Mn0zj8lO1IgnqZpzlxE0m4YhrFsKYJVn126UGV+W1wHf4LdpByuF0goFKI7tv/dAAAAAElFTkSuQmCC'); 1423 } 1424 1399 1425 .wp-slider .ui-slider-handle.ui-state-hover, 1400 1426 .wp-slider .ui-slider-handle.ui-state-focus { 1401 border-color: #aaa; 1427 border-color: none; 1428 outline: none; 1402 1429 } 1403 1430 1404 1431 .wp-slider .ui-slider-handle.ui-state-active { 1405 border-color: #aaa; 1406 background: #eee; 1407 background-image: -webkit-gradient(linear, left bottom, left top, from(#f9f9f9), to(#ececec)); 1408 background-image: -webkit-linear-gradient(bottom, #f9f9f9, #ececec); 1409 background-image: -moz-linear-gradient(bottom, #f9f9f9, #ececec); 1410 background-image: -o-linear-gradient(bottom, #f9f9f9, #ececec); 1411 background-image: linear-gradient(to top, #f9f9f9, #ececec); 1432 background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAARCAMAAAAMs7fIAAAAA3NCSVQICAjb4U/gAAAA51BMVEUgZpDkzc0yd6f///8mcqFJm8cjbZZzr80mg78lh8BDk8UngLl+s9AmfKk4hrGeweBaoMhNlMORwt4nd6Zdm8BAjMEnf7RYmsMkb50mhsFWlsYhZ5ImhbwocZg0f61Lk8E9i7twqNBgo8VSmMUofLBcm8o3faUpfK8mh8Aia5MgZpFMmcgpeapDmcJjo8sliMEmh70nhLkkcKAqgLF2sc8sc5ojbZsngrMkh8EnfKw1eaUjbpkkapImeKQgaJAohb0mh8MmhcMng7kkcKEpf68iZ48haJMmhb8kicEmc6MibJkia5UnhLsw1mWvAAAATXRSTlP/AP8A/////////////////////////////////////////////////////////////////////////////////////////////////9/iR18AAAAJcEhZcwAACxIAAAsSAdLdfvwAAAAUdEVYdENyZWF0aW9uIFRpbWUAMy85LzEzrdD8jAAAABx0RVh0U29mdHdhcmUAQWRvYmUgRmlyZXdvcmtzIENTNui8sowAAACaSURBVBiVVc15D8FAEIfh+Ymj6761LIrSiCNVVyjbRGgifP/PQ6q22/evyZPJDNXzD6G0qNDq5PtO3DJDFyfRpk+po2Eo0h5Qx9U0LRa3SejdlR2rDMLI41yKh6/AtOSzUiuU4kvemSMUDBsRXGuRIHj/CvCXyTNcSXelQBQYY1uBWMY651xfK4KzbdgzqJI73LK7hGC6r0bTB5apIhqIH/YIAAAAAElFTkSuQmCC'); 1412 1433 } 1413 1434 1414 1435 /* edit image */ -
wp-admin/css/wp-admin.css
3594 3594 margin: 2px; 3595 3595 } 3596 3596 3597 #diffrestore, 3598 #diffnext, 3599 #diffcancel { 3597 #diffnext { 3600 3598 float: right; 3601 3599 margin-right: 5px; 3602 3600 } 3603 3601 3602 #diffrestore input{ 3603 margin-left: 10px; 3604 } 3605 3604 3606 #diffprevious, 3605 3607 #difftitle, 3606 3608 #difftitlefrom, … … 3612 3614 3613 3615 #diffprevious, 3614 3616 #diffnext { 3615 margin-top: 7px;3616 3617 height: 30px; 3617 3618 } 3618 3619 … … 3624 3625 #diffheader { 3625 3626 border-bottom: 1px solid #dfdfdf; 3626 3627 width: 100%; 3627 height: 4 5px;3628 line-height: 4 5px;3629 padding-top: 10px;3628 height: 40px; 3629 line-height: 40px; 3630 padding-top: 30px; 3630 3631 } 3631 3632 3632 #diffsubheader {3633 #diffsubheader,.diff-left-hand-meta-row { 3633 3634 border-bottom: 1px solid #dfdfdf; 3634 3635 width: 100%; 3635 3636 height:35px; 3636 3637 line-height: 35px; 3638 display: block; 3637 3639 } 3638 3640 3639 #diffslider 3641 #diffslider{ 3640 3642 width: 70%; 3641 3643 margin-left: auto; 3642 3644 margin-right: auto; 3643 3645 text-align: center; 3644 height: 3.5em; 3646 height: 0.8em; 3647 margin-top: 20px; 3645 3648 } 3646 3649 3650 .diff-slider-ticks-wrapper { 3651 margin-left: auto; 3652 margin-right: auto; 3653 text-align: center; 3654 } 3655 3656 #diff-slider-ticks { 3657 position: absolute; 3658 margin-top: 50px; 3659 z-index: 1; 3660 } 3661 3647 3662 #revisioncount { 3648 3663 width: 50%; 3649 3664 margin-left: auto; … … 3711 3726 3712 3727 #comparetworevisions { 3713 3728 float: right; 3729 position: absolute; 3730 top: 10px; 3731 right: 10px; 3714 3732 line-height: 35px; 3715 3733 padding-right: 5px; 3716 3734 } … … 3746 3764 .comparetwo #diffprevious, 3747 3765 .comparetwo #diffnext, 3748 3766 span#diff_left_current_revision, 3749 span#diff_from_current_revision,3767 #diff_from_current_revision, 3750 3768 .currentversion span#diff_left_count, 3751 3769 .currentversion span#diff_left_count_inner, 3752 .c urrentversion #difftitlefrom,3753 .comparetwo.currentversion #difftitlefrom{3770 .comparetwo.currentversion #diff_from_current_revision, 3771 #diffsubheader.diff-left-hand-meta-row { 3754 3772 display: none; 3755 3773 } 3756 3774 … … 3758 3776 span#diff_left_count, 3759 3777 span#diff_left_count_inner, 3760 3778 .comparetwo #difftitlefrom, 3761 .comparetwo.currentversion span#diff_from_current_revision,3762 3779 .leftmodelloading #modelsloading, 3763 3780 .rightmodelloading #modelsloading, 3764 3781 .leftmodelloading #modelsloading .spinner, 3765 3782 .rightmodelloading #modelsloading .spinner, 3766 {3767 display: inline;3783 .comparetwo #diffsubheader.diff-left-hand-meta-row { 3784 display: block; 3768 3785 } 3769 3786 3787 .revision-tick { 3788 width: 1px; 3789 float: left; 3790 margin-right: 15px; 3791 height: 11px; 3792 padding: 0; 3793 margin-left: 0px; 3794 } 3795 3796 .revision-tick.revision-scopeofchanges-vsmall { 3797 width: 1px; 3798 background-color: #aaa; 3799 } 3800 3801 .revision-tick.revision-scopeofchanges-small { 3802 width: 2px; 3803 background-color: #aaa; 3804 margin-left: -1px; 3805 } 3806 3807 .revision-tick.revision-scopeofchanges-med { 3808 width: 3px; 3809 margin-left: -2px; 3810 background-color: #666; 3811 } 3812 3813 .revision-tick.revision-scopeofchanges-large { 3814 width: 4px; 3815 margin-left: -3px; 3816 background-color: #333; 3817 } 3818 3819 .revision-tick.revision-scopeofchanges-vlarge { 3820 margin-left: -3px; 3821 width: 4px; 3822 background-color: #111; 3823 } 3824 3770 3825 .diff-loading { 3771 3826 margin-top: 50px; 3772 3827 width: 100%; … … 3781 3836 float: none; 3782 3837 } 3783 3838 3784 #difftitlefrom {3785 float: left;3786 display: none;3787 }3788 3789 3839 #modelsloading { 3790 3840 float: right; 3841 position: absolute; 3791 3842 line-height: 30px; 3792 3843 display: none; 3793 3844 clear: none; 3794 margin: 0;3845 right: 170px; 3795 3846 margin-top: -40px; 3796 3847 } 3797 3848 3798 3849 #modelsloading .spinner { 3799 3850 float: left; 3800 3851 } 3801 3852 3853 .ui-tooltip-content img { 3854 float: left; 3855 margin-right: 5px; 3856 } 3857 /* jQuery UI Tooltip 1.10.1 */ 3858 3859 .ui-tooltip { 3860 padding: 8px; 3861 position: absolute; 3862 z-index: 9999; 3863 max-width: 300px; 3864 min-width: 130px; 3865 } 3866 3867 body .ui-tooltip { 3868 border-width: 1px; 3869 } 3870 3871 .ui-tooltip, .arrow:after { 3872 border: 1px solid #d7d7d7; 3873 } 3874 3875 .ui-tooltip { 3876 padding: 5px 10px; 3877 } 3878 3879 .arrow { 3880 width: 70px; 3881 height: 16px; 3882 overflow: hidden; 3883 position: absolute; 3884 left: 50%; 3885 margin-left: -35px; 3886 bottom: -16px; 3887 z-index: 99999; 3888 3889 } 3890 3891 .arrow.top { 3892 top: -16px; 3893 bottom: auto; 3894 } 3895 3896 .arrow.left { 3897 left: 20%; 3898 } 3899 3900 .arrow:after { 3901 content: ""; 3902 position: absolute; 3903 left: 20px; 3904 top: -20px; 3905 width: 25px; 3906 height: 25px; 3907 background-color: #FFF; 3908 -webkit-transform: rotate(45deg); 3909 -moz-transform: rotate(45deg); 3910 -ms-transform: rotate(45deg); 3911 -o-transform: rotate(45deg); 3912 tranform: rotate(45deg); 3913 } 3914 3915 .arrow.top:after { 3916 bottom: -20px; 3917 top: auto; 3918 } 3919 3802 3920 /* jQuery UI Slider */ 3803 3921 3804 3922 .wp-slider.ui-slider { … … 3813 3931 .wp-slider .ui-slider-handle { 3814 3932 position: absolute; 3815 3933 z-index: 2; 3816 width: 1.2em; 3817 height: 1.2em; 3818 border-width: 1px; 3819 border-style: solid; 3820 border-radius: 3px; 3934 width: 17px; 3935 height: 17px; 3936 border: none; 3821 3937 } 3822 3938 3823 3939 .wp-slider .ui-slider-range {