Changeset 22583
- Timestamp:
- 11/14/2012 10:40:34 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/js/media-views.js
r22580 r22583 1249 1249 // Toolbars 1250 1250 mainAttachmentsToolbar: function() { 1251 this.toolbar.view( new media.view.Toolbar.Insert .Post({1251 this.toolbar.view( new media.view.Toolbar.Insert({ 1252 1252 controller: this 1253 1253 }) ); … … 1739 1739 initialize: function() { 1740 1740 var controller = this.options.controller, 1741 selection = controller.state().get('selection'); 1741 selection = controller.state().get('selection'), 1742 selectionToLibrary; 1743 1744 selectionToLibrary = function( state, filter ) { 1745 return function() { 1746 var controller = this.controller, 1747 selection = controller.state().get('selection'), 1748 edit = controller.get( state ), 1749 models = filter ? filter( selection ) : selection.models; 1750 1751 edit.set( 'library', new media.model.Selection( models, { 1752 props: selection.props.toJSON(), 1753 multiple: true 1754 }) ); 1755 1756 this.controller.state( state ); 1757 }; 1758 }; 1742 1759 1743 1760 this.options.items = _.defaults( this.options.items || {}, { … … 1758 1775 selection.clear(); 1759 1776 } 1760 } 1761 }); 1762 1763 media.view.Toolbar.prototype.initialize.apply( this, arguments ); 1764 }, 1765 1766 refresh: function() { 1767 var selection = this.controller.state().get('selection'); 1768 this.get('insert').model.set( 'disabled', ! selection.length ); 1769 } 1770 }); 1771 1772 // wp.media.view.Toolbar.Insert.Post 1773 // --------------------------------- 1774 media.view.Toolbar.Insert.Post = media.view.Toolbar.Insert.extend({ 1775 initialize: function() { 1776 var selectionToLibrary = function( state, filter ) { 1777 return function() { 1778 var controller = this.controller, 1779 selection = controller.state().get('selection'), 1780 edit = controller.get( state ), 1781 models = filter ? filter( selection ) : selection.models; 1782 1783 edit.set( 'library', new media.model.Selection( models, { 1784 props: selection.props.toJSON(), 1785 multiple: true 1786 }) ); 1787 1788 this.controller.state( state ); 1789 }; 1790 }; 1791 1792 this.options.items = _.defaults( this.options.items || {}, { 1777 }, 1778 1793 1779 gallery: { 1794 1780 text: l10n.createNewGallery, … … 1806 1792 }); 1807 1793 1808 media.view.Toolbar. Insert.prototype.initialize.apply( this, arguments );1794 media.view.Toolbar.prototype.initialize.apply( this, arguments ); 1809 1795 }, 1810 1796 … … 1813 1799 count = selection.length; 1814 1800 1815 // Call the parent's `refresh()` method. 1816 media.view.Toolbar.Insert.prototype.refresh.apply( this, arguments ); 1801 this.get('insert').model.set( 'disabled', ! selection.length ); 1817 1802 1818 1803 // Check if every attachment in the selection is an image.
Note: See TracChangeset
for help on using the changeset viewer.