| 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>Untitled Page</title> |
|---|
| 5 | <script type="text/javascript" src="/fckeditor/fckeditor.js"></script> |
|---|
| 6 | <script type="text/javascript"> |
|---|
| 7 | function WysiwygDiv(el){ |
|---|
| 8 | this.div = document.getElementById(el); |
|---|
| 9 | // back ref because fck is not oo |
|---|
| 10 | this.div.wysiwyg = this; |
|---|
| 11 | this.html = this.div.innerHTML; |
|---|
| 12 | this.originalHtml = this.html; |
|---|
| 13 | this.editting = false; |
|---|
| 14 | var fck = new FCKeditor( this.div.id + ".fck" ); |
|---|
| 15 | fck.BasePath = "/FCKeditor/"; |
|---|
| 16 | fck.ToolbarSet = "Basic"; |
|---|
| 17 | this.editorInit = fck; |
|---|
| 18 | this.setEditor = function(editor){ |
|---|
| 19 | this.editor = editor; |
|---|
| 20 | this.editor.SetHTML( this.html ); |
|---|
| 21 | }; |
|---|
| 22 | this.enableEdit = function(){ |
|---|
| 23 | this.div.innerHTML = this.editorInit.CreateHtml(); |
|---|
| 24 | this.editting = true; |
|---|
| 25 | }; |
|---|
| 26 | this.saveEdit = function(){ |
|---|
| 27 | this.html = this.editor.GetXHTML(); |
|---|
| 28 | this.div.innerHTML = this.html; |
|---|
| 29 | this.editting = false; |
|---|
| 30 | } |
|---|
| 31 | } |
|---|
| 32 | |
|---|
| 33 | function FCKeditor_OnComplete( editorInstance ) |
|---|
| 34 | { |
|---|
| 35 | var name = editorInstance.Name; |
|---|
| 36 | if( name.substring( name.length-4 ) == ".fck" ){ |
|---|
| 37 | var div = document.getElementById(name.substring( 0, name.length-4 )); |
|---|
| 38 | div.wysiwyg.setEditor(editorInstance); |
|---|
| 39 | } |
|---|
| 40 | } |
|---|
| 41 | |
|---|
| 42 | function doit(i){ |
|---|
| 43 | var editdiv = (i==1)?editDiv:editDiv2; |
|---|
| 44 | if( !editdiv.editting ){ |
|---|
| 45 | editdiv.enableEdit() ; |
|---|
| 46 | }else{ |
|---|
| 47 | editdiv.saveEdit() |
|---|
| 48 | } |
|---|
| 49 | } |
|---|
| 50 | |
|---|
| 51 | </script> |
|---|
| 52 | |
|---|
| 53 | </head> |
|---|
| 54 | <body> |
|---|
| 55 | |
|---|
| 56 | |
|---|
| 57 | |
|---|
| 58 | <div id="testHtml" style="width:300px;float:left;"> |
|---|
| 59 | Yo, Yo, Yo! |
|---|
| 60 | <b>I am a</b> section of <br /> |
|---|
| 61 | Html |
|---|
| 62 | </div> |
|---|
| 63 | <div id="testHtml2" style="width:300px;float:left;"> |
|---|
| 64 | <i>I am a second</i> section of <br /> wonderful |
|---|
| 65 | Html |
|---|
| 66 | </div> |
|---|
| 67 | <div id="testHtml" style="clear:left;"> |
|---|
| 68 | |
|---|
| 69 | </div> |
|---|
| 70 | <a href="javascript:doit(1)">do it 1</a> <a href="javascript:doit(2)">do it 2</a> |
|---|
| 71 | |
|---|
| 72 | |
|---|
| 73 | |
|---|
| 74 | |
|---|
| 75 | </body> |
|---|
| 76 | <script> |
|---|
| 77 | |
|---|
| 78 | var editDiv2 = new WysiwygDiv("testHtml2"); |
|---|
| 79 | var editDiv = new WysiwygDiv("testHtml"); |
|---|
| 80 | </script> |
|---|
| 81 | </html> |
|---|