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
@@ -10,16 +10,17 @@
10
10
  };
11
11
 
12
12
  EditArea.prototype.show_waiting_screen= function(){
13
- width= this.editor_area.offsetWidth;
14
- height= this.editor_area.offsetHeight;
15
- if(this.nav['isGecko'] || this.nav['isOpera'] || this.nav['isIE']>=7){
16
- width-=2;
17
- height-=2;
13
+ width = this.editor_area.offsetWidth;
14
+ height = this.editor_area.offsetHeight;
15
+ if( !(this.isIE && this.isIE<6) )
16
+ {
17
+ width -= 2;
18
+ height -= 2;
18
19
  }
19
- this.processing_screen.style.display="block";
20
- this.processing_screen.style.width= width+"px";
21
- this.processing_screen.style.height= height+"px";
22
- this.waiting_screen_displayed= true;
20
+ this.processing_screen.style.display= "block";
21
+ this.processing_screen.style.width = width+"px";
22
+ this.processing_screen.style.height = height+"px";
23
+ this.waiting_screen_displayed = true;
23
24
  };
24
25
 
25
26
  EditArea.prototype.hide_waiting_screen= function(){
@@ -32,86 +33,126 @@
32
33
  newcss = document.createElement("style");
33
34
  newcss.type="text/css";
34
35
  newcss.media="all";
35
- document.getElementsByTagName("head")[0].appendChild(newcss);
36
- cssrules = styles.split("}");
37
- newcss = document.styleSheets[0];
38
- if(newcss.rules) { //IE
39
- for(i=cssrules.length-2;i>=0;i--) {
40
- newrule = cssrules[i].split("{");
41
- newcss.addRule(newrule[0],newrule[1])
42
- }
43
- }
44
- else if(newcss.cssRules) { //Firefox etc
45
- for(i=cssrules.length-1;i>=0;i--) {
46
- if(cssrules[i].indexOf("{")!=-1){
47
- newcss.insertRule(cssrules[i]+"}",0);
48
- }
49
- }
36
+ if(newcss.styleSheet){ // IE
37
+ newcss.styleSheet.cssText = styles;
38
+ } else { // W3C
39
+ newcss.appendChild(document.createTextNode(styles));
50
40
  }
41
+ document.getElementsByTagName("head")[0].appendChild(newcss);
51
42
  }
52
43
  };
53
44
 
54
45
  EditArea.prototype.set_font= function(family, size){
55
- var elems= new Array("textarea", "content_highlight", "cursor_pos", "end_bracket", "selection_field", "line_number");
46
+ var t=this, a=this.textarea, s=this.settings, elem_font, i, elem;
47
+ // list all elements concerned by font changes
48
+ var elems= ["textarea", "content_highlight", "cursor_pos", "end_bracket", "selection_field", "selection_field_text", "line_number"];
49
+
56
50
  if(family && family!="")
57
- this.settings["font_family"]= family;
51
+ s["font_family"]= family;
58
52
  if(size && size>0)
59
- this.settings["font_size"]=size;
60
- if(this.nav['isOpera']) // opera can't manage non monospace font
61
- this.settings['font_family']="monospace";
62
- var elem_font=$("area_font_size");
63
- if(elem_font){
64
- for(var i=0; i<elem_font.length; i++){
65
- if(elem_font.options[i].value && elem_font.options[i].value == this.settings["font_size"])
66
- elem_font.options[i].selected=true;
53
+ s["font_size"] = size;
54
+ if( t.isOpera && t.isOpera < 9.6 ) // opera<9.6 can't manage non monospace font
55
+ s['font_family']="monospace";
56
+
57
+ // update the select tag
58
+ if( elem_font = _$("area_font_size") )
59
+ {
60
+ for( i = 0; i < elem_font.length; i++ )
61
+ {
62
+ if( elem_font.options[i].value && elem_font.options[i].value == s["font_size"] )
63
+ elem_font.options[i].selected=true;
67
64
  }
68
65
  }
69
66
 
70
- // calc line height
71
- elem = $("test_font_size");
72
- elem.style.fontFamily= ""+this.settings["font_family"];
73
- elem.style.fontSize= this.settings["font_size"]+"pt";
74
- elem.innerHTML="0";
75
- this.lineHeight= elem.offsetHeight;
76
-
67
+ /*
68
+ * somethimes firefox has rendering mistake with non-monospace font for text width in textarea vs in div for changing font size (eg: verdana change between 11pt to 12pt)
69
+ * => looks like a browser internal random bug as text width can change while content_highlight is updated
70
+ * we'll check if the font-size produce the same text width inside textarea and div and if not, we'll increment the font-size
71
+ *
72
+ * This is an ugly fix
73
+ */
74
+ if( t.isFirefox )
75
+ {
76
+ var nbTry = 3;
77
+ do {
78
+ var div1 = document.createElement( 'div' ), text1 = document.createElement( 'textarea' );
79
+ var styles = {
80
+ width: '40px',
81
+ overflow: 'scroll',
82
+ zIndex: 50,
83
+ visibility: 'hidden',
84
+ fontFamily: s["font_family"],
85
+ fontSize: s["font_size"]+"pt",
86
+ lineHeight: t.lineHeight+"px",
87
+ padding: '0',
88
+ margin: '0',
89
+ border: 'none',
90
+ whiteSpace: 'nowrap'
91
+ };
92
+ var diff, changed = false;
93
+ for( i in styles )
94
+ {
95
+ div1.style[ i ] = styles[i];
96
+ text1.style[ i ] = styles[i];
97
+ }
98
+ // no wrap for this text
99
+ text1.wrap = 'off';
100
+ text1.setAttribute('wrap', 'off');
101
+ t.container.appendChild( div1 );
102
+ t.container.appendChild( text1 );
103
+ // try to make FF to bug
104
+ div1.innerHTML = text1.value = 'azertyuiopqsdfghjklm';
105
+ div1.innerHTML = text1.value = text1.value+'wxcvbn^p*ù$!:;,,';
106
+ diff = text1.scrollWidth - div1.scrollWidth;
107
+
108
+ // firefox return here a diff of 1 px between equals scrollWidth (can't explain)
109
+ if( Math.abs( diff ) >= 2 )
110
+ {
111
+ s["font_size"]++;
112
+ changed = true;
113
+ }
114
+ t.container.removeChild( div1 );
115
+ t.container.removeChild( text1 );
116
+ nbTry--;
117
+ }while( changed && nbTry > 0 );
118
+ }
119
+
77
120
 
78
- for(var i=0; i<elems.length; i++){
79
- var elem= $(elems[i]);
80
- elem.style.fontFamily= this.settings["font_family"];
81
- elem.style.fontSize= this.settings["font_size"]+"pt";
82
- elem.style.lineHeight= this.lineHeight+"px";
121
+ // calc line height
122
+ elem = t.test_font_size;
123
+ elem.style.fontFamily = ""+s["font_family"];
124
+ elem.style.fontSize = s["font_size"]+"pt";
125
+ elem.innerHTML = "0";
126
+ t.lineHeight = elem.offsetHeight;
83
127
 
128
+ // update font for all concerned elements
129
+ for( i=0; i<elems.length; i++)
130
+ {
131
+ elem = _$(elems[i]);
132
+ elem.style.fontFamily = s["font_family"];
133
+ elem.style.fontSize = s["font_size"]+"pt";
134
+ elem.style.lineHeight = t.lineHeight+"px";
84
135
  }
85
- if(this.nav['isOpera']){ // opera doesn't update font change to the textarea
86
- var start=this.textarea.selectionStart;
87
- var end= this.textarea.selectionEnd;
88
- var parNod = this.textarea.parentNode, nxtSib = this.textarea.nextSibling;
89
- parNod.removeChild(this.textarea); parNod.insertBefore(this.textarea, nxtSib);
90
- this.area_select(start, end-start);
91
- }
136
+ // define a css for <pre> tags
137
+ t.add_style("pre{font-family:"+s["font_family"]+"}");
92
138
 
93
- this.add_style("pre{font-family:"+this.settings["font_family"]+"}");
94
-
95
- //alert( getAttribute($("edit_area_test_font_size"), "style"));
139
+ // old opera and IE>=8 doesn't update font changes to the textarea
140
+ if( ( t.isOpera && t.isOpera < 9.6 ) || t.isIE >= 8 )
141
+ {
142
+ var parNod = a.parentNode, nxtSib = a.nextSibling, start= a.selectionStart, end= a.selectionEnd;
143
+ parNod.removeChild(a);
144
+ parNod.insertBefore(a, nxtSib);
145
+ t.area_select(start, end-start);
146
+ }
96
147
 
97
-
98
- //alert("font "+this.textarea.style.font);
99
148
  // force update of selection field
100
- this.last_line_selected=-1;
101
- //if(this.state=="loaded"){
102
- this.last_selection= new Array();
103
- this.resync_highlight();
104
- //}
105
- /* this.last_selection["indexOfCursor"]=-1;
106
- this.last_selection["curr_pos"]=-1;
107
- this.last_selection["line_start"]=-1;
108
- this.focus();*/
109
- //this.check_line_selection(false);
110
- //alert("line_h"+ this.lineHeight + " this.id: "+this.id+ "(size: "+size+")");
149
+ this.focus();
150
+ this.update_size();
151
+ this.check_line_selection();
111
152
  };
112
153
 
113
154
  EditArea.prototype.change_font_size= function(){
114
- var size=$("area_font_size").value;
155
+ var size=_$("area_font_size").value;
115
156
  if(size>0)
116
157
  this.set_font("", size);
117
158
  };
@@ -119,13 +160,13 @@
119
160
 
120
161
  EditArea.prototype.open_inline_popup= function(popup_id){
121
162
  this.close_all_inline_popup();
122
- var popup= $(popup_id);
123
- var editor= $("editor");
163
+ var popup= _$(popup_id);
164
+ var editor= _$("editor");
124
165
 
125
166
  // search matching icon
126
167
  for(var i=0; i<this.inlinePopup.length; i++){
127
168
  if(this.inlinePopup[i]["popup_id"]==popup_id){
128
- var icon= $(this.inlinePopup[i]["icon_id"]);
169
+ var icon= _$(this.inlinePopup[i]["icon_id"]);
129
170
  if(icon){
130
171
  this.switchClassSticky(icon, 'editAreaButtonSelected', true);
131
172
  break;
@@ -157,11 +198,11 @@
157
198
  };
158
199
 
159
200
  EditArea.prototype.close_inline_popup= function(popup_id){
160
- var popup= $(popup_id);
201
+ var popup= _$(popup_id);
161
202
  // search matching icon
162
203
  for(var i=0; i<this.inlinePopup.length; i++){
163
204
  if(this.inlinePopup[i]["popup_id"]==popup_id){
164
- var icon= $(this.inlinePopup[i]["icon_id"]);
205
+ var icon= _$(this.inlinePopup[i]["icon_id"]);
165
206
  if(icon){
166
207
  this.switchClassSticky(icon, 'editAreaButtonNormal', false);
167
208
  break;
@@ -191,7 +232,7 @@
191
232
  };
192
233
 
193
234
  EditArea.prototype.get_all_toolbar_height= function(){
194
- var area= $("editor");
235
+ var area= _$("editor");
195
236
  var results= parent.getChildren(area, "div", "class", "area_toolbar", "all", "0"); // search only direct children
196
237
  //results= results.concat(getChildren(area, "table", "class", "area_toolbar", "all", "0"));
197
238
  var height=0;
@@ -205,7 +246,7 @@
205
246
  EditArea.prototype.go_to_line= function(line){
206
247
  if(!line)
207
248
  {
208
- var icon= $("go_to_line");
249
+ var icon= _$("go_to_line");
209
250
  if(icon != null){
210
251
  this.restoreClass(icon);
211
252
  this.switchClassSticky(icon, 'editAreaButtonSelected', true);
@@ -242,7 +283,7 @@
242
283
  else
243
284
  this.smooth_selection=false;
244
285
  }
245
- var icon= $("change_smooth_selection");
286
+ var icon= _$("change_smooth_selection");
246
287
  this.textarea.focus();
247
288
  if(this.smooth_selection===true){
248
289
  //setAttribute(icon, "class", getAttribute(icon, "class").replace(/ selected/g, "") );
@@ -254,33 +295,37 @@
254
295
 
255
296
  this.smooth_selection=false;
256
297
  this.selection_field.style.display= "none";
257
- $("cursor_pos").style.display= "none";
258
- $("end_bracket").style.display= "none";
298
+ _$("cursor_pos").style.display= "none";
299
+ _$("end_bracket").style.display= "none";
259
300
  }else{
260
301
  //setAttribute(icon, "class", getAttribute(icon, "class") + " selected");
261
302
  //this.switchClass(icon,'editAreaButtonSelected');
262
303
  this.switchClassSticky(icon, 'editAreaButtonSelected', false);
263
304
  this.smooth_selection=true;
264
305
  this.selection_field.style.display= "block";
265
- $("cursor_pos").style.display= "block";
266
- $("end_bracket").style.display= "block";
306
+ _$("cursor_pos").style.display= "block";
307
+ _$("end_bracket").style.display= "block";
267
308
  }
268
309
  };
269
310
 
270
311
  // the auto scroll of the textarea has some lacks when it have to show cursor in the visible area when the textarea size change
271
312
  // show specifiy whereas it is the "top" or "bottom" of the selection that is showned
272
313
  EditArea.prototype.scroll_to_view= function(show){
314
+ var zone, lineElem;
273
315
  if(!this.smooth_selection)
274
316
  return;
275
- var zone= $("result");
317
+ zone= _$("result");
276
318
 
277
- //var cursor_pos_top= parseInt($("cursor_pos").style.top.replace("px",""));
278
- var cursor_pos_top= $("cursor_pos").cursor_top;
319
+ // manage height scroll
320
+ var cursor_pos_top= _$("cursor_pos").cursor_top;
279
321
  if(show=="bottom")
280
- cursor_pos_top+= (this.last_selection["line_nb"]-1)* this.lineHeight;
322
+ {
323
+ //cursor_pos_top+= (this.last_selection["line_nb"]-1)* this.lineHeight;
324
+ cursor_pos_top+= this.getLinePosTop( this.last_selection['line_start'] + this.last_selection['line_nb'] - 1 );
325
+ }
281
326
 
282
327
  var max_height_visible= zone.clientHeight + zone.scrollTop;
283
- var miss_top= cursor_pos_top + this.lineHeight - max_height_visible;
328
+ var miss_top = cursor_pos_top + this.lineHeight - max_height_visible;
284
329
  if(miss_top>0){
285
330
  //alert(miss_top);
286
331
  zone.scrollTop= zone.scrollTop + miss_top;
@@ -289,8 +334,10 @@
289
334
  //alert("else: "+cursor_pos_top);
290
335
  zone.scrollTop= cursor_pos_top;
291
336
  }
292
- //var cursor_pos_left= parseInt($("cursor_pos").style.left.replace("px",""));
293
- var cursor_pos_left= $("cursor_pos").cursor_left;
337
+
338
+ // manage left scroll
339
+ //var cursor_pos_left= parseInt(_$("cursor_pos").style.left.replace("px",""));
340
+ var cursor_pos_left= _$("cursor_pos").cursor_left;
294
341
  var max_width_visible= zone.clientWidth + zone.scrollLeft;
295
342
  var miss_left= cursor_pos_left + 10 - max_width_visible;
296
343
  if(miss_left>0){
@@ -309,7 +356,7 @@
309
356
  if(this.textareaFocused && editAreas[this.id]["displayed"]==true){
310
357
  var text=this.textarea.value;
311
358
  if(this.previous.length<=1)
312
- this.switchClassSticky($("undo"), 'editAreaButtonDisabled', true);
359
+ this.switchClassSticky(_$("undo"), 'editAreaButtonDisabled', true);
313
360
 
314
361
  if(!this.previous[this.previous.length-1] || this.previous[this.previous.length-1]["text"] != text){
315
362
  this.previous.push({"text": text, "selStart": this.textarea.selectionStart, "selEnd": this.textarea.selectionEnd});
@@ -318,7 +365,7 @@
318
365
 
319
366
  }
320
367
  if(this.previous.length >= 2)
321
- this.switchClassSticky($("undo"), 'editAreaButtonNormal', false);
368
+ this.switchClassSticky(_$("undo"), 'editAreaButtonNormal', false);
322
369
  }
323
370
 
324
371
  if(!only_once)
@@ -327,18 +374,18 @@
327
374
 
328
375
  EditArea.prototype.undo= function(){
329
376
  //alert("undo"+this.previous.length);
330
- if(this.previous.length > 0){
331
- if(this.nav['isIE'])
332
- this.getIESelection();
377
+ if(this.previous.length > 0)
378
+ {
379
+ this.getIESelection();
333
380
  // var pos_cursor=this.textarea.selectionStart;
334
- this.next.push({"text": this.textarea.value, "selStart": this.textarea.selectionStart, "selEnd": this.textarea.selectionEnd});
381
+ this.next.push( { "text": this.textarea.value, "selStart": this.textarea.selectionStart, "selEnd": this.textarea.selectionEnd } );
335
382
  var prev= this.previous.pop();
336
- if(prev["text"]==this.textarea.value && this.previous.length > 0)
337
- prev=this.previous.pop();
338
- this.textarea.value= prev["text"];
339
- this.last_undo= prev["text"];
383
+ if( prev["text"] == this.textarea.value && this.previous.length > 0 )
384
+ prev =this.previous.pop();
385
+ this.textarea.value = prev["text"];
386
+ this.last_undo = prev["text"];
340
387
  this.area_select(prev["selStart"], prev["selEnd"]-prev["selStart"]);
341
- this.switchClassSticky($("redo"), 'editAreaButtonNormal', false);
388
+ this.switchClassSticky(_$("redo"), 'editAreaButtonNormal', false);
342
389
  this.resync_highlight(true);
343
390
  //alert("undo"+this.previous.length);
344
391
  this.check_file_changes();
@@ -346,31 +393,31 @@
346
393
  };
347
394
 
348
395
  EditArea.prototype.redo= function(){
349
- if(this.next.length > 0){
350
- /*if(this.nav['isIE'])
351
- this.getIESelection();*/
396
+ if(this.next.length > 0)
397
+ {
398
+ /*this.getIESelection();*/
352
399
  //var pos_cursor=this.textarea.selectionStart;
353
400
  var next= this.next.pop();
354
401
  this.previous.push(next);
355
402
  this.textarea.value= next["text"];
356
403
  this.last_undo= next["text"];
357
404
  this.area_select(next["selStart"], next["selEnd"]-next["selStart"]);
358
- this.switchClassSticky($("undo"), 'editAreaButtonNormal', false);
405
+ this.switchClassSticky(_$("undo"), 'editAreaButtonNormal', false);
359
406
  this.resync_highlight(true);
360
407
  this.check_file_changes();
361
408
  }
362
409
  if( this.next.length == 0)
363
- this.switchClassSticky($("redo"), 'editAreaButtonDisabled', true);
410
+ this.switchClassSticky(_$("redo"), 'editAreaButtonDisabled', true);
364
411
  };
365
412
 
366
413
  EditArea.prototype.check_redo= function(){
367
414
  if(editArea.next.length == 0 || editArea.textarea.value!=editArea.last_undo){
368
- editArea.next= new Array(); // undo the ability to use "redo" button
369
- editArea.switchClassSticky($("redo"), 'editAreaButtonDisabled', true);
415
+ editArea.next= []; // undo the ability to use "redo" button
416
+ editArea.switchClassSticky(_$("redo"), 'editAreaButtonDisabled', true);
370
417
  }
371
418
  else
372
419
  {
373
- this.switchClassSticky($("redo"), 'editAreaButtonNormal', false);
420
+ this.switchClassSticky(_$("redo"), 'editAreaButtonNormal', false);
374
421
  }
375
422
  };
376
423
 
@@ -424,20 +471,27 @@
424
471
 
425
472
  //make the "page up" and "page down" buttons works correctly
426
473
  EditArea.prototype.scroll_page= function(params){
427
- var dir= params["dir"];
428
- var shift_pressed= params["shift"];
429
- screen_height=$("result").clientHeight;
474
+ var dir= params["dir"], shift_pressed= params["shift"];
430
475
  var lines= this.textarea.value.split("\n");
431
- var new_pos=0;
432
- var length=0;
433
- var char_left=0;
434
- var line_nb=0;
476
+ var new_pos=0, length=0, char_left=0, line_nb=0, curLine=0;
477
+ var toScrollAmount = _$("result").clientHeight -30;
478
+ var nbLineToScroll = 0, diff= 0;
479
+
435
480
  if(dir=="up"){
436
- //val= Math.max(0, $("result").scrollTop - screen_height);
437
- //$("result").scrollTop= val;
438
- var scroll_line= Math.ceil((screen_height -30)/this.lineHeight);
481
+ nbLineToScroll = Math.ceil( toScrollAmount / this.lineHeight );
482
+
483
+ // fix number of line to scroll
484
+ for( i = this.last_selection["line_start"]; i - diff > this.last_selection["line_start"] - nbLineToScroll ; i-- )
485
+ {
486
+ if( elem = _$('line_'+ i) )
487
+ {
488
+ diff += Math.floor( ( elem.offsetHeight - 1 ) / this.lineHeight );
489
+ }
490
+ }
491
+ nbLineToScroll -= diff;
492
+
439
493
  if(this.last_selection["selec_direction"]=="up"){
440
- for(line_nb=0; line_nb< Math.min(this.last_selection["line_start"]-scroll_line, lines.length); line_nb++){
494
+ for(line_nb=0; line_nb< Math.min(this.last_selection["line_start"]-nbLineToScroll, lines.length); line_nb++){
441
495
  new_pos+= lines[line_nb].length + 1;
442
496
  }
443
497
  char_left=Math.min(lines[Math.min(lines.length-1, line_nb)].length, this.last_selection["curr_pos"]-1);
@@ -447,7 +501,7 @@
447
501
  view="top";
448
502
  }else{
449
503
  view="bottom";
450
- for(line_nb=0; line_nb< Math.min(this.last_selection["line_start"]+this.last_selection["line_nb"]-1-scroll_line, lines.length); line_nb++){
504
+ for(line_nb=0; line_nb< Math.min(this.last_selection["line_start"]+this.last_selection["line_nb"]-1-nbLineToScroll, lines.length); line_nb++){
451
505
  new_pos+= lines[line_nb].length + 1;
452
506
  }
453
507
  char_left=Math.min(lines[Math.min(lines.length-1, line_nb)].length, this.last_selection["curr_pos"]-1);
@@ -462,13 +516,23 @@
462
516
  this.area_select(start, length);
463
517
 
464
518
  }
465
- }else{
466
- //val= Math.max($("result").style.height.replace("px", ""), $("result").scrollTop + screen_height);
467
- //$("result").scrollTop= val;
468
- var scroll_line= Math.floor((screen_height-30)/this.lineHeight);
519
+ }
520
+ else
521
+ {
522
+ var nbLineToScroll= Math.floor( toScrollAmount / this.lineHeight );
523
+ // fix number of line to scroll
524
+ for( i = this.last_selection["line_start"]; i + diff < this.last_selection["line_start"] + nbLineToScroll ; i++ )
525
+ {
526
+ if( elem = _$('line_'+ i) )
527
+ {
528
+ diff += Math.floor( ( elem.offsetHeight - 1 ) / this.lineHeight );
529
+ }
530
+ }
531
+ nbLineToScroll -= diff;
532
+
469
533
  if(this.last_selection["selec_direction"]=="down"){
470
534
  view="bottom";
471
- for(line_nb=0; line_nb< Math.min(this.last_selection["line_start"]+this.last_selection["line_nb"]-2+scroll_line, lines.length); line_nb++){
535
+ for(line_nb=0; line_nb< Math.min(this.last_selection["line_start"]+this.last_selection["line_nb"]-2+nbLineToScroll, lines.length); line_nb++){
472
536
  if(line_nb==this.last_selection["line_start"]-1)
473
537
  char_left= this.last_selection["selectionStart"] -new_pos;
474
538
  new_pos+= lines[line_nb].length + 1;
@@ -485,7 +549,7 @@
485
549
 
486
550
  }else{
487
551
  view="top";
488
- for(line_nb=0; line_nb< Math.min(this.last_selection["line_start"]+scroll_line-1, lines.length, lines.length); line_nb++){
552
+ for(line_nb=0; line_nb< Math.min(this.last_selection["line_start"]+nbLineToScroll-1, lines.length, lines.length); line_nb++){
489
553
  if(line_nb==this.last_selection["line_start"]-1)
490
554
  char_left= this.last_selection["selectionStart"] -new_pos;
491
555
  new_pos+= lines[line_nb].length + 1;
@@ -502,137 +566,133 @@
502
566
  }
503
567
 
504
568
  }
505
- }
506
-
569
+ }
570
+ //console.log( new_pos, char_left, length, nbLineToScroll, toScrollAmount, _$("result").clientHeigh );
507
571
  this.check_line_selection();
508
572
  this.scroll_to_view(view);
509
573
  };
510
574
 
511
- EditArea.prototype.start_resize= function(e){
512
- parent.editAreaLoader.resize["id"]= editArea.id;
513
- parent.editAreaLoader.resize["start_x"]= (e)? e.pageX : event.x + document.body.scrollLeft;
514
- parent.editAreaLoader.resize["start_y"]= (e)? e.pageY : event.y + document.body.scrollTop;
515
- if(editArea.nav['isIE']){
575
+ EditArea.prototype.start_resize= function(e){
576
+ parent.editAreaLoader.resize["id"] = editArea.id;
577
+ parent.editAreaLoader.resize["start_x"] = (e)? e.pageX : event.x + document.body.scrollLeft;
578
+ parent.editAreaLoader.resize["start_y"] = (e)? e.pageY : event.y + document.body.scrollTop;
579
+ if(editArea.isIE)
580
+ {
516
581
  editArea.textarea.focus();
517
582
  editArea.getIESelection();
518
583
  }
519
- parent.editAreaLoader.resize["selectionStart"]= editArea.textarea.selectionStart;
520
- parent.editAreaLoader.resize["selectionEnd"]= editArea.textarea.selectionEnd;
521
- /*parent.editAreaLoader.resize["frame_top"]= parent.calculeOffsetTop(parent.editAreas[editArea.id]["textarea"]);
522
- /*parent.editAreaLoader.resize["frame_left"]= parent.calculeOffsetLeft(parent.frames[editArea.id]);*/
584
+ parent.editAreaLoader.resize["selectionStart"] = editArea.textarea.selectionStart;
585
+ parent.editAreaLoader.resize["selectionEnd"] = editArea.textarea.selectionEnd;
523
586
  parent.editAreaLoader.start_resize_area();
524
587
  };
525
588
 
526
589
  EditArea.prototype.toggle_full_screen= function(to){
590
+ var t=this, p=parent, a=t.textarea, html, frame, selStart, selEnd, old, icon;
527
591
  if(typeof(to)=="undefined")
528
- to= !this.fullscreen['isFull'];
529
- var old= this.fullscreen['isFull'];
530
- this.fullscreen['isFull']= to;
531
- var icon= $("fullscreen");
592
+ to= !t.fullscreen['isFull'];
593
+ old = t.fullscreen['isFull'];
594
+ t.fullscreen['isFull']= to;
595
+ icon = _$("fullscreen");
596
+ selStart = t.textarea.selectionStart;
597
+ selEnd = t.textarea.selectionEnd;
598
+ html = p.document.getElementsByTagName("html")[0];
599
+ frame = p.document.getElementById("frame_"+t.id);
600
+
532
601
  if(to && to!=old)
533
602
  { // toogle on fullscreen
534
- var selStart= this.textarea.selectionStart;
535
- var selEnd= this.textarea.selectionEnd;
536
- var html= parent.document.getElementsByTagName("html")[0];
537
- var frame= parent.document.getElementById("frame_"+this.id);
538
-
539
- this.fullscreen['old_overflow']= parent.get_css_property(html, "overflow");
540
- this.fullscreen['old_height']= parent.get_css_property(html, "height");
541
- this.fullscreen['old_width']= parent.get_css_property(html, "width");
542
- this.fullscreen['old_scrollTop']= html.scrollTop;
543
- this.fullscreen['old_scrollLeft']= html.scrollLeft;
544
- this.fullscreen['old_zIndex']= parent.get_css_property(frame, "z-index");
545
- if(this.nav['isOpera']){
546
- html.style.height= "100%";
547
- html.style.width= "100%";
548
- }
549
- html.style.overflow= "hidden";
550
- html.scrollTop=0;
551
- html.scrollLeft=0;
552
-
553
-
554
- //html.style.backgroundColor= "#FF0000";
555
- // alert(screen.height+"\n"+window.innerHeight+"\n"+html.clientHeight+"\n"+window.offsetHeight+"\n"+document.body.offsetHeight);
556
603
 
604
+ t.fullscreen['old_overflow'] = p.get_css_property(html, "overflow");
605
+ t.fullscreen['old_height'] = p.get_css_property(html, "height");
606
+ t.fullscreen['old_width'] = p.get_css_property(html, "width");
607
+ t.fullscreen['old_scrollTop'] = html.scrollTop;
608
+ t.fullscreen['old_scrollLeft'] = html.scrollLeft;
609
+ t.fullscreen['old_zIndex'] = p.get_css_property(frame, "z-index");
610
+ if(t.isOpera){
611
+ html.style.height = "100%";
612
+ html.style.width = "100%";
613
+ }
614
+ html.style.overflow = "hidden";
615
+ html.scrollTop = 0;
616
+ html.scrollLeft = 0;
557
617
 
558
- frame.style.position="absolute";
559
- frame.style.width= html.clientWidth+"px";
560
- frame.style.height= html.clientHeight+"px";
561
- frame.style.display="block";
562
- frame.style.zIndex="999999";
563
- frame.style.top="0px";
564
- frame.style.left="0px";
618
+ frame.style.position = "absolute";
619
+ frame.style.width = html.clientWidth+"px";
620
+ frame.style.height = html.clientHeight+"px";
621
+ frame.style.display = "block";
622
+ frame.style.zIndex = "999999";
623
+ frame.style.top = "0px";
624
+ frame.style.left = "0px";
565
625
 
566
626
  // if the iframe was in a div with position absolute, the top and left are the one of the div,
567
627
  // so I fix it by seeing at witch position the iframe start and correcting it
568
- frame.style.top= "-"+parent.calculeOffsetTop(frame)+"px";
569
- frame.style.left= "-"+parent.calculeOffsetLeft(frame)+"px";
628
+ frame.style.top = "-"+p.calculeOffsetTop(frame)+"px";
629
+ frame.style.left = "-"+p.calculeOffsetLeft(frame)+"px";
570
630
 
571
- // parent.editAreaLoader.execCommand(this.id, "update_size();");
631
+ // parent.editAreaLoader.execCommand(t.id, "update_size();");
572
632
  // var body=parent.document.getElementsByTagName("body")[0];
573
633
  // body.appendChild(frame);
574
634
 
575
- this.switchClassSticky(icon, 'editAreaButtonSelected', false);
576
- this.fullscreen['allow_resize']= this.resize_allowed;
577
- this.allow_resize(false);
635
+ t.switchClassSticky(icon, 'editAreaButtonSelected', false);
636
+ t.fullscreen['allow_resize']= t.resize_allowed;
637
+ t.allow_resize(false);
578
638
 
579
- //this.area_select(selStart, selEnd-selStart);
639
+ //t.area_select(selStart, selEnd-selStart);
580
640
 
581
641
 
582
642
  // opera can't manage to do a direct size update
583
- if(this.nav['isFirefox']){
584
- parent.editAreaLoader.execCommand(this.id, "update_size();");
585
- this.area_select(selStart, selEnd-selStart);
586
- this.scroll_to_view();
587
- this.focus();
643
+ if(t.isFirefox){
644
+ p.editAreaLoader.execCommand(t.id, "update_size();");
645
+ t.area_select(selStart, selEnd-selStart);
646
+ t.scroll_to_view();
647
+ t.focus();
588
648
  }else{
589
- setTimeout("parent.editAreaLoader.execCommand('"+ this.id +"', 'update_size();');editArea.focus();", 10);
649
+ p.editAreaLoader.execCommand(t.id, "update_size();");
650
+ setTimeout("editArea.focus();", 10);
651
+ //setTimeout("p.editAreaLoader.execCommand('"+ t.id +"', 'update_size();');editArea.focus();", 10);
590
652
  }
591
653
 
592
654
 
593
655
  }
594
656
  else if(to!=old)
595
657
  { // toogle off fullscreen
596
- var selStart= this.textarea.selectionStart;
597
- var selEnd= this.textarea.selectionEnd;
598
-
599
- var frame= parent.document.getElementById("frame_"+this.id);
600
658
  frame.style.position="static";
601
- frame.style.zIndex= this.fullscreen['old_zIndex'];
602
-
603
- var html= parent.document.getElementsByTagName("html")[0];
604
- // html.style.overflow= this.fullscreen['old_overflow'];
659
+ frame.style.zIndex= t.fullscreen['old_zIndex'];
605
660
 
606
- if(this.nav['isOpera']){
607
- html.style.height= "auto";
608
- html.style.width= "auto";
609
- html.style.overflow= "auto";
610
- }else if(this.nav['isIE'] && parent!=top){ // IE doesn't manage html overflow in frames like in normal page...
611
- html.style.overflow= "auto";
661
+ if(t.isOpera)
662
+ {
663
+ html.style.height = "auto";
664
+ html.style.width = "auto";
665
+ html.style.overflow = "auto";
666
+ }
667
+ else if(t.isIE && p!=top)
668
+ { // IE doesn't manage html overflow in frames like in normal page...
669
+ html.style.overflow = "auto";
612
670
  }
613
671
  else
614
- html.style.overflow= this.fullscreen['old_overflow'];
615
- html.scrollTop= this.fullscreen['old_scrollTop'];
616
- html.scrollTop= this.fullscreen['old_scrollLeft'];
672
+ {
673
+ html.style.overflow = t.fullscreen['old_overflow'];
674
+ }
675
+ html.scrollTop = t.fullscreen['old_scrollTop'];
676
+ html.scrollLeft = t.fullscreen['old_scrollLeft'];
617
677
 
618
- parent.editAreaLoader.hide(this.id);
619
- parent.editAreaLoader.show(this.id);
678
+ p.editAreaLoader.hide(t.id);
679
+ p.editAreaLoader.show(t.id);
620
680
 
621
- this.switchClassSticky(icon, 'editAreaButtonNormal', false);
622
- if(this.fullscreen['allow_resize'])
623
- this.allow_resize(this.fullscreen['allow_resize']);
624
- if(this.nav['isFirefox']){
625
- this.area_select(selStart, selEnd-selStart);
681
+ t.switchClassSticky(icon, 'editAreaButtonNormal', false);
682
+ if(t.fullscreen['allow_resize'])
683
+ t.allow_resize(t.fullscreen['allow_resize']);
684
+ if(t.isFirefox){
685
+ t.area_select(selStart, selEnd-selStart);
626
686
  setTimeout("editArea.scroll_to_view();", 10);
627
687
  }
628
688
 
629
- //parent.editAreaLoader.remove_event(parent.window, "resize", editArea.update_size);
689
+ //p.editAreaLoader.remove_event(p.window, "resize", editArea.update_size);
630
690
  }
631
691
 
632
692
  };
633
693
 
634
694
  EditArea.prototype.allow_resize= function(allow){
635
- var resize= $("resize_area");
695
+ var resize= _$("resize_area");
636
696
  if(allow){
637
697
 
638
698
  resize.style.visibility="visible";
@@ -681,7 +741,7 @@
681
741
  this.allready_used_syntax[new_syntax]=true;
682
742
  }
683
743
  // be sure that the select option is correctly updated
684
- var sel= $("syntax_selection");
744
+ var sel= _$("syntax_selection");
685
745
  if(sel && sel.value!=new_syntax)
686
746
  {
687
747
  for(var i=0; i<sel.length; i++){
@@ -692,8 +752,8 @@
692
752
 
693
753
  /* if(this.settings['syntax'].length==0)
694
754
  {
695
- this.switchClassSticky($("highlight"), 'editAreaButtonNormal', false);
696
- this.switchClassSticky($("reset_highlight"), 'editAreaButtonNormal', false);
755
+ this.switchClassSticky(_$("highlight"), 'editAreaButtonNormal', false);
756
+ this.switchClassSticky(_$("reset_highlight"), 'editAreaButtonNormal', false);
697
757
  this.change_highlight(true);
698
758
  }
699
759
  */
@@ -727,36 +787,63 @@
727
787
  };
728
788
 
729
789
  /***** Wrap mode *****/
790
+
791
+ // toggling function for set_wrap_mode
792
+ EditArea.prototype.toggle_word_wrap= function(){
793
+ this.set_word_wrap( !this.settings['word_wrap'] );
794
+ };
795
+
796
+
730
797
  // open a new tab for the given file
731
- EditArea.prototype.set_wrap_text= function(to){
732
- this.settings['wrap_text'] = to;
733
- if( this.settings['wrap_text'] )
798
+ EditArea.prototype.set_word_wrap= function(to){
799
+ var t=this, a= t.textarea;
800
+
801
+ if( t.isOpera )
802
+ {
803
+ this.settings['word_wrap']= false;
804
+ t.switchClassSticky( _$("word_wrap"), 'editAreaButtonDisabled', true );
805
+ return false;
806
+ }
807
+
808
+ if( to )
734
809
  {
735
810
  wrap_mode = 'soft';
736
- this.container.className+= ' wrap_text';
811
+ this.container.className+= ' word_wrap';
812
+ this.container.style.width="";
813
+ this.content_highlight.style.width="";
814
+ a.style.width="100%";
815
+ if( t.isIE && t.isIE < 7 ) // IE 6 count 50 px too much
816
+ {
817
+ a.style.width = ( a.offsetWidth-5 )+"px";
818
+ }
819
+
820
+ t.switchClassSticky( _$("word_wrap"), 'editAreaButtonSelected', false );
737
821
  }
738
822
  else
739
823
  {
740
824
  wrap_mode = 'off';
741
- this.container.className= this.container.className.replace(/ wrap_text/g, '');
825
+ this.container.className = this.container.className.replace(/word_wrap/g, '');
826
+ t.switchClassSticky( _$("word_wrap"), 'editAreaButtonNormal', true );
742
827
  }
828
+ this.textarea.previous_scrollWidth = '';
829
+ this.textarea.previous_scrollHeight = '';
743
830
 
744
-
745
- var t= this.textarea;
746
- t.wrap= wrap_mode;
747
- t.setAttribute('wrap', wrap_mode);
748
- // seul IE supporte de changer à la volée le wrap mode du textarea
749
- if(!this.nav['isIE']){
750
- var start=t.selectionStart, end= t.selectionEnd;
751
- var parNod = t.parentNode, nxtSib = t.nextSibling;
752
- parNod.removeChild(t); parNod.insertBefore(t, nxtSib);
831
+ a.wrap= wrap_mode;
832
+ a.setAttribute('wrap', wrap_mode);
833
+ // only IE can change wrap mode on the fly without element reloading
834
+ if(!this.isIE)
835
+ {
836
+ var start=a.selectionStart, end= a.selectionEnd;
837
+ var parNod = a.parentNode, nxtSib = a.nextSibling;
838
+ parNod.removeChild(a);
839
+ parNod.insertBefore(a, nxtSib);
753
840
  this.area_select(start, end-start);
754
- /* // v = s.value;
755
- n = s.cloneNode(true);
756
- n.setAttribute("wrap", val);
757
- s.parentNode.replaceChild(n, s);
758
- // n.value = v;*/
759
841
  }
842
+ // reset some optimisation
843
+ this.settings['word_wrap'] = to;
844
+ this.focus();
845
+ this.update_size();
846
+ this.check_line_selection();
760
847
  };
761
848
  /***** tabbed files managing functions *****/
762
849
 
@@ -767,27 +854,28 @@
767
854
  {
768
855
  var id= settings['id'];
769
856
  // create a new file object with defautl values
770
- var new_file= new Object();
771
- new_file['id']= id;
772
- new_file['title']= id;
773
- new_file['text']= "";
774
- new_file['last_selection']= "";
775
- new_file['last_text_to_highlight']= "";
776
- new_file['last_hightlighted_text']= "";
777
- new_file['previous']= new Array();
778
- new_file['next']= new Array();
779
- new_file['last_undo']= "";
780
- new_file['smooth_selection']= this.settings['smooth_selection'];
857
+ var new_file= {};
858
+ new_file['id'] = id;
859
+ new_file['title'] = id;
860
+ new_file['text'] = "";
861
+ new_file['last_selection'] = "";
862
+ new_file['last_text_to_highlight'] = "";
863
+ new_file['last_hightlighted_text'] = "";
864
+ new_file['previous'] = [];
865
+ new_file['next'] = [];
866
+ new_file['last_undo'] = "";
867
+ new_file['smooth_selection'] = this.settings['smooth_selection'];
781
868
  new_file['do_highlight']= this.settings['start_highlight'];
782
- new_file['syntax']= this.settings['syntax'];
783
- new_file['scroll_top']= 0;
784
- new_file['scroll_left']= 0;
869
+ new_file['syntax'] = this.settings['syntax'];
870
+ new_file['scroll_top'] = 0;
871
+ new_file['scroll_left'] = 0;
785
872
  new_file['selection_start']= 0;
786
873
  new_file['selection_end']= 0;
787
- new_file['edited']= false;
788
- new_file['font_size']= this.settings["font_size"];
789
- new_file['font_family']= this.settings["font_family"];
790
- new_file['toolbar']= {'links':{}, 'selects': {}};
874
+ new_file['edited'] = false;
875
+ new_file['font_size'] = this.settings["font_size"];
876
+ new_file['font_family'] = this.settings["font_family"];
877
+ new_file['word_wrap'] = this.settings["word_wrap"];
878
+ new_file['toolbar'] = {'links':{}, 'selects': {}};
791
879
  new_file['compare_edited_text']= new_file['text'];
792
880
 
793
881
 
@@ -800,7 +888,7 @@
800
888
  this.filesIdAssoc[html_id]= id;
801
889
  this.files[id]['html_id']= html_id;
802
890
 
803
- if(!$(this.files[id]['html_id']) && id!="")
891
+ if(!_$(this.files[id]['html_id']) && id!="")
804
892
  {
805
893
  // be sure the tab browsing area is displayed
806
894
  this.tab_browsing_area.style.display= "block";
@@ -808,7 +896,7 @@
808
896
  elem.id= this.files[id]['html_id'];
809
897
  var close= "<img src=\""+ parent.editAreaLoader.baseURL +"images/close.gif\" title=\""+ this.get_translation('close_tab', 'word') +"\" onclick=\"editArea.execCommand('close_file', editArea.filesIdAssoc['"+ html_id +"']);return false;\" class=\"hidden\" onmouseover=\"this.className=''\" onmouseout=\"this.className='hidden'\" />";
810
898
  elem.innerHTML= "<a onclick=\"javascript:editArea.execCommand('switch_to_file', editArea.filesIdAssoc['"+ html_id +"']);\" selec=\"none\"><b><span><strong class=\"edited\">*</strong>"+ this.files[id]['title'] + close +"</span></b></a>";
811
- $('tab_browsing_list').appendChild(elem);
899
+ _$('tab_browsing_list').appendChild(elem);
812
900
  var elem= document.createElement('text');
813
901
  this.update_size();
814
902
  }
@@ -834,7 +922,7 @@
834
922
  if(this.execCommand('file_close', this.files[id])!==false)
835
923
  {
836
924
  // remove the tab in the toolbar
837
- var li= $(this.files[id]['html_id']);
925
+ var li= _$(this.files[id]['html_id']);
838
926
  li.parentNode.removeChild(li);
839
927
  // select a new file
840
928
  if(id== this.curr_file)
@@ -843,15 +931,15 @@
843
931
  var is_next= false;
844
932
  for(var i in this.files)
845
933
  {
846
- if(is_next)
934
+ if( is_next )
847
935
  {
848
- next_file= i;
936
+ next_file = i;
849
937
  break;
850
938
  }
851
- else if(i==id)
852
- is_next= true;
939
+ else if( i == id )
940
+ is_next = true;
853
941
  else
854
- next_file= i;
942
+ next_file = i;
855
943
  }
856
944
  // display the next file
857
945
  this.switch_to_file(next_file);
@@ -865,57 +953,61 @@
865
953
 
866
954
  // backup current file datas
867
955
  EditArea.prototype.save_file= function(id){
868
- if(this.files[id])
956
+ var t= this, save, a_links, a_selects, save_butt, img, i;
957
+ if(t.files[id])
869
958
  {
870
- var save= this.files[id];
871
- save['last_selection']= this.last_selection;
872
- save['last_text_to_highlight']= this.last_text_to_highlight;
873
- save['last_hightlighted_text']= this.last_hightlighted_text;
874
- save['previous']= this.previous;
875
- save['next']= this.next;
876
- save['last_undo']= this.last_undo;
877
- save['smooth_selection']= this.smooth_selection;
878
- save['do_highlight']= this.do_highlight;
879
- save['syntax']= this.settings['syntax'];
880
- save['text']= this.textarea.value;
881
- save['scroll_top']= this.result.scrollTop;
882
- save['scroll_left']= this.result.scrollLeft;
883
- save['selection_start']= this.last_selection["selectionStart"];
884
- save['selection_end']= this.last_selection["selectionEnd"];
885
- save['font_size']= this.settings["font_size"];
886
- save['font_family']= this.settings["font_family"];
887
- save['toolbar']= {'links':{}, 'selects': {}};
959
+ var save= t.files[id];
960
+ save['last_selection'] = t.last_selection;
961
+ save['last_text_to_highlight'] = t.last_text_to_highlight;
962
+ save['last_hightlighted_text'] = t.last_hightlighted_text;
963
+ save['previous'] = t.previous;
964
+ save['next'] = t.next;
965
+ save['last_undo'] = t.last_undo;
966
+ save['smooth_selection'] = t.smooth_selection;
967
+ save['do_highlight'] = t.do_highlight;
968
+ save['syntax'] = t.settings['syntax'];
969
+ save['text'] = t.textarea.value;
970
+ save['scroll_top'] = t.result.scrollTop;
971
+ save['scroll_left'] = t.result.scrollLeft;
972
+ save['selection_start'] = t.last_selection["selectionStart"];
973
+ save['selection_end'] = t.last_selection["selectionEnd"];
974
+ save['font_size'] = t.settings["font_size"];
975
+ save['font_family'] = t.settings["font_family"];
976
+ save['word_wrap'] = t.settings["word_wrap"];
977
+ save['toolbar'] = {'links':{}, 'selects': {}};
978
+
888
979
  // save toolbar buttons state for fileSpecific buttons
889
- var links= $("toolbar_1").getElementsByTagName("a");
890
- for(var i=0; i<links.length; i++)
980
+ a_links= _$("toolbar_1").getElementsByTagName("a");
981
+ for( i=0; i<a_links.length; i++ )
891
982
  {
892
- if(links[i].getAttribute('fileSpecific')=='yes')
983
+ if( a_links[i].getAttribute('fileSpecific') == 'yes' )
893
984
  {
894
- var save_butt= new Object();
895
- var img= links[i].getElementsByTagName('img')[0];
896
- save_butt['classLock']= img.classLock;
897
- save_butt['className']= img.className;
898
- save_butt['oldClassName']= img.oldClassName;
985
+ save_butt = {};
986
+ img = a_links[i].getElementsByTagName('img')[0];
987
+ save_butt['classLock'] = img.classLock;
988
+ save_butt['className'] = img.className;
989
+ save_butt['oldClassName'] = img.oldClassName;
899
990
 
900
- save['toolbar']['links'][links[i].id]= save_butt;
991
+ save['toolbar']['links'][a_links[i].id]= save_butt;
901
992
  }
902
993
  }
994
+
903
995
  // save toolbar select state for fileSpecific buttons
904
- var selects= $("toolbar_1").getElementsByTagName("select");
905
- for(var i=0; i<selects.length; i++)
996
+ a_selects= _$("toolbar_1").getElementsByTagName("select");
997
+ for( i=0; i<a_selects.length; i++)
906
998
  {
907
- if(selects[i].getAttribute('fileSpecific')=='yes')
999
+ if(a_selects[i].getAttribute('fileSpecific')=='yes')
908
1000
  {
909
- save['toolbar']['selects'][selects[i].id]= selects[i].value;
1001
+ save['toolbar']['selects'][a_selects[i].id]= a_selects[i].value;
910
1002
  }
911
1003
  }
912
1004
 
913
- this.files[id]= save;
1005
+ t.files[id]= save;
914
1006
 
915
1007
  return save;
916
1008
  }
917
- else
918
- return false;
1009
+
1010
+ return false;
919
1011
  };
920
1012
 
921
1013
  // update file_datas
@@ -928,88 +1020,103 @@
928
1020
 
929
1021
  // display file datas
930
1022
  EditArea.prototype.display_file= function(id){
931
- // check if there is at least one tab file displayed
1023
+ var t = this, a= t.textarea, new_file, a_lis, a_selects, a_links, a_options, i, j;
1024
+
1025
+ // we're showing the empty file
932
1026
  if(id=='')
933
1027
  {
934
- this.textarea.readOnly= true;
935
- this.tab_browsing_area.style.display= "none";
936
- $("no_file_selected").style.display= "block";
937
- this.result.className= "empty";
938
- if(!this.files[''])
939
- this.open_file({id: ''});
1028
+ a.readOnly= true;
1029
+ t.tab_browsing_area.style.display= "none";
1030
+ _$("no_file_selected").style.display= "block";
1031
+ t.result.className= "empty";
1032
+ // clear current datas
1033
+ if(!t.files[''])
1034
+ {
1035
+ t.open_file({id: ''});
1036
+ }
1037
+ }
1038
+ // we try to show a non existent file, so we left
1039
+ else if( typeof( t.files[id] ) == 'undefined' )
1040
+ {
1041
+ return false;
940
1042
  }
1043
+ // display a normal file
941
1044
  else
942
1045
  {
943
- this.result.className= "";
944
- this.textarea.readOnly= !this.is_editable;
945
- $("no_file_selected").style.display= "none";
946
- this.tab_browsing_area.style.display= "block";
1046
+ t.result.className= "";
1047
+ a.readOnly= !t.is_editable;
1048
+ _$("no_file_selected").style.display= "none";
1049
+ t.tab_browsing_area.style.display= "block";
947
1050
  }
948
1051
 
949
- this.check_redo(true);
950
- this.check_undo(true);
951
- this.curr_file= id;
1052
+ // ensure to have last state for undo/redo actions
1053
+ t.check_redo(true);
1054
+ t.check_undo(true);
1055
+ t.curr_file= id;
952
1056
 
953
1057
  // replace selected tab file
954
- var lis= this.tab_browsing_area.getElementsByTagName('li');
955
- for(var i=0; i<lis.length; i++)
1058
+ a_lis= t.tab_browsing_area.getElementsByTagName('li');
1059
+ for( i=0; i<a_lis.length; i++)
956
1060
  {
957
- if(lis[i].id == this.files[id]['html_id'])
958
- lis[i].className='selected';
1061
+ if(a_lis[i].id == t.files[id]['html_id'])
1062
+ a_lis[i].className='selected';
959
1063
  else
960
- lis[i].className='';
1064
+ a_lis[i].className='';
961
1065
  }
962
1066
 
963
1067
  // replace next files datas
964
- var new_file= this.files[id];
1068
+ new_file= t.files[id];
965
1069
 
966
1070
  // restore text content
967
- this.textarea.value= new_file['text'];
1071
+ a.value= new_file['text'];
968
1072
 
969
1073
  // restore font-size
970
- this.set_font(new_file['font_family'], new_file['font_size']);
1074
+ t.set_font(new_file['font_family'], new_file['font_size']);
971
1075
 
972
1076
  // restore selection and scroll
973
- this.area_select(new_file['last_selection']['selection_start'], new_file['last_selection']['selection_end'] - new_file['last_selection']['selection_start']);
974
- this.manage_size(true);
975
- this.result.scrollTop= new_file['scroll_top'];
976
- this.result.scrollLeft= new_file['scroll_left'];
1077
+ t.area_select(new_file['last_selection']['selection_start'], new_file['last_selection']['selection_end'] - new_file['last_selection']['selection_start']);
1078
+ t.manage_size(true);
1079
+ t.result.scrollTop= new_file['scroll_top'];
1080
+ t.result.scrollLeft= new_file['scroll_left'];
977
1081
 
978
1082
  // restore undo, redo
979
- this.previous= new_file['previous'];
980
- this.next= new_file['next'];
981
- this.last_undo= new_file['last_undo'];
982
- this.check_redo(true);
983
- this.check_undo(true);
1083
+ t.previous= new_file['previous'];
1084
+ t.next= new_file['next'];
1085
+ t.last_undo= new_file['last_undo'];
1086
+ t.check_redo(true);
1087
+ t.check_undo(true);
984
1088
 
985
1089
  // restore highlight
986
- this.execCommand("change_highlight", new_file['do_highlight']);
987
- this.execCommand("change_syntax", new_file['syntax']);
1090
+ t.execCommand("change_highlight", new_file['do_highlight']);
1091
+ t.execCommand("change_syntax", new_file['syntax']);
988
1092
 
989
1093
  // smooth mode
990
- this.execCommand("change_smooth_selection_mode", new_file['smooth_selection']);
1094
+ t.execCommand("change_smooth_selection_mode", new_file['smooth_selection']);
1095
+
1096
+ // word_wrap
1097
+ t.execCommand("set_word_wrap", new_file['word_wrap']);
991
1098
 
992
1099
  // restore links state in toolbar
993
- var links= new_file['toolbar']['links'];
994
- for(var i in links)
1100
+ a_links= new_file['toolbar']['links'];
1101
+ for( i in a_links)
995
1102
  {
996
- if(img= $(i).getElementsByTagName('img')[0])
1103
+ if( img = _$(i).getElementsByTagName('img')[0] )
997
1104
  {
998
- var save_butt= new Object();
999
- img.classLock= links[i]['classLock'];
1000
- img.className= links[i]['className'];
1001
- img.oldClassName= links[i]['oldClassName'];
1105
+ img.classLock = a_links[i]['classLock'];
1106
+ img.className = a_links[i]['className'];
1107
+ img.oldClassName= a_links[i]['oldClassName'];
1002
1108
  }
1003
1109
  }
1110
+
1004
1111
  // restore select state in toolbar
1005
- var selects= new_file['toolbar']['selects'];
1006
- for(var i in selects)
1112
+ a_selects = new_file['toolbar']['selects'];
1113
+ for( i in a_selects)
1007
1114
  {
1008
- var options= $(i).options;
1009
- for(var j=0; j<options.length; j++)
1115
+ a_options = _$(i).options;
1116
+ for( j=0; j<a_options.length; j++)
1010
1117
  {
1011
- if(options[j].value == selects[i])
1012
- $(i).options[j].selected=true;
1118
+ if( a_options[j].value == a_selects[i] )
1119
+ _$(i).options[j].selected=true;
1013
1120
  }
1014
1121
  }
1015
1122
 
@@ -1067,9 +1174,9 @@
1067
1174
  // set if the file is edited or not
1068
1175
  EditArea.prototype.set_file_edited_mode= function(id, to){
1069
1176
  // change CSS for edited tab
1070
- if(this.files[id] && $(this.files[id]['html_id']))
1177
+ if(this.files[id] && _$(this.files[id]['html_id']))
1071
1178
  {
1072
- var link= $(this.files[id]['html_id']).getElementsByTagName('a')[0];
1179
+ var link= _$(this.files[id]['html_id']).getElementsByTagName('a')[0];
1073
1180
  if(to==true)
1074
1181
  {
1075
1182
  link.className= 'edited';