Make WordPress Core

Ticket #38667: 38667.0.diff

File 38667.0.diff, 2.4 KB (added by westonruter, 8 years ago)
  • src/wp-admin/css/customize-controls.css

    diff --git src/wp-admin/css/customize-controls.css src/wp-admin/css/customize-controls.css
    index 2841557..a057532 100644
    p.customize-section-description { 
    11291129        margin-left: 10px;
    11301130        margin-right: 10px;
    11311131}
     1132#customize-theme-controls #sub-accordion-section-custom_css textarea {
     1133        tab-size: 4;
     1134}
    11321135
    11331136#sub-accordion-section-custom_css .customize-control-notifications-container {
    11341137        margin-bottom: 15px;
  • src/wp-admin/js/customize-controls.js

    diff --git src/wp-admin/js/customize-controls.js src/wp-admin/js/customize-controls.js
    index 30e98ea..b20180a 100644
     
    52345234                        });
    52355235                });
    52365236
     5237                // Allow tabs to be entered in Custom CSS textarea.
     5238                api.control( 'custom_css', function ( control ) {
     5239                        control.deferred.embedded.done( function allowTabs() {
     5240                                control.container.find( 'textarea' ).on( 'keydown', function onKeydown( event ) {
     5241                                        var textarea = this, selStart, selEnd, val, scroll, sel;
     5242
     5243                                        if ( 27 === event.keyCode ) { // Escape key.
     5244                                                // When pressing Escape: Opera 12 and 27 blur form fields, IE 8 clears them.
     5245                                                event.preventDefault();
     5246
     5247                                                if ( true !== $( textarea ).data( 'tab-out' ) ) {
     5248                                                        $( textarea ).data( 'tab-out', true );
     5249                                                        event.stopPropagation(); // Prevent collapsing the section.
     5250                                                }
     5251                                                return;
     5252                                        }
     5253
     5254                                        if ( 9 !== event.keyCode || event.ctrlKey || event.altKey || event.shiftKey ) { // Tab key.
     5255                                                return;
     5256                                        }
     5257
     5258                                        if ( $( textarea ).data( 'tab-out' ) ) {
     5259                                                $( textarea ).data( 'tab-out', false );
     5260                                                return;
     5261                                        }
     5262
     5263                                        selStart = textarea.selectionStart;
     5264                                        selEnd = textarea.selectionEnd;
     5265                                        val = textarea.value;
     5266
     5267                                        if ( document.selection ) {
     5268                                                textarea.focus();
     5269                                                sel = document.selection.createRange();
     5270                                                sel.text = '\t';
     5271                                        } else if ( selStart >= 0 ) {
     5272                                                scroll = textarea.scrollTop;
     5273                                                textarea.value = val.substring( 0, selStart ).concat( '\t', val.substring( selEnd ) );
     5274                                                textarea.selectionStart = textarea.selectionEnd = selStart + 1;
     5275                                                textarea.scrollTop = scroll;
     5276                                        }
     5277
     5278                                        event.stopPropagation();
     5279                                        event.preventDefault();
     5280                                } );
     5281                        } );
     5282                } );
     5283
    52375284                // Update the setting validities.
    52385285                api.previewer.bind( 'selective-refresh-setting-validities', function handleSelectiveRefreshedSettingValidities( settingValidities ) {
    52395286                        api._handleSettingValidities( {