Location: PHPKode > projects > EditArea > editarea_0_8_2/docs/javascript_functions.html
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head>
	<title>EditArea documentation</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link href="doc_style.css" rel="stylesheet" type="text/css" />
</head>
<body>
	<div class='header'>
		<h1>Javascript Functions</h1>
	</div>
	<div class='content'>
		<p>This is for advanced users. The object editAreaLoader has some public functions that can be called from the page in order to manage the EditArea editors.</p>
		
		
		<h3>editAreaLoader.getValue(editor_id)</h3>
		<blockquote>
			<p>This method return the content text of the editor. Works on normal textarea if the EditArea is toggled off.</p>        
			<table>
			<thead>
			<tr>
				<td colspan="2">Parameters</td>
			</tr>
			</thead>
			<tbody>
			<tr>
				<td>editor_id</td>
				<td>The id of the converted textarea</td>
			</tr>
			</tbody>
			</table>
	        <p><strong>Returns</strong>: the content text of the editor. <code>String</code></p>
	    </blockquote>

		<div class='separator'></div>

		<h3>editAreaLoader.setValue(editor_id, new_text)</h3>
		<blockquote>
			<p>This method allow to update the content text of an editor. Works on normal textarea if the EditArea is toggled off.</p>        
			<table>
			<thead>
			<tr>
				<td colspan="2">Parameters</td>
			</tr>
			</thead>
			<tbody>
			<tr>
				<td>editor_id</td>
				<td>The id of the converted textarea</td>
			</tr>
			<tr>
				<td>new_text</td>
				<td>The new text that will replace the Editor content.</td>
			</tr>
			</tbody>
			</table>
	        <p><strong>Returns</strong>: Nothing.</p>
		</blockquote>

		<div class='separator'></div>

		<h3>editAreaLoader.insertTags(editor_id, open_tag, close_tag)</h3>
		<blockquote>
			<p>This method allow to insert tags at the current position. If no text was selected, the cursor is then 
			displayed between the open and the close tags. Otherwise, the cursor is positionned after the close tag. 
				Works on normal textarea if the EditArea is toggled off.</p>        
			<table>
			<thead>
			<tr>
				<td colspan="2">Parameters</td>
			</tr>
			</thead>
			<tbody>
			<tr>
				<td>editor_id</td>
				<td>The id of the converted textarea</td>
			</tr>
			<tr>
				<td>open_tag</td>
				<td>The open tag string.</td>
			</tr>
			<tr>
				<td>close_tag</td>
				<td>The close tag string.</td>
			</tr>
			</tbody>
			</table>
	        <p><strong>Returns</strong>: Nothing.</p>
		</blockquote>
		
		<div class='separator'></div>

		<h3>editAreaLoader.getSelectedText(editor_id)</h3>
		<blockquote>
			<p>This method return the text contained in the the selection range. 
				Works on normal textarea if the EditArea is toggled off.</p>        
			<table>
			<thead>
			<tr>
				<td colspan="2">Parameters</td>
			</tr>
			</thead>
			<tbody>
			<tr>
				<td>editor_id</td>
				<td>The id of the converted textarea</td>
			</tr>
			</tbody>
			</table>
	        <p><strong>Returns</strong>: The text contained in the the selection range. <code>String</code></p>
		</blockquote>

		<div class='separator'></div>

		<h3>editAreaLoader.setSelectedText(editor_id, new_text)</h3>
		<blockquote>
			<p>This method allow to replace the text contained in the selection range with a given string. 
				The selection range will then contain the new string. 
				Works on normal textarea if the EditArea is toggled off.</p>        
			<table>
			<thead>
			<tr>
				<td colspan="2">Parameters</td>
			</tr>
			</thead>
			<tbody>
			<tr>
				<td>editor_id</td>
				<td>The id of the converted textarea</td>
			</tr>
			<tr>
				<td>new_text</td>
				<td>The string that will replace the current selected text.</td>
			</tr>
			</tbody>
			</table>
	        <p><strong>Returns</strong>: Nothing.</p>
		</blockquote>

		<div class='separator'></div>

		<h3>editAreaLoader.getSelectionRange(editor_id)</h3>
		<blockquote>
			<p>This method return the position start and position end of the selection range in the editor. 
				Works on normal textarea if the EditArea is toggled off.</p>        
			<table>
			<thead>
			<tr>
				<td colspan="2">Parameters</td>
			</tr>
			</thead>
			<tbody>
			<tr>
				<td>editor_id</td>
				<td>The id of the converted textarea</td>
			</tr>
			</tbody>
			</table>
	        <p><strong>Returns</strong>: An array containing the index of the selection start and end. 
				<code>Array("start", "end")</code> </p>
		</blockquote>

		<div class='separator'></div>

		<h3>editAreaLoader.setSelectionRange(editor_id, new_start, new_end)</h3>
		<blockquote>
			<p>This method allow to set the selection range with the given start and end positions. 
				Works on normal textarea if the EditArea is toggled off.</p>        
			<table>
			<thead>
			<tr>
				<td colspan="2">Parameters</td>
			</tr>
			</thead>
			<tbody>
			<tr>
				<td>editor_id</td>
				<td>The id of the converted textarea</td>
			</tr>
			<tr>
				<td>new_start</td>
				<td>The character position determining the start of the selection range.</td>
			</tr>
			<tr>
				<td>new_end</td>
				<td>The character position determining the end of the selection range.</td>
			</tr>
			</tbody>
			</table>
	        <p><strong>Returns</strong>: Nothing.</p>
		</blockquote>

		<div class='separator'></div>
	
		<h3>editAreaLoader.execCommand(editor_id, command, command_param)</h3>
		<blockquote>
			<p>Allow to access to EditArea functions and datas (for advanced users only).</p>        
			<table>
			<thead>
			<tr>
				<td colspan="2">Parameters</td>
			</tr>
			</thead>
			<tbody>
			<tr>
				<td>editor_id</td>
				<td>The id of the converted textarea on which the command should be executed.</td>
			</tr>
			<tr>
				<td>command</td>
				<td>The function or the parameter of the EditArea object that will be returned.</td>
			</tr>
			<tr>
				<td>command_param (optionnal)</td>
				<td>If command is a function, the you can pass one parameter to the function with command_param</td>
			</tr>
			</tbody>
			</table>
	        <p><strong>Returns</strong>: the value of the executed command or data. <code>unknown</code></p> 
	        
	        <table>
			<thead>
			<tr>
				<td colspan="2">Examples</td>
			</tr>
			</thead>
			<tbody>
			<tr>
				<td>Change edit mode</td>
				<td>
					<p>Allow to toggle EditArea etit mode from normal edition to readonly with no toolbars.</p>
					<pre>editAreaLoader.execCommand('editor_id', 'set_editable', !editAreaLoader.execCommand('editor_id', 'is_editable'));</pre>
				</td>
			</tr>
			<tr>
				<td>Insert tags</td>
				<td>
					<p>Insert tags arround selected text or at current cursor position if not text is selected</p>
					<pre>editAreaLoader.insertTags('editor_id', "[OPEN]", "[CLOSE]");</pre>
				</td>
			</tr>
			</tbody>
			</table>
	    </blockquote>

		<div class='separator'></div>
	
		<h3>editAreaLoader.delete_instance(editor_id)</h3>
		<blockquote>
			<p>Delete an instance of EditArea and restore simple textarea.</p>        
			<table>
			<thead>
			<tr>
				<td colspan="2">Parameters</td>
			</tr>
			</thead>
			<tbody>
			<tr>
				<td>editor_id</td>
				<td>The id of the converted textarea on which the command should be executed.</td>
			</tr>
			</tbody>
			</table>
	        <p><strong>Returns</strong>: Nothing.</p> 
	    </blockquote>

		<div class='separator'></div>
	
		<h3>editAreaLoader.hide(editor_id)</h3>
		<blockquote>
			<p>Hide a textarea and it's related EditArea.</p>        
			<table>
			<thead>
			<tr>
				<td colspan="2">Parameters</td>
			</tr>
			</thead>
			<tbody>
			<tr>
				<td>editor_id</td>
				<td>The id of the converted textarea on which the command should be executed.</td>
			</tr>
			</tbody>
			</table>
	        <p><strong>Returns</strong>: Nothing.</p> 
	    </blockquote>

		<div class='separator'></div>
	
		<h3>editAreaLoader.show(editor_id)</h3>
		<blockquote>
			<p>Restore a textarea and it's related EditArea hidden with the hide() function.</p>        
			<table>
			<thead>
			<tr>
				<td colspan="2">Parameters</td>
			</tr>
			</thead>
			<tbody>
			<tr>
				<td>editor_id</td>
				<td>The id of the converted textarea on which the command should be executed.</td>
			</tr>
			</tbody>
			</table>
	        <p><strong>Returns</strong>: Nothing.</p> 
	    </blockquote>

		<div class='separator'></div>
	
		<h3>editAreaLoader.openFile(editor_id, file_infos)</h3>
		<blockquote>
			<p></p>        
			<table>
			<thead>
			<tr>
				<td colspan="2">Parameters</td>
			</tr>
			</thead>
			<tbody>
			<tr>
				<td>editor_id</td>
				<td>The id of the converted textarea on which the command should be executed.</td>
			</tr>
			<tr>
				<td>file_infos</td>
				<td>An object containing datas of the file that will be openned. Here are the main fields (for the other possible fields see the returned Object of the getFile function):<br>
					<ul>
						<li><strong>id</strong> : (required) A string that will identify the file. it's the only required field.
							<br /><span class='underline'>Type</span>: String
						</li>
						<li><strong>title</strong> : (optionnal) The title that will be displayed in the tab area.
							<br /><span class='underline'>Type</span>: String
							<br /><span class='underline'>Default</span>: set with the id field value
						</li>
						<li><strong>text</strong> : (optionnal) The text content of the file.
							<br /><span class='underline'>Type</span>: String
							<br /><span class='underline'>Default</span>: ""
						</li>
						<li><strong>syntax</strong> : (optionnal) The syntax to use for this file.
							<br /><span class='underline'>Type</span>: String
							<br /><span class='underline'>Default</span>: ""
						</li>
						<li><strong>do_highlight</strong> : (optionnal) Set if the file should start highlighted or not
							<br /><span class='underline'>Type</span>: String
							<br /><span class='underline'>Default</span>: ""
						</li>
					</ul>
				</td>
			</tr>
			</tbody>
			</table>
	        <p><strong>Returns</strong>: Nothing.</p> 
	    </blockquote>

		<div class='separator'></div>
	
		<h3>editAreaLoader.getCurrentFile(editor_id)</h3>
		<blockquote>
			<p>Return datas of the currently selected file (for multi file editing mode).</p>        
			<table>
			<thead>
			<tr>
				<td colspan="2">Parameters</td>
			</tr>
			</thead>
			<tbody>
			<tr>
				<td>editor_id</td>
				<td>The id of the converted textarea on which the command should be executed.</td>
			</tr>
			</tbody>
			</table>
	        <p><strong>Returns</strong>: An object containing datas related to the file.<code>Object</code></p>
	    </blockquote>

		<div class='separator'></div>
	
		<h3>editAreaLoader.getFile(editor_id, file_id)</h3>
		<blockquote>
			<p>Return datas of the file identified by file_id (for multi file editing mode).</p>        
			<table>
			<thead>
			<tr>
				<td colspan="2">Parameters</td>
			</tr>
			</thead>
			<tbody>
			<tr>
				<td>editor_id</td>
				<td>The id of the converted textarea on which the command should be executed.</td>
			</tr>
			<tr>
				<td>file_id</td>
				<td>The id of the file to close.</td>
			</tr>
			</tbody>
			</table>
	        <p><strong>Returns</strong>: An object containing datas related to the file.<code>Object</code></p>
	    </blockquote>

		<div class='separator'></div>
	
		<h3>editAreaLoader.getAllFiles(editor_id)</h3>
		<blockquote>
			<p>Return datas of all the currently openned files (for multi file editing mode).</p>        
			<table>
			<thead>
			<tr>
				<td colspan="2">Parameters</td>
			</tr>
			</thead>
			<tbody>
			<tr>
				<td>editor_id</td>
				<td>The id of the converted textarea on which the command should be executed.</td>
			</tr>
			</tbody>
			</table>
	        <p><strong>Returns</strong>: An object containing datas of each files.<code>Object</code></p> 
	    </blockquote>

		<div class='separator'></div>
	
		<h3>editAreaLoader.closeFile(editor_id, file_id)</h3>
		<blockquote>
			<p>Close the file identified by file_id (for multi file editing mode).</p>        
			<table>
			<thead>
			<tr>
				<td colspan="2">Parameters</td>
			</tr>
			</thead>
			<tbody>
			<tr>
				<td>editor_id</td>
				<td>The id of the converted textarea on which the command should be executed.</td>
			</tr>
			<tr>
				<td>file_id</td>
				<td>The id of the file to close.</td>
			</tr>
			</tbody>
			</table>
	        <p><strong>Returns</strong>: Nothing.</p> 
	    </blockquote>

		<div class='separator'></div>
	
		<h3>editAreaLoader.setFileEditedMode(editor_id, file_id, edited_mode)</h3>
		<blockquote>
			<p>Define is the file should appears as edited or not.</p>        
			<table>
			<thead>
			<tr>
				<td colspan="2">Parameters</td>
			</tr>
			</thead>
			<tbody>
			<tr>
				<td>editor_id</td>
				<td>The id of the converted textarea on which the command should be executed.</td>
			</tr>
			<tr>
				<td>file_id</td>
				<td>The id of the file to close.</td>
			</tr>
			<tr>
				<td>edited_mode</td>
				<td>A boolean that indicate if the file should be set edited or not edited.</td>
			</tr>
			</tbody>
			</table>
	        <p><strong>Returns</strong>: Nothing.</p> 
	    </blockquote>
 
	</div>
	<div class='footer'>
		<div class="indexlink"><a href="index.html">Index</a></div>	
		<div class='copyright'>EditArea - &copy; Christophe Dolivet 2007-2010</div>
		<br style="clear: both" />
	</div>
</body>
</html>
Return current item: EditArea