diff --git src/wp-admin/js/revisions.js src/wp-admin/js/revisions.js
index 521e55c..6421c1d 100644
|
|
|
window.wp = window.wp || {}; |
| 35 | 35 | }); |
| 36 | 36 | }; |
| 37 | 37 | |
| 38 | | // wp_localize_script transforms top-level numbers into strings. Undo that. |
| 39 | | if ( revisions.settings.to ) { |
| 40 | | revisions.settings.to = parseInt( revisions.settings.to, 10 ); |
| 41 | | } |
| 42 | | if ( revisions.settings.from ) { |
| 43 | | revisions.settings.from = parseInt( revisions.settings.from, 10 ); |
| 44 | | } |
| 45 | | |
| 46 | | // wp_localize_script does not allow for top-level booleans. Fix that. |
| 47 | | if ( revisions.settings.compareTwoMode ) { |
| 48 | | revisions.settings.compareTwoMode = revisions.settings.compareTwoMode === '1'; |
| 49 | | } |
| 50 | | |
| 51 | 38 | /** |
| 52 | 39 | * ======================================================================== |
| 53 | 40 | * MODELS |
| … |
… |
window.wp = window.wp || {}; |
| 223 | 210 | _.bindAll( this, 'getClosestUnloaded' ); |
| 224 | 211 | this.loadAll = _.once( this._loadAll ); |
| 225 | 212 | this.revisions = options.revisions; |
| | 213 | this.postId = options.postId; |
| 226 | 214 | this.requests = {}; |
| 227 | 215 | }, |
| 228 | 216 | |
| … |
… |
window.wp = window.wp || {}; |
| 320 | 308 | options.context = this; |
| 321 | 309 | options.data = _.extend( options.data || {}, { |
| 322 | 310 | action: 'get-revision-diffs', |
| 323 | | post_id: revisions.settings.postId |
| | 311 | post_id: this.postId |
| 324 | 312 | }); |
| 325 | 313 | |
| 326 | 314 | var deferred = wp.ajax.send( options ), |
| … |
… |
window.wp = window.wp || {}; |
| 360 | 348 | }, |
| 361 | 349 | |
| 362 | 350 | initialize: function( attributes, options ) { |
| 363 | | var properties = {}; |
| 364 | | |
| 365 | 351 | _.bindAll( this, 'receiveDiff' ); |
| 366 | 352 | this._debouncedEnsureDiff = _.debounce( this._ensureDiff, 200 ); |
| 367 | 353 | |
| 368 | 354 | this.revisions = options.revisions; |
| 369 | | this.diffs = new revisions.model.Diffs( [], { revisions: this.revisions }); |
| | 355 | this.diffs = new revisions.model.Diffs( [], { revisions: this.revisions, |
| | 356 | postId: this.get( 'postId' ) }); |
| 370 | 357 | |
| 371 | | // Set the initial diffs collection provided through the settings |
| 372 | | this.diffs.set( revisions.settings.diffData ); |
| | 358 | // Set the initial diffs collection. |
| | 359 | this.diffs.set( this.get( 'diffData' ) ); |
| 373 | 360 | |
| 374 | 361 | // Set up internal listeners |
| 375 | 362 | this.listenTo( this, 'change:from', this.changeRevisionHandler ); |
| … |
… |
window.wp = window.wp || {}; |
| 379 | 366 | this.listenTo( this.diffs, 'ensure:load', this.updateLoadingStatus ); |
| 380 | 367 | this.listenTo( this, 'update:diff', this.updateLoadingStatus ); |
| 381 | 368 | |
| 382 | | // Set the initial revisions, baseUrl, and mode as provided through settings |
| 383 | | properties.to = this.revisions.get( revisions.settings.to ); |
| 384 | | properties.from = this.revisions.get( revisions.settings.from ); |
| 385 | | properties.compareTwoMode = revisions.settings.compareTwoMode; |
| 386 | | properties.baseUrl = revisions.settings.baseUrl; |
| | 369 | |
| | 370 | // Set the initial revisions, baseUrl, and mode as provided through attributes. |
| | 371 | var properties = {}; |
| | 372 | properties.to = this.revisions.get( this.get( 'initialDiffState' ).to ); |
| | 373 | properties.from = this.revisions.get( this.get( 'initialDiffState' ).from ); |
| | 374 | properties.compareTwoMode = this.revisions.get( this.get( 'initialDiffState' ).compareTwoMode ); |
| 387 | 375 | this.set( properties ); |
| 388 | 376 | |
| 389 | 377 | // Start the router if browser supports History API |
| … |
… |
window.wp = window.wp || {}; |
| 1100 | 1088 | // Initialize the revisions UI. |
| 1101 | 1089 | revisions.init = function() { |
| 1102 | 1090 | revisions.view.frame = new revisions.view.Frame({ |
| 1103 | | model: new revisions.model.FrameState({}, { |
| | 1091 | model: new revisions.model.FrameState({ |
| | 1092 | initialDiffState: { |
| | 1093 | // wp_localize_script doesn't stringifies ints, so cast them. |
| | 1094 | to: parseInt( revisions.settings.to, 10 ), |
| | 1095 | from: parseInt( revisions.settings.from, 10 ), |
| | 1096 | // wp_localize_script does not allow for top-level booleans so do a comparator here. |
| | 1097 | compareTwoMode: ( revisions.settings.compareTwoMode === '1' ) |
| | 1098 | }, |
| | 1099 | diffData: revisions.settings.diffData, |
| | 1100 | baseUrl: revisions.settings.baseUrl, |
| | 1101 | postId: parseInt( revisions.settings.postId, 10 ) |
| | 1102 | }, { |
| 1104 | 1103 | revisions: new revisions.model.Revisions( revisions.settings.revisionData ) |
| 1105 | 1104 | }) |
| 1106 | 1105 | }).render(); |