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,163 +7,147 @@
7
7
  ******/
8
8
 
9
9
  function EditArea(){
10
- this.error= false; // to know if load is interrrupt
10
+ var t=this;
11
+ t.error= false; // to know if load is interrrupt
11
12
 
12
- this.inlinePopup= new Array({popup_id: "area_search_replace", icon_id: "search"},
13
- {popup_id: "edit_area_help", icon_id: "help"});
14
- this.plugins= new Object();
13
+ t.inlinePopup= [{popup_id: "area_search_replace", icon_id: "search"},
14
+ {popup_id: "edit_area_help", icon_id: "help"}];
15
+ t.plugins= {};
15
16
 
16
- this.line_number=0;
17
-
18
- this.nav=parent.editAreaLoader.nav; // navigator identification
19
-
20
- this.last_selection=new Object();
21
- this.last_text_to_highlight="";
22
- this.last_hightlighted_text= "";
23
- this.syntax_list= new Array();
24
- this.allready_used_syntax= new Object();
25
- this.check_line_selection_timer= 50; // the timer delay for modification and/or selection change detection
26
-
27
- this.textareaFocused= false;
28
- this.highlight_selection_line= null;
29
- this.previous= new Array();
30
- this.next= new Array();
31
- this.last_undo="";
32
- this.files= new Object();
33
- this.filesIdAssoc= new Object();
34
- this.curr_file= '';
35
- //this.loaded= false;
36
- this.assocBracket=new Object();
37
- this.revertAssocBracket= new Object();
17
+ t.line_number=0;
18
+
19
+ parent.editAreaLoader.set_browser_infos(t); // navigator identification
20
+ // fix IE8 detection as we run in IE7 emulate mode through X-UA <meta> tag
21
+ if( t.isIE >= 8 )
22
+ t.isIE = 7;
23
+
24
+ t.last_selection={};
25
+ t.last_text_to_highlight="";
26
+ t.last_hightlighted_text= "";
27
+ t.syntax_list= [];
28
+ t.allready_used_syntax= {};
29
+ t.check_line_selection_timer= 50; // the timer delay for modification and/or selection change detection
30
+
31
+ t.textareaFocused= false;
32
+ t.highlight_selection_line= null;
33
+ t.previous= [];
34
+ t.next= [];
35
+ t.last_undo="";
36
+ t.files= {};
37
+ t.filesIdAssoc= {};
38
+ t.curr_file= '';
39
+ //t.loaded= false;
40
+ t.assocBracket={};
41
+ t.revertAssocBracket= {};
38
42
  // bracket selection init
39
- this.assocBracket["("]=")";
40
- this.assocBracket["{"]="}";
41
- this.assocBracket["["]="]";
42
- for(var index in this.assocBracket){
43
- this.revertAssocBracket[this.assocBracket[index]]=index;
43
+ t.assocBracket["("]=")";
44
+ t.assocBracket["{"]="}";
45
+ t.assocBracket["["]="]";
46
+ for(var index in t.assocBracket){
47
+ t.revertAssocBracket[t.assocBracket[index]]=index;
44
48
  }
45
- this.is_editable= true;
49
+ t.is_editable= true;
46
50
 
47
51
 
48
- /*this.textarea="";
52
+ /*t.textarea="";
49
53
 
50
- this.state="declare";
51
- this.code = new Array(); // store highlight syntax for languagues*/
54
+ t.state="declare";
55
+ t.code = []; // store highlight syntax for languagues*/
52
56
  // font datas
53
- this.lineHeight= 16;
54
- /*this.default_font_family= "monospace";
55
- this.default_font_size= 10;*/
56
- this.tab_nb_char= 8; //nb of white spaces corresponding to a tabulation
57
- if(this.nav['isOpera'])
58
- this.tab_nb_char= 6;
57
+ t.lineHeight= 16;
58
+ /*t.default_font_family= "monospace";
59
+ t.default_font_size= 10;*/
60
+ t.tab_nb_char= 8; //nb of white spaces corresponding to a tabulation
61
+ if(t.isOpera)
62
+ t.tab_nb_char= 6;
59
63
 
60
- this.is_tabbing= false;
64
+ t.is_tabbing= false;
61
65
 
62
- this.fullscreen= {'isFull': false};
66
+ t.fullscreen= {'isFull': false};
63
67
 
64
- this.isResizing=false; // resize var
68
+ t.isResizing=false; // resize var
65
69
 
66
- // init with settings and ID
67
- this.id= area_id;
68
- this.settings= editAreas[this.id]["settings"];
70
+ // init with settings and ID (area_id is a global var defined by editAreaLoader on iframe creation
71
+ t.id= area_id;
72
+ t.settings= editAreas[t.id]["settings"];
69
73
 
70
- if((""+this.settings['replace_tab_by_spaces']).match(/^[0-9]+$/))
74
+ if((""+t.settings['replace_tab_by_spaces']).match(/^[0-9]+$/))
71
75
  {
72
- this.tab_nb_char= this.settings['replace_tab_by_spaces'];
73
- this.tabulation="";
74
- for(var i=0; i<this.tab_nb_char; i++)
75
- this.tabulation+=" ";
76
+ t.tab_nb_char= t.settings['replace_tab_by_spaces'];
77
+ t.tabulation="";
78
+ for(var i=0; i<t.tab_nb_char; i++)
79
+ t.tabulation+=" ";
76
80
  }else{
77
- this.tabulation="\t";
81
+ t.tabulation="\t";
78
82
  }
79
83
 
80
84
  // retrieve the init parameter for syntax
81
- if(this.settings["syntax_selection_allow"] && this.settings["syntax_selection_allow"].length>0)
82
- this.syntax_list= this.settings["syntax_selection_allow"].replace(/ /g,"").split(",");
85
+ if(t.settings["syntax_selection_allow"] && t.settings["syntax_selection_allow"].length>0)
86
+ t.syntax_list= t.settings["syntax_selection_allow"].replace(/ /g,"").split(",");
83
87
 
84
- if(this.settings['syntax'])
85
- this.allready_used_syntax[this.settings['syntax']]=true;
88
+ if(t.settings['syntax'])
89
+ t.allready_used_syntax[t.settings['syntax']]=true;
86
90
 
87
91
 
88
92
  };
89
-
90
-
91
- //called by the toggle_on
92
- EditArea.prototype.update_size= function(){
93
-
94
- if(editAreas[editArea.id] && editAreas[editArea.id]["displayed"]==true){
95
- if(editArea.fullscreen['isFull']){
96
- parent.document.getElementById("frame_"+editArea.id).style.width= parent.document.getElementsByTagName("html")[0].clientWidth + "px";
97
- parent.document.getElementById("frame_"+editArea.id).style.height= parent.document.getElementsByTagName("html")[0].clientHeight + "px";
98
- }
99
-
100
- if(editArea.tab_browsing_area.style.display=='block' && !editArea.nav['isIE'])
101
- {
102
- editArea.tab_browsing_area.style.height= "0px";
103
- editArea.tab_browsing_area.style.height= (editArea.result.offsetTop - editArea.tab_browsing_area.offsetTop -1)+"px";
104
- }
105
-
106
- var height= document.body.offsetHeight - editArea.get_all_toolbar_height() - 4;
107
- editArea.result.style.height= height +"px";
108
-
109
- var width=document.body.offsetWidth -2;
110
- editArea.result.style.width= width+"px";
111
- //alert("result h: "+ height+" w: "+width+"\ntoolbar h: "+this.get_all_toolbar_height()+"\nbody_h: "+document.body.offsetHeight);
112
-
113
- // check that the popups don't get out of the screen
114
- for(var i=0; i<editArea.inlinePopup.length; i++){
115
- var popup= $(editArea.inlinePopup[i]["popup_id"]);
116
- var max_left= document.body.offsetWidth- popup.offsetWidth;
117
- var max_top= document.body.offsetHeight- popup.offsetHeight;
118
- if(popup.offsetTop>max_top)
119
- popup.style.top= max_top+"px";
120
- if(popup.offsetLeft>max_left)
121
- popup.style.left= max_left+"px";
122
- }
123
- }
124
- };
125
-
93
+ EditArea.prototype.debug = function (obj) {
94
+ var out = document.getElementById('debug');
95
+ if ( typeof obj == "string" ) {
96
+ out.innerHTML += obj + "<br/>";
97
+ } else {
98
+ out.innerHTML += "---<br/>";
99
+ out.innerHTML += obj + "<br/>";
100
+ for ( var i in obj ) {
101
+ out.innerHTML += i + " : " + obj[i] + "<br/>";
102
+ }
103
+ }
104
+ };
126
105
  EditArea.prototype.init= function(){
127
- this.textarea= $("textarea");
128
- this.container= $("container");
129
- this.result= $("result");
130
- this.content_highlight= $("content_highlight");
131
- this.selection_field= $("selection_field");
132
- this.processing_screen= $("processing");
133
- this.editor_area= $("editor");
134
- this.tab_browsing_area= $("tab_browsing_area");
135
-
136
- if(!this.settings['is_editable'])
137
- this.set_editable(false);
138
-
139
- this.set_show_line_colors( this.settings['show_line_colors'] );
140
-
141
- if(syntax_selec= $("syntax_selection"))
106
+ //try {
107
+ var t=this, a, s=t.settings;
108
+ t.textarea = _$("textarea");
109
+ t.container = _$("container");
110
+ t.result = _$("result");
111
+ t.content_highlight = _$("content_highlight");
112
+ t.selection_field = _$("selection_field");
113
+ t.selection_field_text= _$("selection_field_text");
114
+ t.processing_screen = _$("processing");
115
+ t.editor_area = _$("editor");
116
+ t.tab_browsing_area = _$("tab_browsing_area");
117
+ t.test_font_size = _$("test_font_size");
118
+ a = t.textarea;
119
+
120
+ if(!s['is_editable'])
121
+ t.set_editable(false);
122
+
123
+ t.set_show_line_colors( s['show_line_colors'] );
124
+
125
+ if(syntax_selec= _$("syntax_selection"))
142
126
  {
143
127
  // set up syntax selection lsit in the toolbar
144
- for(var i=0; i<this.syntax_list.length; i++) {
145
- var syntax= this.syntax_list[i];
128
+ for(var i=0; i<t.syntax_list.length; i++) {
129
+ var syntax= t.syntax_list[i];
146
130
  var option= document.createElement("option");
147
131
  option.value= syntax;
148
- if(syntax==this.settings['syntax'])
132
+ if(syntax==s['syntax'])
149
133
  option.selected= "selected";
150
- option.innerHTML= this.get_translation("syntax_" + syntax, "word");
134
+ option.innerHTML= t.get_translation("syntax_" + syntax, "word");
151
135
  syntax_selec.appendChild(option);
152
136
  }
153
137
  }
154
138
 
155
139
  // add plugins buttons in the toolbar
156
- spans= parent.getChildren($("toolbar_1"), "span", "", "", "all", -1);
140
+ spans= parent.getChildren(_$("toolbar_1"), "span", "", "", "all", -1);
157
141
 
158
142
  for(var i=0; i<spans.length; i++){
159
143
 
160
144
  id=spans[i].id.replace(/tmp_tool_(.*)/, "$1");
161
145
  if(id!= spans[i].id){
162
- for(var j in this.plugins){
163
- if(typeof(this.plugins[j].get_control_html)=="function" ){
164
- html=this.plugins[j].get_control_html(id);
146
+ for(var j in t.plugins){
147
+ if(typeof(t.plugins[j].get_control_html)=="function" ){
148
+ html=t.plugins[j].get_control_html(id);
165
149
  if(html!=false){
166
- html= this.get_translation(html, "template");
150
+ html= t.get_translation(html, "template");
167
151
  var new_span= document.createElement("span");
168
152
  new_span.innerHTML= html;
169
153
  var father= spans[i].parentNode;
@@ -175,55 +159,58 @@
175
159
  }
176
160
  }
177
161
 
178
-
179
162
  // init datas
180
- this.textarea.value=editAreas[this.id]["textarea"].value;
181
- if(this.settings["debug"])
182
- this.debug=parent.document.getElementById("edit_area_debug_"+this.id);
183
-
163
+ //a.value = 'a';//editAreas[t.id]["textarea"].value;
164
+
165
+ if(s["debug"])
166
+ {
167
+ t.debug=parent.document.getElementById("edit_area_debug_"+t.id);
168
+ }
184
169
  // init size
185
170
  //this.update_size();
186
171
 
187
- if($("redo") != null)
188
- this.switchClassSticky($("redo"), 'editAreaButtonDisabled', true);
189
-
172
+ if(_$("redo") != null)
173
+ t.switchClassSticky(_$("redo"), 'editAreaButtonDisabled', true);
190
174
 
191
175
  // insert css rules for highlight mode
192
- if(typeof(parent.editAreaLoader.syntax[this.settings["syntax"]])!="undefined"){
176
+ if(typeof(parent.editAreaLoader.syntax[s["syntax"]])!="undefined"){
193
177
  for(var i in parent.editAreaLoader.syntax){
194
- this.add_style(parent.editAreaLoader.syntax[i]["styles"]);
178
+ if (typeof(parent.editAreaLoader.syntax[i]["styles"]) != "undefined"){
179
+ t.add_style(parent.editAreaLoader.syntax[i]["styles"]);
180
+ }
195
181
  }
196
182
  }
183
+
197
184
  // init key events
198
- if(this.nav['isOpera'])
199
- $("editor").onkeypress= keyDown;
185
+ if(t.isOpera)
186
+ _$("editor").onkeypress = keyDown;
200
187
  else
201
- $("editor").onkeydown= keyDown;
188
+ _$("editor").onkeydown = keyDown;
202
189
 
203
- for(var i=0; i<this.inlinePopup.length; i++){
204
- if(this.nav['isIE'] || this.nav['isFirefox'])
205
- $(this.inlinePopup[i]["popup_id"]).onkeydown= keyDown;
190
+ for(var i=0; i<t.inlinePopup.length; i++){
191
+ if(t.isOpera)
192
+ _$(t.inlinePopup[i]["popup_id"]).onkeypress = keyDown;
206
193
  else
207
- $(this.inlinePopup[i]["popup_id"]).onkeypress= keyDown;
194
+ _$(t.inlinePopup[i]["popup_id"]).onkeydown = keyDown;
208
195
  }
209
196
 
210
- if(this.settings["allow_resize"]=="both" || this.settings["allow_resize"]=="x" || this.settings["allow_resize"]=="y")
211
- this.allow_resize(true);
197
+ if(s["allow_resize"]=="both" || s["allow_resize"]=="x" || s["allow_resize"]=="y")
198
+ t.allow_resize(true);
212
199
 
213
- parent.editAreaLoader.toggle(this.id, "on");
214
- //this.textarea.focus();
200
+ parent.editAreaLoader.toggle(t.id, "on");
201
+ //a.focus();
215
202
  // line selection init
216
- this.change_smooth_selection_mode(editArea.smooth_selection);
203
+ t.change_smooth_selection_mode(editArea.smooth_selection);
217
204
  // highlight
218
- this.execCommand("change_highlight", this.settings["start_highlight"]);
219
-
205
+ t.execCommand("change_highlight", s["start_highlight"]);
206
+
220
207
  // get font size datas
221
- this.set_font(editArea.settings["font_family"], editArea.settings["font_size"]);
208
+ t.set_font(editArea.settings["font_family"], editArea.settings["font_size"]);
222
209
 
223
210
  // set unselectable text
224
211
  children= parent.getChildren(document.body, "", "selec", "none", "all", -1);
225
212
  for(var i=0; i<children.length; i++){
226
- if(this.nav['isIE'])
213
+ if(t.isIE)
227
214
  children[i].unselectable = true; // IE
228
215
  else
229
216
  children[i].onmousedown= function(){return false};
@@ -231,112 +218,162 @@
231
218
  children[i].style.KhtmlUserSelect = "none"; // Konqueror/Safari*/
232
219
  }
233
220
 
234
- if(this.nav['isGecko']){
235
- this.textarea.spellcheck= this.settings["gecko_spellcheck"];
236
- }
237
-
221
+ a.spellcheck= s["gecko_spellcheck"];
222
+
238
223
  /** Browser specific style fixes **/
239
224
 
240
225
  // fix rendering bug for highlighted lines beginning with no tabs
241
- if( this.nav['isFirefox'] >= '3' )
242
- this.content_highlight.style.borderLeft= "solid 1px transparent";
226
+ if( t.isFirefox >= '3' ) {
227
+ t.content_highlight.style.paddingLeft= "1px";
228
+ t.selection_field.style.paddingLeft= "1px";
229
+ t.selection_field_text.style.paddingLeft= "1px";
230
+ }
243
231
 
244
- if(this.nav['isIE']){
245
- this.textarea.style.marginTop= "-1px";
232
+ if(t.isIE && t.isIE < 8 ){
233
+ a.style.marginTop= "-1px";
246
234
  }
247
235
  /*
248
- if(this.nav['isOpera']){
249
- this.editor_area.style.position= "absolute";
236
+ if(t.isOpera){
237
+ t.editor_area.style.position= "absolute";
250
238
  }*/
251
239
 
252
- if(this.nav['isSafari'] ){
253
- this.editor_area.style.position= "absolute";
254
- this.textarea.style.marginLeft="-3px";
255
- this.textarea.style.marginTop="1px";
256
- }
257
-
258
- if( this.nav['isChrome'] ){
259
- this.editor_area.style.position= "absolute";
260
- this.textarea.style.marginLeft="0px";
261
- this.textarea.style.marginTop="0px";
240
+ if( t.isSafari ){
241
+ t.editor_area.style.position = "absolute";
242
+ a.style.marginLeft ="-3px";
243
+ if( t.isSafari < 3.2 ) // Safari 3.0 (3.1?)
244
+ a.style.marginTop ="1px";
262
245
  }
263
246
 
264
247
  // si le textarea n'est pas grand, un click sous le textarea doit provoquer un focus sur le textarea
265
- parent.editAreaLoader.add_event(this.result, "click", function(e){ if((e.target || e.srcElement)==editArea.result) { editArea.area_select(editArea.textarea.value.length, 0);} });
248
+ parent.editAreaLoader.add_event(t.result, "click", function(e){ if((e.target || e.srcElement)==editArea.result) { editArea.area_select(editArea.textarea.value.length, 0);} });
266
249
 
267
- if(this.settings['is_multi_files']!=false)
268
- this.open_file({'id': this.curr_file, 'text': ''});
250
+ if(s['is_multi_files']!=false)
251
+ t.open_file({'id': t.curr_file, 'text': ''});
269
252
 
270
- this.set_wrap_text( this.settings['wrap_text'] );
253
+ t.set_word_wrap( s['word_wrap'] );
271
254
 
272
255
  setTimeout("editArea.focus();editArea.manage_size();editArea.execCommand('EA_load');", 10);
273
256
  //start checkup routine
274
- this.check_undo();
275
- this.check_line_selection(true);
276
- this.scroll_to_view();
257
+ t.check_undo();
258
+ t.check_line_selection(true);
259
+ t.scroll_to_view();
277
260
 
278
- for(var i in this.plugins){
279
- if(typeof(this.plugins[i].onload)=="function")
280
- this.plugins[i].onload();
261
+ for(var i in t.plugins){
262
+ if(typeof(t.plugins[i].onload)=="function")
263
+ t.plugins[i].onload();
281
264
  }
282
- if(this.settings['fullscreen']==true)
283
- this.toggle_full_screen(true);
265
+ if(s['fullscreen']==true)
266
+ t.toggle_full_screen(true);
284
267
 
285
268
  parent.editAreaLoader.add_event(window, "resize", editArea.update_size);
286
269
  parent.editAreaLoader.add_event(parent.window, "resize", editArea.update_size);
287
270
  parent.editAreaLoader.add_event(top.window, "resize", editArea.update_size);
288
- parent.editAreaLoader.add_event(window, "unload", function(){if(editAreas[editArea.id] && editAreas[editArea.id]["displayed"]) editArea.execCommand("EA_unload");});
289
-
271
+ parent.editAreaLoader.add_event(window, "unload", function(){
272
+ // in case where editAreaLoader have been already cleaned
273
+ if( parent.editAreaLoader )
274
+ {
275
+ parent.editAreaLoader.remove_event(parent.window, "resize", editArea.update_size);
276
+ parent.editAreaLoader.remove_event(top.window, "resize", editArea.update_size);
277
+ }
278
+ if(editAreas[editArea.id] && editAreas[editArea.id]["displayed"]){
279
+ editArea.execCommand("EA_unload");
280
+ }
281
+ });
290
282
 
283
+ //} catch ( e ) { debug(e); }
291
284
  /*date= new Date();
292
285
  alert(date.getTime()- parent.editAreaLoader.start_time);*/
293
286
  };
294
287
 
295
288
 
289
+
290
+ //called by the toggle_on
291
+ EditArea.prototype.update_size= function(){
292
+ var d=document,pd=parent.document,height,width,popup,maxLeft,maxTop;
293
+
294
+ if( typeof editAreas != 'undefined' && editAreas[editArea.id] && editAreas[editArea.id]["displayed"]==true){
295
+ if(editArea.fullscreen['isFull']){
296
+ pd.getElementById("frame_"+editArea.id).style.width = pd.getElementsByTagName("html")[0].clientWidth + "px";
297
+ pd.getElementById("frame_"+editArea.id).style.height = pd.getElementsByTagName("html")[0].clientHeight + "px";
298
+ }
299
+
300
+ if(editArea.tab_browsing_area.style.display=='block' && ( !editArea.isIE || editArea.isIE >= 8 ) )
301
+ {
302
+ editArea.tab_browsing_area.style.height = "0px";
303
+ editArea.tab_browsing_area.style.height = (editArea.result.offsetTop - editArea.tab_browsing_area.offsetTop -1)+"px";
304
+ }
305
+
306
+ height = d.body.offsetHeight - editArea.get_all_toolbar_height() - 4;
307
+ editArea.result.style.height = Math.max(height, 0) +"px";
308
+
309
+ width = d.body.offsetWidth -2;
310
+ editArea.result.style.width = Math.max(width, 0)+"px";
311
+ //alert("result h: "+ height+" w: "+width+"\ntoolbar h: "+this.get_all_toolbar_height()+"\nbody_h: "+document.body.offsetHeight);
312
+
313
+ // check that the popups don't get out of the screen
314
+ for( i=0; i < editArea.inlinePopup.length; i++ )
315
+ {
316
+ popup = _$(editArea.inlinePopup[i]["popup_id"]);
317
+ maxLeft = d.body.offsetWidth - popup.offsetWidth;
318
+ maxTop = d.body.offsetHeight - popup.offsetHeight;
319
+ if( popup.offsetTop > maxTop )
320
+ popup.style.top = maxTop+"px";
321
+ if( popup.offsetLeft > maxLeft )
322
+ popup.style.left = maxLeft+"px";
323
+ }
324
+
325
+ editArea.manage_size( true );
326
+ editArea.fixLinesHeight( editArea.textarea.value, 0,-1);
327
+ }
328
+ };
329
+
330
+
296
331
  EditArea.prototype.manage_size= function(onlyOneTime){
297
332
  if(!editAreas[this.id])
298
333
  return false;
334
+
299
335
  if(editAreas[this.id]["displayed"]==true && this.textareaFocused)
300
336
  {
301
- var resized= false;
337
+ var area_height,resized= false;
302
338
 
303
339
  //1) Manage display width
304
340
  //1.1) Calc the new width to use for display
305
- if( this.settings['wrap_text'] )
306
- {
307
- // var area_width= this.result.offsetWidth -50;
308
- }
309
- else
341
+ if( !this.settings['word_wrap'] )
310
342
  {
311
343
  var area_width= this.textarea.scrollWidth;
312
- var area_height= this.textarea.scrollHeight;
313
- if(this.nav['isOpera']){
314
- area_width=10000; /* TODO: find a better way to fix the width problem */
344
+ area_height= this.textarea.scrollHeight;
345
+ // bug on old opera versions
346
+ if(this.isOpera && this.isOpera < 9.6 ){
347
+ area_width=10000;
348
+ }
349
+ //1.2) the width is not the same, we must resize elements
350
+ if(this.textarea.previous_scrollWidth!=area_width)
351
+ {
352
+ this.container.style.width= area_width+"px";
353
+ this.textarea.style.width= area_width+"px";
354
+ this.content_highlight.style.width= area_width+"px";
355
+ this.textarea.previous_scrollWidth=area_width;
356
+ resized=true;
315
357
  }
316
358
  }
317
-
318
-
319
- //1.2) the width is not the same, we must resize elements
320
- if(this.textarea.previous_scrollWidth!=area_width)
321
- {
322
-
323
- this.container.style.width= area_width+"px";
324
- this.textarea.style.width= area_width+"px";
325
- this.content_highlight.style.width= area_width+"px";
326
- this.textarea.previous_scrollWidth=area_width;
327
- resized=true;
328
- }
329
-
359
+ // manage wrap width
360
+ if( this.settings['word_wrap'] )
361
+ {
362
+ newW=this.textarea.offsetWidth;
363
+ if( this.isFirefox || this.isIE )
364
+ newW-=2;
365
+ if( this.isSafari )
366
+ newW-=6;
367
+ this.content_highlight.style.width=this.selection_field_text.style.width=this.selection_field.style.width=this.test_font_size.style.width=newW+"px";
368
+ }
330
369
 
331
370
  //2) Manage display height
332
371
  //2.1) Calc the new height to use for display
333
- var area_height = this.textarea.scrollHeight;
334
- if(this.nav['isOpera']){
335
- area_height= this.last_selection['nb_line']*this.lineHeight;
336
- }
337
-
338
- if(this.nav['isGecko'] && this.smooth_selection && this.last_selection["nb_line"])
339
- area_height= this.last_selection["nb_line"]*this.lineHeight;
372
+ if( this.isOpera || this.isFirefox || this.isSafari ) {
373
+ area_height= this.getLinePosTop( this.last_selection["nb_line"] + 1 );
374
+ } else {
375
+ area_height = this.textarea.scrollHeight;
376
+ }
340
377
  //2.2) the width is not the same, we must resize elements
341
378
  if(this.textarea.previous_scrollHeight!=area_height)
342
379
  {
@@ -350,17 +387,15 @@
350
387
  //3) if there is new lines, we add new line numbers in the line numeration area
351
388
  if(this.last_selection["nb_line"] >= this.line_number)
352
389
  {
353
- var div_line_number="";
354
- for(i=this.line_number+1; i<this.last_selection["nb_line"]+100; i++)
390
+ var newLines= '', destDiv=_$("line_number"), start=this.line_number, end=this.last_selection["nb_line"]+100;
391
+ for( i = start+1; i < end; i++ )
355
392
  {
356
- div_line_number+=i+"<br />";
393
+ newLines+='<div id="line_'+ i +'">'+i+"</div>";
357
394
  this.line_number++;
358
395
  }
359
- var span= document.createElement("span");
360
- if(this.nav['isIE'])
361
- span.unselectable=true;
362
- span.innerHTML=div_line_number;
363
- $("line_number").appendChild(span);
396
+ destDiv.innerHTML= destDiv.innerHTML + newLines;
397
+
398
+ this.fixLinesHeight( this.textarea.value, start, -1 );
364
399
  }
365
400
 
366
401
  //4) be sure the text is well displayed
@@ -370,18 +405,11 @@
370
405
  this.scroll_to_view();
371
406
  }
372
407
  }
408
+
373
409
  if(!onlyOneTime)
374
410
  setTimeout("editArea.manage_size();", 100);
375
411
  };
376
412
 
377
- EditArea.prototype.add_event = function(obj, name, handler) {
378
- if (this.nav['isIE']) {
379
- obj.attachEvent("on" + name, handler);
380
- } else{
381
- obj.addEventListener(name, handler, false);
382
- }
383
- };
384
-
385
413
  EditArea.prototype.execCommand= function(cmd, param){
386
414
 
387
415
  for(var i in this.plugins){
@@ -390,6 +418,7 @@
390
418
  return;
391
419
  }
392
420
  }
421
+ //debug( "exec: " + cmd );
393
422
  switch(cmd){
394
423
  case "save":
395
424
  if(this.settings["save_callback"].length>0)
@@ -494,16 +523,16 @@
494
523
  // add plugin translation to language translation array
495
524
  EditArea.prototype.add_lang= function(language, values){
496
525
  if(!parent.editAreaLoader.lang[language])
497
- parent.editAreaLoader.lang[language]=new Object();
526
+ parent.editAreaLoader.lang[language]={};
498
527
  for(var i in values)
499
528
  parent.editAreaLoader.lang[language][i]= values[i];
500
529
  };
501
530
 
502
531
  // short cut for document.getElementById()
503
- function $(id){return document.getElementById( id );};
532
+ function _$(id){return document.getElementById( id );};
504
533
 
505
534
  var editArea = new EditArea();
506
- editArea.add_event(window, "load", init);
535
+ parent.editAreaLoader.add_event(window, "load", init);
507
536
 
508
537
  function init(){
509
538
  setTimeout("editArea.init(); ", 10);