mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-12 13:44:21 +01:00
Revisions: Clean up JavaScript variable names, see #23901.
git-svn-id: http://core.svn.wordpress.org/trunk@24019 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
81b300582e
commit
45a9b723ee
@ -1483,14 +1483,14 @@ table.diff .diff-addedline ins {
|
||||
color: #0080aa;
|
||||
}
|
||||
|
||||
.revision-tick.loading-true {
|
||||
.revision-tick.completed-false {
|
||||
background-color: #9999cc;
|
||||
background: url(../images/wpspin_light.gif) no-repeat;
|
||||
background-position: middle;
|
||||
background-size: 1px 10px;
|
||||
}
|
||||
|
||||
.revision-tick.loading-false {
|
||||
.revision-tick.completed-true {
|
||||
background-color: #aaa;
|
||||
}
|
||||
|
||||
|
@ -1377,14 +1377,14 @@ table.diff .diff-addedline ins {
|
||||
background-color: #f7f7f7;
|
||||
}
|
||||
|
||||
.revision-tick.loading-true {
|
||||
.revision-tick.completed-false {
|
||||
background-color: #9999cc;
|
||||
background: url(../images/wpspin_light.gif) no-repeat;
|
||||
background-position: middle;
|
||||
background-size: 1px 10px;
|
||||
}
|
||||
|
||||
.revision-tick.loading-false {
|
||||
.revision-tick.completed-true {
|
||||
background-color: #aaa;
|
||||
}
|
||||
|
||||
|
@ -2164,8 +2164,8 @@ function wp_ajax_revisions_data() {
|
||||
|
||||
$all_the_revisions = array (
|
||||
'diff' => $content,
|
||||
'lines_deleted' => $lines_deleted,
|
||||
'lines_added' => $lines_added
|
||||
'linesDeleted' => $lines_deleted,
|
||||
'linesAdded' => $lines_added
|
||||
);
|
||||
|
||||
echo json_encode( $all_the_revisions );
|
||||
@ -2278,9 +2278,8 @@ function wp_ajax_revisions_data() {
|
||||
'titleFrom' => $revision_from_date_author,
|
||||
'titleTooltip' => $revision_date_author_short,
|
||||
'restoreLink' => urldecode( $restore_link ),
|
||||
'revision_toload' => true,
|
||||
'previous_revision_id' => $previous_revision_id,
|
||||
'is_current_revision' => $is_current_revision,
|
||||
'previousID' => $previous_revision_id,
|
||||
'isCurrent' => $is_current_revision,
|
||||
);
|
||||
}
|
||||
$previous_revision_id = $revision->ID;
|
||||
|
@ -59,9 +59,9 @@ window.wp = window.wp || {};
|
||||
}
|
||||
},
|
||||
|
||||
reloadToLoadRevisions: function( models, reverse_direction ) {
|
||||
loadDiffs: function( models ) {
|
||||
var self = this,
|
||||
revisionsToLoad = models.where( { revision_toload: true } ),
|
||||
revisionsToLoad = models.where( { completed: false } ),
|
||||
delay = 0;
|
||||
|
||||
// match slider to passed revision_id
|
||||
@ -77,29 +77,29 @@ window.wp = window.wp || {};
|
||||
add: false,
|
||||
remove: false,
|
||||
success: function( model ) {
|
||||
model.set( 'revision_toload', 'false' );
|
||||
model.set( 'completed', true );
|
||||
|
||||
// stop spinner when all models are loaded
|
||||
if ( 0 === models.where( { revision_toload: true } ).length )
|
||||
if ( 0 === models.where( { completed: false } ).length )
|
||||
self.stopModelLoadingSpinner();
|
||||
|
||||
self.tickmarkView.render();
|
||||
|
||||
var total_changes = model.get( 'lines_added' ) + model.get( 'lines_deleted'),
|
||||
scope_of_changes = 'vsmall';
|
||||
var totalChanges = model.get( 'linesAdded' ) + model.get( 'linesDeleted' ),
|
||||
scopeOfChanges = 'vsmall';
|
||||
|
||||
// Note: hard coded scope of changes
|
||||
// TODO change to dynamic based on range of values
|
||||
if ( total_changes > 1 && total_changes <= 3 ) {
|
||||
scope_of_changes = 'small';
|
||||
} else if( total_changes > 3 && total_changes <= 5 ) {
|
||||
scope_of_changes = 'med';
|
||||
} else if( total_changes > 5 && total_changes <= 10 ) {
|
||||
scope_of_changes = 'large';
|
||||
} else if( total_changes > 10 ) {
|
||||
scope_of_changes = 'vlarge';
|
||||
if ( totalChanges > 1 && totalChanges <= 3 ) {
|
||||
scopeOfChanges = 'small';
|
||||
} else if ( totalChanges > 3 && totalChanges <= 5 ) {
|
||||
scopeOfChanges = 'med';
|
||||
} else if ( totalChanges > 5 && totalChanges <= 10 ) {
|
||||
scopeOfChanges = 'large';
|
||||
} else if ( totalChanges > 10 ) {
|
||||
scopeOfChanges = 'vlarge';
|
||||
}
|
||||
model.set( 'scope_of_changes', scope_of_changes );
|
||||
model.set( 'scopeOfChanges', scopeOfChanges );
|
||||
if ( 0 !== self.rightDiff &&
|
||||
model.get( 'ID' ) === self.revisions.at( self.rightDiff - 1 ).get( 'ID' ) ) {
|
||||
// reload if current model refreshed
|
||||
@ -149,19 +149,19 @@ window.wp = window.wp || {};
|
||||
reloadModelSingle: function() {
|
||||
var self = this;
|
||||
|
||||
// TODO: Only updates the query args yet
|
||||
self.startRightModelLoading();
|
||||
|
||||
self.revisions.reload({
|
||||
options: {
|
||||
'showAutosaves': self.autosaves,
|
||||
'showSplitView': self.showSplitView
|
||||
});
|
||||
},
|
||||
|
||||
self.startRightModelLoading();
|
||||
self.revisions.fetch({ // reload revision data
|
||||
success: function() {
|
||||
var revisionCount = self.revisions.length;
|
||||
self.revisionView.model = self.revisions;
|
||||
self.revisionView.render();
|
||||
self.reloadToLoadRevisions( self.revisions );
|
||||
self.loadDiffs( self.revisions );
|
||||
self.tickmarkView.model = self.revisions;
|
||||
self.tickmarkView.render();
|
||||
self.slider.refresh({
|
||||
@ -173,7 +173,6 @@ window.wp = window.wp || {};
|
||||
error: function() {
|
||||
self.stopRightModelLoading();
|
||||
}
|
||||
|
||||
});
|
||||
},
|
||||
|
||||
@ -191,7 +190,7 @@ window.wp = window.wp || {};
|
||||
self.leftHandleRevisions.fetch({
|
||||
success: function(){
|
||||
self.stopLeftModelLoading();
|
||||
self.reloadToLoadRevisions( self.leftHandleRevisions );
|
||||
self.loadDiffs( self.leftHandleRevisions );
|
||||
self.tickmarkView.model = self.leftHandleRevisions;
|
||||
self.slider.refresh({
|
||||
'max': self.revisions.length
|
||||
@ -222,7 +221,7 @@ window.wp = window.wp || {};
|
||||
self.rightHandleRevisions.fetch({
|
||||
success: function(){
|
||||
self.stopRightModelLoading();
|
||||
self.reloadToLoadRevisions( self.rightHandleRevisions );
|
||||
self.loadDiffs( self.rightHandleRevisions );
|
||||
self.tickmarkView.model = self.rightHandleRevisions;
|
||||
self.slider.refresh({
|
||||
'max': self.revisions.length,
|
||||
@ -250,7 +249,7 @@ window.wp = window.wp || {};
|
||||
});
|
||||
this.revisionView.render();
|
||||
|
||||
this.reloadToLoadRevisions( this.revisions );
|
||||
this.loadDiffs( this.revisions );
|
||||
|
||||
this.revisionsInteractions = new revisions.view.Interact({
|
||||
model: this.revisions
|
||||
@ -262,7 +261,6 @@ window.wp = window.wp || {};
|
||||
});
|
||||
this.tickmarkView.render();
|
||||
this.tickmarkView.resetTicks();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
@ -473,9 +471,6 @@ window.wp = window.wp || {};
|
||||
$(this).css( 'margin-right', tickWidth - 1 + 'px'); // space the ticks out using right margin
|
||||
});
|
||||
|
||||
if( ! Diff.singleRevision ) {
|
||||
$( '.revision-tick' ).first().remove(); // TODO - remove the check
|
||||
}
|
||||
$( '.revision-tick' ).last().css( 'margin-right', '0' ); // last tick gets no right margin
|
||||
}
|
||||
|
||||
@ -633,7 +628,7 @@ window.wp = window.wp || {};
|
||||
this.toggleCompareTwoCheckbox();
|
||||
|
||||
// hide the restore button when on the last sport/current post data
|
||||
$( '#restore-revision' ).toggle( ! Diff.revisions.at( Diff.rightDiff - 1 ).get( 'is_current_revision' ) );
|
||||
$( '#restore-revision' ).toggle( ! Diff.revisions.at( Diff.rightDiff - 1 ).get( 'isCurrent' ) );
|
||||
|
||||
return this;
|
||||
},
|
||||
@ -686,8 +681,7 @@ window.wp = window.wp || {};
|
||||
*/
|
||||
Revision = revisions.model.Revision = Backbone.Model.extend({
|
||||
idAttribute: 'ID',
|
||||
urlRoot: ajaxurl + '?action=revisions-data' +
|
||||
'&show_autosaves=true&show_split_view=true&nonce=' + revisions.model.settings.nonce,
|
||||
|
||||
defaults: {
|
||||
ID: 0,
|
||||
titleTo: '',
|
||||
@ -695,19 +689,23 @@ window.wp = window.wp || {};
|
||||
titleFrom: '',
|
||||
diff: '<div class="diff-loading"><div class="spinner"></div></div>',
|
||||
restoreLink: '',
|
||||
revision_toload: false,
|
||||
lines_added: 0,
|
||||
lines_deleted: 0,
|
||||
scope_of_changes: 'none',
|
||||
previous_revision_id: 0,
|
||||
is_current_revision: false
|
||||
completed: false,
|
||||
linesAdded: 0,
|
||||
linesDeleted: 0,
|
||||
scopeOfChanges: 'none',
|
||||
previousID: 0,
|
||||
isCurrent: false
|
||||
},
|
||||
|
||||
url: function() {
|
||||
if ( Diff.singleRevision ) {
|
||||
return this.urlRoot +
|
||||
return ajaxurl +
|
||||
'?action=revisions-data' +
|
||||
'&show_autosaves=true' +
|
||||
'&show_split_view=true' +
|
||||
'&nonce=' + revisions.model.settings.nonce +
|
||||
'&single_revision_id=' + this.id +
|
||||
'&compare_to=' + this.get( 'previous_revision_id' ) +
|
||||
'&compare_to=' + this.get( 'previousID' ) +
|
||||
'&post_id=' + revisions.model.settings.post_id;
|
||||
} else {
|
||||
return this.collection.url() + '&single_revision_id=' + this.id;
|
||||
@ -721,7 +719,6 @@ window.wp = window.wp || {};
|
||||
*/
|
||||
Revisions = revisions.Revisions = Backbone.Collection.extend({
|
||||
model: Revision,
|
||||
urlRoot: ajaxurl + '?action=revisions-data',
|
||||
|
||||
initialize: function( models, options ) {
|
||||
this.options = _.defaults( options || {}, {
|
||||
@ -736,7 +733,8 @@ window.wp = window.wp || {};
|
||||
},
|
||||
|
||||
url: function() {
|
||||
return this.urlRoot +
|
||||
return ajaxurl +
|
||||
'?action=revisions-data' +
|
||||
'&compare_to=' + this.options.compareTo +
|
||||
'&post_id=' + this.options.post_id +
|
||||
'&show_autosaves=' + this.options.showAutosaves +
|
||||
@ -747,10 +745,12 @@ window.wp = window.wp || {};
|
||||
},
|
||||
|
||||
reload: function( options ) {
|
||||
this.options = _.defaults( options || {}, this.options );
|
||||
this.options = _.defaults( options.options || {}, this.options );
|
||||
|
||||
// TODO
|
||||
//this.fetch();
|
||||
this.fetch({
|
||||
success: options.success || null,
|
||||
error: options.error || null
|
||||
});
|
||||
}
|
||||
|
||||
} );
|
||||
|
@ -157,7 +157,7 @@ require_once( './admin-header.php' );
|
||||
</script>
|
||||
|
||||
<script id="tmpl-revision-ticks" type="text/html">
|
||||
<div class="revision-tick loading-{{{ data.revision_toload }}} scope-of-changes-{{{ data.scope_of_changes }}}"></div>
|
||||
<div class="revision-tick completed-{{{ data.completed }}} scope-of-changes-{{{ data.scopeOfChanges }}}"></div>
|
||||
</script>
|
||||
<?php
|
||||
require_once( './admin-footer.php' );
|
||||
|
Loading…
Reference in New Issue
Block a user