diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index a352105ab..471f6e353 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -46,6 +46,8 @@ - fixed #8807: _NewAsset.skeleton out of date - added: "Duplicate this template and edit" now updates the asset we came from, if any - fixed #8818: Visitor sends a welcome message + - added: "EditArea" code highlighter and editing tool for WebGUI::Form::Codearea, used + in Template, Snippet, SQLReport, and more 7.6.0 - added: users may now customize the post received page for the CS diff --git a/lib/WebGUI/Asset/Template.pm b/lib/WebGUI/Asset/Template.pm index 5a4568c53..e24a5ac15 100644 --- a/lib/WebGUI/Asset/Template.pm +++ b/lib/WebGUI/Asset/Template.pm @@ -69,6 +69,7 @@ sub definition { properties => { template => { fieldType => 'codearea', + syntax => "html", defaultValue => undef, }, isEditable => { @@ -165,6 +166,7 @@ sub getEditForm { -name=>"template", -label=>$i18n->get('assetName'), -hoverHelp=>$i18n->get('template description'), + -syntax => "html", -value=>$self->getValue("template") ); $tabform->getTab("properties")->codearea( diff --git a/lib/WebGUI/Asset/Wobject/SQLReport.pm b/lib/WebGUI/Asset/Wobject/SQLReport.pm index 6ac5c868c..bdb1394dc 100644 --- a/lib/WebGUI/Asset/Wobject/SQLReport.pm +++ b/lib/WebGUI/Asset/Wobject/SQLReport.pm @@ -52,10 +52,12 @@ sub definition { }, dbQuery1=>{ fieldType=>"codearea", - defaultValue=>undef + syntax => "sql", + defaultValue=>undef, }, prequeryStatements1=>{ fieldType=>"codearea", + syntax => "sql", defaultValue=>undef }, preprocessMacros1=>{ @@ -72,10 +74,12 @@ sub definition { }, dbQuery2=>{ fieldType=>"codearea", + syntax => "sql", defaultValue=>undef }, prequeryStatements2=>{ fieldType=>"codearea", + syntax => "sql", defaultValue=>undef }, preprocessMacros2=>{ @@ -92,10 +96,12 @@ sub definition { }, dbQuery3=>{ fieldType=>"codearea", + syntax => "sql", defaultValue=>undef }, prequeryStatements3=>{ fieldType=>"codearea", + syntax => "sql", defaultValue=>undef }, preprocessMacros3=>{ @@ -112,10 +118,12 @@ sub definition { }, dbQuery4=>{ fieldType=>"codearea", + syntax => "sql", defaultValue=>undef }, prequeryStatements4=>{ fieldType=>"codearea", + syntax => "sql", defaultValue=>undef }, preprocessMacros4=>{ @@ -132,10 +140,12 @@ sub definition { }, dbQuery5=>{ fieldType=>"codearea", + syntax => "sql", defaultValue=>undef }, prequeryStatements5=>{ fieldType=>"codearea", + syntax => "sql", defaultValue=>undef }, preprocessMacros5=>{ @@ -324,12 +334,14 @@ sub getEditForm { -name => "prequeryStatements".$nr, -label => $i18n->get('Prequery statements'), -hoverHelp => $i18n->get('Prequery statements description'), + -syntax => "sql", -value => $self->getValue("prequeryStatements".$nr), ); $tabform->getTab("properties")->codearea( -name=>"dbQuery".$nr, -label=>$i18n->get(4), -hoverHelp=>$i18n->get('4 description'), + -syntax => "sql", -value=>$self->getValue("dbQuery".$nr) ); $tabform->getTab("properties")->databaseLink( diff --git a/lib/WebGUI/Form/Codearea.pm b/lib/WebGUI/Form/Codearea.pm index bf4c7dc50..0e19ce0d4 100644 --- a/lib/WebGUI/Form/Codearea.pm +++ b/lib/WebGUI/Form/Codearea.pm @@ -59,6 +59,11 @@ Style attributes besides width and height which should be specified using the ab The following additional parameters have been added via this sub class. +=head4 syntax + +The type of syntax highlighting to use by default. The types available are located at +$WEBGUI_ROOT/www/extras/editarea/edit_area/reg_syntax + =cut sub definition { @@ -75,8 +80,11 @@ sub definition { style=>{ defaultValue => undef, }, - }); - return $class->SUPER::definition($session, $definition); + syntax => { + defaultValue => "html", + }, + }); + return $class->SUPER::definition($session, $definition); } #------------------------------------------------------------------- @@ -125,10 +133,36 @@ Renders a code area field. =cut sub toHtml { - my $self = shift; - $self->session->style->setScript($self->session->url->extras('TabFix.js'),{type=>"text/javascript"}); - $self->set("extras", $self->get('extras').' onkeypress="return TabFix_keyPress(event)" onkeydown="return TabFix_keyDown(event)"'); - return $self->SUPER::toHtml; + my $self = shift; + my $output = ""; + + # Do our superclass's job + my $value = $self->fixMacros($self->fixTags($self->fixSpecialCharacters($self->getOriginalValue))); + my $width = $self->get('width') || 400; + my $height = $self->get('height') || 150; + my ($style, $url) = $self->session->quick(qw(style url)); + my $styleAttribute = "width: ".$width."px; height: ".$height."px; ".$self->get("style"); + $style->setRawHeadTags(qq||); + $output = ''; + + # Vars for JS below + my $id = $self->get( "id" ); + my $syntax = $self->get( "syntax" ); + my $editareaPath = $self->session->url->extras( 'editarea' ); + + $self->session->style->setScript($editareaPath . '/edit_area/edit_area_full.js',{type=>"text/javascript"}); + $output .= qq~ + + ~; + + return $output; } diff --git a/www/extras/editarea/change_log.txt b/www/extras/editarea/change_log.txt new file mode 100755 index 000000000..e2699d5d5 --- /dev/null +++ b/www/extras/editarea/change_log.txt @@ -0,0 +1,234 @@ +**** v 0.7.2.2 **** +- Fix bug regression introduced in 0.7.2 that make IE7 not working +- add Esperento translation (thanks to Olivier) +- add Coldfusion syntax (thanks to Max Leynov) + +**** v 0.7.2.1 **** +- fix bug for firefox rendering of highlighted lines that doesn't begin with a tab +- support for browser with grandParadisio agent instead of firefox + +**** v 0.7.2 **** +- add Chrome support +- add show_line_colors init() option for enabling syntax color display and update on the currently edited line (disable the blue bar) (default to false) +- Add Perl syntax definition file (thanks to Christoph Pinkel) +- Bug fix: there allways was an horizontal scrollbar even if the content fit in the area. + +**** v 0.7.1.3 **** +- Fix a bug introduced in Firefox 3.0.1 => the browser is no more able to render properly "pre" element with left padding... +- Add Robots.txt (thanks to Pavle Ggardijan) and T-SQL syntax definition files (thanks to Miladin Joksic) + +**** v 0.7.1.2 **** +- Fix a bug on the full screen mode (regression added on 0.7.1.1) + +**** v 0.7.1.1 **** +- Firefox 3 RC1 compatibility +- Code size reduction: 120Ko => 107Ko for edit_area_full.js + +**** v 0.7.1 **** +- released under both LGPL and Apache license (you can use the one you prefer) +- it's now possible to get a readonly mode: + * new EditAreaLoader.init()'s option: "is_editable": true/false + * Possibility to switch edition mode by using the execCommand function: editAreaLoader.execCommand('editor_id', 'set_editable', !editAreaLoader.execCommand('editor_id', 'is_editable')); +- Added Ruby syntax (thanks to Patrice De Saint Steban) +- Fix a bug where the textarea lose the focus under firefox for Mac +- Minor other bug fixes + +**** v 0.7.0.2 **** +- Fixed a bug with translation files containing non-latin caracters. Translations files must be in UTF-8. +- Added Czech, Macedionian and Russian translations + + +**** v 0.7.0.1 **** +- in multiple file mode, it's now possible to cancel the 'EA_file_close_callback' function. if the callback return false, the edited file won't be closed +- bug fix: if no syntax was defined in the main init() function in multifile mode, the first time the text was not highlighted + + +**** v 0.7 **** +- it's now possible to edit multiple files into one instance of EditArea. This (sponsored by Jupiter) feature comes with: + * new EditAreaLoader.init()'s option: "is_multi_files": true + * new editAreaLoader's functions: editAreaLoader.getCurrentFile(editArea_id), editAreaLoader.getFile(editArea_id, file_id), editAreaLoader.getAllFiles(editArea_id), editAreaLoader.openFile(editArea_id, file_infos), editAreaLoader.closeFile(editArea_id, file_id), editAreaLoader.setFileEditedMode(editArea_id, file_id, edited_mode) + * new callabacks: EA_file_switch_on_callback, EA_file_switch_off_callback, EA_file_close_callback +- look likes Safari 3 is working with EditArea +- add spanish translation (thanks Garito) +- add slovak translation (thanks Gabriel Schwardy) +- add SQL syntax definition file (thanks to Philippe Lewicki) +- the syntax selection plugin has been integrated to editarea core and load only needed files (the plugins was loading all the possible syntax files...). Toolbar button name: "syntax_selection", comma separated available syntax list: "syntax_selection_allow" +- add a 'compression' option in edit_area_compressor.php that allow to set where the code should be compressed or just packed (simple packed mode usefull for debugging) +- the yellow area that indicate the current edited line is now blue +- bug fix: parenthesis matching was not working correctly if there where an "<" between parenthesis + +**** v 0.6.7 **** +- add a new plugin that allow the user to change the syntax definition in use. It adds a select in the toolbar. - plugin name to add to the plugin list: "syntax_selection". - plugin name to add to the toolbar list: "syntax_selection". - possible parameter to add to EditAreaLoader.init(): +"syntax_selection_allow": (String) define a list separated by "," of possible language syntax to use (eg: "php,js,python,html") +- add Croatian translation (HR) (thanks to Ivan Vucica and Davor Cihlar) +- add BASIC, Brainf*ck, C, C++ and Pascal syntax definition files (thanks to Ivan Vucica and Davor Cihlar) +- add Iceweasel as a known working navigator (its a clone of Firefox) +- improved the php syntax by highlighting the variables ($...) +- reactivate gzip compression for IE7 (was desactivate for IE as it sometimes failed). (Let me know if you see that the load fails under IE7) +- pressing "enter" while being in the search box now perform a search. +- add Camino as a supported browser +- bug fix: when clicking between the bottom toolbar and the textarea (when there is only few lines of text), the textarea didn't get the focus +- bug fix: under IE the delete_instance() method was throwing an error +- bug fix: if the textarea to convert in an EditArea was in a frame (or iframe) getting back from fullscreen to normal display was not restoring the correct settings to the frame containing the textarea. +- bug fix (at least I hope): in IE if the textarea to convert in an EditArea was in a frame, resizing the frame was not correctly resizing the editor if it was in fullscreen. +- bug fix: in Opera the selectionned line was not rendered correctly if containing \t caracters (bug introduced in one of the latest version...) +- bug fix: "altgr+f" was openning the searchbox and avoid to write "[" and "]" in croatian keyboards. +- bug fix: in Firefox "ctrl+tab" was inserting a tabulation while switching active tab (window) + +Note: v 0.6.5 and v 0.6.6 have been private release (change log is regrouped in v 0.6.7) + +**** v 0.6.4 **** +- add replace_tab_by_spaces init() option which allow to replace all tabulation caracters typped in the text by a given number of spaces +- add min_width and min_height init() option for the minimum size in pixel for the editor +- add dutch translation files (NL) (thanks to Bart Bosma) +- pressing Shift+Tab when no text is selected now delete the tabulation before the cursor (if a tabulation is present directly behing the cursor) +- improve Python syntax (thanks to Andre Roberge) +- bug fix: the fullpage plugin was not working correctly when the Editor was placed inside several divs that have positioning of there own +- bug fix: one regexp used in edit_area_compressor.php was not compatible with latest PCRE version + +- fix the my_load and my_save functions of the 'exemple_full.html' page + +**** v 0.6.3.1 **** +- regression: restore monospace as default font +- add little improvements to the PHP compressor: allow to win 7 Ko on edit_area_full.js +- add the version number in the about popup +- bug fix: fix a regexp that was not compliant with newer version of PCRE +- bug fix: fix some bug with the fullscreen mode (still not perfect in Opera) +- bug fix: the close button of the help popup was not correctly translated +- bug fix: when deleting an instance of editArea toggle_off was called even if the editArea was not displayed + + +**** v 0.6.3 **** +- allow to use non monospace font using the font_family init option. Firefox get smaller tabulation with non monospace fonts. IE doesn't change the tabulation width and Opera doesn't take this option into account... new default font-familly: 'verdana,monospace' +- add fullscreen option in the toolbar and as an init() option. +- if the based textarea has a width (or height) in '%', EditArea will get the same '%' width (or height), allowing EditArea to be resized in the same time than the window. +- add many callback possibility: submit_callback, EA_load_callback, EA_unload_callback, EA_init_callback, EA_toggle_on_callback, EA_toggle_off_callback, EA_delete_callback (see documentation for more information) +- bug fix: when toggling from textarea to editarea, IE was almost of the time not keeping the selection +- bug fix: the brackets where still highlighted in red when being deleted +- bug fix: brackets where not placed correctly when the line contains html entitites (& " etc....) + + +**** v 0.6.2 **** +WARNING => POSSIBLE BREAK COMPATIBILITY: +- the load_callback now receive the 'id' of the textarea and no more a reference to the textarea. Developpers should use editAreaLoder methods rather than modfying directly the textarea. +- the save_callback now receive the 'id' of the textarea as first argument, and it's content in the second argument. + +- EditArea is now compatible with javascript libraries like "prototype" (1.5) and "mootools" (release 83) +- add two function to EditAreaLoader: hide(id) and show(id), that will allow to completly hide/restore both EditArea and normal textarea (usefull when EditArea is included in tabs). +- it's no more possible to move the search window out of the frame. +- gecko_spellcheck option is now set to false by default. +- add a onchange_callback option (cf doc) +- bug fix: in IE when syntax highlight was on, clicking on the textarea outside the range of the text, the click wasn't taking into account. +- bug fix: references to the orginal textarea could be lost while using EditArea. +- bug fix: using insertTags, getSelectionRange when editArea was not focused, IE failed +- bug fix: main script could fail to load additionnal files in certain specific cases + +**** v 0.6.1 **** +- compatiblity with Firefox 2 checked (was already compatible before). +- compatiblity with IE7 checked (was already compatible before). +- added possibility to call the editAreaLoader.init() function at any moment (no more limited to window load). Allow to replace an EditArea instance by a new one with other options. +- added new gecko_spellcheck option, this enables you to disable/enable the FF 2.0 spellchecker. +- added editAreaLoader.delete_instance(id) to allow to delete an EditArea instance +- Fix a bug where "Ctrl+G" wasn't openning anymore the go to line prompt box. + + +**** v 0.6.0.1 **** +- add italian translation (thanks to Luciano Vernaschi) +- add polish translation (thanks to Piotr Furman) +- improve deutsh translation (thanks to Felix Riesterer) +- add a little style improvement for buttons in search popup. they can't be splited in two line anymore +- change color for tags in html and xml syntax due to visibility problems + + +**** v 0.6 **** +- add plugins possibilies +- add editAreaLoader.insertTags function to allow easy tags insertion. +- improve undo & redo functionnality +- improve php compression: "edit_area_full.js" is 9 Ko smaller +- improve syntax highlight regexp for quotted string. \\" or \\' (or \\\\", etc...) will now effectively close quotted string +- add scrollbars to the popups when the popup's height is smaller than the editor's height +- add japanese translation file (thanks to ISHITOYA Kentaro) +- add possibility to add line-break in toolbar ("*") +- disable gzip compression for IE (see: http://support.microsoft.com/default.aspx?scid=kb;en-us;Q312496) +- bug fix: when submitting form while editarea toggled off, the post value was equals to the old content of editarea and not the visible textarea +- bug fix: under IE the editor was scrolling when pressing enter +- bug fix: when insterting text on first line there was an highlight desynchronization + + + +**** v 0.5.3 **** +WARNING => POSSIBLE BREAK COMPATIBILITY: +- correct a spelling error: "toogle" become "toggle" in the whole code. This can perturb the initialization with the "allow_toggle" init parameters + +- add a case sensitive option in syntax definition files +- improve html syntax definition file +- add xml syntax definition file +- add vb syntax definition file (thanks to Martin Gottlieb) +- add some function that will allow dynamic EditArea content management, taking into account if the editor is displayed or toggled off (editAreaLodaer.getValue(), editAreaLoader.setValue(), editAreaLoader.getSelectedText(), editAreaLoader.setSelectedText(), editAreaLoader.getSelectionRange and editAreaLoader.setSelectionRange()). See "javascript functions" documentation for more informations +- add a generic function (editaAreaLoader.execCommand) to allow to access EditArea's functions and datas +- add portuguese translation file (thanks to Leonardo Sapucaia) +- add compatibility to IE7 RC1 + + +**** v 0.5.2 **** +- Opera improvement: text indentation is now working, and "go to line" is now working as in other browsers +- Bug fix: It was still possible to select text in search popup +- Bug fix: the "go to line" popup wasn't displaying anymore +- There was still some hard codded word in the search field => added them to translation files +- Bug fix: when multiple languages were used in the same page, there could have translation exchange between the different editors + + +**** v 0.5.1 **** +- Bug fix: the highlighted bracket was displayed on line 1 when it should be in line 2 +- Bug fix: the highlighted bracket were bad displayed in IE +- Bug fix: their was some error in the optimisation process of the highlight mode +- Bug fix: their was a bug when moving the search popup on IE + +**** v 0.5 **** +- Now released under LGPL +- Rewrite nearly from scratch +- Added Danish translation file (thanks to Peter Klein) +- Add python syntax + + +WARNING => BREAK COMPATIBILITY: +- the whole loading process (javascript include and init function call) is changed (but it's similar to the old version) +- the languages translation files are not stored in the same variable + + +IMPROVEMENTS: +- The whole code is more stable +- Allow several instance on the same page +- Faster to load +- The highlight process is more stable and there is nearly no more to use the "re sync" button +- Add support of Opera 9 (even if its still not perfect) +- Add the possibility to load a new compressed script of only 20Ko for the whole core script even if PHP is not installed +- The textarea can be toggled to an EditArea on window load or later +- The EditArea is loaded in a iframe => there is no more interaction with user css +- Support the reset action of a form +- Add support for "page up" & "page down" button +- There is now a waiting screen when toggling on the highlight syntax (but it can't be an animated one, even gif are not animated due to CPU load) +- All supported browsers can now change font-size + +BUG FIXES: +- Sometimes while using the "toggle editor" button to turn of the editor, the standard textarea was expanded to the full size of the textarea content. +- When resizing the area the selection was lost +- Allow translation for some forgotten hard-coded word (the "move" button for search popup, and "font size", and keys word in help panel). +- It was possible to "drag" the buttons from the Search/Replace popup into the content of the textarea. +- On first display (when the files are not in cache) or with xhtml doctype there is a display bug (the content of the textarea exceed of 4px) +- when the cursor was at the beginning of the 1st line of the textarea, the caracter position was set to 0 instead of 1 + + + +***v 0.4**** +- Increases syntax highlight proccess speed by 5 => allow a better live editing mode with syntax highlight. +- Now syntax highlight has a real language syntax. Text is parsing with rules depending of the language definition file. (limitation: there is only one language on the same time > doesn't allow to parse html and php on the same page). +- Syntax highlight can be easily extended with new code languages (there is currently: php, css, js, html). +- Add german language file (thanks to Olaf Brambrink). +- Fix some little bugs. + + + + +***v0.33*** +- First release. diff --git a/www/extras/editarea/docs/about.html b/www/extras/editarea/docs/about.html new file mode 100755 index 000000000..5df27abec --- /dev/null +++ b/www/extras/editarea/docs/about.html @@ -0,0 +1,48 @@ + + + + + EditArea documentation + + + + +
+

About

+
+
+

General information

+

EditArea is a free javascript editor for source code. It allow to write + well formated source code. That's no way a WYSIWYG editor. +

+

+ EditArea is developed by Christophe Dolivet + (contact) + and is currently released + under the "LGPL" license, read the license agreement for details. +

+

Features

+ + +
+ + + diff --git a/www/extras/editarea/docs/compatibility.html b/www/extras/editarea/docs/compatibility.html new file mode 100755 index 000000000..c34c24981 --- /dev/null +++ b/www/extras/editarea/docs/compatibility.html @@ -0,0 +1,90 @@ + + + + + EditArea documentation + + + + +
+

Compatiblity Chart

+
+
+

Browser support

+

EditArea uses advanced JavaScript and tries to be as smart as possible when it comes to + different browsers. But as every browser (and every version of thoses browser) manage + css and javascript implementation with some little change, it will probably be bad + displayed on other browser. + The table was reset to only show the browsers I take care of. +

+ +

Since I have no mac, I can't make test for safari, neither testing multi-plateform browsers. + Let me know if you constat that such browsers are working. +

+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 Windows XPLinuxMacOS X
MSIE 7 & 6OK  
Firefox 3 & 2 & 1.5OKOKOK
Safari 3.0 & 3.1OK OK
ChromeOK??????
Opera 9 & 9.5OKOKOK
Camino 1.2  OK
+

+

+ (1) - Partialy working
+ (2) - Buggy browser version +

+
+ Notices: + +
+ + + diff --git a/www/extras/editarea/docs/configuration.html b/www/extras/editarea/docs/configuration.html new file mode 100755 index 000000000..eec35c739 --- /dev/null +++ b/www/extras/editarea/docs/configuration.html @@ -0,0 +1,216 @@ + + + + + EditArea documentation + + + + +
+

Configuration reference

+
+
+

This document is the index/reference page for all available core configuration + options in EditArea.

+
+ +

Configuration options

+

All configuration options below is to be placed within the init JavaScript call.
+

+
+ +

Initialization of EditArea

+

In order to initialize EditArea the following code must be placed within HEAD element + of a document. The following example is configurated to convert the TEXTAREA element + which has "textarea_1" as id into editor when the page loads. The "id" + option is the only obligatory option. +

+<html>
+<head>
+<script language="javascript" type="text/javascript" src="/editarea/edit_area/edit_area_full.js"></script>
+<script language="javascript" type="text/javascript">
+editAreaLoader.init({
+	id : "textarea_1"		// textarea id
+	,syntax: "css"			// syntax to be uses for highgliting
+	,start_highlight: true		// to display with highlight mode on start-up
+});
+</script>
+</head>
+
+

+

See the include document to learn more about the way to use the best script include. +

+

If you want to convert several textarea on your webpage, just call several time the init function with a different id parameter.

+ +
+ + + diff --git a/www/extras/editarea/docs/credits.html b/www/extras/editarea/docs/credits.html new file mode 100755 index 000000000..d71b136c3 --- /dev/null +++ b/www/extras/editarea/docs/credits.html @@ -0,0 +1,71 @@ + + + + + EditArea documentation + + + + +
+

Credits

+
+
+

Special thanks

+

+ I would like to make a special thanks to TinyMCE + developpers. I have taken some of their WYSIWYG editor functions + (managing the toolbar buttons), + and it give me inspiration for some point (gzip compression, translation, documentation) + of my project. +

+

Contributors

+

These are the people that have contributed in some way to the EditArea project. + If you feel we are missing someone please inform me right away and I will correct this + in future versions of EditArea. +

