| 1 |
<!DOCTYPE html> |
| 2 |
<html> |
| 3 |
<!-- |
| 4 |
Copyright 2010 The Closure Library Authors. All Rights Reserved. |
| 5 |
|
| 6 |
Use of this source code is governed by the Apache License, Version 2.0. |
| 7 |
See the COPYING file for details. |
| 8 |
--> |
| 9 |
<head> |
| 10 |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> |
| 11 |
<title>goog.editor.SeamlessField</title> |
| 12 |
<script src="../../base.js"></script> |
| 13 |
<script> |
| 14 |
goog.require('goog.dom'); |
| 15 |
goog.require('goog.editor.SeamlessField'); |
| 16 |
</script> |
| 17 |
<link rel="stylesheet" href="../css/demo.css"> |
| 18 |
<style> |
| 19 |
#editMe { |
| 20 |
border: 1px solid grey; |
| 21 |
width: 600px; |
| 22 |
} |
| 23 |
|
| 24 |
#wrapper { |
| 25 |
background-color: #87CEFA; |
| 26 |
} |
| 27 |
|
| 28 |
h1 { |
| 29 |
font-family: courier; |
| 30 |
color: red; |
| 31 |
} |
| 32 |
|
| 33 |
p { |
| 34 |
margin: 0; |
| 35 |
background-color: lightgrey; |
| 36 |
} |
| 37 |
|
| 38 |
li { |
| 39 |
list-style-type: lower-greek; |
| 40 |
} |
| 41 |
|
| 42 |
table p { |
| 43 |
margin: 3px; |
| 44 |
background-color: white; |
| 45 |
} |
| 46 |
</style> |
| 47 |
</head> |
| 48 |
<body> |
| 49 |
<h1>goog.editor.SeamlessField</h1> |
| 50 |
<p>This is a very basic demonstration of how to make a region editable, that |
| 51 |
blends in with the surrounding page, even if the editable content is inside |
| 52 |
an iframe.</p> |
| 53 |
<input type="button" value="Make Editable" onclick="makeFieldEditable();" /> |
| 54 |
<input type="button" value="Make Uneditable" |
| 55 |
onclick="makeFieldUneditable();" /> |
| 56 |
<br> |
| 57 |
<div id="wrapper"> |
| 58 |
<br><br> |
| 59 |
<div id="editMe">I am a regular div. |
| 60 |
Click <b>"Make Editable"</b> above to transform me into an editable region. |
| 61 |
I'll grow and shrink with my content! |
| 62 |
And I'll inherit styles from the parent document. |
| 63 |
|
| 64 |
<h1>Heading styled by outer document.</h1> |
| 65 |
<ol> |
| 66 |
<li>And lists too! One!</li> |
| 67 |
<li>Two!</li> |
| 68 |
</ol> |
| 69 |
<p>Paragraph 1</p> |
| 70 |
<table><tr><td> |
| 71 |
<p>Inherited CSS works!</p> |
| 72 |
</td></tr></table> |
| 73 |
</div> |
| 74 |
<br><br> |
| 75 |
</div> |
| 76 |
<hr> |
| 77 |
<p><b>Current field contents</b> |
| 78 |
(updates as contents of the editable field above change):<br> |
| 79 |
<textarea id="fieldContents" style="height:100px;width:400px;"></textarea><br> |
| 80 |
<input type="button" value="Set Field Contents" |
| 81 |
onclick="myField.setHtml(false, goog.dom.getElement('fieldContents').value);" /> |
| 82 |
(Use to set contents of the editable field to the contents of this textarea) |
| 83 |
</p> |
| 84 |
|
| 85 |
<script> |
| 86 |
var myField = new goog.editor.SeamlessField('editMe'); |
| 87 |
|
| 88 |
function makeFieldEditable() { |
| 89 |
goog.events.listen(myField, goog.editor.Field.EventType.DELAYEDCHANGE, |
| 90 |
updateFieldContents); |
| 91 |
|
| 92 |
myField.makeEditable(); |
| 93 |
updateFieldContents(); |
| 94 |
} |
| 95 |
|
| 96 |
function makeFieldUneditable() { |
| 97 |
myField.makeUneditable(); |
| 98 |
} |
| 99 |
|
| 100 |
function updateFieldContents() { |
| 101 |
goog.dom.getElement('fieldContents').value = myField.getCleanContents(); |
| 102 |
} |
| 103 |
|
| 104 |
</script> |
| 105 |
</body> |
| 106 |
</html> |