Revisions: Pinned controls, layout tweaks, copy tweaks, misc.
* When you scroll down the diff view, the controls will pin to the top. * The revisions meta view was cleaned up. Copy changes. * Loading indicator in the center of the screen (so it follows as you scroll). * Tooltips "flip" when you cross the center line, so that they don't hit the container edge and wrap for later revisions. * The "Restore" button's inactive state is handled on render, instead of after. * Make sure we always have a current revision, even if the timestamp doesn't work out on the most recent one. See #24804. Props markjaquith, nacin, ocean90, aaroncampbell. git-svn-id: http://core.svn.wordpress.org/trunk@24761 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
062928d842
commit
13c63d211a
|
@ -164,7 +164,7 @@ textarea.disabled {
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
#diff-header,
|
.revisions-meta,
|
||||||
.widget .widget-top,
|
.widget .widget-top,
|
||||||
.postbox h3,
|
.postbox h3,
|
||||||
.stuffbox h3,
|
.stuffbox h3,
|
||||||
|
@ -1481,24 +1481,32 @@ table.diff .diff-addedline ins {
|
||||||
background-color: #afa;
|
background-color: #afa;
|
||||||
}
|
}
|
||||||
|
|
||||||
#diff-header {
|
.revisions-meta {
|
||||||
border: 1px solid #d1e5ee;
|
border: 1px solid #d1e5ee;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.revisions-controls {
|
||||||
|
background: #fff;
|
||||||
|
background: -webkit-gradient(linear, left bottom, left top, color-stop(0%,rgba(255,255,255,1)), color-stop(30px,rgba(255,255,255,1)), color-stop(100%,rgba(255,255,255,1)));
|
||||||
|
background: -webkit-linear-gradient(bottom, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 30px, rgba(255,255,255,1) 100%);
|
||||||
|
background: -moz-linear-gradient(bottom, rgba(255,255,255,0) 0%,rgba(255,255,255,1) 30px, rgba(255,255,255,1) 100%);
|
||||||
|
background: -o-linear-gradient(bottom, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 30px, rgba(255,255,255,1) 100%);
|
||||||
|
background: linear-gradient(to top, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 30px, rgba(255,255,255,1) 100%);
|
||||||
|
}
|
||||||
|
|
||||||
.revisions-tooltip,
|
.revisions-tooltip,
|
||||||
.revisions-tooltip-arrow span {
|
.revisions-tooltip-arrow span {
|
||||||
border-color: #d1e5ee;
|
border-color: #d1e5ee;
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
#diff-title-to strong {
|
.revisions-tickmarks > div {
|
||||||
color: #08a;
|
border-color: #d1e5ee;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* jQuery UI Slider */
|
/* jQuery UI Slider */
|
||||||
.wp-slider.ui-slider {
|
.wp-slider.ui-slider {
|
||||||
border-color: #d1e5ee;
|
border-color: #d1e5ee;
|
||||||
background: #eff8ff;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.wp-slider .ui-slider-handle {
|
.wp-slider .ui-slider-handle {
|
||||||
|
@ -1507,7 +1515,6 @@ table.diff .diff-addedline ins {
|
||||||
}
|
}
|
||||||
|
|
||||||
.wp-slider .ui-slider-handle {
|
.wp-slider .ui-slider-handle {
|
||||||
border-color: #ccc;
|
|
||||||
border-color: #d0dfe9;
|
border-color: #d0dfe9;
|
||||||
background: #eff8ff;
|
background: #eff8ff;
|
||||||
background-image: -webkit-gradient(linear, left bottom, left top, from(#eff8ff), to(#fff));
|
background-image: -webkit-gradient(linear, left bottom, left top, from(#eff8ff), to(#fff));
|
||||||
|
|
|
@ -164,7 +164,7 @@ textarea.disabled {
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
#diff-header,
|
.revisions-meta,
|
||||||
.widget .widget-top,
|
.widget .widget-top,
|
||||||
.postbox h3,
|
.postbox h3,
|
||||||
.stuffbox h3,
|
.stuffbox h3,
|
||||||
|
@ -1375,10 +1375,19 @@ table.diff .diff-addedline ins {
|
||||||
background-color: #afa;
|
background-color: #afa;
|
||||||
}
|
}
|
||||||
|
|
||||||
#diff-header {
|
.revisions-meta {
|
||||||
border: 1px solid #dfdfdf;
|
border: 1px solid #dfdfdf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.revisions-controls {
|
||||||
|
background: #fff;
|
||||||
|
background: -webkit-gradient(linear, left bottom, left top, color-stop(0%,rgba(255,255,255,1)), color-stop(30px,rgba(255,255,255,1)), color-stop(100%,rgba(255,255,255,1)));
|
||||||
|
background: -webkit-linear-gradient(bottom, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 30px, rgba(255,255,255,1) 100%);
|
||||||
|
background: -moz-linear-gradient(bottom, rgba(255,255,255,0) 0%,rgba(255,255,255,1) 30px, rgba(255,255,255,1) 100%);
|
||||||
|
background: -o-linear-gradient(bottom, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 30px, rgba(255,255,255,1) 100%);
|
||||||
|
background: linear-gradient(to top, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 30px, rgba(255,255,255,1) 100%);
|
||||||
|
}
|
||||||
|
|
||||||
.revisions-tooltip,
|
.revisions-tooltip,
|
||||||
.revisions-tooltip-arrow span {
|
.revisions-tooltip-arrow span {
|
||||||
border-color: #d7d7d7;
|
border-color: #d7d7d7;
|
||||||
|
@ -1389,14 +1398,9 @@ table.diff .diff-addedline ins {
|
||||||
border-color: #aaa;
|
border-color: #aaa;
|
||||||
}
|
}
|
||||||
|
|
||||||
#diff-title-to strong {
|
|
||||||
color: #08a;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* jQuery UI Slider */
|
/* jQuery UI Slider */
|
||||||
.wp-slider.ui-slider {
|
.wp-slider.ui-slider {
|
||||||
border-color: #d7d7d7;
|
border-color: #d7d7d7;
|
||||||
background: transparent;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.wp-slider .ui-slider-handle {
|
.wp-slider .ui-slider-handle {
|
||||||
|
|
|
@ -976,6 +976,14 @@ th.sorted a span {
|
||||||
padding: 9px 0 0 9px;
|
padding: 9px 0 0 9px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.revisions .loading-indicator {
|
||||||
|
margin-right: -90px;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.folded .revisions .loading-indicator {
|
||||||
|
margin-right: -32px;
|
||||||
|
}
|
||||||
|
|
||||||
.revisions-next {
|
.revisions-next {
|
||||||
float: left;
|
float: left;
|
||||||
}
|
}
|
||||||
|
@ -984,10 +992,6 @@ th.sorted a span {
|
||||||
float: right;
|
float: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
#diff-header {
|
|
||||||
padding: 5px 5px 5px 200px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.diff-title {
|
.diff-title {
|
||||||
float: right;
|
float: right;
|
||||||
}
|
}
|
||||||
|
@ -1004,7 +1008,7 @@ th.sorted a span {
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.diff-header > input.restore-revision {
|
.diff-meta > input.restore-revision {
|
||||||
margin-left: 0;
|
margin-left: 0;
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
}
|
}
|
||||||
|
@ -1027,11 +1031,11 @@ th.sorted a span {
|
||||||
.revisions-tooltip {
|
.revisions-tooltip {
|
||||||
margin-left: 0;
|
margin-left: 0;
|
||||||
margin-right: -70px;
|
margin-right: -70px;
|
||||||
-webkit-transition: right 15ms;
|
}
|
||||||
-moz-transition: right 15ms;
|
|
||||||
-ms-transition: right 15ms;
|
.revisions-tooltip.flipped {
|
||||||
-o-transition: right 15ms;
|
margin-right: 0;
|
||||||
transition: right 15ms;
|
margin-left: -70px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ie8 .revisions-tooltip {
|
.ie8 .revisions-tooltip {
|
||||||
|
@ -1044,10 +1048,22 @@ th.sorted a span {
|
||||||
margin-right: 35px;
|
margin-right: 35px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.revisions-tooltip.flipped .revisions-tooltip-arrow {
|
||||||
|
margin-right: 0;
|
||||||
|
margin-left: 35px;
|
||||||
|
right: auto;
|
||||||
|
left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.revisions-tooltip-arrow > span {
|
.revisions-tooltip-arrow > span {
|
||||||
right: 20px;
|
right: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.revisions-tooltip.flipped .revisions-tooltip-arrow > span {
|
||||||
|
right: auto;
|
||||||
|
left: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
.revisions-tooltip img {
|
.revisions-tooltip img {
|
||||||
float: right;
|
float: right;
|
||||||
margin: 2px 0 0 5px;
|
margin: 2px 0 0 5px;
|
||||||
|
|
|
@ -3519,6 +3519,7 @@ td.plugin-title p {
|
||||||
.revisions-controls {
|
.revisions-controls {
|
||||||
padding-top: 40px;
|
padding-top: 40px;
|
||||||
height: 100px;
|
height: 100px;
|
||||||
|
z-index: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.revisions-controls input[type="checkbox"] {
|
.revisions-controls input[type="checkbox"] {
|
||||||
|
@ -3527,6 +3528,12 @@ td.plugin-title p {
|
||||||
vertical-align: text-bottom;
|
vertical-align: text-bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.revisions.pinned .revisions-controls {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
padding-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
.revisions-tickmarks {
|
.revisions-tickmarks {
|
||||||
position: relative;
|
position: relative;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
|
@ -3571,11 +3578,12 @@ td.plugin-title p {
|
||||||
}
|
}
|
||||||
|
|
||||||
.revisions .loading-indicator {
|
.revisions .loading-indicator {
|
||||||
position: absolute;
|
position: fixed;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
top: 3em;
|
top: 50%;
|
||||||
|
margin-left: -90px;
|
||||||
-webkit-transition: opacity 0.5s;
|
-webkit-transition: opacity 0.5s;
|
||||||
-moz-transition: opacity 0.5s;
|
-moz-transition: opacity 0.5s;
|
||||||
-ms-transition: opacity 0.5s;
|
-ms-transition: opacity 0.5s;
|
||||||
|
@ -3584,6 +3592,10 @@ td.plugin-title p {
|
||||||
filter: alpha(opacity=0); /* ie8 and earlier */
|
filter: alpha(opacity=0); /* ie8 and earlier */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
body.folded .revisions .loading-indicator {
|
||||||
|
margin-left: -32px;
|
||||||
|
}
|
||||||
|
|
||||||
.revisions .loading-indicator span.spinner {
|
.revisions .loading-indicator span.spinner {
|
||||||
display: block;
|
display: block;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
|
@ -3623,10 +3635,22 @@ td.plugin-title p {
|
||||||
}
|
}
|
||||||
|
|
||||||
.comparing-two-revisions .revisions-previous,
|
.comparing-two-revisions .revisions-previous,
|
||||||
.comparing-two-revisions .revisions-next {
|
.comparing-two-revisions .revisions-next,
|
||||||
|
.revisions-meta .diff-meta-to strong {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.revisions-controls .author-card .date {
|
||||||
|
color: #777;
|
||||||
|
}
|
||||||
|
.revisions-controls .author-card .author-name {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.comparing-two-revisions .diff-meta-to strong {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
.revisions-previous,
|
.revisions-previous,
|
||||||
.revisions-next {
|
.revisions-next {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
@ -3689,49 +3713,50 @@ table.diff .diff-addedline ins {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
#diff-title-to strong {
|
.diff-meta {
|
||||||
display: inline;
|
|
||||||
}
|
|
||||||
|
|
||||||
#diff-header {
|
|
||||||
-webkit-border-radius: 3px;
|
-webkit-border-radius: 3px;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
clear: both;
|
clear: both;
|
||||||
}
|
min-height: 32px;
|
||||||
|
|
||||||
.diff-header {
|
|
||||||
min-height: 35px;
|
|
||||||
line-height: 35px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.diff-title {
|
|
||||||
float: left;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.diff-title strong {
|
.diff-title strong {
|
||||||
font-size: 14px;
|
line-height: 32px;
|
||||||
width: 60px;
|
min-width: 60px;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
float: left;
|
float: left;
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.diff-title img {
|
.revisions-controls .author-card .avatar,
|
||||||
|
.revisions-controls .author-card .author-info {
|
||||||
|
float: left;
|
||||||
|
margin-left: 6px;
|
||||||
|
margin-right: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.revisions-controls .author-card .byline {
|
||||||
|
display: block;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.revisions-controls .author-card .avatar {
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
margin-left: 5px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.diff-header > input.restore-revision {
|
.diff-meta input.restore-revision {
|
||||||
margin-left: 10px;
|
float: right;
|
||||||
|
margin-left: 6px;
|
||||||
|
margin-right: 6px;
|
||||||
|
margin-top: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#diff-header-from {
|
.diff-meta-from {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.comparing-two-revisions #diff-title-from,
|
.comparing-two-revisions .diff-meta-from {
|
||||||
.comparing-two-revisions #diff-header-from {
|
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3740,31 +3765,27 @@ table.diff .diff-addedline ins {
|
||||||
bottom: 105px;
|
bottom: 105px;
|
||||||
margin-right: 0;
|
margin-right: 0;
|
||||||
margin-left: -70px;
|
margin-left: -70px;
|
||||||
line-height: 28px;
|
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
max-width: 350px;
|
max-width: 350px;
|
||||||
min-width: 130px;
|
min-width: 130px;
|
||||||
padding: 4px;
|
padding: 8px 4px;
|
||||||
display: none;
|
display: none;
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
-webkit-transition: left 15ms;
|
}
|
||||||
-moz-transition: left 15ms;
|
|
||||||
-ms-transition: left 15ms;
|
.revisions-tooltip.flipped {
|
||||||
-o-transition: left 15ms;
|
margin-left: 0;
|
||||||
transition: left 15ms;
|
margin-right: -70px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.revisions.pinned .revisions-tooltip {
|
||||||
|
display: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.comparing-two-revisions .revisions-tooltip {
|
.comparing-two-revisions .revisions-tooltip {
|
||||||
bottom: 145px;
|
bottom: 145px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.revisions-tooltip img {
|
|
||||||
float: left;
|
|
||||||
margin: 2px 5px 0 0;
|
|
||||||
padding: 0;
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
|
|
||||||
.revisions-tooltip-arrow {
|
.revisions-tooltip-arrow {
|
||||||
width: 70px;
|
width: 70px;
|
||||||
height: 15px;
|
height: 15px;
|
||||||
|
@ -3776,6 +3797,13 @@ table.diff .diff-addedline ins {
|
||||||
z-index: 10000;
|
z-index: 10000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.revisions-tooltip.flipped .revisions-tooltip-arrow {
|
||||||
|
margin-left: 0;
|
||||||
|
margin-right: 35px;
|
||||||
|
left: auto;
|
||||||
|
right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.revisions-tooltip-arrow > span {
|
.revisions-tooltip-arrow > span {
|
||||||
content: "";
|
content: "";
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
@ -3790,10 +3818,15 @@ table.diff .diff-addedline ins {
|
||||||
tranform: rotate(45deg);
|
tranform: rotate(45deg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.revisions-tooltip.flipped .revisions-tooltip-arrow > span {
|
||||||
|
left: auto;
|
||||||
|
right: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
.ie8 .revisions-tooltip-arrow > span {
|
.ie8 .revisions-tooltip-arrow > span {
|
||||||
left: 14px;
|
left: 14px;
|
||||||
top: -25px;
|
top: -25px;
|
||||||
-ms-filter: "progid:DXImageTransform.Microsoft.Matrix(SizingMethod='auto expand', M11=0.7071067811865476, M12=-0.7071067811865475, M21=0.7071067811865475, M22=0.7071067811865476)"; /* IE8 */
|
-ms-filter: "progid:DXImageTransform.Microsoft.Matrix(SizingMethod='auto expand', M11=0.7071067811865476, M12=-0.7071067811865475, M21=0.7071067811865475, M22=0.7071067811865476)";
|
||||||
}
|
}
|
||||||
|
|
||||||
.revisions-tooltip,
|
.revisions-tooltip,
|
||||||
|
|
|
@ -99,19 +99,19 @@ function wp_prepare_revisions_for_js( $post, $selected_revision_id, $from = null
|
||||||
foreach ( $revisions as $revision ) {
|
foreach ( $revisions as $revision ) {
|
||||||
$modified = strtotime( $revision->post_modified );
|
$modified = strtotime( $revision->post_modified );
|
||||||
$modified_gmt = strtotime( $revision->post_modified_gmt );
|
$modified_gmt = strtotime( $revision->post_modified_gmt );
|
||||||
$restore_link = wp_nonce_url(
|
$restore_link = str_replace( '&', '&', wp_nonce_url(
|
||||||
add_query_arg(
|
add_query_arg(
|
||||||
array( 'revision' => $revision->ID,
|
array( 'revision' => $revision->ID,
|
||||||
'action' => 'restore' ),
|
'action' => 'restore' ),
|
||||||
admin_url( 'revision.php' )
|
admin_url( 'revision.php' )
|
||||||
),
|
),
|
||||||
"restore-post_{$revision->ID}"
|
"restore-post_{$revision->ID}"
|
||||||
);
|
) );
|
||||||
|
|
||||||
if ( ! isset( $authors[ $revision->post_author ] ) ) {
|
if ( ! isset( $authors[ $revision->post_author ] ) ) {
|
||||||
$authors[ $revision->post_author ] = array(
|
$authors[ $revision->post_author ] = array(
|
||||||
'id' => (int) $revision->post_author,
|
'id' => (int) $revision->post_author,
|
||||||
'avatar' => $show_avatars ? get_avatar( $revision->post_author, 24 ) : '',
|
'avatar' => $show_avatars ? get_avatar( $revision->post_author, 32 ) : '',
|
||||||
'name' => get_the_author_meta( 'display_name', $revision->post_author ),
|
'name' => get_the_author_meta( 'display_name', $revision->post_author ),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -142,6 +142,11 @@ function wp_prepare_revisions_for_js( $post, $selected_revision_id, $from = null
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If a post has been saved since the last revision (no revisioned fields were changed)
|
||||||
|
// we may not have a "current" revision. Mark the latest revision as "current".
|
||||||
|
if ( empty( $current_id ) )
|
||||||
|
$revisions[ $revision->ID ]['current'] = true;
|
||||||
|
|
||||||
// Now, grab the initial diff
|
// Now, grab the initial diff
|
||||||
$compare_two_mode = is_numeric( $from );
|
$compare_two_mode = is_numeric( $from );
|
||||||
if ( ! $compare_two_mode ) {
|
if ( ! $compare_two_mode ) {
|
||||||
|
|
|
@ -531,6 +531,8 @@ window.wp = window.wp || {};
|
||||||
className: 'revisions-controls',
|
className: 'revisions-controls',
|
||||||
|
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
|
_.bindAll( this, 'setWidth' );
|
||||||
|
|
||||||
// Add the button view
|
// Add the button view
|
||||||
this.views.add( new revisions.view.Buttons({
|
this.views.add( new revisions.view.Buttons({
|
||||||
model: this.model
|
model: this.model
|
||||||
|
@ -573,7 +575,40 @@ window.wp = window.wp || {};
|
||||||
this.views.add( new revisions.view.Meta({
|
this.views.add( new revisions.view.Meta({
|
||||||
model: this.model
|
model: this.model
|
||||||
}) );
|
}) );
|
||||||
|
},
|
||||||
|
|
||||||
|
ready: function() {
|
||||||
|
this.top = this.$el.offset().top;
|
||||||
|
this.window = $(window);
|
||||||
|
this.window.on( 'scroll.wp.revisions', {controls: this}, function(e) {
|
||||||
|
var controls = e.data.controls;
|
||||||
|
var container = controls.$el.parent();
|
||||||
|
var scrolled = controls.window.scrollTop();
|
||||||
|
var frame = controls.views.parent;
|
||||||
|
|
||||||
|
if ( scrolled >= controls.top ) {
|
||||||
|
if ( ! frame.$el.hasClass('pinned') ) {
|
||||||
|
controls.setWidth();
|
||||||
|
container.css('height', container.height() + 'px' );
|
||||||
|
controls.window.on('resize.wp.revisions.pinning click.wp.revisions.pinning', {controls: controls}, function(e) {
|
||||||
|
e.data.controls.setWidth();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
frame.$el.addClass('pinned');
|
||||||
|
} else if ( frame.$el.hasClass('pinned') ) {
|
||||||
|
controls.window.off('.wp.revisions.pinning');
|
||||||
|
controls.$el.css('width', 'auto');
|
||||||
|
frame.$el.removeClass('pinned');
|
||||||
|
container.css('height', 'auto');
|
||||||
|
controls.top = controls.$el.offset().top;
|
||||||
|
} else {
|
||||||
|
controls.top = controls.$el.offset().top;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
setWidth: function() {
|
||||||
|
this.$el.css('width', this.$el.parent().width() + 'px');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -592,15 +627,18 @@ window.wp = window.wp || {};
|
||||||
tick = this.$('div:nth-of-type(' + index + ')');
|
tick = this.$('div:nth-of-type(' + index + ')');
|
||||||
offset = tick.allPositions();
|
offset = tick.allPositions();
|
||||||
elWidth = tick.outerWidth();
|
elWidth = tick.outerWidth();
|
||||||
// adjust
|
|
||||||
_.extend( offset, {
|
_.extend( offset, {
|
||||||
right: offset.right + elWidth + 1,
|
rightPlusWidth: offset.right,
|
||||||
left: offset.left + elWidth + 1
|
leftPlusWidth: offset.left
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// Normal tick
|
// Normal tick
|
||||||
tick = this.$('div:nth-of-type(' + (index + 1) + ')');
|
tick = this.$('div:nth-of-type(' + (index + 1) + ')');
|
||||||
offset = tick.allPositions();
|
offset = tick.allPositions();
|
||||||
|
_.extend( offset, {
|
||||||
|
leftPlusWidth: offset.left + tick.outerWidth() + 1,
|
||||||
|
rightPlusWidth: offset.right + tick.outerWidth() + 1
|
||||||
|
});
|
||||||
}
|
}
|
||||||
this.model.set({ offset: offset });
|
this.model.set({ offset: offset });
|
||||||
},
|
},
|
||||||
|
@ -626,20 +664,15 @@ window.wp = window.wp || {};
|
||||||
},
|
},
|
||||||
|
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
this.listenTo( this.model, 'update:revisions', this.ready );
|
this.listenTo( this.model, 'update:revisions', this.render );
|
||||||
},
|
},
|
||||||
|
|
||||||
prepare: function() {
|
prepare: function() {
|
||||||
return this.model.toJSON();
|
return this.model.toJSON();
|
||||||
},
|
},
|
||||||
|
|
||||||
ready: function() {
|
|
||||||
this.$('.restore-revision').prop( 'disabled', this.model.get('to').get('current') );
|
|
||||||
},
|
|
||||||
|
|
||||||
restoreRevision: function() {
|
restoreRevision: function() {
|
||||||
var restoreUrl = this.model.get('to').attributes.restoreUrl.replace(/&/g, '&');
|
document.location = this.model.get('to').attributes.restoreUrl;
|
||||||
document.location = restoreUrl;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -677,7 +710,6 @@ window.wp = window.wp || {};
|
||||||
revisions.view.Tooltip = wp.Backbone.View.extend({
|
revisions.view.Tooltip = wp.Backbone.View.extend({
|
||||||
className: 'revisions-tooltip',
|
className: 'revisions-tooltip',
|
||||||
template: wp.template('revisions-tooltip'),
|
template: wp.template('revisions-tooltip'),
|
||||||
direction: isRtl ? 'right' : 'left',
|
|
||||||
|
|
||||||
initialize: function( options ) {
|
initialize: function( options ) {
|
||||||
this.listenTo( this.model, 'change:offset', this.render );
|
this.listenTo( this.model, 'change:offset', this.render );
|
||||||
|
@ -690,10 +722,20 @@ window.wp = window.wp || {};
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
var css = {};
|
var direction, directionVal, flipped, css = {}, position = this.model.revisions.indexOf( this.model.get('revision') ) + 1;
|
||||||
|
flipped = ( position / this.model.revisions.length ) > 0.5;
|
||||||
|
if ( isRtl ) {
|
||||||
|
direction = flipped ? 'left' : 'right';
|
||||||
|
directionVal = flipped ? 'leftPlusWidth' : direction;
|
||||||
|
} else {
|
||||||
|
direction = flipped ? 'right' : 'left';
|
||||||
|
directionVal = flipped ? 'rightPlusWidth' : direction;
|
||||||
|
}
|
||||||
|
otherDirection = 'right' === direction ? 'left': 'right';
|
||||||
wp.Backbone.View.prototype.render.apply( this, arguments );
|
wp.Backbone.View.prototype.render.apply( this, arguments );
|
||||||
css[this.direction] = this.model.get('offset')[this.direction] + 'px';
|
css[direction] = this.model.get('offset')[directionVal] + 'px';
|
||||||
this.$el.css( css );
|
css[otherDirection] = '';
|
||||||
|
this.$el.toggleClass( 'flipped', flipped ).css( css );
|
||||||
},
|
},
|
||||||
|
|
||||||
visible: function() {
|
visible: function() {
|
||||||
|
@ -716,8 +758,8 @@ window.wp = window.wp || {};
|
||||||
template: wp.template('revisions-buttons'),
|
template: wp.template('revisions-buttons'),
|
||||||
|
|
||||||
events: {
|
events: {
|
||||||
'click #next': 'nextRevision',
|
'click .revisions-next .button': 'nextRevision',
|
||||||
'click #previous': 'previousRevision'
|
'click .revisions-previous .button': 'previousRevision'
|
||||||
},
|
},
|
||||||
|
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
|
|
|
@ -122,20 +122,23 @@ require_once( './admin-header.php' );
|
||||||
|
|
||||||
<script id="tmpl-revisions-buttons" type="text/html">
|
<script id="tmpl-revisions-buttons" type="text/html">
|
||||||
<div class="revisions-previous">
|
<div class="revisions-previous">
|
||||||
<input class="button" type="button" id="previous" value="<?php echo esc_attr_x( 'Previous', 'Button label for a previous revision' ); ?>" />
|
<input class="button" type="button" value="<?php echo esc_attr_x( 'Previous', 'Button label for a previous revision' ); ?>" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="revisions-next">
|
<div class="revisions-next">
|
||||||
<input class="button" type="button" id="next" value="<?php echo esc_attr_x( 'Next', 'Button label for a next revision' ); ?>" />
|
<input class="button" type="button" value="<?php echo esc_attr_x( 'Next', 'Button label for a next revision' ); ?>" />
|
||||||
</div>
|
</div>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script id="tmpl-revisions-tooltip" type="text/html">
|
<script id="tmpl-revisions-tooltip" type="text/html">
|
||||||
<div class="revisions-tooltip-content">
|
<div class="author-card">
|
||||||
<# if ( 'undefined' !== typeof data && 'undefined' !== typeof data.author ) { #>
|
<# if ( 'undefined' !== typeof data && 'undefined' !== typeof data.author ) { #>
|
||||||
{{{ data.author.avatar }}} {{ data.author.name }},
|
{{{ data.author.avatar }}}
|
||||||
{{ data.timeAgo }}
|
<div class="author-info">
|
||||||
({{ data.dateShort }})
|
<span class="byline">Edit by <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>
|
<div class="revisions-tooltip-arrow"><span></span></div>
|
||||||
|
@ -157,30 +160,41 @@ require_once( './admin-header.php' );
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script id="tmpl-revisions-meta" type="text/html">
|
<script id="tmpl-revisions-meta" type="text/html">
|
||||||
<div id="diff-header">
|
<div class="diff-meta diff-meta-from">
|
||||||
<div id="diff-header-from" class="diff-header">
|
<div class="diff-title">
|
||||||
<div id="diff-title-from" class="diff-title">
|
<strong><?php _ex( 'From:', 'Followed by post revision info' ); ?></strong>
|
||||||
<strong><?php _ex( 'From:', 'Followed by post revision info' ); ?></strong>
|
<# if ( 'undefined' !== typeof data.from ) { #>
|
||||||
<# if ( 'undefined' !== typeof data.from ) { #>
|
<div class="author-card">
|
||||||
{{{ data.from.attributes.author.avatar }}} {{ data.from.attributes.author.name }},
|
{{{ data.from.attributes.author.avatar }}}
|
||||||
{{ data.from.attributes.timeAgo }}
|
<div class="author-info">
|
||||||
({{ data.from.attributes.dateShort }})
|
<span class="byline"><?php printf( __( 'Revision by %s' ),
|
||||||
<# } #>
|
'<span class="author-name">{{ data.to.attributes.author.name }}</span>' ); ?></span>
|
||||||
|
<span class="time-ago">{{ data.from.attributes.timeAgo }}</span>
|
||||||
|
<span class="date">({{ data.from.attributes.dateShort }})</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="clear"></div>
|
<# } #>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div id="diff-header-to" class="diff-header">
|
<div class="diff-meta diff-meta-to">
|
||||||
<div id="diff-title-to" class="diff-title">
|
<div class="diff-title">
|
||||||
<strong><?php _ex( 'To:', 'Followed by post revision info' ); ?></strong>
|
<strong><?php _ex( 'To:', 'Followed by post revision info' ); ?></strong>
|
||||||
<# if ( 'undefined' !== typeof data.to ) { #>
|
<# if ( 'undefined' !== typeof data.to ) { #>
|
||||||
{{{ data.to.attributes.author.avatar }}} {{ data.to.attributes.author.name }},
|
<div class="author-card">
|
||||||
{{ data.to.attributes.timeAgo }}
|
{{{ data.to.attributes.author.avatar }}}
|
||||||
({{ data.to.attributes.dateShort }})
|
<div class="author-info">
|
||||||
<# } #>
|
<span class="byline"><?php printf( __( 'Revision by %s' ),
|
||||||
</div>
|
'<span class="author-name">{{ data.to.attributes.author.name }}</span>' ); ?></span>
|
||||||
|
<span class="time-ago">{{ data.to.attributes.timeAgo }}</span>
|
||||||
<input type="button" class="restore-revision button button-primary" data-restore-link="{{{ data.restoreLink }}}" value="<?php esc_attr_e( 'Restore This Revision' )?>" />
|
<span class="date">({{ data.to.attributes.dateShort }})</span>
|
||||||
|
</div>
|
||||||
|
<# } #>
|
||||||
|
<input
|
||||||
|
<# if ( data.to.attributes.current ) { #>
|
||||||
|
disabled="disabled"
|
||||||
|
<# } #>
|
||||||
|
type="button" class="restore-revision button button-primary" data-restore-link="{{{ data.restoreLink }}}" value="<?php esc_attr_e( 'Restore This Revision' ); ?>" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue