tableeditor.html 3.1 KB

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