Edit File by line
/home/barbar84/public_h.../wp-admin/js
File: revisions.js
/**
[0] Fix | Delete
* @file Revisions interface functions, Backbone classes and
[1] Fix | Delete
* the revisions.php document.ready bootstrap.
[2] Fix | Delete
*
[3] Fix | Delete
* @output wp-admin/js/revisions.js
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
/* global isRtl */
[7] Fix | Delete
[8] Fix | Delete
window.wp = window.wp || {};
[9] Fix | Delete
[10] Fix | Delete
(function($) {
[11] Fix | Delete
var revisions;
[12] Fix | Delete
/**
[13] Fix | Delete
* Expose the module in window.wp.revisions.
[14] Fix | Delete
*/
[15] Fix | Delete
revisions = wp.revisions = { model: {}, view: {}, controller: {} };
[16] Fix | Delete
[17] Fix | Delete
// Link post revisions data served from the back end.
[18] Fix | Delete
revisions.settings = window._wpRevisionsSettings || {};
[19] Fix | Delete
[20] Fix | Delete
// For debugging.
[21] Fix | Delete
revisions.debug = false;
[22] Fix | Delete
[23] Fix | Delete
/**
[24] Fix | Delete
* wp.revisions.log
[25] Fix | Delete
*
[26] Fix | Delete
* A debugging utility for revisions. Works only when a
[27] Fix | Delete
* debug flag is on and the browser supports it.
[28] Fix | Delete
*/
[29] Fix | Delete
revisions.log = function() {
[30] Fix | Delete
if ( window.console && revisions.debug ) {
[31] Fix | Delete
window.console.log.apply( window.console, arguments );
[32] Fix | Delete
}
[33] Fix | Delete
};
[34] Fix | Delete
[35] Fix | Delete
// Handy functions to help with positioning.
[36] Fix | Delete
$.fn.allOffsets = function() {
[37] Fix | Delete
var offset = this.offset() || {top: 0, left: 0}, win = $(window);
[38] Fix | Delete
return _.extend( offset, {
[39] Fix | Delete
right: win.width() - offset.left - this.outerWidth(),
[40] Fix | Delete
bottom: win.height() - offset.top - this.outerHeight()
[41] Fix | Delete
});
[42] Fix | Delete
};
[43] Fix | Delete
[44] Fix | Delete
$.fn.allPositions = function() {
[45] Fix | Delete
var position = this.position() || {top: 0, left: 0}, parent = this.parent();
[46] Fix | Delete
return _.extend( position, {
[47] Fix | Delete
right: parent.outerWidth() - position.left - this.outerWidth(),
[48] Fix | Delete
bottom: parent.outerHeight() - position.top - this.outerHeight()
[49] Fix | Delete
});
[50] Fix | Delete
};
[51] Fix | Delete
[52] Fix | Delete
/**
[53] Fix | Delete
* ========================================================================
[54] Fix | Delete
* MODELS
[55] Fix | Delete
* ========================================================================
[56] Fix | Delete
*/
[57] Fix | Delete
revisions.model.Slider = Backbone.Model.extend({
[58] Fix | Delete
defaults: {
[59] Fix | Delete
value: null,
[60] Fix | Delete
values: null,
[61] Fix | Delete
min: 0,
[62] Fix | Delete
max: 1,
[63] Fix | Delete
step: 1,
[64] Fix | Delete
range: false,
[65] Fix | Delete
compareTwoMode: false
[66] Fix | Delete
},
[67] Fix | Delete
[68] Fix | Delete
initialize: function( options ) {
[69] Fix | Delete
this.frame = options.frame;
[70] Fix | Delete
this.revisions = options.revisions;
[71] Fix | Delete
[72] Fix | Delete
// Listen for changes to the revisions or mode from outside.
[73] Fix | Delete
this.listenTo( this.frame, 'update:revisions', this.receiveRevisions );
[74] Fix | Delete
this.listenTo( this.frame, 'change:compareTwoMode', this.updateMode );
[75] Fix | Delete
[76] Fix | Delete
// Listen for internal changes.
[77] Fix | Delete
this.on( 'change:from', this.handleLocalChanges );
[78] Fix | Delete
this.on( 'change:to', this.handleLocalChanges );
[79] Fix | Delete
this.on( 'change:compareTwoMode', this.updateSliderSettings );
[80] Fix | Delete
this.on( 'update:revisions', this.updateSliderSettings );
[81] Fix | Delete
[82] Fix | Delete
// Listen for changes to the hovered revision.
[83] Fix | Delete
this.on( 'change:hoveredRevision', this.hoverRevision );
[84] Fix | Delete
[85] Fix | Delete
this.set({
[86] Fix | Delete
max: this.revisions.length - 1,
[87] Fix | Delete
compareTwoMode: this.frame.get('compareTwoMode'),
[88] Fix | Delete
from: this.frame.get('from'),
[89] Fix | Delete
to: this.frame.get('to')
[90] Fix | Delete
});
[91] Fix | Delete
this.updateSliderSettings();
[92] Fix | Delete
},
[93] Fix | Delete
[94] Fix | Delete
getSliderValue: function( a, b ) {
[95] Fix | Delete
return isRtl ? this.revisions.length - this.revisions.indexOf( this.get(a) ) - 1 : this.revisions.indexOf( this.get(b) );
[96] Fix | Delete
},
[97] Fix | Delete
[98] Fix | Delete
updateSliderSettings: function() {
[99] Fix | Delete
if ( this.get('compareTwoMode') ) {
[100] Fix | Delete
this.set({
[101] Fix | Delete
values: [
[102] Fix | Delete
this.getSliderValue( 'to', 'from' ),
[103] Fix | Delete
this.getSliderValue( 'from', 'to' )
[104] Fix | Delete
],
[105] Fix | Delete
value: null,
[106] Fix | Delete
range: true // Ensures handles cannot cross.
[107] Fix | Delete
});
[108] Fix | Delete
} else {
[109] Fix | Delete
this.set({
[110] Fix | Delete
value: this.getSliderValue( 'to', 'to' ),
[111] Fix | Delete
values: null,
[112] Fix | Delete
range: false
[113] Fix | Delete
});
[114] Fix | Delete
}
[115] Fix | Delete
this.trigger( 'update:slider' );
[116] Fix | Delete
},
[117] Fix | Delete
[118] Fix | Delete
// Called when a revision is hovered.
[119] Fix | Delete
hoverRevision: function( model, value ) {
[120] Fix | Delete
this.trigger( 'hovered:revision', value );
[121] Fix | Delete
},
[122] Fix | Delete
[123] Fix | Delete
// Called when `compareTwoMode` changes.
[124] Fix | Delete
updateMode: function( model, value ) {
[125] Fix | Delete
this.set({ compareTwoMode: value });
[126] Fix | Delete
},
[127] Fix | Delete
[128] Fix | Delete
// Called when `from` or `to` changes in the local model.
[129] Fix | Delete
handleLocalChanges: function() {
[130] Fix | Delete
this.frame.set({
[131] Fix | Delete
from: this.get('from'),
[132] Fix | Delete
to: this.get('to')
[133] Fix | Delete
});
[134] Fix | Delete
},
[135] Fix | Delete
[136] Fix | Delete
// Receives revisions changes from outside the model.
[137] Fix | Delete
receiveRevisions: function( from, to ) {
[138] Fix | Delete
// Bail if nothing changed.
[139] Fix | Delete
if ( this.get('from') === from && this.get('to') === to ) {
[140] Fix | Delete
return;
[141] Fix | Delete
}
[142] Fix | Delete
[143] Fix | Delete
this.set({ from: from, to: to }, { silent: true });
[144] Fix | Delete
this.trigger( 'update:revisions', from, to );
[145] Fix | Delete
}
[146] Fix | Delete
[147] Fix | Delete
});
[148] Fix | Delete
[149] Fix | Delete
revisions.model.Tooltip = Backbone.Model.extend({
[150] Fix | Delete
defaults: {
[151] Fix | Delete
revision: null,
[152] Fix | Delete
offset: {},
[153] Fix | Delete
hovering: false, // Whether the mouse is hovering.
[154] Fix | Delete
scrubbing: false // Whether the mouse is scrubbing.
[155] Fix | Delete
},
[156] Fix | Delete
[157] Fix | Delete
initialize: function( options ) {
[158] Fix | Delete
this.frame = options.frame;
[159] Fix | Delete
this.revisions = options.revisions;
[160] Fix | Delete
this.slider = options.slider;
[161] Fix | Delete
[162] Fix | Delete
this.listenTo( this.slider, 'hovered:revision', this.updateRevision );
[163] Fix | Delete
this.listenTo( this.slider, 'change:hovering', this.setHovering );
[164] Fix | Delete
this.listenTo( this.slider, 'change:scrubbing', this.setScrubbing );
[165] Fix | Delete
},
[166] Fix | Delete
[167] Fix | Delete
[168] Fix | Delete
updateRevision: function( revision ) {
[169] Fix | Delete
this.set({ revision: revision });
[170] Fix | Delete
},
[171] Fix | Delete
[172] Fix | Delete
setHovering: function( model, value ) {
[173] Fix | Delete
this.set({ hovering: value });
[174] Fix | Delete
},
[175] Fix | Delete
[176] Fix | Delete
setScrubbing: function( model, value ) {
[177] Fix | Delete
this.set({ scrubbing: value });
[178] Fix | Delete
}
[179] Fix | Delete
});
[180] Fix | Delete
[181] Fix | Delete
revisions.model.Revision = Backbone.Model.extend({});
[182] Fix | Delete
[183] Fix | Delete
/**
[184] Fix | Delete
* wp.revisions.model.Revisions
[185] Fix | Delete
*
[186] Fix | Delete
* A collection of post revisions.
[187] Fix | Delete
*/
[188] Fix | Delete
revisions.model.Revisions = Backbone.Collection.extend({
[189] Fix | Delete
model: revisions.model.Revision,
[190] Fix | Delete
[191] Fix | Delete
initialize: function() {
[192] Fix | Delete
_.bindAll( this, 'next', 'prev' );
[193] Fix | Delete
},
[194] Fix | Delete
[195] Fix | Delete
next: function( revision ) {
[196] Fix | Delete
var index = this.indexOf( revision );
[197] Fix | Delete
[198] Fix | Delete
if ( index !== -1 && index !== this.length - 1 ) {
[199] Fix | Delete
return this.at( index + 1 );
[200] Fix | Delete
}
[201] Fix | Delete
},
[202] Fix | Delete
[203] Fix | Delete
prev: function( revision ) {
[204] Fix | Delete
var index = this.indexOf( revision );
[205] Fix | Delete
[206] Fix | Delete
if ( index !== -1 && index !== 0 ) {
[207] Fix | Delete
return this.at( index - 1 );
[208] Fix | Delete
}
[209] Fix | Delete
}
[210] Fix | Delete
});
[211] Fix | Delete
[212] Fix | Delete
revisions.model.Field = Backbone.Model.extend({});
[213] Fix | Delete
[214] Fix | Delete
revisions.model.Fields = Backbone.Collection.extend({
[215] Fix | Delete
model: revisions.model.Field
[216] Fix | Delete
});
[217] Fix | Delete
[218] Fix | Delete
revisions.model.Diff = Backbone.Model.extend({
[219] Fix | Delete
initialize: function() {
[220] Fix | Delete
var fields = this.get('fields');
[221] Fix | Delete
this.unset('fields');
[222] Fix | Delete
[223] Fix | Delete
this.fields = new revisions.model.Fields( fields );
[224] Fix | Delete
}
[225] Fix | Delete
});
[226] Fix | Delete
[227] Fix | Delete
revisions.model.Diffs = Backbone.Collection.extend({
[228] Fix | Delete
initialize: function( models, options ) {
[229] Fix | Delete
_.bindAll( this, 'getClosestUnloaded' );
[230] Fix | Delete
this.loadAll = _.once( this._loadAll );
[231] Fix | Delete
this.revisions = options.revisions;
[232] Fix | Delete
this.postId = options.postId;
[233] Fix | Delete
this.requests = {};
[234] Fix | Delete
},
[235] Fix | Delete
[236] Fix | Delete
model: revisions.model.Diff,
[237] Fix | Delete
[238] Fix | Delete
ensure: function( id, context ) {
[239] Fix | Delete
var diff = this.get( id ),
[240] Fix | Delete
request = this.requests[ id ],
[241] Fix | Delete
deferred = $.Deferred(),
[242] Fix | Delete
ids = {},
[243] Fix | Delete
from = id.split(':')[0],
[244] Fix | Delete
to = id.split(':')[1];
[245] Fix | Delete
ids[id] = true;
[246] Fix | Delete
[247] Fix | Delete
wp.revisions.log( 'ensure', id );
[248] Fix | Delete
[249] Fix | Delete
this.trigger( 'ensure', ids, from, to, deferred.promise() );
[250] Fix | Delete
[251] Fix | Delete
if ( diff ) {
[252] Fix | Delete
deferred.resolveWith( context, [ diff ] );
[253] Fix | Delete
} else {
[254] Fix | Delete
this.trigger( 'ensure:load', ids, from, to, deferred.promise() );
[255] Fix | Delete
_.each( ids, _.bind( function( id ) {
[256] Fix | Delete
// Remove anything that has an ongoing request.
[257] Fix | Delete
if ( this.requests[ id ] ) {
[258] Fix | Delete
delete ids[ id ];
[259] Fix | Delete
}
[260] Fix | Delete
// Remove anything we already have.
[261] Fix | Delete
if ( this.get( id ) ) {
[262] Fix | Delete
delete ids[ id ];
[263] Fix | Delete
}
[264] Fix | Delete
}, this ) );
[265] Fix | Delete
if ( ! request ) {
[266] Fix | Delete
// Always include the ID that started this ensure.
[267] Fix | Delete
ids[ id ] = true;
[268] Fix | Delete
request = this.load( _.keys( ids ) );
[269] Fix | Delete
}
[270] Fix | Delete
[271] Fix | Delete
request.done( _.bind( function() {
[272] Fix | Delete
deferred.resolveWith( context, [ this.get( id ) ] );
[273] Fix | Delete
}, this ) ).fail( _.bind( function() {
[274] Fix | Delete
deferred.reject();
[275] Fix | Delete
}) );
[276] Fix | Delete
}
[277] Fix | Delete
[278] Fix | Delete
return deferred.promise();
[279] Fix | Delete
},
[280] Fix | Delete
[281] Fix | Delete
// Returns an array of proximal diffs.
[282] Fix | Delete
getClosestUnloaded: function( ids, centerId ) {
[283] Fix | Delete
var self = this;
[284] Fix | Delete
return _.chain([0].concat( ids )).initial().zip( ids ).sortBy( function( pair ) {
[285] Fix | Delete
return Math.abs( centerId - pair[1] );
[286] Fix | Delete
}).map( function( pair ) {
[287] Fix | Delete
return pair.join(':');
[288] Fix | Delete
}).filter( function( diffId ) {
[289] Fix | Delete
return _.isUndefined( self.get( diffId ) ) && ! self.requests[ diffId ];
[290] Fix | Delete
}).value();
[291] Fix | Delete
},
[292] Fix | Delete
[293] Fix | Delete
_loadAll: function( allRevisionIds, centerId, num ) {
[294] Fix | Delete
var self = this, deferred = $.Deferred(),
[295] Fix | Delete
diffs = _.first( this.getClosestUnloaded( allRevisionIds, centerId ), num );
[296] Fix | Delete
if ( _.size( diffs ) > 0 ) {
[297] Fix | Delete
this.load( diffs ).done( function() {
[298] Fix | Delete
self._loadAll( allRevisionIds, centerId, num ).done( function() {
[299] Fix | Delete
deferred.resolve();
[300] Fix | Delete
});
[301] Fix | Delete
}).fail( function() {
[302] Fix | Delete
if ( 1 === num ) { // Already tried 1. This just isn't working. Give up.
[303] Fix | Delete
deferred.reject();
[304] Fix | Delete
} else { // Request fewer diffs this time.
[305] Fix | Delete
self._loadAll( allRevisionIds, centerId, Math.ceil( num / 2 ) ).done( function() {
[306] Fix | Delete
deferred.resolve();
[307] Fix | Delete
});
[308] Fix | Delete
}
[309] Fix | Delete
});
[310] Fix | Delete
} else {
[311] Fix | Delete
deferred.resolve();
[312] Fix | Delete
}
[313] Fix | Delete
return deferred;
[314] Fix | Delete
},
[315] Fix | Delete
[316] Fix | Delete
load: function( comparisons ) {
[317] Fix | Delete
wp.revisions.log( 'load', comparisons );
[318] Fix | Delete
// Our collection should only ever grow, never shrink, so `remove: false`.
[319] Fix | Delete
return this.fetch({ data: { compare: comparisons }, remove: false }).done( function() {
[320] Fix | Delete
wp.revisions.log( 'load:complete', comparisons );
[321] Fix | Delete
});
[322] Fix | Delete
},
[323] Fix | Delete
[324] Fix | Delete
sync: function( method, model, options ) {
[325] Fix | Delete
if ( 'read' === method ) {
[326] Fix | Delete
options = options || {};
[327] Fix | Delete
options.context = this;
[328] Fix | Delete
options.data = _.extend( options.data || {}, {
[329] Fix | Delete
action: 'get-revision-diffs',
[330] Fix | Delete
post_id: this.postId
[331] Fix | Delete
});
[332] Fix | Delete
[333] Fix | Delete
var deferred = wp.ajax.send( options ),
[334] Fix | Delete
requests = this.requests;
[335] Fix | Delete
[336] Fix | Delete
// Record that we're requesting each diff.
[337] Fix | Delete
if ( options.data.compare ) {
[338] Fix | Delete
_.each( options.data.compare, function( id ) {
[339] Fix | Delete
requests[ id ] = deferred;
[340] Fix | Delete
});
[341] Fix | Delete
}
[342] Fix | Delete
[343] Fix | Delete
// When the request completes, clear the stored request.
[344] Fix | Delete
deferred.always( function() {
[345] Fix | Delete
if ( options.data.compare ) {
[346] Fix | Delete
_.each( options.data.compare, function( id ) {
[347] Fix | Delete
delete requests[ id ];
[348] Fix | Delete
});
[349] Fix | Delete
}
[350] Fix | Delete
});
[351] Fix | Delete
[352] Fix | Delete
return deferred;
[353] Fix | Delete
[354] Fix | Delete
// Otherwise, fall back to `Backbone.sync()`.
[355] Fix | Delete
} else {
[356] Fix | Delete
return Backbone.Model.prototype.sync.apply( this, arguments );
[357] Fix | Delete
}
[358] Fix | Delete
}
[359] Fix | Delete
});
[360] Fix | Delete
[361] Fix | Delete
[362] Fix | Delete
/**
[363] Fix | Delete
* wp.revisions.model.FrameState
[364] Fix | Delete
*
[365] Fix | Delete
* The frame state.
[366] Fix | Delete
*
[367] Fix | Delete
* @see wp.revisions.view.Frame
[368] Fix | Delete
*
[369] Fix | Delete
* @param {object} attributes Model attributes - none are required.
[370] Fix | Delete
* @param {object} options Options for the model.
[371] Fix | Delete
* @param {revisions.model.Revisions} options.revisions A collection of revisions.
[372] Fix | Delete
*/
[373] Fix | Delete
revisions.model.FrameState = Backbone.Model.extend({
[374] Fix | Delete
defaults: {
[375] Fix | Delete
loading: false,
[376] Fix | Delete
error: false,
[377] Fix | Delete
compareTwoMode: false
[378] Fix | Delete
},
[379] Fix | Delete
[380] Fix | Delete
initialize: function( attributes, options ) {
[381] Fix | Delete
var state = this.get( 'initialDiffState' );
[382] Fix | Delete
_.bindAll( this, 'receiveDiff' );
[383] Fix | Delete
this._debouncedEnsureDiff = _.debounce( this._ensureDiff, 200 );
[384] Fix | Delete
[385] Fix | Delete
this.revisions = options.revisions;
[386] Fix | Delete
[387] Fix | Delete
this.diffs = new revisions.model.Diffs( [], {
[388] Fix | Delete
revisions: this.revisions,
[389] Fix | Delete
postId: this.get( 'postId' )
[390] Fix | Delete
} );
[391] Fix | Delete
[392] Fix | Delete
// Set the initial diffs collection.
[393] Fix | Delete
this.diffs.set( this.get( 'diffData' ) );
[394] Fix | Delete
[395] Fix | Delete
// Set up internal listeners.
[396] Fix | Delete
this.listenTo( this, 'change:from', this.changeRevisionHandler );
[397] Fix | Delete
this.listenTo( this, 'change:to', this.changeRevisionHandler );
[398] Fix | Delete
this.listenTo( this, 'change:compareTwoMode', this.changeMode );
[399] Fix | Delete
this.listenTo( this, 'update:revisions', this.updatedRevisions );
[400] Fix | Delete
this.listenTo( this.diffs, 'ensure:load', this.updateLoadingStatus );
[401] Fix | Delete
this.listenTo( this, 'update:diff', this.updateLoadingStatus );
[402] Fix | Delete
[403] Fix | Delete
// Set the initial revisions, baseUrl, and mode as provided through attributes.
[404] Fix | Delete
[405] Fix | Delete
this.set( {
[406] Fix | Delete
to : this.revisions.get( state.to ),
[407] Fix | Delete
from : this.revisions.get( state.from ),
[408] Fix | Delete
compareTwoMode : state.compareTwoMode
[409] Fix | Delete
} );
[410] Fix | Delete
[411] Fix | Delete
// Start the router if browser supports History API.
[412] Fix | Delete
if ( window.history && window.history.pushState ) {
[413] Fix | Delete
this.router = new revisions.Router({ model: this });
[414] Fix | Delete
if ( Backbone.History.started ) {
[415] Fix | Delete
Backbone.history.stop();
[416] Fix | Delete
}
[417] Fix | Delete
Backbone.history.start({ pushState: true });
[418] Fix | Delete
}
[419] Fix | Delete
},
[420] Fix | Delete
[421] Fix | Delete
updateLoadingStatus: function() {
[422] Fix | Delete
this.set( 'error', false );
[423] Fix | Delete
this.set( 'loading', ! this.diff() );
[424] Fix | Delete
},
[425] Fix | Delete
[426] Fix | Delete
changeMode: function( model, value ) {
[427] Fix | Delete
var toIndex = this.revisions.indexOf( this.get( 'to' ) );
[428] Fix | Delete
[429] Fix | Delete
// If we were on the first revision before switching to two-handled mode,
[430] Fix | Delete
// bump the 'to' position over one.
[431] Fix | Delete
if ( value && 0 === toIndex ) {
[432] Fix | Delete
this.set({
[433] Fix | Delete
from: this.revisions.at( toIndex ),
[434] Fix | Delete
to: this.revisions.at( toIndex + 1 )
[435] Fix | Delete
});
[436] Fix | Delete
}
[437] Fix | Delete
[438] Fix | Delete
// When switching back to single-handled mode, reset 'from' model to
[439] Fix | Delete
// one position before the 'to' model.
[440] Fix | Delete
if ( ! value && 0 !== toIndex ) { // '! value' means switching to single-handled mode.
[441] Fix | Delete
this.set({
[442] Fix | Delete
from: this.revisions.at( toIndex - 1 ),
[443] Fix | Delete
to: this.revisions.at( toIndex )
[444] Fix | Delete
});
[445] Fix | Delete
}
[446] Fix | Delete
},
[447] Fix | Delete
[448] Fix | Delete
updatedRevisions: function( from, to ) {
[449] Fix | Delete
if ( this.get( 'compareTwoMode' ) ) {
[450] Fix | Delete
// @todo Compare-two loading strategy.
[451] Fix | Delete
} else {
[452] Fix | Delete
this.diffs.loadAll( this.revisions.pluck('id'), to.id, 40 );
[453] Fix | Delete
}
[454] Fix | Delete
},
[455] Fix | Delete
[456] Fix | Delete
// Fetch the currently loaded diff.
[457] Fix | Delete
diff: function() {
[458] Fix | Delete
return this.diffs.get( this._diffId );
[459] Fix | Delete
},
[460] Fix | Delete
[461] Fix | Delete
/*
[462] Fix | Delete
* So long as `from` and `to` are changed at the same time, the diff
[463] Fix | Delete
* will only be updated once. This is because Backbone updates all of
[464] Fix | Delete
* the changed attributes in `set`, and then fires the `change` events.
[465] Fix | Delete
*/
[466] Fix | Delete
updateDiff: function( options ) {
[467] Fix | Delete
var from, to, diffId, diff;
[468] Fix | Delete
[469] Fix | Delete
options = options || {};
[470] Fix | Delete
from = this.get('from');
[471] Fix | Delete
to = this.get('to');
[472] Fix | Delete
diffId = ( from ? from.id : 0 ) + ':' + to.id;
[473] Fix | Delete
[474] Fix | Delete
// Check if we're actually changing the diff id.
[475] Fix | Delete
if ( this._diffId === diffId ) {
[476] Fix | Delete
return $.Deferred().reject().promise();
[477] Fix | Delete
}
[478] Fix | Delete
[479] Fix | Delete
this._diffId = diffId;
[480] Fix | Delete
this.trigger( 'update:revisions', from, to );
[481] Fix | Delete
[482] Fix | Delete
diff = this.diffs.get( diffId );
[483] Fix | Delete
[484] Fix | Delete
// If we already have the diff, then immediately trigger the update.
[485] Fix | Delete
if ( diff ) {
[486] Fix | Delete
this.receiveDiff( diff );
[487] Fix | Delete
return $.Deferred().resolve().promise();
[488] Fix | Delete
// Otherwise, fetch the diff.
[489] Fix | Delete
} else {
[490] Fix | Delete
if ( options.immediate ) {
[491] Fix | Delete
return this._ensureDiff();
[492] Fix | Delete
} else {
[493] Fix | Delete
this._debouncedEnsureDiff();
[494] Fix | Delete
return $.Deferred().reject().promise();
[495] Fix | Delete
}
[496] Fix | Delete
}
[497] Fix | Delete
},
[498] Fix | Delete
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function