Make WordPress Core

Ticket #31522: 31522.3.patch

File 31522.3.patch, 11.2 KB (added by azaozz, 10 years ago)
  • src/wp-includes/js/quicktags.js

     
    327327         * @param string title Optional. Button's title="..."
    328328         * @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.
    329329         * @param string instance Optional. Limit the button to a specific instance of Quicktags, add to all instances if not present.
     330         * @param attr object Optional. Used to pass additional attributes. Currently supports `ariaLabel` and `ariaLabelClose` (for "close tag" state)
    330331         * @return mixed null or the button object that is needed for back-compat.
    331332         */
    332         qt.addButton = function( id, display, arg1, arg2, access_key, title, priority, instance ) {
     333        qt.addButton = function( id, display, arg1, arg2, access_key, title, priority, instance, attr ) {
    333334                var btn;
    334335
    335336                if ( !id || !display ) {
     
    338339
    339340                priority = priority || 0;
    340341                arg2 = arg2 || '';
     342                attr = attr || {};
    341343
    342344                if ( typeof(arg1) === 'function' ) {
    343                         btn = new qt.Button(id, display, access_key, title, instance);
     345                        btn = new qt.Button( id, display, access_key, title, instance, attr );
    344346                        btn.callback = arg1;
    345347                } else if ( typeof(arg1) === 'string' ) {
    346                         btn = new qt.TagButton(id, display, arg1, arg2, access_key, title, instance);
     348                        btn = new qt.TagButton( id, display, arg1, arg2, access_key, title, instance, attr );
    347349                } else {
    348350                        return;
    349351                }
     
    399401        };
    400402
    401403        // a plain, dumb button
    402         qt.Button = function(id, display, access, title, instance) {
    403                 var t = this;
    404                 t.id = id;
    405                 t.display = display;
    406                 t.access = '';
    407                 t.title = title || '';
    408                 t.instance = instance || '';
     404        qt.Button = function( id, display, access, title, instance, attr ) {
     405                this.id = id;
     406                this.display = display;
     407                this.access = '';
     408                this.title = title || '';
     409                this.instance = instance || '';
     410                this.attr = attr || {};
    409411        };
    410412        qt.Button.prototype.html = function(idPrefix) {
    411                 var title = this.title ? ' title="' + this.title + '"' : '',
    412                         active, on, wp,
     413                var active, on, wp,
     414                        title = this.title ? ' title="' + this.title + '"' : '',
     415                        ariaLabel = this.attr && this.attr.ariaLabel ? ' aria-label="' + this.attr.ariaLabel + '"' : '',
    413416                        dfw = ( wp = window.wp ) && wp.editor && wp.editor.dfw;
    414417
    415418                if ( this.id === 'fullscreen' ) {
    416                         return '<button type="button" id="' + idPrefix + this.id + '" class="ed_button qt-dfw qt-fullscreen"' + title + '></button>';
     419                        return '<button type="button" id="' + idPrefix + this.id + '" class="ed_button qt-dfw qt-fullscreen"' + title + ariaLabel + '></button>';
    417420                } else if ( this.id === 'dfw' ) {
    418421                        active = dfw && dfw.isActive() ? '' : ' disabled="disabled"';
    419422                        on = dfw && dfw.isOn() ? ' active' : '';
    420423
    421                         return '<button type="button" id="' + idPrefix + this.id + '" class="ed_button qt-dfw' + on + '"' + title + active + '></button>';
     424                        return '<button type="button" id="' + idPrefix + this.id + '" class="ed_button qt-dfw' + on + '"' + title + ariaLabel + active + '></button>';
    422425                }
    423426
    424                 return '<input type="button" id="' + idPrefix + this.id + '" class="ed_button button button-small"' + title + ' value="' + this.display + '" />';
     427                return '<input type="button" id="' + idPrefix + this.id + '" class="ed_button button button-small"' + title + ariaLabel + ' value="' + this.display + '" />';
    425428        };
    426429        qt.Button.prototype.callback = function(){};
    427430
    428431        // a button that inserts HTML tag
    429         qt.TagButton = function(id, display, tagStart, tagEnd, access, title, instance) {
     432        qt.TagButton = function( id, display, tagStart, tagEnd, access, title, instance, attr ) {
    430433                var t = this;
    431                 qt.Button.call(t, id, display, access, title, instance);
     434                qt.Button.call( t, id, display, access, title, instance, attr );
    432435                t.tagStart = tagStart;
    433436                t.tagEnd = tagEnd;
    434437        };
    435438        qt.TagButton.prototype = new qt.Button();
    436         qt.TagButton.prototype.openTag = function(e, ed) {
    437                 var t = this;
    438 
     439        qt.TagButton.prototype.openTag = function( element, ed ) {
    439440                if ( ! ed.openTags ) {
    440441                        ed.openTags = [];
    441442                }
    442                 if ( t.tagEnd ) {
    443                         ed.openTags.push(t.id);
    444                         e.value = '/' + e.value;
     443
     444                if ( this.tagEnd ) {
     445                        ed.openTags.push( this.id );
     446                        element.value = '/' + element.value;
     447
     448                        if ( this.attr.ariaLabelClose ) {
     449                                element.setAttribute( 'aria-label', this.attr.ariaLabelClose );
     450                        }
    445451                }
    446452        };
    447         qt.TagButton.prototype.closeTag = function(e, ed) {
    448                 var t = this, i = t.isOpen(ed);
     453        qt.TagButton.prototype.closeTag = function( element, ed ) {
     454                var t = this, i = this.isOpen(ed);
    449455
    450456                if ( i !== false ) {
    451                         ed.openTags.splice(i, 1);
     457                        ed.openTags.splice( i, 1 );
    452458                }
    453459
    454                 e.value = t.display;
     460                element.value = this.display;
     461
     462                if ( this.attr.ariaLabel ) {
     463                        element.setAttribute( 'aria-label', this.attr.ariaLabel );
     464                }
    455465        };
    456466        // whether a tag is open or not. Returns false if not open, or current open depth of the tag
    457467        qt.TagButton.prototype.isOpen = function (ed) {
     
    544554
    545555        // the close tags button
    546556        qt.CloseButton = function() {
    547                 qt.Button.call(this, 'close', quicktagsL10n.closeTags, '', quicktagsL10n.closeAllOpenTags);
     557                qt.Button.call( this, 'close', quicktagsL10n.closeTags, '', quicktagsL10n.closeAllOpenTags );
    548558        };
    549559
    550560        qt.CloseButton.prototype = new qt.Button();
     
    575585
    576586        // the link button
    577587        qt.LinkButton = function() {
    578                 qt.TagButton.call(this, 'link', 'link', '', '</a>');
     588                var attr = {
     589                        ariaLabel: quicktagsL10n.link
     590                };
     591
     592                qt.TagButton.call( this, 'link', 'link', '', '</a>', '', '', '', attr );
    579593        };
    580594        qt.LinkButton.prototype = new qt.TagButton();
    581595        qt.LinkButton.prototype.callback = function(e, c, ed, defaultValue) {
     
    603617
    604618        // the img button
    605619        qt.ImgButton = function() {
    606                 qt.TagButton.call(this, 'img', 'img', '', '');
     620                var attr = {
     621                        ariaLabel: quicktagsL10n.image
     622                };
     623
     624                qt.TagButton.call( this, 'img', 'img', '', '', '', '', '', attr );
    607625        };
    608626        qt.ImgButton.prototype = new qt.TagButton();
    609627        qt.ImgButton.prototype.callback = function(e, c, ed, defaultValue) {
     
    633651        };
    634652
    635653        qt.TextDirectionButton = function() {
    636                 qt.Button.call(this, 'textdirection', quicktagsL10n.textdirection, '', quicktagsL10n.toggleTextdirection);
     654                qt.Button.call( this, 'textdirection', quicktagsL10n.textdirection, '', quicktagsL10n.toggleTextdirection );
    637655        };
    638656        qt.TextDirectionButton.prototype = new qt.Button();
    639657        qt.TextDirectionButton.prototype.callback = function(e, c) {
     
    649667        };
    650668
    651669        // ensure backward compatibility
    652         edButtons[10] = new qt.TagButton('strong','b','<strong>','</strong>');
    653         edButtons[20] = new qt.TagButton('em','i','<em>','</em>'),
    654         edButtons[30] = new qt.LinkButton(), // special case
    655         edButtons[40] = new qt.TagButton('block','b-quote','\n\n<blockquote>','</blockquote>\n\n'),
    656         edButtons[50] = new qt.TagButton('del','del','<del datetime="' + _datetime + '">','</del>'),
    657         edButtons[60] = new qt.TagButton('ins','ins','<ins datetime="' + _datetime + '">','</ins>'),
    658         edButtons[70] = new qt.ImgButton(), // special case
    659         edButtons[80] = new qt.TagButton('ul','ul','<ul>\n','</ul>\n\n'),
    660         edButtons[90] = new qt.TagButton('ol','ol','<ol>\n','</ol>\n\n'),
    661         edButtons[100] = new qt.TagButton('li','li','\t<li>','</li>\n'),
    662         edButtons[110] = new qt.TagButton('code','code','<code>','</code>'),
    663         edButtons[120] = new qt.TagButton('more','more','<!--more-->\n\n',''),
     670        edButtons[10] = new qt.TagButton( 'strong', 'b', '<strong>', '</strong>', '', '', '', { ariaLabel: quicktagsL10n.strong, ariaLabelClose: quicktagsL10n.strongClose } );
     671        edButtons[20] = new qt.TagButton( 'em', 'i', '<em>', '</em>', '', '', '', { ariaLabel: quicktagsL10n.emphasized, ariaLabelClose: quicktagsL10n.emphasizedClose } );
     672        edButtons[30] = new qt.LinkButton(); // special case
     673        edButtons[40] = new qt.TagButton( 'block', 'b-quote', '\n\n<blockquote>', '</blockquote>\n\n', '', '', '', { ariaLabel: quicktagsL10n.blockquote, ariaLabelClose: quicktagsL10n.blockquoteClose } );
     674        edButtons[50] = new qt.TagButton( 'del', 'del', '<del datetime="' + _datetime + '">', '</del>', '', '', '', { ariaLabel: quicktagsL10n.deletion, ariaLabelClose: quicktagsL10n.deletionClose } );
     675        edButtons[60] = new qt.TagButton( 'ins', 'ins', '<ins datetime="' + _datetime + '">', '</ins>', '', '', '', { ariaLabel: quicktagsL10n.insertion, ariaLabelClose: quicktagsL10n.insertionClose } );
     676        edButtons[70] = new qt.ImgButton(); // special case
     677        edButtons[80] = new qt.TagButton( 'ul', 'ul', '<ul>\n', '</ul>\n\n', '', '', '', { ariaLabel: quicktagsL10n.bulllist, ariaLabelClose: quicktagsL10n.bulllistClose } );
     678        edButtons[90] = new qt.TagButton( 'ol', 'ol', '<ol>\n', '</ol>\n\n', '', '', '', { ariaLabel: quicktagsL10n.numlist, ariaLabelClose: quicktagsL10n.numlistClose } );
     679        edButtons[100] = new qt.TagButton( 'li', 'li', '\t<li>', '</li>\n', '', '', '', { ariaLabel: quicktagsL10n.listitem, ariaLabelClose: quicktagsL10n.listitemClose } );
     680        edButtons[110] = new qt.TagButton( 'code', 'code', '<code>', '</code>', '', '', '', { ariaLabel: quicktagsL10n.code, ariaLabelClose: quicktagsL10n.codeClose } );
     681        edButtons[120] = new qt.TagButton( 'more', 'more', '<!--more-->\n\n', '', '', '', '', { ariaLabel: quicktagsL10n.more } );
    664682        edButtons[140] = new qt.CloseButton();
    665683
    666684})();
  • src/wp-includes/script-loader.php

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