<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[24815] branches/3.6/wp-admin: Revisions: Combine our tooltip and from/to templates into one generic template</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/24815">24815</a></dd>
<dt>Author</dt> <dd>markjaquith</dd>
<dt>Date</dt> <dd>2013-07-28 20:22:17 +0000 (Sun, 28 Jul 2013)</dd>
</dl>
<h3>Log Message</h3>
<pre>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 3.6. See <a href="http://core.trac.wordpress.org/ticket/24804">#24804</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#branches36wpadminjsrevisionsjs">branches/3.6/wp-admin/js/revisions.js</a></li>
<li><a href="#branches36wpadminrevisionphp">branches/3.6/wp-admin/revision.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="branches36wpadminjsrevisionsjs"></a>
<div class="modfile"><h4>Modified: branches/3.6/wp-admin/js/revisions.js (24814 => 24815)</h4>
<pre class="diff"><span>
<span class="info">--- branches/3.6/wp-admin/js/revisions.js 2013-07-28 20:15:28 UTC (rev 24814)
+++ branches/3.6/wp-admin/js/revisions.js 2013-07-28 20:22:17 UTC (rev 24815)
</span><span class="lines">@@ -156,7 +156,7 @@
</span><span class="cx"> this.listenTo( this.slider, 'change:hovering', this.setHovering );
</span><span class="cx"> this.listenTo( this.slider, 'change:scrubbing', this.setScrubbing );
</span><span class="cx">
</span><del>- this.set({ revision: this.frame.diff() });
</del><ins>+ this.set({ revision: this.revisions.get( this.frame.get('to') ) });
</ins><span class="cx"> },
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -571,8 +571,8 @@
</span><span class="cx"> model: slider
</span><span class="cx"> }) );
</span><span class="cx">
</span><del>- // Add the Meta view
- this.views.add( new revisions.view.Meta({
</del><ins>+ // Add the Metabox view
+ this.views.add( new revisions.view.Metabox({
</ins><span class="cx"> model: this.model
</span><span class="cx"> }) );
</span><span class="cx"> },
</span><span class="lines">@@ -659,9 +659,26 @@
</span><span class="cx"> }
</span><span class="cx"> });
</span><span class="cx">
</span><del>- // The meta view
</del><ins>+ // The metabox view
+ revisions.view.Metabox = wp.Backbone.View.extend({
+ className: 'revisions-meta',
+
+ initialize: function() {
+ // Add the 'from' view
+ this.views.add( new revisions.view.MetaFrom({
+ model: this.model,
+ className: 'diff-meta diff-meta-from'
+ }) );
+
+ // Add the 'to' view
+ this.views.add( new revisions.view.MetaTo({
+ model: this.model
+ }) );
+ }
+ });
+
+ // The revision meta view (to be extended)
</ins><span class="cx"> revisions.view.Meta = wp.Backbone.View.extend({
</span><del>- className: 'revisions-meta',
</del><span class="cx"> template: wp.template('revisions-meta'),
</span><span class="cx">
</span><span class="cx"> events: {
</span><span class="lines">@@ -673,7 +690,9 @@
</span><span class="cx"> },
</span><span class="cx">
</span><span class="cx"> prepare: function() {
</span><del>- return this.model.toJSON();
</del><ins>+ return _.extend( this.model.toJSON()[this.type] || {}, {
+ type: this.type
+ });
</ins><span class="cx"> },
</span><span class="cx">
</span><span class="cx"> restoreRevision: function() {
</span><span class="lines">@@ -681,6 +700,18 @@
</span><span class="cx"> }
</span><span class="cx"> });
</span><span class="cx">
</span><ins>+ // The revision meta 'from' view
+ revisions.view.MetaFrom = revisions.view.Meta.extend({
+ className: 'diff-meta diff-meta-from',
+ type: 'from'
+ });
+
+ // The revision meta 'to' view
+ revisions.view.MetaTo = revisions.view.Meta.extend({
+ className: 'diff-meta diff-meta-to',
+ type: 'to'
+ });
+
</ins><span class="cx"> // The checkbox view.
</span><span class="cx"> revisions.view.Checkbox = wp.Backbone.View.extend({
</span><span class="cx"> className: 'revisions-checkbox',
</span><span class="lines">@@ -714,7 +745,7 @@
</span><span class="cx"> // Encapsulates the tooltip.
</span><span class="cx"> revisions.view.Tooltip = wp.Backbone.View.extend({
</span><span class="cx"> className: 'revisions-tooltip',
</span><del>- template: wp.template('revisions-tooltip'),
</del><ins>+ template: wp.template('revisions-meta'),
</ins><span class="cx">
</span><span class="cx"> initialize: function( options ) {
</span><span class="cx"> this.listenTo( this.model, 'change:offset', this.render );
</span><span class="lines">@@ -723,7 +754,9 @@
</span><span class="cx"> },
</span><span class="cx">
</span><span class="cx"> prepare: function() {
</span><del>- return this.model.get('revision').toJSON();
</del><ins>+ return _.extend( { type: 'tooltip' }, {
+ attributes: this.model.get('revision').toJSON()
+ });
</ins><span class="cx"> },
</span><span class="cx">
</span><span class="cx"> render: function() {
</span></span></pre></div>
<a id="branches36wpadminrevisionphp"></a>
<div class="modfile"><h4>Modified: branches/3.6/wp-admin/revision.php (24814 => 24815)</h4>
<pre class="diff"><span>
<span class="info">--- branches/3.6/wp-admin/revision.php 2013-07-28 20:15:28 UTC (rev 24814)
+++ branches/3.6/wp-admin/revision.php 2013-07-28 20:22:17 UTC (rev 24815)
</span><span class="lines">@@ -130,31 +130,6 @@
</span><span class="cx"> </div>
</span><span class="cx"> </script>
</span><span class="cx">
</span><del>-<script id="tmpl-revisions-tooltip" type="text/html">
- <div class="author-card">
- <# if ( 'undefined' !== typeof data && 'undefined' !== typeof data.author ) { #>
- <div class="author-card<# if ( data.autosave ) { #> autosave<# } #>">
- {{{ data.author.avatar }}}
- <div class="author-info">
- <# if ( data.autosave ) { #>
- <span class="byline"><?php printf( __( 'Autosave by %s' ),
- '<span class="author-name">{{ data.author.name }}</span>' ); ?></span>
- <# } else if ( data.current ) { #>
- <span class="byline"><?php printf( __( 'Current Revision by %s' ),
- '<span class="author-name">{{ data.author.name }}</span>' ); ?></span>
- <# } else { #>
- <span class="byline"><?php printf( __( 'Revision by %s' ),
- '<span class="author-name">{{ data.author.name }}</span>' ); ?></span>
- <# } #>
- <span class="time-ago">{{ data.timeAgo }}</span>
- <span class="date">({{ data.dateShort }})</span>
- </div>
- </div>
- <# } #>
- </div>
- <div class="revisions-tooltip-arrow"><span></span></div>
-</script>
-
</del><span class="cx"> <script id="tmpl-revisions-checkbox" type="text/html">
</span><span class="cx"> <div class="revision-toggle-compare-mode">
</span><span class="cx"> <label>
</span><span class="lines">@@ -171,65 +146,45 @@
</span><span class="cx"> </script>
</span><span class="cx">
</span><span class="cx"> <script id="tmpl-revisions-meta" type="text/html">
</span><del>- <div class="diff-meta diff-meta-from">
</del><ins>+ <# if ( ! _.isUndefined( data.attributes ) ) { #>
</ins><span class="cx"> <div class="diff-title">
</span><del>- <strong><?php _ex( 'From:', 'Followed by post revision info' ); ?></strong>
- <# if ( 'undefined' !== typeof data.from ) { #>
- <div class="author-card<# if ( data.from.attributes.autosave ) { #> autosave<# } #>">
- {{{ data.from.attributes.author.avatar }}}
</del><ins>+ <# if ( 'from' === data.type ) { #>
+ <strong><?php _ex( 'From:', 'Followed by post revision info' ); ?></strong>
+ <# } else if ( 'to' === data.type ) { #>
+ <strong><?php _ex( 'To:', 'Followed by post revision info' ); ?></strong>
+ <# } #>
+ <div class="author-card<# if ( data.attributes.autosave ) { #> autosave<# } #>">
+ {{{ data.attributes.author.avatar }}}
</ins><span class="cx"> <div class="author-info">
</span><del>- <# if ( data.from.attributes.autosave ) { #>
</del><ins>+ <# if ( data.attributes.autosave ) { #>
</ins><span class="cx"> <span class="byline"><?php printf( __( 'Autosave by %s' ),
</span><del>- '<span class="author-name">{{ data.from.attributes.author.name }}</span>' ); ?></span>
- <# } else if ( data.from.attributes.current ) { #>
</del><ins>+ '<span class="author-name">{{ data.attributes.author.name }}</span>' ); ?></span>
+ <# } else if ( data.attributes.current ) { #>
</ins><span class="cx"> <span class="byline"><?php printf( __( 'Current Revision by %s' ),
</span><del>- '<span class="author-name">{{ data.from.attributes.author.name }}</span>' ); ?></span>
</del><ins>+ '<span class="author-name">{{ data.attributes.author.name }}</span>' ); ?></span>
</ins><span class="cx"> <# } else { #>
</span><span class="cx"> <span class="byline"><?php printf( __( 'Revision by %s' ),
</span><del>- '<span class="author-name">{{ data.from.attributes.author.name }}</span>' ); ?></span>
</del><ins>+ '<span class="author-name">{{ data.attributes.author.name }}</span>' ); ?></span>
</ins><span class="cx"> <# } #>
</span><del>- <span class="time-ago">{{ data.from.attributes.timeAgo }}</span>
- <span class="date">({{ data.from.attributes.dateShort }})</span>
</del><ins>+ <span class="time-ago">{{ data.attributes.timeAgo }}</span>
+ <span class="date">({{ data.attributes.dateShort }})</span>
</ins><span class="cx"> </div>
</span><del>- </div>
- <# } #>
- </div>
- </div>
-
- <div class="diff-meta diff-meta-to">
- <div class="diff-title">
- <strong><?php _ex( 'To:', 'Followed by post revision info' ); ?></strong>
- <# if ( 'undefined' !== typeof data.to ) { #>
- <div class="author-card<# if ( data.to.attributes.autosave ) { #> autosave<# } #>">
- {{{ data.to.attributes.author.avatar }}}
- <div class="author-info">
- <# if ( data.to.attributes.autosave ) { #>
- <span class="byline"><?php printf( __( 'Autosave by %s' ),
- '<span class="author-name">{{ data.to.attributes.author.name }}</span>' ); ?></span>
- <# } else if ( data.to.attributes.current ) { #>
- <span class="byline"><?php printf( __( 'Current Revision by %s' ),
- '<span class="author-name">{{ data.to.attributes.author.name }}</span>' ); ?></span>
</del><ins>+ <# if ( 'to' === data.type && data.attributes.restoreUrl ) { #>
+ <input
+ <# if ( data.attributes.current ) { #>
+ disabled="disabled"
+ <# } #>
+ <# if ( data.attributes.autosave ) { #>
+ type="button" class="restore-revision button button-primary" value="<?php esc_attr_e( 'Restore This Autosave' ); ?>" />
</ins><span class="cx"> <# } else { #>
</span><del>- <span class="byline"><?php printf( __( 'Revision by %s' ),
- '<span class="author-name">{{ data.to.attributes.author.name }}</span>' ); ?></span>
</del><ins>+ type="button" class="restore-revision button button-primary" value="<?php esc_attr_e( 'Restore This Revision' ); ?>" />
</ins><span class="cx"> <# } #>
</span><del>- <span class="time-ago">{{ data.to.attributes.timeAgo }}</span>
- <span class="date">({{ data.to.attributes.dateShort }})</span>
- </div>
- <# } #>
- <# if ( data.to.attributes.restoreUrl ) { #>
- <input
- <# if ( data.to.attributes.current ) { #>
- disabled="disabled"
</del><span class="cx"> <# } #>
</span><del>- <# if ( data.to.attributes.autosave ) { #>
- type="button" class="restore-revision button button-primary" value="<?php esc_attr_e( 'Restore This Autosave' ); ?>" />
- <# } else { #>
- type="button" class="restore-revision button button-primary" value="<?php esc_attr_e( 'Restore This Revision' ); ?>" />
- <# } #>
- <# } #>
</del><span class="cx"> </div>
</span><del>- </div>
</del><ins>+ <# if ( 'tooltip' === data.type ) { #>
+ <div class="revisions-tooltip-arrow"><span></span></div>
+ <# } #>
+<# } #>
</ins><span class="cx"> </script>
</span><span class="cx">
</span><span class="cx"> <script id="tmpl-revisions-diff" type="text/html">
</span></span></pre>
</div>
</div>
</body>
</html>