| 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: form</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 | CKEDITOR.test.addTestCase( ( function() |
| 11 | { |
| 12 | /** |
| 13 | * IE always returning CRLF for linefeed, so remove it when retrieve |
| 14 | * pre-formated text from text area. |
| 15 | * @param {Object} id |
| 16 | */ |
| 17 | function getTextAreaValue( id ) |
| 18 | { |
| 19 | return CKEDITOR.document.getById( id ).getValue().replace( /\r/gi, '' ); |
| 20 | } |
| 21 | // Local references. |
| 22 | var assert = CKEDITOR.test.assert, doc = CKEDITOR.document; |
| 23 | return { |
| 24 | /** |
| 25 | * Test insert a form element with all supported attributes. |
| 26 | */ |
| 27 | test_createForm : function() |
| 28 | { |
| 29 | var editor = CKEDITOR.replace( 'editor1' ); |
| 30 | editor.on( 'instanceReady', |
| 31 | function() |
| 32 | { |
| 33 | this.resume( function() |
| 34 | { |
| 35 | editor.focus(); |
| 36 | // async |
| 37 | editor.execCommand( 'form' ); |
| 38 | this.wait( |
| 39 | function() |
| 40 | { |
| 41 | var dialog = editor._.storedDialogs[ 'form' ]; |
| 42 | var name = dialog |
| 43 | .getContentElement( 'info', |
| 44 | 'txtName' ), action = dialog |
| 45 | .getContentElement( 'info', |
| 46 | 'txtAction' ), formId = dialog |
| 47 | .getContentElement( 'info', |
| 48 | 'txtId' ), encoding = dialog |
| 49 | .getContentElement( 'info', |
| 50 | 'cmbEncoding' ), target = dialog |
| 51 | .getContentElement( 'info', |
| 52 | 'cmbTarget' ), method = dialog |
| 53 | .getContentElement( 'info', |
| 54 | 'cmbMethod' ); |
| 55 | |
| 56 | // Set form fields values |
| 57 | name.setValue( 'form-name' ); |
| 58 | action.setValue( 'http://dev.fckeditor.net/newticket?' ); |
| 59 | formId.setValue( 'form-id1' ); |
| 60 | encoding.setValue( 'application/x-www-form-urlencoded' ); |
| 61 | target.setValue( '_blank' ); |
| 62 | method.setValue( 'post' ); |
| 63 | |
| 64 | dialog.fire( 'ok' ); |
| 65 | dialog.hide(); |
| 66 | |
| 67 | var result = editor.getData(), expected; |
| 68 | if ( CKEDITOR.env.gecko ) |
| 69 | expected = getTextAreaValue( 'formResultGecko' ) |
| 70 | else |
| 71 | expected = getTextAreaValue( 'formResultIE' ) |
| 72 | |
| 73 | //compensate lastline |
| 74 | if ( CKEDITOR.env.gecko ) |
| 75 | expected += '<br />\n'; |
| 76 | assert.areEqual( expected, result, |
| 77 | 'Created form element doesn\'t match.' ); |
| 78 | |
| 79 | }, 1000 ); |
| 80 | } ); |
| 81 | }, this ); |
| 82 | |
| 83 | this.wait(); |
| 84 | }, |
| 85 | |
| 86 | name :document.title |
| 87 | }; |
| 88 | } )() ); |
| 89 | //]]> |
| 90 | </script> |
| 91 | </head> |
| 92 | <body> |
| 93 | <textarea id="editor1" name="editor1"></textarea> |
| 94 | <textarea id="formResultGecko"><form action="http://dev.fckeditor.net/newticket?" encoding="application/x-www-form-urlencoded" id="form-id1" method="post" name="form-name" target="_blank"> |
| 95 | <br /> |
| 96 | </form></textarea> |
| 97 | <textarea id="formResultIE"><form action="http://dev.fckeditor.net/newticket?" encoding="application/x-www-form-urlencoded" id="form-id1" method="post" name="form-name" target="_blank"> |
| 98 | </form> |
| 99 | </textarea> |
| 100 | </body> |
| 101 | </html> |