unageanu-jiji 1.1.4 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (233) hide show
  1. data/ChangeLog +24 -1
  2. data/README +0 -0
  3. data/base/shared_lib/moving_average.rb +34 -33
  4. data/base/shared_lib/system/cross.rb +76 -0
  5. data/base/shared_lib/system/position_manager.rb +160 -0
  6. data/base/shared_lib/system/signal.rb +347 -0
  7. data/html/css/datatable.css +4 -4
  8. data/html/css/default.css +57 -5
  9. data/html/css/treeview.css +205 -0
  10. data/html/img/bin_closed.png +0 -0
  11. data/html/img/bin_empty.png +0 -0
  12. data/html/img/button_add_small.gif +0 -0
  13. data/html/img/button_add_small_gray.gif +0 -0
  14. data/html/img/button_add_small_over.gif +0 -0
  15. data/html/img/button_mkcol.gif +0 -0
  16. data/html/img/button_mkcol_gray.gif +0 -0
  17. data/html/img/button_mkcol_over.gif +0 -0
  18. data/html/img/button_remove_small.gif +0 -0
  19. data/html/img/button_remove_small_gray.gif +0 -0
  20. data/html/img/button_remove_small_over.gif +0 -0
  21. data/html/img/button_rename.gif +0 -0
  22. data/html/img/button_rename_gray.gif +0 -0
  23. data/html/img/button_rename_over.gif +0 -0
  24. data/html/img/control_play.png +0 -0
  25. data/html/img/control_play_blue.png +0 -0
  26. data/html/img/folder.png +0 -0
  27. data/html/img/folder_brick.png +0 -0
  28. data/html/img/folder_user.png +0 -0
  29. data/html/{js/codepress/images → img}/line-numbers.png +0 -0
  30. data/html/img/page_white_ruby.png +0 -0
  31. data/html/img/sidebar_agent_edit.png +0 -0
  32. data/html/img/sidebar_agent_edit_over.png +0 -0
  33. data/html/img/sidebar_agent_edit_s.png +0 -0
  34. data/html/img/yui/treeview-sprite.gif +0 -0
  35. data/html/index.html +34 -18
  36. data/html/js/agent-editor/agent-editor-page.js +324 -0
  37. data/html/js/agent-editor/agent-editor.js +363 -0
  38. data/html/js/agent-editor/agent-list-tree.js +251 -0
  39. data/html/js/agent-selector.js +23 -28
  40. data/html/js/app.js +63 -91
  41. data/html/js/bt-create-page.js +25 -19
  42. data/html/js/container-min.js +1 -1
  43. data/html/js/container.js +944 -0
  44. data/html/js/edit_area/autocompletion.js +11 -13
  45. data/html/js/edit_area/edit_area.css +79 -40
  46. data/html/js/edit_area/edit_area.js +255 -226
  47. data/html/js/edit_area/edit_area_compressor.php +4 -4
  48. data/html/js/edit_area/edit_area_full.gz +0 -0
  49. data/html/js/edit_area/edit_area_full.js +31 -31
  50. data/html/js/edit_area/edit_area_full_with_plugins.gz +0 -0
  51. data/html/js/edit_area/edit_area_full_with_plugins.js +31 -31
  52. data/html/js/edit_area/edit_area_functions.js +448 -341
  53. data/html/js/edit_area/edit_area_loader.js +409 -397
  54. data/html/js/edit_area/elements_functions.js +120 -123
  55. data/html/js/edit_area/highlight.js +305 -197
  56. data/html/js/edit_area/images/goto.png +0 -0
  57. data/html/js/edit_area/images/help.png +0 -0
  58. data/html/js/edit_area/images/redo.png +0 -0
  59. data/html/js/edit_area/images/save.png +0 -0
  60. data/html/js/edit_area/images/search.png +0 -0
  61. data/html/js/edit_area/images/undo.png +0 -0
  62. data/html/js/edit_area/images/word_wrap.gif +0 -0
  63. data/html/js/edit_area/keyboard.js +5 -5
  64. data/html/js/edit_area/langs/bg.js +73 -0
  65. data/html/js/edit_area/langs/cs.js +2 -0
  66. data/html/js/edit_area/langs/de.js +2 -0
  67. data/html/js/edit_area/langs/dk.js +2 -0
  68. data/html/js/edit_area/langs/en.js +2 -0
  69. data/html/js/edit_area/langs/eo.js +2 -0
  70. data/html/js/edit_area/langs/es.js +2 -0
  71. data/html/js/edit_area/langs/fi.js +67 -0
  72. data/html/js/edit_area/langs/fr.js +2 -0
  73. data/html/js/edit_area/langs/hr.js +2 -0
  74. data/html/js/edit_area/langs/it.js +2 -0
  75. data/html/js/edit_area/langs/ja.js +2 -0
  76. data/html/js/edit_area/langs/mk.js +2 -0
  77. data/html/js/edit_area/langs/nl.js +2 -0
  78. data/html/js/edit_area/langs/pl.js +2 -0
  79. data/html/js/edit_area/langs/pt.js +2 -0
  80. data/html/js/edit_area/langs/ru.js +2 -0
  81. data/html/js/edit_area/langs/sk.js +2 -0
  82. data/html/js/edit_area/langs/zh.js +67 -0
  83. data/html/js/edit_area/manage_area.js +362 -205
  84. data/html/js/edit_area/plugins/charmap/langs/bg.js +12 -0
  85. data/html/js/edit_area/plugins/charmap/langs/zh.js +6 -0
  86. data/html/js/edit_area/plugins/test/langs/bg.js +10 -0
  87. data/html/js/edit_area/plugins/test/langs/zh.js +4 -0
  88. data/html/js/edit_area/reg_syntax/java.js +56 -0
  89. data/html/js/edit_area/reg_syntax/ruby.js +9 -9
  90. data/html/js/edit_area/reg_syntax.js +15 -13
  91. data/html/js/edit_area/regexp.js +36 -32
  92. data/html/js/edit_area/resize_area.js +43 -47
  93. data/html/js/edit_area/search_replace.js +29 -29
  94. data/html/js/edit_area/template.html +6 -4
  95. data/html/js/json-broker-client.js +23 -17
  96. data/html/js/result-page.js +107 -57
  97. data/html/js/rt-setting-page.js +38 -15
  98. data/html/js/sidebar.js +41 -27
  99. data/html/js/templates.js +167 -32
  100. data/html/js/utils.js +143 -7
  101. data/html/js/yui/treeview.js +3671 -0
  102. data/html/swf/chart.swf +0 -0
  103. data/html/test/agent_editor_spec.js +815 -0
  104. data/html/test/index.html +40 -0
  105. data/html/test/jsspec/JSSpec.css +224 -0
  106. data/html/test/jsspec/JSSpec.js +1549 -0
  107. data/html/test/jsspec/diff_match_patch.js +1 -0
  108. data/html/test/utils_spec.js +111 -0
  109. data/lib/jiji/agent/agent.rb +69 -12
  110. data/lib/jiji/agent/agent_manager.rb +18 -12
  111. data/lib/jiji/agent/agent_registry.rb +35 -121
  112. data/lib/jiji/collector.rb +16 -6
  113. data/lib/jiji/command.rb +46 -5
  114. data/lib/jiji/dao/file_system_dao.rb +158 -0
  115. data/lib/jiji/dao/timed_data_dao.rb +2 -0
  116. data/lib/jiji/dao/trade_result_dao.rb +1 -1
  117. data/lib/jiji/error.rb +24 -8
  118. data/lib/jiji/migration/migrator1_2_0.rb +67 -0
  119. data/lib/jiji/models.rb +82 -24
  120. data/lib/jiji/operator.rb +55 -51
  121. data/lib/jiji/output.rb +85 -29
  122. data/lib/jiji/output_manager.rb +84 -0
  123. data/lib/jiji/plugin/embedded/single_click_client.rb +2 -2
  124. data/lib/jiji/plugin/securities_plugin.rb +0 -1
  125. data/lib/jiji/process.rb +229 -208
  126. data/lib/jiji/process_manager.rb +190 -96
  127. data/lib/jiji/registry.rb +87 -19
  128. data/lib/jiji/server.rb +1 -0
  129. data/lib/jiji/service/agent_service.rb +147 -48
  130. data/lib/jiji/service/output_service.rb +37 -17
  131. data/lib/jiji/service/process_service.rb +3 -5
  132. data/lib/jiji/service/trade_result_service.rb +4 -5
  133. data/lib/jiji/util/file_lock.rb +4 -4
  134. data/lib/jiji/util/include_proxy.rb +17 -0
  135. data/lib/jiji/util/json_broker.rb +6 -4
  136. data/lib/jiji/util/util.rb +1 -1
  137. data/swf/chart/fx/chart/Chart.as +7 -0
  138. data/swf/chart/fx/chart/ui/graph/GraphManager.as +15 -2
  139. data/test/ProcessTest/agents/foo.rb +10 -0
  140. data/test/ProcessTest/conf/configuration.yaml +3 -0
  141. data/test/agent/agent_tests.rb +10 -0
  142. data/test/agent/test_AgentManager.rb +28 -12
  143. data/test/agent/test_AgentRegistry.rb +194 -99
  144. data/test/agent/test_PeriodicallyAgent.rb +1 -2
  145. data/test/agent/test_Permitter.rb +1 -2
  146. data/test/all_tests.rb +7 -19
  147. data/test/dao/dao_tests.rb +9 -0
  148. data/test/dao/test_FileSystemDao.rb +431 -0
  149. data/test/dao/test_RateDao.rb +5 -7
  150. data/test/dao/test_TradeResultDao.rb +1 -2
  151. data/test/migration/migration_tests.rb +10 -0
  152. data/test/migration/migrator1_2_0test_data/basic/out/M2NlOTA2ODEtZDdlNi00NWU1LWIwNDQtMjBmODY2ZGNkNzBj/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
  153. data/test/migration/migrator1_2_0test_data/basic/out/MDVhYzcxMjYtMGFlMS00Mzk0LWEyNmUtYjVjZjgwNDA0ZmE2/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
  154. data/test/migration/migrator1_2_0test_data/basic/out/MzA1YTk0NDgtNzhjNi00NDk3LTk2NTktYzE1ZjBhNzdiYjNj/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
  155. data/test/migration/migrator1_2_0test_data/basic/out/YjRkOTI1MzEtZTM4MS00YjQwLTg1ZTQtMWFmZDRlNDUwMzBm/56e75YuV5bmz5Z2H57ea/meta.yaml +9 -0
  156. data/test/migration/migrator1_2_0test_data/basic/props.yaml +85 -0
  157. data/test/migration/migrator1_2_0test_data/illegal_props/out/M2NlOTA2ODEtZDdlNi00NWU1LWIwNDQtMjBmODY2ZGNkNzBj/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
  158. data/test/migration/migrator1_2_0test_data/illegal_props/out/MDVhYzcxMjYtMGFlMS00Mzk0LWEyNmUtYjVjZjgwNDA0ZmE2/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
  159. data/test/migration/migrator1_2_0test_data/illegal_props/out/MzA1YTk0NDgtNzhjNi00NDk3LTk2NTktYzE1ZjBhNzdiYjNj/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
  160. data/test/migration/migrator1_2_0test_data/illegal_props/out/YjRkOTI1MzEtZTM4MS00YjQwLTg1ZTQtMWFmZDRlNDUwMzBm/56e75YuV5bmz5Z2H57ea/meta.yaml +9 -0
  161. data/test/migration/migrator1_2_0test_data/illegal_props/props.yaml +1 -0
  162. data/test/migration/migrator1_2_0test_data/no_outs/props.yaml +85 -0
  163. data/test/migration/migrator1_2_0test_data/no_props/out/M2NlOTA2ODEtZDdlNi00NWU1LWIwNDQtMjBmODY2ZGNkNzBj/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
  164. data/test/migration/migrator1_2_0test_data/no_props/out/MDVhYzcxMjYtMGFlMS00Mzk0LWEyNmUtYjVjZjgwNDA0ZmE2/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
  165. data/test/migration/migrator1_2_0test_data/no_props/out/MzA1YTk0NDgtNzhjNi00NDk3LTk2NTktYzE1ZjBhNzdiYjNj/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
  166. data/test/migration/migrator1_2_0test_data/no_props/out/YjRkOTI1MzEtZTM4MS00YjQwLTg1ZTQtMWFmZDRlNDUwMzBm/56e75YuV5bmz5Z2H57ea/meta.yaml +9 -0
  167. data/test/migration/test_Migrator.rb +1 -1
  168. data/test/migration/test_Migrator1_0_3.rb +1 -1
  169. data/test/migration/test_Migrator1_1_0.rb +1 -1
  170. data/test/migration/test_Migrator1_2_0.rb +94 -0
  171. data/test/plugin/embedded/test_SingleClickClient.rb +1 -2
  172. data/test/plugin/plugin_tests.rb +8 -0
  173. data/test/plugin/test_Loader.rb +1 -1
  174. data/test/shared/rate.csv +144 -0
  175. data/test/shared/shared_tests.rb +9 -0
  176. data/test/shared/test_Cross.rb +144 -0
  177. data/test/shared/test_PositionManager.rb +285 -0
  178. data/test/shared/test_Signal.rb +65 -0
  179. data/test/test_Output.rb +28 -21
  180. data/test/test_OutputManager.rb +162 -0
  181. data/test/test_Output_registry.rb +6 -17
  182. data/test/test_Process.rb +434 -222
  183. data/test/test_ProcessManager.rb +458 -101
  184. data/test/test_utils.rb +71 -8
  185. data/test/util/test_BlockToSession.rb +1 -2
  186. data/test/util/test_CSV.rb +1 -2
  187. data/test/util/test_SynchronizeInterceptor.rb +1 -2
  188. data/test/util/util_tests.rb +9 -0
  189. metadata +127 -47
  190. data/html/js/agent-editor-page.js +0 -440
  191. data/html/js/codepress/codepress.css +0 -21
  192. data/html/js/codepress/codepress.html +0 -35
  193. data/html/js/codepress/codepress.js +0 -138
  194. data/html/js/codepress/engines/gecko.js +0 -293
  195. data/html/js/codepress/engines/khtml.js +0 -0
  196. data/html/js/codepress/engines/msie.js +0 -304
  197. data/html/js/codepress/engines/older.js +0 -0
  198. data/html/js/codepress/engines/opera.js +0 -260
  199. data/html/js/codepress/images/line-numbers.gif +0 -0
  200. data/html/js/codepress/index.html +0 -443
  201. data/html/js/codepress/languages/asp.css +0 -71
  202. data/html/js/codepress/languages/asp.js +0 -117
  203. data/html/js/codepress/languages/autoit.css +0 -13
  204. data/html/js/codepress/languages/autoit.js +0 -32
  205. data/html/js/codepress/languages/csharp.css +0 -9
  206. data/html/js/codepress/languages/csharp.js +0 -25
  207. data/html/js/codepress/languages/css.css +0 -10
  208. data/html/js/codepress/languages/css.js +0 -23
  209. data/html/js/codepress/languages/generic.css +0 -9
  210. data/html/js/codepress/languages/generic.js +0 -25
  211. data/html/js/codepress/languages/html.css +0 -13
  212. data/html/js/codepress/languages/html.js +0 -59
  213. data/html/js/codepress/languages/java.css +0 -7
  214. data/html/js/codepress/languages/java.js +0 -24
  215. data/html/js/codepress/languages/javascript.css +0 -8
  216. data/html/js/codepress/languages/javascript.js +0 -30
  217. data/html/js/codepress/languages/perl.css +0 -11
  218. data/html/js/codepress/languages/perl.js +0 -27
  219. data/html/js/codepress/languages/php.css +0 -12
  220. data/html/js/codepress/languages/php.js +0 -61
  221. data/html/js/codepress/languages/ruby.css +0 -10
  222. data/html/js/codepress/languages/ruby.js +0 -26
  223. data/html/js/codepress/languages/sql.css +0 -10
  224. data/html/js/codepress/languages/sql.js +0 -30
  225. data/html/js/codepress/languages/text.css +0 -5
  226. data/html/js/codepress/languages/text.js +0 -9
  227. data/html/js/codepress/languages/vbscript.css +0 -71
  228. data/html/js/codepress/languages/vbscript.js +0 -117
  229. data/html/js/codepress/languages/xsl.css +0 -15
  230. data/html/js/codepress/languages/xsl.js +0 -103
  231. data/html/js/codepress/license.txt +0 -458
  232. data/html/js/edit_area/images/Thumbs.db +0 -0
  233. data/test/plugin/test_gem/a/lib/jiji_plugin_test.rb +0 -6