+ +
+ + + diff --git a/www/extras/editarea/docs/customization_language.html b/www/extras/editarea/docs/customization_language.html new file mode 100755 index 000000000..b72d9a3a2 --- /dev/null +++ b/www/extras/editarea/docs/customization_language.html @@ -0,0 +1,65 @@ + + + + + EditArea documentation + + + + +
+

Customization - Creating a language translation

+
+
+

Making language file

+ +

Language packs are simply JavaScript name/value arrays placed in the ".js" + files in the "lang" directory. Notice there are two kinds of language packs.

+ +

+ Remember, the last translation line should not have a , character at the end. +

+ +

Files to edit

+ +

+ When translating EditArea, these are the files that currently needs to be translated: +

+

+ edit_area/langs/en.js
+ edit_area/plugins/<plugin_name>/langs/en.js
+

+ +

Contributing your language pack

+

+ Go to the sourceforge patch page + and upload a zip containing all the language files in the correct directory structure.

+ + Please translate all the plugins, even if you aren't using them.
+

+
+ + + diff --git a/www/extras/editarea/docs/customization_plugin.html b/www/extras/editarea/docs/customization_plugin.html new file mode 100755 index 000000000..bc294ffc3 --- /dev/null +++ b/www/extras/editarea/docs/customization_plugin.html @@ -0,0 +1,175 @@ + + + + + EditArea documentation + + + + +
+

Customization - Creating a plugin

+
+
+

Creating your own plugins

+

+ Creating you own plugins for EditArea is fairly easy if you know the basics of HTML, CSS and Javascript. + The most easy way is to copy the "test" directory and work from there. The "test" + directory is a tutorial plugin that shows how to create a plugin. After you copy the template you need to + change the red sections marked below to the name of your plugin this is needed so that plugins don't + overlap in other words it gives the plugin a unique name. Notice that when you write a new plugin, + you have to end each javascript instructions by ";", even if it's optionnal in javascript. +

+ +

If you want you may add plugin specific options/settings but remember to namespace them in the + following format "<your plugin>_<option>" for example "yourplugin_someoption".

+ +

Specific callback functions that you don't need or doesn't do anything can be removed.

+ +

If you want you can try the test plugin by adding the following parameters to the EditAreaLoader.init command.

+
end_toolbar: "*,test_but, |,test_select",
+plugins: "test",
+ +
+

Plugin directory structure

+

+ + + + + + + + + +
File/Directory + Description +
cssPlugin specific CSS files
imagesPlugin specific images
langsPlugin specific language files
<your_plugin>.jsMain plugin file
+

+
+

Plugin example source

+

+ The example below shows a simple empty plugin and all possible callbacks. +

+

+ +

+
/**
+ * Plugin designed for test prupose. It add a button (that manage an alert) and a select (that allow to insert tags) in the toolbar.
+ * This plugin also disable the "f" key in the editarea, and load a CSS and a JS file
+ */  
+var EditArea_test= {
+	/**
+	 * Get called once this file is loaded (editArea still not initialized)
+	 *
+	 * @return nothing	 
+	 */	 	 	
+	init: function(){	
+		//	alert("test init: "+ this._someInternalFunction(2, 3));
+		editArea.load_css(this.baseURL+"css/test.css");
+		editArea.load_script(this.baseURL+"test2.js");
+	}
+	/**
+	 * Returns the HTML code for a specific control string or false if this plugin doesn't have that control.
+	 * A control can be a button, select list or any other HTML item to present in the EditArea user interface.
+	 * Language variables such as {$lang_somekey} will also be replaced with contents from
+	 * the language packs.
+	 * 
+	 * @param {string} ctrl_name: the name of the control to add	  
+	 * @return HTML code for a specific control or false.
+	 * @type string	or boolean
+	 */	
+	,get_control_html: function(ctrl_name){
+		switch(ctrl_name){
+			case "test_but":
+				// Control id, button img, isFileSpecific, command
+				return parent.editAreaLoader.get_button_html('test_but', 'test.gif', 'test_cmd', false, this.baseURL);
+			case "test_select":
+				html= "<select id='test_select' onchange='javascript:editArea.execCommand(\"test_select_change\")'>"
+					+"			<option value='-1'>{$test_select}</option>"
+					+"			<option value='h1'>h1</option>"
+					+"			<option value='h2'>h2</option>"
+					+"			<option value='h3'>h3</option>"
+					+"			<option value='h4'>h4</option>"
+					+"			<option value='h5'>h5</option>"
+					+"			<option value='h6'>h6</option>"
+					+"		</select>";
+				return html;
+		}
+		return false;
+	}
+	/**
+	 * Get called once EditArea is fully loaded and initialised
+	 *	 
+	 * @return nothing
+	 */	 	 	
+	,onload: function(){ 
+		alert("test load");
+	}
+	
+	/**
+	 * Is called each time the user touch a keyboard key.
+	 *	 
+	 * @param (event) e: the keydown event
+	 * @return true - pass to next handler in chain, false - stop chain execution
+	 * @type boolean	 
+	 */
+	,onkeydown: function(e){
+		var str= String.fromCharCode(e.keyCode);
+		// desactivate the "f" character
+		if(str.toLowerCase()=="f"){
+			return true;
+		}
+		return false;
+	}
+	
+	/**
+	 * Executes a specific command, this function handles plugin commands.
+	 *
+	 * @param {string} cmd: the name of the command being executed
+	 * @param {unknown} param: the parameter of the command	 
+	 * @return true - pass to next handler in chain, false - stop chain execution
+	 * @type boolean	
+	 */
+	,execCommand: function(cmd, param){
+		// Handle commands
+		switch(cmd){
+			case "test_select_change":
+				var val= document.getElementById("test_select").value;
+				if(val!=-1)
+					parent.editAreaLoader.insertTags(editArea.id, "<"+val+">", "</"+val+">");
+				document.getElementById("test_select").options[0].selected=true; 
+				return false;
+			case "test_cmd":
+				alert("user clicked on test_cmd");
+				return false;
+		}
+		// Pass to next handler in chain
+		return true;
+	}
+	
+	/**
+	 * This is just an internal plugin method, prefix all internal methods with a _ character.
+	 * The prefix is needed so they doesn't collide with future EditArea callback functions.
+	 *
+	 * @param {string} a Some arg1.
+	 * @param {string} b Some arg2.
+	 * @return Some return.
+	 * @type unknown
+	 */
+	,_someInternalFunction : function(a, b) {
+		return a+b;
+	}
+};
+
+// Adds the plugin class to the list of available EditArea plugins
+editArea.add_plugin("test", EditArea_test);
+
+
+ + + diff --git a/www/extras/editarea/docs/customization_syntax.html b/www/extras/editarea/docs/customization_syntax.html new file mode 100755 index 000000000..2b0d70fd8 --- /dev/null +++ b/www/extras/editarea/docs/customization_syntax.html @@ -0,0 +1,139 @@ + + + + + EditArea documentation + + + + +
+

Customization - Creating a syntax definition file

+
+
+

Creating your own syntax definition file

+

Creating you own syntax definition file for EditArea is fairly easy. You just have to know the language syntax, + it's kewords, and then fill a javascript array with thoses values.

+

If your want to create a new syntax file for a given language, choose a language abbreviation for it + (<language_abbr>) in lowercase. Then create the file "edit_area/reg_syntax/<language_abbr>.js".

+

Here is a "css" example:

+
editAreaLoader.load_syntax["css"] = {		// here <language_abbr> is "css" so the file is "css.js"
+	'COMMENT_SINGLE' : ['@']		// Array:  possible single line comments
+	,'COMMENT_MULTI' : {'/*' : '*/'}	// associated Array: possible multiple line comments 
+						// ("open_mark1" : "close mark1", "open_mark2" : "close_mark2"}
+	,'QUOTEMARKS' : ['"', "'"]		// Array: the different possible quotemarks that delimitate strings
+	,'KEYWORD_CASE_SENSITIVE' : false	// Boolean: define if the language is case-sensitive
+	,'KEYWORDS' : {				// Array: an array of array containing the different keywords class 
+		'attributes' : [		// the name 'attribute' can be changed with no problem. I
+						// it's only used to define the matching style class 
+			'aqua', 'azimuth', 'background-attachment', 'background-color'	// etc...
+		]
+		,'values' : [
+			'absolute', 'block', 'bold', 'bolder', 'both' 	// etc...
+		]
+		,'specials' : [
+			'important'
+		]
+	}
+	,'OPERATORS' :[		// Array: the operators to highlight (eg, can also contain: +, -, * or / in other languages).
+		':', ';', '!', '.', '#'
+	]
+	,'DELIMITERS' :[	// Array: the block code delimiters to highlight
+		'{', '}'
+	]
+	,'STYLES' : {	// Array: an array of array, containing all style to apply for categories defined before.
+			// Better to define color style only. 
+		'COMMENTS': 'color: #AAAAAA;'
+		,'QUOTESMARKS': 'color: #6381F8;'
+		,'KEYWORDS' : {			// contain the associated style foreach keywords categories
+			'attributes' : 'color: #48BDDF;'
+			,'values' : 'color: #2B60FF;'
+			,'specials' : 'color: #FF0000;'
+			}
+		,'OPERATORS' : 'color: #FF00FF;'
+		,'DELIMITERS' : 'color: #60CA00;'
+				
+	}
+};
+

After reading this example you should be able to create your own syntax file.

+
+

Advanced syntax definition

+ +
editAreaLoader.load_syntax["xml"] = {
+	'COMMENT_SINGLE' : {}
+	,'COMMENT_MULTI' : {'<!--' : '-->'}
+	,'QUOTEMARKS' : {1: "'", 2: '"'}
+	,'KEYWORD_CASE_SENSITIVE' : false
+	,'KEYWORDS' : {
+	}
+	,'OPERATORS' :[
+	]
+	,'DELIMITERS' :[
+	]
+	,'REGEXPS' : {			// advance syntax highlight through regexp
+		'xml' : {		// the name 'doctype' can be changed with no problem.
+			'search' : '()(<\\?[^>]*?\\?>)()'	// the regexp
+			,'class' : 'xml'			// the css class
+			,'modifiers' : 'g'			// the modifier ("g" and/or "i")
+			,'execute' : 'before'			// "before" or "after". Determine if the regexp must 
+								// be done before or after the main highlight process
+		}
+		,'cdatas' : {
+			'search' : '()(<!\\[CDATA\\[.*?\\]\\]>)()'
+			,'class' : 'cdata'
+			,'modifiers' : 'g'
+			,'execute' : 'before' 
+		}
+		,'tags' : {
+			'search' : '(<)(/?[a-z][^ \r\n\t>]*)([^>]*>)'
+			,'class' : 'tags'
+			,'modifiers' : 'gi'
+			,'execute' : 'before' 
+		}
+		,'attributes' : {
+			'search' : '( |\n|\r|\t)([^ \r\n\t=]+)(=)'
+			,'class' : 'attributes'
+			,'modifiers' : 'g'
+			,'execute' : 'before'
+		}
+	}
+	,'STYLES' : {
+		'COMMENTS': 'color: #AAAAAA;'
+		,'QUOTESMARKS': 'color: #6381F8;'
+		,'KEYWORDS' : {
+			}
+		,'OPERATORS' : 'color: #E775F0;'
+		,'DELIMITERS' : ''
+		,'REGEXPS' : {
+			'attributes': 'color: #B1AC41;'
+			,'tags': 'color: #800080;'
+			,'xml': 'color: #8DCFB5;'
+			,'cdata': 'color: #50B020;'
+		}	
+	}		
+};
+

Well, as you can see in this example, the syntax highlight for xml is not based on keywords but on regexp. + The text that will be highlighted, is the one between the second parentheses. The search parameter should always + be like this: +

+
(<before_highlight>)(<code_to_highlight>)(<after_highlight>)
+

For the pattern modifier, "g" signify that all occurences will be highlighted, "i" signify + that the regexp will be case-insensitive.

+ +
+ +

Contributing your syntax definition file

+

+ Go to the sourceforge patch page + and upload the syntax file. +

+ + +
+ + + diff --git a/www/extras/editarea/docs/doc_style.css b/www/extras/editarea/docs/doc_style.css new file mode 100755 index 000000000..08024ed8b --- /dev/null +++ b/www/extras/editarea/docs/doc_style.css @@ -0,0 +1,120 @@ +body { + background-color: #FFFFFF; + font-family: Verdana, Arial, helvetica, sans-serif; + font-size: 12px; +} + +h1{ + font-size: 18px; + font-weight: bold; + padding: 0; + margin: 4px; +} + +h2 { + font-size: 14px; + font-weight: bold; + padding: 0; + margin: 0; + margin-top: 4px; + margin-bottom: 4px; +} + +h3 { + font-size: 11px; + font-weight: bold; + padding: 0; + margin: 0; + margin-bottom: 3px; +} + +h4, h5, h6{ + margin: 0; + padding: 0; +} + +pre, code{ + margin: 0; + padding: 0 5px; + background-color: #E6EBF1; +} + + +a:hover{ + color: #666666; + text-decoration: underline; +} + +a{ + color: #666666; + text-decoration: underline; +} + +ul, ol{ + padding: 0px; + margin: 3px 0 3px 10px; +} + +li{ + padding: 0; + margin: 3px 0 3px 10px; +} + +li li{ + padding: 0; + margin-left: 30px; +} + +table{ + border-collapse: collapse; +} + +td, th{ + padding: 4px; + border: 2px groove #000000; +} + +thead { + background-color: #E6EBF1; +} + +.header{ + border: #E0E0E0 solid 1px; +} + +.footer{ + border: #E0E0E0 solid 1px; + height: 1.3em; + padding: 2px; +} + +.content{ + padding: 10px 0 10px 10px; +} + +.indexlink{ + float: right; +} + +.separator { + border-bottom: 1px solid #E6EBF1; + margin-top: 10px; + margin-bottom: 10px; +} + + +.optionlist li li{ + text-indent: -15px; + padding-left: 15px; + line-height: 1.3em; +} + +.optionlist .underline{ + background-color: #E6EBF1; + border-bottom: dashed #000000 1px; +} + +.marked{ + color: #FF0000; + font-weight: bold; +} diff --git a/www/extras/editarea/docs/include.html b/www/extras/editarea/docs/include.html new file mode 100755 index 000000000..369bf8506 --- /dev/null +++ b/www/extras/editarea/docs/include.html @@ -0,0 +1,159 @@ + + + + + EditArea documentation + + + + +
+

Main script include

+
+
+

As you have seen it before in installation and + configuration, in order to make EditArea work on a + webpage, you must include one external javascript file and call an init + function for each textarea you want to convert. + In thoses examples the file "edit_area_full.js" whas the file included, + but in fact there are 5 possible files to include EditArea scripts + into your webpage. All thoses files are in the same directory, + and they all have advantage and inconvenient. +

+ +

edit_area_full.js

+
+

This is the easier file to use for script integration. The file is nearly 100Kb length. +

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

Advantage:

+
    +
  • The simplest choice.
  • +
  • Load the core script in one call to server.
  • +
+

Inconvient:

+
    +
  • Not designed to allow core script modification.
  • +
  • Need to make additional server calls for plugins.
  • +
+
+

+
+ +
+ +

edit_area_compressor.php

+
+

This php file send in a gzipped file the whole core script to the brower (if the browser + has not already an updated version in cache). +
+ If the source core script files have changed, it take thoses files and merge them into one file. + Then it remove all comments, white-spaces, etc... and save it in + "edit_area_full.js". It also save a gzip version in + "edit_area_full.gz". Then it send the gzip content to the browser (except for IE for which it is not gzipped due to IE bug with compression). +

<script language="javascript" type="text/javascript" src="/editarea/edit_area/edit_area_compressor.php"></script>
+
+

Advantage:

+
    +
  • The script is very small if gzip is supported (~25Ko).
  • +
  • Designed to allow core script modification.
  • +
  • Load the core script in one call to server.
  • +
+

Inconvient:

+
    +
  • Need PHP to be installed on the server (and allowed to write in editarea directory for disk caching).
  • +
  • Need to make additional server calls for plugins.
  • +
+
+

+

If you plan to use "edit_area_compressor.php" be sure that PHP scripts are allowed + to write in editarea directory (at the same level than the file "edit_area_compressor.php") + for disk caching. +

+
+ +
+ +

edit_area_compressor.php?plugins

+
recommanded version
+
+

This include is very similar to "edit_area_compressor.php". The difference is that + with "plugins" parameter, the compressor also include the main script of all the plugins + in the merged file and also compress them. This will avoid later server calls for plugin main script. +
+ In this case, the saved files are "edit_area_full_with_plugins.js" and "edit_area_full_with_plugins.gz". +

<script language="javascript" type="text/javascript" src="/editarea/edit_area/edit_area_compressor.php?plugins"></script>
+
+

Advantage:

+
    +
  • The script is very small if gzip is supported.
  • +
  • Designed to allow core script modification.
  • +
  • Load the core script in one call to server.
  • +
  • Load plugins script in the same call.
  • +
+

Inconvient:

+
    +
  • Need PHP to be installed on the server (and allowed to write in editarea directory for disk caching).
  • +
+
+

+

If you plan to use "edit_area_compressor.php" be sure that PHP scripts are allowed + to write in editarea directory (at the same level than the file "edit_area_compressor.php") + for disk caching. +

+
+ +
+ +

edit_area_full.gz

+
+

This is the smaller file to use for script integration. The file is gzipped and is only 20Kb + length. +

<script language="javascript" type="text/javascript" src="/editarea/edit_area/edit_area_full.gz"></script>
+
+

Advantage:

+
    +
  • The script is only 20Kb length.
  • +
  • Load the core script in one call to server.
  • +
+

Inconvient:

+
    +
  • Is server dependant: It will work only on servers that will return a + "Content-Encoding: gzip" for *.gz files (can work with Apache). + So you must test if it work on your server.
  • +
  • Not designed to allow core script modification.
  • +
  • Need to make additional server calls for plugins.
  • +
+
+

+
+ +
+ +

edit_area_loader.js

+
+

This is the original loading script of EditArea. Use this one only if you can't use + any of the 3 other loading files. There is no code epuration nor gzip compression. +

<script language="javascript" type="text/javascript" src="/editarea/edit_area/edit_area_loader.js"></script>
+
+

Advantage:

+
    +
  • Designed to allow core script modification.
  • +
+

Inconvient:

+
    +
  • Load the core scripts in 12 call to the server.
  • +
  • Need to make additional server calls for plugins.
  • +
+
+

+
+ +
+ + + diff --git a/www/extras/editarea/docs/index.html b/www/extras/editarea/docs/index.html new file mode 100755 index 000000000..2a7e02a26 --- /dev/null +++ b/www/extras/editarea/docs/index.html @@ -0,0 +1,41 @@ + + + + + EditArea documentation + + + + +
+

EditArea documentation

+
+
+ +
+ + + diff --git a/www/extras/editarea/docs/installation.html b/www/extras/editarea/docs/installation.html new file mode 100755 index 000000000..803551614 --- /dev/null +++ b/www/extras/editarea/docs/installation.html @@ -0,0 +1,110 @@ + + + + + EditArea documentation + + + + +
+

Installation instructions

+
+
+

Installing EditArea is very simple, follow the instructions here. Also look at the + options for configuration and the different + javascript load possibility. +

+
+ +

Requirements

+

EditArea has no direct requirements except for browser + compatibility and of course JavaScript needs to be turned on. + For developpers there is also a PHP compressor that is included in the release. +

+
+ +

Downloading

+

For downloading check the + sourceforge web site. +

+
+ +

Extracting the archives

+

On windows you could use WinZip or something similar. + And on other operating systems such as Linux you simply extract the archive with + the tar command. +

+

+ You should extract EditArea somewhere in your website. Notice that EditArea loads additionnal files + while being used (language translation, syntax definition and images), so don't delete any of the + file in the archive, and be sure that any files can be accessed. +

+

+ If you plan to use "edit_area_compressor.php" be sure that PHP scripts are allowed + to write in editarea repertory (at the same level than the file "edit_area_compressor.php") + in order to allow disk caching. +

+
+ +

Making changes on your web site

+

Once you have extracted the archive you will need to edit the pages + to include the configuration and javascript for EditArea. + Please note that you should probably only include the EditArea javascript on the pages + that need it, not all the pages of the web site. Remember to change the URL to + the .js below to match your installation path.

+

+

The most basic page integration (converts one textarea into editor):

+

+

+<html>
+<head>
+<title>EditArea Test</title>
+<script language="javascript" type="text/javascript" src="/editarea/edit_area/edit_area_full.js"></script>
+<script language="javascript" type="text/javascript">
+editAreaLoader.init({
+	id : "textarea_1"		// textarea id
+	,syntax: "css"			// syntax to be uses for highgliting
+	,start_highlight: true		// to display with highlight mode on start-up
+});
+</script>
+</head>
+<body>
+<form method="post">
+	<textarea id="textarea_1" name="content" cols="80" rows="15">
+/*This is some css that will be editable with EditArea.*/
+body, html{
+	margin: 0; 
+	padding: 0;
+	height: 100%;
+	border: none;
+	overflow: hidden;
+}</textarea>
+
+</form>
+</body>
+</html>
+
+

+

+ See the configuration help to learn about + initialization options, + and the include help to learn more about the way + to use the best script include (there is 4 possible files for EditArea loading). +

+

+ Here is an example of EditArea possibilities: Full exemple. +

+

+ If you have any problems, you could contact me on + my website. + Just be sure you've read the documentation before... +

+
+ + + diff --git a/www/extras/editarea/docs/javascript_functions.html b/www/extras/editarea/docs/javascript_functions.html new file mode 100755 index 000000000..9eb30d4c9 --- /dev/null +++ b/www/extras/editarea/docs/javascript_functions.html @@ -0,0 +1 @@ + EditArea documentation

Javascript Functions

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.

editAreaLoader.getValue(editor_id)

This method return the content text of the editor. Works on normal textarea if the EditArea is toggled off.

Parameters
editor_id The id of the converted textarea

Returns: the content text of the editor. String

editAreaLoader.setValue(editor_id, new_text)

This method allow to update the content text of an editor. Works on normal textarea if the EditArea is toggled off.

Parameters
editor_id The id of the converted textarea
new_text The new text that will replace the Editor content.

Returns: Nothing.

editAreaLoader.insertTags(editor_id, open_tag, close_tag)

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.

Parameters
editor_id The id of the converted textarea
open_tag The open tag string.
close_tag The close tag string.

Returns: Nothing.

editAreaLoader.getSelectedText(editor_id)

This method return the text contained in the the selection range. Works on normal textarea if the EditArea is toggled off.

Parameters
editor_id The id of the converted textarea

Returns: The text contained in the the selection range. String

editAreaLoader.setSelectedText(editor_id, new_text)

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.

Parameters
editor_id The id of the converted textarea
new_text The string that will replace the current selected text.

Returns: Nothing.

editAreaLoader.getSelectionRange(editor_id)

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.

Parameters
editor_id The id of the converted textarea

Returns: An array containing the index of the selection start and end. Array("start", "end")

editAreaLoader.setSelectionRange(editor_id, new_start, new_end)

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.

Parameters
editor_id The id of the converted textarea
new_start The character position determining the start of the selection range.
new_end The character position determining the end of the selection range.

Returns: Nothing.

editAreaLoader.execCommand(editor_id, command, command_param)

Allow to access to EditArea functions and datas (for advanced users only).

Parameters
editor_id The id of the converted textarea on which the command should be executed.
command The function or the parameter of the EditArea object that will be returned.
command_param (optionnal) If command is a function, the you can pass one parameter to the function with command_param

Returns: the value of the executed command or data. unknown

Examples
Change edit mode

Allow to toggle EditArea etit mode from normal edition to readonly with no toolbars.

editAreaLoader.execCommand('editor_id', 'set_editable', !editAreaLoader.execCommand('editor_id', 'is_editable'));
Insert tags

Insert tags arround selected text or at current cursor position if not text is selected

editAreaLoader.insertTags('editor_id', "[OPEN]", "[CLOSE]");

editAreaLoader.delete_instance(editor_id)

Delete an instance of EditArea and restore simple textarea.

Parameters
editor_id The id of the converted textarea on which the command should be executed.

Returns: Nothing.

editAreaLoader.hide(editor_id)

Hide a textarea and it's related EditArea.

Parameters
editor_id The id of the converted textarea on which the command should be executed.

Returns: Nothing.

editAreaLoader.show(editor_id)

Restore a textarea and it's related EditArea hidden with the hide() function.

Parameters
editor_id The id of the converted textarea on which the command should be executed.

Returns: Nothing.

editAreaLoader.openFile(editor_id, file_infos)

Parameters
editor_id The id of the converted textarea on which the command should be executed.
file_infos 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):
  • id : (required) A string that will identify the file. it's the only required field.
    Type: String
  • title : (optionnal) The title that will be displayed in the tab area.
    Type: String
    Default: set with the id field value
  • text : (optionnal) The text content of the file.
    Type: String
    Default: ""
  • syntax : (optionnal) The syntax to use for this file.
    Type: String
    Default: ""
  • do_highlight : (optionnal) Set if the file should start highlighted or not
    Type: String
    Default: ""

