| 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 2 | <html xmlns="http://www.w3.org/1999/xhtml"> |
| 3 | <head> |
| 4 | <title>Plugin: toolbar</title> |
| 5 | <link rel="stylesheet" type="text/css" href="../../test.css" /> |
| 6 | <script type="text/javascript" src="../../../../ckeditor_source.js"></script> |
| 7 | <script type="text/javascript" src="../../test.js"></script> |
| 8 | <script type="text/javascript"> |
| 9 | //<![CDATA[ |
| 10 | /** |
| 11 | * Load the editor and wait for fully interactable. |
| 12 | * @param {Object} elementId |
| 13 | * @parma {Object} mode |
| 14 | * @param {Object} config |
| 15 | * @param {Object} callback Continuation with {@param editor}. |
| 16 | * @param {Object} context |
| 17 | */ |
| 18 | function prepareEditor( elementId, mode, config, callback, context ) |
| 19 | { |
| 20 | CKEDITOR.on( 'instanceReady', |
| 21 | function( evt ) |
| 22 | { |
| 23 | var isMe = mode == CKEDITOR.ELEMENT_MODE_REPLACE ? |
| 24 | evt.editor.name == elementId |
| 25 | : evt.editor.element.$ == |
| 26 | document.getElementById( elementId ); |
| 27 | if ( isMe ) |
| 28 | { |
| 29 | callback.call( context, evt.editor ); |
| 30 | } |
| 31 | }, this ); |
| 32 | |
| 33 | mode = mode || CKEDITOR.ELEMENT_MODE_REPLACE; |
| 34 | switch( mode ) |
| 35 | { |
| 36 | case CKEDITOR.ELEMENT_MODE_REPLACE : |
| 37 | CKEDITOR.replace( elementId, config ); |
| 38 | break; |
| 39 | case CKEDITOR.ELEMENT_MODE_APPENDTO : |
| 40 | CKEDITOR.appendTo( elementId, config ); |
| 41 | break; |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * Find the specific UI item by row and column index. |
| 47 | * @param {Object} editor |
| 48 | * @param {Object} rowIndex |
| 49 | * @param {Object} colIndex |
| 50 | */ |
| 51 | function getToolbarUIItem( editor, rowIndex, colIndex){ |
| 52 | return editor.toolbox.toolbars[ rowIndex -1].items[ colIndex-1]; |
| 53 | } |
| 54 | |
| 55 | CKEDITOR.test.addTestCase( ( function() |
| 56 | { |
| 57 | |
| 58 | // Local references. |
| 59 | var assert = CKEDITOR.test.assert, |
| 60 | doc = CKEDITOR.document, |
| 61 | action = YAHOO.util.UserAction, |
| 62 | selector = YAHOO.util.Selector; |
| 63 | |
| 64 | return { |
| 65 | |
| 66 | /** |
| 67 | * Test 'tabIndex' and 'title' attribute of all toolbar items. |
| 68 | */ |
| 69 | test_toolbarItemTabAndIndex : function() |
| 70 | { |
| 71 | prepareEditor( 'editor1', null, null, function( editor ) |
| 72 | { |
| 73 | this.resume( function() |
| 74 | { |
| 75 | var toolbarItems = CKEDITOR.config.toolbar; |
| 76 | var i , l = toolbarItems.length, row, rowIndex = 0; |
| 77 | for ( i = 0; i < l ; i++ ) { |
| 78 | row = toolbarItems[ i ]; |
| 79 | // Bypass line delimiter |
| 80 | if( row == '/' ) |
| 81 | continue; |
| 82 | rowIndex++; |
| 83 | |
| 84 | var j, s = toolbarItems[ i ].length, col, colIndex = 0; |
| 85 | for ( j = 0; j < s; j++ ) { |
| 86 | col = toolbarItems[ i ][ j ]; |
| 87 | |
| 88 | colIndex++; |
| 89 | var item = getToolbarUIItem( editor, rowIndex, colIndex ); |
| 90 | |
| 91 | // By pass column dividers |
| 92 | if( !item.id ) |
| 93 | continue; |
| 94 | |
| 95 | var itemElement = doc.getById( item.id ); |
| 96 | |
| 97 | //Special case for combo |
| 98 | if( itemElement.hasClass( 'cke_rcombo' ) ) |
| 99 | itemElement = itemElement.getElementsByTag( 'a' ).getItem( 0 ); |
| 100 | |
| 101 | assert.isTrue( !!itemElement.getAttribute( 'title' ), |
| 102 | 'Toolbar item ' + col + ' doesn\'t have description title.' ); |
| 103 | assert.areEqual( -1, itemElement.getAttribute( 'tabIndex' ), |
| 104 | 'Toolbar item ' + col + ' doesn\'t have correct tabIndex.' ); |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | } ); |
| 109 | }, this ); |
| 110 | this.wait(); |
| 111 | }, |
| 112 | |
| 113 | name :document.title |
| 114 | }; |
| 115 | } )() ); |
| 116 | //]]> |
| 117 | </script> |
| 118 | </head> |
| 119 | <body> |
| 120 | <textarea id="editor1" name="editor1"></textarea> |
| 121 | </body> |
| 122 | </html> |