Changeset 30131
- Timestamp:
- 11/01/2014 12:38:21 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/js/revisions.js
r30130 r30131 49 49 }); 50 50 }; 51 52 // wp_localize_script transforms top-level numbers into strings. Undo that.53 if ( revisions.settings.to ) {54 revisions.settings.to = parseInt( revisions.settings.to, 10 );55 }56 if ( revisions.settings.from ) {57 revisions.settings.from = parseInt( revisions.settings.from, 10 );58 }59 60 // wp_localize_script does not allow for top-level booleans. Fix that.61 if ( revisions.settings.compareTwoMode ) {62 revisions.settings.compareTwoMode = revisions.settings.compareTwoMode === '1';63 }64 51 65 52 /** … … 88 75 89 76 // Listen for internal changes 90 this. listenTo( this,'change:from', this.handleLocalChanges );91 this. listenTo( this,'change:to', this.handleLocalChanges );92 this. listenTo( this,'change:compareTwoMode', this.updateSliderSettings );93 this. listenTo( this,'update:revisions', this.updateSliderSettings );77 this.on( 'change:from', this.handleLocalChanges ); 78 this.on( 'change:to', this.handleLocalChanges ); 79 this.on( 'change:compareTwoMode', this.updateSliderSettings ); 80 this.on( 'update:revisions', this.updateSliderSettings ); 94 81 95 82 // Listen for changes to the hovered revision 96 this. listenTo( this,'change:hoveredRevision', this.hoverRevision );83 this.on( 'change:hoveredRevision', this.hoverRevision ); 97 84 98 85 this.set({ … … 243 230 this.loadAll = _.once( this._loadAll ); 244 231 this.revisions = options.revisions; 232 this.postId = options.postId; 245 233 this.requests = {}; 246 234 }, … … 340 328 options.data = _.extend( options.data || {}, { 341 329 action: 'get-revision-diffs', 342 post_id: revisions.settings.postId330 post_id: this.postId 343 331 }); 344 332 … … 391 379 392 380 initialize: function( attributes, options ) { 393 var properties = {}; 394 381 var state = this.get( 'initialDiffState' ); 395 382 _.bindAll( this, 'receiveDiff' ); 396 383 this._debouncedEnsureDiff = _.debounce( this._ensureDiff, 200 ); 397 384 398 385 this.revisions = options.revisions; 399 this.diffs = new revisions.model.Diffs( [], { revisions: this.revisions }); 400 401 // Set the initial diffs collection provided through the settings 402 this.diffs.set( revisions.settings.diffData ); 386 387 this.diffs = new revisions.model.Diffs( [], { 388 revisions: this.revisions, 389 postId: this.get( 'postId' ) 390 } ); 391 392 // Set the initial diffs collection. 393 this.diffs.set( this.get( 'diffData' ) ); 403 394 404 395 // Set up internal listeners … … 410 401 this.listenTo( this, 'update:diff', this.updateLoadingStatus ); 411 402 412 // Set the initial revisions, baseUrl, and mode as provided through settings 413 properties.to = this.revisions.get( revisions.settings.to ); 414 properties.from = this.revisions.get( revisions.settings.from ); 415 properties.compareTwoMode = revisions.settings.compareTwoMode; 416 properties.baseUrl = revisions.settings.baseUrl; 417 this.set( properties ); 403 // Set the initial revisions, baseUrl, and mode as provided through attributes. 404 405 this.set( { 406 to : this.revisions.get( state.to ), 407 from : this.revisions.get( state.from ), 408 compareTwoMode : this.revisions.get( state.compareTwoMode ) 409 } ); 418 410 419 411 // Start the router if browser supports History API … … 1144 1136 */ 1145 1137 revisions.init = function() { 1138 var state; 1139 1146 1140 // Bail if the current page is not revision.php. 1147 1141 if ( ! window.adminpage || 'revision-php' !== window.adminpage ) { … … 1149 1143 } 1150 1144 1145 state = new revisions.model.FrameState({ 1146 initialDiffState: { 1147 // wp_localize_script doesn't stringifies ints, so cast them. 1148 to: parseInt( revisions.settings.to, 10 ), 1149 from: parseInt( revisions.settings.from, 10 ), 1150 // wp_localize_script does not allow for top-level booleans so do a comparator here. 1151 compareTwoMode: ( revisions.settings.compareTwoMode === '1' ) 1152 }, 1153 diffData: revisions.settings.diffData, 1154 baseUrl: revisions.settings.baseUrl, 1155 postId: parseInt( revisions.settings.postId, 10 ) 1156 }, { 1157 revisions: new revisions.model.Revisions( revisions.settings.revisionData ) 1158 }); 1159 1151 1160 revisions.view.frame = new revisions.view.Frame({ 1152 model: new revisions.model.FrameState({}, { 1153 revisions: new revisions.model.Revisions( revisions.settings.revisionData ) 1154 }) 1161 model: state 1155 1162 }).render(); 1156 1163 };
Note: See TracChangeset
for help on using the changeset viewer.