PageRenderTime 55ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/opencore/js/thirdparty/xinha/examples/ext_example-body.html

https://github.com/socialplanning/oc-js
HTML | 202 lines | 164 code | 31 blank | 7 comment | 0 complexity | 267d83e36c2fe67d19c8d00d6bc97e4a MD5 | raw file
  1. <!DOCTYPE BHTML PUBLIC "-//BC//DTD BHTML 3.2 Final//EN">
  2. <html>
  3. <head>
  4. <!-- ---------------------------------------------------------------------
  5. -- $HeadURL: http://svn.xinha.webfactional.com/tags/0.92beta/examples/ext_example-body.html $
  6. -- $LastChangedDate: 2007-01-22 10:06:18 -0500 (Mon, 22 Jan 2007) $
  7. -- $LastChangedRevision: 686 $
  8. -- $LastChangedBy: gocher $
  9. ------------------------------------------------------------------------ -->
  10. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  11. <title>Example of Xinha</title>
  12. <link rel="stylesheet" type="text/css" href="full_example.css" />
  13. <script type="text/javascript">
  14. function showError( sMsg, sUrl, sLine){
  15. document.getElementById('errors').value += 'Error: ' + sMsg + '\n' +
  16. 'Source File: ' + sUrl + '\n' +
  17. 'Line: ' + sLine + '\n';
  18. return false;
  19. }
  20. // You must set _editor_url to the URL (including trailing slash) where
  21. // where xinha is installed, it's highly recommended to use an absolute URL
  22. // eg: _editor_url = "/path/to/xinha/";
  23. // You may try a relative URL if you wish]
  24. // eg: _editor_url = "../";
  25. // in this example we do a little regular expression to find the absolute path.
  26. _editor_url = document.location.href.replace(/examples\/ext_example-body\.html.*/, '')
  27. //moved _editor_lang & _editor_skin to init function because of error thrown when frame document not ready
  28. </script>
  29. <!-- Load up the actual editor core -->
  30. <script type="text/javascript" src="../XinhaCore.js"></script>
  31. <script type="text/javascript">
  32. xinha_editors = null;
  33. xinha_init = null;
  34. xinha_config = null;
  35. xinha_plugins = null;
  36. xinha_init = xinha_init ? xinha_init : function() {
  37. window.onerror = showError;
  38. document.onerror = showError;
  39. var f = top.frames["menu"].document.forms["fsettings"];
  40. _editor_lang = f.lang[f.lang.selectedIndex].value; // the language we need to use in the editor.
  41. _editor_skin = f.skin[f.skin.selectedIndex].value; // the skin we use in the editor
  42. // What are the plugins you will be using in the editors on this page.
  43. // List all the plugins you will need, even if not all the editors will use all the plugins.
  44. xinha_plugins = [ ];
  45. for(var x = 0; x < f.plugins.length; x++) {
  46. if(f.plugins[x].checked) xinha_plugins.push(f.plugins[x].value);
  47. }
  48. // THIS BIT OF JAVASCRIPT LOADS THE PLUGINS, NO TOUCHING :)
  49. if(!Xinha.loadPlugins(xinha_plugins, xinha_init)) return;
  50. // What are the names of the textareas you will be turning into editors?
  51. var num = 1;
  52. num = parseInt(f.num.value);
  53. if(isNaN(num)) {
  54. num = 1;
  55. f.num.value = 1;
  56. }
  57. var dest = document.getElementById("editors_here");
  58. var lipsum = window.parent.menu.document.getElementById('myTextarea0').value;
  59. xinha_editors = [ ]
  60. for(var x = 0; x < num; x++) {
  61. var ta = 'myTextarea' + x;
  62. xinha_editors.push(ta);
  63. var div = document.createElement('div');
  64. div.className = 'area_holder';
  65. var txta = document.createElement('textarea');
  66. txta.id = ta;
  67. txta.name = ta;
  68. txta.value = lipsum;
  69. txta.style.width="100%";
  70. txta.style.height="420px";
  71. div.appendChild(txta);
  72. dest.appendChild(div);
  73. }
  74. // Create a default configuration to be used by all the editors.
  75. settings = top.frames["menu"].settings;
  76. xinha_config = new Xinha.Config();
  77. xinha_config.width = settings.width;
  78. xinha_config.height = settings.height;
  79. xinha_config.sizeIncludesBars = settings.sizeIncludesBars;
  80. xinha_config.statusBar = settings.statusBar;
  81. xinha_config.mozParaHandler = settings.mozParaHandler;
  82. xinha_config.undoSteps = settings.undoSteps;
  83. xinha_config.baseHref = settings.baseHref;
  84. xinha_config.stripBaseHref = settings.stripBaseHref;
  85. xinha_config.stripSelfNamedAnchors = settings.stripSelfNamedAnchors;
  86. xinha_config.only7BitPrintablesInURLs = settings.only7BitPrintablesInURLs;
  87. xinha_config.sevenBitClean = settings.sevenBitClean;
  88. xinha_config.killWordOnPaste = settings.killWordOnPaste;
  89. xinha_config.flowToolbars = settings.flowToolbars;
  90. xinha_config.showLoading = settings.showLoading;
  91. if (typeof CharCounter != 'undefined') {
  92. xinha_config.CharCounter.showChar = settings.showChar;
  93. xinha_config.CharCounter.showWord = settings.showWord;
  94. xinha_config.CharCounter.showHtml = settings.showHtml;
  95. }
  96. if (typeof CharacterMap != 'undefined') xinha_config.CharacterMap.mode = settings.CharacterMapMode;
  97. if (typeof ListType != 'undefined') xinha_config.ListType.mode = settings.ListTypeMode;
  98. if(typeof CSS != 'undefined') {
  99. xinha_config.pageStyle = "@import url(custom.css);";
  100. }
  101. if(typeof Stylist != 'undefined') {
  102. // We can load an external stylesheet like this - NOTE : YOU MUST GIVE AN ABSOLUTE URL
  103. // otherwise it won't work!
  104. xinha_config.stylistLoadStylesheet(document.location.href.replace(/[^\/]*\.html/, 'stylist.css'));
  105. // Or we can load styles directly
  106. xinha_config.stylistLoadStyles('p.red_text { color:red }');
  107. // If you want to provide "friendly" names you can do so like
  108. // (you can do this for stylistLoadStylesheet as well)
  109. xinha_config.stylistLoadStyles('p.pink_text { color:pink }', {'p.pink_text' : 'Pretty Pink'});
  110. }
  111. if(typeof DynamicCSS != 'undefined') {
  112. xinha_config.pageStyle = "@import url(dynamic.css);";
  113. }
  114. if(typeof InsertWords != 'undefined') {
  115. // Register the keyword/replacement list
  116. var keywrds1 = new Object();
  117. var keywrds2 = new Object();
  118. keywrds1['-- Dropdown Label --'] = '';
  119. keywrds1['onekey'] = 'onevalue';
  120. keywrds1['twokey'] = 'twovalue';
  121. keywrds1['threekey'] = 'threevalue';
  122. keywrds2['-- Insert Keyword --'] = '';
  123. keywrds2['Username'] = '%user%';
  124. keywrds2['Last login date'] = '%last_login%';
  125. xinha_config.InsertWords = {
  126. combos : [ { options: keywrds1, context: "body" },
  127. { options: keywrds2, context: "li" } ]
  128. }
  129. }
  130. if(typeof Filter != 'undefined') {
  131. xinha_config.Filters = ["Word", "Paragraph"];
  132. }
  133. // First create editors for the textareas.
  134. // You can do this in two ways, either
  135. // xinha_editors = Xinha.makeEditors(xinha_editors, xinha_config, xinha_plugins);
  136. // if you want all the editor objects to use the same set of plugins, OR;
  137. // xinha_editors = Xinha.makeEditors(xinha_editors, xinha_config);
  138. // xinha_editors['myTextarea0'].registerPlugins(['Stylist','FullScreen']);
  139. // xinha_editors['myTextarea1'].registerPlugins(['CSS','SuperClean']);
  140. // if you want to use a different set of plugins for one or more of the editors.
  141. xinha_editors = Xinha.makeEditors(xinha_editors, xinha_config, xinha_plugins);
  142. // If you want to change the configuration variables of any of the editors,
  143. // this is the place to do that, for example you might want to
  144. // change the width and height of one of the editors, like this...
  145. // xinha_editors['myTextarea0'].config.width = '640px';
  146. // xinha_editors['myTextarea0'].config.height = '480px';
  147. // Finally we "start" the editors, this turns the textareas into Xinha editors.
  148. Xinha.startEditors(xinha_editors);
  149. }
  150. // javascript submit handler
  151. // this shows how to create a javascript submit button that works with the htmleditor.
  152. submitHandler = function(formname) {
  153. var form = document.getElementById(formname);
  154. // in order for the submit to work both of these methods have to be called.
  155. form.onsubmit();
  156. window.parent.menu.document.getElementById('myTextarea0').value = document.getElementById('myTextarea0').value;
  157. form.submit();
  158. return true;
  159. }
  160. window.onload = xinha_init;
  161. // window.onunload = Xinha.collectGarbageForIE;
  162. </script>
  163. </head>
  164. <body>
  165. <form id="to_submit" name="to_submit" method="post" action="ext_example-dest.php">
  166. <div id="editors_here" name="editors_here"></div>
  167. <button type="button" onclick="submitHandler('to_submit');">Submit</button>
  168. <textarea id="errors" name="errors" style="width:100%; height:100px; background:silver;"></textarea><!-- style="display:none;" -->
  169. </form>
  170. </body>
  171. </html>