Make WordPress Core

Ticket #31522: 31522.2.patch

File 31522.2.patch, 9.5 KB (added by afercia, 10 years ago)

Adds labels for the buttons "close" status.

  • src/wp-includes/js/quicktags.js

     
    330330         * @param string arg2 Optional. Ending tag like "</span>"
    331331         * @param string access_key Deprecated Not used
    332332         * @param string title Optional. Button's title="..."
     333         * @param string ariaLabel Optional. Button's aria-label="..."
     334         * @param string ariaLabelClose Optional. Button's aria-label for "close tag" status
    333335         * @param int priority Optional. Number representing the desired position of the button in the toolbar. 1 - 9 = first, 11 - 19 = second, 21 - 29 = third, etc.
    334336         * @param string instance Optional. Limit the button to a specific instance of Quicktags, add to all instances if not present.
    335337         * @return mixed null or the button object that is needed for back-compat.
    336338         */
    337         qt.addButton = function( id, display, arg1, arg2, access_key, title, priority, instance ) {
     339        qt.addButton = function( id, display, arg1, arg2, access_key, title, ariaLabel, ariaLabelClose, priority, instance ) {
    338340                var btn;
    339341
    340342                if ( !id || !display ) {
     
    345347                arg2 = arg2 || '';
    346348
    347349                if ( typeof(arg1) === 'function' ) {
    348                         btn = new qt.Button(id, display, access_key, title, instance);
     350                        btn = new qt.Button(id, display, access_key, title, ariaLabel, ariaLabelClose, instance);
    349351                        btn.callback = arg1;
    350352                } else if ( typeof(arg1) === 'string' ) {
    351                         btn = new qt.TagButton(id, display, arg1, arg2, access_key, title, instance);
     353                        btn = new qt.TagButton(id, display, arg1, arg2, access_key, title, ariaLabel, ariaLabelClose, instance);
    352354                } else {
    353355                        return;
    354356                }
     
    404406        };
    405407
    406408        // a plain, dumb button
    407         qt.Button = function(id, display, access, title, instance) {
     409        qt.Button = function(id, display, access, title, ariaLabel, ariaLabelClose, instance) {
    408410                var t = this;
    409411                t.id = id;
    410412                t.display = display;
    411413                t.access = '';
    412414                t.title = title || '';
     415                t.ariaLabel = ariaLabel || '';
     416                t.ariaLabelClose = ariaLabelClose || '';
    413417                t.instance = instance || '';
    414418        };
    415419        qt.Button.prototype.html = function(idPrefix) {
    416420                var title = this.title ? ' title="' + this.title + '"' : '',
     421                        ariaLabel = this.ariaLabel ? ' aria-label="' + this.ariaLabel + '"' : '',
    417422                        active, on, wp,
    418423                        dfw = ( wp = window.wp ) && wp.editor && wp.editor.dfw;
    419424
    420425                if ( this.id === 'fullscreen' ) {
    421                         return '<button type="button" id="' + idPrefix + this.id + '" class="ed_button qt-dfw qt-fullscreen"' + title + '></button>';
     426                        return '<button type="button" id="' + idPrefix + this.id + '" class="ed_button qt-dfw qt-fullscreen"' + title + ariaLabel + '></button>';
    422427                } else if ( this.id === 'dfw' ) {
    423428                        active = dfw && dfw.isActive() ? '' : ' disabled="disabled"';
    424429                        on = dfw && dfw.isOn() ? ' active' : '';
    425430
    426                         return '<button type="button" id="' + idPrefix + this.id + '" class="ed_button qt-dfw' + on + '"' + title + active + '></button>';
     431                        return '<button type="button" id="' + idPrefix + this.id + '" class="ed_button qt-dfw' + on + '"' + title + ariaLabel + active + '></button>';
    427432                }
    428433
    429                 return '<input type="button" id="' + idPrefix + this.id + '" class="ed_button button button-small"' + title + ' value="' + this.display + '" />';
     434                return '<input type="button" id="' + idPrefix + this.id + '" class="ed_button button button-small"' + title + ariaLabel + ' value="' + this.display + '" />';
    430435        };
    431436        qt.Button.prototype.callback = function(){};
    432437
    433438        // a button that inserts HTML tag
    434         qt.TagButton = function(id, display, tagStart, tagEnd, access, title, instance) {
     439        qt.TagButton = function( id, display, tagStart, tagEnd, access, title, ariaLabel, ariaLabelClose, instance ) {
    435440                var t = this;
    436                 qt.Button.call(t, id, display, access, title, instance);
     441                qt.Button.call( t, id, display, access, title, ariaLabel, ariaLabelClose, instance );
    437442                t.tagStart = tagStart;
    438443                t.tagEnd = tagEnd;
    439444        };
     
    447452                if ( t.tagEnd ) {
    448453                        ed.openTags.push(t.id);
    449454                        e.value = '/' + e.value;
     455                        e.setAttribute( 'aria-label', t.ariaLabelClose );
    450456                }
    451457        };
    452458        qt.TagButton.prototype.closeTag = function(e, ed) {
     
    457463                }
    458464
    459465                e.value = t.display;
     466                e.setAttribute( 'aria-label', t.ariaLabel );
    460467        };
    461468        // whether a tag is open or not. Returns false if not open, or current open depth of the tag
    462469        qt.TagButton.prototype.isOpen = function (ed) {
     
    549556
    550557        // the close tags button
    551558        qt.CloseButton = function() {
    552                 qt.Button.call(this, 'close', quicktagsL10n.closeTags, '', quicktagsL10n.closeAllOpenTags);
     559                qt.Button.call(this, 'close', quicktagsL10n.closeTags, '', '', quicktagsL10n.closeAllOpenTags);
    553560        };
    554561
    555562        qt.CloseButton.prototype = new qt.Button();
     
    580587
    581588        // the link button
    582589        qt.LinkButton = function() {
    583                 qt.TagButton.call(this, 'link', 'link', '', '</a>');
     590                qt.TagButton.call(this, 'link', 'link', '', '</a>', '', '', quicktagsL10n.link);
    584591        };
    585592        qt.LinkButton.prototype = new qt.TagButton();
    586593        qt.LinkButton.prototype.callback = function(e, c, ed, defaultValue) {
     
    608615
    609616        // the img button
    610617        qt.ImgButton = function() {
    611                 qt.TagButton.call(this, 'img', 'img', '', '');
     618                qt.TagButton.call(this, 'img', 'img', '', '', '', '', quicktagsL10n.image);
    612619        };
    613620        qt.ImgButton.prototype = new qt.TagButton();
    614621        qt.ImgButton.prototype.callback = function(e, c, ed, defaultValue) {
     
    666673        };
    667674
    668675        // ensure backward compatibility
    669         edButtons[10] = new qt.TagButton('strong','b','<strong>','</strong>');
    670         edButtons[20] = new qt.TagButton('em','i','<em>','</em>'),
     676        edButtons[10] = new qt.TagButton('strong','b','<strong>','</strong>','','',quicktagsL10n.strong,quicktagsL10n.strongClose);
     677        edButtons[20] = new qt.TagButton('em','i','<em>','</em>','','',quicktagsL10n.emphasized,quicktagsL10n.emphasizedClose),
    671678        edButtons[30] = new qt.LinkButton(), // special case
    672         edButtons[40] = new qt.TagButton('block','b-quote','\n\n<blockquote>','</blockquote>\n\n'),
    673         edButtons[50] = new qt.TagButton('del','del','<del datetime="' + _datetime + '">','</del>'),
    674         edButtons[60] = new qt.TagButton('ins','ins','<ins datetime="' + _datetime + '">','</ins>'),
     679        edButtons[40] = new qt.TagButton('block','b-quote','\n\n<blockquote>','</blockquote>\n\n','','',quicktagsL10n.blockquote,quicktagsL10n.blockquoteClose),
     680        edButtons[50] = new qt.TagButton('del','del','<del datetime="' + _datetime + '">','</del>','','',quicktagsL10n.deletion,quicktagsL10n.deletionClose),
     681        edButtons[60] = new qt.TagButton('ins','ins','<ins datetime="' + _datetime + '">','</ins>','','',quicktagsL10n.insertion,quicktagsL10n.insertionClose),
    675682        edButtons[70] = new qt.ImgButton(), // special case
    676         edButtons[80] = new qt.TagButton('ul','ul','<ul>\n','</ul>\n\n'),
    677         edButtons[90] = new qt.TagButton('ol','ol','<ol>\n','</ol>\n\n'),
    678         edButtons[100] = new qt.TagButton('li','li','\t<li>','</li>\n'),
    679         edButtons[110] = new qt.TagButton('code','code','<code>','</code>'),
    680         edButtons[120] = new qt.TagButton('more','more','<!--more-->\n\n',''),
     683        edButtons[80] = new qt.TagButton('ul','ul','<ul>\n','</ul>\n\n','','',quicktagsL10n.bulllist,quicktagsL10n.bulllistClose),
     684        edButtons[90] = new qt.TagButton('ol','ol','<ol>\n','</ol>\n\n','','',quicktagsL10n.numlist,quicktagsL10n.numlistClose),
     685        edButtons[100] = new qt.TagButton('li','li','\t<li>','</li>\n','','',quicktagsL10n.listitem,quicktagsL10n.listitemClose),
     686        edButtons[110] = new qt.TagButton('code','code','<code>','</code>','','',quicktagsL10n.code,quicktagsL10n.codeClose),
     687        edButtons[120] = new qt.TagButton('more','more','<!--more-->\n\n','','','',quicktagsL10n.more),
    681688        edButtons[140] = new qt.CloseButton();
    682689
    683690})();
  • src/wp-includes/script-loader.php

     
    9797                'toggleFullscreen'      => esc_attr__( 'Toggle fullscreen mode' ),
    9898                'textdirection'         => esc_attr__( 'text direction' ),
    9999                'toggleTextdirection'   => esc_attr__( 'Toggle Editor Text Direction' ),
    100                 'dfw'                   => esc_attr__( 'Distraction-free writing mode' )
     100                'dfw'                   => esc_attr__( 'Distraction-free writing mode' ),
     101                'strong'                => esc_attr__( 'Bold' ),
     102                'strongClose'           => esc_attr__( 'Close bold tag' ),
     103                'emphasized'            => esc_attr__( 'Italic' ),
     104                'emphasizedClose'       => esc_attr__( 'Close italic tag' ),
     105                'link'                  => esc_attr__( 'Insert link' ),
     106                'blockquote'            => esc_attr__( 'Blockquote' ),
     107                'blockquoteClose'       => esc_attr__( 'Close blockquote tag' ),
     108                'deletion'              => esc_attr__( 'Deleted text (strikethrough)' ),
     109                'deletionClose'         => esc_attr__( 'Close deleted text tag' ),
     110                'insertion'             => esc_attr__( 'Added text' ),
     111                'insertionClose'        => esc_attr__( 'Close added text tag' ),
     112                'image'                 => esc_attr__( 'Insert image' ),
     113                'bulllist'              => esc_attr__( 'Bulleted list' ),
     114                'bulllistClose'         => esc_attr__( 'Close bulleted list tag' ),
     115                'numlist'               => esc_attr__( 'Numbered list' ),
     116                'numlistClose'          => esc_attr__( 'Close numbered list tag' ),
     117                'listitem'              => esc_attr__( 'List item' ),
     118                'listitemClose'         => esc_attr__( 'Close list item tag' ),
     119                'code'                  => esc_attr__( 'Code' ),
     120                'codeClose'             => esc_attr__( 'Close code tag' ),
     121                'more'                  => esc_attr__( 'Insert Read More tag' ),
    101122        ) );
    102123
    103124        $scripts->add( 'colorpicker', "/wp-includes/js/colorpicker$suffix.js", array('prototype'), '3517m' );