Ticket #5647: 5647_2.patch
File 5647_2.patch, 16.4 KB (added by , 15 years ago) |
---|
-
_source/lang/en.js
748 748 clear : 'Clear' 749 749 }, 750 750 751 toolbarGroup : 752 { 753 mode : 'Editing Mode', 754 page : 'Page Tool', 755 template : 'Templates', 756 clipboard : 'Clipboard', 757 spellcheck : 'Spell Checking', 758 undo : 'Undo/Redo', 759 find : 'Find and Replace', 760 clear : 'Clear Format', 761 form : 'Form Fields', 762 basicstyle : 'Basic Styles', 763 list : 'List Operations', 764 indent : 'Indentation Operations', 765 block : 'Blocks', 766 justify : 'Justification Operations', 767 bidi : 'Bi-directional Text Options', 768 link : 'Links', 769 objects : 'Object Controls', 770 color : 'Font Colors', 771 tool : 'Tools' 772 }, 773 751 774 toolbarCollapse : 'Collapse Toolbar', 752 775 toolbarExpand : 'Expand Toolbar', 753 776 -
_source/plugins/toolbar/plugin.js
10 10 11 11 (function() 12 12 { 13 var toolbox = function() 13 // Trait for toolbar containing unit. 14 function container() 14 15 { 15 this.toolbars = []; 16 this.focusCommandExecuted = false; 17 }; 18 19 toolbox.prototype.focus = function() 20 { 21 for ( var t = 0, toolbar ; toolbar = this.toolbars[ t++ ] ; ) 22 { 23 for ( var i = 0, item ; item = toolbar.items[ i++ ] ; ) 16 return CKEDITOR.tools.createClass( { 17 $ : function() 24 18 { 25 if ( item.focus ) 19 this.id = CKEDITOR.tools.getNextId(), 20 this.items = []; 21 }, 22 proto : 23 { 24 /** 25 * Focus the first/last item of the container. 26 * @param {Boolean} focusEnd 27 */ 28 focus : function( focusEnd ) 26 29 { 27 item.focus(); 28 return; 30 var current = this, 31 target; 32 33 while ( 1 ) 34 { 35 target = current.items[ focusEnd ? current.items.length -1 : 0 ]; 36 if ( target && target.focus ) 37 break; 38 // No focusable candidate found, move focus to parent's siblings. 39 else if ( current.parent ) 40 current = current.parent; 41 else 42 { 43 target = current; 44 break; 45 } 46 } 47 48 target.focus( focusEnd ); 49 }, 50 51 add : function( item ) 52 { 53 var index = this.items.push( item ) - 1; 54 55 // Create the next/previous/parent reference. 56 if ( index > 0 ) 57 { 58 item.previous = this.items[ index - 1 ]; 59 item.previous.next = item; 60 } 61 item.parent = this; 29 62 } 30 63 } 31 } 32 } ;64 } ); 65 } 33 66 67 var toolbox = container(), 68 toolbar = container(), 69 group = container(); 70 34 71 var commands = 35 72 { 36 73 toolbarFocus : … … 57 94 { 58 95 init : function( editor ) 59 96 { 60 var itemKeystroke = function( item, keystroke )97 var buttonKeystroke = function( item, keystroke ) 61 98 { 62 var next, nextToolGroup, groupItemsCount;99 var next, closewise; 63 100 var rtl = editor.lang.dir == 'rtl'; 64 101 65 102 switch ( keystroke ) 66 103 { 67 case rtl ? 37 : 39 : // RIGHT-ARROW68 104 case 9 : // TAB 69 do 105 case CKEDITOR.SHIFT + 9 : // SHIFT + TAB 106 107 closewise = keystroke == 9; 108 109 // Move to next group if when button group existed. 110 if ( item.parent instanceof group ) 70 111 { 71 // Look for the next item in the toolbar. 72 next = item.next; 73 74 if ( !next ) 112 item = item.parent; 113 while( !next ) 75 114 { 76 nextToolGroup = item.toolbar.next; 77 groupItemsCount = nextToolGroup && nextToolGroup.items.length; 78 79 // Bypass the empty toolgroups. 80 while ( groupItemsCount === 0 ) 115 next = item[ closewise ? 'next' : 'previous' ]; 116 if ( !next ) 81 117 { 82 nextToolGroup = nextToolGroup.next; 83 groupItemsCount = nextToolGroup && nextToolGroup.items.length; 118 if ( item.parent ) 119 item = item.parent; 120 else 121 next = item; 84 122 } 85 86 if ( nextToolGroup ) 87 next = nextToolGroup.items[ 0 ]; 123 else if ( !next.focus ) 124 { 125 item = next; 126 next = null; 127 } 88 128 } 89 129 90 item = next; 130 next.focus( !closewise ); 131 return false; 91 132 } 92 while ( item && !item.focus )93 133 94 // If available, just focus it, otherwise focus the 95 // first one. 96 if ( item ) 97 item.focus(); 98 else 99 editor.toolbox.focus(); 134 case rtl ? 37 : 39 : // RIGHT-ARROW 135 case rtl ? 39 : 37 : // LEFT-ARROW 100 136 101 return false; 137 if ( closewise == undefined ) 138 closewise = keystroke == ( rtl ? 37 : 39 ); 102 139 103 case rtl ? 39 : 37 : // LEFT-ARROW 104 case CKEDITOR.SHIFT + 9 : // SHIFT + TAB 105 do 140 while( !next ) 106 141 { 107 // Look for the previous item in the toolbar. 108 next = item.previous; 109 142 next = item[ closewise ? 'next' : 'previous' ]; 110 143 if ( !next ) 111 144 { 112 nextToolGroup = item.toolbar.previous; 113 groupItemsCount = nextToolGroup && nextToolGroup.items.length; 114 115 // Bypass the empty toolgroups. 116 while ( groupItemsCount === 0 ) 117 { 118 nextToolGroup = nextToolGroup.previous; 119 groupItemsCount = nextToolGroup && nextToolGroup.items.length; 120 } 121 122 if ( nextToolGroup ) 123 next = nextToolGroup.items[ groupItemsCount - 1 ]; 145 // Cyrcling inside the group when button group existed. 146 if ( item.parent instanceof group ) 147 next = item.parent; 148 else if ( item.parent ) 149 item = item.parent; 150 else 151 next = item; 124 152 } 125 126 item = next; 153 else if ( !next.focus ) 154 { 155 item = next; 156 next = null; 157 } 127 158 } 128 while ( item && !item.focus )129 159 130 // If available, just focus it, otherwise focus the 131 // last one. 132 if ( item ) 133 item.focus(); 134 else 135 { 136 var lastToolbarItems = editor.toolbox.toolbars[ editor.toolbox.toolbars.length - 1 ].items; 137 lastToolbarItems[ lastToolbarItems.length - 1 ].focus(); 138 } 139 160 next.focus( !closewise ); 140 161 return false; 141 162 142 163 case 27 : // ESC … … 157 178 { 158 179 editor.toolbox = new toolbox(); 159 180 160 var labelId = 'cke_' + CKEDITOR.tools.getNextNumber(); 181 var labelId = CKEDITOR.tools.getNextId(), 182 groupsLang = CKEDITOR.tools.extend( {}, editor.lang.toolbarGroup, editor.config.toolbarGroupsLabels, true ); 161 183 162 184 var output = [ '<div class="cke_toolbox" role="toolbar" aria-labelledby="', labelId, '"' ], 163 185 expanded = editor.config.toolbarStartupExpanded !== false, … … 168 190 // Sends the ARIA label. 169 191 output.push( '<span id="', labelId, '" class="cke_voice_label">', editor.lang.toolbar, '</span>' ); 170 192 171 var toolb ars = editor.toolbox.toolbars,172 toolbar =193 var toolboxObj = editor.toolbox, 194 toolbarDef = 173 195 ( editor.config.toolbar instanceof Array ) ? 174 196 editor.config.toolbar 175 197 : 176 198 editor.config[ 'toolbar_' + editor.config.toolbar ]; 177 199 178 for ( var r = 0 ; r < toolbar .length ; r++ )200 for ( var r = 0 ; r < toolbarDef.length ; r++ ) 179 201 { 180 var row = toolbar [ r ];202 var row = toolbarDef[ r ]; 181 203 182 204 // It's better to check if the row object is really 183 205 // available because it's a common mistake to leave … … 187 209 if ( !row ) 188 210 continue; 189 211 190 var toolbarId = 'cke_' + CKEDITOR.tools.getNextNumber(), 191 toolbarObj = { id : toolbarId, items : [] }; 212 var toolbarObj = new toolbar(); 192 213 193 214 if ( groupStarted ) 194 215 { … … 202 223 continue; 203 224 } 204 225 205 output.push( '<span id="', toolbar Id, '" class="cke_toolbar" role="presentation"><span class="cke_toolbar_start"></span>' );226 output.push( '<span id="', toolbar.id, '" class="cke_toolbar" role="presentation"><span class="cke_toolbar_start"></span>' ); 206 227 207 // Add the toolbar to the "editor.toolbox.toolbars" 208 // array. 209 var index = toolbars.push( toolbarObj ) - 1; 228 toolboxObj.add( toolbarObj ); 210 229 211 // Create the next/previous reference.212 if ( index > 0 )213 {214 toolbarObj.previous = toolbars[ index - 1 ];215 toolbarObj.previous.next = toolbarObj;216 }217 218 // Create all items defined for this toolbar.219 230 for ( var i = 0 ; i < row.length ; i++ ) 220 231 { 221 var item, 222 itemName = row[ i ]; 232 var item = row[ i ], 233 isGroup = ( typeof item == 'object' ), 234 buttons = isGroup ? item.buttons : [ item ]; 223 235 224 if ( itemName == '-' ) 225 item = CKEDITOR.ui.separator; 226 else 227 item = editor.ui.create( itemName ); 236 // Group start. 237 if ( isGroup ) 238 { 239 var groupObj = new group(); 240 output.push( '<span id="' + groupObj.id + '" class="cke_toolgroup" role="group" aria-labelledby="'+ groupObj.id + '_label">' + 241 '<span id="' + groupObj.id + '_label" class="cke_voice_label">' + ( item.label || groupsLang[ item.name ] || '' ) + ' </span>' ); 242 toolbarObj.add( groupObj ); 243 } 228 244 229 if ( item ) 245 // Create all items defined for this toolbar. 246 for ( var j = 0 ; j < buttons.length ; j++ ) 230 247 { 231 if ( item.canGroup ) 248 var button, 249 itemName = buttons[ j ]; 250 251 // Ignore separater in group mode. 252 if ( itemName == '-' && !isGroup ) 253 button = CKEDITOR.ui.separator; 254 else 255 button = editor.ui.create( itemName ); 256 257 if ( button ) 232 258 { 233 if ( !groupStarted)259 if ( button.canGroup ) 234 260 { 235 output.push( '<span class="cke_toolgroup" role="presentation">' ); 236 groupStarted = 1; 261 if ( !( groupStarted || isGroup ) ) 262 { 263 output.push( '<span class="cke_toolgroup" role="presentation">' ); 264 groupStarted = 1; 265 } 237 266 } 238 } 239 else if ( groupStarted ) 240 { 241 output.push( '</span>' ); 242 groupStarted = 0; 243 } 267 else if ( groupStarted ) 268 { 269 output.push( '</span>' ); 270 groupStarted = 0; 271 } 244 272 245 var itemObj = item.render( editor, output ); 246 index = toolbarObj.items.push( itemObj ) - 1; 273 var container = isGroup ? groupObj : toolbarObj; 274 var buttonObj = button.render( editor, output ); 275 container.add( buttonObj ); 247 276 248 if ( index > 0 ) 249 { 250 itemObj.previous = toolbarObj.items[ index - 1 ]; 251 itemObj.previous.next = itemObj; 277 buttonObj.onkey = buttonKeystroke; 252 278 } 279 } 253 280 254 itemObj.toolbar = toolbarObj; 255 itemObj.onkey = itemKeystroke; 256 257 /* 258 * Fix for #3052: 259 * Prevent JAWS from focusing the toolbar after document load. 260 */ 261 itemObj.onfocus = function() 262 { 263 if ( !editor.toolbox.focusCommandExecuted ) 264 editor.focus(); 265 }; 281 // Group close. 282 if ( isGroup ) 283 { 284 output.push( '</span>' ); 285 groupStarted = 0; 266 286 } 267 287 } 268 288 289 // Group must close on toolbar row end. 269 290 if ( groupStarted ) 270 291 { 271 292 output.push( '</span>' ); 272 293 groupStarted = 0; 273 294 } 274 275 295 output.push( '<span class="cke_toolbar_end"></span></span>' ); 276 296 } 277 297 … … 443 463 ]; 444 464 445 465 /** 466 * This is a toolbar definition with all features, grouping by functionality. 467 * @type Array 468 * @default (see example) 469 * @example 470 * // This is actually the default value. 471 * CKEDITOR.config.toolbar_Full_Group = 472 * [ 473 * [ 474 * { 475 * name: 'mode', 476 * buttons : [ 'Source' ] 477 * }, 478 * { 479 * name: 'page', 480 * buttons : [ 'Save','NewPage','Preview','Print' ] 481 * }, 482 * { 483 * name: 'template', 484 * buttons : [ 'Templates' ] 485 * }, 486 * { 487 * name: 'clipboard', 488 * buttons : [ 'Cut','Copy','Paste','PasteText','PasteFromWord' ] 489 * }, 490 * { 491 * name: 'spellcheck', 492 * buttons : [ 'SpellChecker', 'Scayt' ] 493 * }, 494 * { 495 * name: 'undo', 496 * buttons : [ 'Undo','Redo' ] 497 * }, 498 * { 499 * name: 'find', 500 * buttons : [ 'Find','Replace' ] 501 * }, 502 * { 503 * name: 'clear', 504 * buttons : [ 'SelectAll','RemoveFormat' ] 505 * }, 506 * { 507 * name: 'form', 508 * buttons : [ 'Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField' ] 509 * } 510 * ], 511 * '/', 512 * [ 513 * { 514 * name: 'basicstyle', 515 * buttons : [ 'Bold','Italic','Underline','Strike','Subscript','Superscript' ] 516 * }, 517 * { 518 * name: 'list', 519 * buttons : [ 'NumberedList','BulletedList' ] 520 * }, 521 * { 522 * name: 'indent', 523 * buttons : [ 'Outdent','Indent' ] 524 * }, 525 * { 526 * name: 'block', 527 * buttons : [ 'Blockquote','CreateDiv' ] 528 * }, 529 * { 530 * name: 'justify', 531 * buttons : [ 'JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock' ] 532 * }, 533 * { 534 * name: 'bidi', 535 * buttons : ['BidiLtr', 'BidiRtl'] 536 * }, 537 * { 538 * name: 'link', 539 * buttons : [ 'Link','Unlink','Anchor' ] 540 * }, 541 * { 542 * name: 'objects', 543 * buttons : [ 'Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak' ] 544 * } 545 * ], 546 * '/', 547 * [ 548 * 'Styles','Format','Font','FontSize', 549 * { 550 * name: 'color', 551 * buttons : [ 'TextColor','BGColor' ] 552 * }, 553 * { 554 * name: 'tool', 555 * buttons : [ 'Maximize', 'ShowBlocks' ] 556 * }, 557 * 'About' 558 * ], 559 * ]; 560 * 561 */ 562 CKEDITOR.config.toolbar_Full_Group = 563 [ 564 [ 565 { 566 name: 'mode', 567 buttons : [ 'Source' ] 568 }, 569 { 570 name: 'page', 571 buttons : [ 'Save','NewPage','Preview','Print' ] 572 }, 573 { 574 name: 'template', 575 buttons : [ 'Templates' ] 576 }, 577 { 578 name: 'clipboard', 579 buttons : [ 'Cut','Copy','Paste','PasteText','PasteFromWord' ] 580 }, 581 { 582 name: 'spellcheck', 583 buttons : [ 'SpellChecker', 'Scayt' ] 584 }, 585 { 586 name: 'undo', 587 buttons : [ 'Undo','Redo' ] 588 }, 589 { 590 name: 'find', 591 buttons : [ 'Find','Replace' ] 592 }, 593 { 594 name: 'clear', 595 buttons : [ 'SelectAll','RemoveFormat' ] 596 }, 597 { 598 name: 'form', 599 buttons : [ 'Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField' ] 600 } 601 ], 602 '/', 603 [ 604 { 605 name: 'basicstyle', 606 buttons : [ 'Bold','Italic','Underline','Strike','Subscript','Superscript' ] 607 }, 608 { 609 name: 'list', 610 buttons : [ 'NumberedList','BulletedList' ] 611 }, 612 { 613 name: 'indent', 614 buttons : [ 'Outdent','Indent' ] 615 }, 616 { 617 name: 'block', 618 buttons : [ 'Blockquote','CreateDiv' ] 619 }, 620 { 621 name: 'justify', 622 buttons : [ 'JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock' ] 623 }, 624 { 625 name: 'bidi', 626 buttons : ['BidiLtr', 'BidiRtl'] 627 }, 628 { 629 name: 'link', 630 buttons : [ 'Link','Unlink','Anchor' ] 631 }, 632 { 633 name: 'objects', 634 buttons : [ 'Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak' ] 635 } 636 ], 637 '/', 638 [ 639 'Styles','Format','Font','FontSize', 640 { 641 name: 'color', 642 buttons : [ 'TextColor','BGColor' ] 643 }, 644 { 645 name: 'tool', 646 buttons : [ 'Maximize', 'ShowBlocks' ] 647 }, 648 'About' 649 ], 650 ]; 651 652 /** 446 653 * The toolbox (alias toolbar) definition. It is a toolbar name or an array of 447 654 * toolbars (strips), each one being also an array, containing a list of UI items. 448 655 * @type Array|String … … 478 685 * @example 479 686 * config.toolbarStartupExpanded = false; 480 687 */ 688 689 /** 690 * Tool configuration that specifies labels for custom groups or overrides the already present labels. 691 * @name CKEDITOR.config.toolbarGroupsLabels 692 * @type Object 693 * @default {} 694 * @example 695 * config.toolbarGroupsLabels = { 696 * find : 'Another label', 697 * customGroup : 'My Group' 698 * }; 699 */