| 1 |
<html> |
| 2 |
<!-- |
| 3 |
Copyright 2009 The Closure Library Authors. All Rights Reserved. |
| 4 |
|
| 5 |
Use of this source code is governed by the Apache License, Version 2.0. |
| 6 |
See the COPYING file for details. |
| 7 |
--> |
| 8 |
<!-- |
| 9 |
Author: [email protected] (Nick Santos) |
| 10 |
--> |
| 11 |
<head> |
| 12 |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> |
| 13 |
<title>goog.editor.plugins.TableEditor Demo</title> |
| 14 |
<script src="../../base.js"></script> |
| 15 |
<script> |
| 16 |
goog.require('goog.dom'); |
| 17 |
goog.require('goog.editor.Command'); |
| 18 |
goog.require('goog.editor.Field'); |
| 19 |
goog.require('goog.editor.plugins.TableEditor'); |
| 20 |
goog.require('goog.ui.editor.DefaultToolbar'); |
| 21 |
goog.require('goog.ui.editor.ToolbarController'); |
| 22 |
</script> |
| 23 |
|
| 24 |
<link rel="stylesheet" href="../css/demo.css"> |
| 25 |
|
| 26 |
<link rel="stylesheet" href="../../css/button.css" /> |
| 27 |
<link rel="stylesheet" href="../../css/dialog.css" /> |
| 28 |
<link rel="stylesheet" href="../../css/linkbutton.css" /> |
| 29 |
<link rel="stylesheet" href="../../css/menu.css"> |
| 30 |
<link rel="stylesheet" href="../../css/menuitem.css"> |
| 31 |
<link rel="stylesheet" href="../../css/menuseparator.css"> |
| 32 |
<link rel="stylesheet" href="../../css/tab.css" /> |
| 33 |
<link rel="stylesheet" href="../../css/tabbar.css" /> |
| 34 |
<link rel="stylesheet" href="../../css/toolbar.css" /> |
| 35 |
<link rel="stylesheet" href="../../css/editortoolbar.css" /> |
| 36 |
|
| 37 |
<style> |
| 38 |
#editMe { |
| 39 |
width: 600px; |
| 40 |
height: 300px; |
| 41 |
background-color: white; |
| 42 |
border: 1px solid grey; |
| 43 |
} |
| 44 |
</style> |
| 45 |
</head> |
| 46 |
|
| 47 |
<body> |
| 48 |
<h1>goog.editor.plugins.TableEditor Demo</h1> |
| 49 |
<p>This is a demonstration of the table editor plugin for goog.editor.</p> |
| 50 |
<br> |
| 51 |
<div id='toolbar' style='width:602px'></div> |
| 52 |
<div id='editMe'></div> |
| 53 |
<hr> |
| 54 |
<p><b>Current field contents</b> |
| 55 |
(updates as contents of the editable field above change):<br> |
| 56 |
<textarea id="fieldContents" style="height:100px;width:400px;"></textarea><br> |
| 57 |
<input type="button" value="Set Field Contents" |
| 58 |
onclick="myField.setHtml(false, goog.dom.getElement('fieldContents').value);" /> |
| 59 |
(Use to set contents of the editable field to the contents of this textarea) |
| 60 |
</p> |
| 61 |
|
| 62 |
<script> |
| 63 |
function updateFieldContents() { |
| 64 |
goog.dom.getElement('fieldContents').value = myField.getCleanContents(); |
| 65 |
} |
| 66 |
|
| 67 |
var myField = new goog.editor.Field('editMe'); |
| 68 |
|
| 69 |
myField.registerPlugin(new goog.editor.plugins.TableEditor()); |
| 70 |
|
| 71 |
// Specify the buttons to add to the toolbar, using built in default buttons. |
| 72 |
var buttonIds = goog.object.getValues( |
| 73 |
goog.editor.plugins.TableEditor.COMMAND); |
| 74 |
var buttons = [] |
| 75 |
for (var i = 0; i < buttonIds.length; i++) { |
| 76 |
var cmd = buttonIds[i]; |
| 77 |
buttons[i] = goog.ui.editor.ToolbarFactory.makeButton(cmd, cmd, cmd); |
| 78 |
} |
| 79 |
var myToolbar = goog.ui.editor.DefaultToolbar.makeToolbar(buttons, |
| 80 |
goog.dom.getElement('toolbar')); |
| 81 |
|
| 82 |
// Hook the toolbar into the field. |
| 83 |
var myToolbarController = |
| 84 |
new goog.ui.editor.ToolbarController(myField, myToolbar); |
| 85 |
|
| 86 |
// Watch for field changes, to display below. |
| 87 |
goog.events.listen(myField, goog.editor.Field.EventType.DELAYEDCHANGE, |
| 88 |
updateFieldContents); |
| 89 |
|
| 90 |
myField.makeEditable(); |
| 91 |
updateFieldContents(); |
| 92 |
</script> |
| 93 |
</body> |
| 94 |
</html> |