Returns: Nothing.

editAreaLoader.getCurrentFile(editor_id)

Return datas of the currently selected file (for multi file editing mode).

Parameters
editor_id The id of the converted textarea on which the command should be executed.

Returns: An object containing datas related to the file.Object

editAreaLoader.getFile(editor_id, file_id)

Return datas of the file identified by file_id (for multi file editing mode).

Parameters
editor_id The id of the converted textarea on which the command should be executed.
file_id The id of the file to close.

Returns: An object containing datas related to the file.Object

editAreaLoader.getAllFiles(editor_id)

Return datas of all the currently openned files (for multi file editing mode).

Parameters
editor_id The id of the converted textarea on which the command should be executed.

Returns: An object containing datas of each files.Object

editAreaLoader.closeFile(editor_id, file_id)

Close the file identified by file_id (for multi file editing mode).

Parameters
editor_id The id of the converted textarea on which the command should be executed.
file_id The id of the file to close.

Returns: Nothing.

editAreaLoader.setFileEditedMode(editor_id, file_id, edited_mode)

Define is the file should appears as edited or not.

Parameters
editor_id The id of the converted textarea on which the command should be executed.
file_id The id of the file to close.
edited_mode A boolean that indicate if the file should be set edited or not edited.

Returns: Nothing.

\ No newline at end of file diff --git a/www/extras/editarea/docs/license.html b/www/extras/editarea/docs/license.html new file mode 100755 index 000000000..3f5fcbe01 --- /dev/null +++ b/www/extras/editarea/docs/license.html @@ -0,0 +1,484 @@ + + + + + EditArea documentation + + + + +
+

EditArea license (LGPL)

+
+
+

+ Visit http://www.fsf.org for more information about Open-Source licenses. +

