Changeset 22155
- Timestamp:
- 10/10/2012 08:31:12 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/js/media-upload.js
r22120 r22155 91 91 // ----------------------------- 92 92 (function($){ 93 // Stores the editors' `wp.media.controller.Workflow` insta ces.93 // Stores the editors' `wp.media.controller.Workflow` instances. 94 94 var workflows = {}; 95 95 -
trunk/wp-includes/js/mce-view.js
r22140 r22155 547 547 548 548 shortcode: function( attachments ) { 549 var attrs = _.pick( attachments.props.toJSON(), 'include', 'exclude', 'orderby', 'order' ), 549 var props = attachments.props.toJSON(), 550 attrs = _.pick( props, 'include', 'exclude', 'orderby', 'order' ), 550 551 shortcode; 551 552 … … 558 559 }); 559 560 560 galleries[ shortcode.string() ] = attachments; 561 // Use a cloned version of the gallery. 562 galleries[ shortcode.string() ] = new wp.media.model.Attachments( attachments.models, { 563 props: props 564 }); 565 561 566 return shortcode; 562 567 } … … 575 580 576 581 events: { 577 'click .close': 'remove' 582 'click .close': 'remove', 583 'click .edit': 'edit' 578 584 }, 579 585 580 586 initialize: function() { 581 var view = mceview.get('gallery'), 582 shortcode = this.options.shortcode; 583 584 this.attachments = view.gallery.attachments( shortcode, this.parent ); 587 this.update(); 588 }, 589 590 update: function() { 591 var view = mceview.get('gallery'); 592 593 this.attachments = view.gallery.attachments( this.options.shortcode, this.parent ); 585 594 this.attachments.more().done( _.bind( this.render, this ) ); 586 595 }, … … 602 611 603 612 this.$el.html( this.template( options ) ); 613 }, 614 615 edit: function() { 616 if ( ! wp.media.view || this.workflow ) 617 return; 618 619 this.workflow = wp.media({ 620 view: 'gallery', 621 selection: this.attachments.models, 622 title: mceview.l10n.editGallery, 623 editing: true, 624 multiple: true 625 }); 626 627 // Create a single-use workflow. If the workflow is closed, 628 // then detach it from the DOM and remove the reference. 629 this.workflow.on( 'close', function() { 630 this.workflow.detach(); 631 delete this.workflow; 632 }, this ); 633 634 // Update the `shortcode` and `attachments`. 635 this.workflow.on( 'update:gallery', function( selection ) { 636 var view = mceview.get('gallery'); 637 638 this.options.shortcode = view.gallery.shortcode( selection ); 639 this.update(); 640 }, this ); 604 641 } 605 642 } -
trunk/wp-includes/js/media-views.js
r22143 r22155 120 120 update: function( event ) { 121 121 this.close(); 122 this.trigger( 'update', this.selection );123 this.trigger( 'update:' + event, this.selection );122 this.trigger( 'update', this.selection, this ); 123 this.trigger( 'update:' + event, this.selection, this ); 124 124 this.selection.clear(); 125 125 }, … … 218 218 attach: function() { 219 219 this.$el.appendTo( this.options.container ); 220 this.controller.trigger( 'attach', this.controller ); 220 221 }, 221 222 222 223 detach: function() { 223 224 this.$el.detach(); 225 this.controller.trigger( 'detach', this.controller ); 224 226 }, 225 227 226 228 open: function() { 227 229 this.$el.show(); 230 this.controller.trigger( 'open', this.controller ); 228 231 }, 229 232 230 233 close: function() { 231 234 this.$el.hide(); 235 this.controller.trigger( 'close', this.controller ); 232 236 }, 233 237 … … 278 282 // Otherwise, `jQuery.html()` will unbind their events. 279 283 $( _.pluck( this._views, 'el' ) ).detach(); 280 this.$primary.html( _.pluck( views.primary , 'el' ) );281 this.$secondary.html( _.pluck( views.secondary , 'el' ) );284 this.$primary.html( _.pluck( views.primary || [], 'el' ) ); 285 this.$secondary.html( _.pluck( views.secondary || [], 'el' ) ); 282 286 283 287 return this; … … 737 741 // to test multiple selections. 738 742 initToolbarView: function() { 739 var controller = this.controller; 740 741 this.toolbarView = new media.view.Toolbar({ 742 items: { 743 'return-to-library': { 744 text: l10n.returnToLibrary, 745 priority: -40, 746 747 click: function() { 748 controller.render('library'); 749 } 750 }, 751 752 'insert-gallery-into-post': { 743 var controller = this.controller, 744 editing = controller.get('editing'), 745 items = { 746 'update-gallery': { 753 747 style: 'primary', 754 text: l10n.insertGalleryIntoPost,748 text: editing ? l10n.updateGallery : l10n.insertGalleryIntoPost, 755 749 priority: 40, 756 750 click: _.bind( controller.update, controller, 'gallery' ) … … 761 755 priority: 30 762 756 } 763 } 757 }; 758 759 if ( ! editing ) { 760 items['return-to-library'] = { 761 text: l10n.returnToLibrary, 762 priority: -40, 763 764 click: function() { 765 controller.render('library'); 766 } 767 }; 768 } 769 770 this.toolbarView = new media.view.Toolbar({ 771 items: items 764 772 }); 765 773 -
trunk/wp-includes/script-loader.php
r22129 r22155 331 331 'returnToLibrary' => __( 'Return to media library' ), 332 332 'insertGalleryIntoPost' => __( 'Insert gallery into post' ), 333 'updateGallery' => __( 'Update gallery' ), 333 334 'addImagesFromLibrary' => __( 'Add images from media library' ), 334 335 ) ); … … 338 339 did_action( 'init' ) && $scripts->localize( 'mce-view', '_wpMceViewL10n', array( 339 340 'contentWidth' => isset( $GLOBALS['content_width'] ) ? $GLOBALS['content_width'] : 800, 341 'editGallery' => __( 'Edit Gallery' ), 340 342 ) ); 341 343
Note: See TracChangeset
for help on using the changeset viewer.