<!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>[24595] trunk/wp-admin: Tick marks are back for revisions</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/24595">24595</a></dd>
<dt>Author</dt> <dd>markjaquith</dd>
<dt>Date</dt> <dd>2013-07-08 21:37:03 +0000 (Mon, 08 Jul 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>Tick marks are back for revisions

* Simple tick marks
* Tooltips snap to tick marks
* Tooltips arrow reverses side for LTR/RTL
* Fix for routing issue where just the hash is changed in the URL bar relating to compare two mode

see <a href="http://core.trac.wordpress.org/ticket/24425">#24425</a>. props adamsilverstein, ocean90.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadmincsscolorsfreshcss">trunk/wp-admin/css/colors-fresh.css</a></li>
<li><a href="#trunkwpadmincsswpadminrtlcss">trunk/wp-admin/css/wp-admin-rtl.css</a></li>
<li><a href="#trunkwpadmincsswpadmincss">trunk/wp-admin/css/wp-admin.css</a></li>
<li><a href="#trunkwpadminjsrevisionsjs">trunk/wp-admin/js/revisions.js</a></li>
<li><a href="#trunkwpadminrevisionphp">trunk/wp-admin/revision.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadmincsscolorsfreshcss"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/css/colors-fresh.css (24594 => 24595)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/css/colors-fresh.css      2013-07-08 20:27:06 UTC (rev 24594)
+++ trunk/wp-admin/css/colors-fresh.css 2013-07-08 21:37:03 UTC (rev 24595)
</span><span class="lines">@@ -1385,6 +1385,15 @@
</span><span class="cx">  background-color: #fff;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+
+.revisions-tickmarks {
+       background-color: #f7f7f7;
+}
+
+.revisions-tickmarks > div {
+       background-color: #ccc;
+}
+
</ins><span class="cx"> #diff-title-to strong {
</span><span class="cx">  color: #08a;
</span><span class="cx"> }
</span><span class="lines">@@ -1392,7 +1401,7 @@
</span><span class="cx"> /* jQuery UI Slider */
</span><span class="cx"> .wp-slider.ui-slider {
</span><span class="cx">  border-color: #d7d7d7;
</span><del>-       background: #f7f7f7;
</del><ins>+        background: transparent;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> .wp-slider .ui-slider-handle {
</span></span></pre></div>
<a id="trunkwpadmincsswpadminrtlcss"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/css/wp-admin-rtl.css (24594 => 24595)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/css/wp-admin-rtl.css      2013-07-08 20:27:06 UTC (rev 24594)
+++ trunk/wp-admin/css/wp-admin-rtl.css 2013-07-08 21:37:03 UTC (rev 24595)
</span><span class="lines">@@ -1019,12 +1019,20 @@
</span><span class="cx">  float: left;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-.ui-tooltip-content img {
</del><ins>+.revisions img {
</ins><span class="cx">   float: right;
</span><span class="cx">  margin-right: 0;
</span><span class="cx">  margin-left: 5px;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+.revisions-tooltip {
+       margin-left: -185px;
+}
+
+.revisions-tooltip-arrow {
+       margin-left: 150px;
+}
+
</ins><span class="cx"> /*------------------------------------------------------------------------------
</span><span class="cx">   11.3 - Featured Images
</span><span class="cx"> ------------------------------------------------------------------------------*/
</span></span></pre></div>
<a id="trunkwpadmincsswpadmincss"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/css/wp-admin.css (24594 => 24595)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/css/wp-admin.css  2013-07-08 20:27:06 UTC (rev 24594)
+++ trunk/wp-admin/css/wp-admin.css     2013-07-08 21:37:03 UTC (rev 24595)
</span><span class="lines">@@ -3505,6 +3505,22 @@
</span><span class="cx">  height: 100px;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+.revisions-tickmarks {
+       position: relative;
+       margin: 0 auto 0;
+       height: 0.8em;
+       z-index: 2;
+       top: 7px;
+}
+
+.revisions-tickmarks > div {
+       height: 0.8em;
+       width: 1px;
+       float: left;
+       position: relative;
+       z-index: 10002;
+}
+
</ins><span class="cx"> .comparing-two-revisions .revisions-controls {
</span><span class="cx">  height: 140px;
</span><span class="cx"> }
</span><span class="lines">@@ -3534,7 +3550,8 @@
</span><span class="cx"> 
</span><span class="cx"> .wp-slider {
</span><span class="cx">  width: 70%;
</span><del>-       margin: 6px auto 0;
</del><ins>+        margin: 0 auto 0;
+       top: -3px;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /* Revision meta box */
</span></span></pre></div>
<a id="trunkwpadminjsrevisionsjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/js/revisions.js (24594 => 24595)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/revisions.js   2013-07-08 20:27:06 UTC (rev 24594)
+++ trunk/wp-admin/js/revisions.js      2013-07-08 21:37:03 UTC (rev 24595)
</span><span class="lines">@@ -280,7 +280,10 @@
</span><span class="cx">          },
</span><span class="cx"> 
</span><span class="cx">          updateCompareTwoMode: function() {
</span><del>-                       this.$el.toggleClass( 'comparing-two-revisions' );
</del><ins>+                        if ( this.model.get( 'compareTwoMode' ) )
+                               this.$el.addClass( 'comparing-two-revisions' );
+                       else
+                               this.$el.removeClass( 'comparing-two-revisions' );
</ins><span class="cx">           }
</span><span class="cx">  });
</span><span class="cx"> 
</span><span class="lines">@@ -307,6 +310,11 @@
</span><span class="cx">                  });
</span><span class="cx">                  this.views.add( tooltip );
</span><span class="cx"> 
</span><ins>+                       // Add the Tickmarks view
+                       this.views.add( new revisions.view.Tickmarks({
+                               model: this.model
+                       }));
+
</ins><span class="cx">                   // Add the Slider view with a reference to the tooltip view
</span><span class="cx">                  this.views.add( new revisions.view.Slider({
</span><span class="cx">                          model: this.model,
</span><span class="lines">@@ -317,9 +325,42 @@
</span><span class="cx">                  this.views.add( new revisions.view.Meta({
</span><span class="cx">                          model: this.model
</span><span class="cx">                  }) );
</span><ins>+
</ins><span class="cx">           }
</span><span class="cx">  });
</span><span class="cx"> 
</span><ins>+       // The tickmarks view
+       // This contains the slider tickmarks.
+       revisions.view.Tickmarks = wp.Backbone.View.extend({
+               tagName: 'div',
+               className: 'revisions-tickmarks',
+               template: wp.template('revisions-tickmarks'),
+
+               numberOfTickmarksSet: function() {
+                       var tickCount = this.model.revisions.length - 1, // One tickmark per model
+                               sliderWidth = $( '.wp-slider' ).parent().width() * 0.7, // Width of slider is 70% of container (reset on resize)
+                               tickWidth = Math.floor( sliderWidth / tickCount ), // Divide width by # of tickmarks, round down
+                               newSiderWidth = ( ( tickWidth + 1 ) * tickCount ) + 1, // Calculate the actual width
+                               tickNumber;
+
+                       $( '.wp-slider' ).css( 'width', newSiderWidth ); // Reset the slider width to match the calculated tick size
+                       this.$el.css( 'width', newSiderWidth ); // Match the tickmark div width
+
+                       for ( tickNumber = 0; tickNumber <= tickCount; tickNumber++ ){
+                               this.$el.append( '<div style="left:' + ( tickWidth * tickNumber ) + 'px;"></div>' );
+                       }
+               },
+
+               ready: function() {
+                       var self = this;
+                       self.numberOfTickmarksSet();
+                       $( window ).on( 'resize', _.debounce( function() {
+                               self.$el.html( '' );
+                               self.numberOfTickmarksSet();
+                               }, 50 ) );
+               }
+       });
+
</ins><span class="cx">   // The meta view.
</span><span class="cx">  // This contains the revision meta, and the restore button.
</span><span class="cx">  revisions.view.Meta = wp.Backbone.View.extend({
</span><span class="lines">@@ -511,8 +552,8 @@
</span><span class="cx"> 
</span><span class="cx">          events: {
</span><span class="cx">                  'mousemove'  : 'mousemove',
</span><del>-                       'mouseenter' : 'mouseenter',
-                       'mouseleave' : 'mouseleave'
</del><ins>+                        'mouseleave' : 'mouseleave',
+                       'mouseenter' : 'mouseenter'
</ins><span class="cx">           },
</span><span class="cx"> 
</span><span class="cx">          initialize: function( options ) {
</span><span class="lines">@@ -559,35 +600,37 @@
</span><span class="cx">          },
</span><span class="cx"> 
</span><span class="cx">          mousemove: function( e ) {
</span><del>-                       var sliderLeft = Math.ceil( this.$el.offset().left ),
-                               sliderWidth = Math.ceil( this.$el.width() ) + 2,
-                               tickWidth = Math.ceil( ( sliderWidth ) / this.model.revisions.length ),
-                               actualX = e.clientX - sliderLeft,
-                               hoveringAt = Math.floor( actualX / tickWidth );
</del><ins>+                        var tickCount = this.model.revisions.length - 1, // One tickmark per model
+                               sliderLeft = Math.ceil( this.$el.offset().left ), // Left edge of slider
+                               sliderWidth = this.$el.width(), // Width of slider
+                               tickWidth = Math.floor( sliderWidth / tickCount ), // Calculated width of tickmark
+                               actualX = e.clientX - sliderLeft, // Offset of mouse position in slider
+                               currentModelIndex = Math.floor( ( actualX + tickWidth / 2 ) / tickWidth ), // Calculate the model index
+                               tooltipPosition = sliderLeft + 2 + currentModelIndex * tickWidth; // Stick tooltip to tickmark
</ins><span class="cx"> 
</span><span class="cx">                  // Reverse direction in RTL mode.
</span><span class="cx">                  if ( isRtl )
</span><del>-                               hoveringAt = this.model.revisions.length - hoveringAt - 1;
</del><ins>+                                currentModelIndex = this.model.revisions.length - currentModelIndex - 1;
</ins><span class="cx"> 
</span><del>-                       // Ensure sane value for hoveringAt.
-                       if ( hoveringAt < 0 )
-                               hoveringAt = 0;
-                       else if ( hoveringAt >= this.model.revisions.length )
-                               hoveringAt = this.model.revisions.length - 1;
</del><ins>+                        // Ensure sane value for currentModelIndex.
+                       if ( currentModelIndex < 0 )
+                               currentModelIndex = 0;
+                       else if ( currentModelIndex >= this.model.revisions.length )
+                               currentModelIndex = this.model.revisions.length - 1;
</ins><span class="cx"> 
</span><span class="cx">                  // Update the tooltip model
</span><del>-                       this.tooltip.model.set( 'revision', this.model.revisions.at( hoveringAt ) );
-                       this.tooltip.model.set( 'position', e.clientX );
</del><ins>+                        this.tooltip.model.set( 'revision', this.model.revisions.at( currentModelIndex ) );
+                       this.tooltip.model.set( 'position', tooltipPosition );
</ins><span class="cx">           },
</span><span class="cx"> 
</span><ins>+               mouseleave: function( e ) {
+                       this.tooltip.hide();
+               },
+
</ins><span class="cx">           mouseenter: function( e ) {
</span><span class="cx">                  this.tooltip.show();
</span><span class="cx">          },
</span><span class="cx"> 
</span><del>-               mouseleave: function( e ) {
-                       this.tooltip.hide();
-               },
-
</del><span class="cx">           updateSliderSettings: function() {
</span><span class="cx">                  if ( this.model.get( 'compareTwoMode' ) ) {
</span><span class="cx">                          var leftValue, rightValue;
</span></span></pre></div>
<a id="trunkwpadminrevisionphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/revision.php (24594 => 24595)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/revision.php      2013-07-08 20:27:06 UTC (rev 24594)
+++ trunk/wp-admin/revision.php 2013-07-08 21:37:03 UTC (rev 24595)
</span><span class="lines">@@ -152,6 +152,9 @@
</span><span class="cx">  </div>
</span><span class="cx"> </script>
</span><span class="cx"> 
</span><ins>+<script id="tmpl-revisions-tickmarks" type="text/html">
+</script>
+
</ins><span class="cx"> <script id="tmpl-revisions-meta" type="text/html">
</span><span class="cx">  <div id="diff-header">
</span><span class="cx">          <div id="diff-header-from" class="diff-header">
</span></span></pre>
</div>
</div>

</body>
</html>