@@ -7,35 +7,35 @@
7
7
  ******/
8
8
 
9
9
  function EditAreaLoader(){
10
- this.version= "0.7.2.3";
10
+ var t=this;
11
+ t.version= "0.8.1.1";
11
12
  date= new Date();
12
- this.start_time=date.getTime();
13
- this.win= "loading"; // window loading state
14
- this.error= false; // to know if load is interrrupt
15
- this.baseURL="";
16
- //this.suffix="";
17
- this.template="";
18
- this.lang= new Object(); // array of loaded speech language
19
- this.load_syntax= new Object(); // array of loaded syntax language for highlight mode
20
- this.syntax= new Object(); // array of initilized syntax language for highlight mode
21
- this.loadedFiles= new Array();
22
- this.waiting_loading= new Object(); // files that must be loaded in order to allow the script to really start
13
+ t.start_time=date.getTime();
14
+ t.win= "loading"; // window loading state
15
+ t.error= false; // to know if load is interrrupt
16
+ t.baseURL="";
17
+ //t.suffix="";
18
+ t.template="";
19
+ t.lang= {}; // array of loaded speech language
20
+ t.load_syntax= {}; // array of loaded syntax language for highlight mode
21
+ t.syntax= {}; // array of initilized syntax language for highlight mode
22
+ t.loadedFiles= [];
23
+ t.waiting_loading= {}; // files that must be loaded in order to allow the script to really start
23
24
  // scripts that must be loaded in the iframe
24
- this.scripts_to_load= new Array("elements_functions", "resize_area", "reg_syntax");
25
- this.sub_scripts_to_load= new Array("edit_area", "manage_area" ,"edit_area_functions", "keyboard", "search_replace", "highlight", "regexp" );
25
+ t.scripts_to_load= ["elements_functions", "resize_area", "reg_syntax"];
26
+ t.sub_scripts_to_load= ["edit_area", "manage_area" ,"edit_area_functions", "keyboard", "search_replace", "highlight", "regexp"];
26
27
 
27
- this.resize= new Array(); // contain resizing datas
28
- this.hidden= new Object(); // store datas of the hidden textareas
28
+ t.resize= []; // contain resizing datas
29
+ t.hidden= {}; // store datas of the hidden textareas
29
30
 
30
- this.default_settings= {
31
+ t.default_settings= {
31
32
  //id: "src" // id of the textarea to transform
32
33
  debug: false
33
34
  ,smooth_selection: true
34
35
  ,font_size: "10" // not for IE
35
36
  ,font_family: "monospace" // can be "verdana,monospace". Allow non monospace font but Firefox get smaller tabulation with non monospace fonts. IE doesn't change the tabulation width and Opera doesn't take this option into account...
36
37
  ,start_highlight: false // if start with highlight
37
- ,autocompletion: false // DEV ONLY if enable auto completion
38
- ,toolbar: "search, go_to_line, fullscreen, |, undo, redo, |, select_font,|, change_smooth_selection, highlight, reset_highlight, |, help"
38
+ ,toolbar: "search, go_to_line, fullscreen, |, undo, redo, |, select_font,|, change_smooth_selection, highlight, reset_highlight, word_wrap, |, help"
39
39
  ,begin_toolbar: "" // "new_document, save, load, |"
40
40
  ,end_toolbar: "" // or end_toolbar
41
41
  ,is_multi_files: false // enable the multi file mode (the textarea content is ignored)
@@ -47,7 +47,7 @@ function EditAreaLoader(){
47
47
  ,allow_toggle: true // true or false
48
48
  ,language: "en"
49
49
  ,syntax: ""
50
- ,syntax_selection_allow: "basic,brainfuck,c,coldfusion,cpp,css,html,js,pas,perl,php,python,ruby,robotstxt,sql,tsql,vb,xml"
50
+ ,syntax_selection_allow: "basic,brainfuck,c,coldfusion,cpp,css,html,java,js,pas,perl,php,python,ruby,robotstxt,sql,tsql,vb,xml"
51
51
  ,display: "onload" // onload or later
52
52
  ,max_undo: 30
53
53
  ,browsers: "known" // all or known
@@ -55,7 +55,9 @@ function EditAreaLoader(){
55
55
  ,gecko_spellcheck: false // enable/disable by default the gecko_spellcheck
56
56
  ,fullscreen: false
57
57
  ,is_editable: true
58
- ,wrap_text: false // NOT IMPLEMENTED
58
+ ,cursor_position: "begin"
59
+ ,word_wrap: false // define if the text is wrapped of not in the textarea
60
+ ,autocompletion: false // NOT IMPLEMENTED
59
61
  ,load_callback: "" // click on load button (function name)
60
62
  ,save_callback: "" // click on save button (function name)
61
63
  ,change_callback: "" // textarea onchange trigger (function name)
@@ -71,83 +73,39 @@ function EditAreaLoader(){
71
73
  ,EA_file_close_callback: "" // close a tab
72
74
  };
73
75
 
74
- this.advanced_buttons = [
76
+ t.advanced_buttons = [
75
77
  // id, button img, command (it will try to find the translation of "id"), is_file_specific
76
78
  ['new_document', 'newdocument.gif', 'new_document', false],
77
- ['search', 'search.gif', 'show_search', false],
78
- ['go_to_line', 'go_to_line.gif', 'go_to_line', false],
79
- ['undo', 'undo.gif', 'undo', true],
80
- ['redo', 'redo.gif', 'redo', true],
79
+ ['search', 'search.png', 'show_search', false],
80
+ ['go_to_line', 'goto.png', 'go_to_line', false],
81
+ ['undo', 'undo.png', 'undo', true],
82
+ ['redo', 'redo.png', 'redo', true],
81
83
  ['change_smooth_selection', 'smooth_selection.gif', 'change_smooth_selection_mode', true],
82
84
  ['reset_highlight', 'reset_highlight.gif', 'resync_highlight', true],
83
85
  ['highlight', 'highlight.gif','change_highlight', true],
84
- ['help', 'help.gif', 'show_help', false],
85
- ['save', 'save.gif', 'save', false],
86
+ ['help', 'help.png', 'show_help', false],
87
+ ['save', 'save.png', 'save', false],
86
88
  ['load', 'load.gif', 'load', false],
87
89
  ['fullscreen', 'fullscreen.gif', 'toggle_full_screen', false],
90
+ ['word_wrap', 'word_wrap.gif', 'toggle_word_wrap', true],
88
91
  ['autocompletion', 'autocompletion.gif', 'toggle_autocompletion', true]
89
92
  ];
90
93
 
91
94
  // navigator identification
92
- ua= navigator.userAgent;
93
-
94
- this.nav= new Object();
95
-
96
- this.nav['isMacOS'] = (ua.indexOf('Mac OS') != -1);
97
-
98
- this.nav['isIE'] = (navigator.appName == "Microsoft Internet Explorer");
99
- if(this.nav['isIE']){
100
- this.nav['isIE'] = ua.replace(/^.*?MSIE ([0-9\.]*).*$/, "$1");
101
- if(this.nav['isIE']<6)
102
- this.has_error();
103
- }
104
- if(this.nav['isNS'] = ua.indexOf('Netscape/') != -1){ // work only on netscape > 8 with render mode IE
105
- this.nav['isNS']= ua.substr(ua.indexOf('Netscape/')+9);
106
- if(this.nav['isNS']<8 || !this.nav['isIE'])
107
- this.has_error();
108
- }
109
-
110
- if(this.nav['isOpera'] = (ua.indexOf('Opera') != -1)){
111
- this.nav['isOpera']= ua.replace(/^.*?Opera.*?([0-9\.]+).*$/i, "$1");
112
- if(this.nav['isOpera']<9)
113
- this.has_error();
114
- this.nav['isIE']=false;
115
- }
116
- this.nav['isGecko'] = (ua.indexOf('Gecko') != -1);
117
-
118
- if(this.nav['isFirefox'] =(ua.indexOf('Firefox') != -1))
119
- this.nav['isFirefox'] = ua.replace(/^.*?Firefox.*?([0-9\.]+).*$/i, "$1");
120
- // Iceweasel is a clone of Firefox
121
- if(this.nav['isIceweasel'] =(ua.indexOf('Iceweasel') != -1))
122
- this.nav['isFirefox']= this.nav['isIceweasel'] = ua.replace(/^.*?Iceweasel.*?([0-9\.]+).*$/i, "$1");
123
- // grandparadisio is a clone of Firefox
124
- if(this.nav['GranParadiso'] =(ua.indexOf('GranParadiso') != -1))
125
- this.nav['isFirefox']= this.nav['isGranParadiso'] = ua.replace(/^.*?GranParadiso.*?([0-9\.]+).*$/i, "$1");
126
- // BonEcho is a clone of Firefox
127
- if(this.nav['BonEcho'] =(ua.indexOf('BonEcho') != -1))
128
- this.nav['isFirefox']= this.nav['isBonEcho'] = ua.replace(/^.*?BonEcho.*?([0-9\.]+).*$/i, "$1");
129
-
130
- if(this.nav['isCamino'] =(ua.indexOf('Camino') != -1))
131
- this.nav['isCamino'] = ua.replace(/^.*?Camino.*?([0-9\.]+).*$/i, "$1");
95
+ t.set_browser_infos(t);
132
96
 
133
- if(this.nav['isChrome'] =(ua.indexOf('Chrome') != -1))
134
- this.nav['isChrome'] = ua.replace(/^.*?Chrome.*?([0-9\.]+).*$/i, "$1");
135
-
136
- if(this.nav['isSafari'] =(ua.indexOf('Safari') != -1))
137
- this.nav['isSafari']= ua.replace(/^.*?Version\/([0-9]+\.[0-9]+).*$/i, "$1");
138
-
139
- if(this.nav['isIE']>=6 || this.nav['isOpera']>=9 || this.nav['isFirefox'] || this.nav['isChrome'] || this.nav['isCamino'] || this.nav['isSafari']>=3)
140
- this.nav['isValidBrowser']=true;
97
+ if(t.isIE>=6 || t.isGecko || ( t.isWebKit && !t.isSafari<3 ) || t.isOpera>=9 || t.isCamino )
98
+ t.isValidBrowser=true;
141
99
  else
142
- this.nav['isValidBrowser']=false;
100
+ t.isValidBrowser=false;
143
101
 
144
- this.set_base_url();
102
+ t.set_base_url();
145
103
 
146
- for(var i=0; i<this.scripts_to_load.length; i++){
147
- setTimeout("editAreaLoader.load_script('"+this.baseURL + this.scripts_to_load[i]+ ".js');", 1); // let the time to Object editAreaLoader to be created before loading additionnal scripts
148
- this.waiting_loading[this.scripts_to_load[i]+ ".js"]= false;
149
- }
150
- this.add_event(window, "load", EditAreaLoader.prototype.window_loaded);
104
+ for(var i=0; i<t.scripts_to_load.length; i++){
105
+ setTimeout("editAreaLoader.load_script('"+t.baseURL + t.scripts_to_load[i]+ ".js');", 1); // let the time to Object editAreaLoader to be created before loading additionnal scripts
106
+ t.waiting_loading[t.scripts_to_load[i]+ ".js"]= false;
107
+ }
108
+ t.add_event(window, "load", EditAreaLoader.prototype.window_loaded);
151
109
  };
152
110
 
153
111
  EditAreaLoader.prototype ={
@@ -159,6 +117,54 @@ EditAreaLoader.prototype ={
159
117
  }
160
118
  },
161
119
 
120
+ // add browser informations to the object passed in parameter
121
+ set_browser_infos : function(o){
122
+ ua= navigator.userAgent;
123
+
124
+ // general detection
125
+ o.isWebKit = /WebKit/.test(ua);
126
+ o.isGecko = !o.isWebKit && /Gecko/.test(ua);
127
+ o.isMac = /Mac/.test(ua);
128
+
129
+ o.isIE = (navigator.appName == "Microsoft Internet Explorer");
130
+ if(o.isIE){
131
+ o.isIE = ua.replace(/^.*?MSIE\s+([0-9\.]+).*$/, "$1");
132
+ if(o.isIE<6)
133
+ o.has_error();
134
+ }
135
+
136
+ if(o.isOpera = (ua.indexOf('Opera') != -1)){
137
+ o.isOpera= ua.replace(/^.*?Opera.*?([0-9\.]+).*$/i, "$1");
138
+ if(o.isOpera<9)
139
+ o.has_error();
140
+ o.isIE=false;
141
+ }
142
+
143
+ if(o.isFirefox =(ua.indexOf('Firefox') != -1))
144
+ o.isFirefox = ua.replace(/^.*?Firefox.*?([0-9\.]+).*$/i, "$1");
145
+ // Firefox clones
146
+ if( ua.indexOf('Iceweasel') != -1 )
147
+ o.isFirefox = ua.replace(/^.*?Iceweasel.*?([0-9\.]+).*$/i, "$1");
148
+ if( ua.indexOf('GranParadiso') != -1 )
149
+ o.isFirefox = ua.replace(/^.*?GranParadiso.*?([0-9\.]+).*$/i, "$1");
150
+ if( ua.indexOf('BonEcho') != -1 )
151
+ o.isFirefox = ua.replace(/^.*?BonEcho.*?([0-9\.]+).*$/i, "$1");
152
+ if( ua.indexOf('SeaMonkey') != -1)
153
+ o.isFirefox = (ua.replace(/^.*?SeaMonkey.*?([0-9\.]+).*$/i, "$1") ) + 1;
154
+
155
+ if(o.isCamino =(ua.indexOf('Camino') != -1))
156
+ o.isCamino = ua.replace(/^.*?Camino.*?([0-9\.]+).*$/i, "$1");
157
+
158
+ if(o.isSafari =(ua.indexOf('Safari') != -1))
159
+ o.isSafari= ua.replace(/^.*?Version\/([0-9]+\.[0-9]+).*$/i, "$1");
160
+
161
+ if(o.isChrome =(ua.indexOf('Chrome') != -1)) {
162
+ o.isChrome = ua.replace(/^.*?Chrome.*?([0-9\.]+).*$/i, "$1");
163
+ o.isSafari = false;
164
+ }
165
+
166
+ },
167
+
162
168
  window_loaded : function(){
163
169
  editAreaLoader.win="loaded";
164
170
 
@@ -182,150 +188,145 @@ EditAreaLoader.prototype ={
182
188
 
183
189
  // init the checkup of the selection of the IE textarea
184
190
  init_ie_textarea : function(id){
185
- var t=document.getElementById(id);
191
+ var a=document.getElementById(id);
186
192
  try{
187
- if(t && typeof(t.focused)=="undefined"){
188
- t.focus();
189
- t.focused=true;
190
- t.selectionStart= t.selectionEnd= 0;
191
- get_IE_selection(t);
192
- editAreaLoader.add_event(t, "focus", IE_textarea_focus);
193
- editAreaLoader.add_event(t, "blur", IE_textarea_blur);
193
+ if(a && typeof(a.focused)=="undefined"){
194
+ a.focus();
195
+ a.focused=true;
196
+ a.selectionStart= a.selectionEnd= 0;
197
+ get_IE_selection(a);
198
+ editAreaLoader.add_event(a, "focus", IE_textarea_focus);
199
+ editAreaLoader.add_event(a, "blur", IE_textarea_blur);
194
200
 
195
201
  }
196
202
  }catch(ex){}
197
203
  },
198
204
 
199
205
  init : function(settings){
200
-
201
- if(!settings["id"])
202
- this.has_error();
206
+ var t=this,s=settings,i;
203
207
 
204
- if(this.error)
208
+ if(!s["id"])
209
+ t.has_error();
210
+ if(t.error)
205
211
  return;
206
212
  // if an instance of the editor already exists for this textarea => delete the previous one
207
- if(editAreas[settings["id"]])
208
- editAreaLoader.delete_instance(settings["id"]);
213
+ if(editAreas[s["id"]])
214
+ t.delete_instance(s["id"]);
209
215
 
210
216
  // init settings
211
- for(var i in this.default_settings){
212
- if(typeof(settings[i])=="undefined")
213
- settings[i]=this.default_settings[i];
217
+ for(i in t.default_settings){
218
+ if(typeof(s[i])=="undefined")
219
+ s[i]=t.default_settings[i];
214
220
  }
215
221
 
216
- if(settings["browsers"]=="known" && this.nav['isValidBrowser']==false){
222
+ if(s["browsers"]=="known" && t.isValidBrowser==false){
217
223
  return;
218
224
  }
219
225
 
220
- if(settings["begin_toolbar"].length>0)
221
- settings["toolbar"]= settings["begin_toolbar"] +","+ settings["toolbar"];
222
- if(settings["end_toolbar"].length>0)
223
- settings["toolbar"]= settings["toolbar"] +","+ settings["end_toolbar"];
224
- settings["tab_toolbar"]= settings["toolbar"].replace(/ /g,"").split(",");
226
+ if(s["begin_toolbar"].length>0)
227
+ s["toolbar"]= s["begin_toolbar"] +","+ s["toolbar"];
228
+ if(s["end_toolbar"].length>0)
229
+ s["toolbar"]= s["toolbar"] +","+ s["end_toolbar"];
230
+ s["tab_toolbar"]= s["toolbar"].replace(/ /g,"").split(",");
225
231
 
226
- settings["plugins"]= settings["plugins"].replace(/ /g,"").split(",");
227
- for(var i=0; i<settings["plugins"].length; i++){
228
- if(settings["plugins"][i].length==0)
229
- settings["plugins"].splice(i,1);
232
+ s["plugins"]= s["plugins"].replace(/ /g,"").split(",");
233
+ for(i=0; i<s["plugins"].length; i++){
234
+ if(s["plugins"][i].length==0)
235
+ s["plugins"].splice(i,1);
230
236
  }
231
237
  // alert(settings["plugins"].length+": "+ settings["plugins"].join(","));
232
- /* var tmp="";
233
- for(var i in settings){
234
- tmp+=i+" : "+settings[i]+";\n";
235
- }
236
- alert(tmp);*/
237
- this.get_template();
238
- this.load_script(this.baseURL + "langs/"+ settings["language"] + ".js");
238
+ t.get_template();
239
+ t.load_script(t.baseURL + "langs/"+ s["language"] + ".js");
239
240
 
240
- if(settings["syntax"].length>0){
241
- settings["syntax"]=settings["syntax"].toLowerCase();
242
- this.load_script(this.baseURL + "reg_syntax/"+ settings["syntax"] + ".js");
241
+ if(s["syntax"].length>0){
242
+ s["syntax"]=s["syntax"].toLowerCase();
243
+ t.load_script(t.baseURL + "reg_syntax/"+ s["syntax"] + ".js");
243
244
  }
244
245
  //alert(this.template);
245
246
 
246
- editAreas[settings["id"]]= {"settings": settings};
247
- editAreas[settings["id"]]["displayed"]=false;
248
- editAreas[settings["id"]]["hidden"]=false;
247
+ editAreas[s["id"]]= {"settings": s};
248
+ editAreas[s["id"]]["displayed"]=false;
249
+ editAreas[s["id"]]["hidden"]=false;
249
250
 
250
251
  //if(settings["display"]=="onload")
251
- editAreaLoader.start(settings["id"]);
252
+ t.start(s["id"]);
252
253
  },
253
254
 
254
255
  // delete an instance of an EditArea
255
256
  delete_instance : function(id){
256
-
257
+ var d=document,fs=window.frames,span,iframe;
257
258
  editAreaLoader.execCommand(id, "EA_delete");
258
- if(window.frames["frame_"+id] && window.frames["frame_"+id].editArea)
259
+ if(fs["frame_"+id] && fs["frame_"+id].editArea)
259
260
  {
260
261
  if(editAreas[id]["displayed"])
261
262
  editAreaLoader.toggle(id, "off");
262
- window.frames["frame_"+id].editArea.execCommand("EA_unload");
263
+ fs["frame_"+id].editArea.execCommand("EA_unload");
263
264
  }
264
265
 
265
266
  // remove toggle infos and debug textarea
266
- var span= document.getElementById("EditAreaArroundInfos_"+id);
267
+ span= d.getElementById("EditAreaArroundInfos_"+id);
267
268
  if(span)
268
269
  span.parentNode.removeChild(span);
269
270
 
270
271
  // remove the iframe
271
- var iframe= document.getElementById("frame_"+id);
272
+ iframe= d.getElementById("frame_"+id);
272
273
  if(iframe){
273
274
  iframe.parentNode.removeChild(iframe);
274
275
  //delete iframe;
275
276
  try {
276
- delete window.frames["frame_"+id];
277
+ delete fs["frame_"+id];
277
278
  } catch (e) {// Do nothing
278
279
  }
279
280
  }
280
281
 
281
282
  delete editAreas[id];
282
-
283
283
  },
284
284
 
285
285
 
286
286
  start : function(id){
287
+ var t=this,d=document,f,span,father,next,html='',html_toolbar_content='',template,content,i;
288
+
287
289
  // check that the window is loaded
288
- if(this.win!="loaded"){
290
+ if(t.win!="loaded"){
289
291
  setTimeout("editAreaLoader.start('"+id+"');", 50);
290
292
  return;
291
293
  }
292
294
 
293
295
  // check that all needed scripts are loaded
294
- for(var i in editAreaLoader.waiting_loading){
295
- if(editAreaLoader.waiting_loading[i]!="loaded" && typeof(editAreaLoader.waiting_loading[i])!="function"){
296
+ for( i in t.waiting_loading){
297
+ if(t.waiting_loading[i]!="loaded" && typeof(t.waiting_loading[i])!="function"){
296
298
  setTimeout("editAreaLoader.start('"+id+"');", 50);
297
299
  return;
298
300
  }
299
301
  }
300
302
 
301
303
  // wait until language and syntax files are loaded
302
- if(!editAreaLoader.lang[editAreas[id]["settings"]["language"]] || (editAreas[id]["settings"]["syntax"].length>0 && !editAreaLoader.load_syntax[editAreas[id]["settings"]["syntax"]]) ){
304
+ if(!t.lang[editAreas[id]["settings"]["language"]] || (editAreas[id]["settings"]["syntax"].length>0 && !t.load_syntax[editAreas[id]["settings"]["syntax"]]) ){
303
305
  setTimeout("editAreaLoader.start('"+id+"');", 50);
304
306
  return;
305
307
  }
306
308
  // init the regexp for syntax highlight
307
309
  if(editAreas[id]["settings"]["syntax"].length>0)
308
- editAreaLoader.init_syntax_regexp();
310
+ t.init_syntax_regexp();
309
311
 
310
312
 
311
313
  // display toggle option and debug area
312
- if(!document.getElementById("EditAreaArroundInfos_"+id) && (editAreas[id]["settings"]["debug"] || editAreas[id]["settings"]["allow_toggle"]))
314
+ if(!d.getElementById("EditAreaArroundInfos_"+id) && (editAreas[id]["settings"]["debug"] || editAreas[id]["settings"]["allow_toggle"]))
313
315
  {
314
- var span= document.createElement("span");
316
+ span= d.createElement("span");
315
317
  span.id= "EditAreaArroundInfos_"+id;
316
- var html="";
317
318
  if(editAreas[id]["settings"]["allow_toggle"]){
318
- checked=(editAreas[id]["settings"]["display"]=="onload")?"checked":"";
319
+ checked=(editAreas[id]["settings"]["display"]=="onload")?"checked='checked'":"";
319
320
  html+="<div id='edit_area_toggle_"+i+"'>";
320
321
  html+="<input id='edit_area_toggle_checkbox_"+ id +"' class='toggle_"+ id +"' type='checkbox' onclick='editAreaLoader.toggle(\""+ id +"\");' accesskey='e' "+checked+" />";
321
322
  html+="<label for='edit_area_toggle_checkbox_"+ id +"'>{$toggle}</label></div>";
322
323
  }
323
324
  if(editAreas[id]["settings"]["debug"])
324
- html+="<textarea id='edit_area_debug_"+ id +"' style='z-index: 20; width: 100%; height: 120px;overflow: auto; border: solid black 1px;'></textarea><br />";
325
- html= editAreaLoader.translate(html, editAreas[id]["settings"]["language"]);
325
+ html+="<textarea id='edit_area_debug_"+ id +"' spellcheck='off' style='z-index: 20; width: 100%; height: 120px;overflow: auto; border: solid black 1px;'></textarea><br />";
326
+ html= t.translate(html, editAreas[id]["settings"]["language"]);
326
327
  span.innerHTML= html;
327
- var father= document.getElementById(id).parentNode;
328
- var next= document.getElementById(id).nextSibling;
328
+ father= d.getElementById(id).parentNode;
329
+ next= d.getElementById(id).nextSibling;
329
330
  if(next==null)
330
331
  father.appendChild(span);
331
332
  else
@@ -334,68 +335,70 @@ EditAreaLoader.prototype ={
334
335
 
335
336
  if(!editAreas[id]["initialized"])
336
337
  {
337
- this.execCommand(id, "EA_init"); // ini callback
338
+ t.execCommand(id, "EA_init"); // ini callback
338
339
  if(editAreas[id]["settings"]["display"]=="later"){
339
340
  editAreas[id]["initialized"]= true;
340
341
  return;
341
342
  }
342
343
  }
343
344
 
344
- if(this.nav['isIE']){ // launch IE selection checkup
345
- editAreaLoader.init_ie_textarea(id);
345
+ if(t.isIE){ // launch IE selection checkup
346
+ t.init_ie_textarea(id);
346
347
  }
347
348
 
348
349
  // get toolbar content
349
- var html_toolbar_content="";
350
350
  area=editAreas[id];
351
351
 
352
- for(var i=0; i<area["settings"]["tab_toolbar"].length; i++){
352
+ for(i=0; i<area["settings"]["tab_toolbar"].length; i++){
353
353
  // alert(this.tab_toolbar[i]+"\n"+ this.get_control_html(this.tab_toolbar[i]));
354
- html_toolbar_content+= this.get_control_html(area["settings"]["tab_toolbar"][i], area["settings"]["language"]);
354
+ html_toolbar_content+= t.get_control_html(area["settings"]["tab_toolbar"][i], area["settings"]["language"]);
355
355
  }
356
+ // translate toolbar text here for chrome 2
357
+ html_toolbar_content = t.translate(html_toolbar_content, area["settings"]["language"], "template");
358
+
356
359
 
357
360
  // create javascript import rules for the iframe if the javascript has not been already loaded by the compressor
358
- if(!this.iframe_script){
359
- this.iframe_script="";
360
- for(var i=0; i<this.sub_scripts_to_load.length; i++)
361
- this.iframe_script+='<script language="javascript" type="text/javascript" src="'+ this.baseURL + this.sub_scripts_to_load[i] +'.js"></script>';
361
+ if(!t.iframe_script){
362
+ t.iframe_script="";
363
+ for(i=0; i<t.sub_scripts_to_load.length; i++)
364
+ t.iframe_script+='<script language="javascript" type="text/javascript" src="'+ t.baseURL + t.sub_scripts_to_load[i] +'.js"></script>';
362
365
  }
363
366
 
364
367
  // add plugins scripts if not already loaded by the compressor (but need to load language in all the case)
365
- for(var i=0; i<area["settings"]["plugins"].length; i++){
368
+ for(i=0; i<area["settings"]["plugins"].length; i++){
366
369
  //if(typeof(area["settings"]["plugins"][i])=="function") continue;
367
- if(!editAreaLoader.all_plugins_loaded)
368
- this.iframe_script+='<script language="javascript" type="text/javascript" src="'+ this.baseURL + 'plugins/' + area["settings"]["plugins"][i] + '/' + area["settings"]["plugins"][i] +'.js"></script>';
369
- this.iframe_script+='<script language="javascript" type="text/javascript" src="'+ this.baseURL + 'plugins/' + area["settings"]["plugins"][i] + '/langs/' + area["settings"]["language"] +'.js"></script>';
370
+ if(!t.all_plugins_loaded)
371
+ t.iframe_script+='<script language="javascript" type="text/javascript" src="'+ t.baseURL + 'plugins/' + area["settings"]["plugins"][i] + '/' + area["settings"]["plugins"][i] +'.js"></script>';
372
+ t.iframe_script+='<script language="javascript" type="text/javascript" src="'+ t.baseURL + 'plugins/' + area["settings"]["plugins"][i] + '/langs/' + area["settings"]["language"] +'.js"></script>';
370
373
  }
371
374
 
372
375
 
373
376
  // create css link for the iframe if the whole css text has not been already loaded by the compressor
374
- if(!this.iframe_css){
375
- this.iframe_css="<link href='"+ this.baseURL +"edit_area.css' rel='stylesheet' type='text/css' />";
377
+ if(!t.iframe_css){
378
+ t.iframe_css="<link href='"+ t.baseURL +"edit_area.css' rel='stylesheet' type='text/css' />";
376
379
  }
377
380
 
378
381
 
379
382
  // create template
380
- var template= this.template.replace(/\[__BASEURL__\]/g, this.baseURL);
383
+ template= t.template.replace(/\[__BASEURL__\]/g, t.baseURL);
381
384
  template= template.replace("[__TOOLBAR__]",html_toolbar_content);
382
385
 
383
386
 
384
387
  // fill template with good language sentences
385
- template= this.translate(template, area["settings"]["language"], "template");
388
+ template= t.translate(template, area["settings"]["language"], "template");
386
389
 
387
390
  // add css_code
388
- template= template.replace("[__CSSRULES__]", this.iframe_css);
391
+ template= template.replace("[__CSSRULES__]", t.iframe_css);
389
392
  // add js_code
390
- template= template.replace("[__JSCODE__]", this.iframe_script);
393
+ template= template.replace("[__JSCODE__]", t.iframe_script);
391
394
 
392
395
  // add version_code
393
- template= template.replace("[__EA_VERSION__]", this.version);
396
+ template= template.replace("[__EA_VERSION__]", t.version);
394
397
  //template=template.replace(/\{\$([^\}]+)\}/gm, this.traduc_template);
395
398
 
396
399
  //editAreas[area["settings"]["id"]]["template"]= template;
397
400
 
398
- area.textarea=document.getElementById(area["settings"]["id"]);
401
+ area.textarea=d.getElementById(area["settings"]["id"]);
399
402
  editAreas[area["settings"]["id"]]["textarea"]=area.textarea;
400
403
 
401
404
  // if removing previous instances from DOM before (fix from Marcin)
@@ -403,38 +406,31 @@ EditAreaLoader.prototype ={
403
406
  delete window.frames["frame_"+area["settings"]["id"]];
404
407
 
405
408
  // insert template in the document after the textarea
406
- var father= area.textarea.parentNode;
409
+ father= area.textarea.parentNode;
407
410
  /* var container= document.createElement("div");
408
411
  container.id= "EditArea_frame_container_"+area["settings"]["id"];
409
412
  */
410
- var content= document.createElement("iframe");
413
+ content= d.createElement("iframe");
411
414
  content.name= "frame_"+area["settings"]["id"];
412
415
  content.id= "frame_"+area["settings"]["id"];
413
416
  content.style.borderWidth= "0px";
414
417
  setAttribute(content, "frameBorder", "0"); // IE
415
418
  content.style.overflow="hidden";
416
419
  content.style.display="none";
420
+
417
421
 
418
- /* container.appendChild(content);
419
- var next= area.textarea.nextSibling;
420
- if(next==null)
421
- father.appendChild(container);
422
- else
423
- father.insertBefore(container, next) ;*/
424
-
425
- var next= area.textarea.nextSibling;
422
+ next= area.textarea.nextSibling;
426
423
  if(next==null)
427
424
  father.appendChild(content);
428
425
  else
429
426
  father.insertBefore(content, next) ;
430
- var frame=window.frames["frame_"+area["settings"]["id"]];
431
-
432
- frame.document.open();
433
- frame.editAreas=editAreas;
434
- frame.area_id= area["settings"]["id"];
435
- frame.document.area_id= area["settings"]["id"];
436
- frame.document.write(template);
437
- frame.document.close();
427
+ f=window.frames["frame_"+area["settings"]["id"]];
428
+ f.document.open();
429
+ f.editAreas=editAreas;
430
+ f.area_id= area["settings"]["id"];
431
+ f.document.area_id= area["settings"]["id"];
432
+ f.document.write(template);
433
+ f.document.close();
438
434
 
439
435
  // frame.editAreaLoader=this;
440
436
  //editAreas[area["settings"]["id"]]["displayed"]=true;
@@ -459,97 +455,97 @@ EditAreaLoader.prototype ={
459
455
  return false;
460
456
  },
461
457
 
458
+ // static function
462
459
  toggle_off : function(id){
463
- if(window.frames["frame_"+id])
460
+ var fs=window.frames,f,t,parNod,nxtSib,selStart,selEnd,scrollTop,scrollLeft;
461
+ if(fs["frame_"+id])
464
462
  {
465
- var frame=window.frames["frame_"+id];
466
- if(frame.editArea.fullscreen['isFull'])
467
- frame.editArea.toggle_full_screen(false);
463
+ f = fs["frame_"+id];
464
+ t = editAreas[id]["textarea"];
465
+ if(f.editArea.fullscreen['isFull'])
466
+ f.editArea.toggle_full_screen(false);
468
467
  editAreas[id]["displayed"]=false;
469
468
 
470
- // set wrap to off to keep same display mode (some browser get problem with this, so it need more complex operation
471
-
472
- editAreas[id]["textarea"].wrap = "off"; // for IE
473
- setAttribute(editAreas[id]["textarea"], "wrap", "off"); // for Firefox
474
- var parNod = editAreas[id]["textarea"].parentNode;
475
- var nxtSib = editAreas[id]["textarea"].nextSibling;
476
- parNod.removeChild(editAreas[id]["textarea"]);
477
- parNod.insertBefore(editAreas[id]["textarea"], nxtSib);
469
+ // set wrap to off to keep same display mode (some browser get problem with this, so it need more complex operation
470
+ t.wrap = "off"; // for IE
471
+ setAttribute(t, "wrap", "off"); // for Firefox
472
+ parNod = t.parentNode;
473
+ nxtSib = t.nextSibling;
474
+ parNod.removeChild(t);
475
+ parNod.insertBefore(t, nxtSib);
478
476
 
479
477
  // restore values
480
- editAreas[id]["textarea"].value= frame.editArea.textarea.value;
481
- var selStart= frame.editArea.last_selection["selectionStart"];
482
- var selEnd= frame.editArea.last_selection["selectionEnd"];
483
- var scrollTop= frame.document.getElementById("result").scrollTop;
484
- var scrollLeft= frame.document.getElementById("result").scrollLeft;
478
+ t.value= f.editArea.textarea.value;
479
+ selStart = f.editArea.last_selection["selectionStart"];
480
+ selEnd = f.editArea.last_selection["selectionEnd"];
481
+ scrollTop = f.document.getElementById("result").scrollTop;
482
+ scrollLeft = f.document.getElementById("result").scrollLeft;
485
483
 
486
484
 
487
485
  document.getElementById("frame_"+id).style.display='none';
488
486
 
489
- editAreas[id]["textarea"].style.display="inline";
490
-
487
+ t.style.display="inline";
491
488
 
492
- editAreas[id]["textarea"].focus();
493
- if(this.nav['isIE']){
494
- editAreas[id]["textarea"].selectionStart= selStart;
495
- editAreas[id]["textarea"].selectionEnd= selEnd;
496
- editAreas[id]["textarea"].focused=true;
497
- set_IE_selection(editAreas[id]["textarea"]);
489
+ try{ // IE will give an error when trying to focus an invisible or disabled textarea
490
+ t.focus();
491
+ } catch(e){};
492
+ if(this.isIE){
493
+ t.selectionStart= selStart;
494
+ t.selectionEnd = selEnd;
495
+ t.focused = true;
496
+ set_IE_selection(t);
498
497
  }else{
499
- if(this.nav['isOpera']){ // Opera bug when moving selection start and selection end
500
- editAreas[id]["textarea"].setSelectionRange(0, 0);
498
+ if(this.isOpera && this.isOpera < 9.6 ){ // Opera bug when moving selection start and selection end
499
+ t.setSelectionRange(0, 0);
501
500
  }
502
501
  try{
503
- editAreas[id]["textarea"].setSelectionRange(selStart, selEnd);
504
- } catch(e) {
505
- };
502
+ t.setSelectionRange(selStart, selEnd);
503
+ } catch(e) {};
506
504
  }
507
- editAreas[id]["textarea"].scrollTop= scrollTop;
508
- editAreas[id]["textarea"].scrollLeft= scrollLeft;
509
- frame.editArea.execCommand("toggle_off");
505
+ t.scrollTop= scrollTop;
506
+ t.scrollLeft= scrollLeft;
507
+ f.editArea.execCommand("toggle_off");
510
508
 
511
509
  }
512
510
  },
513
511
 
512
+ // static function
514
513
  toggle_on : function(id){
515
- /*if(!editAreas[area["settings"]["id"]]["started"])
516
- editAreaLoader.start(id);*/
514
+ var fs=window.frames,f,t,selStart=0,selEnd=0,scrollTop=0,scrollLeft=0,curPos,elem;
517
515
 
518
- if(window.frames["frame_"+id])
516
+ if(fs["frame_"+id])
519
517
  {
520
- var frame=window.frames["frame_"+id];
521
- area= window.frames["frame_"+id].editArea;
522
- area.textarea.value= editAreas[id]["textarea"].value;
518
+ f = fs["frame_"+id];
519
+ t = editAreas[id]["textarea"];
520
+ area= f.editArea;
521
+ area.textarea.value= t.value;
523
522
 
524
523
  // store display values;
525
- var selStart= 0;
526
- var selEnd= 0;
527
- var scrollTop= 0;
528
- var scrollLeft= 0;
524
+ curPos = editAreas[id]["settings"]["cursor_position"];
529
525
 
530
- if(editAreas[id]["textarea"].use_last==true)
526
+ if(t.use_last==true)
531
527
  {
532
- var selStart= editAreas[id]["textarea"].last_selectionStart;
533
- var selEnd= editAreas[id]["textarea"].last_selectionEnd;
534
- var scrollTop= editAreas[id]["textarea"].last_scrollTop;
535
- var scrollLeft= editAreas[id]["textarea"].last_scrollLeft;
536
- editAreas[id]["textarea"].use_last=false;
528
+ selStart = t.last_selectionStart;
529
+ selEnd = t.last_selectionEnd;
530
+ scrollTop = t.last_scrollTop;
531
+ scrollLeft = t.last_scrollLeft;
532
+ t.use_last=false;
537
533
  }
538
- else
534
+ else if( curPos == "auto" )
539
535
  {
540
536
  try{
541
- var selStart= editAreas[id]["textarea"].selectionStart;
542
- var selEnd= editAreas[id]["textarea"].selectionEnd;
543
- var scrollTop= editAreas[id]["textarea"].scrollTop;
544
- var scrollLeft= editAreas[id]["textarea"].scrollLeft;
537
+ selStart = t.selectionStart;
538
+ selEnd = t.selectionEnd;
539
+ scrollTop = t.scrollTop;
540
+ scrollLeft = t.scrollLeft;
545
541
  //alert(scrollTop);
546
542
  }catch(ex){}
547
543
  }
548
544
 
549
545
  // set to good size
550
546
  this.set_editarea_size_from_textarea(id, document.getElementById("frame_"+id));
551
- editAreas[id]["textarea"].style.display="none";
552
- document.getElementById("frame_"+id).style.display="inline";
547
+ t.style.display="none";
548
+ document.getElementById("frame_"+id).style.display="block"; //"inline";
553
549
  area.execCommand("focus"); // without this focus opera doesn't manage well the iframe body height
554
550
 
555
551
 
@@ -557,21 +553,18 @@ EditAreaLoader.prototype ={
557
553
  editAreas[id]["displayed"]=true;
558
554
  area.execCommand("update_size");
559
555
 
560
- window.frames["frame_"+id].document.getElementById("result").scrollTop= scrollTop;
561
- window.frames["frame_"+id].document.getElementById("result").scrollLeft= scrollLeft;
556
+ f.document.getElementById("result").scrollTop= scrollTop;
557
+ f.document.getElementById("result").scrollLeft= scrollLeft;
562
558
  area.area_select(selStart, selEnd-selStart);
563
559
  area.execCommand("toggle_on");
564
560
 
565
- /*date= new Date();
566
- end_time=date.getTime();
567
- alert("load time: "+ (end_time-this.start_time));*/
568
561
 
569
562
  }
570
563
  else
571
564
  {
572
- /* if(this.nav['isIE'])
565
+ /* if(this.isIE)
573
566
  get_IE_selection(document.getElementById(id)); */
574
- var elem= document.getElementById(id);
567
+ elem= document.getElementById(id);
575
568
  elem.last_selectionStart= elem.selectionStart;
576
569
  elem.last_selectionEnd= elem.selectionEnd;
577
570
  elem.last_scrollTop= elem.scrollTop;
@@ -582,15 +575,15 @@ EditAreaLoader.prototype ={
582
575
  },
583
576
 
584
577
  set_editarea_size_from_textarea : function(id, frame){
585
- var elem= document.getElementById(id);
586
- //var width= elem.offsetWidth+"px";
587
- //var height= elem.offsetHeight+"px";
588
- var width=Math.max(editAreas[id]["settings"]["min_width"], elem.offsetWidth)+"px";
589
- var height=Math.max(editAreas[id]["settings"]["min_height"], elem.offsetHeight)+"px";
578
+ var elem,width,height;
579
+ elem = document.getElementById(id);
580
+
581
+ width = Math.max(editAreas[id]["settings"]["min_width"], elem.offsetWidth)+"px";
582
+ height = Math.max(editAreas[id]["settings"]["min_height"], elem.offsetHeight)+"px";
590
583
  if(elem.style.width.indexOf("%")!=-1)
591
- width= elem.style.width;
584
+ width = elem.style.width;
592
585
  if(elem.style.height.indexOf("%")!=-1)
593
- height= elem.style.height;
586
+ height = elem.style.height;
594
587
  //alert("h: "+height+" w: "+width);
595
588
 
596
589
  frame.style.width= width;
@@ -598,52 +591,53 @@ EditAreaLoader.prototype ={
598
591
  },
599
592
 
600
593
  set_base_url : function(){
601
- //this.baseURL="";
602
- if (!this.baseURL) {
603
- var elements = document.getElementsByTagName('script');
594
+ var t=this,elems,i,docBasePath;
595
+
596
+ if( !this.baseURL ){
597
+ elems = document.getElementsByTagName('script');
604
598
 
605
- for (var i=0; i<elements.length; i++) {
606
- if (elements[i].src && elements[i].src.match(/edit_area_[^\\\/]*$/i) ) {
607
- var src = elements[i].src;
599
+ for( i=0; i<elems.length; i++ ){
600
+ if (elems[i].src && elems[i].src.match(/edit_area_[^\\\/]*$/i) ) {
601
+ var src = elems[i].src;
608
602
  src = src.substring(0, src.lastIndexOf('/'));
609
603
  this.baseURL = src;
610
- this.file_name= elements[i].src.substr(elements[i].src.lastIndexOf("/")+1);
604
+ this.file_name= elems[i].src.substr(elems[i].src.lastIndexOf("/")+1);
611
605
  break;
612
606
  }
613
607
  }
614
608
  }
615
609
 
616
- var documentBasePath = document.location.href;
617
- if (documentBasePath.indexOf('?') != -1)
618
- documentBasePath = documentBasePath.substring(0, documentBasePath.indexOf('?'));
619
- var documentURL = documentBasePath;
620
- documentBasePath = documentBasePath.substring(0, documentBasePath.lastIndexOf('/'));
610
+ docBasePath = document.location.href;
611
+ if (docBasePath.indexOf('?') != -1)
612
+ docBasePath = docBasePath.substring(0, docBasePath.indexOf('?'));
613
+ docBasePath = docBasePath.substring(0, docBasePath.lastIndexOf('/'));
621
614
 
622
615
  // If not HTTP absolute
623
- if (this.baseURL.indexOf('://') == -1 && this.baseURL.charAt(0) != '/') {
616
+ if (t.baseURL.indexOf('://') == -1 && t.baseURL.charAt(0) != '/') {
624
617
  // If site absolute
625
- this.baseURL = documentBasePath + "/" + this.baseURL;
618
+ t.baseURL = docBasePath + "/" + t.baseURL;
626
619
  }
627
- this.baseURL+="/";
620
+ t.baseURL +="/";
628
621
  },
629
622
 
630
623
  get_button_html : function(id, img, exec, isFileSpecific, baseURL) {
624
+ var cmd,html;
631
625
  if(!baseURL)
632
626
  baseURL= this.baseURL;
633
- var cmd = 'editArea.execCommand(\'' + exec + '\')';
634
- html= '<a id="a_'+ id +'" href="javascript:' + cmd + '" onclick="' + cmd + ';return false;" onmousedown="return false;" target="_self" fileSpecific="'+ (isFileSpecific?'yes':'no') +'">';
635
- html+= '<img id="' + id + '" src="'+ baseURL +'images/' + img + '" title="{$' + id + '}" width="20" height="20" class="editAreaButtonNormal" onmouseover="editArea.switchClass(this,\'editAreaButtonOver\');" onmouseout="editArea.restoreClass(this);" onmousedown="editArea.restoreAndSwitchClass(this,\'editAreaButtonDown\');" /></a>';
627
+ cmd = 'editArea.execCommand(\'' + exec + '\')';
628
+ html = '<a id="a_'+ id +'" href="javascript:' + cmd + '" onclick="' + cmd + ';return false;" onmousedown="return false;" target="_self" fileSpecific="'+ (isFileSpecific?'yes':'no') +'">';
629
+ html += '<img id="' + id + '" src="'+ baseURL +'images/' + img + '" title="{$' + id + '}" class="editAreaButtonNormal" onmouseover="editArea.switchClass(this,\'editAreaButtonOver\');" onmouseout="editArea.restoreClass(this);" onmousedown="editArea.restoreAndSwitchClass(this,\'editAreaButtonDown\');" /></a>';
636
630
  return html;
637
631
  },
638
632
 
639
633
  get_control_html : function(button_name, lang) {
640
-
641
- for (var i=0; i<this.advanced_buttons.length; i++)
634
+ var t=this,i,but,html,si;
635
+ for (i=0; i<t.advanced_buttons.length; i++)
642
636
  {
643
- var but = this.advanced_buttons[i];
637
+ but = t.advanced_buttons[i];
644
638
  if (but[0] == button_name)
645
639
  {
646
- return this.get_button_html(but[0], but[1], but[2], but[3]);
640
+ return t.get_button_html(but[0], but[1], but[2], but[3]);
647
641
  }
648
642
  }
649
643
 
@@ -653,20 +647,18 @@ EditAreaLoader.prototype ={
653
647
  return "<br />";
654
648
  case "|":
655
649
  case "separator":
656
- return '<img src="'+ this.baseURL +'images/spacer.gif" width="1" height="15" class="editAreaSeparatorLine">';
650
+ return '<img src="'+ t.baseURL +'images/spacer.gif" width="1" height="15" class="editAreaSeparatorLine">';
657
651
  case "select_font":
658
- html= "<select id='area_font_size' onchange='javascript:editArea.execCommand(\"change_font_size\")' fileSpecific='yes'>"
659
- +"<option value='-1'>{$font_size}</option>"
660
- +"<option value='8'>8 pt</option>"
661
- +"<option value='9'>9 pt</option>"
662
- +"<option value='10'>10 pt</option>"
663
- +"<option value='11'>11 pt</option>"
664
- +"<option value='12'>12 pt</option>"
665
- +"<option value='14'>14 pt</option>"
666
- +"</select>";
652
+ html= "<select id='area_font_size' onchange='javascript:editArea.execCommand(\"change_font_size\")' fileSpecific='yes'>";
653
+ html+="<option value='-1'>{$font_size}</option>";
654
+ si=[8,9,10,11,12,14];
655
+ for( i=0;i<si.length;i++){
656
+ html+="<option value='"+si[i]+"'>"+si[i]+" pt</option>";
657
+ }
658
+ html+="</select>";
667
659
  return html;
668
660
  case "syntax_selection":
669
- var html= "<select id='syntax_selection' onchange='javascript:editArea.execCommand(\"change_syntax\", this.value)' fileSpecific='yes'>";
661
+ html= "<select id='syntax_selection' onchange='javascript:editArea.execCommand(\"change_syntax\", this.value)' fileSpecific='yes'>";
670
662
  html+="<option value='-1'>{$syntax_selection}</option>";
671
663
  html+="</select>";
672
664
  return html;
@@ -700,7 +692,6 @@ EditAreaLoader.prototype ={
700
692
 
701
693
  // translate text
702
694
  translate : function(text, lang, mode){
703
-
704
695
  if(mode=="word")
705
696
  text=editAreaLoader.get_word_translation(text, lang);
706
697
  else if(mode="template"){
@@ -715,7 +706,9 @@ EditAreaLoader.prototype ={
715
706
  },
716
707
 
717
708
  get_word_translation : function(val, lang){
718
- for(var i in editAreaLoader.lang[lang]){
709
+ var i;
710
+
711
+ for( i in editAreaLoader.lang[lang]){
719
712
  if(i == val)
720
713
  return editAreaLoader.lang[lang][i];
721
714
  }
@@ -723,48 +716,57 @@ EditAreaLoader.prototype ={
723
716
  },
724
717
 
725
718
  load_script : function(url){
726
- if (this.loadedFiles[url])
719
+ try {
720
+ var t=this,d=document,script,head;
721
+
722
+ if( t.loadedFiles[url] )
727
723
  return;
728
724
  //alert("load: "+url);
729
725
  try{
730
- var script= document.createElement("script");
726
+ script= d.createElement("script");
731
727
  script.type= "text/javascript";
732
728
  script.src= url;
733
729
  script.charset= "UTF-8";
734
- var head= document.getElementsByTagName("head");
735
- head[0].appendChild(script);
730
+ d.getElementsByTagName("head")[0].appendChild(script);
736
731
  }catch(e){
737
- document.write('<sc'+'ript language="javascript" type="text/javascript" src="' + url + '" charset="UTF-8"></sc'+'ript>');
732
+ d.write('<sc'+'ript language="javascript" type="text/javascript" src="' + url + '" charset="UTF-8"></sc'+'ript>');
738
733
  }
739
- //var filename= url.replace(/^.*?\/?([a-z\.\_\-]+)$/i, "$1");
740
- this.loadedFiles[url] = true;
734
+
735
+ t.loadedFiles[url] = true;
736
+ } catch (e) { debug(e); }
741
737
  },
742
738
 
743
739
  add_event : function(obj, name, handler) {
744
- if (obj.attachEvent) {
745
- obj.attachEvent("on" + name, handler);
746
- } else{
747
- obj.addEventListener(name, handler, false);
748
- }
740
+ try{
741
+ if (obj.attachEvent) {
742
+ obj.attachEvent("on" + name, handler);
743
+ } else{
744
+ obj.addEventListener(name, handler, false);
745
+ }
746
+ }catch(e){}
749
747
  },
750
748
 
751
749
  remove_event : function(obj, name, handler){
752
- if (obj.detachEvent)
753
- obj.detachEvent("on" + name, handler);
754
- else
755
- obj.removeEventListener(name, handler, false);
750
+ try{
751
+ if (obj.detachEvent)
752
+ obj.detachEvent("on" + name, handler);
753
+ else
754
+ obj.removeEventListener(name, handler, false);
755
+ }catch(e){}
756
756
  },
757
757
 
758
758
 
759
759
  // reset all the editareas in the form that have been reseted
760
760
  reset : function(e){
761
- var formObj = editAreaLoader.nav['isIE'] ? window.event.srcElement : e.target;
761
+ var formObj,is_child,i,x;
762
+
763
+ formObj = editAreaLoader.isIE ? window.event.srcElement : e.target;
762
764
  if(formObj.tagName!='FORM')
763
765
  formObj= formObj.form;
764
766
 
765
- for(var i in editAreas){
766
- var is_child= false;
767
- for (var x=0;x<formObj.elements.length;x++) {
767
+ for( i in editAreas ){
768
+ is_child= false;
769
+ for( x=0;x<formObj.elements.length;x++ ) {
768
770
  if(formObj.elements[x].id == i)
769
771
  is_child=true;
770
772
  }
@@ -784,34 +786,35 @@ EditAreaLoader.prototype ={
784
786
 
785
787
  // prepare all the textarea replaced by an editarea to be submited
786
788
  submit : function(e){
787
- var formObj = editAreaLoader.nav['isIE'] ? window.event.srcElement : e.target;
789
+ var formObj,is_child,fs=window.frames,i,x;
790
+ formObj = editAreaLoader.isIE ? window.event.srcElement : e.target;
788
791
  if(formObj.tagName!='FORM')
789
792
  formObj= formObj.form;
790
793
 
791
- for(var i in editAreas){
792
- var is_child= false;
793
- for (var x=0;x<formObj.elements.length;x++) {
794
+ for( i in editAreas){
795
+ is_child= false;
796
+ for( x=0;x<formObj.elements.length;x++ ) {
794
797
  if(formObj.elements[x].id == i)
795
798
  is_child=true;
796
799
  }
797
800
 
798
801
  if(is_child)
799
802
  {
800
- if(window.frames["frame_"+i] && editAreas[i]["displayed"]==true)
801
- document.getElementById(i).value= window.frames["frame_"+ i].editArea.textarea.value;
803
+ if(fs["frame_"+i] && editAreas[i]["displayed"]==true)
804
+ document.getElementById(i).value= fs["frame_"+ i].editArea.textarea.value;
802
805
  editAreaLoader.execCommand(i,"EA_submit");
803
806
  }
804
807
  }
805
- if(typeof(formObj.edit_area_replaced_submit) == "function"){
808
+ if( typeof(formObj.edit_area_replaced_submit) == "function" ){
806
809
  res= formObj.edit_area_replaced_submit();
807
810
  if(res==false){
808
- if(editAreaLoader.nav['isIE'])
811
+ if(editAreaLoader.isIE)
809
812
  return false;
810
813
  else
811
814
  e.preventDefault();
812
815
  }
813
816
  }
814
- return ;
817
+ return;
815
818
  },
816
819
 
817
820
  // allow to get the value of the editarea
@@ -826,11 +829,13 @@ EditAreaLoader.prototype ={
826
829
 
827
830
  // allow to set the value of the editarea
828
831
  setValue : function(id, new_val){
829
- if(window.frames["frame_"+id] && editAreas[id]["displayed"]==true){
830
- window.frames["frame_"+ id].editArea.textarea.value= new_val;
831
- window.frames["frame_"+ id].editArea.execCommand("focus");
832
- window.frames["frame_"+ id].editArea.check_line_selection(false);
833
- window.frames["frame_"+ id].editArea.execCommand("onchange");
832
+ var fs=window.frames;
833
+
834
+ if( ( f=fs["frame_"+id] ) && editAreas[id]["displayed"]==true){
835
+ f.editArea.textarea.value= new_val;
836
+ f.editArea.execCommand("focus");
837
+ f.editArea.check_line_selection(false);
838
+ f.editArea.execCommand("onchange");
834
839
  }else if(elem=document.getElementById(id)){
835
840
  elem.value= new_val;
836
841
  }
@@ -838,21 +843,16 @@ EditAreaLoader.prototype ={
838
843
 
839
844
  // allow to get infos on the selection: array(start, end)
840
845
  getSelectionRange : function(id){
841
- var sel= {"start": 0, "end": 0};
842
- if(window.frames["frame_"+id] && editAreas[id]["displayed"]==true){
843
- var editArea= window.frames["frame_"+ id].editArea;
844
-
845
- /* if(this.nav['isIE']){
846
- editArea.getIESelection();
847
-
848
- }
849
- sel["start"]=editArea.textarea.selectionStart;
850
- sel["end"]=editArea.textarea.selectionEnd;
851
- */
852
- sel["start"]=editArea.textarea.selectionStart;
853
- sel["end"]=editArea.textarea.selectionEnd;
846
+ var sel,eA,fs=window.frames;
847
+
848
+ sel= {"start": 0, "end": 0};
849
+ if(fs["frame_"+id] && editAreas[id]["displayed"]==true){
850
+ eA= fs["frame_"+ id].editArea;
851
+
852
+ sel["start"] = eA.textarea.selectionStart;
853
+ sel["end"] = eA.textarea.selectionEnd;
854
854
 
855
- }else if(elem=document.getElementById(id)){
855
+ }else if( elem=document.getElementById(id) ){
856
856
  sel= getSelectionRange(elem);
857
857
  }
858
858
  return sel;
@@ -860,12 +860,14 @@ EditAreaLoader.prototype ={
860
860
 
861
861
  // allow to set the selection with the given start and end positions
862
862
  setSelectionRange : function(id, new_start, new_end){
863
- if(window.frames["frame_"+id] && editAreas[id]["displayed"]==true){
864
- window.frames["frame_"+ id].editArea.area_select(new_start, new_end-new_start);
863
+ var fs=window.frames;
864
+
865
+ if(fs["frame_"+id] && editAreas[id]["displayed"]==true){
866
+ fs["frame_"+ id].editArea.area_select(new_start, new_end-new_start);
865
867
  // make an auto-scroll to the selection
866
- if(!this.nav['isIE']){
867
- window.frames["frame_"+ id].editArea.check_line_selection(false);
868
- window.frames["frame_"+ id].editArea.scroll_to_view();
868
+ if(!this.isIE){
869
+ fs["frame_"+ id].editArea.check_line_selection(false);
870
+ fs["frame_"+ id].editArea.scroll_to_view();
869
871
  }
870
872
  }else if(elem=document.getElementById(id)){
871
873
  setSelectionRange(elem, new_start, new_end);
@@ -874,24 +876,27 @@ EditAreaLoader.prototype ={
874
876
 
875
877
  getSelectedText : function(id){
876
878
  var sel= this.getSelectionRange(id);
879
+
877
880
  return this.getValue(id).substring(sel["start"], sel["end"]);
878
881
  },
879
882
 
880
883
  setSelectedText : function(id, new_val){
881
- new_val= new_val.replace(/\r/g, "");
882
- var sel= this.getSelectionRange(id);
883
- var text= this.getValue(id);
884
- if(window.frames["frame_"+id] && editAreas[id]["displayed"]==true){
885
- var scrollTop= window.frames["frame_"+ id].document.getElementById("result").scrollTop;
886
- var scrollLeft= window.frames["frame_"+ id].document.getElementById("result").scrollLeft;
884
+ var fs=window.frames,d=document,sel,text,scrollTop,scrollLeft,new_sel_end;
885
+
886
+ new_val = new_val.replace(/\r/g, "");
887
+ sel = this.getSelectionRange(id);
888
+ text = this.getValue(id);
889
+ if(fs["frame_"+id] && editAreas[id]["displayed"]==true){
890
+ scrollTop = fs["frame_"+ id].document.getElementById("result").scrollTop;
891
+ scrollLeft = fs["frame_"+ id].document.getElementById("result").scrollLeft;
887
892
  }else{
888
- var scrollTop= document.getElementById(id).scrollTop;
889
- var scrollLeft= document.getElementById(id).scrollLeft;
893
+ scrollTop = d.getElementById(id).scrollTop;
894
+ scrollLeft = d.getElementById(id).scrollLeft;
890
895
  }
891
896
 
892
- text= text.substring(0, sel["start"])+ new_val +text.substring(sel["end"]);
897
+ text = text.substring(0, sel["start"])+ new_val +text.substring(sel["end"]);
893
898
  this.setValue(id, text);
894
- var new_sel_end= sel["start"]+ new_val.length;
899
+ new_sel_end = sel["start"]+ new_val.length;
895
900
  this.setSelectionRange(id, sel["start"], new_sel_end);
896
901
 
897
902
 
@@ -900,21 +905,25 @@ EditAreaLoader.prototype ={
900
905
  this.setSelectionRange(id, sel["start"], new_sel_end+ new_val.split("\n").length -1);
901
906
  }
902
907
  // restore scrolling position
903
- if(window.frames["frame_"+id] && editAreas[id]["displayed"]==true){
904
- window.frames["frame_"+ id].document.getElementById("result").scrollTop= scrollTop;
905
- window.frames["frame_"+ id].document.getElementById("result").scrollLeft= scrollLeft;
906
- window.frames["frame_"+ id].editArea.execCommand("onchange");
908
+ if(fs["frame_"+id] && editAreas[id]["displayed"]==true){
909
+ fs["frame_"+ id].document.getElementById("result").scrollTop= scrollTop;
910
+ fs["frame_"+ id].document.getElementById("result").scrollLeft= scrollLeft;
911
+ fs["frame_"+ id].editArea.execCommand("onchange");
907
912
  }else{
908
- document.getElementById(id).scrollTop= scrollTop;
909
- document.getElementById(id).scrollLeft= scrollLeft;
913
+ d.getElementById(id).scrollTop= scrollTop;
914
+ d.getElementById(id).scrollLeft= scrollLeft;
910
915
  }
911
916
  },
912
917
 
913
918
  insertTags : function(id, open_tag, close_tag){
914
- var old_sel= this.getSelectionRange(id);
915
- text= open_tag + this.getSelectedText(id) + close_tag;
919
+ var old_sel,new_sel;
920
+
921
+ old_sel = this.getSelectionRange(id);
922
+ text = open_tag + this.getSelectedText(id) + close_tag;
923
+
916
924
  editAreaLoader.setSelectedText(id, text);
917
- var new_sel= this.getSelectionRange(id);
925
+
926
+ new_sel = this.getSelectionRange(id);
918
927
  if(old_sel["end"] > old_sel["start"]) // if text was selected, cursor at the end
919
928
  this.setSelectionRange(id, new_sel["end"], new_sel["end"]);
920
929
  else // cursor in the middle
@@ -923,58 +932,60 @@ EditAreaLoader.prototype ={
923
932
 
924
933
  // hide both EditArea and normal textarea
925
934
  hide : function(id){
926
- if(document.getElementById(id) && !this.hidden[id])
935
+ var fs= window.frames,d=document,t=this,scrollTop,scrollLeft,span;
936
+ if(d.getElementById(id) && !t.hidden[id])
927
937
  {
928
- this.hidden[id]= new Object();
929
- this.hidden[id]["selectionRange"]= this.getSelectionRange(id);
930
- if(document.getElementById(id).style.display!="none")
938
+ t.hidden[id]= {};
939
+ t.hidden[id]["selectionRange"]= t.getSelectionRange(id);
940
+ if(d.getElementById(id).style.display!="none")
931
941
  {
932
- this.hidden[id]["scrollTop"]= document.getElementById(id).scrollTop;
933
- this.hidden[id]["scrollLeft"]= document.getElementById(id).scrollLeft;
942
+ t.hidden[id]["scrollTop"]= d.getElementById(id).scrollTop;
943
+ t.hidden[id]["scrollLeft"]= d.getElementById(id).scrollLeft;
934
944
  }
935
945
 
936
- if(window.frames["frame_"+id])
946
+ if(fs["frame_"+id])
937
947
  {
938
- this.hidden[id]["toggle"]= editAreas[id]["displayed"];
948
+ t.hidden[id]["toggle"]= editAreas[id]["displayed"];
939
949
 
940
- if(window.frames["frame_"+id] && editAreas[id]["displayed"]==true){
941
- var scrollTop= window.frames["frame_"+ id].document.getElementById("result").scrollTop;
942
- var scrollLeft= window.frames["frame_"+ id].document.getElementById("result").scrollLeft;
950
+ if(fs["frame_"+id] && editAreas[id]["displayed"]==true){
951
+ scrollTop = fs["frame_"+ id].document.getElementById("result").scrollTop;
952
+ scrollLeft = fs["frame_"+ id].document.getElementById("result").scrollLeft;
943
953
  }else{
944
- var scrollTop= document.getElementById(id).scrollTop;
945
- var scrollLeft= document.getElementById(id).scrollLeft;
954
+ scrollTop = d.getElementById(id).scrollTop;
955
+ scrollLeft = d.getElementById(id).scrollLeft;
946
956
  }
947
- this.hidden[id]["scrollTop"]= scrollTop;
948
- this.hidden[id]["scrollLeft"]= scrollLeft;
957
+ t.hidden[id]["scrollTop"]= scrollTop;
958
+ t.hidden[id]["scrollLeft"]= scrollLeft;
949
959
 
950
960
  if(editAreas[id]["displayed"]==true)
951
961
  editAreaLoader.toggle_off(id);
952
962
  }
953
963
 
954
964
  // hide toggle button and debug box
955
- var span= document.getElementById("EditAreaArroundInfos_"+id);
965
+ span= d.getElementById("EditAreaArroundInfos_"+id);
956
966
  if(span){
957
967
  span.style.display='none';
958
968
  }
959
969
 
960
970
  // hide textarea
961
- document.getElementById(id).style.display= "none";
971
+ d.getElementById(id).style.display= "none";
962
972
  }
963
973
  },
964
974
 
965
975
  // restore hidden EditArea and normal textarea
966
976
  show : function(id){
967
- if((elem=document.getElementById(id)) && this.hidden[id])
977
+ var fs= window.frames,d=document,t=this,span;
978
+ if((elem=d.getElementById(id)) && t.hidden[id])
968
979
  {
969
980
  elem.style.display= "inline";
970
- elem.scrollTop= this.hidden[id]["scrollTop"];
971
- elem.scrollLeft= this.hidden[id]["scrollLeft"];
972
- var span= document.getElementById("EditAreaArroundInfos_"+id);
981
+ elem.scrollTop= t.hidden[id]["scrollTop"];
982
+ elem.scrollLeft= t.hidden[id]["scrollLeft"];
983
+ span= d.getElementById("EditAreaArroundInfos_"+id);
973
984
  if(span){
974
985
  span.style.display='inline';
975
986
  }
976
987
 
977
- if(window.frames["frame_"+id])
988
+ if(fs["frame_"+id])
978
989
  {
979
990
 
980
991
  // restore toggle button and debug box
@@ -984,25 +995,25 @@ EditAreaLoader.prototype ={
984
995
  elem.style.display= "inline";
985
996
 
986
997
  // restore EditArea
987
- if(this.hidden[id]["toggle"]==true)
998
+ if(t.hidden[id]["toggle"]==true)
988
999
  editAreaLoader.toggle_on(id);
989
1000
 
990
- scrollTop= this.hidden[id]["scrollTop"];
991
- scrollLeft= this.hidden[id]["scrollLeft"];
1001
+ scrollTop = t.hidden[id]["scrollTop"];
1002
+ scrollLeft = t.hidden[id]["scrollLeft"];
992
1003
 
993
- if(window.frames["frame_"+id] && editAreas[id]["displayed"]==true){
994
- window.frames["frame_"+ id].document.getElementById("result").scrollTop= scrollTop;
995
- window.frames["frame_"+ id].document.getElementById("result").scrollLeft= scrollLeft;
1004
+ if(fs["frame_"+id] && editAreas[id]["displayed"]==true){
1005
+ fs["frame_"+ id].document.getElementById("result").scrollTop = scrollTop;
1006
+ fs["frame_"+ id].document.getElementById("result").scrollLeft = scrollLeft;
996
1007
  }else{
997
- elem.scrollTop= scrollTop;
998
- elem.scrollLeft= scrollLeft;
1008
+ elem.scrollTop = scrollTop;
1009
+ elem.scrollLeft = scrollLeft;
999
1010
  }
1000
1011
 
1001
1012
  }
1002
1013
  // restore selection
1003
- sel= this.hidden[id]["selectionRange"];
1004
- this.setSelectionRange(id, sel["start"], sel["end"]);
1005
- delete this.hidden[id];
1014
+ sel = t.hidden[id]["selectionRange"];
1015
+ t.setSelectionRange(id, sel["start"], sel["end"]);
1016
+ delete t.hidden[id];
1006
1017
  }
1007
1018
  },
1008
1019
 
@@ -1033,8 +1044,9 @@ EditAreaLoader.prototype ={
1033
1044
 
1034
1045
  // close the given file (for multi file editing mode)
1035
1046
  setFileEditedMode : function(id, file_id, to){
1036
- var reg1= new RegExp('\\\\', 'g');
1037
- var reg2= new RegExp('"', 'g');
1047
+ var reg1,reg2;
1048
+ reg1 = new RegExp('\\\\', 'g');
1049
+ reg2 = new RegExp('"', 'g');
1038
1050
  return this.execCommand(id, 'set_file_edited_mode("'+ file_id.replace(reg1, '\\\\').replace(reg2, '\\"') +'", '+ to +')');
1039
1051
  },
1040
1052
 
@@ -1066,5 +1078,5 @@ EditAreaLoader.prototype ={
1066
1078
  };
1067
1079
 
1068
1080
  var editAreaLoader= new EditAreaLoader();
1069
- var editAreas= new Object();
1081
+ var editAreas= {};
1070
1082