| 66 | | var pasteButton = dojo.byId("pastebutton"); |
| 67 | | dojo.event.connect(pasteButton, "onclick", function(){ |
| 68 | | editableRT.execCommand("inserthtml", "<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Quisque iaculis, nulla id semper faucibus, pede tellus nonummy magna, vitae adipiscing orci arcu ut augue. Nunc condimentum, magna a vestibulum convallis, libero purus pulvinar orci, sed vestibulum urna sem ut pede.</p>"); |
| | 55 | dojo.event.connect(savebutton, "onclick", function (e) { |
| | 56 | if (editableRT) { |
| | 57 | editableRT.close(true); |
| | 58 | savebutton.value = "edit"; |
| | 59 | editableRT = null; |
| | 60 | } else { |
| | 61 | editableRT = dojo.widget.createWidget("RichText", {}, editable); |
| | 62 | savebutton.value = "save"; |
| | 63 | } |
| | 64 | }); |
| | 65 | |
| | 66 | pasteButton = dojo.byId("pastebutton"); |
| | 67 | dojo.event.connect(pasteButton, "onclick", function(){ |
| | 68 | editableRT.execCommand("inserthtml", "<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Quisque iaculis, nulla id semper faucibus, pede tellus nonummy magna, vitae adipiscing orci arcu ut augue. Nunc condimentum, magna a vestibulum convallis, libero purus pulvinar orci, sed vestibulum urna sem ut pede.</p>"); |
| | 69 | }); |
| 75 | | |
| 76 | | dojo.event.connect(dojo, "loaded", function (e) { |
| 77 | | function makeEditable (e) { |
| 78 | | // create an editor from the table cell and keep it's width |
| 79 | | var editor = dojo.widget.createWidget("RichText", |
| 80 | | {inheritWidth: true}, e.currentTarget); |
| 81 | | editor.placeCursorAtEnd(); |
| 82 | | |
| 83 | | // save and exit on a blur |
| 84 | | dojo.event.connect(editor, "onBlur", function (e) { |
| 85 | | editor.close(); |
| 86 | | }); |
| 87 | | } |
| 88 | | |
| 89 | | var table = dojo.byId("editabletable"); |
| 90 | | var tds = table.getElementsByTagName("td"); |
| 91 | | for (var i = 0; i < tds.length; i++) { |
| 92 | | dojo.event.connect(tds[i], "onclick", makeEditable); |
| 93 | | } |
| | 76 | dojo.addOnLoad(function(){ |
| | 77 | dojo.event.connect(dojo, "loaded", function (e) { |
| | 78 | function makeEditable (e) { |
| | 79 | // create an editor from the table cell and keep it's width |
| | 80 | var editor = dojo.widget.createWidget("RichText", |
| | 81 | {inheritWidth: true}, e.currentTarget); |
| | 82 | editor.placeCursorAtEnd(); |
| | 83 | |
| | 84 | // save and exit on a blur |
| | 85 | dojo.event.connect(editor, "onBlur", function (e) { |
| | 86 | editor.close(); |
| | 87 | }); |
| | 88 | } |
| | 89 | |
| | 90 | table = dojo.byId("editabletable"); |
| | 91 | tds = table.getElementsByTagName("td"); |
| | 92 | for (var i = 0; i < tds.length; i++) { |
| | 93 | dojo.event.connect(tds[i], "onclick", makeEditable); |
| | 94 | } |
| | 95 | }); |