+
+		  GNU LESSER GENERAL PUBLIC LICENSE
+		       Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL.  It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+			    Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+  This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it.  You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+  When we speak of free software, we are referring to freedom of use,
+not price.  Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+  To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights.  These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+  For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you.  You must make sure that they, too, receive or can get the source
+code.  If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it.  And you must show them these terms so they know their rights.
+
+  We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+  To protect each distributor, we want to make it very clear that
+there is no warranty for the free library.  Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+  Finally, software patents pose a constant threat to the existence of
+any free program.  We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder.  Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+  Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License.  This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License.  We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+  When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library.  The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom.  The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+  We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License.  It also provides other free software developers Less
+of an advantage over competing non-free programs.  These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries.  However, the Lesser license provides advantages in certain
+special circumstances.
+
+  For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard.  To achieve this, non-free programs must be
+allowed to use the library.  A more frequent case is that a free
+library does the same job as widely used non-free libraries.  In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+  In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software.  For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+  Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.  Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library".  The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+		  GNU LESSER GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+  A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+  The "Library", below, refers to any such software library or work
+which has been distributed under these terms.  A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language.  (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+  "Source code" for a work means the preferred form of the work for
+making modifications to it.  For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+  Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it).  Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+  
+  1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+  You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+  2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) The modified work must itself be a software library.
+
+    b) You must cause the files modified to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    c) You must cause the whole of the work to be licensed at no
+    charge to all third parties under the terms of this License.
+
+    d) If a facility in the modified Library refers to a function or a
+    table of data to be supplied by an application program that uses
+    the facility, other than as an argument passed when the facility
+    is invoked, then you must make a good faith effort to ensure that,
+    in the event an application does not supply such function or
+    table, the facility still operates, and performs whatever part of
+    its purpose remains meaningful.
+
+    (For example, a function in a library to compute square roots has
+    a purpose that is entirely well-defined independent of the
+    application.  Therefore, Subsection 2d requires that any
+    application-supplied function or table used by this function must
+    be optional: if the application does not supply it, the square
+    root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library.  To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License.  (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.)  Do not make any other change in
+these notices.
+
+  Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+  This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+  4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+  If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library".  Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+  However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library".  The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+  When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library.  The
+threshold for this to be true is not precisely defined by law.
+
+  If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work.  (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+  Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+  6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+  You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License.  You must supply a copy of this License.  If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License.  Also, you must do one
+of these things:
+
+    a) Accompany the work with the complete corresponding
+    machine-readable source code for the Library including whatever
+    changes were used in the work (which must be distributed under
+    Sections 1 and 2 above); and, if the work is an executable linked
+    with the Library, with the complete machine-readable "work that
+    uses the Library", as object code and/or source code, so that the
+    user can modify the Library and then relink to produce a modified
+    executable containing the modified Library.  (It is understood
+    that the user who changes the contents of definitions files in the
+    Library will not necessarily be able to recompile the application
+    to use the modified definitions.)
+
+    b) Use a suitable shared library mechanism for linking with the
+    Library.  A suitable mechanism is one that (1) uses at run time a
+    copy of the library already present on the user's computer system,
+    rather than copying library functions into the executable, and (2)
+    will operate properly with a modified version of the library, if
+    the user installs one, as long as the modified version is
+    interface-compatible with the version that the work was made with.
+
+    c) Accompany the work with a written offer, valid for at
+    least three years, to give the same user the materials
+    specified in Subsection 6a, above, for a charge no more
+    than the cost of performing this distribution.
+
+    d) If distribution of the work is made by offering access to copy
+    from a designated place, offer equivalent access to copy the above
+    specified materials from the same place.
+
+    e) Verify that the user has already received a copy of these
+    materials or that you have already sent this user a copy.
+
+  For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it.  However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+  It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system.  Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+  7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+    a) Accompany the combined library with a copy of the same work
+    based on the Library, uncombined with any other library
+    facilities.  This must be distributed under the terms of the
+    Sections above.
+
+    b) Give prominent notice with the combined library of the fact
+    that part of it is a work based on the Library, and explaining
+    where to find the accompanying uncombined form of the same work.
+
+  8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License.  Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License.  However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+  9. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Library or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+  10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+  11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded.  In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+  13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation.  If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+  14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission.  For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this.  Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+			    NO WARRANTY
+
+  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+		     END OF TERMS AND CONDITIONS
+		
+
+ + + diff --git a/www/extras/editarea/edit_area/autocompletion.js b/www/extras/editarea/edit_area/autocompletion.js new file mode 100755 index 000000000..29e3fb1eb --- /dev/null +++ b/www/extras/editarea/edit_area/autocompletion.js @@ -0,0 +1,493 @@ +/** + * Autocompletion class + * + * An auto completion box appear while you're writing. It's possible to force it to appear with Ctrl+Space short cut + * + * Loaded as a plugin inside editArea (everything made here could have been made in the plugin directory) + * But is definitly linked to syntax selection (no need to do 2 different files for color and auto complete for each syntax language) + * and add a too important feature that many people would miss if included as a plugin + * + * - init param: autocompletion_start + * - Button name: "autocompletion" + */ + +var EditArea_autocompletion= { + + /** + * Get called once this file is loaded (editArea still not initialized) + * + * @return nothing + */ + init: function(){ + // alert("test init: "+ this._someInternalFunction(2, 3)); + + if(editArea.settings["autocompletion"]) + this.enabled= true; + else + this.enabled= false; + this.current_word = false; + this.shown = false; + this.selectIndex = -1; + this.forceDisplay = false; + this.isInMiddleWord = false; + this.autoSelectIfOneResult = false; + this.delayBeforeDisplay = 100; + this.checkDelayTimer = false; + this.curr_syntax_str = ''; + + this.file_syntax_datas = {}; + } + /** + * Returns the HTML code for a specific control string or false if this plugin doesn't have that control. + * A control can be a button, select list or any other HTML item to present in the EditArea user interface. + * Language variables such as {$lang_somekey} will also be replaced with contents from + * the language packs. + * + * @param {string} ctrl_name: the name of the control to add + * @return HTML code for a specific control or false. + * @type string or boolean + */ + /*,get_control_html: function(ctrl_name){ + switch( ctrl_name ){ + case 'autocompletion': + // Control id, button img, command + return parent.editAreaLoader.get_button_html('autocompletion_but', 'autocompletion.gif', 'toggle_autocompletion', false, this.baseURL); + break; + } + return false; + }*/ + /** + * Get called once EditArea is fully loaded and initialised + * + * @return nothing + */ + ,onload: function(){ + if(this.enabled) + { + var icon= document.getElementById("autocompletion"); + if(icon) + editArea.switchClassSticky(icon, 'editAreaButtonSelected', true); + } + + this.container = document.createElement('div'); + this.container.id = "auto_completion_area"; + editArea.container.insertBefore( this.container, editArea.container.firstChild ); + + // add event detection for hiding suggestion box + editArea.add_event( document, "click", function(){ editArea.plugins['autocompletion']._hide();} ); + editArea.add_event( editArea.textarea, "blur", function(){ editArea.plugins['autocompletion']._hide();} ); + + } + + /** + * Is called each time the user touch a keyboard key. + * + * @param (event) e: the keydown event + * @return true - pass to next handler in chain, false - stop chain execution + * @type boolean + */ + ,onkeydown: function(e){ + if(!this.enabled) + return true; + + if (EA_keys[e.keyCode]) + letter=EA_keys[e.keyCode]; + else + letter=String.fromCharCode(e.keyCode); + // shown + if( this._isShown() ) + { + // if escape, hide the box + if(letter=="Esc") + { + this._hide(); + return false; + } + // Enter + else if( letter=="Entrer") + { + var as = this.container.getElementsByTagName('A'); + // select a suggested entry + if( this.selectIndex >= 0 && this.selectIndex < as.length ) + { + as[ this.selectIndex ].onmousedown(); + return false + } + // simply add an enter in the code + else + { + this._hide(); + return true; + } + } + else if( letter=="Tab" || letter=="Down") + { + this._selectNext(); + return false; + } + else if( letter=="Up") + { + this._selectBefore(); + return false; + } + } + // hidden + else + { + + } + + // show current suggestion list and do autoSelect if possible (no matter it's shown or hidden) + if( letter=="Space" && CtrlPressed(e) ) + { + parent.console.log('SHOW SUGGEST'); + this.forceDisplay = true; + this.autoSelectIfOneResult = true; + this._checkLetter(); + return false; + } + + // wait a short period for check that the cursor isn't moving + setTimeout("editArea.plugins['autocompletion']._checkDelayAndCursorBeforeDisplay();", editArea.check_line_selection_timer +5 ); + this.checkDelayTimer = false; + return true; + } + /** + * Executes a specific command, this function handles plugin commands. + * + * @param {string} cmd: the name of the command being executed + * @param {unknown} param: the parameter of the command + * @return true - pass to next handler in chain, false - stop chain execution + * @type boolean + */ + ,execCommand: function(cmd, param){ + switch( cmd ){ + case 'toggle_autocompletion': + var icon= document.getElementById("autocompletion"); + if(!this.enabled) + { + if(icon != null){ + editArea.restoreClass(icon); + editArea.switchClassSticky(icon, 'editAreaButtonSelected', true); + } + this.enabled= true; + } + else + { + this.enabled= false; + if(icon != null) + editArea.switchClassSticky(icon, 'editAreaButtonNormal', false); + } + return true; + } + return true; + } + ,_checkDelayAndCursorBeforeDisplay: function() + { + this.checkDelayTimer = setTimeout("if(editArea.textarea.selectionStart == "+ editArea.textarea.selectionStart +") EditArea_autocompletion._checkLetter();", this.delayBeforeDisplay - editArea.check_line_selection_timer - 5 ); + } + // hide the suggested box + ,_hide: function(){ + this.container.style.display="none"; + this.selectIndex = -1; + this.shown = false; + this.forceDisplay = false; + this.autoSelectIfOneResult = false; + } + // display the suggested box + ,_show: function(){ + if( !this._isShown() ) + { + this.container.style.display="block"; + this.selectIndex = -1; + this.shown = true; + } + } + // is the suggested box displayed? + ,_isShown: function(){ + return this.shown; + } + // setter and getter + ,_isInMiddleWord: function( new_value ){ + if( typeof( new_value ) == "undefined" ) + return this.isInMiddleWord; + else + this.isInMiddleWord = new_value; + } + // select the next element in the suggested box + ,_selectNext: function() + { + var as = this.container.getElementsByTagName('A'); + + // clean existing elements + for( var i=0; i= as.length || this.selectIndex < 0 ) ? 0 : this.selectIndex; + as[ this.selectIndex ].className += " focus"; + } + // select the previous element in the suggested box + ,_selectBefore: function() + { + var as = this.container.getElementsByTagName('A'); + + // clean existing elements + for( var i=0; i= as.length || this.selectIndex < 0 ) ? as.length-1 : this.selectIndex; + as[ this.selectIndex ].className += " focus"; + } + ,_select: function( content ) + { + cursor_forced_position = content.indexOf( '{@}' ); + content = content.replace(/{@}/g, '' ); + if(editArea.nav['isIE']) + editArea.getIESelection(); + + // retrive the number of matching characters + var start_index = Math.max( 0, editArea.textarea.selectionEnd - content.length ); + + line_string = editArea.textarea.value.substring( start_index, editArea.textarea.selectionEnd + 1); + limit = line_string.length -1; + nbMatch = 0; + for( i =0; i 0 ) + parent.editAreaLoader.setSelectionRange(editArea.id, editArea.textarea.selectionStart - nbMatch , editArea.textarea.selectionEnd); + + parent.editAreaLoader.setSelectedText(editArea.id, content ); + range= parent.editAreaLoader.getSelectionRange(editArea.id); + + if( cursor_forced_position != -1 ) + new_pos = range["end"] - ( content.length-cursor_forced_position ); + else + new_pos = range["end"]; + parent.editAreaLoader.setSelectionRange(editArea.id, new_pos, new_pos); + this._hide(); + } + + + /** + * Parse the AUTO_COMPLETION part of syntax definition files + */ + ,_parseSyntaxAutoCompletionDatas: function(){ + //foreach syntax loaded + for(var lang in parent.editAreaLoader.load_syntax) + { + if(!parent.editAreaLoader.syntax[lang]['autocompletion']) // init the regexp if not already initialized + { + parent.editAreaLoader.syntax[lang]['autocompletion']= {}; + // the file has auto completion datas + if(parent.editAreaLoader.load_syntax[lang]['AUTO_COMPLETION']) + { + // parse them + for(var i in parent.editAreaLoader.load_syntax[lang]['AUTO_COMPLETION']) + { + datas = parent.editAreaLoader.load_syntax[lang]['AUTO_COMPLETION'][i]; + tmp = {}; + if(datas["CASE_SENSITIVE"]!="undefined" && datas["CASE_SENSITIVE"]==false) + tmp["modifiers"]="i"; + else + tmp["modifiers"]=""; + tmp["prefix_separator"]= datas["REGEXP"]["prefix_separator"]; + tmp["match_prefix_separator"]= new RegExp( datas["REGEXP"]["prefix_separator"] +"$", tmp["modifiers"]); + tmp["match_word"]= new RegExp("(?:"+ datas["REGEXP"]["before_word"] +")("+ datas["REGEXP"]["possible_words_letters"] +")$", tmp["modifiers"]); + tmp["match_next_letter"]= new RegExp("^("+ datas["REGEXP"]["letter_after_word_must_match"] +")$", tmp["modifiers"]); + tmp["keywords"]= {}; + console.log( datas["KEYWORDS"] ); + for( var prefix in datas["KEYWORDS"] ) + { + tmp["keywords"][prefix]= { + prefix: prefix, + prefix_name: prefix, + prefix_reg: new RegExp("(?:"+ parent.editAreaLoader.get_escaped_regexp( prefix ) +")(?:"+ tmp["prefix_separator"] +")$", tmp["modifiers"] ), + datas: [] + }; + for( var j=0; j it's valid + if( !match_prefix_separator && this.curr_syntax[i]["keywords"][prefix]['prefix'].length == 0 ) + { + if( ! before.match( this.curr_syntax[i]["keywords"][prefix]['prefix_reg'] ) ) + hasMatch = true; + } + // we still need to check the prefix if there is one + else if( this.curr_syntax[i]["keywords"][prefix]['prefix'].length > 0 ) + { + if( before.match( this.curr_syntax[i]["keywords"][prefix]['prefix_reg'] ) ) + hasMatch = true; + } + + if( hasMatch ) + results[results.length]= [ this.curr_syntax[i]["keywords"][prefix], this.curr_syntax[i]["keywords"][prefix]['datas'][j] ]; + } + } + } + } + // it doesn't match any possible word but we want to display something + // we'll display to list of all available words + else if( this.forceDisplay || match_prefix_separator ) + { + for(var prefix in this.curr_syntax[i]["keywords"]) + { + for(var j=0; j it's valid + if( !match_prefix_separator && this.curr_syntax[i]["keywords"][prefix]['prefix'].length == 0 ) + { + hasMatch = true; + } + // we still need to check the prefix if there is one + else if( match_prefix_separator && this.curr_syntax[i]["keywords"][prefix]['prefix'].length > 0 ) + { + var before = last_chars; //.substr( 0, last_chars.length ); + if( before.match( this.curr_syntax[i]["keywords"][prefix]['prefix_reg'] ) ) + hasMatch = true; + } + + if( hasMatch ) + results[results.length]= [ this.curr_syntax[i]["keywords"][prefix], this.curr_syntax[i]["keywords"][prefix]['datas'][j] ]; + } + } + } + } + } + + // there is only one result, and we can select it automatically + if( results.length == 1 && this.autoSelectIfOneResult ) + { + console.log( results ); + this._select( results[0][1]['replace_with'] ); + } + else if( results.length == 0 ) + { + this._hide(); + } + else + { + // build the suggestion box content + var lines=[]; + for(var i=0; i"+ results[i][1]['comment']; + if(results[i][0]['prefix_name'].length>0) + line+=''+ results[i][0]['prefix_name'] +''; + line+=''; + lines[lines.length]=line; + } + // sort results + this.container.innerHTML = '
    '+ lines.sort().join('') +'
'; + + var cursor = $("cursor_pos"); + this.container.style.top = ( cursor.cursor_top + editArea.lineHeight ) +"px"; + this.container.style.left = ( cursor.cursor_left + 8 ) +"px"; + this._show(); + } + + this.autoSelectIfOneResult = false; + time=new Date; + t2= time.getTime(); + + //parent.console.log( begin_word +"\n"+ (t2-t1) +"\n"+ html ); + } + } +}; + +// Load as a plugin +editArea.settings['plugins'][ editArea.settings['plugins'].length ] = 'autocompletion'; +editArea.add_plugin('autocompletion', EditArea_autocompletion); \ No newline at end of file diff --git a/www/extras/editarea/edit_area/edit_area.css b/www/extras/editarea/edit_area/edit_area.css new file mode 100755 index 000000000..2b96af9b2 --- /dev/null +++ b/www/extras/editarea/edit_area/edit_area.css @@ -0,0 +1,507 @@ +body, html{ + margin: 0; + padding: 0; + height: 100%; + border: none; + overflow: hidden; + background-color: #FFF; +} + +body, html, table, form, textarea{ + font: 12px monospace, sans-serif; +} + +#editor{ + border: solid #888 1px; + overflow: visible; +} + +#result{ + z-index: 4; + overflow-x: auto; + overflow-y: scroll; + border-top: solid #888 1px; + border-bottom: solid #888 1px; + position: relative; + clear: both; +} + +#result.empty{ + overflow: hidden; +} + +#container{ + overflow: hidden; + border: solid blue 0; + position: relative; + z-index: 10; + padding: 0 5px 0 45px; + /*padding-right: 5px;*/ +} + +#textarea{ + position: relative; + top: 0; + left: 0; + margin: 0; + padding: 0; + width: 100%; + height: 100%; + overflow: hidden; + z-index: 7; + border-width: 0; + background-color: transparent; +} + +#textarea, #textarea:hover{ + outline: none; /* safari outline fix */ +} + +#content_highlight{ + white-space: pre; + margin: 0; + padding: 0; + position : absolute; + z-index: 4; + overflow: visible; +} + + +#selection_field{ + margin: 0; + background-color: #E1F2F9; + height: 1px; + position: absolute; + z-index: 5; + top: -100px; + padding: 0; + white-space: pre; + overflow: hidden; +} + +#selection_field.show_colors{ + z-index: 3; + background-color:#EDF9FC; + color:transparent; +} + +#container.wrap_text #content_highlight, #container.wrap_text #selection_field{ + white-space: pre-wrap; /* css-3 */ + white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */ + white-space: -pre-wrap; /* Opera 4-6 */ + white-space: -o-pre-wrap; /* Opera 7 */ + word-wrap: break-word; /* Internet Explorer 5.5+ */ + width: 99%; +} + +#line_number{ + position: absolute; + overflow: hidden; + border-right: solid black 1px; + z-index:8; + width: 38px; + padding: 0 5px 0 0; + margin: 0 0 0 -45px; + text-align: right; + color: #AAAAAA; +} + +#test_font_size{ + padding: 0; + margin: 0; + visibility: hidden; + position: absolute; + white-space: pre; +} + +pre{ + margin: 0; + padding: 0; +} + +.hidden{ + opacity: 0.2; + filter:alpha(opacity=20); +} + +#result .edit_area_cursor{ + position: absolute; + z-index:6; + background-color: #FF6633; + top: -100px; + margin: 1px 0 0 0; +} + +#result .edit_area_selection_field .overline{ + background-color: #996600; +} + + +/* area popup */ +.editarea_popup{ + border: solid 1px #888888; + background-color: #ECE9D8; + width: 250px; + padding: 4px; + position: absolute; + visibility: hidden; + z-index: 15; + top: -500px; +} + +.editarea_popup, .editarea_popup table{ + font-family: sans-serif; + font-size: 10pt; +} + +.editarea_popup img{ + border: 0; +} + +.editarea_popup .close_popup{ + float: right; + line-height: 16px; + border: 0; + padding: 0; +} + +.editarea_popup h1,.editarea_popup h2,.editarea_popup h3,.editarea_popup h4,.editarea_popup h5,.editarea_popup h6{ + margin: 0; + padding: 0; +} + +.editarea_popup .copyright{ + text-align: right; +} + +/* Area_search */ +div#area_search_replace{ + /*width: 250px;*/ +} + +div#area_search_replace img{ + border: 0; +} + +div#area_search_replace div.button{ + text-align: center; + line-height: 1.7em; +} + +div#area_search_replace .button a{ + cursor: pointer; + border: solid 1px #888888; + background-color: #DEDEDE; + text-decoration: none; + padding: 0 2px; + color: #000000; + white-space: nowrap; +} + +div#area_search_replace a:hover{ + /*border: solid 1px #888888;*/ + background-color: #EDEDED; +} + +div#area_search_replace #move_area_search_replace{ + cursor: move; + border: solid 1px #888; +} + +div#area_search_replace #close_area_search_replace{ + text-align: right; + vertical-align: top; + white-space: nowrap; +} + +div#area_search_replace #area_search_msg{ + height: 18px; + overflow: hidden; + border-top: solid 1px #888; + margin-top: 3px; +} + +/* area help */ +#edit_area_help{ + width: 350px; +} + +#edit_area_help div.close_popup{ + float: right; +} + +/* area_toolbar */ +.area_toolbar{ + /*font: 11px sans-serif;*/ + width: 100%; + /*height: 21px; */ + margin: 0; + padding: 0; + background-color: #ECE9D8; + text-align: center; +} + +.area_toolbar, .area_toolbar table{ + font: 11px sans-serif; +} + +.area_toolbar img{ + border: 0; + vertical-align: middle; +} + +.area_toolbar input{ + margin: 0; + padding: 0; +} + +.area_toolbar select{ + font-family: 'MS Sans Serif',sans-serif,Verdana,Arial; + font-size: 7pt; + font-weight: normal; + margin: 2px 0 0 0 ; + padding: 0; + vertical-align: top; + background-color: #F0F0EE; +} + +table.statusbar{ + width: 100%; +} + +.area_toolbar td.infos{ + text-align: center; + width: 130px; + border-right: solid 1px #888; + border-width: 0 1px 0 0; + padding: 0; +} + +.area_toolbar td.total{ + text-align: right; + width: 50px; + padding: 0; +} + +.area_toolbar td.resize{ + text-align: right; +} +/* +.area_toolbar span{ + line-height: 1px; + padding: 0; + margin: 0; +}*/ + +.area_toolbar span#resize_area{ + cursor: nw-resize; + visibility: hidden; +} + +/* toolbar buttons */ +.editAreaButtonNormal, .editAreaButtonOver, .editAreaButtonDown, .editAreaSeparator, .editAreaSeparatorLine, .editAreaButtonDisabled, .editAreaButtonSelected { + border: 0; margin: 0; padding: 0; background: transparent; + margin-top: 0; + margin-left: 1px; + padding: 0; +} + +.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; +} + +/* waiting screen */ +#processing{ + display: none; + background-color:#ECE9D8; + border: solid #888 1px; + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + z-index: 100; + text-align: center; +} + +#processing_text{ + position:absolute; + left: 50%; + top: 50%; + width: 200px; + height: 20px; + margin-left: -100px; + margin-top: -10px; + text-align: center; +} +/* end */ + + +/**** tab browsing area ****/ +#tab_browsing_area{ + display: none; + background-color: #CCC9A8; + border-top: 1px solid #888; + text-align: left; + margin: 0; +} + +#tab_browsing_list { + padding: 0; + margin: 0; + list-style-type: none; + white-space: nowrap; +} +#tab_browsing_list li { + float: left; + margin: -1px; +} +#tab_browsing_list a { + position: relative; + display: block; + text-decoration: none; + float: left; + cursor: pointer; + line-height:14px; +} + +#tab_browsing_list a span { + display: block; + color: #000; + background: #ECE9D8; + border: 1px solid #888; + border-width: 1px 1px 0; + text-align: center; + padding: 2px 2px 1px 4px; + position: relative; /*IE 6 hack */ +} + +#tab_browsing_list a b { + display: block; + border-bottom: 2px solid #617994; +} + +#tab_browsing_list a .edited { + display: none; +} + +#tab_browsing_list a.edited .edited { + display: inline; +} + +#tab_browsing_list a img{ + margin-left: 7px; +} + +#tab_browsing_list a.edited img{ + margin-left: 3px; +} + +#tab_browsing_list a:hover span { + background: #F4F2E8; + border-color: #0A246A; +} + +#tab_browsing_list .selected a span{ + background: #046380; + color: #FFF; +} + + +#no_file_selected{ + height: 100%; + width: 150%; /* Opera need more than 100% */ + background: #CCC; + display: none; + z-index: 20; + position: absolute; +} + + +/*** Non-editable mode ***/ +.non_editable #editor +{ + border-width: 0 1px; +} + +.non_editable .area_toolbar +{ + display: none; +} + +/*** Auto completion ***/ +#auto_completion_area +{ + background: #FFF; + border: solid 1px #888; + position: absolute; + z-index: 15; + width: 280px; + height: 180px; + overflow: auto; + display:none; +} + +#auto_completion_area a, #auto_completion_area a:visited +{ + display: block; + padding: 0 2px 1px; + color: #000; + text-decoration:none; +} + +#auto_completion_area a:hover, #auto_completion_area a:focus, #auto_completion_area a.focus +{ + background: #D6E1FE; + text-decoration:none; +} + +#auto_completion_area ul +{ + margin: 0; + padding: 0; + list-style: none inside; +} +#auto_completion_area li +{ + padding: 0; +} +#auto_completion_area .prefix +{ + font-style: italic; + padding: 0 3px; +} \ No newline at end of file diff --git a/www/extras/editarea/edit_area/edit_area.js b/www/extras/editarea/edit_area/edit_area.js new file mode 100755 index 000000000..ac0c62daf --- /dev/null +++ b/www/extras/editarea/edit_area/edit_area.js @@ -0,0 +1,510 @@ +/****** + * + * EditArea + * Developped by Christophe Dolivet + * Released under LGPL and Apache licenses + * +******/ + + function EditArea(){ + this.error= false; // to know if load is interrrupt + + this.inlinePopup= new Array({popup_id: "area_search_replace", icon_id: "search"}, + {popup_id: "edit_area_help", icon_id: "help"}); + this.plugins= new Object(); + + this.line_number=0; + + this.nav=parent.editAreaLoader.nav; // navigator identification + + this.last_selection=new Object(); + this.last_text_to_highlight=""; + this.last_hightlighted_text= ""; + this.syntax_list= new Array(); + this.allready_used_syntax= new Object(); + this.check_line_selection_timer= 50; // the timer delay for modification and/or selection change detection + + this.textareaFocused= false; + this.highlight_selection_line= null; + this.previous= new Array(); + this.next= new Array(); + this.last_undo=""; + this.files= new Object(); + this.filesIdAssoc= new Object(); + this.curr_file= ''; + //this.loaded= false; + this.assocBracket=new Object(); + this.revertAssocBracket= new Object(); + // bracket selection init + this.assocBracket["("]=")"; + this.assocBracket["{"]="}"; + this.assocBracket["["]="]"; + for(var index in this.assocBracket){ + this.revertAssocBracket[this.assocBracket[index]]=index; + } + this.is_editable= true; + + + /*this.textarea=""; + + this.state="declare"; + this.code = new Array(); // store highlight syntax for languagues*/ + // font datas + this.lineHeight= 16; + /*this.default_font_family= "monospace"; + this.default_font_size= 10;*/ + this.tab_nb_char= 8; //nb of white spaces corresponding to a tabulation + if(this.nav['isOpera']) + this.tab_nb_char= 6; + + this.is_tabbing= false; + + this.fullscreen= {'isFull': false}; + + this.isResizing=false; // resize var + + // init with settings and ID + this.id= area_id; + this.settings= editAreas[this.id]["settings"]; + + if((""+this.settings['replace_tab_by_spaces']).match(/^[0-9]+$/)) + { + this.tab_nb_char= this.settings['replace_tab_by_spaces']; + this.tabulation=""; + for(var i=0; i0) + this.syntax_list= this.settings["syntax_selection_allow"].replace(/ /g,"").split(","); + + if(this.settings['syntax']) + this.allready_used_syntax[this.settings['syntax']]=true; + + + }; + + + //called by the toggle_on + EditArea.prototype.update_size= function(){ + + if(editAreas[editArea.id] && editAreas[editArea.id]["displayed"]==true){ + if(editArea.fullscreen['isFull']){ + parent.document.getElementById("frame_"+editArea.id).style.width= parent.document.getElementsByTagName("html")[0].clientWidth + "px"; + parent.document.getElementById("frame_"+editArea.id).style.height= parent.document.getElementsByTagName("html")[0].clientHeight + "px"; + } + + if(editArea.tab_browsing_area.style.display=='block' && !editArea.nav['isIE']) + { + editArea.tab_browsing_area.style.height= "0px"; + editArea.tab_browsing_area.style.height= (editArea.result.offsetTop - editArea.tab_browsing_area.offsetTop -1)+"px"; + } + + var height= document.body.offsetHeight - editArea.get_all_toolbar_height() - 4; + editArea.result.style.height= height +"px"; + + var width=document.body.offsetWidth -2; + editArea.result.style.width= width+"px"; + //alert("result h: "+ height+" w: "+width+"\ntoolbar h: "+this.get_all_toolbar_height()+"\nbody_h: "+document.body.offsetHeight); + + // check that the popups don't get out of the screen + for(var i=0; imax_top) + popup.style.top= max_top+"px"; + if(popup.offsetLeft>max_left) + popup.style.left= max_left+"px"; + } + } + }; + + EditArea.prototype.init= function(){ + this.textarea= $("textarea"); + this.container= $("container"); + this.result= $("result"); + this.content_highlight= $("content_highlight"); + this.selection_field= $("selection_field"); + this.processing_screen= $("processing"); + this.editor_area= $("editor"); + this.tab_browsing_area= $("tab_browsing_area"); + + if(!this.settings['is_editable']) + this.set_editable(false); + + this.set_show_line_colors( this.settings['show_line_colors'] ); + + if(syntax_selec= $("syntax_selection")) + { + // set up syntax selection lsit in the toolbar + for(var i=0; i= '3' ) + this.content_highlight.style.borderLeft= "solid 1px transparent"; + + if(this.nav['isIE']){ + this.textarea.style.marginTop= "-1px"; + } + /* + if(this.nav['isOpera']){ + this.editor_area.style.position= "absolute"; + }*/ + + if(this.nav['isSafari'] ){ + this.editor_area.style.position= "absolute"; + this.textarea.style.marginLeft="-3px"; + this.textarea.style.marginTop="1px"; + } + + if( this.nav['isChrome'] ){ + this.editor_area.style.position= "absolute"; + this.textarea.style.marginLeft="0px"; + this.textarea.style.marginTop="0px"; + } + + // si le textarea n'est pas grand, un click sous le textarea doit provoquer un focus sur le textarea + parent.editAreaLoader.add_event(this.result, "click", function(e){ if((e.target || e.srcElement)==editArea.result) { editArea.area_select(editArea.textarea.value.length, 0);} }); + + if(this.settings['is_multi_files']!=false) + this.open_file({'id': this.curr_file, 'text': ''}); + + this.set_wrap_text( this.settings['wrap_text'] ); + + setTimeout("editArea.focus();editArea.manage_size();editArea.execCommand('EA_load');", 10); + //start checkup routine + this.check_undo(); + this.check_line_selection(true); + this.scroll_to_view(); + + for(var i in this.plugins){ + if(typeof(this.plugins[i].onload)=="function") + this.plugins[i].onload(); + } + if(this.settings['fullscreen']==true) + this.toggle_full_screen(true); + + parent.editAreaLoader.add_event(window, "resize", editArea.update_size); + parent.editAreaLoader.add_event(parent.window, "resize", editArea.update_size); + parent.editAreaLoader.add_event(top.window, "resize", editArea.update_size); + parent.editAreaLoader.add_event(window, "unload", function(){if(editAreas[editArea.id] && editAreas[editArea.id]["displayed"]) editArea.execCommand("EA_unload");}); + + + /*date= new Date(); + alert(date.getTime()- parent.editAreaLoader.start_time);*/ + }; + + + EditArea.prototype.manage_size= function(onlyOneTime){ + if(!editAreas[this.id]) + return false; + if(editAreas[this.id]["displayed"]==true && this.textareaFocused) + { + var resized= false; + + //1) Manage display width + //1.1) Calc the new width to use for display + if( this.settings['wrap_text'] ) + { + // var area_width= this.result.offsetWidth -50; + } + else + { + var area_width= this.textarea.scrollWidth; + var area_height= this.textarea.scrollHeight; + if(this.nav['isOpera']){ + area_width=10000; /* TODO: find a better way to fix the width problem */ + } + } + + + //1.2) the width is not the same, we must resize elements + if(this.textarea.previous_scrollWidth!=area_width) + { + + this.container.style.width= area_width+"px"; + this.textarea.style.width= area_width+"px"; + this.content_highlight.style.width= area_width+"px"; + this.textarea.previous_scrollWidth=area_width; + resized=true; + } + + + //2) Manage display height + //2.1) Calc the new height to use for display + var area_height = this.textarea.scrollHeight; + if(this.nav['isOpera']){ + area_height= this.last_selection['nb_line']*this.lineHeight; + } + + if(this.nav['isGecko'] && this.smooth_selection && this.last_selection["nb_line"]) + area_height= this.last_selection["nb_line"]*this.lineHeight; + //2.2) the width is not the same, we must resize elements + if(this.textarea.previous_scrollHeight!=area_height) + { + this.container.style.height= (area_height+2)+"px"; + this.textarea.style.height= area_height+"px"; + this.content_highlight.style.height= area_height+"px"; + this.textarea.previous_scrollHeight= area_height; + resized=true; + } + + //3) if there is new lines, we add new line numbers in the line numeration area + if(this.last_selection["nb_line"] >= this.line_number) + { + var div_line_number=""; + for(i=this.line_number+1; i"; + this.line_number++; + } + var span= document.createElement("span"); + if(this.nav['isIE']) + span.unselectable=true; + span.innerHTML=div_line_number; + $("line_number").appendChild(span); + } + + //4) be sure the text is well displayed + this.textarea.scrollTop="0px"; + this.textarea.scrollLeft="0px"; + if(resized==true){ + this.scroll_to_view(); + } + } + if(!onlyOneTime) + setTimeout("editArea.manage_size();", 100); + }; + + EditArea.prototype.add_event = function(obj, name, handler) { + if (this.nav['isIE']) { + obj.attachEvent("on" + name, handler); + } else{ + obj.addEventListener(name, handler, false); + } + }; + + EditArea.prototype.execCommand= function(cmd, param){ + + for(var i in this.plugins){ + if(typeof(this.plugins[i].execCommand)=="function"){ + if(!this.plugins[i].execCommand(cmd, param)) + return; + } + } + switch(cmd){ + case "save": + if(this.settings["save_callback"].length>0) + eval("parent."+this.settings["save_callback"]+"('"+ this.id +"', editArea.textarea.value);"); + break; + case "load": + if(this.settings["load_callback"].length>0) + eval("parent."+this.settings["load_callback"]+"('"+ this.id +"');"); + break; + case "onchange": + if(this.settings["change_callback"].length>0) + eval("parent."+this.settings["change_callback"]+"('"+ this.id +"');"); + break; + case "EA_load": + if(this.settings["EA_load_callback"].length>0) + eval("parent."+this.settings["EA_load_callback"]+"('"+ this.id +"');"); + break; + case "EA_unload": + if(this.settings["EA_unload_callback"].length>0) + eval("parent."+this.settings["EA_unload_callback"]+"('"+ this.id +"');"); + break; + case "toggle_on": + if(this.settings["EA_toggle_on_callback"].length>0) + eval("parent."+this.settings["EA_toggle_on_callback"]+"('"+ this.id +"');"); + break; + case "toggle_off": + if(this.settings["EA_toggle_off_callback"].length>0) + eval("parent."+this.settings["EA_toggle_off_callback"]+"('"+ this.id +"');"); + break; + case "re_sync": + if(!this.do_highlight) + break; + case "file_switch_on": + if(this.settings["EA_file_switch_on_callback"].length>0) + eval("parent."+this.settings["EA_file_switch_on_callback"]+"(param);"); + break; + case "file_switch_off": + if(this.settings["EA_file_switch_off_callback"].length>0) + eval("parent."+this.settings["EA_file_switch_off_callback"]+"(param);"); + break; + case "file_close": + if(this.settings["EA_file_close_callback"].length>0) + return eval("parent."+this.settings["EA_file_close_callback"]+"(param);"); + break; + + default: + if(typeof(eval("editArea."+cmd))=="function") + { + if(this.settings["debug"]) + eval("editArea."+ cmd +"(param);"); + else + try{eval("editArea."+ cmd +"(param);");}catch(e){}; + } + } + }; + + EditArea.prototype.get_translation= function(word, mode){ + if(mode=="template") + return parent.editAreaLoader.translate(word, this.settings["language"], mode); + else + return parent.editAreaLoader.get_word_translation(word, this.settings["language"]); + }; + + EditArea.prototype.add_plugin= function(plug_name, plug_obj){ + for(var i=0; i"); + } + }; + + EditArea.prototype.load_script= function(url){ + try{ + script = document.createElement("script"); + script.type = "text/javascript"; + script.src = url; + script.charset= "UTF-8"; + head = document.getElementsByTagName("head"); + head[0].appendChild(script); + }catch(e){ + document.write("\";\n", $sub_scripts); + + + // add the script and use a last compression + if( $this->param['compress'] ) + { + $last_comp = array( 'Á' => 'this', + 'Â' => 'textarea', + 'Ã' => 'function', + 'Ä' => 'prototype', + 'Å' => 'settings', + 'Æ' => 'length', + 'Ç' => 'style', + 'È' => 'parent', + 'É' => 'last_selection', + 'Ê' => 'value', + 'Ë' => 'true', + 'Ì' => 'false' + /*, + 'Î' => '"', + 'Ï' => "\n", + 'À' => "\r"*/); + } + else + { + $last_comp = array(); + } + + $js_replace= ''; + foreach( $last_comp as $key => $val ) + $js_replace .= ".replace(/". $key ."/g,'". str_replace( array("\n", "\r"), array('\n','\r'), $val ) ."')"; + + $this->datas.= sprintf("editAreaLoader.iframe_script= \"\"%s;\n", + str_replace( array_values($last_comp), array_keys($last_comp), $sub_scripts ), + $js_replace); + + if($this->load_all_plugins) + $this->datas.="editAreaLoader.all_plugins_loaded=true;\n"; + + + // load the template + $this->datas.= sprintf("editAreaLoader.template= \"%s\";\n", $this->get_html_content("template.html")); + // load the css + $this->datas.= sprintf("editAreaLoader.iframe_css= \"\";\n", $this->get_css_content("edit_area.css")); + + // $this->datas= "function editArea(){};editArea.prototype.loader= function(){alert('bouhbouh');} var a= new editArea();a.loader();"; + + } + + function send_datas() + { + if($this->param['debug']){ + $header=sprintf("/* USE PHP COMPRESSION\n"); + $header.=sprintf("javascript size: based files: %s => PHP COMPRESSION => %s ", $this->file_loaded_size, strlen($this->datas)); + if($this->use_gzip){ + $gzip_datas= gzencode($this->datas, 9, FORCE_GZIP); + $header.=sprintf("=> GZIP COMPRESSION => %s", strlen($gzip_datas)); + $ratio = round(100 - strlen($gzip_datas) / $this->file_loaded_size * 100.0); + }else{ + $ratio = round(100 - strlen($this->datas) / $this->file_loaded_size * 100.0); + } + $header.=sprintf(", reduced by %s%%\n", $ratio); + $header.=sprintf("compression time: %s\n", $this->get_microtime()-$this->start_time); + $header.=sprintf("%s\n", implode("\n", $this->infos)); + $header.=sprintf("*/\n"); + $this->datas= $header.$this->datas; + } + $mtime= time(); // ensure that the 2 disk files will have the same update time + // generate gzip file and cahce it if using disk cache + if($this->use_gzip){ + $this->gzip_datas= gzencode($this->datas, 9, FORCE_GZIP); + if($this->param['use_disk_cache']) + $this->file_put_contents($this->gzip_cache_file, $this->gzip_datas, $mtime); + } + + // generate full js file and cache it if using disk cache + if($this->param['use_disk_cache']) + $this->file_put_contents($this->full_cache_file, $this->datas, $mtime); + + // generate output + if($this->use_gzip) + echo $this->gzip_datas; + else + echo $this->datas; + +// die; + } + + + function get_content($end_uri) + { + $end_uri=preg_replace("/\.\./", "", $end_uri); // Remove any .. (security) + $file= $this->path.$end_uri; + if(file_exists($file)){ + $this->infos[]=sprintf("'%s' loaded", $end_uri); + /*$fd = fopen($file, 'rb'); + $content = fread($fd, filesize($file)); + fclose($fd); + return $content;*/ + return $this->file_get_contents($file); + }else{ + $this->infos[]=sprintf("'%s' not loaded", $end_uri); + return ""; + } + } + + function get_javascript_content($end_uri) + { + $val=$this->get_content($end_uri); + + $this->compress_javascript($val); + $this->prepare_string_for_quotes($val); + return $val; + } + + function compress_javascript(&$code) + { + if($this->param['compress']) + { + // remove all comments + // (\"(?:[^\"\\]*(?:\\\\)*(?:\\\"?)?)*(?:\"|$))|(\'(?:[^\'\\]*(?:\\\\)*(?:\\'?)?)*(?:\'|$))|(?:\/\/(?:.|\r|\t)*?(\n|$))|(?:\/\*(?:.|\n|\r|\t)*?(?:\*\/|$)) + $code= preg_replace("/(\"(?:[^\"\\\\]*(?:\\\\\\\\)*(?:\\\\\"?)?)*(?:\"|$))|(\'(?:[^\'\\\\]*(?:\\\\\\\\)*(?:\\\\\'?)?)*(?:\'|$))|(?:\/\/(?:.|\r|\t)*?(\n|$))|(?:\/\*(?:.|\n|\r|\t)*?(?:\*\/|$))/s", "$1$2$3", $code); + // remove line return, empty line and tabulation + $code= preg_replace('/(( |\t|\r)*\n( |\t)*)+/s', " ", $code); + // add line break before "else" otherwise navigators can't manage to parse the file + $code= preg_replace('/(\b(else)\b)/', "\n$1", $code); + // remove unnecessary spaces + $code= preg_replace('/( |\t|\r)?(;|\{|\}|=|==|\-|\+|,|\(|\)|\|\||&\&|\:)( |\t|\r)+/', "$2", $code); + } + } + + function get_css_content($end_uri){ + $code=$this->get_content($end_uri); + // remove comments + $code= preg_replace("/(?:\/\*(?:.|\n|\r|\t)*?(?:\*\/|$))/s", "", $code); + // remove spaces + $code= preg_replace('/(( |\t|\r)*\n( |\t)*)+/s', "", $code); + // remove spaces + $code= preg_replace('/( |\t|\r)?(\:|,|\{|\})( |\t|\r)+/', "$2", $code); + + $this->prepare_string_for_quotes($code); + return $code; + } + + function get_html_content($end_uri){ + $code=$this->get_content($end_uri); + //$code= preg_replace('/(\"(?:\\\"|[^\"])*(?:\"|$))|' . "(\'(?:\\\'|[^\'])*(?:\'|$))|(?:\/\/(?:.|\r|\t)*?(\n|$))|(?:\/\*(?:.|\n|\r|\t)*?(?:\*\/|$))/s", "$1$2$3", $code); + $code= preg_replace('/(( |\t|\r)*\n( |\t)*)+/s', " ", $code); + $this->prepare_string_for_quotes($code); + return $code; + } + + function prepare_string_for_quotes(&$str){ + // prepare the code to be putted into quotes + /*$pattern= array("/(\\\\)?\"/", '/\\\n/' , '/\\\r/' , "/(\r?\n)/"); + $replace= array('$1$1\\"', '\\\\\\n', '\\\\\\r' , '\\\n"$1+"');*/ + $pattern= array("/(\\\\)?\"/", '/\\\n/' , '/\\\r/' , "/(\r?\n)/"); + if($this->param['compress']) + $replace= array('$1$1\\"', '\\\\\\n', '\\\\\\r' , '\n'); + else + $replace= array('$1$1\\"', '\\\\\\n', '\\\\\\r' , "\\n\"\n+\""); + $str= preg_replace($pattern, $replace, $str); + } + + function replace_scripts($var, $param1, $param2) + { + $this->$var=stripslashes($param2); + return $param1."();"; + } + + /* for php version that have not thoses functions */ + function file_get_contents($file) + { + $fd = fopen($file, 'rb'); + $content = fread($fd, filesize($file)); + fclose($fd); + $this->file_loaded_size+= strlen($content); + return $content; + } + + function file_put_contents($file, &$content, $mtime=-1) + { + if($mtime==-1) + $mtime=time(); + $fp = @fopen($file, "wb"); + if ($fp) { + fwrite($fp, $content); + fclose($fp); + touch($file, $mtime); + return true; + } + return false; + } + + function get_microtime() + { + list($usec, $sec) = explode(" ", microtime()); + return ((float)$usec + (float)$sec); + } + } +?> diff --git a/www/extras/editarea/edit_area/edit_area_full.gz b/www/extras/editarea/edit_area/edit_area_full.gz new file mode 100755 index 000000000..980e86079 Binary files /dev/null and b/www/extras/editarea/edit_area/edit_area_full.gz differ diff --git a/www/extras/editarea/edit_area/edit_area_full.js b/www/extras/editarea/edit_area/edit_area_full.js new file mode 100755 index 000000000..866103bfa --- /dev/null +++ b/www/extras/editarea/edit_area/edit_area_full.js @@ -0,0 +1,38 @@ + function EAL(){this.version="0.7.2.2";date=new Date();this.start_time=date.getTime();this.win="loading";this.error=false;this.baseURL="";this.template="";this.lang=new Object();this.load_syntax=new Object();this.syntax=new Object();this.loadedFiles=new Array();this.waiting_loading=new Object();this.scripts_to_load=new Array();this.sub_scripts_to_load=new Array();this.resize=new Array();this.hidden=new Object();this.default_settings={debug:false ,smooth_selection:true ,font_size:"10" ,font_family:"monospace" ,start_highlight:false ,autocompletion:false ,toolbar:"search,go_to_line,fullscreen,|,undo,redo,|,select_font,|,change_smooth_selection,highlight,reset_highlight,|,help" ,begin_toolbar:"" ,end_toolbar:"" ,is_multi_files:false ,allow_resize:"both" ,show_line_colors:false ,min_width:400 ,min_height:125 ,replace_tab_by_spaces:false ,allow_toggle:true ,language:"en" ,syntax:"" ,syntax_selection_allow:"basic,brainfuck,c,coldfusion,cpp,css,html,js,pas,perl,php,python,ruby,robotstxt,sql,tsql,vb,xml" ,display:"onload" ,max_undo:30 ,browsers:"known" ,plugins:"" ,gecko_spellcheck:false ,fullscreen:false ,is_editable:true ,wrap_text:false ,load_callback:"" ,save_callback:"" ,change_callback:"" ,submit_callback:"" ,EA_init_callback:"" ,EA_delete_callback:"" ,EA_load_callback:"" ,EA_unload_callback:"" ,EA_toggle_on_callback:"" ,EA_toggle_off_callback:"" ,EA_file_switch_on_callback:"" ,EA_file_switch_off_callback:"" ,EA_file_close_callback:"" };this.advanced_buttons=[ ['new_document','newdocument.gif','new_document',false],['search','search.gif','show_search',false],['go_to_line','go_to_line.gif','go_to_line',false],['undo','undo.gif','undo',true],['redo','redo.gif','redo',true],['change_smooth_selection','smooth_selection.gif','change_smooth_selection_mode',true],['reset_highlight','reset_highlight.gif','resync_highlight',true],['highlight','highlight.gif','change_highlight',true],['help','help.gif','show_help',false],['save','save.gif','save',false],['load','load.gif','load',false],['fullscreen','fullscreen.gif','toggle_full_screen',false],['autocompletion','autocompletion.gif','toggle_autocompletion',true] ];ua=navigator.userAgent;this.nav=new Object();this.nav['isMacOS']=(ua.indexOf('Mac OS')!=-1);this.nav['isIE']=(navigator.appName=="Microsoft Internet Explorer");if(this.nav['isIE']){this.nav['isIE']=ua.replace(/^.*?MSIE ([0-9\.]*).*$/,"$1");if(this.nav['isIE']<6)this.has_error();}if(this.nav['isNS']=ua.indexOf('Netscape/')!=-1){this.nav['isNS']=ua.substr(ua.indexOf('Netscape/')+9);if(this.nav['isNS']<8||!this.nav['isIE'])this.has_error();}if(this.nav['isOpera']=(ua.indexOf('Opera')!=-1)){this.nav['isOpera']=ua.replace(/^.*?Opera.*?([0-9\.]+).*$/i,"$1");if(this.nav['isOpera']<9)this.has_error();this.nav['isIE']=false;}this.nav['isGecko']=(ua.indexOf('Gecko')!=-1);if(this.nav['isFirefox'] =(ua.indexOf('Firefox')!=-1))this.nav['isFirefox']=ua.replace(/^.*?Firefox.*?([0-9\.]+).*$/i,"$1");if(this.nav['isIceweasel'] =(ua.indexOf('Iceweasel')!=-1))this.nav['isFirefox']=this.nav['isIceweasel']=ua.replace(/^.*?Iceweasel.*?([0-9\.]+).*$/i,"$1");if(this.nav['GranParadiso'] =(ua.indexOf('GranParadiso')!=-1))this.nav['isFirefox']=this.nav['isGranParadiso']=ua.replace(/^.*?GranParadiso.*?([0-9\.]+).*$/i,"$1");if(this.nav['isCamino'] =(ua.indexOf('Camino')!=-1))this.nav['isCamino']=ua.replace(/^.*?Camino.*?([0-9\.]+).*$/i,"$1");if(this.nav['isChrome'] =(ua.indexOf('Chrome')!=-1))this.nav['isChrome']=ua.replace(/^.*?Chrome.*?([0-9\.]+).*$/i,"$1");if(this.nav['isSafari'] =(ua.indexOf('Safari')!=-1))this.nav['isSafari']=ua.replace(/^.*?Version\/([0-9]+\.[0-9]+).*$/i,"$1");if(this.nav['isIE']>=6||this.nav['isOpera']>=9||this.nav['isFirefox']||this.nav['isChrome']||this.nav['isCamino']||this.nav['isSafari']>=3)this.nav['isValidBrowser']=true; +else this.nav['isValidBrowser']=false;this.set_base_url();for(var i=0;i0)settings["toolbar"]=settings["begin_toolbar"] +","+settings["toolbar"];if(settings["end_toolbar"].length>0)settings["toolbar"]=settings["toolbar"] +","+settings["end_toolbar"];settings["tab_toolbar"]=settings["toolbar"].replace(/ /g,"").split(",");settings["plugins"]=settings["plugins"].replace(/ /g,"").split(",");for(var i=0;i0){settings["syntax"]=settings["syntax"].toLowerCase();this.load_script(this.baseURL+"reg_syntax/"+settings["syntax"]+".js");}eAs[settings["id"]]={"settings":settings};eAs[settings["id"]]["displayed"]=false;eAs[settings["id"]]["hidden"]=false;eAL.start(settings["id"]);},delete_instance:function(id){eAL.execCommand(id,"EA_delete");if(window.frames["frame_"+id]&&window.frames["frame_"+id].editArea){if(eAs[id]["displayed"])eAL.toggle(id,"off");window.frames["frame_"+id].editArea.execCommand("EA_unload");}var span=document.getElementById("EditAreaArroundInfos_"+id);if(span)span.parentNode.removeChild(span);var iframe=document.getElementById("frame_"+id);if(iframe){iframe.parentNode.removeChild(iframe);try{delete window.frames["frame_"+id];}catch (e){}}delete eAs[id];},start:function(id){if(this.win!="loaded"){setTimeout("eAL.start('"+id+"');",50);return;}for(var i in eAL.waiting_loading){if(eAL.waiting_loading[i]!="loaded"&&typeof(eAL.waiting_loading[i])!="function"){setTimeout("eAL.start('"+id+"');",50);return;}}if(!eAL.lang[eAs[id]["settings"]["language"]]||(eAs[id]["settings"]["syntax"].length>0&&!eAL.load_syntax[eAs[id]["settings"]["syntax"]])){setTimeout("eAL.start('"+id+"');",50);return;}if(eAs[id]["settings"]["syntax"].length>0)eAL.init_syntax_regexp();if(!document.getElementById("EditAreaArroundInfos_"+id)&&(eAs[id]["settings"]["debug"]||eAs[id]["settings"]["allow_toggle"])){var span=document.createElement("span");span.id="EditAreaArroundInfos_"+id;var html="";if(eAs[id]["settings"]["allow_toggle"]){checked=(eAs[id]["settings"]["display"]=="onload")?"checked":"";html+="
";html+="";html+="
";}if(eAs[id]["settings"]["debug"])html+="
";html=eAL.translate(html,eAs[id]["settings"]["language"]);span.innerHTML=html;var father=document.getElementById(id).parentNode;var next=document.getElementById(id).nextSibling;if(next==null)father.appendChild(span); +else father.insertBefore(span,next);}if(!eAs[id]["initialized"]){this.execCommand(id,"EA_init");if(eAs[id]["settings"]["display"]=="later"){eAs[id]["initialized"]=true;return;}}if(this.nav['isIE']){eAL.init_ie_textarea(id);}var html_toolbar_content="";area=eAs[id];for(var i=0;i';}for(var i=0;i';this.iframe_script+='';}if(!this.iframe_css){this.iframe_css="";}var template=this.template.replace(/\[__BASEURL__\]/g,this.baseURL);template=template.replace("[__TOOLBAR__]",html_toolbar_content);template=this.translate(template,area["settings"]["language"],"template");template=template.replace("[__CSSRULES__]",this.iframe_css);template=template.replace("[__JSCODE__]",this.iframe_script);template=template.replace("[__EA_VERSION__]",this.version);area.textarea=document.getElementById(area["settings"]["id"]);eAs[area["settings"]["id"]]["textarea"]=area.textarea;if(typeof(window.frames["frame_"+area["settings"]["id"]])!='undefined')delete window.frames["frame_"+area["settings"]["id"]];var father=area.textarea.parentNode;var content=document.createElement("iframe");content.name="frame_"+area["settings"]["id"];content.id="frame_"+area["settings"]["id"];content.style.borderWidth="0px";setAttribute(content,"frameBorder","0");content.style.overflow="hidden";content.style.display="none";var next=area.textarea.nextSibling;if(next==null)father.appendChild(content); +else father.insertBefore(content,next);var frame=window.frames["frame_"+area["settings"]["id"]];frame.document.open();frame.eAs=eAs;frame.area_id=area["settings"]["id"];frame.document.area_id=area["settings"]["id"];frame.document.write(template);frame.document.close();},toggle:function(id,toggle_to){if(!toggle_to)toggle_to=(eAs[id]["displayed"]==true)?"off":"on";if(eAs[id]["displayed"]==true &&toggle_to=="off"){this.toggle_off(id);} +else if(eAs[id]["displayed"]==false &&toggle_to=="on"){this.toggle_on(id);}return false;},toggle_off:function(id){if(window.frames["frame_"+id]){var frame=window.frames["frame_"+id];if(frame.editArea.fullscreen['isFull'])frame.editArea.toggle_full_screen(false);eAs[id]["displayed"]=false;eAs[id]["textarea"].wrap="off";setAttribute(eAs[id]["textarea"],"wrap","off");var parNod=eAs[id]["textarea"].parentNode;var nxtSib=eAs[id]["textarea"].nextSibling;parNod.removeChild(eAs[id]["textarea"]);parNod.insertBefore(eAs[id]["textarea"],nxtSib);eAs[id]["textarea"].value=frame.editArea.textarea.value;var selStart=frame.editArea.last_selection["selectionStart"];var selEnd=frame.editArea.last_selection["selectionEnd"];var scrollTop=frame.document.getElementById("result").scrollTop;var scrollLeft=frame.document.getElementById("result").scrollLeft;document.getElementById("frame_"+id).style.display='none';eAs[id]["textarea"].style.display="inline";eAs[id]["textarea"].focus();if(this.nav['isIE']){eAs[id]["textarea"].selectionStart=selStart;eAs[id]["textarea"].selectionEnd=selEnd;eAs[id]["textarea"].focused=true;set_IE_selection(eAs[id]["textarea"]);} +else{if(this.nav['isOpera']){eAs[id]["textarea"].setSelectionRange(0,0);}try{eAs[id]["textarea"].setSelectionRange(selStart,selEnd);}catch(e){};}eAs[id]["textarea"].scrollTop=scrollTop;eAs[id]["textarea"].scrollLeft=scrollLeft;frame.editArea.execCommand("toggle_off");}},toggle_on:function(id){if(window.frames["frame_"+id]){var frame=window.frames["frame_"+id];area=window.frames["frame_"+id].editArea;area.textarea.value=eAs[id]["textarea"].value;var selStart=0;var selEnd=0;var scrollTop=0;var scrollLeft=0;if(eAs[id]["textarea"].use_last==true){var selStart=eAs[id]["textarea"].last_selectionStart;var selEnd=eAs[id]["textarea"].last_selectionEnd;var scrollTop=eAs[id]["textarea"].last_scrollTop;var scrollLeft=eAs[id]["textarea"].last_scrollLeft;eAs[id]["textarea"].use_last=false;} +else{try{var selStart=eAs[id]["textarea"].selectionStart;var selEnd=eAs[id]["textarea"].selectionEnd;var scrollTop=eAs[id]["textarea"].scrollTop;var scrollLeft=eAs[id]["textarea"].scrollLeft;}catch(ex){}}this.set_editarea_size_from_textarea(id,document.getElementById("frame_"+id));eAs[id]["textarea"].style.display="none";document.getElementById("frame_"+id).style.display="inline";area.execCommand("focus");eAs[id]["displayed"]=true;area.execCommand("update_size");window.frames["frame_"+id].document.getElementById("result").scrollTop=scrollTop;window.frames["frame_"+id].document.getElementById("result").scrollLeft=scrollLeft;area.area_select(selStart,selEnd-selStart);area.execCommand("toggle_on");} +else{var elem=document.getElementById(id);elem.last_selectionStart=elem.selectionStart;elem.last_selectionEnd=elem.selectionEnd;elem.last_scrollTop=elem.scrollTop;elem.last_scrollLeft=elem.scrollLeft;elem.use_last=true;eAL.start(id);}},set_editarea_size_from_textarea:function(id,frame){var elem=document.getElementById(id);var width=Math.max(eAs[id]["settings"]["min_width"],elem.offsetWidth)+"px";var height=Math.max(eAs[id]["settings"]["min_height"],elem.offsetHeight)+"px";if(elem.style.width.indexOf("%")!=-1)width=elem.style.width;if(elem.style.height.indexOf("%")!=-1)height=elem.style.height;frame.style.width=width;frame.style.height=height;},set_base_url:function(){if (!this.baseURL){var elements=document.getElementsByTagName('script');for (var i=0;i';html+='';return html;},get_control_html:function(button_name,lang){for (var i=0;i";case "|":case "separator":return '';case "select_font":html="";return html;case "syntax_selection":var html="";return html;}return "["+button_name+"]";},get_template:function(){if(this.template==""){var xhr_object=null;if(window.XMLHttpRequest)xhr_object=new XMLHttpRequest(); +else if(window.ActiveXObject)xhr_object=new ActiveXObject("Microsoft.XMLHTTP"); +else{alert("XMLHTTPRequest not supported. EditArea not loaded");return;}xhr_object.open("GET",this.baseURL+"template.html",false);xhr_object.send(null);if(xhr_object.readyState==4)this.template=xhr_object.responseText; +else this.has_error();}},translate:function(text,lang,mode){if(mode=="word")text=eAL.get_word_translation(text,lang); +else if(mode="template"){eAL.current_language=lang;text=text.replace(/\{\$([^\}]+)\}/gm,eAL.translate_template);}return text;},translate_template:function(){return eAL.get_word_translation(EAL.prototype.translate_template.arguments[1],eAL.current_language);},get_word_translation:function(val,lang){for(var i in eAL.lang[lang]){if(i==val)return eAL.lang[lang][i];}return "_"+val;},load_script:function(url){if (this.loadedFiles[url])return;try{var script=document.createElement("script");script.type="text/javascript";script.src=url;script.charset="UTF-8";var head=document.getElementsByTagName("head");head[0].appendChild(script);}catch(e){document.write('');}this.loadedFiles[url]=true;},add_event:function(obj,name,handler){if (obj.attachEvent){obj.attachEvent("on"+name,handler);} +else{obj.addEventListener(name,handler,false);}},remove_event:function(obj,name,handler){if (obj.detachEvent)obj.detachEvent("on"+name,handler); +else obj.removeEventListener(name,handler,false);},reset:function(e){var formObj=eAL.nav['isIE'] ? window.event.srcElement:e.target;if(formObj.tagName!='FORM')formObj=formObj.form;for(var i in eAs){var is_child=false;for (var x=0;x old_sel["start"])this.setSelectionRange(id,new_sel["end"],new_sel["end"]); +else this.setSelectionRange(id,old_sel["start"]+open_tag.length,old_sel["start"]+open_tag.length);},hide:function(id){if(document.getElementById(id)&&!this.hidden[id]){this.hidden[id]=new Object();this.hidden[id]["selectionRange"]=this.getSelectionRange(id);if(document.getElementById(id).style.display!="none"){this.hidden[id]["scrollTop"]=document.getElementById(id).scrollTop;this.hidden[id]["scrollLeft"]=document.getElementById(id).scrollLeft;}if(window.frames["frame_"+id]){this.hidden[id]["toggle"]=eAs[id]["displayed"];if(window.frames["frame_"+id]&&eAs[id]["displayed"]==true){var scrollTop=window.frames["frame_"+id].document.getElementById("result").scrollTop;var scrollLeft=window.frames["frame_"+id].document.getElementById("result").scrollLeft;} +else{var scrollTop=document.getElementById(id).scrollTop;var scrollLeft=document.getElementById(id).scrollLeft;}this.hidden[id]["scrollTop"]=scrollTop;this.hidden[id]["scrollLeft"]=scrollLeft;if(eAs[id]["displayed"]==true)eAL.toggle_off(id);}var span=document.getElementById("EditAreaArroundInfos_"+id);if(span){span.style.display='none';}document.getElementById(id).style.display="none";}},show:function(id){if((elem=document.getElementById(id))&&this.hidden[id]){elem.style.display="inline";elem.scrollTop=this.hidden[id]["scrollTop"];elem.scrollLeft=this.hidden[id]["scrollLeft"];var span=document.getElementById("EditAreaArroundInfos_"+id);if(span){span.style.display='inline';}if(window.frames["frame_"+id]){elem.style.display="inline";if(this.hidden[id]["toggle"]==true)eAL.toggle_on(id);scrollTop=this.hidden[id]["scrollTop"];scrollLeft=this.hidden[id]["scrollLeft"];if(window.frames["frame_"+id]&&eAs[id]["displayed"]==true){window.frames["frame_"+id].document.getElementById("result").scrollTop=scrollTop;window.frames["frame_"+id].document.getElementById("result").scrollLeft=scrollLeft;} +else{elem.scrollTop=scrollTop;elem.scrollLeft=scrollLeft;}}sel=this.hidden[id]["selectionRange"];this.setSelectionRange(id,sel["start"],sel["end"]);delete this.hidden[id];}},getCurrentFile:function(id){return this.execCommand(id,'get_file',this.execCommand(id,'curr_file'));},getFile:function(id,file_id){return this.execCommand(id,'get_file',file_id);},getAllFiles:function(id){return this.execCommand(id,'get_all_files()');},openFile:function(id,file_infos){return this.execCommand(id,'open_file',file_infos);},closeFile:function(id,file_id){return this.execCommand(id,'close_file',file_id);},setFileEditedMode:function(id,file_id,to){var reg1=new RegExp('\\\\','g');var reg2=new RegExp('"','g');return this.execCommand(id,'set_file_edited_mode("'+file_id.replace(reg1,'\\\\').replace(reg2,'\\"')+'",'+to +')');},execCommand:function(id,cmd,fct_param){switch(cmd){case "EA_init":if(eAs[id]['settings']["EA_init_callback"].length>0)eval(eAs[id]['settings']["EA_init_callback"]+"('"+id +"');");break;case "EA_delete":if(eAs[id]['settings']["EA_delete_callback"].length>0)eval(eAs[id]['settings']["EA_delete_callback"]+"('"+id +"');");break;case "EA_submit":if(eAs[id]['settings']["submit_callback"].length>0)eval(eAs[id]['settings']["submit_callback"]+"('"+id +"');");break;}if(window.frames["frame_"+id]&&window.frames["frame_"+id].editArea){if(fct_param!=undefined)return eval('window.frames["frame_'+id +'"].editArea.'+cmd +'(fct_param);'); +else return eval('window.frames["frame_'+id +'"].editArea.'+cmd +';');}return false;}};var eAL=new EAL();var eAs=new Object(); function getAttribute(elm,aname){try{var avalue=elm.getAttribute(aname );}catch(exept){}if(! avalue){for(var i=0;i < elm.attributes.length;i ++){var taName=elm.attributes [i] .name.toLowerCase();if(taName==aname){avalue=elm.attributes [i] .value;return avalue;}}}return avalue;};function setAttribute(elm,attr,val){if(attr=="class"){elm.setAttribute("className",val);elm.setAttribute("class",val);} +else{elm.setAttribute(attr,val);}};function getChildren(elem,elem_type,elem_attribute,elem_attribute_match,option,depth){if(!option)var option="single";if(!depth)var depth=-1;if(elem){var children=elem.childNodes;var result=null;var results=new Array();for (var x=0;x0){results=results.concat(result);}} +else if(result!=null){return result;}}}}if(option=="all")return results;}return null;};function isChildOf(elem,parent){if(elem){if(elem==parent)return true;while(elem.parentNode !='undefined'){return isChildOf(elem.parentNode,parent);}}return false;};function getMouseX(e){if(e!=null&&typeof(e.pageX)!="undefined"){return e.pageX;} +else{return (e!=null?e.x:event.x)+document.documentElement.scrollLeft;}};function getMouseY(e){if(e!=null&&typeof(e.pageY)!="undefined"){return e.pageY;} +else{return (e!=null?e.y:event.y)+document.documentElement.scrollTop;}};function calculeOffsetLeft(r){return calculeOffset(r,"offsetLeft")};function calculeOffsetTop(r){return calculeOffset(r,"offsetTop")};function calculeOffset(element,attr){var offset=0;while(element){offset+=element[attr];element=element.offsetParent}return offset;};function get_css_property(elem,prop){if(document.defaultView){return document.defaultView.getComputedStyle(elem,null).getPropertyValue(prop);} +else if(elem.currentStyle){var prop=prop.replace(/-\D/gi,function(sMatch){return sMatch.charAt(sMatch.length-1).toUpperCase();});return elem.currentStyle[prop];} +else return null;}var move_current_element;function start_move_element(e,id,frame){var elem_id=(e.target||e.srcElement).id;if(id)elem_id=id;if(!frame)frame=window;if(frame.event)e=frame.event;move_current_element=frame.document.getElementById(elem_id);move_current_element.frame=frame;frame.document.onmousemove=move_element;frame.document.onmouseup=end_move_element;mouse_x=getMouseX(e);mouse_y=getMouseY(e);move_current_element.start_pos_x=mouse_x-(move_current_element.style.left.replace("px","")||calculeOffsetLeft(move_current_element));move_current_element.start_pos_y=mouse_y-(move_current_element.style.top.replace("px","")||calculeOffsetTop(move_current_element));return false;};function end_move_element(e){move_current_element.frame.document.onmousemove="";move_current_element.frame.document.onmouseup="";move_current_element=null;};function move_element(e){if(move_current_element.frame&&move_current_element.frame.event)e=move_current_element.frame.event;var mouse_x=getMouseX(e);var mouse_y=getMouseY(e);var new_top=mouse_y-move_current_element.start_pos_y;var new_left=mouse_x-move_current_element.start_pos_x;var max_left=move_current_element.frame.document.body.offsetWidth-move_current_element.offsetWidth;max_top=move_current_element.frame.document.body.offsetHeight-move_current_element.offsetHeight;new_top=Math.min(Math.max(0,new_top),max_top);new_left=Math.min(Math.max(0,new_left),max_left);move_current_element.style.top=new_top+"px";move_current_element.style.left=new_left+"px";return false;};var nav=eAL.nav;function getSelectionRange(textarea){return {"start":textarea.selectionStart,"end":textarea.selectionEnd};};function setSelectionRange(textarea,start,end){textarea.focus();start=Math.max(0,Math.min(textarea.value.length,start));end=Math.max(start,Math.min(textarea.value.length,end));if(nav['isOpera']){textarea.selectionEnd=1;textarea.selectionStart=0;textarea.selectionEnd=1;textarea.selectionStart=0;}textarea.selectionStart=start;textarea.selectionEnd=end;if(nav['isIE'])set_IE_selection(textarea);};function get_IE_selection(textarea){if(textarea&&textarea.focused){if(!textarea.ea_line_height){var div=document.createElement("div");div.style.fontFamily=get_css_property(textarea,"font-family");div.style.fontSize=get_css_property(textarea,"font-size");div.style.visibility="hidden";div.innerHTML="0";document.body.appendChild(div);textarea.ea_line_height=div.offsetHeight;document.body.removeChild(div);}var range=document.selection.createRange();var stored_range=range.duplicate();stored_range.moveToElementText(textarea );stored_range.setEndPoint('EndToEnd',range );if(stored_range.parentElement()==textarea){var elem=textarea;var scrollTop=0;while(elem.parentNode){scrollTop+=elem.scrollTop;elem=elem.parentNode;}var relative_top=range.offsetTop-calculeOffsetTop(textarea)+scrollTop;var line_start=Math.round((relative_top / textarea.ea_line_height)+1);var line_nb=Math.round(range.boundingHeight / textarea.ea_line_height);var range_start=stored_range.text.length-range.text.length;var tab=textarea.value.substr(0,range_start).split("\n");range_start+=(line_start-tab.length)*2;textarea.selectionStart=range_start;var range_end=textarea.selectionStart+range.text.length;tab=textarea.value.substr(0,range_start+range.text.length).split("\n");range_end+=(line_start+line_nb-1-tab.length)*2;textarea.selectionEnd=range_end;}}setTimeout("get_IE_selection(document.getElementById('"+textarea.id +"'));",50);};function IE_textarea_focus(){event.srcElement.focused=true;}function IE_textarea_blur(){event.srcElement.focused=false;}function set_IE_selection(textarea){if(!window.closed){var nbLineStart=textarea.value.substr(0,textarea.selectionStart).split("\n").length-1;var nbLineEnd=textarea.value.substr(0,textarea.selectionEnd).split("\n").length-1;var range=document.selection.createRange();range.moveToElementText(textarea );range.setEndPoint('EndToStart',range );range.moveStart('character',textarea.selectionStart-nbLineStart);range.moveEnd('character',textarea.selectionEnd-nbLineEnd-(textarea.selectionStart-nbLineStart));range.select();}};eAL.waiting_loading["elements_functions.js"]="loaded"; + EAL.prototype.start_resize_area=function(){document.onmouseup=eAL.end_resize_area;document.onmousemove=eAL.resize_area;eAL.toggle(eAL.resize["id"]);var textarea=eAs[eAL.resize["id"]]["textarea"];var div=document.getElementById("edit_area_resize");if(!div){div=document.createElement("div");div.id="edit_area_resize";div.style.border="dashed #888888 1px";}var width=textarea.offsetWidth -2;var height=textarea.offsetHeight -2;div.style.display="block";div.style.width=width+"px";div.style.height=height+"px";var father=textarea.parentNode;father.insertBefore(div,textarea);textarea.style.display="none";eAL.resize["start_top"]=calculeOffsetTop(div);eAL.resize["start_left"]=calculeOffsetLeft(div);};EAL.prototype.end_resize_area=function(e){document.onmouseup="";document.onmousemove="";var div=document.getElementById("edit_area_resize");var textarea=eAs[eAL.resize["id"]]["textarea"];var width=Math.max(eAs[eAL.resize["id"]]["settings"]["min_width"],div.offsetWidth-4);var height=Math.max(eAs[eAL.resize["id"]]["settings"]["min_height"],div.offsetHeight-4);if(eAL.nav['isIE']==6){width-=2;height-=2;}textarea.style.width=width+"px";textarea.style.height=height+"px";div.style.display="none";textarea.style.display="inline";textarea.selectionStart=eAL.resize["selectionStart"];textarea.selectionEnd=eAL.resize["selectionEnd"];eAL.toggle(eAL.resize["id"]);return false;};EAL.prototype.resize_area=function(e){var allow=eAs[eAL.resize["id"]]["settings"]["allow_resize"];if(allow=="both"||allow=="y"){new_y=getMouseY(e);var new_height=Math.max(20,new_y-eAL.resize["start_top"]);document.getElementById("edit_area_resize").style.height=new_height+"px";}if(allow=="both"||allow=="x"){new_x=getMouseX(e);var new_width=Math.max(20,new_x-eAL.resize["start_left"]);document.getElementById("edit_area_resize").style.width=new_width+"px";}return false;};eAL.waiting_loading["resize_area.js"]="loaded"; + EAL.prototype.get_regexp=function(text_array){res="(\\b)(";for(i=0;i0)res+="|";res+=this.get_escaped_regexp(text_array[i]);}res+=")(\\b)";reg=new RegExp(res);return res;};EAL.prototype.get_escaped_regexp=function(str){return str.replace(/(\.|\?|\*|\+|\\|\(|\)|\[|\]|\}|\{|\$|\^|\|)/g,"\\$1");};EAL.prototype.init_syntax_regexp=function(){var lang_style=new Object();for(var lang in this.load_syntax){if(!this.syntax[lang]){this.syntax[lang]=new Object();this.syntax[lang]["keywords_reg_exp"]=new Object();this.keywords_reg_exp_nb=0;if(this.load_syntax[lang]['KEYWORDS']){param="g";if(this.load_syntax[lang]['KEYWORD_CASE_SENSITIVE']===false)param+="i";for(var i in this.load_syntax[lang]['KEYWORDS']){if(typeof(this.load_syntax[lang]['KEYWORDS'][i])=="function")continue;this.syntax[lang]["keywords_reg_exp"][i]=new RegExp(this.get_regexp(this.load_syntax[lang]['KEYWORDS'][i] ),param);this.keywords_reg_exp_nb++;}}if(this.load_syntax[lang]['OPERATORS']){var str="";var nb=0;for(var i in this.load_syntax[lang]['OPERATORS']){if(typeof(this.load_syntax[lang]['OPERATORS'][i])=="function")continue;if(nb>0)str+="|";str+=this.get_escaped_regexp(this.load_syntax[lang]['OPERATORS'][i]);nb++;}if(str.length>0)this.syntax[lang]["operators_reg_exp"]=new RegExp("("+str+")","g");}if(this.load_syntax[lang]['DELIMITERS']){var str="";var nb=0;for(var i in this.load_syntax[lang]['DELIMITERS']){if(typeof(this.load_syntax[lang]['DELIMITERS'][i])=="function")continue;if(nb>0)str+="|";str+=this.get_escaped_regexp(this.load_syntax[lang]['DELIMITERS'][i]);nb++;}if(str.length>0)this.syntax[lang]["delimiters_reg_exp"]=new RegExp("("+str+")","g");}var syntax_trace=new Array();this.syntax[lang]["quotes"]=new Object();var quote_tab=new Array();if(this.load_syntax[lang]['QUOTEMARKS']){for(var i in this.load_syntax[lang]['QUOTEMARKS']){if(typeof(this.load_syntax[lang]['QUOTEMARKS'][i])=="function")continue;var x=this.get_escaped_regexp(this.load_syntax[lang]['QUOTEMARKS'][i]);this.syntax[lang]["quotes"][x]=x;quote_tab[quote_tab.length]="("+x+"(?:[^"+x+"\\\\]*(\\\\\\\\)*(\\\\"+x+"?)?)*("+x+"|$))";syntax_trace.push(x);}}this.syntax[lang]["comments"]=new Object();if(this.load_syntax[lang]['COMMENT_SINGLE']){for(var i in this.load_syntax[lang]['COMMENT_SINGLE']){if(typeof(this.load_syntax[lang]['COMMENT_SINGLE'][i])=="function")continue;var x=this.get_escaped_regexp(this.load_syntax[lang]['COMMENT_SINGLE'][i]);quote_tab[quote_tab.length]="("+x+"(.|\\r|\\t)*(\\n|$))";syntax_trace.push(x);this.syntax[lang]["comments"][x]="\n";}}if(this.load_syntax[lang]['COMMENT_MULTI']){for(var i in this.load_syntax[lang]['COMMENT_MULTI']){if(typeof(this.load_syntax[lang]['COMMENT_MULTI'][i])=="function")continue;var start=this.get_escaped_regexp(i);var end=this.get_escaped_regexp(this.load_syntax[lang]['COMMENT_MULTI'][i]);quote_tab[quote_tab.length]="("+start+"(.|\\n|\\r)*?("+end+"|$))";syntax_trace.push(start);syntax_trace.push(end);this.syntax[lang]["comments"][i]=this.load_syntax[lang]['COMMENT_MULTI'][i];}}if(quote_tab.length>0)this.syntax[lang]["comment_or_quote_reg_exp"]=new RegExp("("+quote_tab.join("|")+")","gi");if(syntax_trace.length>0)this.syntax[lang]["syntax_trace_regexp"]=new RegExp("((.|\n)*?)(\\\\*("+syntax_trace.join("|")+"|$))","gmi");if(this.load_syntax[lang]['SCRIPT_DELIMITERS']){this.syntax[lang]["script_delimiters"]=new Object();for(var i in this.load_syntax[lang]['SCRIPT_DELIMITERS']){if(typeof(this.load_syntax[lang]['SCRIPT_DELIMITERS'][i])=="function")continue;this.syntax[lang]["script_delimiters"][i]=this.load_syntax[lang]['SCRIPT_DELIMITERS'];}}this.syntax[lang]["custom_regexp"]=new Object();if(this.load_syntax[lang]['REGEXPS']){for(var i in this.load_syntax[lang]['REGEXPS']){if(typeof(this.load_syntax[lang]['REGEXPS'][i])=="function")continue;var val=this.load_syntax[lang]['REGEXPS'][i];if(!this.syntax[lang]["custom_regexp"][val['execute']])this.syntax[lang]["custom_regexp"][val['execute']]=new Object();this.syntax[lang]["custom_regexp"][val['execute']][i]={'regexp':new RegExp(val['search'],val['modifiers']),'class':val['class']};}}if(this.load_syntax[lang]['STYLES']){lang_style[lang]=new Object();for(var i in this.load_syntax[lang]['STYLES']){if(typeof(this.load_syntax[lang]['STYLES'][i])=="function")continue;if(typeof(this.load_syntax[lang]['STYLES'][i])!="string"){for(var j in this.load_syntax[lang]['STYLES'][i]){lang_style[lang][j]=this.load_syntax[lang]['STYLES'][i][j];}} +else{lang_style[lang][i]=this.load_syntax[lang]['STYLES'][i];}}}var style="";for(var i in lang_style[lang]){if(lang_style[lang][i].length>0){style+="."+lang +" ."+i.toLowerCase()+" span{"+lang_style[lang][i]+"}\n";style+="."+lang +" ."+i.toLowerCase()+"{"+lang_style[lang][i]+"}\n";}}this.syntax[lang]["styles"]=style;}}};eAL.waiting_loading["reg_syntax.js"]="loaded"; +var editAreaLoader= eAL;var editAreas=eAs;EditAreaLoader=EAL;editAreaLoader.iframe_script= "".replace(/Á/g,'this').replace(/Â/g,'textarea').replace(/Ã/g,'function').replace(/Ä/g,'prototype').replace(/Å/g,'settings').replace(/Æ/g,'length').replace(/Ç/g,'style').replace(/È/g,'parent').replace(/É/g,'last_selection').replace(/Ê/g,'value').replace(/Ë/g,'true').replace(/Ì/g,'false'); +editAreaLoader.template= " EditArea [__CSSRULES__] [__JSCODE__]
[__TOOLBAR__]
 
 
{$position}: {$line_abbr} 0, {$char_abbr} 0 {$total}: {$line_abbr} 0, {$char_abbr} 0 resize
{$processing}
{$search} {$close_popup}
{$replace} {$move_popup}

