Make WordPress Core

Changeset 22053


Ignore:
Timestamp:
09/27/2012 07:45:26 AM (14 years ago)
Author:
koopersmith
Message:

Add quick insert buttons to attachment views in the library and remove buttons to attachment views in the gallery editor. see #21390, #21809.

Location:
trunk/wp-includes
Files:
3 edited

Legend:

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

    r22046 r22053  
    294294        margin: 0 auto;
    295295        box-shadow: inset 0 0 0 1px rgba( 0, 0, 0, 0.4 );
     296}
     297
     298.attachment .insert {
     299        display: none;
     300        position: absolute;
     301        left: 7px;
     302        bottom: 7px;
     303}
     304
     305.attachment:hover .insert {
     306        display: block;
     307}
     308
     309.attachment .close {
     310        /*display: none;*/
     311        position: absolute;
     312        top: 0;
     313        right: 0;
     314        height: 26px;
     315        width: 26px;
     316        font-size: 20px;
     317        line-height: 24px;
     318        text-align: center;
     319        text-decoration: none;
     320        color: #464646;
     321        background: #fff;
     322}
     323
     324.attachment:hover .close {
     325        display: block;
    296326}
    297327
  • trunk/wp-includes/js/media-views.js

    r22046 r22053  
    379379                },
    380380
     381                buttons: {},
     382
    381383                initialize: function() {
    382384                        this.controller = this.options.controller;
    … …  
    386388                        this.model.on( 'add', this.select, this );
    387389                        this.model.on( 'remove', this.deselect, this );
     390
     391                        // Prevent default navigation on all links.
     392                        this.$el.on( 'click', 'a', this.preventDefault );
    388393                },
    389394
    … …  
    395400                                        orientation: attachment.orientation || 'landscape',
    396401                                        type:        attachment.type,
    397                                         subtype:     attachment.subtype
     402                                        subtype:     attachment.subtype,
     403                                        buttons:     this.buttons
    398404                                };
    399405
    … …  
    446452
    447453                        this.$el.removeClass('selected');
     454                },
     455
     456                preventDefault: function( event ) {
     457                        event.preventDefault();
    448458                }
    449459        });
    … …  
    453463         */
    454464        media.view.Attachment.Library = media.view.Attachment.extend({
    455                 className: 'attachment library'
     465                className: 'attachment library',
     466
     467                buttons: {
     468                        insert: true
     469                },
     470
     471                events: _.defaults({
     472                        'click .insert': 'insert'
     473                }, media.view.Attachment.prototype.events ),
     474
     475                insert: function() {
     476                        this.controller.selection.reset([ this.model ]);
     477                        this.controller.update();
     478                }
    456479        });
    457480
    … …  
    460483         */
    461484        media.view.Attachment.Gallery = media.view.Attachment.extend({
    462                 events: {}
     485                buttons: {
     486                        close: true
     487                },
     488
     489                events: {
     490                        'click .close': 'toggleSelection'
     491                }
    463492        });
    464493
  • trunk/wp-includes/media.php

    r22043 r22053  
    14001400                                <div class="media-progress-bar"><div></div></div>
    14011401                        <% } %>
    1402                         <div class="actions"></div>
     1402
     1403                        <% if ( buttons.close ) { %>
     1404                                <a class="close" href="#">&times;</a>
     1405                        <% } %>
     1406
     1407                        <% if ( buttons.insert ) { %>
     1408                                <a class="insert button button-primary button-small" href="#"><?php _e( 'Insert' ); ?></a>
     1409                        <% } %>
    14031410                </div>
    14041411                <div class="describe"></div>
Note: See TracChangeset for help on using the changeset viewer.