| 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>Core : Editor</title> |
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| 6 | <link rel="stylesheet" type="text/css" href="../test.css" /> |
| 7 | <script type="text/javascript" src="../../../ckeditor_source.js"></script> |
| 8 | <script type="text/javascript" src="../test.js"></script> |
| 9 | <script type="text/javascript"> |
| 10 | //<![CDATA[ |
| 11 | |
| 12 | function prepareEditor( elementId, mode, config, callback, context ) |
| 13 | { |
| 14 | CKEDITOR.on( 'instanceReady', |
| 15 | function( evt ) |
| 16 | { |
| 17 | var isMe = mode == CKEDITOR.ELEMENT_MODE_REPLACE ? |
| 18 | evt.editor.name == elementId |
| 19 | : evt.editor.element.$ == |
| 20 | document.getElementById( elementId ); |
| 21 | if ( isMe ) |
| 22 | { |
| 23 | callback.call( context, evt.editor ); |
| 24 | } |
| 25 | }, this ); |
| 26 | |
| 27 | mode = mode || CKEDITOR.ELEMENT_MODE_REPLACE; |
| 28 | switch( mode ) |
| 29 | { |
| 30 | case CKEDITOR.ELEMENT_MODE_REPLACE : |
| 31 | CKEDITOR.replace( elementId, config ); |
| 32 | break; |
| 33 | case CKEDITOR.ELEMENT_MODE_APPENDTO : |
| 34 | CKEDITOR.appendTo( elementId, config ); |
| 35 | break; |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | |
| 40 | CKEDITOR.test.addTestCase( ( function() |
| 41 | { |
| 42 | |
| 43 | // Local references. |
| 44 | var assert = CKEDITOR.test.assert, |
| 45 | arrayAssert = YAHOO.util.ArrayAssert; |
| 46 | |
| 47 | var doc = new CKEDITOR.dom.document( document ); |
| 48 | |
| 49 | return { |
| 50 | |
| 51 | /** |
| 52 | * Make sure there's no multiple classes been attached on every elements. |
| 53 | */ |
| 54 | test_multipleClasses : function() |
| 55 | { |
| 56 | var multiClassesRegex = /\w+\s\w+/; |
| 57 | prepareEditor( 'editor1', null, null, function( editor ) |
| 58 | { |
| 59 | this.resume( function() |
| 60 | { |
| 61 | var dirtyElements = []; |
| 62 | var walker = new CKEDITOR.dom.domWalker( doc.getById( 'editor1' ) ); |
| 63 | walker.on( 'step', function( evt ) |
| 64 | { |
| 65 | var node = evt.data.node; |
| 66 | // Catch all elements wth multiple classes. |
| 67 | if ( node && node.type == CKEDITOR.NODE_ELEMENT && |
| 68 | multiClassesRegex.test ( node.$.className ) ) |
| 69 | dirtyElements.push( node ); |
| 70 | } ); |
| 71 | walker.forward(); |
| 72 | assert.isTrue( dirtyElements.length == 0, 'Elements are having multiple css classes.' ); |
| 73 | } ); |
| 74 | }, this ); |
| 75 | this.wait(); |
| 76 | }, |
| 77 | |
| 78 | name : document.title |
| 79 | }; |
| 80 | })() ); |
| 81 | |
| 82 | //]]> |
| 83 | </script> |
| 84 | </head> |
| 85 | <body> |
| 86 | <textarea id="editor1"></textarea> |
| 87 | </body> |
| 88 | </html> |
| 89 | No newline at end of file |