| 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" |
|---|
| 2 | "http://www.w3.org/TR/html4/strict.dtd"> |
|---|
| 3 | <html> |
|---|
| 4 | <head> |
|---|
| 5 | <title>Dojo Editor2 Test</title> |
|---|
| 6 | <script type="text/javascript"> |
|---|
| 7 | djConfig = { |
|---|
| 8 | isDebug: true, |
|---|
| 9 | dojoRichTextFrameUrl: "../../../src/widget/templates/richtextframe.html" |
|---|
| 10 | }; |
|---|
| 11 | </script> |
|---|
| 12 | |
|---|
| 13 | <style> |
|---|
| 14 | html, body { |
|---|
| 15 | width: 100%; |
|---|
| 16 | height: 100%; |
|---|
| 17 | overflow: hidden; |
|---|
| 18 | } |
|---|
| 19 | </style> |
|---|
| 20 | <script type="text/javascript" src="../../../dojo.js"></script> |
|---|
| 21 | <script type="text/javascript"> |
|---|
| 22 | dojo.require("dojo.debug.console"); |
|---|
| 23 | dojo.require("dojo.widget.Editor2Plugin.SimpleSignalCommands"); |
|---|
| 24 | dojo.require("dojo.widget.Editor2"); |
|---|
| 25 | dojo.require("dojo.widget.Button"); |
|---|
| 26 | |
|---|
| 27 | function updateContent(contentId, content) { |
|---|
| 28 | dojo.byId(contentId).innerHTML=content; |
|---|
| 29 | } |
|---|
| 30 | |
|---|
| 31 | function edit(contentId) { |
|---|
| 32 | var content = dojo.byId(contentId).innerHTML; |
|---|
| 33 | dojo.debug("Editing " + content); |
|---|
| 34 | |
|---|
| 35 | var div = document.createElement("div"); |
|---|
| 36 | document.body.appendChild(div); |
|---|
| 37 | div.style.width="810px"; |
|---|
| 38 | div.style.height="400px"; |
|---|
| 39 | |
|---|
| 40 | var newFloat =dojo.widget.createWidget("dojo:FloatingPane", {displayCloseAction: true, title: contentId},div); |
|---|
| 41 | |
|---|
| 42 | var newEditor= dojo.widget.createWidget("Editor2", {height: 100, shareToolbar: false, toolbarTemplatePath: "../../../tests/widget/Editor/EditorToolbarLight.html"}); |
|---|
| 43 | newEditor.contentSource=contentId; |
|---|
| 44 | dojo.event.connect(newEditor, "editorOnLoad", dojo.lang.hitch(newEditor, function() { |
|---|
| 45 | dojo.debug("contentId: " + this.contentSource); |
|---|
| 46 | dojo.debug(dojo.byId(this.contentSource)); |
|---|
| 47 | dojo.debug("content from div: " + dojo.byId(this.contentSource).innerHTML) |
|---|
| 48 | this.replaceEditorContent(dojo.byId(this.contentSource).innerHTML); |
|---|
| 49 | this.parent.onResized(); |
|---|
| 50 | dojo.event.connect(this, "save", dojo.lang.hitch(this, function() { |
|---|
| 51 | dojo.debug("**** editor" + this.contentSource); |
|---|
| 52 | updateContent(this.contentSource,this.getEditorContent()); |
|---|
| 53 | })); |
|---|
| 54 | })); |
|---|
| 55 | |
|---|
| 56 | dojo.event.connect(dj_global, "updateContent", |
|---|
| 57 | dojo.lang.hitch(newEditor, function(contentId, content){ |
|---|
| 58 | if (contentId == this.contentSource) { |
|---|
| 59 | this.replaceEditorContent(content); |
|---|
| 60 | } |
|---|
| 61 | }) |
|---|
| 62 | ); |
|---|
| 63 | |
|---|
| 64 | newFloat.addChild(newEditor); |
|---|
| 65 | |
|---|
| 66 | } |
|---|
| 67 | |
|---|
| 68 | dojo.addOnLoad(function() { |
|---|
| 69 | var editAButton = dojo.widget.byId("editA"); |
|---|
| 70 | dojo.event.connect(editAButton, "onClick", function() { edit("content1"); } ); |
|---|
| 71 | |
|---|
| 72 | var editBButton = dojo.widget.byId("editB"); |
|---|
| 73 | dojo.event.connect(editBButton, "onClick", function() { edit("content2"); } ); |
|---|
| 74 | }); |
|---|
| 75 | </script> |
|---|
| 76 | |
|---|
| 77 | </head> |
|---|
| 78 | <body> |
|---|
| 79 | <p>Some more editor tests, primarily dealing with programmatically created editors</p> |
|---|
| 80 | <ul> |
|---|
| 81 | <li>Open up an arbitrary number of editors on either of the two source data areas</li> |
|---|
| 82 | <li>Open up multiple editors on the same source area, changes to one editor, should be reflected everywhere that source data is opened</li> |
|---|
| 83 | <li>Closing an editor (which destroys it) shouldn't throw an error when a new one is created</li> |
|---|
| 84 | </ul> |
|---|
| 85 | |
|---|
| 86 | <div id="editA" dojoType="dojo:Button" label="Edit Content A">Edit Content A</div> |
|---|
| 87 | <div id="content1"> |
|---|
| 88 | this is the first content area holding some data |
|---|
| 89 | </div> |
|---|
| 90 | |
|---|
| 91 | <br> |
|---|
| 92 | <br> |
|---|
| 93 | |
|---|
| 94 | <div id="editB" dojoType="dojo:Button" label="Edit Content B">Edit Content B</div> |
|---|
| 95 | |
|---|
| 96 | <div id="content2"> |
|---|
| 97 | this is the second content area holding some data |
|---|
| 98 | </div> |
|---|
| 99 | </body> |
|---|
| 100 | </html> |
|---|