{$find_next} {$replace} {$replace_all}
{$close_popup}

Editarea [__EA_VERSION__]


{$shortcuts}:

{$tab}: {$add_tab}
{$shift}+{$tab}: {$remove_tab}
{$ctrl}+f: {$search_command}
{$ctrl}+r: {$replace_command}
{$ctrl}+h: {$highlight}
{$ctrl}+g: {$go_to_line}
{$ctrl}+z: {$undo}
{$ctrl}+y: {$redo}
{$ctrl}+e: {$help}
{$ctrl}+q, {$esc}: {$close_popup}
{$accesskey} E: {$toggle}

{$about_notice}
"; +editAreaLoader.iframe_css= ""; diff --git a/www/extras/editarea/edit_area/edit_area_full_with_plugins.gz b/www/extras/editarea/edit_area/edit_area_full_with_plugins.gz new file mode 100755 index 000000000..7f70156fd Binary files /dev/null and b/www/extras/editarea/edit_area/edit_area_full_with_plugins.gz differ diff --git a/www/extras/editarea/edit_area/edit_area_full_with_plugins.js b/www/extras/editarea/edit_area/edit_area_full_with_plugins.js new file mode 100755 index 000000000..d249a5da3 --- /dev/null +++ b/www/extras/editarea/edit_area/edit_area_full_with_plugins.js @@ -0,0 +1,39 @@ + function EAL(){this.version="0.7.2.2";date=new Date();this.start_time=date.getTime();this.win="loading";this.error=false;this.baseURL="";this.template="";this.lang=new Object();this.load_syntax=new Object();this.syntax=new Object();this.loadedFiles=new Array();this.waiting_loading=new Object();this.scripts_to_load=new Array();this.sub_scripts_to_load=new Array();this.resize=new Array();this.hidden=new Object();this.default_settings={debug:false ,smooth_selection:true ,font_size:"10" ,font_family:"monospace" ,start_highlight:false ,autocompletion:false ,toolbar:"search,go_to_line,fullscreen,|,undo,redo,|,select_font,|,change_smooth_selection,highlight,reset_highlight,|,help" ,begin_toolbar:"" ,end_toolbar:"" ,is_multi_files:false ,allow_resize:"both" ,show_line_colors:false ,min_width:400 ,min_height:125 ,replace_tab_by_spaces:false ,allow_toggle:true ,language:"en" ,syntax:"" ,syntax_selection_allow:"basic,brainfuck,c,coldfusion,cpp,css,html,js,pas,perl,php,python,ruby,robotstxt,sql,tsql,vb,xml" ,display:"onload" ,max_undo:30 ,browsers:"known" ,plugins:"" ,gecko_spellcheck:false ,fullscreen:false ,is_editable:true ,wrap_text:false ,load_callback:"" ,save_callback:"" ,change_callback:"" ,submit_callback:"" ,EA_init_callback:"" ,EA_delete_callback:"" ,EA_load_callback:"" ,EA_unload_callback:"" ,EA_toggle_on_callback:"" ,EA_toggle_off_callback:"" ,EA_file_switch_on_callback:"" ,EA_file_switch_off_callback:"" ,EA_file_close_callback:"" };this.advanced_buttons=[ ['new_document','newdocument.gif','new_document',false],['search','search.gif','show_search',false],['go_to_line','go_to_line.gif','go_to_line',false],['undo','undo.gif','undo',true],['redo','redo.gif','redo',true],['change_smooth_selection','smooth_selection.gif','change_smooth_selection_mode',true],['reset_highlight','reset_highlight.gif','resync_highlight',true],['highlight','highlight.gif','change_highlight',true],['help','help.gif','show_help',false],['save','save.gif','save',false],['load','load.gif','load',false],['fullscreen','fullscreen.gif','toggle_full_screen',false],['autocompletion','autocompletion.gif','toggle_autocompletion',true] ];ua=navigator.userAgent;this.nav=new Object();this.nav['isMacOS']=(ua.indexOf('Mac OS')!=-1);this.nav['isIE']=(navigator.appName=="Microsoft Internet Explorer");if(this.nav['isIE']){this.nav['isIE']=ua.replace(/^.*?MSIE ([0-9\.]*).*$/,"$1");if(this.nav['isIE']<6)this.has_error();}if(this.nav['isNS']=ua.indexOf('Netscape/')!=-1){this.nav['isNS']=ua.substr(ua.indexOf('Netscape/')+9);if(this.nav['isNS']<8||!this.nav['isIE'])this.has_error();}if(this.nav['isOpera']=(ua.indexOf('Opera')!=-1)){this.nav['isOpera']=ua.replace(/^.*?Opera.*?([0-9\.]+).*$/i,"$1");if(this.nav['isOpera']<9)this.has_error();this.nav['isIE']=false;}this.nav['isGecko']=(ua.indexOf('Gecko')!=-1);if(this.nav['isFirefox'] =(ua.indexOf('Firefox')!=-1))this.nav['isFirefox']=ua.replace(/^.*?Firefox.*?([0-9\.]+).*$/i,"$1");if(this.nav['isIceweasel'] =(ua.indexOf('Iceweasel')!=-1))this.nav['isFirefox']=this.nav['isIceweasel']=ua.replace(/^.*?Iceweasel.*?([0-9\.]+).*$/i,"$1");if(this.nav['GranParadiso'] =(ua.indexOf('GranParadiso')!=-1))this.nav['isFirefox']=this.nav['isGranParadiso']=ua.replace(/^.*?GranParadiso.*?([0-9\.]+).*$/i,"$1");if(this.nav['isCamino'] =(ua.indexOf('Camino')!=-1))this.nav['isCamino']=ua.replace(/^.*?Camino.*?([0-9\.]+).*$/i,"$1");if(this.nav['isChrome'] =(ua.indexOf('Chrome')!=-1))this.nav['isChrome']=ua.replace(/^.*?Chrome.*?([0-9\.]+).*$/i,"$1");if(this.nav['isSafari'] =(ua.indexOf('Safari')!=-1))this.nav['isSafari']=ua.replace(/^.*?Version\/([0-9]+\.[0-9]+).*$/i,"$1");if(this.nav['isIE']>=6||this.nav['isOpera']>=9||this.nav['isFirefox']||this.nav['isChrome']||this.nav['isCamino']||this.nav['isSafari']>=3)this.nav['isValidBrowser']=true; +else this.nav['isValidBrowser']=false;this.set_base_url();for(var i=0;i0)settings["toolbar"]=settings["begin_toolbar"] +","+settings["toolbar"];if(settings["end_toolbar"].length>0)settings["toolbar"]=settings["toolbar"] +","+settings["end_toolbar"];settings["tab_toolbar"]=settings["toolbar"].replace(/ /g,"").split(",");settings["plugins"]=settings["plugins"].replace(/ /g,"").split(",");for(var i=0;i0){settings["syntax"]=settings["syntax"].toLowerCase();this.load_script(this.baseURL+"reg_syntax/"+settings["syntax"]+".js");}eAs[settings["id"]]={"settings":settings};eAs[settings["id"]]["displayed"]=false;eAs[settings["id"]]["hidden"]=false;eAL.start(settings["id"]);},delete_instance:function(id){eAL.execCommand(id,"EA_delete");if(window.frames["frame_"+id]&&window.frames["frame_"+id].editArea){if(eAs[id]["displayed"])eAL.toggle(id,"off");window.frames["frame_"+id].editArea.execCommand("EA_unload");}var span=document.getElementById("EditAreaArroundInfos_"+id);if(span)span.parentNode.removeChild(span);var iframe=document.getElementById("frame_"+id);if(iframe){iframe.parentNode.removeChild(iframe);try{delete window.frames["frame_"+id];}catch (e){}}delete eAs[id];},start:function(id){if(this.win!="loaded"){setTimeout("eAL.start('"+id+"');",50);return;}for(var i in eAL.waiting_loading){if(eAL.waiting_loading[i]!="loaded"&&typeof(eAL.waiting_loading[i])!="function"){setTimeout("eAL.start('"+id+"');",50);return;}}if(!eAL.lang[eAs[id]["settings"]["language"]]||(eAs[id]["settings"]["syntax"].length>0&&!eAL.load_syntax[eAs[id]["settings"]["syntax"]])){setTimeout("eAL.start('"+id+"');",50);return;}if(eAs[id]["settings"]["syntax"].length>0)eAL.init_syntax_regexp();if(!document.getElementById("EditAreaArroundInfos_"+id)&&(eAs[id]["settings"]["debug"]||eAs[id]["settings"]["allow_toggle"])){var span=document.createElement("span");span.id="EditAreaArroundInfos_"+id;var html="";if(eAs[id]["settings"]["allow_toggle"]){checked=(eAs[id]["settings"]["display"]=="onload")?"checked":"";html+="
";html+="";html+="
";}if(eAs[id]["settings"]["debug"])html+="
";html=eAL.translate(html,eAs[id]["settings"]["language"]);span.innerHTML=html;var father=document.getElementById(id).parentNode;var next=document.getElementById(id).nextSibling;if(next==null)father.appendChild(span); +else father.insertBefore(span,next);}if(!eAs[id]["initialized"]){this.execCommand(id,"EA_init");if(eAs[id]["settings"]["display"]=="later"){eAs[id]["initialized"]=true;return;}}if(this.nav['isIE']){eAL.init_ie_textarea(id);}var html_toolbar_content="";area=eAs[id];for(var i=0;i';}for(var i=0;i';this.iframe_script+='';}if(!this.iframe_css){this.iframe_css="";}var template=this.template.replace(/\[__BASEURL__\]/g,this.baseURL);template=template.replace("[__TOOLBAR__]",html_toolbar_content);template=this.translate(template,area["settings"]["language"],"template");template=template.replace("[__CSSRULES__]",this.iframe_css);template=template.replace("[__JSCODE__]",this.iframe_script);template=template.replace("[__EA_VERSION__]",this.version);area.textarea=document.getElementById(area["settings"]["id"]);eAs[area["settings"]["id"]]["textarea"]=area.textarea;if(typeof(window.frames["frame_"+area["settings"]["id"]])!='undefined')delete window.frames["frame_"+area["settings"]["id"]];var father=area.textarea.parentNode;var content=document.createElement("iframe");content.name="frame_"+area["settings"]["id"];content.id="frame_"+area["settings"]["id"];content.style.borderWidth="0px";setAttribute(content,"frameBorder","0");content.style.overflow="hidden";content.style.display="none";var next=area.textarea.nextSibling;if(next==null)father.appendChild(content); +else father.insertBefore(content,next);var frame=window.frames["frame_"+area["settings"]["id"]];frame.document.open();frame.eAs=eAs;frame.area_id=area["settings"]["id"];frame.document.area_id=area["settings"]["id"];frame.document.write(template);frame.document.close();},toggle:function(id,toggle_to){if(!toggle_to)toggle_to=(eAs[id]["displayed"]==true)?"off":"on";if(eAs[id]["displayed"]==true &&toggle_to=="off"){this.toggle_off(id);} +else if(eAs[id]["displayed"]==false &&toggle_to=="on"){this.toggle_on(id);}return false;},toggle_off:function(id){if(window.frames["frame_"+id]){var frame=window.frames["frame_"+id];if(frame.editArea.fullscreen['isFull'])frame.editArea.toggle_full_screen(false);eAs[id]["displayed"]=false;eAs[id]["textarea"].wrap="off";setAttribute(eAs[id]["textarea"],"wrap","off");var parNod=eAs[id]["textarea"].parentNode;var nxtSib=eAs[id]["textarea"].nextSibling;parNod.removeChild(eAs[id]["textarea"]);parNod.insertBefore(eAs[id]["textarea"],nxtSib);eAs[id]["textarea"].value=frame.editArea.textarea.value;var selStart=frame.editArea.last_selection["selectionStart"];var selEnd=frame.editArea.last_selection["selectionEnd"];var scrollTop=frame.document.getElementById("result").scrollTop;var scrollLeft=frame.document.getElementById("result").scrollLeft;document.getElementById("frame_"+id).style.display='none';eAs[id]["textarea"].style.display="inline";eAs[id]["textarea"].focus();if(this.nav['isIE']){eAs[id]["textarea"].selectionStart=selStart;eAs[id]["textarea"].selectionEnd=selEnd;eAs[id]["textarea"].focused=true;set_IE_selection(eAs[id]["textarea"]);} +else{if(this.nav['isOpera']){eAs[id]["textarea"].setSelectionRange(0,0);}try{eAs[id]["textarea"].setSelectionRange(selStart,selEnd);}catch(e){};}eAs[id]["textarea"].scrollTop=scrollTop;eAs[id]["textarea"].scrollLeft=scrollLeft;frame.editArea.execCommand("toggle_off");}},toggle_on:function(id){if(window.frames["frame_"+id]){var frame=window.frames["frame_"+id];area=window.frames["frame_"+id].editArea;area.textarea.value=eAs[id]["textarea"].value;var selStart=0;var selEnd=0;var scrollTop=0;var scrollLeft=0;if(eAs[id]["textarea"].use_last==true){var selStart=eAs[id]["textarea"].last_selectionStart;var selEnd=eAs[id]["textarea"].last_selectionEnd;var scrollTop=eAs[id]["textarea"].last_scrollTop;var scrollLeft=eAs[id]["textarea"].last_scrollLeft;eAs[id]["textarea"].use_last=false;} +else{try{var selStart=eAs[id]["textarea"].selectionStart;var selEnd=eAs[id]["textarea"].selectionEnd;var scrollTop=eAs[id]["textarea"].scrollTop;var scrollLeft=eAs[id]["textarea"].scrollLeft;}catch(ex){}}this.set_editarea_size_from_textarea(id,document.getElementById("frame_"+id));eAs[id]["textarea"].style.display="none";document.getElementById("frame_"+id).style.display="inline";area.execCommand("focus");eAs[id]["displayed"]=true;area.execCommand("update_size");window.frames["frame_"+id].document.getElementById("result").scrollTop=scrollTop;window.frames["frame_"+id].document.getElementById("result").scrollLeft=scrollLeft;area.area_select(selStart,selEnd-selStart);area.execCommand("toggle_on");} +else{var elem=document.getElementById(id);elem.last_selectionStart=elem.selectionStart;elem.last_selectionEnd=elem.selectionEnd;elem.last_scrollTop=elem.scrollTop;elem.last_scrollLeft=elem.scrollLeft;elem.use_last=true;eAL.start(id);}},set_editarea_size_from_textarea:function(id,frame){var elem=document.getElementById(id);var width=Math.max(eAs[id]["settings"]["min_width"],elem.offsetWidth)+"px";var height=Math.max(eAs[id]["settings"]["min_height"],elem.offsetHeight)+"px";if(elem.style.width.indexOf("%")!=-1)width=elem.style.width;if(elem.style.height.indexOf("%")!=-1)height=elem.style.height;frame.style.width=width;frame.style.height=height;},set_base_url:function(){if (!this.baseURL){var elements=document.getElementsByTagName('script');for (var i=0;i';html+='';return html;},get_control_html:function(button_name,lang){for (var i=0;i";case "|":case "separator":return '';case "select_font":html="";return html;case "syntax_selection":var html="";return html;}return "["+button_name+"]";},get_template:function(){if(this.template==""){var xhr_object=null;if(window.XMLHttpRequest)xhr_object=new XMLHttpRequest(); +else if(window.ActiveXObject)xhr_object=new ActiveXObject("Microsoft.XMLHTTP"); +else{alert("XMLHTTPRequest not supported. EditArea not loaded");return;}xhr_object.open("GET",this.baseURL+"template.html",false);xhr_object.send(null);if(xhr_object.readyState==4)this.template=xhr_object.responseText; +else this.has_error();}},translate:function(text,lang,mode){if(mode=="word")text=eAL.get_word_translation(text,lang); +else if(mode="template"){eAL.current_language=lang;text=text.replace(/\{\$([^\}]+)\}/gm,eAL.translate_template);}return text;},translate_template:function(){return eAL.get_word_translation(EAL.prototype.translate_template.arguments[1],eAL.current_language);},get_word_translation:function(val,lang){for(var i in eAL.lang[lang]){if(i==val)return eAL.lang[lang][i];}return "_"+val;},load_script:function(url){if (this.loadedFiles[url])return;try{var script=document.createElement("script");script.type="text/javascript";script.src=url;script.charset="UTF-8";var head=document.getElementsByTagName("head");head[0].appendChild(script);}catch(e){document.write('');}this.loadedFiles[url]=true;},add_event:function(obj,name,handler){if (obj.attachEvent){obj.attachEvent("on"+name,handler);} +else{obj.addEventListener(name,handler,false);}},remove_event:function(obj,name,handler){if (obj.detachEvent)obj.detachEvent("on"+name,handler); +else obj.removeEventListener(name,handler,false);},reset:function(e){var formObj=eAL.nav['isIE'] ? window.event.srcElement:e.target;if(formObj.tagName!='FORM')formObj=formObj.form;for(var i in eAs){var is_child=false;for (var x=0;x old_sel["start"])this.setSelectionRange(id,new_sel["end"],new_sel["end"]); +else this.setSelectionRange(id,old_sel["start"]+open_tag.length,old_sel["start"]+open_tag.length);},hide:function(id){if(document.getElementById(id)&&!this.hidden[id]){this.hidden[id]=new Object();this.hidden[id]["selectionRange"]=this.getSelectionRange(id);if(document.getElementById(id).style.display!="none"){this.hidden[id]["scrollTop"]=document.getElementById(id).scrollTop;this.hidden[id]["scrollLeft"]=document.getElementById(id).scrollLeft;}if(window.frames["frame_"+id]){this.hidden[id]["toggle"]=eAs[id]["displayed"];if(window.frames["frame_"+id]&&eAs[id]["displayed"]==true){var scrollTop=window.frames["frame_"+id].document.getElementById("result").scrollTop;var scrollLeft=window.frames["frame_"+id].document.getElementById("result").scrollLeft;} +else{var scrollTop=document.getElementById(id).scrollTop;var scrollLeft=document.getElementById(id).scrollLeft;}this.hidden[id]["scrollTop"]=scrollTop;this.hidden[id]["scrollLeft"]=scrollLeft;if(eAs[id]["displayed"]==true)eAL.toggle_off(id);}var span=document.getElementById("EditAreaArroundInfos_"+id);if(span){span.style.display='none';}document.getElementById(id).style.display="none";}},show:function(id){if((elem=document.getElementById(id))&&this.hidden[id]){elem.style.display="inline";elem.scrollTop=this.hidden[id]["scrollTop"];elem.scrollLeft=this.hidden[id]["scrollLeft"];var span=document.getElementById("EditAreaArroundInfos_"+id);if(span){span.style.display='inline';}if(window.frames["frame_"+id]){elem.style.display="inline";if(this.hidden[id]["toggle"]==true)eAL.toggle_on(id);scrollTop=this.hidden[id]["scrollTop"];scrollLeft=this.hidden[id]["scrollLeft"];if(window.frames["frame_"+id]&&eAs[id]["displayed"]==true){window.frames["frame_"+id].document.getElementById("result").scrollTop=scrollTop;window.frames["frame_"+id].document.getElementById("result").scrollLeft=scrollLeft;} +else{elem.scrollTop=scrollTop;elem.scrollLeft=scrollLeft;}}sel=this.hidden[id]["selectionRange"];this.setSelectionRange(id,sel["start"],sel["end"]);delete this.hidden[id];}},getCurrentFile:function(id){return this.execCommand(id,'get_file',this.execCommand(id,'curr_file'));},getFile:function(id,file_id){return this.execCommand(id,'get_file',file_id);},getAllFiles:function(id){return this.execCommand(id,'get_all_files()');},openFile:function(id,file_infos){return this.execCommand(id,'open_file',file_infos);},closeFile:function(id,file_id){return this.execCommand(id,'close_file',file_id);},setFileEditedMode:function(id,file_id,to){var reg1=new RegExp('\\\\','g');var reg2=new RegExp('"','g');return this.execCommand(id,'set_file_edited_mode("'+file_id.replace(reg1,'\\\\').replace(reg2,'\\"')+'",'+to +')');},execCommand:function(id,cmd,fct_param){switch(cmd){case "EA_init":if(eAs[id]['settings']["EA_init_callback"].length>0)eval(eAs[id]['settings']["EA_init_callback"]+"('"+id +"');");break;case "EA_delete":if(eAs[id]['settings']["EA_delete_callback"].length>0)eval(eAs[id]['settings']["EA_delete_callback"]+"('"+id +"');");break;case "EA_submit":if(eAs[id]['settings']["submit_callback"].length>0)eval(eAs[id]['settings']["submit_callback"]+"('"+id +"');");break;}if(window.frames["frame_"+id]&&window.frames["frame_"+id].editArea){if(fct_param!=undefined)return eval('window.frames["frame_'+id +'"].editArea.'+cmd +'(fct_param);'); +else return eval('window.frames["frame_'+id +'"].editArea.'+cmd +';');}return false;}};var eAL=new EAL();var eAs=new Object(); function getAttribute(elm,aname){try{var avalue=elm.getAttribute(aname );}catch(exept){}if(! avalue){for(var i=0;i < elm.attributes.length;i ++){var taName=elm.attributes [i] .name.toLowerCase();if(taName==aname){avalue=elm.attributes [i] .value;return avalue;}}}return avalue;};function setAttribute(elm,attr,val){if(attr=="class"){elm.setAttribute("className",val);elm.setAttribute("class",val);} +else{elm.setAttribute(attr,val);}};function getChildren(elem,elem_type,elem_attribute,elem_attribute_match,option,depth){if(!option)var option="single";if(!depth)var depth=-1;if(elem){var children=elem.childNodes;var result=null;var results=new Array();for (var x=0;x0){results=results.concat(result);}} +else if(result!=null){return result;}}}}if(option=="all")return results;}return null;};function isChildOf(elem,parent){if(elem){if(elem==parent)return true;while(elem.parentNode !='undefined'){return isChildOf(elem.parentNode,parent);}}return false;};function getMouseX(e){if(e!=null&&typeof(e.pageX)!="undefined"){return e.pageX;} +else{return (e!=null?e.x:event.x)+document.documentElement.scrollLeft;}};function getMouseY(e){if(e!=null&&typeof(e.pageY)!="undefined"){return e.pageY;} +else{return (e!=null?e.y:event.y)+document.documentElement.scrollTop;}};function calculeOffsetLeft(r){return calculeOffset(r,"offsetLeft")};function calculeOffsetTop(r){return calculeOffset(r,"offsetTop")};function calculeOffset(element,attr){var offset=0;while(element){offset+=element[attr];element=element.offsetParent}return offset;};function get_css_property(elem,prop){if(document.defaultView){return document.defaultView.getComputedStyle(elem,null).getPropertyValue(prop);} +else if(elem.currentStyle){var prop=prop.replace(/-\D/gi,function(sMatch){return sMatch.charAt(sMatch.length-1).toUpperCase();});return elem.currentStyle[prop];} +else return null;}var move_current_element;function start_move_element(e,id,frame){var elem_id=(e.target||e.srcElement).id;if(id)elem_id=id;if(!frame)frame=window;if(frame.event)e=frame.event;move_current_element=frame.document.getElementById(elem_id);move_current_element.frame=frame;frame.document.onmousemove=move_element;frame.document.onmouseup=end_move_element;mouse_x=getMouseX(e);mouse_y=getMouseY(e);move_current_element.start_pos_x=mouse_x-(move_current_element.style.left.replace("px","")||calculeOffsetLeft(move_current_element));move_current_element.start_pos_y=mouse_y-(move_current_element.style.top.replace("px","")||calculeOffsetTop(move_current_element));return false;};function end_move_element(e){move_current_element.frame.document.onmousemove="";move_current_element.frame.document.onmouseup="";move_current_element=null;};function move_element(e){if(move_current_element.frame&&move_current_element.frame.event)e=move_current_element.frame.event;var mouse_x=getMouseX(e);var mouse_y=getMouseY(e);var new_top=mouse_y-move_current_element.start_pos_y;var new_left=mouse_x-move_current_element.start_pos_x;var max_left=move_current_element.frame.document.body.offsetWidth-move_current_element.offsetWidth;max_top=move_current_element.frame.document.body.offsetHeight-move_current_element.offsetHeight;new_top=Math.min(Math.max(0,new_top),max_top);new_left=Math.min(Math.max(0,new_left),max_left);move_current_element.style.top=new_top+"px";move_current_element.style.left=new_left+"px";return false;};var nav=eAL.nav;function getSelectionRange(textarea){return {"start":textarea.selectionStart,"end":textarea.selectionEnd};};function setSelectionRange(textarea,start,end){textarea.focus();start=Math.max(0,Math.min(textarea.value.length,start));end=Math.max(start,Math.min(textarea.value.length,end));if(nav['isOpera']){textarea.selectionEnd=1;textarea.selectionStart=0;textarea.selectionEnd=1;textarea.selectionStart=0;}textarea.selectionStart=start;textarea.selectionEnd=end;if(nav['isIE'])set_IE_selection(textarea);};function get_IE_selection(textarea){if(textarea&&textarea.focused){if(!textarea.ea_line_height){var div=document.createElement("div");div.style.fontFamily=get_css_property(textarea,"font-family");div.style.fontSize=get_css_property(textarea,"font-size");div.style.visibility="hidden";div.innerHTML="0";document.body.appendChild(div);textarea.ea_line_height=div.offsetHeight;document.body.removeChild(div);}var range=document.selection.createRange();var stored_range=range.duplicate();stored_range.moveToElementText(textarea );stored_range.setEndPoint('EndToEnd',range );if(stored_range.parentElement()==textarea){var elem=textarea;var scrollTop=0;while(elem.parentNode){scrollTop+=elem.scrollTop;elem=elem.parentNode;}var relative_top=range.offsetTop-calculeOffsetTop(textarea)+scrollTop;var line_start=Math.round((relative_top / textarea.ea_line_height)+1);var line_nb=Math.round(range.boundingHeight / textarea.ea_line_height);var range_start=stored_range.text.length-range.text.length;var tab=textarea.value.substr(0,range_start).split("\n");range_start+=(line_start-tab.length)*2;textarea.selectionStart=range_start;var range_end=textarea.selectionStart+range.text.length;tab=textarea.value.substr(0,range_start+range.text.length).split("\n");range_end+=(line_start+line_nb-1-tab.length)*2;textarea.selectionEnd=range_end;}}setTimeout("get_IE_selection(document.getElementById('"+textarea.id +"'));",50);};function IE_textarea_focus(){event.srcElement.focused=true;}function IE_textarea_blur(){event.srcElement.focused=false;}function set_IE_selection(textarea){if(!window.closed){var nbLineStart=textarea.value.substr(0,textarea.selectionStart).split("\n").length-1;var nbLineEnd=textarea.value.substr(0,textarea.selectionEnd).split("\n").length-1;var range=document.selection.createRange();range.moveToElementText(textarea );range.setEndPoint('EndToStart',range );range.moveStart('character',textarea.selectionStart-nbLineStart);range.moveEnd('character',textarea.selectionEnd-nbLineEnd-(textarea.selectionStart-nbLineStart));range.select();}};eAL.waiting_loading["elements_functions.js"]="loaded"; + EAL.prototype.start_resize_area=function(){document.onmouseup=eAL.end_resize_area;document.onmousemove=eAL.resize_area;eAL.toggle(eAL.resize["id"]);var textarea=eAs[eAL.resize["id"]]["textarea"];var div=document.getElementById("edit_area_resize");if(!div){div=document.createElement("div");div.id="edit_area_resize";div.style.border="dashed #888888 1px";}var width=textarea.offsetWidth -2;var height=textarea.offsetHeight -2;div.style.display="block";div.style.width=width+"px";div.style.height=height+"px";var father=textarea.parentNode;father.insertBefore(div,textarea);textarea.style.display="none";eAL.resize["start_top"]=calculeOffsetTop(div);eAL.resize["start_left"]=calculeOffsetLeft(div);};EAL.prototype.end_resize_area=function(e){document.onmouseup="";document.onmousemove="";var div=document.getElementById("edit_area_resize");var textarea=eAs[eAL.resize["id"]]["textarea"];var width=Math.max(eAs[eAL.resize["id"]]["settings"]["min_width"],div.offsetWidth-4);var height=Math.max(eAs[eAL.resize["id"]]["settings"]["min_height"],div.offsetHeight-4);if(eAL.nav['isIE']==6){width-=2;height-=2;}textarea.style.width=width+"px";textarea.style.height=height+"px";div.style.display="none";textarea.style.display="inline";textarea.selectionStart=eAL.resize["selectionStart"];textarea.selectionEnd=eAL.resize["selectionEnd"];eAL.toggle(eAL.resize["id"]);return false;};EAL.prototype.resize_area=function(e){var allow=eAs[eAL.resize["id"]]["settings"]["allow_resize"];if(allow=="both"||allow=="y"){new_y=getMouseY(e);var new_height=Math.max(20,new_y-eAL.resize["start_top"]);document.getElementById("edit_area_resize").style.height=new_height+"px";}if(allow=="both"||allow=="x"){new_x=getMouseX(e);var new_width=Math.max(20,new_x-eAL.resize["start_left"]);document.getElementById("edit_area_resize").style.width=new_width+"px";}return false;};eAL.waiting_loading["resize_area.js"]="loaded"; + EAL.prototype.get_regexp=function(text_array){res="(\\b)(";for(i=0;i0)res+="|";res+=this.get_escaped_regexp(text_array[i]);}res+=")(\\b)";reg=new RegExp(res);return res;};EAL.prototype.get_escaped_regexp=function(str){return str.replace(/(\.|\?|\*|\+|\\|\(|\)|\[|\]|\}|\{|\$|\^|\|)/g,"\\$1");};EAL.prototype.init_syntax_regexp=function(){var lang_style=new Object();for(var lang in this.load_syntax){if(!this.syntax[lang]){this.syntax[lang]=new Object();this.syntax[lang]["keywords_reg_exp"]=new Object();this.keywords_reg_exp_nb=0;if(this.load_syntax[lang]['KEYWORDS']){param="g";if(this.load_syntax[lang]['KEYWORD_CASE_SENSITIVE']===false)param+="i";for(var i in this.load_syntax[lang]['KEYWORDS']){if(typeof(this.load_syntax[lang]['KEYWORDS'][i])=="function")continue;this.syntax[lang]["keywords_reg_exp"][i]=new RegExp(this.get_regexp(this.load_syntax[lang]['KEYWORDS'][i] ),param);this.keywords_reg_exp_nb++;}}if(this.load_syntax[lang]['OPERATORS']){var str="";var nb=0;for(var i in this.load_syntax[lang]['OPERATORS']){if(typeof(this.load_syntax[lang]['OPERATORS'][i])=="function")continue;if(nb>0)str+="|";str+=this.get_escaped_regexp(this.load_syntax[lang]['OPERATORS'][i]);nb++;}if(str.length>0)this.syntax[lang]["operators_reg_exp"]=new RegExp("("+str+")","g");}if(this.load_syntax[lang]['DELIMITERS']){var str="";var nb=0;for(var i in this.load_syntax[lang]['DELIMITERS']){if(typeof(this.load_syntax[lang]['DELIMITERS'][i])=="function")continue;if(nb>0)str+="|";str+=this.get_escaped_regexp(this.load_syntax[lang]['DELIMITERS'][i]);nb++;}if(str.length>0)this.syntax[lang]["delimiters_reg_exp"]=new RegExp("("+str+")","g");}var syntax_trace=new Array();this.syntax[lang]["quotes"]=new Object();var quote_tab=new Array();if(this.load_syntax[lang]['QUOTEMARKS']){for(var i in this.load_syntax[lang]['QUOTEMARKS']){if(typeof(this.load_syntax[lang]['QUOTEMARKS'][i])=="function")continue;var x=this.get_escaped_regexp(this.load_syntax[lang]['QUOTEMARKS'][i]);this.syntax[lang]["quotes"][x]=x;quote_tab[quote_tab.length]="("+x+"(?:[^"+x+"\\\\]*(\\\\\\\\)*(\\\\"+x+"?)?)*("+x+"|$))";syntax_trace.push(x);}}this.syntax[lang]["comments"]=new Object();if(this.load_syntax[lang]['COMMENT_SINGLE']){for(var i in this.load_syntax[lang]['COMMENT_SINGLE']){if(typeof(this.load_syntax[lang]['COMMENT_SINGLE'][i])=="function")continue;var x=this.get_escaped_regexp(this.load_syntax[lang]['COMMENT_SINGLE'][i]);quote_tab[quote_tab.length]="("+x+"(.|\\r|\\t)*(\\n|$))";syntax_trace.push(x);this.syntax[lang]["comments"][x]="\n";}}if(this.load_syntax[lang]['COMMENT_MULTI']){for(var i in this.load_syntax[lang]['COMMENT_MULTI']){if(typeof(this.load_syntax[lang]['COMMENT_MULTI'][i])=="function")continue;var start=this.get_escaped_regexp(i);var end=this.get_escaped_regexp(this.load_syntax[lang]['COMMENT_MULTI'][i]);quote_tab[quote_tab.length]="("+start+"(.|\\n|\\r)*?("+end+"|$))";syntax_trace.push(start);syntax_trace.push(end);this.syntax[lang]["comments"][i]=this.load_syntax[lang]['COMMENT_MULTI'][i];}}if(quote_tab.length>0)this.syntax[lang]["comment_or_quote_reg_exp"]=new RegExp("("+quote_tab.join("|")+")","gi");if(syntax_trace.length>0)this.syntax[lang]["syntax_trace_regexp"]=new RegExp("((.|\n)*?)(\\\\*("+syntax_trace.join("|")+"|$))","gmi");if(this.load_syntax[lang]['SCRIPT_DELIMITERS']){this.syntax[lang]["script_delimiters"]=new Object();for(var i in this.load_syntax[lang]['SCRIPT_DELIMITERS']){if(typeof(this.load_syntax[lang]['SCRIPT_DELIMITERS'][i])=="function")continue;this.syntax[lang]["script_delimiters"][i]=this.load_syntax[lang]['SCRIPT_DELIMITERS'];}}this.syntax[lang]["custom_regexp"]=new Object();if(this.load_syntax[lang]['REGEXPS']){for(var i in this.load_syntax[lang]['REGEXPS']){if(typeof(this.load_syntax[lang]['REGEXPS'][i])=="function")continue;var val=this.load_syntax[lang]['REGEXPS'][i];if(!this.syntax[lang]["custom_regexp"][val['execute']])this.syntax[lang]["custom_regexp"][val['execute']]=new Object();this.syntax[lang]["custom_regexp"][val['execute']][i]={'regexp':new RegExp(val['search'],val['modifiers']),'class':val['class']};}}if(this.load_syntax[lang]['STYLES']){lang_style[lang]=new Object();for(var i in this.load_syntax[lang]['STYLES']){if(typeof(this.load_syntax[lang]['STYLES'][i])=="function")continue;if(typeof(this.load_syntax[lang]['STYLES'][i])!="string"){for(var j in this.load_syntax[lang]['STYLES'][i]){lang_style[lang][j]=this.load_syntax[lang]['STYLES'][i][j];}} +else{lang_style[lang][i]=this.load_syntax[lang]['STYLES'][i];}}}var style="";for(var i in lang_style[lang]){if(lang_style[lang][i].length>0){style+="."+lang +" ."+i.toLowerCase()+" span{"+lang_style[lang][i]+"}\n";style+="."+lang +" ."+i.toLowerCase()+"{"+lang_style[lang][i]+"}\n";}}this.syntax[lang]["styles"]=style;}}};eAL.waiting_loading["reg_syntax.js"]="loaded"; +var editAreaLoader= eAL;var editAreas=eAs;EditAreaLoader=EAL;editAreaLoader.iframe_script= "".replace(/Á/g,'this').replace(/Â/g,'textarea').replace(/Ã/g,'function').replace(/Ä/g,'prototype').replace(/Å/g,'settings').replace(/Æ/g,'length').replace(/Ç/g,'style').replace(/È/g,'parent').replace(/É/g,'last_selection').replace(/Ê/g,'value').replace(/Ë/g,'true').replace(/Ì/g,'false'); +editAreaLoader.all_plugins_loaded=true; +editAreaLoader.template= " EditArea [__CSSRULES__] [__JSCODE__]
[__TOOLBAR__]
 
 
{$position}: {$line_abbr} 0, {$char_abbr} 0 {$total}: {$line_abbr} 0, {$char_abbr} 0 resize
{$processing}
{$search} {$close_popup}
{$replace} {$move_popup}

