WordPress.org

Making WordPress.org

Changeset 3316


Ignore:
Timestamp:
06/07/2016 07:28:51 PM (5 years ago)
Author:
coffee2code
Message:

developer.wordpress.org: In textarea for user notes, make the 'tab' key insert a tab.

Adapts JS code, behavior, and help string from core. It is still possible to navigate out of the field by first pressing escape (sometimes twice), then tab.

Also sets tab-size to match that used on display.

Props afercia for insight.
Fixes #626.

Location:
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/comments.php

    r1687 r3316  
    7070                '</p><p>' .
    7171                __( 'You can enter text and code. Use the php, js, or inline code buttons to wrap code snippets.', 'wporg' ) .
     72                '</p><p>' .
     73                __( 'In the editing area the Tab key enters a tab character. To move below this area by pressing Tab, press the Esc key followed by the Tab key. In some cases the Esc key will need to be pressed twice before the Tab key will allow you to continue.', 'wporg' ) .
    7274                '</p><p class="user-notes-are-gpl">' .
    7375                sprintf( __( '<strong>NOTE:</strong> All contributions are licensed under <a href="%s">GFDL</a> and are moderated before appearing on the site.', 'wporg' ), 'https://gnu.org/licenses/fdl.html' ) .
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/js/user-notes.js

    r1675 r3316  
    3737    QTags.addButton( 'inline-code', 'inline code', '<code>', '</code>' );
    3838
     39    // Override tab within user notes textarea to actually insert a tab character.
     40    // Copied from code within core's wp-admin/js/common.js.
     41    $('.comment-form textarea').bind('keydown.wpevent_InsertTab', function(e) {
     42        var el = e.target, selStart, selEnd, val, scroll, sel;
     43
     44        if ( e.keyCode == 27 ) { // escape key
     45            // when pressing Escape: Opera 12 and 27 blur form fields, IE 8 clears them
     46            e.preventDefault();
     47            $(el).data('tab-out', true);
     48            return;
     49        }
     50
     51        if ( e.keyCode != 9 || e.ctrlKey || e.altKey || e.shiftKey ) // tab key
     52            return;
     53
     54        if ( $(el).data('tab-out') ) {
     55            $(el).data('tab-out', false);
     56            return;
     57        }
     58
     59        selStart = el.selectionStart;
     60        selEnd = el.selectionEnd;
     61        val = el.value;
     62
     63        if ( document.selection ) {
     64            el.focus();
     65            sel = document.selection.createRange();
     66            sel.text = '\t';
     67        } else if ( selStart >= 0 ) {
     68            scroll = this.scrollTop;
     69            el.value = val.substring(0, selStart).concat('\t', val.substring(selEnd) );
     70            el.selectionStart = el.selectionEnd = selStart + 1;
     71            this.scrollTop = scroll;
     72        }
     73
     74        if ( e.stopPropagation )
     75            e.stopPropagation();
     76        if ( e.preventDefault )
     77            e.preventDefault();
     78    });
     79
    3980} )( jQuery );
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/scss/main.scss

    r3245 r3316  
    243243        overflow: auto; /* Removes default vertical scrollbar in IE6/7/8/9 */
    244244        padding-left: 3px;
     245        tab-size: 4;
    245246        vertical-align: top; /* Improves readability and alignment in all browsers */
    246247        width: 98%;
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/stylesheets/main.css

    r3245 r3316  
    556556  /* Removes default vertical scrollbar in IE6/7/8/9 */
    557557  padding-left: 3px;
     558  tab-size: 4;
    558559  vertical-align: top;
    559560  /* Improves readability and alignment in all browsers */
Note: See TracChangeset for help on using the changeset viewer.