Make WordPress Core

Ticket #31334: 31334.2.diff

File 31334.2.diff, 2.1 KB (added by westonruter, 10 years ago)

Define container removal in customize-controls.js, and use in customize-widgets.js

  • src/wp-admin/js/customize-controls.js

    diff --git src/wp-admin/js/customize-controls.js src/wp-admin/js/customize-controls.js
    index e211a41..89a977a 100644
     
    11/* globals _wpCustomizeHeader, _wpCustomizeBackground, _wpMediaViewsL10n, MediaElementPlayer */
    22(function( exports, $ ){
    3         var Container, focus, api = wp.customize;
     3        var Container, focus, removeContainer, api = wp.customize;
    44
    55        /**
    66         * @class
     
    20602060        // Change objects contained within the main customize object to Settings.
    20612061        api.defaultConstructor = api.Setting;
    20622062
     2063        /**
     2064         * Remove a Control, Section, or Panel's container when it is removed from its Values collection.
     2065         *
     2066         * @param {string} id
     2067         * @this {wp.customize.Values}
     2068         */
     2069        removeContainer = function ( id ) {
     2070                var value;
     2071                if ( this.has( id ) ) {
     2072                        value = this.value( id );
     2073                        if ( value.container ) {
     2074                                value.container.remove();
     2075                        }
     2076                }
     2077                api.Values.prototype.remove.call( this, id );
     2078        };
     2079
    20632080        // Create the collections for Controls, Sections and Panels.
    2064         api.control = new api.Values({ defaultConstructor: api.Control });
    2065         api.section = new api.Values({ defaultConstructor: api.Section });
    2066         api.panel = new api.Values({ defaultConstructor: api.Panel });
     2081        api.control = new api.Values({ defaultConstructor: api.Control, remove: removeContainer });
     2082        api.section = new api.Values({ defaultConstructor: api.Section, remove: removeContainer });
     2083        api.panel = new api.Values({ defaultConstructor: api.Panel, remove: removeContainer });
    20672084
    20682085        /**
    20692086         * @class
  • src/wp-admin/js/customize-widgets.js

    diff --git src/wp-admin/js/customize-widgets.js src/wp-admin/js/customize-widgets.js
    index 729e6a8..d38299d 100644
     
    15661566                                                // Delete any widget form controls for removed widgets
    15671567                                                if ( removedControl && ! wasDraggedToAnotherSidebar ) {
    15681568                                                        api.control.remove( removedControl.id );
    1569                                                         removedControl.container.remove();
    15701569                                                }
    15711570
    15721571                                                // Move widget to inactive widgets sidebar (move it to trash) if has been previously saved