Make WordPress Core


Ignore:
Timestamp:
07/28/2013 08:15:28 PM (12 years ago)
Author:
markjaquith
Message:

Revisions: Combine our tooltip and from/to templates into one generic template

We had three copies of essentially the same template. Now just one, with minor logic inside.

Also fixes a bug where tooltip.revision was being initially set to a diff instead of a revision.

For trunk. See #24804.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/revision.php

    r24790 r24814  
    129129        <input class="button" type="button" value="<?php echo esc_attr_x( 'Next', 'Button label for a next revision' ); ?>" />
    130130    </div>
    131 </script>
    132 
    133 <script id="tmpl-revisions-tooltip" type="text/html">
    134     <div class="author-card">
    135     <# if ( 'undefined' !== typeof data && 'undefined' !== typeof data.author ) { #>
    136             <div class="author-card<# if ( data.autosave ) { #> autosave<# } #>">
    137                 {{{ data.author.avatar }}}
    138                 <div class="author-info">
    139                 <# if ( data.autosave ) { #>
    140                     <span class="byline"><?php printf( __( 'Autosave by %s' ),
    141                         '<span class="author-name">{{ data.author.name }}</span>' ); ?></span>
    142                 <# } else if ( data.current ) { #>
    143                     <span class="byline"><?php printf( __( 'Current Revision by %s' ),
    144                         '<span class="author-name">{{ data.author.name }}</span>' ); ?></span>
    145                 <# } else { #>
    146                     <span class="byline"><?php printf( __( 'Revision by %s' ),
    147                         '<span class="author-name">{{ data.author.name }}</span>' ); ?></span>
    148                 <# } #>
    149                     <span class="time-ago">{{ data.timeAgo }}</span>
    150                     <span class="date">({{ data.dateShort }})</span>
    151                 </div>
    152             </div>
    153     <# } #>
    154     </div>
    155     <div class="revisions-tooltip-arrow"><span></span></div>
    156131</script>
    157132
     
    172147
    173148<script id="tmpl-revisions-meta" type="text/html">
    174     <div class="diff-meta diff-meta-from">
     149    <# if ( ! _.isUndefined( data.attributes ) ) { #>
    175150        <div class="diff-title">
    176             <strong><?php _ex( 'From:', 'Followed by post revision info' ); ?></strong>
    177         <# if ( 'undefined' !== typeof data.from ) { #>
    178             <div class="author-card<# if ( data.from.attributes.autosave ) { #> autosave<# } #>">
    179                 {{{ data.from.attributes.author.avatar }}}
     151            <# if ( 'from' === data.type ) { #>
     152                <strong><?php _ex( 'From:', 'Followed by post revision info' ); ?></strong>
     153            <# } else if ( 'to' === data.type ) { #>
     154                <strong><?php _ex( 'To:', 'Followed by post revision info' ); ?></strong>
     155            <# } #>
     156            <div class="author-card<# if ( data.attributes.autosave ) { #> autosave<# } #>">
     157                {{{ data.attributes.author.avatar }}}
    180158                <div class="author-info">
    181                 <# if ( data.from.attributes.autosave ) { #>
     159                <# if ( data.attributes.autosave ) { #>
    182160                    <span class="byline"><?php printf( __( 'Autosave by %s' ),
    183                         '<span class="author-name">{{ data.from.attributes.author.name }}</span>' ); ?></span>
    184                 <# } else if ( data.from.attributes.current ) { #>
     161                        '<span class="author-name">{{ data.attributes.author.name }}</span>' ); ?></span>
     162                <# } else if ( data.attributes.current ) { #>
    185163                    <span class="byline"><?php printf( __( 'Current Revision by %s' ),
    186                         '<span class="author-name">{{ data.from.attributes.author.name }}</span>' ); ?></span>
     164                        '<span class="author-name">{{ data.attributes.author.name }}</span>' ); ?></span>
    187165                <# } else { #>
    188166                    <span class="byline"><?php printf( __( 'Revision by %s' ),
    189                         '<span class="author-name">{{ data.from.attributes.author.name }}</span>' ); ?></span>
     167                        '<span class="author-name">{{ data.attributes.author.name }}</span>' ); ?></span>
    190168                <# } #>
    191                     <span class="time-ago">{{ data.from.attributes.timeAgo }}</span>
    192                     <span class="date">({{ data.from.attributes.dateShort }})</span>
     169                    <span class="time-ago">{{ data.attributes.timeAgo }}</span>
     170                    <span class="date">({{ data.attributes.dateShort }})</span>
    193171                </div>
    194             </div>
    195         <# } #>
     172            <# if ( 'to' === data.type && data.attributes.restoreUrl ) { #>
     173                <input
     174                <# if ( data.attributes.current ) { #>
     175                    disabled="disabled"
     176                <# } #>
     177                <# if ( data.attributes.autosave ) { #>
     178                    type="button" class="restore-revision button button-primary" value="<?php esc_attr_e( 'Restore This Autosave' ); ?>" />
     179                <# } else { #>
     180                    type="button" class="restore-revision button button-primary" value="<?php esc_attr_e( 'Restore This Revision' ); ?>" />
     181                <# } #>
     182            <# } #>
    196183        </div>
    197     </div>
    198 
    199     <div class="diff-meta diff-meta-to">
    200         <div class="diff-title">
    201             <strong><?php _ex( 'To:', 'Followed by post revision info' ); ?></strong>
    202         <# if ( 'undefined' !== typeof data.to ) { #>
    203             <div class="author-card<# if ( data.to.attributes.autosave ) { #> autosave<# } #>">
    204                 {{{ data.to.attributes.author.avatar }}}
    205                 <div class="author-info">
    206                 <# if ( data.to.attributes.autosave ) { #>
    207                     <span class="byline"><?php printf( __( 'Autosave by %s' ),
    208                         '<span class="author-name">{{ data.to.attributes.author.name }}</span>' ); ?></span>
    209                 <# } else if ( data.to.attributes.current ) { #>
    210                     <span class="byline"><?php printf( __( 'Current Revision by %s' ),
    211                         '<span class="author-name">{{ data.to.attributes.author.name }}</span>' ); ?></span>
    212                 <# } else { #>
    213                     <span class="byline"><?php printf( __( 'Revision by %s' ),
    214                         '<span class="author-name">{{ data.to.attributes.author.name }}</span>' ); ?></span>
    215                 <# } #>
    216                     <span class="time-ago">{{ data.to.attributes.timeAgo }}</span>
    217                     <span class="date">({{ data.to.attributes.dateShort }})</span>
    218                 </div>
    219         <# } #>
    220         <# if ( data.to.attributes.restoreUrl ) { #>
    221             <input
    222             <# if ( data.to.attributes.current ) { #>
    223                 disabled="disabled"
    224             <# } #>
    225             <# if ( data.to.attributes.autosave ) { #>
    226                 type="button" class="restore-revision button button-primary" value="<?php esc_attr_e( 'Restore This Autosave' ); ?>" />
    227             <# } else { #>
    228                 type="button" class="restore-revision button button-primary" value="<?php esc_attr_e( 'Restore This Revision' ); ?>" />
    229             <# } #>
    230         <# } #>
    231         </div>
    232     </div>
     184    <# if ( 'tooltip' === data.type ) { #>
     185        <div class="revisions-tooltip-arrow"><span></span></div>
     186    <# } #>
     187<# } #>
    233188</script>
    234189
Note: See TracChangeset for help on using the changeset viewer.