Make WordPress Core

Changeset 22356


Ignore:
Timestamp:
11/02/2012 01:20:01 AM (14 years ago)
Author:
koopersmith
Message:

Media: Update the gallery "add images" state. see #21390.

Location:
trunk/wp-includes
Files:
2 edited

Legend:

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

    r22348 r22356  
    302302                        }).render() );
    303303                }
     304        });
     305
     306        media.controller.GalleryAddImages = media.controller.Library.extend({
     307                defaults: {
     308                        id:       'gallery:add',
     309                        multiple: true,
     310                        title:    l10n.createGalleryTitle
     311                },
     312
     313                initialize: function() {
     314                        if ( ! this.get('library') )
     315                                this.set( 'library', media.query({ type: 'image' }) );
     316                        return media.controller.Library.prototype.initialize.apply( this, arguments );
     317                },
     318
     319                toolbar: function() {
     320                        var frame = this.frame;
     321
     322                        frame.toolbar( new media.view.Toolbar.GalleryAddImages({
     323                                controller: frame,
     324                                state:      this
     325                        }) );
     326                },
     327
     328                // Leave the sidebar.
     329                sidebar: function() {}
    304330        });
    305331
     
    384410                                        library: options.selection,
    385411                                        editing: options.editing
    386                                 })
     412                                }),
     413                                new media.controller.GalleryAddImages()
    387414                        ]);
    388415
     
    835862                                                controller.close();
    836863                                                state.trigger( 'update', library );
    837                                                 library.clear();
     864                                                controller.get('library').get('selection').clear();
    838865                                                controller.state('library');
     866                                        }
     867                                },
     868
     869                                addImages: {
     870                                        text:     l10n.addImages,
     871                                        priority: -40,
     872
     873                                        click: function() {
     874                                                controller.get('gallery:add').set( 'selection', new media.model.Selection( library.models, {
     875                                                        props:    library.props.toJSON(),
     876                                                        multiple: true
     877                                                }) );
     878                                                controller.state('gallery:add');
    839879                                        }
    840880                                },
     
    849889                                                else
    850890                                                        controller.state('library');
     891                                        }
     892                                }
     893                        };
     894
     895                        media.view.Toolbar.prototype.initialize.apply( this, arguments );
     896                }
     897        });
     898
     899        // wp.media.view.Toolbar.GalleryAddImages
     900        // -----------------------------
     901        media.view.Toolbar.GalleryAddImages = media.view.Toolbar.extend({
     902                initialize: function() {
     903                        var state = this.options.state,
     904                                editing = state.get('editing'),
     905                                library = state.get('library'),
     906                                controller = this.options.controller;
     907
     908                        this.options.items = {
     909                                update: {
     910                                        style:    'primary',
     911                                        text:     l10n.continueEditing,
     912                                        priority: 40,
     913
     914                                        click: function() {
     915                                                controller.get('gallery').set( 'library', state.get('selection') );
     916                                                controller.state('gallery');
     917                                        }
     918                                },
     919
     920                                cancel: {
     921                                        text:     l10n.cancel,
     922                                        priority: -60,
     923
     924                                        click: function() {
     925                                                controller.state('gallery');
    851926                                        }
    852927                                }
  • trunk/wp-includes/script-loader.php

    r22348 r22356  
    339339                'insertGallery'      => __( 'Insert gallery' ),
    340340                'updateGallery'      => __( 'Update gallery' ),
     341                'continueEditing'    => __( 'Continue editing' ),
    341342        ) );
    342343
Note: See TracChangeset for help on using the changeset viewer.