item.js
28 lines
| 1 | /** |
| 2 | * wp.media.model.MenuIconsItem |
| 3 | * |
| 4 | * @class |
| 5 | * @augments Backbone.Model |
| 6 | */ |
| 7 | var Item = Backbone.Model.extend({ |
| 8 | initialize: function() { |
| 9 | this.on( 'change', this.updateValues, this ); |
| 10 | }, |
| 11 | |
| 12 | /** |
| 13 | * Update the values of menu item's settings fields |
| 14 | * |
| 15 | * #fires mi:update |
| 16 | */ |
| 17 | updateValues: function() { |
| 18 | _.each( this.get( '$inputs' ), function( $input, key ) { |
| 19 | $input.val( this.get( key ) ); |
| 20 | }, this ); |
| 21 | |
| 22 | // Trigger the 'mi:update' event to regenerate the icon on the field. |
| 23 | this.get( '$el' ).trigger( 'mi:update' ); |
| 24 | } |
| 25 | }); |
| 26 | |
| 27 | module.exports = Item; |
| 28 |