Ticket #31522: 31522.3.patch
File 31522.3.patch, 11.2 KB (added by , 10 years ago) |
---|
-
src/wp-includes/js/quicktags.js
327 327 * @param string title Optional. Button's title="..." 328 328 * @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. 329 329 * @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) 330 331 * @return mixed null or the button object that is needed for back-compat. 331 332 */ 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 ) { 333 334 var btn; 334 335 335 336 if ( !id || !display ) { … … 338 339 339 340 priority = priority || 0; 340 341 arg2 = arg2 || ''; 342 attr = attr || {}; 341 343 342 344 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 ); 344 346 btn.callback = arg1; 345 347 } 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 ); 347 349 } else { 348 350 return; 349 351 } … … 399 401 }; 400 402 401 403 // 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 || {}; 409 411 }; 410 412 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 + '"' : '', 413 416 dfw = ( wp = window.wp ) && wp.editor && wp.editor.dfw; 414 417 415 418 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>'; 417 420 } else if ( this.id === 'dfw' ) { 418 421 active = dfw && dfw.isActive() ? '' : ' disabled="disabled"'; 419 422 on = dfw && dfw.isOn() ? ' active' : ''; 420 423 421 return '<button type="button" id="' + idPrefix + this.id + '" class="ed_button qt-dfw' + on + '"' + title + a ctive + '></button>';424 return '<button type="button" id="' + idPrefix + this.id + '" class="ed_button qt-dfw' + on + '"' + title + ariaLabel + active + '></button>'; 422 425 } 423 426 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 + '" />'; 425 428 }; 426 429 qt.Button.prototype.callback = function(){}; 427 430 428 431 // 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 ) { 430 433 var t = this; 431 qt.Button.call( t, id, display, access, title, instance);434 qt.Button.call( t, id, display, access, title, instance, attr ); 432 435 t.tagStart = tagStart; 433 436 t.tagEnd = tagEnd; 434 437 }; 435 438 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 ) { 439 440 if ( ! ed.openTags ) { 440 441 ed.openTags = []; 441 442 } 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 } 445 451 } 446 452 }; 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); 449 455 450 456 if ( i !== false ) { 451 ed.openTags.splice( i, 1);457 ed.openTags.splice( i, 1 ); 452 458 } 453 459 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 } 455 465 }; 456 466 // whether a tag is open or not. Returns false if not open, or current open depth of the tag 457 467 qt.TagButton.prototype.isOpen = function (ed) { … … 544 554 545 555 // the close tags button 546 556 qt.CloseButton = function() { 547 qt.Button.call( this, 'close', quicktagsL10n.closeTags, '', quicktagsL10n.closeAllOpenTags);557 qt.Button.call( this, 'close', quicktagsL10n.closeTags, '', quicktagsL10n.closeAllOpenTags ); 548 558 }; 549 559 550 560 qt.CloseButton.prototype = new qt.Button(); … … 575 585 576 586 // the link button 577 587 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 ); 579 593 }; 580 594 qt.LinkButton.prototype = new qt.TagButton(); 581 595 qt.LinkButton.prototype.callback = function(e, c, ed, defaultValue) { … … 603 617 604 618 // the img button 605 619 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 ); 607 625 }; 608 626 qt.ImgButton.prototype = new qt.TagButton(); 609 627 qt.ImgButton.prototype.callback = function(e, c, ed, defaultValue) { … … 633 651 }; 634 652 635 653 qt.TextDirectionButton = function() { 636 qt.Button.call( this, 'textdirection', quicktagsL10n.textdirection, '', quicktagsL10n.toggleTextdirection);654 qt.Button.call( this, 'textdirection', quicktagsL10n.textdirection, '', quicktagsL10n.toggleTextdirection ); 637 655 }; 638 656 qt.TextDirectionButton.prototype = new qt.Button(); 639 657 qt.TextDirectionButton.prototype.callback = function(e, c) { … … 649 667 }; 650 668 651 669 // 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 case655 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 case659 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 } ); 664 682 edButtons[140] = new qt.CloseButton(); 665 683 666 684 })(); -
src/wp-includes/script-loader.php
96 96 'enterImageDescription' => __( 'Enter a description of the image' ), 97 97 'textdirection' => esc_attr__( 'text direction' ), 98 98 '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' ), 100 121 ) ); 101 122 102 123 $scripts->add( 'colorpicker', "/wp-includes/js/colorpicker$suffix.js", array('prototype'), '3517m' );