| 1 | <!DOCTYPE html |
|---|
| 2 | PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" |
|---|
| 3 | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
|---|
| 4 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
|---|
| 5 | <head> |
|---|
| 6 | |
|---|
| 7 | <!--------------------------------------:noTabs=true:tabSize=2:indentSize=2:-- |
|---|
| 8 | -- Xinha example usage. This file shows how a developer might make use of |
|---|
| 9 | -- Xinha, it forms the primary example file for the entire Xinha project. |
|---|
| 10 | -- This file can be copied and used as a template for development by the |
|---|
| 11 | -- end developer who should simply removed the area indicated at the bottom |
|---|
| 12 | -- of the file to remove the auto-example-generating code and allow for the |
|---|
| 13 | -- use of the file as a boilerplate. |
|---|
| 14 | -- |
|---|
| 15 | -- $HeadURL: http://svn.xinha.org/trunk/examples/testbed.html $ |
|---|
| 16 | -- $LastChangedDate: 2009-11-08 17:36:46 +1300 (Sun, 08 Nov 2009) $ |
|---|
| 17 | -- $LastChangedRevision: 1197 $ |
|---|
| 18 | -- $LastChangedBy: gogo $ |
|---|
| 19 | ---------------------------------------------------------------------------> |
|---|
| 20 | |
|---|
| 21 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
|---|
| 22 | <title>Example of Xinha</title> |
|---|
| 23 | <link rel="stylesheet" href="files/full_example.css" /> |
|---|
| 24 | |
|---|
| 25 | <script type="text/javascript"> |
|---|
| 26 | // You must set _editor_url to the URL (including trailing slash) where |
|---|
| 27 | // where xinha is installed, it's highly recommended to use an absolute URL |
|---|
| 28 | // eg: _editor_url = "/path/to/xinha/"; |
|---|
| 29 | // You may try a relative URL htmlif you wish] |
|---|
| 30 | // eg: _editor_url = "../"; |
|---|
| 31 | // in this example we do a little regular expression to find the absolute path. |
|---|
| 32 | _editor_url = document.location.href.replace(/examples\/.*/, '') |
|---|
| 33 | _editor_lang = "en"; // And the language we need to use in the editor. |
|---|
| 34 | </script> |
|---|
| 35 | |
|---|
| 36 | <!-- Load up the actual editor core --> |
|---|
| 37 | <script type="text/javascript" src="../XinhaCore.js"></script> |
|---|
| 38 | |
|---|
| 39 | <script type="text/javascript"> |
|---|
| 40 | xinha_editors = null; |
|---|
| 41 | xinha_init = null; |
|---|
| 42 | xinha_config = null; |
|---|
| 43 | xinha_plugins = null; |
|---|
| 44 | |
|---|
| 45 | // This contains the names of textareas we will make into Xinha editors |
|---|
| 46 | xinha_init = xinha_init ? xinha_init : function() |
|---|
| 47 | { |
|---|
| 48 | /** STEP 1 *************************************************************** |
|---|
| 49 | * First, what are the plugins you will be using in the editors on this |
|---|
| 50 | * page. List all the plugins you will need, even if not all the editors |
|---|
| 51 | * will use all the plugins. |
|---|
| 52 | ************************************************************************/ |
|---|
| 53 | |
|---|
| 54 | xinha_plugins = xinha_plugins ? xinha_plugins : |
|---|
| 55 | [ |
|---|
| 56 | 'MootoolsFileManager' |
|---|
| 57 | ]; |
|---|
| 58 | // THIS BIT OF JAVASCRIPT LOADS THE PLUGINS, NO TOUCHING :) |
|---|
| 59 | if(!Xinha.loadPlugins(xinha_plugins, xinha_init)) return; |
|---|
| 60 | |
|---|
| 61 | /** STEP 2 *************************************************************** |
|---|
| 62 | * Now, what are the names of the textareas you will be turning into |
|---|
| 63 | * editors? |
|---|
| 64 | ************************************************************************/ |
|---|
| 65 | |
|---|
| 66 | xinha_editors = xinha_editors ? xinha_editors : |
|---|
| 67 | [ |
|---|
| 68 | 'myTextArea' |
|---|
| 69 | ]; |
|---|
| 70 | |
|---|
| 71 | /** STEP 3 *************************************************************** |
|---|
| 72 | * We create a default configuration to be used by all the editors. |
|---|
| 73 | * If you wish to configure some of the editors differently this will be |
|---|
| 74 | * done in step 4. |
|---|
| 75 | * |
|---|
| 76 | * If you want to modify the default config you might do something like this. |
|---|
| 77 | * |
|---|
| 78 | * xinha_config = new Xinha.Config(); |
|---|
| 79 | * xinha_config.width = 640; |
|---|
| 80 | * xinha_config.height = 420; |
|---|
| 81 | * |
|---|
| 82 | *************************************************************************/ |
|---|
| 83 | |
|---|
| 84 | xinha_config = xinha_config ? xinha_config : new Xinha.Config(); |
|---|
| 85 | xinha_config.fullPage = true; |
|---|
| 86 | with (xinha_config.MootoolsFileManager) |
|---|
| 87 | { |
|---|
| 88 | <?php |
|---|
| 89 | require_once('../contrib/php-xinha.php'); |
|---|
| 90 | xinha_pass_to_php_backend |
|---|
| 91 | ( |
|---|
| 92 | array |
|---|
| 93 | ( |
|---|
| 94 | 'images_dir' => getcwd() . '/images', |
|---|
| 95 | 'images_url' => '/examples/images', |
|---|
| 96 | 'allow_images_upload' => true, |
|---|
| 97 | |
|---|
| 98 | 'files_dir' => getcwd() . '/files', |
|---|
| 99 | 'files_url' => '/examples/files', |
|---|
| 100 | 'allow_files_upload' => true, |
|---|
| 101 | ) |
|---|
| 102 | ) |
|---|
| 103 | ?> |
|---|
| 104 | } |
|---|
| 105 | |
|---|
| 106 | /** STEP 3 *************************************************************** |
|---|
| 107 | * We first create editors for the textareas. |
|---|
| 108 | * |
|---|
| 109 | * You can do this in two ways, either |
|---|
| 110 | * |
|---|
| 111 | * xinha_editors = Xinha.makeEditors(xinha_editors, xinha_config, xinha_plugins); |
|---|
| 112 | * |
|---|
| 113 | * if you want all the editor objects to use the same set of plugins, OR; |
|---|
| 114 | * |
|---|
| 115 | * xinha_editors = Xinha.makeEditors(xinha_editors, xinha_config); |
|---|
| 116 | * xinha_editors['myTextArea'].registerPlugins(['Stylist']); |
|---|
| 117 | * xinha_editors['anotherOne'].registerPlugins(['CSS','SuperClean']); |
|---|
| 118 | * |
|---|
| 119 | * if you want to use a different set of plugins for one or more of the |
|---|
| 120 | * editors. |
|---|
| 121 | ************************************************************************/ |
|---|
| 122 | |
|---|
| 123 | xinha_editors = Xinha.makeEditors(xinha_editors, xinha_config, xinha_plugins); |
|---|
| 124 | |
|---|
| 125 | /** STEP 4 *************************************************************** |
|---|
| 126 | * If you want to change the configuration variables of any of the |
|---|
| 127 | * editors, this is the place to do that, for example you might want to |
|---|
| 128 | * change the width and height of one of the editors, like this... |
|---|
| 129 | * |
|---|
| 130 | * xinha_editors.myTextArea.config.width = 640; |
|---|
| 131 | * xinha_editors.myTextArea.config.height = 480; |
|---|
| 132 | * |
|---|
| 133 | ************************************************************************/ |
|---|
| 134 | |
|---|
| 135 | |
|---|
| 136 | /** STEP 5 *************************************************************** |
|---|
| 137 | * Finally we "start" the editors, this turns the textareas into |
|---|
| 138 | * Xinha editors. |
|---|
| 139 | ************************************************************************/ |
|---|
| 140 | |
|---|
| 141 | Xinha.startEditors(xinha_editors); |
|---|
| 142 | window.onload = null; |
|---|
| 143 | } |
|---|
| 144 | |
|---|
| 145 | window.onload = xinha_init; |
|---|
| 146 | </script> |
|---|
| 147 | </head> |
|---|
| 148 | |
|---|
| 149 | <body> |
|---|
| 150 | |
|---|
| 151 | <form action="javascript:void(0);" id="editors_here" onsubmit="alert(this.myTextArea.value);"> |
|---|
| 152 | <div> |
|---|
| 153 | <textarea id="myTextArea" name="myTextArea" style="width:100%;height:320px;"> |
|---|
| 154 | <html> |
|---|
| 155 | <head> |
|---|
| 156 | <title>Hello</title> |
|---|
| 157 | <style type="text/css"> |
|---|
| 158 | li { color:red; } |
|---|
| 159 | </style> |
|---|
| 160 | </head> |
|---|
| 161 | <body><span style="color:purple"> |
|---|
| 162 | <img src="../images/xinha_logo.gif" usemap="#m1"> |
|---|
| 163 | <map name="m1"> |
|---|
| 164 | <area shape="rect" coords="137,101,255,124" href="http://www.mydomain.com"> |
|---|
| 165 | </map> |
|---|
| 166 | |
|---|
| 167 | <p> |
|---|
| 168 | Lorem ipsum dolor sit amet, consectetuer adipiscing elit. |
|---|
| 169 | Aliquam et tellus vitae justo varius placerat. Suspendisse iaculis |
|---|
| 170 | velit semper dolor. Donec gravida tincidunt mi. Curabitur tristique |
|---|
| 171 | ante elementum turpis. <span style="color:green">Aliquam </span> nisl. Nulla posuere neque non |
|---|
| 172 | tellus. Morbi vel nibh. <font face="Arial"><font color="#009933">Cum sociis natoque</font></font> penatibus et magnis dis |
|---|
| 173 | parturient montes, nascetur ridiculus mus. Nam nec wisi. In wisi. |
|---|
| 174 | Curabitur pharetra bibendum lectus. |
|---|
| 175 | </p> |
|---|
| 176 | |
|---|
| 177 | <ul> |
|---|
| 178 | <li style="color:green"> Phasellus et massa sed diam viverra semper. </li> |
|---|
| 179 | <li> Mauris tincidunt felis in odio. </li> |
|---|
| 180 | <li> Nulla placerat nunc ut pede. </li> |
|---|
| 181 | <li> Vivamus ultrices mi sit amet urna. </li> |
|---|
| 182 | <li> Quisque sed augue quis nunc laoreet volutpat.</li> |
|---|
| 183 | <li> Nunc sit amet metus in tortor semper mattis. </li> |
|---|
| 184 | </ul> |
|---|
| 185 | </span></body> |
|---|
| 186 | </html> |
|---|
| 187 | </textarea> |
|---|
| 188 | |
|---|
| 189 | <input type="submit" /> <input type="reset" /> |
|---|
| 190 | </div> |
|---|
| 191 | </form> |
|---|
| 192 | <script type="text/javascript"> |
|---|
| 193 | document.write(document.compatMode); |
|---|
| 194 | </script> |
|---|
| 195 | <div> |
|---|
| 196 | <a href="#" onclick="xinha_editors.myTextArea.hidePanels();">Hide</a> |
|---|
| 197 | <a href="#" onclick="xinha_editors.myTextArea.showPanels();">Show</a> |
|---|
| 198 | </div> |
|---|
| 199 | |
|---|
| 200 | </body> |
|---|
| 201 | </html> |
|---|