Make WordPress Core

Changeset 22157


Ignore:
Timestamp:
10/10/2012 09:30:22 AM (14 years ago)
Author:
koopersmith
Message:

When editing a gallery, images can now be added from the media library.

Enables the "Add images from media library" button when editing. The UX has room for improvement, but it's a start.

see #21390, #21809.

Location:
trunk/wp-includes
Files:
3 edited

Legend:

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

    r22155 r22157  
    4343                        this.add( 'library', media.view.Workspace.Library, {
    4444                                collection: media.query( this.get('library') )
    45                         } );
     45                        });
    4646                        this.unset('library');
    4747
    4848                        // Add the gallery view.
    49                         this.add( 'gallery', media.view.Workspace.Gallery, { collection: this.selection } );
     49                        this.add( 'gallery', media.view.Workspace.Gallery, {
     50                                collection: this.selection
     51                        });
     52                        this.add( 'gallery-library', media.view.Workspace.Library.Gallery, {
     53                                collection: media.query({ type: 'image' })
     54                        });
    5055                },
    5156
    … …  
    720725        });
    721726
     727        media.view.Workspace.Library.Gallery = media.view.Workspace.Library.extend({
     728                initToolbarView: function() {
     729                        var controller = this.controller,
     730                                editing = controller.get('editing'),
     731                                items = {
     732                                        'selection-preview': new media.view.SelectionPreview({
     733                                                controller: this.controller,
     734                                                collection: this.controller.selection,
     735                                                priority:   -40,
     736                                                clearable:  false
     737                                        }),
     738
     739                                        'continue-editing-gallery': {
     740                                                style:    'primary',
     741                                                text:     l10n.continueEditingGallery,
     742                                                priority: 40,
     743
     744                                                click: function() {
     745                                                        controller.render( 'gallery' );
     746                                                }
     747                                        }
     748                                };
     749
     750                        this.toolbarView = new media.view.Toolbar({
     751                                items: items
     752                        });
     753
     754                        this.$el.addClass('with-toolbar');
     755                        this.$content.append( this.toolbarView.$el );
     756                }
     757        });
     758
    722759        /**
    723760         * wp.media.view.Workspace.Gallery
    … …  
    751788                                        },
    752789
    753                                         'add-images-from-library': {
    754                                                 text:     l10n.addImagesFromLibrary,
    755                                                 priority: 30
     790                                        'return-to-library': {
     791                                                text:     editing ? l10n.addImagesFromLibrary : l10n.returnToLibrary,
     792                                                priority: -40,
     793
     794                                                click: function() {
     795                                                        controller.render( editing ? 'gallery-library' : 'library' );
     796                                                }
    756797                                        }
    757798                                };
    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                         }
    769799
    770800                        this.toolbarView = new media.view.Toolbar({
    … …  
    949979
    950980                initialize: function() {
     981                        _.defaults( this.options, {
     982                                clearable: true
     983                        });
     984
    951985                        this.controller = this.options.controller;
    952986                        this.collection.on( 'add change:url remove', this.render, this );
    … …  
    955989
    956990                render: function() {
    957                         var options = {},
     991                        var options = _.clone( this.options ),
    958992                                first, sizes, amount;
    959993
  • trunk/wp-includes/media.php

    r22154 r22157  
    13591359                        <span class="count"><%- count %></span>
    13601360                </div>
    1361                 <a class="clear-selection" href="#"><?php _e('Clear selection'); ?></a>
     1361                <% if ( clearable ) { %>
     1362                        <a class="clear-selection" href="#"><?php _e('Clear selection'); ?></a>
     1363                <% } %>
    13621364        </script>
    13631365
  • trunk/wp-includes/script-loader.php

    r22155 r22157  
    329329
    330330                // Gallery
    331                 'returnToLibrary'       => __( 'Return to media library' ),
    332                 'insertGalleryIntoPost' => __( 'Insert gallery into post' ),
    333                 'updateGallery'         => __( 'Update gallery' ),
    334                 'addImagesFromLibrary'  => __( 'Add images from media library' ),
     331                'returnToLibrary'        => __( 'Return to media library' ),
     332                'continueEditingGallery' => __( 'Continue editing gallery' ),
     333                'insertGalleryIntoPost'  => __( 'Insert gallery into post' ),
     334                'updateGallery'          => __( 'Update gallery' ),
     335                'addImagesFromLibrary'   => __( 'Add images from media library' ),
    335336        ) );
    336337
Note: See TracChangeset for help on using the changeset viewer.