Blame view

docs/js/editarea_0_8_2/exemples/exemple_full.html 9.51 KB
c2589de4   Luigi Serra   added demo page
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" >

  <head>

  	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

  	<title>EditArea - the code editor in a textarea</title>

  	<script language="Javascript" type="text/javascript" src="../edit_area/edit_area_full.js"></script>

  	<script language="Javascript" type="text/javascript">

  		// initialisation

  		editAreaLoader.init({

  			id: "example_1"	// id of the textarea to transform		

  			,start_highlight: true	// if start with highlight

  			,allow_resize: "both"

  			,allow_toggle: true

  			,word_wrap: true

  			,language: "en"

  			,syntax: "php"	

  		});

  		

  		editAreaLoader.init({

  			id: "example_2"	// id of the textarea to transform	

  			,start_highlight: true

  			,allow_toggle: false

  			,language: "en"

  			,syntax: "html"	

  			,toolbar: "search, go_to_line, |, undo, redo, |, select_font, |, syntax_selection, |, change_smooth_selection, highlight, reset_highlight, |, help"

  			,syntax_selection_allow: "css,html,js,php,python,vb,xml,c,cpp,sql,basic,pas,brainfuck"

  			,is_multi_files: true

  			,EA_load_callback: "editAreaLoaded"

  			,show_line_colors: true

  		});

  		

  		editAreaLoader.init({

  			id: "example_3"	// id of the textarea to transform	

  			,start_highlight: true	

  			,font_size: "8"

  			,font_family: "verdana, monospace"

  			,allow_resize: "y"

  			,allow_toggle: false

  			,language: "fr"

  			,syntax: "css"	

  			,toolbar: "new_document, save, load, |, charmap, |, search, go_to_line, |, undo, redo, |, select_font, |, change_smooth_selection, highlight, reset_highlight, |, help"

  			,load_callback: "my_load"

  			,save_callback: "my_save"

  			,plugins: "charmap"

  			,charmap_default: "arrows"

  				

  		});

  		

  		editAreaLoader.init({

  			id: "example_4"	// id of the textarea to transform		

  			//,start_highlight: true	// if start with highlight

  			//,font_size: "10"	

  			,allow_resize: "no"

  			,allow_toggle: true

  			,language: "de"

  			,syntax: "python"

  			,load_callback: "my_load"

  			,save_callback: "my_save"

  			,display: "later"

  			,replace_tab_by_spaces: 4

  			,min_height: 350

  		});

  		

  		// callback functions

  		function my_save(id, content){

  			alert("Here is the content of the EditArea '"+ id +"' as received by the save callback function:\n"+content);

  		}

  		

  		function my_load(id){

  			editAreaLoader.setValue(id, "The content is loaded from the load_callback function into EditArea");

  		}

  		

  		function test_setSelectionRange(id){

  			editAreaLoader.setSelectionRange(id, 100, 150);

  		}

  		

  		function test_getSelectionRange(id){

  			var sel =editAreaLoader.getSelectionRange(id);

  			alert("start: "+sel["start"]+"\nend: "+sel["end"]); 

  		}

  		

  		function test_setSelectedText(id){

  			text= "[REPLACED SELECTION]"; 

  			editAreaLoader.setSelectedText(id, text);

  		}

  		

  		function test_getSelectedText(id){

  			alert(editAreaLoader.getSelectedText(id)); 

  		}

  		

  		function editAreaLoaded(id){

  			if(id=="example_2")

  			{

  				open_file1();

  				open_file2();

  			}

  		}

  		

  		function open_file1()

  		{

  			var new_file= {id: "to\\ é # € to", text: "$authors= array();\n$news= array();", syntax: 'php', title: 'beautiful title'};

  			editAreaLoader.openFile('example_2', new_file);

  		}

  		

  		function open_file2()

  		{

  			var new_file= {id: "Filename", text: "<a href=\"toto\">\n\tbouh\n</a>\n<!-- it's a comment -->", syntax: 'html'};

  			editAreaLoader.openFile('example_2', new_file);

  		}

  		

  		function close_file1()

  		{

  			editAreaLoader.closeFile('example_2', "to\\ é # € to");

  		}

  		

  		function toogle_editable(id)

  		{

  			editAreaLoader.execCommand(id, 'set_editable', !editAreaLoader.execCommand(id, 'is_editable'));

  		}

  	

  	</script>

  </head>

  <body>

  <h2>EditArea examples</h2>

  <p>Retrieve EditArea on <a href='http://sourceforge.net/projects/editarea'>sourceforge</a> or on 

  	my personal <a href='http://www.cdolivet.com/index.php?page=editArea'>website</a>.

  </p>

  <form action='' method='post'>

  	<fieldset>

  		<legend>Example 1</legend>

  		<p>Test in English with php syntax, highlighted, toggle enabled, word-wrap enabled, resize enabled and default toolbar. Also offer the possibility to switch on/off the readonly mode.</p>

  		<textarea id="example_1" style="height: 350px; width: 100%;" name="test_1">

  <?php	

  	$authors	= array();

  	$news		= array();

  	/* this is a long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long comment for showing word-wrap feature */

  	$query	= "SELECT author, COUNT(id) as 'nb_news' FROM news_messages GROUP BY author";

  	$result	= mysql_query($query, $DBnews);

  	while( $line = mysql_fetch_assoc($result) ){

  		$authors[$line["author"]]	= $line["author"];

  		$news[$line["author"]]		= $line['nb_news'];

  	}

  	

  	$list= sprintf("('%s')", implode("', '", $authors));

  	

  	

  	$query="SELECT p.people_id, p.name, p.fname, p.status, team_name, t.leader_id=p.people_id as 'team_leader', w.name as 'wp_name', w.type

  			FROM people p, teams t, wppartis wp, wps w

  			WHERE p.people_id IN $list AND p.org_id=t.team_id AND wp.team_id=t.team_id AND wp.wp_id=w.wp_id 

  			GROUP BY p.people_id";

  	if(isset($_GET["order"]) && $_GET["order"]!="nb_news")

  		$query.=" ORDER BY ".$_GET["order"];

  		

  	$result=mysql_query($query, $DBkal);

  	while($line = mysql_fetch_assoc($result)){

  		printf("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>", $line["name"], $line["fname"],

  			$news[$line["people_id"]], $line["status"], $line["team_name"], ($line["team_leader"]=="1")?"yes":"no", $line["type"], $line["wp_name"]);

  	

  	}

  	printf("</table>");

  ?>

  		</textarea>

  		<p>Custom controls:<br />

  			<input type='button' onclick='alert(editAreaLoader.getValue("example_1"));' value='get value' />

  			<input type='button' onclick='editAreaLoader.setValue("example_1", "new_value");' value='set value' />

  			<input type='button' onclick='test_getSelectionRange("example_1");' value='getSelectionRange' />

  			<input type='button' onclick='test_setSelectionRange("example_1");' value='setSelectionRange' />

  			<input type='button' onclick='test_getSelectedText("example_1");' value='getSelectedText' />

  			<input type='button' onclick='test_setSelectedText("example_1");' value='setSelectedText' />

  			<input type='button' onclick='editAreaLoader.insertTags("example_1", "[OPEN]", "[CLOSE]");' value='insertTags' />

  			<input type='button' onclick='toogle_editable("example_1");' value='Toggle readonly mode' />

  		</p>

  	</fieldset>

  	<fieldset>

  		<legend>Example 2</legend>

  		<p>Multi file mode example with syntax selection option. The highlight colors of the selected line is also shown.</p>

  		<textarea id="example_2" style="height: 250px; width: 100%;" name="test_2">

  		</textarea>

  		<p>Custom controls:<br />

  			<input type='button' onclick='open_file1()' value='open file 1' />

  			<input type='button' onclick='open_file2()' value='open file 2' />

  			<input type='button' onclick='close_file1()' value='close file 1' />

  		</p>

  	</fieldset>

  	<fieldset>

  		<legend>Example 3</legend>

  		<p>Test in French with css syntax, verdana font, smaller default font size, toggle disabled, vertical only resize, custom toolbar, visual keyboard plugin, save and load callback examples.</p>

  <textarea id="example_3" style="height: 350px; width: 100%;" name="test_3">

  /* toolbar buttons (inspired from tinyMCE ones)*/

  .editAreaButtonNormal, .editAreaButtonOver, .editAreaButtonDown, .editAreaSeparator, .editAreaSeparatorLine, .editAreaButtonDisabled, .editAreaButtonSelected {

  	border: 0px; margin: 0px; padding: 0px; background: transparent;

  	margin-top: 0px;

  	margin-left: 1px;

  	padding: 0px;

  }

  

  .editAreaButtonNormal {

  	border: 1px solid #ECE9D8 !important;

  	cursor: pointer;

  }

  

  .editAreaButtonOver {

  	border: 1px solid #0A246A !important;

  	cursor: pointer;

  	background-color: #B6BDD2;

  }

  

  .editAreaButtonDown {

  	cursor: pointer;

  	border: 1px solid #0A246A !important;

  	background-color: #8592B5;

  }

  

  .editAreaButtonSelected {

  	border: 1px solid #C0C0BB !important;

  	cursor: pointer;

  	background-color: #F4F2E8;

  }

  

  .editAreaButtonDisabled {

  	filter:progid:DXImageTransform.Microsoft.Alpha(opacity=30);

  	-moz-opacity:0.3;

  	opacity: 0.3;

  	border: 1px solid #F0F0EE !important;

  	cursor: pointer;

  }

  

  .editAreaSeparatorLine {

  	margin: 1px 2px;

  	background-color: #C0C0BB;

  	width: 2px;

  	height: 18px;

  }		

  </textarea>

  	</fieldset>

  	<fieldset>

  		<legend>example 4</legend>

  		<p>Test in German with Python syntax, toggle enabled for a later display, with highlight not enabled by default, without resizing possibility (but with larger minimum height when editor is toggled), and with tabs replaced by 4 spaces.</p>

  <textarea id="example_4" style="height: 50px; width: 100%;" name="test_4">

  import Blender

   

  class Python:

  	# Instancie un objet

  	# cls = la classe Python et non pas l'object instancié

  	def __new__(cls):

  		pass

  	

  	# Constructeur de l'objet

  	def __init__(self):

  		self.items = [1, 2, 3]

  	

  	# Destructeur

  	def __del__(self):

  		print "Pourquoi tant de haine ?"

  	

  	# Utilisé pour : "len(p)"

  	def __len__(self):

  		return len(self.items)

  	

  	# Utilisé pour : "p[x]"

  	def __getitem__(self, key):

  		return self.items[key]

  	

  	# Utilisé pour : "x in p"

  	def __contains__(self, value):

  		return (value in self.items)

  	

  	# Utilisé pour : "for x in p"

  	def __iter__(self):

  		for x in self.items:

  			yield x

  </textarea>

  	</fieldset>

  </form>

  </body>

  </html>