{$find_next} {$replace} {$replace_all}
{$close_popup}

Editarea [__EA_VERSION__]


{$shortcuts}:

{$tab}: {$add_tab}
{$shift}+{$tab}: {$remove_tab}
{$ctrl}+f: {$search_command}
{$ctrl}+r: {$replace_command}
{$ctrl}+h: {$highlight}
{$ctrl}+g: {$go_to_line}
{$ctrl}+z: {$undo}
{$ctrl}+y: {$redo}
{$ctrl}+e: {$help}
{$ctrl}+q, {$esc}: {$close_popup}
{$accesskey} E: {$toggle}

{$about_notice}
"; +editAreaLoader.iframe_css= ""; diff --git a/www/extras/editarea/edit_area/edit_area_functions.js b/www/extras/editarea/edit_area/edit_area_functions.js new file mode 100755 index 000000000..3b40f9049 --- /dev/null +++ b/www/extras/editarea/edit_area/edit_area_functions.js @@ -0,0 +1,1098 @@ + //replace tabulation by the good number of white spaces + EditArea.prototype.replace_tab= function(text){ + return text.replace(/((\n?)([^\t\n]*)\t)/gi, editArea.smartTab); // slower than simple replace... + }; + + // call by the replace_tab function + EditArea.prototype.smartTab= function(){ + val=" "; + return EditArea.prototype.smartTab.arguments[2] + EditArea.prototype.smartTab.arguments[3] + val.substr(0, editArea.tab_nb_char - (EditArea.prototype.smartTab.arguments[3].length)%editArea.tab_nb_char); + }; + + EditArea.prototype.show_waiting_screen= function(){ + width= this.editor_area.offsetWidth; + height= this.editor_area.offsetHeight; + if(this.nav['isGecko'] || this.nav['isOpera'] || this.nav['isIE']>=7){ + width-=2; + height-=2; + } + this.processing_screen.style.display="block"; + this.processing_screen.style.width= width+"px"; + this.processing_screen.style.height= height+"px"; + this.waiting_screen_displayed= true; + }; + + EditArea.prototype.hide_waiting_screen= function(){ + this.processing_screen.style.display="none"; + this.waiting_screen_displayed= false; + }; + + EditArea.prototype.add_style= function(styles){ + if(styles.length>0){ + newcss = document.createElement("style"); + newcss.type="text/css"; + newcss.media="all"; + document.getElementsByTagName("head")[0].appendChild(newcss); + cssrules = styles.split("}"); + newcss = document.styleSheets[0]; + if(newcss.rules) { //IE + for(i=cssrules.length-2;i>=0;i--) { + newrule = cssrules[i].split("{"); + newcss.addRule(newrule[0],newrule[1]) + } + } + else if(newcss.cssRules) { //Firefox etc + for(i=cssrules.length-1;i>=0;i--) { + if(cssrules[i].indexOf("{")!=-1){ + newcss.insertRule(cssrules[i]+"}",0); + } + } + } + } + }; + + EditArea.prototype.set_font= function(family, size){ + var elems= new Array("textarea", "content_highlight", "cursor_pos", "end_bracket", "selection_field", "line_number"); + if(family && family!="") + this.settings["font_family"]= family; + if(size && size>0) + this.settings["font_size"]=size; + if(this.nav['isOpera']) // opera can't manage non monospace font + this.settings['font_family']="monospace"; + var elem_font=$("area_font_size"); + if(elem_font){ + for(var i=0; i0) + this.set_font("", size); + }; + + + EditArea.prototype.open_inline_popup= function(popup_id){ + this.close_all_inline_popup(); + var popup= $(popup_id); + var editor= $("editor"); + + // search matching icon + for(var i=0; i lines.length) + start= this.textarea.value.length; + else{ + for(var i=0; i0){ + //alert(miss_top); + zone.scrollTop= zone.scrollTop + miss_top; + }else if( zone.scrollTop > cursor_pos_top){ + // when erase all the content -> does'nt scroll back to the top + //alert("else: "+cursor_pos_top); + zone.scrollTop= cursor_pos_top; + } + //var cursor_pos_left= parseInt($("cursor_pos").style.left.replace("px","")); + var cursor_pos_left= $("cursor_pos").cursor_left; + var max_width_visible= zone.clientWidth + zone.scrollLeft; + var miss_left= cursor_pos_left + 10 - max_width_visible; + if(miss_left>0){ + zone.scrollLeft= zone.scrollLeft + miss_left + 50; + }else if( zone.scrollLeft > cursor_pos_left){ + zone.scrollLeft= cursor_pos_left ; + }else if( zone.scrollLeft == 45){ + // show the line numbers if textarea align to it's left + zone.scrollLeft=0; + } + }; + + EditArea.prototype.check_undo= function(only_once){ + if(!editAreas[this.id]) + return false; + if(this.textareaFocused && editAreas[this.id]["displayed"]==true){ + var text=this.textarea.value; + if(this.previous.length<=1) + this.switchClassSticky($("undo"), 'editAreaButtonDisabled', true); + + if(!this.previous[this.previous.length-1] || this.previous[this.previous.length-1]["text"] != text){ + this.previous.push({"text": text, "selStart": this.textarea.selectionStart, "selEnd": this.textarea.selectionEnd}); + if(this.previous.length > this.settings["max_undo"]+1) + this.previous.shift(); + + } + if(this.previous.length >= 2) + this.switchClassSticky($("undo"), 'editAreaButtonNormal', false); + } + + if(!only_once) + setTimeout("editArea.check_undo()", 3000); + }; + + EditArea.prototype.undo= function(){ + //alert("undo"+this.previous.length); + if(this.previous.length > 0){ + if(this.nav['isIE']) + this.getIESelection(); + // var pos_cursor=this.textarea.selectionStart; + this.next.push({"text": this.textarea.value, "selStart": this.textarea.selectionStart, "selEnd": this.textarea.selectionEnd}); + var prev= this.previous.pop(); + if(prev["text"]==this.textarea.value && this.previous.length > 0) + prev=this.previous.pop(); + this.textarea.value= prev["text"]; + this.last_undo= prev["text"]; + this.area_select(prev["selStart"], prev["selEnd"]-prev["selStart"]); + this.switchClassSticky($("redo"), 'editAreaButtonNormal', false); + this.resync_highlight(true); + //alert("undo"+this.previous.length); + this.check_file_changes(); + } + }; + + EditArea.prototype.redo= function(){ + if(this.next.length > 0){ + /*if(this.nav['isIE']) + this.getIESelection();*/ + //var pos_cursor=this.textarea.selectionStart; + var next= this.next.pop(); + this.previous.push(next); + this.textarea.value= next["text"]; + this.last_undo= next["text"]; + this.area_select(next["selStart"], next["selEnd"]-next["selStart"]); + this.switchClassSticky($("undo"), 'editAreaButtonNormal', false); + this.resync_highlight(true); + this.check_file_changes(); + } + if( this.next.length == 0) + this.switchClassSticky($("redo"), 'editAreaButtonDisabled', true); + }; + + EditArea.prototype.check_redo= function(){ + if(editArea.next.length == 0 || editArea.textarea.value!=editArea.last_undo){ + editArea.next= new Array(); // undo the ability to use "redo" button + editArea.switchClassSticky($("redo"), 'editAreaButtonDisabled', true); + } + else + { + this.switchClassSticky($("redo"), 'editAreaButtonNormal', false); + } + }; + + + // functions that manage icons roll over, disabled, etc... + EditArea.prototype.switchClass = function(element, class_name, lock_state) { + var lockChanged = false; + + if (typeof(lock_state) != "undefined" && element != null) { + element.classLock = lock_state; + lockChanged = true; + } + + if (element != null && (lockChanged || !element.classLock)) { + element.oldClassName = element.className; + element.className = class_name; + } + }; + + EditArea.prototype.restoreAndSwitchClass = function(element, class_name) { + if (element != null && !element.classLock) { + this.restoreClass(element); + this.switchClass(element, class_name); + } + }; + + EditArea.prototype.restoreClass = function(element) { + if (element != null && element.oldClassName && !element.classLock) { + element.className = element.oldClassName; + element.oldClassName = null; + } + }; + + EditArea.prototype.setClassLock = function(element, lock_state) { + if (element != null) + element.classLock = lock_state; + }; + + EditArea.prototype.switchClassSticky = function(element, class_name, lock_state) { + var lockChanged = false; + if (typeof(lock_state) != "undefined" && element != null) { + element.classLock = lock_state; + lockChanged = true; + } + + if (element != null && (lockChanged || !element.classLock)) { + element.className = class_name; + element.oldClassName = class_name; + } + }; + + //make the "page up" and "page down" buttons works correctly + EditArea.prototype.scroll_page= function(params){ + var dir= params["dir"]; + var shift_pressed= params["shift"]; + screen_height=$("result").clientHeight; + var lines= this.textarea.value.split("\n"); + var new_pos=0; + var length=0; + var char_left=0; + var line_nb=0; + if(dir=="up"){ + //val= Math.max(0, $("result").scrollTop - screen_height); + //$("result").scrollTop= val; + var scroll_line= Math.ceil((screen_height -30)/this.lineHeight); + if(this.last_selection["selec_direction"]=="up"){ + for(line_nb=0; line_nb< Math.min(this.last_selection["line_start"]-scroll_line, lines.length); line_nb++){ + new_pos+= lines[line_nb].length + 1; + } + char_left=Math.min(lines[Math.min(lines.length-1, line_nb)].length, this.last_selection["curr_pos"]-1); + if(shift_pressed) + length=this.last_selection["selectionEnd"]-new_pos-char_left; + this.area_select(new_pos+char_left, length); + view="top"; + }else{ + view="bottom"; + for(line_nb=0; line_nb< Math.min(this.last_selection["line_start"]+this.last_selection["line_nb"]-1-scroll_line, lines.length); line_nb++){ + new_pos+= lines[line_nb].length + 1; + } + char_left=Math.min(lines[Math.min(lines.length-1, line_nb)].length, this.last_selection["curr_pos"]-1); + if(shift_pressed){ + //length=this.last_selection["selectionEnd"]-new_pos-char_left; + start= Math.min(this.last_selection["selectionStart"], new_pos+char_left); + length= Math.max(new_pos+char_left, this.last_selection["selectionStart"] )- start ; + if(new_pos+char_left < this.last_selection["selectionStart"]) + view="top"; + }else + start=new_pos+char_left; + this.area_select(start, length); + + } + }else{ + //val= Math.max($("result").style.height.replace("px", ""), $("result").scrollTop + screen_height); + //$("result").scrollTop= val; + var scroll_line= Math.floor((screen_height-30)/this.lineHeight); + if(this.last_selection["selec_direction"]=="down"){ + view="bottom"; + for(line_nb=0; line_nb< Math.min(this.last_selection["line_start"]+this.last_selection["line_nb"]-2+scroll_line, lines.length); line_nb++){ + if(line_nb==this.last_selection["line_start"]-1) + char_left= this.last_selection["selectionStart"] -new_pos; + new_pos+= lines[line_nb].length + 1; + + } + if(shift_pressed){ + length=Math.abs(this.last_selection["selectionStart"]-new_pos); + length+=Math.min(lines[Math.min(lines.length-1, line_nb)].length, this.last_selection["curr_pos"]); + //length+=Math.min(lines[Math.min(lines.length-1, line_nb)].length, char_left); + this.area_select(Math.min(this.last_selection["selectionStart"], new_pos), length); + }else{ + this.area_select(new_pos+char_left, 0); + } + + }else{ + view="top"; + for(line_nb=0; line_nb< Math.min(this.last_selection["line_start"]+scroll_line-1, lines.length, lines.length); line_nb++){ + if(line_nb==this.last_selection["line_start"]-1) + char_left= this.last_selection["selectionStart"] -new_pos; + new_pos+= lines[line_nb].length + 1; + } + if(shift_pressed){ + length=Math.abs(this.last_selection["selectionEnd"]-new_pos-char_left); + length+=Math.min(lines[Math.min(lines.length-1, line_nb)].length, this.last_selection["curr_pos"])- char_left-1; + //length+=Math.min(lines[Math.min(lines.length-1, line_nb)].length, char_left); + this.area_select(Math.min(this.last_selection["selectionEnd"], new_pos+char_left), length); + if(new_pos+char_left > this.last_selection["selectionEnd"]) + view="bottom"; + }else{ + this.area_select(new_pos+char_left, 0); + } + + } + } + + this.check_line_selection(); + this.scroll_to_view(view); + }; + + EditArea.prototype.start_resize= function(e){ + parent.editAreaLoader.resize["id"]= editArea.id; + parent.editAreaLoader.resize["start_x"]= (e)? e.pageX : event.x + document.body.scrollLeft; + parent.editAreaLoader.resize["start_y"]= (e)? e.pageY : event.y + document.body.scrollTop; + if(editArea.nav['isIE']){ + editArea.textarea.focus(); + editArea.getIESelection(); + } + parent.editAreaLoader.resize["selectionStart"]= editArea.textarea.selectionStart; + parent.editAreaLoader.resize["selectionEnd"]= editArea.textarea.selectionEnd; + /*parent.editAreaLoader.resize["frame_top"]= parent.calculeOffsetTop(parent.editAreas[editArea.id]["textarea"]); + /*parent.editAreaLoader.resize["frame_left"]= parent.calculeOffsetLeft(parent.frames[editArea.id]);*/ + parent.editAreaLoader.start_resize_area(); + }; + + EditArea.prototype.toggle_full_screen= function(to){ + if(typeof(to)=="undefined") + to= !this.fullscreen['isFull']; + var old= this.fullscreen['isFull']; + this.fullscreen['isFull']= to; + var icon= $("fullscreen"); + if(to && to!=old) + { // toogle on fullscreen + var selStart= this.textarea.selectionStart; + var selEnd= this.textarea.selectionEnd; + var html= parent.document.getElementsByTagName("html")[0]; + var frame= parent.document.getElementById("frame_"+this.id); + + this.fullscreen['old_overflow']= parent.get_css_property(html, "overflow"); + this.fullscreen['old_height']= parent.get_css_property(html, "height"); + this.fullscreen['old_width']= parent.get_css_property(html, "width"); + this.fullscreen['old_scrollTop']= html.scrollTop; + this.fullscreen['old_scrollLeft']= html.scrollLeft; + this.fullscreen['old_zIndex']= parent.get_css_property(frame, "z-index"); + if(this.nav['isOpera']){ + html.style.height= "100%"; + html.style.width= "100%"; + } + html.style.overflow= "hidden"; + html.scrollTop=0; + html.scrollLeft=0; + + + //html.style.backgroundColor= "#FF0000"; +// alert(screen.height+"\n"+window.innerHeight+"\n"+html.clientHeight+"\n"+window.offsetHeight+"\n"+document.body.offsetHeight); + + + frame.style.position="absolute"; + frame.style.width= html.clientWidth+"px"; + frame.style.height= html.clientHeight+"px"; + frame.style.display="block"; + frame.style.zIndex="999999"; + frame.style.top="0px"; + frame.style.left="0px"; + + // if the iframe was in a div with position absolute, the top and left are the one of the div, + // so I fix it by seeing at witch position the iframe start and correcting it + frame.style.top= "-"+parent.calculeOffsetTop(frame)+"px"; + frame.style.left= "-"+parent.calculeOffsetLeft(frame)+"px"; + + // parent.editAreaLoader.execCommand(this.id, "update_size();"); + // var body=parent.document.getElementsByTagName("body")[0]; + // body.appendChild(frame); + + this.switchClassSticky(icon, 'editAreaButtonSelected', false); + this.fullscreen['allow_resize']= this.resize_allowed; + this.allow_resize(false); + + //this.area_select(selStart, selEnd-selStart); + + + // opera can't manage to do a direct size update + if(this.nav['isFirefox']){ + parent.editAreaLoader.execCommand(this.id, "update_size();"); + this.area_select(selStart, selEnd-selStart); + this.scroll_to_view(); + this.focus(); + }else{ + setTimeout("parent.editAreaLoader.execCommand('"+ this.id +"', 'update_size();');editArea.focus();", 10); + } + + + } + else if(to!=old) + { // toogle off fullscreen + var selStart= this.textarea.selectionStart; + var selEnd= this.textarea.selectionEnd; + + var frame= parent.document.getElementById("frame_"+this.id); + frame.style.position="static"; + frame.style.zIndex= this.fullscreen['old_zIndex']; + + var html= parent.document.getElementsByTagName("html")[0]; + // html.style.overflow= this.fullscreen['old_overflow']; + + if(this.nav['isOpera']){ + html.style.height= "auto"; + html.style.width= "auto"; + html.style.overflow= "auto"; + }else if(this.nav['isIE'] && parent!=top){ // IE doesn't manage html overflow in frames like in normal page... + html.style.overflow= "auto"; + } + else + html.style.overflow= this.fullscreen['old_overflow']; + html.scrollTop= this.fullscreen['old_scrollTop']; + html.scrollTop= this.fullscreen['old_scrollLeft']; + + parent.editAreaLoader.hide(this.id); + parent.editAreaLoader.show(this.id); + + this.switchClassSticky(icon, 'editAreaButtonNormal', false); + if(this.fullscreen['allow_resize']) + this.allow_resize(this.fullscreen['allow_resize']); + if(this.nav['isFirefox']){ + this.area_select(selStart, selEnd-selStart); + setTimeout("editArea.scroll_to_view();", 10); + } + + //parent.editAreaLoader.remove_event(parent.window, "resize", editArea.update_size); + } + + }; + + EditArea.prototype.allow_resize= function(allow){ + var resize= $("resize_area"); + if(allow){ + + resize.style.visibility="visible"; + parent.editAreaLoader.add_event(resize, "mouseup", editArea.start_resize); + }else{ + resize.style.visibility="hidden"; + parent.editAreaLoader.remove_event(resize, "mouseup", editArea.start_resize); + } + this.resize_allowed= allow; + }; + + + EditArea.prototype.change_syntax= function(new_syntax, is_waiting){ + // alert("cahnge to "+new_syntax); + // the syntax is the same + if(new_syntax==this.settings['syntax']) + return true; + + // check that the syntax is one allowed + var founded= false; + for(var i=0; i"; + elem.innerHTML= "*"+ this.files[id]['title'] + close +""; + $('tab_browsing_list').appendChild(elem); + var elem= document.createElement('text'); + this.update_size(); + } + + // open file callback (for plugin) + if(id!="") + this.execCommand('file_open', this.files[id]); + + this.switch_to_file(id, true); + return true; + } + else + return false; + }; + + // close the given file + EditArea.prototype.close_file= function(id){ + if(this.files[id]) + { + this.save_file(id); + + // close file callback + if(this.execCommand('file_close', this.files[id])!==false) + { + // remove the tab in the toolbar + var li= $(this.files[id]['html_id']); + li.parentNode.removeChild(li); + // select a new file + if(id== this.curr_file) + { + var next_file= ""; + var is_next= false; + for(var i in this.files) + { + if(is_next) + { + next_file= i; + break; + } + else if(i==id) + is_next= true; + else + next_file= i; + } + // display the next file + this.switch_to_file(next_file); + } + // clear datas + delete (this.files[id]); + this.update_size(); + } + } + }; + + // backup current file datas + EditArea.prototype.save_file= function(id){ + if(this.files[id]) + { + var save= this.files[id]; + save['last_selection']= this.last_selection; + save['last_text_to_highlight']= this.last_text_to_highlight; + save['last_hightlighted_text']= this.last_hightlighted_text; + save['previous']= this.previous; + save['next']= this.next; + save['last_undo']= this.last_undo; + save['smooth_selection']= this.smooth_selection; + save['do_highlight']= this.do_highlight; + save['syntax']= this.settings['syntax']; + save['text']= this.textarea.value; + save['scroll_top']= this.result.scrollTop; + save['scroll_left']= this.result.scrollLeft; + save['selection_start']= this.last_selection["selectionStart"]; + save['selection_end']= this.last_selection["selectionEnd"]; + save['font_size']= this.settings["font_size"]; + save['font_family']= this.settings["font_family"]; + save['toolbar']= {'links':{}, 'selects': {}}; + // save toolbar buttons state for fileSpecific buttons + var links= $("toolbar_1").getElementsByTagName("a"); + for(var i=0; i