WordPress.org

Make WordPress Core

Changeset 22339


Ignore:
Timestamp:
10/30/2012 11:59:57 PM (8 years ago)
Author:
koopersmith
Message:

Media JS: Several improvements to the Attachment views.

  • Bind Attachment details updates to the Attachments initialize method.
  • Improve Attachment view unbinding.
  • Re-render Attachment views when titles and captions are updated.

see #21390.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/js/media-views.js

    r22338 r22339  
    10401040            this.controller = this.options.controller;
    10411041
    1042             this.model.on( 'change:sizes change:uploading', this.render, this );
     1042            this.model.on( 'change:sizes change:uploading change:caption change:title', this.render, this );
    10431043            this.model.on( 'change:percent', this.progress, this );
    10441044            this.model.on( 'add', this.select, this );
    10451045            this.model.on( 'remove', this.deselect, this );
    10461046
     1047            // Update the model's details view.
     1048            this.model.on( 'selection:single selection:unsingle', this.details, this );
     1049            this.details( this.model, this.controller.state().get('selection') );
     1050
    10471051            // Prevent default navigation on all links.
    10481052            this.$el.on( 'click', 'a', this.preventDefault );
    10491053        },
    10501054
     1055        destroy: function() {
     1056            this.model.off( null, null, this );
     1057        },
     1058
    10511059        render: function() {
    1052             var state = this.controller.state(),
    1053                 attachment = this.model.toJSON(),
     1060            var attachment = this.model.toJSON(),
    10541061                options = _.defaults( this.model.toJSON(), {
    10551062                    orientation: 'landscape',
     
    10641071
    10651072            options.buttons  = this.buttons;
    1066             options.describe = state.get('describe');
     1073            options.describe = this.controller.state().get('describe');
    10671074
    10681075            if ( 'image' === options.type )
     
    10801087                this.select();
    10811088
    1082             // Update the model's details view.
    1083             this.model.on( 'selection:single selection:unsingle', this.details, this );
    1084             this.details( this.model, state.get('selection') );
    1085 
    1086             return this;
    1087         },
    1088 
    1089         destroy: function() {
    1090             this.model.off( 'single', this.details, this );
     1089            return this;
    10911090        },
    10921091
Note: See TracChangeset for help on using the changeset viewer.