Make WordPress Core

Ticket #27403: 27403.3.diff

File 27403.3.diff, 4.0 KB (added by sirbrillig, 9 years ago)

Updated patch to include icon removal

  • src/wp-includes/css/customize-preview.css

     
    1010        -webkit-box-shadow: none;
    1111        box-shadow: none;
    1212}
     13
     14.customize-partial-icon {
     15        fill: #fff;
     16        width: 30px;
     17        height: 30px;
     18        font-size: 18px;
     19        z-index: 5;
     20        background: #0087BE;
     21        border-radius: 50%;
     22        border: 2px solid #fff;
     23        box-shadow: 0 2px 1px rgba(46,68,83,0.15);
     24        text-align: center;
     25        display: flex;
     26        flex-direction: row;
     27        justify-content: center;
     28        align-items: center;
     29        cursor: pointer;
     30        animation-name: bounce-appear;
     31        animation-delay: 0.8s;
     32        animation-duration: 1s;
     33        animation-fill-mode: both;
     34        animation-duration: .75s;
     35        padding: 0;
     36}
     37
     38.customize-partial-icon svg {
     39        width: 18px;
     40        height: 18px;
     41}
     42
     43@keyframes bounce-appear {
     44        from, 20%, 40%, 60%, 80%, to {
     45                animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
     46        }
     47        0% {
     48                opacity: 0;
     49                transform: scale3d(.3, .3, .3);
     50        }
     51        20% {
     52                transform: scale3d(1.1, 1.1, 1.1);
     53        }
     54        40% {
     55                transform: scale3d(.9, .9, .9);
     56        }
     57        60% {
     58                opacity: 1;
     59                transform: scale3d(1.03, 1.03, 1.03);
     60        }
     61        80% {
     62                transform: scale3d(.97, .97, .97);
     63        }
     64        to {
     65                opacity: 1;
     66                transform: scale3d(1, 1, 1);
     67        }
     68}
  • src/wp-includes/js/customize-selective-refresh.js

     
    1919
    2020        _.extend( self, api.Events );
    2121
     22        // Extend jQuery to notice element removal and call the 'destroyed' event
     23        $.event.special.destroyed = {
     24                remove: function( o ) {
     25                        if ( o.handler ) {
     26                                o.handler();
     27                        }
     28                }
     29        };
    2230        /**
    2331         * A Customizer Partial.
    2432         *
     
    8593                        var partial = this;
    8694                        _.each( _.pluck( partial.placements(), 'container' ), function( container ) {
    8795                                $( container ).attr( 'title', self.data.l10n.shiftClickToEdit );
     96                                // TODO: newly added widgets have no placements and so get no icon
     97                                partial.showEditIconForElement( container );
    8898                        } );
    8999                        $( document ).on( 'click', partial.params.selector, function( e ) {
    90100                                if ( ! e.shiftKey ) {
     
    100110                },
    101111
    102112                /**
     113                 * Create and show the edit icon for this element.
     114                 */
     115                showEditIconForElement: function( element ) {
     116                        var partial = this;
     117                        var $icon = this.createEditIcon();
     118                        // TODO: hide icon when sidebar is collapsed
     119                        $( element ).before( $icon );
     120                        $icon.on( 'click', partial.showControl.bind( this ) );
     121                        $( element ).on( 'destroyed', function() {
     122                                $icon.remove();
     123                        } );
     124                },
     125
     126                getIconClassName: function() {
     127                        var partial = this;
     128                        var cleanId = partial.id.replace( /\]/g, '' ).replace( /\[/g, '-' );
     129                        return 'customize-partial-icon-' + cleanId;
     130                },
     131
     132                createEditIcon: function() {
     133                        // TODO: get translated text for title/hover text
     134                        var editIconSource = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><rect x="0" fill="none" width="24" height="24"/><g><path d="M13 6l5 5-9.507 9.507c-.686-.686-.69-1.794-.012-2.485l-.002-.003c-.69.676-1.8.673-2.485-.013-.677-.677-.686-1.762-.036-2.455l-.008-.008c-.694.65-1.78.64-2.456-.036L13 6zm7.586-.414l-2.172-2.172c-.78-.78-2.047-.78-2.828 0L14 5l5 5 1.586-1.586c.78-.78.78-2.047 0-2.828zM3 18v3h3c0-1.657-1.343-3-3-3z"/></g></svg>';
     135                        return $( '<button aria-label="edit" type="button" class="customize-partial-icon ' + this.getIconClassName() + '">' + editIconSource + '</button>' );
     136                },
     137
     138                /**
    103139                 * Find all placements for this partial int he document.
    104140                 *
    105141                 * @since 4.5.0
     
    180216                        if ( ! settingId ) {
    181217                                settingId = _.first( partial.settings() );
    182218                        }
     219                        if ( settingId.match( /^nav_menu_instance/ ) ) {
     220                                var menuSlug = partial.params.navMenuArgs.theme_location;
     221                                if ( menuSlug ) {
     222                                        settingId = 'nav_menu_locations[' + menuSlug + ']';
     223                                }
     224                        }
    183225                        api.preview.send( 'focus-control-for-setting', settingId );
    184226                },
    185227