Changeset 24361
- Timestamp:
- 05/25/2013 09:38:12 PM (13 years ago)
- Location:
- trunk/wp-includes/js
- Files:
-
- 2 edited
-
media-views.js (modified) (1 diff)
-
wp-backbone.js (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/js/media-views.js
r24360 r24361 848 848 // 849 849 // The base view class. 850 media.View = wp.View; 850 // 851 // Undelegating events, removing events from the model, and 852 // removing events from the controller mirror the code for 853 // `Backbone.View.dispose` in Backbone 0.9.8 development. 854 // 855 // This behavior has since been removed, and should not be used 856 // outside of the media manager. 857 media.View = wp.View.extend({ 858 constructor: function( options ) { 859 if ( options && options.controller ) 860 this.controller = options.controller; 861 862 wp.View.apply( this, arguments ); 863 }, 864 865 dispose: function() { 866 // Undelegating events, removing events from the model, and 867 // removing events from the controller mirror the code for 868 // `Backbone.View.dispose` in Backbone 0.9.8 development. 869 this.undelegateEvents(); 870 871 if ( this.model && this.model.off ) 872 this.model.off( null, null, this ); 873 874 if ( this.collection && this.collection.off ) 875 this.collection.off( null, null, this ); 876 877 // Unbind controller events. 878 if ( this.controller && this.controller.off ) 879 this.controller.off( null, null, this ); 880 881 return this; 882 }, 883 884 remove: function() { 885 this.dispose(); 886 return wp.View.prototype.remove.apply( this, arguments ); 887 } 888 }); 851 889 852 890 /** -
trunk/wp-includes/js/wp-backbone.js
r24360 r24361 127 127 view.$el.detach(); 128 128 else 129 view. dispose();129 view.remove(); 130 130 }); 131 131 … … 183 183 // Stops tracking `views` registered to a `selector`. If no `views` are 184 184 // set, then all of the `selector`'s subviews will be unregistered and 185 // disposed.186 // 187 // Accepts an `options` object. If `options.silent` is set, ` dispose`185 // removed. 186 // 187 // Accepts an `options` object. If `options.silent` is set, `remove` 188 188 // will *not* be triggered on the unregistered views. 189 189 unset: function( selector, views, options ) { … … 204 204 205 205 if ( ! options || ! options.silent ) 206 _.invoke( views, ' dispose' );206 _.invoke( views, 'remove' ); 207 207 208 208 return this; … … 236 236 }, 237 237 238 // ### Dispose all subviews239 // 240 // Triggers the ` dispose()` method on all subviews. Detaches the master238 // ### Remove all subviews 239 // 240 // Triggers the `remove()` method on all subviews. Detaches the master 241 241 // view from its parent. Resets the internals of the views manager. 242 242 // 243 243 // Accepts an `options` object. If `options.silent` is set, `unset` 244 244 // will *not* be triggered on the master view's parent. 245 dispose: function( options ) {245 remove: function( options ) { 246 246 if ( ! options || ! options.silent ) { 247 247 if ( this.parent && this.parent.views ) … … 251 251 } 252 252 253 _.invoke( this.all(), ' dispose' );253 _.invoke( this.all(), 'remove' ); 254 254 this._views = []; 255 255 return this; … … 362 362 Subviews: wp.Subviews, 363 363 364 constructor: function( options) {364 constructor: function() { 365 365 this.views = new this.Subviews( this, this.views ); 366 366 this.on( 'ready', this.ready, this ); 367 367 368 if ( options && options.controller )369 this.controller = options.controller;370 371 368 Backbone.View.apply( this, arguments ); 372 369 }, 373 370 374 dispose: function() { 375 // Undelegating events, removing events from the model, and 376 // removing events from the controller mirror the code for 377 // `Backbone.View.dispose` in Backbone master. 378 this.undelegateEvents(); 379 380 if ( this.model && this.model.off ) 381 this.model.off( null, null, this ); 382 383 if ( this.collection && this.collection.off ) 384 this.collection.off( null, null, this ); 385 386 // Unbind controller events. 387 if ( this.controller && this.controller.off ) 388 this.controller.off( null, null, this ); 389 390 // Recursively dispose child views. 371 remove: function() { 372 var result = Backbone.View.prototype.remove.apply( this, arguments ); 373 374 // Recursively remove child views. 391 375 if ( this.views ) 392 this.views.dispose(); 393 394 return this; 395 }, 396 397 remove: function() { 398 this.dispose(); 399 return Backbone.View.prototype.remove.apply( this, arguments ); 376 this.views.remove(); 377 378 return result; 400 379 }, 401 380
Note: See TracChangeset
for help on using the changeset viewer.