rsence 2.0.0.0.pre

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (311) hide show
  1. data/INSTALL.rdoc +295 -0
  2. data/LICENSE +622 -0
  3. data/README.rdoc +24 -0
  4. data/VERSION +1 -0
  5. data/bin/build_client.rb +254 -0
  6. data/bin/help +6 -0
  7. data/bin/launch.rb +120 -0
  8. data/bin/rdoc.sh +2 -0
  9. data/bin/restart +6 -0
  10. data/bin/rsence +120 -0
  11. data/bin/run +6 -0
  12. data/bin/run.rb +6 -0
  13. data/bin/save +6 -0
  14. data/bin/start +6 -0
  15. data/bin/status +6 -0
  16. data/bin/stop +6 -0
  17. data/conf/config.ru +5 -0
  18. data/conf/default_conf.yaml +337 -0
  19. data/conf/default_strings.yaml +77 -0
  20. data/conf/local_conf.yaml +14 -0
  21. data/conf/unicorn.conf +78 -0
  22. data/js/comm/comm/autosync/autosync.js +18 -0
  23. data/js/comm/comm/autosync/js.inc +0 -0
  24. data/js/comm/comm/comm.js +195 -0
  25. data/js/comm/comm/js.inc +0 -0
  26. data/js/comm/comm/queue/js.inc +0 -0
  27. data/js/comm/comm/queue/queue.js +183 -0
  28. data/js/comm/comm/session/js.inc +0 -0
  29. data/js/comm/comm/session/session.js +51 -0
  30. data/js/comm/comm/sessionwatcher/js.inc +0 -0
  31. data/js/comm/comm/sessionwatcher/sessionwatcher.js +43 -0
  32. data/js/comm/comm/transporter/js.inc +0 -0
  33. data/js/comm/comm/transporter/transporter.js +257 -0
  34. data/js/comm/comm/urlresponder/js.inc +0 -0
  35. data/js/comm/comm/urlresponder/urlresponder.js +148 -0
  36. data/js/comm/comm/values/js.inc +0 -0
  37. data/js/comm/comm/values/values.js +432 -0
  38. data/js/comm/jsloader/js.inc +0 -0
  39. data/js/comm/jsloader/jsloader.js +114 -0
  40. data/js/comm/reloadapp/js.inc +0 -0
  41. data/js/comm/reloadapp/reloadapp.js +150 -0
  42. data/js/comm/reloadapp/themes/default/reloadapp_warning-ie6.gif +0 -0
  43. data/js/comm/reloadapp/themes/default/reloadapp_warning.png +0 -0
  44. data/js/comm/sha/js.inc +0 -0
  45. data/js/comm/sha/sha.js +432 -0
  46. data/js/comm/values/value/js.inc +0 -0
  47. data/js/comm/values/value/value.js +182 -0
  48. data/js/comm/values/valuematrix/js.inc +0 -0
  49. data/js/comm/values/valuematrix/valuematrix.js +138 -0
  50. data/js/controls/button/button.js +57 -0
  51. data/js/controls/button/js.inc +0 -0
  52. data/js/controls/button/themes/bright/button.css +89 -0
  53. data/js/controls/button/themes/bright/button.html +7 -0
  54. data/js/controls/button/themes/bright/button_parts1-ie6.gif +0 -0
  55. data/js/controls/button/themes/bright/button_parts1.png +0 -0
  56. data/js/controls/button/themes/default/button.css +89 -0
  57. data/js/controls/button/themes/default/button.html +7 -0
  58. data/js/controls/button/themes/default/button_parts1-ie6.gif +0 -0
  59. data/js/controls/button/themes/default/button_parts1.png +0 -0
  60. data/js/controls/checkbox/checkbox.js +47 -0
  61. data/js/controls/checkbox/js.inc +0 -0
  62. data/js/controls/checkbox/themes/default/checkbox.css +69 -0
  63. data/js/controls/checkbox/themes/default/checkbox.html +5 -0
  64. data/js/controls/checkbox/themes/default/checkbox_parts1-ie6.gif +0 -0
  65. data/js/controls/checkbox/themes/default/checkbox_parts1.png +0 -0
  66. data/js/controls/datetime/calendar/calendar.js +197 -0
  67. data/js/controls/datetime/calendar/js.inc +0 -0
  68. data/js/controls/datetime/calendar/themes/default/calendar.css +108 -0
  69. data/js/controls/datetime/calendar/themes/default/calendar.html +9 -0
  70. data/js/controls/datetime/calendar/themes/default/calendar_arrows-ie6.gif +0 -0
  71. data/js/controls/datetime/calendar/themes/default/calendar_arrows.png +0 -0
  72. data/js/controls/datetime/datetimevalue/datetimevalue.js +246 -0
  73. data/js/controls/datetime/datetimevalue/js.inc +0 -0
  74. data/js/controls/datetime/timesheet/js.inc +0 -0
  75. data/js/controls/datetime/timesheet/themes/default/timesheet.css +30 -0
  76. data/js/controls/datetime/timesheet/themes/default/timesheet.html +2 -0
  77. data/js/controls/datetime/timesheet/timesheet.js +182 -0
  78. data/js/controls/datetime/timesheet_item/js.inc +0 -0
  79. data/js/controls/datetime/timesheet_item/themes/default/timesheet_item.css +42 -0
  80. data/js/controls/datetime/timesheet_item/themes/default/timesheet_item.html +8 -0
  81. data/js/controls/datetime/timesheet_item/timesheet_item.js +247 -0
  82. data/js/controls/datetime/timesheet_item_edit/js.inc +0 -0
  83. data/js/controls/datetime/timesheet_item_edit/timesheet_item_edit.js +274 -0
  84. data/js/controls/dialogs/alert_sheet/alert_sheet.js +62 -0
  85. data/js/controls/dialogs/alert_sheet/js.inc +0 -0
  86. data/js/controls/dialogs/confirm_sheet/confirm_sheet.js +36 -0
  87. data/js/controls/dialogs/confirm_sheet/js.inc +0 -0
  88. data/js/controls/dialogs/sheet/js.inc +0 -0
  89. data/js/controls/dialogs/sheet/sheet.js +83 -0
  90. data/js/controls/dialogs/sheet/themes/default/sheet.css +64 -0
  91. data/js/controls/dialogs/sheet/themes/default/sheet.html +14 -0
  92. data/js/controls/dialogs/sheet/themes/default/sheet_bg-ie6.gif +0 -0
  93. data/js/controls/dialogs/sheet/themes/default/sheet_bg.png +0 -0
  94. data/js/controls/dialogs/sheet/themes/default/sheet_dim-ie6.gif +0 -0
  95. data/js/controls/dialogs/sheet/themes/default/sheet_dim.png +0 -0
  96. data/js/controls/dialogs/sheet/themes/default/sheet_parts1-ie6.gif +0 -0
  97. data/js/controls/dialogs/sheet/themes/default/sheet_parts1.png +0 -0
  98. data/js/controls/dialogs/sheet/themes/default/sheet_parts2-ie6.gif +0 -0
  99. data/js/controls/dialogs/sheet/themes/default/sheet_parts2.png +0 -0
  100. data/js/controls/dialogs/sheet/themes/default/sheet_warning-ie6.gif +0 -0
  101. data/js/controls/dialogs/sheet/themes/default/sheet_warning.png +0 -0
  102. data/js/controls/imageview/imageview.js +108 -0
  103. data/js/controls/imageview/js.inc +0 -0
  104. data/js/controls/imageview/themes/default/blank.gif +0 -0
  105. data/js/controls/lists/checkboxlist/checkboxlist.js +170 -0
  106. data/js/controls/lists/checkboxlist/js.inc +0 -0
  107. data/js/controls/lists/listitems/js.inc +0 -0
  108. data/js/controls/lists/listitems/listitems.js +65 -0
  109. data/js/controls/lists/radiobuttonlist/js.inc +0 -0
  110. data/js/controls/lists/radiobuttonlist/radiobuttonlist.js +126 -0
  111. data/js/controls/passwordcontrol/js.inc +0 -0
  112. data/js/controls/passwordcontrol/passwordcontrol.js +22 -0
  113. data/js/controls/passwordcontrol/themes/default/passwordcontrol.css +0 -0
  114. data/js/controls/passwordcontrol/themes/default/passwordcontrol.html +18 -0
  115. data/js/controls/progress/progressbar/js.inc +0 -0
  116. data/js/controls/progress/progressbar/progressbar.js +36 -0
  117. data/js/controls/progress/progressbar/themes/default/progressbar.css +16 -0
  118. data/js/controls/progress/progressbar/themes/default/progressbar.html +2 -0
  119. data/js/controls/progress/progressindicator/js.inc +0 -0
  120. data/js/controls/progress/progressindicator/progressindicator.js +43 -0
  121. data/js/controls/radiobutton/js.inc +0 -0
  122. data/js/controls/radiobutton/radiobutton.js +41 -0
  123. data/js/controls/radiobutton/themes/default/radiobutton.css +69 -0
  124. data/js/controls/radiobutton/themes/default/radiobutton.html +5 -0
  125. data/js/controls/radiobutton/themes/default/radiobutton_parts1-ie6.gif +0 -0
  126. data/js/controls/radiobutton/themes/default/radiobutton_parts1.png +0 -0
  127. data/js/controls/sliders/slider/js.inc +0 -0
  128. data/js/controls/sliders/slider/slider.js +356 -0
  129. data/js/controls/sliders/slider/themes/default/hslider_tracks-ie6.gif +0 -0
  130. data/js/controls/sliders/slider/themes/default/hslider_tracks.png +0 -0
  131. data/js/controls/sliders/slider/themes/default/slider.css +108 -0
  132. data/js/controls/sliders/slider/themes/default/slider.html +5 -0
  133. data/js/controls/sliders/slider/themes/default/slider_thumbs-ie6.gif +0 -0
  134. data/js/controls/sliders/slider/themes/default/slider_thumbs.png +0 -0
  135. data/js/controls/sliders/vslider/js.inc +0 -0
  136. data/js/controls/sliders/vslider/themes/default/vslider.css +52 -0
  137. data/js/controls/sliders/vslider/themes/default/vslider.html +5 -0
  138. data/js/controls/sliders/vslider/themes/default/vslider_tracks-ie6.gif +0 -0
  139. data/js/controls/sliders/vslider/themes/default/vslider_tracks.png +0 -0
  140. data/js/controls/sliders/vslider/vslider.js +40 -0
  141. data/js/controls/stepper/js.inc +0 -0
  142. data/js/controls/stepper/stepper.js +212 -0
  143. data/js/controls/stepper/themes/default/stepper-ie6.gif +0 -0
  144. data/js/controls/stepper/themes/default/stepper.css +14 -0
  145. data/js/controls/stepper/themes/default/stepper.html +2 -0
  146. data/js/controls/stepper/themes/default/stepper.png +0 -0
  147. data/js/controls/stringview/js.inc +0 -0
  148. data/js/controls/stringview/stringview.js +49 -0
  149. data/js/controls/stringview/themes/default/stringview.css +8 -0
  150. data/js/controls/stringview/themes/default/stringview.html +1 -0
  151. data/js/controls/tab/js.inc +0 -0
  152. data/js/controls/tab/tab.js +276 -0
  153. data/js/controls/tab/themes/bright/tab.css +76 -0
  154. data/js/controls/tab/themes/bright/tab.html +6 -0
  155. data/js/controls/tab/themes/bright/tab_bg_color-ie6.gif +0 -0
  156. data/js/controls/tab/themes/bright/tab_bg_color.png +0 -0
  157. data/js/controls/tab/themes/bright/tab_border_pattern-ie6.gif +0 -0
  158. data/js/controls/tab/themes/bright/tab_border_pattern.png +0 -0
  159. data/js/controls/tab/themes/bright/tab_parts1-ie6.gif +0 -0
  160. data/js/controls/tab/themes/bright/tab_parts1.png +0 -0
  161. data/js/controls/tab/themes/default/tab.css +77 -0
  162. data/js/controls/tab/themes/default/tab.html +6 -0
  163. data/js/controls/tab/themes/default/tab_bg_color-ie6.gif +0 -0
  164. data/js/controls/tab/themes/default/tab_bg_color.png +0 -0
  165. data/js/controls/tab/themes/default/tab_border_pattern-ie6.gif +0 -0
  166. data/js/controls/tab/themes/default/tab_border_pattern.png +0 -0
  167. data/js/controls/tab/themes/default/tab_parts1-ie6.gif +0 -0
  168. data/js/controls/tab/themes/default/tab_parts1.png +0 -0
  169. data/js/controls/textarea/js.inc +0 -0
  170. data/js/controls/textarea/textarea.js +23 -0
  171. data/js/controls/textarea/themes/default/textarea.css +21 -0
  172. data/js/controls/textarea/themes/default/textarea.html +18 -0
  173. data/js/controls/textcontrol/js.inc +0 -0
  174. data/js/controls/textcontrol/textcontrol.js +372 -0
  175. data/js/controls/textcontrol/themes/default/textcontrol.css +107 -0
  176. data/js/controls/textcontrol/themes/default/textcontrol.html +18 -0
  177. data/js/controls/textcontrol/themes/default/textcontrol_parts1-ie6.gif +0 -0
  178. data/js/controls/textcontrol/themes/default/textcontrol_parts1.png +0 -0
  179. data/js/controls/textcontrol/themes/default/textcontrol_parts2-ie6.gif +0 -0
  180. data/js/controls/textcontrol/themes/default/textcontrol_parts2.png +0 -0
  181. data/js/controls/textcontrol/themes/default/textcontrol_parts3-ie6.gif +0 -0
  182. data/js/controls/textcontrol/themes/default/textcontrol_parts3.png +0 -0
  183. data/js/controls/uploader/js.inc +0 -0
  184. data/js/controls/uploader/themes/default/upload_progress.gif +0 -0
  185. data/js/controls/uploader/themes/default/uploader.css +108 -0
  186. data/js/controls/uploader/themes/default/uploader.html +27 -0
  187. data/js/controls/uploader/uploader.js +153 -0
  188. data/js/controls/validatorview/js.inc +0 -0
  189. data/js/controls/validatorview/themes/default/validator-ie6.gif +0 -0
  190. data/js/controls/validatorview/themes/default/validator.png +0 -0
  191. data/js/controls/validatorview/themes/default/validatorview.css +0 -0
  192. data/js/controls/validatorview/themes/default/validatorview.html +0 -0
  193. data/js/controls/validatorview/validatorview.js +55 -0
  194. data/js/controls/window/js.inc +0 -0
  195. data/js/controls/window/themes/default/window.css +219 -0
  196. data/js/controls/window/themes/default/window.html +17 -0
  197. data/js/controls/window/themes/default/window_bg_active-ie6.gif +0 -0
  198. data/js/controls/window/themes/default/window_bg_active.png +0 -0
  199. data/js/controls/window/themes/default/window_bg_inactive-ie6.gif +0 -0
  200. data/js/controls/window/themes/default/window_bg_inactive.png +0 -0
  201. data/js/controls/window/themes/default/window_buttons-ie6.gif +0 -0
  202. data/js/controls/window/themes/default/window_buttons.png +0 -0
  203. data/js/controls/window/themes/default/window_parts1-ie6.gif +0 -0
  204. data/js/controls/window/themes/default/window_parts1.png +0 -0
  205. data/js/controls/window/themes/default/window_parts2-ie6.gif +0 -0
  206. data/js/controls/window/themes/default/window_parts2.png +0 -0
  207. data/js/controls/window/window.js +284 -0
  208. data/js/core/class/class.js +317 -0
  209. data/js/core/class/js.inc +0 -0
  210. data/js/core/elem/elem.js +1376 -0
  211. data/js/core/elem/js.inc +0 -0
  212. data/js/core/event/event.js +1021 -0
  213. data/js/core/event/js.inc +0 -0
  214. data/js/core/iefix/ie_css_element.htc +5 -0
  215. data/js/core/iefix/ie_css_style.htc +5 -0
  216. data/js/core/iefix/iefix.js +359 -0
  217. data/js/core/iefix/js.inc +0 -0
  218. data/js/debugg/debugg.js +43 -0
  219. data/js/debugg/js.inc +0 -0
  220. data/js/foundation/application/application.js +209 -0
  221. data/js/foundation/application/js.inc +0 -0
  222. data/js/foundation/control/control.js +342 -0
  223. data/js/foundation/control/controldefaults/controldefaults.js +59 -0
  224. data/js/foundation/control/controldefaults/js.inc +0 -0
  225. data/js/foundation/control/dummyvalue/dummyvalue.js +50 -0
  226. data/js/foundation/control/dummyvalue/js.inc +0 -0
  227. data/js/foundation/control/dyncontrol/dyncontrol.js +494 -0
  228. data/js/foundation/control/dyncontrol/js.inc +0 -0
  229. data/js/foundation/control/dyncontrol/themes/default/dyncontrol.css +0 -0
  230. data/js/foundation/control/dyncontrol/themes/default/dyncontrol.html +0 -0
  231. data/js/foundation/control/eventresponder/eventresponder.js +713 -0
  232. data/js/foundation/control/eventresponder/js.inc +0 -0
  233. data/js/foundation/control/js.inc +0 -0
  234. data/js/foundation/control/valueresponder/js.inc +0 -0
  235. data/js/foundation/control/valueresponder/valueresponder.js +77 -0
  236. data/js/foundation/geom/point/js.inc +0 -0
  237. data/js/foundation/geom/point/point.js +202 -0
  238. data/js/foundation/geom/rect/js.inc +0 -0
  239. data/js/foundation/geom/rect/rect.js +610 -0
  240. data/js/foundation/json_renderer/js.inc +0 -0
  241. data/js/foundation/json_renderer/json_renderer.js +231 -0
  242. data/js/foundation/system/js.inc +0 -0
  243. data/js/foundation/system/system.js +369 -0
  244. data/js/foundation/thememanager/js.inc +0 -0
  245. data/js/foundation/thememanager/thememanager.js +387 -0
  246. data/js/foundation/view/js.inc +0 -0
  247. data/js/foundation/view/markupview/js.inc +0 -0
  248. data/js/foundation/view/markupview/markupview.js +113 -0
  249. data/js/foundation/view/morphanimation/js.inc +0 -0
  250. data/js/foundation/view/morphanimation/morphanimation.js +236 -0
  251. data/js/foundation/view/view.js +1804 -0
  252. data/js/foundation/view/viewdefaults/js.inc +0 -0
  253. data/js/foundation/view/viewdefaults/viewdefaults.js +25 -0
  254. data/js/views/centerview/centerview.js +45 -0
  255. data/js/views/centerview/js.inc +0 -0
  256. data/js/views/inlineview/inlineview.js +14 -0
  257. data/js/views/inlineview/js.inc +0 -0
  258. data/js/views/scrollview/js.inc +0 -0
  259. data/js/views/scrollview/scrollview.js +39 -0
  260. data/lib/conf/default.rb +220 -0
  261. data/lib/conf/wizard.rb +303 -0
  262. data/lib/daemon/daemon.rb +293 -0
  263. data/lib/http/broker.rb +102 -0
  264. data/lib/http/rackup.rb +88 -0
  265. data/lib/http/request.rb +69 -0
  266. data/lib/http/response.rb +63 -0
  267. data/lib/plugins/gui_plugin.rb +129 -0
  268. data/lib/plugins/guiparser.rb +114 -0
  269. data/lib/plugins/plugin.rb +652 -0
  270. data/lib/plugins/plugin_plugins.rb +47 -0
  271. data/lib/plugins/plugin_sqlite_db.rb +72 -0
  272. data/lib/plugins/plugin_util.rb +96 -0
  273. data/lib/plugins/pluginmanager.rb +517 -0
  274. data/lib/plugins/servlet.rb +69 -0
  275. data/lib/session/msg.rb +291 -0
  276. data/lib/session/sessionmanager.rb +491 -0
  277. data/lib/session/sessionstorage.rb +314 -0
  278. data/lib/transporter/transporter.rb +254 -0
  279. data/lib/util/gzstring.rb +5 -0
  280. data/lib/values/hvalue.rb +323 -0
  281. data/lib/values/valuemanager.rb +152 -0
  282. data/plugins/client_pkg/client_pkg.rb +186 -0
  283. data/plugins/client_pkg/info.yaml +25 -0
  284. data/plugins/client_pkg/lib/client_pkg_build.rb +569 -0
  285. data/plugins/client_pkg/lib/client_pkg_cache.rb +50 -0
  286. data/plugins/client_pkg/lib/client_pkg_serve.rb +210 -0
  287. data/plugins/client_pkg/log/build_log +0 -0
  288. data/plugins/index_html/img/loading.gif +0 -0
  289. data/plugins/index_html/img/riassence.gif +0 -0
  290. data/plugins/index_html/index_html.rb +150 -0
  291. data/plugins/index_html/tmpl/index.html +22 -0
  292. data/plugins/index_html/tmpl/startup_index.html +29 -0
  293. data/plugins/legacy/disabled +0 -0
  294. data/plugins/legacy/disabled- +0 -0
  295. data/plugins/legacy/info.yaml +22 -0
  296. data/plugins/legacy/legacy.rb +15 -0
  297. data/plugins/main/js/riassence_ns.js +87 -0
  298. data/plugins/main/main.rb +234 -0
  299. data/plugins/main/values.yaml +8 -0
  300. data/plugins/ticketservices/lib/common.rb +300 -0
  301. data/plugins/ticketservices/lib/favicon.rb +38 -0
  302. data/plugins/ticketservices/lib/file.rb +58 -0
  303. data/plugins/ticketservices/lib/img.rb +50 -0
  304. data/plugins/ticketservices/lib/objblob.rb +66 -0
  305. data/plugins/ticketservices/lib/rsrc.rb +34 -0
  306. data/plugins/ticketservices/lib/upload.rb +206 -0
  307. data/plugins/ticketservices/ticketservices.rb +268 -0
  308. data/var/db/.git_include +0 -0
  309. data/var/log/.git_include +0 -0
  310. data/var/run/.git_include +0 -0
  311. metadata +390 -0
File without changes
@@ -0,0 +1,1021 @@
1
+ /* Riassence Framework
2
+ * Copyright 2007 Riassence Inc.
3
+ * http://riassence.com/
4
+ *
5
+ * You should have received a copy of the GNU General Public License along
6
+ * with this software package. If not, contact licensing@riassence.com
7
+ */
8
+
9
+ /*** = Description
10
+ ** Abstracts the DOM Event differences between browsers.
11
+ ***/
12
+ Event = {
13
+
14
+ /** Returns the element of the event.
15
+ **/
16
+ element: function(e) {
17
+ return e.target || e.srcElement;
18
+ },
19
+
20
+ /** Returns the mouse cursor x -coordinate of the event.
21
+ **/
22
+ pointerX: function(e) {
23
+ return e.pageX || e.clientX + document.documentElement.scrollLeft;
24
+ },
25
+
26
+ /** Returns the mouse cursor y -coordinate of the event.
27
+ **/
28
+ pointerY: function(e) {
29
+ return e.pageY || e.clientY + document.documentElement.scrollTop;
30
+ },
31
+
32
+ /** Stops event propagation
33
+ **/
34
+ stop: function(e) {
35
+ if (e.preventDefault) {
36
+ e.preventDefault();
37
+ e.stopPropagation();
38
+ }
39
+ else {
40
+ e.returnValue = false;
41
+ e.cancelBubble = true;
42
+ }
43
+ },
44
+
45
+ /** Returns true if the left mouse butten was clicked.
46
+ **/
47
+ isLeftClick: function(e) {
48
+ // IE: left 1, middle 4, right 2
49
+ if (BROWSER_TYPE.ie || BROWSER_TYPE.safari) {
50
+ return (e.button === 1);
51
+ }
52
+ else {
53
+ return (e.button === 0);
54
+ }
55
+ },
56
+
57
+ /** List of event observers
58
+ **/
59
+ observers: false,
60
+
61
+ /* Implementation of observe */
62
+ _observeAndCache: function(_elem, _name, _function, _useCapture) {
63
+ if (!Event.observers) {
64
+ Event.observers = [];
65
+ }
66
+ if (_elem.addEventListener) {
67
+ this.observers.push([_elem, _name, _function, _useCapture]);
68
+ _elem.addEventListener(_name, _function, _useCapture);
69
+ }
70
+ else if (_elem.attachEvent) {
71
+ this.observers.push([_elem, _name, _function, _useCapture]);
72
+ _elem.attachEvent("on" + _name, _function);
73
+ }
74
+ },
75
+
76
+ /** Flushes the event observer cache.
77
+ **/
78
+ unloadCache: function() {
79
+ if (!Event.observers) {
80
+ return;
81
+ }
82
+ var i,
83
+ l = Event.observers.length;
84
+ for (i = 0; i < l; i++) {
85
+ Event.stopObserving.apply(this, Event.observers[0]);
86
+ }
87
+ Event.observers = false;
88
+ },
89
+
90
+ /** Starts observing the named event of the element and
91
+ * specifies a callback function.
92
+ **/
93
+ observe: function(_elem, _name, _function, _useCapture) {
94
+ _useCapture = _useCapture || false;
95
+ Event._observeAndCache(_elem, _name, _function, _useCapture);
96
+ },
97
+
98
+ /** Stops observing the named event of the element and
99
+ * removes the callback function.
100
+ **/
101
+ stopObserving: function(_elem, _name, _function, _useCapture) {
102
+ if (_elem === undefined) {
103
+ console.log('Warning Event.stopObserving of event name: "' + _name + '" called with an undefined elem!');
104
+ return;
105
+ }
106
+ _useCapture = _useCapture || false;
107
+ if (_elem['removeEventListener']) {
108
+ _elem.removeEventListener(_name, _function, _useCapture);
109
+ }
110
+ else if (detachEvent) {
111
+ _elem.detachEvent("on" + _name, _function);
112
+ }
113
+ var i = 0;
114
+ while (i < Event.observers.length) {
115
+ var eo = Event.observers[i];
116
+ if (eo && eo[0] === _elem && eo[1] === _name && eo[2] === _function && eo[3] === _useCapture) {
117
+ Event.observers[i] = null;
118
+ Event.observers.splice(i, 1);
119
+ }
120
+ else {
121
+ i++;
122
+ }
123
+ }
124
+ },
125
+
126
+ // List of ASCII "special characters":
127
+ KEY_BACKSPACE: 8,
128
+ KEY_TAB: 9,
129
+ KEY_RETURN: 13,
130
+ KEY_ESC: 27,
131
+ KEY_LEFT: 37,
132
+ KEY_UP: 38,
133
+ KEY_RIGHT: 39,
134
+ KEY_DOWN: 40,
135
+ KEY_DELETE: 46,
136
+ KEY_HOME: 36,
137
+ KEY_END: 35,
138
+ KEY_PAGEUP: 33,
139
+ KEY_PAGEDOWN: 34
140
+ };
141
+
142
+ // Activates the garbage collector of Internet Explorer
143
+ // when the document is unloaded:
144
+ if (BROWSER_TYPE.ie) {
145
+ Event.observe(window, "unload", Event.unloadCache, false);
146
+ }
147
+
148
+ // Default options for focus (all false)
149
+ _defaultFocusOptions = {
150
+ mouseMove: false,
151
+ mouseDown: false,
152
+ click: false,
153
+ mouseUp: false,
154
+ draggable: false,
155
+ droppable: false,
156
+ keyDown: false,
157
+ keyUp: false,
158
+ mouseWheel: false,
159
+ textEnter: false
160
+ };
161
+
162
+ /*** = Description
163
+ ** Mid-level event abstraction manager.
164
+ **
165
+ ** This engine serves the HControl classes, so usually the existence of it
166
+ ** is not obvious. The main interface to use it is the methods in HControl.
167
+ ***/
168
+ EVENT = {
169
+
170
+ /** = Description
171
+ * Array that keeps the last known global event status type.
172
+ *
173
+ * The format is an array with an index per "interesting" event value.
174
+ *
175
+ * = Indexes
176
+ * +EVENT.status[ EVENT.button1 ]+:: The state of the left mouse button.
177
+ * 0 when not pressed
178
+ * 1 when pressed.
179
+ *
180
+ * +EVENT.status[ EVENT.button2 ]+:: The state of the right mouse button.
181
+ * 0 when not pressed
182
+ * 1 when pressed.
183
+ *
184
+ * +EVENT.status[ EVENT.crsrX ]+:: The x-coordinate of the mouse cursor.
185
+ *
186
+ * +EVENT.status[ EVENT.crsrY ]+:: The y-coordinate of the mouse cursor.
187
+ *
188
+ * +EVENT.status[ EVENT.keysDown ]+:: A list of keycodes of all the keys
189
+ * currently held down in the order of
190
+ * occurrence (first pressed comes first,
191
+ * last pressed last).
192
+ *
193
+ * +EVENT.status[ EVENT.altKeyDown ]+:: The boolean status of the Alt
194
+ * modifier key being held down.
195
+ *
196
+ * +EVENT.status[ EVENT.ctrlKeyDown ]+:: The boolean status of the Ctrl
197
+ * modifier key being held down.
198
+ *
199
+ * +EVENT.status[ EVENT.shiftKeyDown ]+:: The boolean status of the Shift
200
+ * modifier key being held down.
201
+ *
202
+ **/
203
+ status: [false, false, 0, 0, [], false, false, false],
204
+
205
+ /** The index in the status array for the left mouse button.
206
+ **/
207
+ button1: 0,
208
+
209
+ /** The index in the status array for the right mouse button.
210
+ **/
211
+ button2: 1,
212
+
213
+ /** The index in the status array for the mouse cursor x coordinate.
214
+ **/
215
+ crsrX: 2,
216
+
217
+ /** The index in the status array for the mouse cursor y coordinate.
218
+ **/
219
+ crsrY: 3,
220
+
221
+ /** The index in the status array for the list of keycodes of all the
222
+ * keys currently held down in the order of occurrence (first pressed
223
+ * comes first, last pressed last).
224
+ *
225
+ **/
226
+ keysDown: 4,
227
+
228
+ /** The index in the status orray for the state of the Alt modifier key.
229
+ **/
230
+ altKeyDown: 5,
231
+
232
+ /** The index in the status orray for the state of the Ctrl modifier key.
233
+ **/
234
+ ctrlKeyDown: 6,
235
+
236
+ /** The index in the status orray for the state of the Shift modifier key.
237
+ **/
238
+ shiftKeyDown: 7,
239
+
240
+ /** A flag to disable, if your applications don't need drop events.
241
+ * Setting this to false when not needed improves overall performance,
242
+ * because the drop events need constant calculation of the mouse cursor
243
+ * location against all possible drop targets.
244
+ *
245
+ **/
246
+ enableDroppableChecks: true,
247
+
248
+ /** Initializes the members used by the drop -related events.
249
+ * This method is called from within EVENT and is never called,
250
+ * if enableDroppableChecks is false.
251
+ **/
252
+ startDroppable: function() {
253
+ var _this = EVENT;
254
+ _this.hovered = [];
255
+ // items currently under the mouse cursor
256
+ _this.hoverInterval = 50;
257
+ // 50 means send hover events at most with 50ms intervals
258
+ _this.hoverTimer = new Date().getTime();
259
+ // Time since last hover event triggered
260
+ },
261
+
262
+ /** Starts event listening.
263
+ **/
264
+ start: function() {
265
+ var _globalEventTargetElement = BROWSER_TYPE.ie?document:window,
266
+ _this = EVENT;
267
+ // _eventMap = [
268
+ Event.observe( _globalEventTargetElement, 'mousemove', _this.mouseMove );
269
+ Event.observe( _globalEventTargetElement, 'mouseup', _this.mouseUp );
270
+ Event.observe( _globalEventTargetElement, 'mousedown', _this.mouseDown );
271
+ Event.observe( _globalEventTargetElement, 'click', _this.click );
272
+ Event.observe( _globalEventTargetElement, 'keyup', _this.keyUp );
273
+ Event.observe( _globalEventTargetElement, 'keydown', _this.keyDown );
274
+ Event.observe( _globalEventTargetElement, 'keypress', _this.keyPress );
275
+ Event.observe( _globalEventTargetElement, 'contextmenu', _this.contextMenu );
276
+ Event.observe( _globalEventTargetElement, 'resize', _this.resize );
277
+ Event.observe( _globalEventTargetElement, 'mousewheel', _this.mouseWheel );
278
+ // ],
279
+ // i = 0;
280
+ // for (; i !== _eventMap.length; i++) {
281
+ // Event.observe(_globalEventTargetElement, _eventMap[i][0], _eventMap[i][1]);
282
+ // }
283
+ if (window.addEventListener) {
284
+ window.addEventListener('DOMMouseScroll', EVENT.mouseWheel, false);
285
+ window.addEventListener('resize', EVENT.resize, false);
286
+ }
287
+ //window.onmousewheel=document.onmousewheel=EVENT.mouseWheel;
288
+ _this.listeners = [];
289
+ // keep elemId buffer of all listeners
290
+ _this.focused = [];
291
+ // keep elemId buffer of all focused listeners
292
+ _this.resizeListeners = [];
293
+ // list of resize-event listeners
294
+ _this.coordListeners = [];
295
+ // global mouse movement listeners
296
+ _this.focusOptions = {};
297
+ // keep property lists by elemId
298
+ _this.dragItems = [];
299
+ // elemId of currently dragged items
300
+ if (_this.enableDroppableChecks) {
301
+ _this.startDroppable();
302
+ }
303
+
304
+ _this.topmostDroppable = null;
305
+ // the currently hovered element accepting droppable items
306
+ _this.textEnterCtrls = [];
307
+ // ID of controls with textfields
308
+ // position caching benefits performance, see coordCacheFlush
309
+ _this._coordCache = [];
310
+ _this._coordCacheFlag = true;
311
+ _this._lastCoordFlushTimeout = null;
312
+
313
+ _this.activeControl = null;
314
+ // control that currently has the focus
315
+ _this._lastKeyDown = null;
316
+ // the most recent keypress
317
+ },
318
+
319
+ /** Flushes the position cache by elemId, if no elemId is specified,
320
+ * everything is flushed.
321
+ **/
322
+ coordCacheFlush: function(_elemId) {
323
+ if (_elemId) {
324
+ EVENT._coordCache[_elemId] = null;
325
+ }
326
+ else {
327
+ EVENT._coordCache = [];
328
+ }
329
+ },
330
+
331
+ /** Registers the _ctrl object by event listener flags in _focusOptions.
332
+ **/
333
+ reg: function(_ctrl, _focusOptions) {
334
+ var _elemId,
335
+ _elem,
336
+ _this = EVENT,
337
+ _propIn;
338
+ // Binds the class to the element (so it can be called on the event)
339
+ _elemId = _ctrl.elemId;
340
+ _elem = ELEM.get(_elemId);
341
+ if (BROWSER_TYPE.ie) {
342
+ _elem.setAttribute('ctrl', _ctrl);
343
+ }
344
+ else {
345
+ _elem.ctrl = _ctrl;
346
+ }
347
+ _this.listeners[_elemId] = true;
348
+ _this.focused[_elemId] = false;
349
+ for (_propIn in _defaultFocusOptions) {
350
+ if (_focusOptions[_propIn] === undefined) {
351
+ _focusOptions[_propIn] = _defaultFocusOptions[_propIn];
352
+ }
353
+ }
354
+ _this.focusOptions[_elemId] = _focusOptions;
355
+ var _coordListenIdx = _this.coordListeners.indexOf(_elemId);
356
+ if (_focusOptions.mouseMove) {
357
+ if (_coordListenIdx === -1) {
358
+ _this.coordListeners.push(_elemId);
359
+ }
360
+ }
361
+ else if (_coordListenIdx !== -1) {
362
+ _this.coordListeners.splice(_coordListenIdx, 1);
363
+ }
364
+ //console.log('focusOptions:',_focusOptions);
365
+ //console.log('focusOptions.textEnter: ',_focusOptions.textEnter);
366
+ if (_focusOptions.textEnter) {
367
+ if (_this.textEnterCtrls.indexOf(_ctrl.viewId) === -1) {
368
+ _this.textEnterCtrls.push(_ctrl.viewId);
369
+ }
370
+ }
371
+ if (_focusOptions.resize) {
372
+ if (_this.resizeListeners.indexOf(_ctrl.viewId) === -1) {
373
+ _this.resizeListeners.push(_ctrl.viewId);
374
+ }
375
+ }
376
+ Event.observe(_elem, 'mouseover', _this._mouseOver);
377
+ },
378
+
379
+ /** Unregisters the _ctrl object event listeners
380
+ **/
381
+ unreg: function(_ctrl) {
382
+ var _this = EVENT,
383
+ _elemId,
384
+ _elem;
385
+ if (_ctrl === this.activeControl) {
386
+ _this.changeActiveControl(null);
387
+ }
388
+ _elemId = _ctrl.elemId;
389
+ _elem = ELEM.get(_elemId);
390
+
391
+ _this._coordCache[_elemId] = null;
392
+
393
+ _this.listeners[_elemId] = false;
394
+ _this.focused[_elemId] = false;
395
+ _this.focusOptions[_elemId] = { ctrl: _ctrl };
396
+ var _coordListenIdx = _this.coordListeners.indexOf(_elemId);
397
+ if (_coordListenIdx !== -1) {
398
+ _this.coordListeners.splice(_coordListenIdx, 1);
399
+ }
400
+
401
+ var _textEnterIndex = _this.textEnterCtrls.indexOf(_ctrl.viewId);
402
+ if (_textEnterIndex !== -1) {
403
+ _this.textEnterCtrls.splice(_textEnterIndex, 1);
404
+ }
405
+ var _resizeIndex = _this.resizeListeners.indexOf(_ctrl.viewId);
406
+ if (_resizeIndex !== -1) {
407
+ _this.resizeListeners.splice(_resizeIndex, 1);
408
+ }
409
+ if (_elem !== undefined) {
410
+ Event.stopObserving(_elem, 'mouseover', _this._mouseOver);
411
+ }
412
+ },
413
+
414
+ /** Receiver of the onResize event.
415
+ * Delegates calls to the high-level event receivers of all
416
+ * controls registered for the event.
417
+ **/
418
+ resize: function(e) {
419
+ var i = 0,
420
+ _this = EVENT,
421
+ _ctrlID,
422
+ _ctrl;
423
+ for (; i < _this.resizeListeners.length; i++) {
424
+ _ctrlID = _this.resizeListeners[i];
425
+ _ctrl = HSystem.views[_ctrlID];
426
+ if (_ctrl['resize']) {
427
+ _ctrl.resize();
428
+ }
429
+ if (_ctrl['onResize']) {
430
+ _ctrl.onResize();
431
+ }
432
+ }
433
+ },
434
+
435
+ /* Element-specific mouse over/out event receiver. */
436
+ _mouseOver: function(e) {
437
+ if (!Event.element) {
438
+ return;
439
+ }
440
+ var _that = Event.element(e);
441
+ while (_that && _that.ctrl === undefined) {
442
+ _that = _that.parentNode;
443
+ }
444
+ if (!_that) {
445
+ return;
446
+ }
447
+ var _this = _that.ctrl;
448
+ EVENT.focus(_this);
449
+ Event.stop(e);
450
+ },
451
+
452
+ /* Element-specific mouse over/out event receiver. */
453
+ _mouseOut: function(e) {
454
+ if (!Event.element) {
455
+ return;
456
+ }
457
+ var _that = Event.element(e);
458
+ while (_that && _that.ctrl === undefined) {
459
+ _that = _that.parentNode;
460
+ }
461
+ if (!_that) {
462
+ return;
463
+ }
464
+ var _this = _that.ctrl;
465
+ EVENT.blur(_this);
466
+ Event.stop(e);
467
+ },
468
+
469
+ /** Mid-level focus manager.
470
+ * Gets called on the onMouseOver event.
471
+ * Starts listening for onMouseOut to blur.
472
+ * Delegates focus calls to the high-level event receivers of all
473
+ * enabled controls registered.
474
+ **/
475
+ focus: function(_ctrl) {
476
+ var _this = EVENT,
477
+ _elemId = _ctrl.elemId,
478
+ _elem = ELEM.get(_elemId);
479
+ if (_this.focused[_elemId] === false ){ // && _this.dragItems.indexOf(_elemId) === -1) {
480
+ Event.stopObserving(_elem, 'mouseover', _this._mouseOver);
481
+ Event.observe(_elem, 'mouseout', _this._mouseOut);
482
+ _this.focused[_elemId] = true;
483
+ if (_ctrl['focus']) {
484
+ _ctrl.focus();
485
+ }
486
+ }
487
+ },
488
+
489
+ /** Mid-level blur (focus lost) manager.
490
+ * Gets called on the onMouseOut event.
491
+ * Starts listening for onMouseOver to (re)focus.
492
+ * Delegates blur calls to the high-level event receivers of all
493
+ * enabled controls registered.
494
+ **/
495
+ blur: function(_ctrl) {
496
+ var _this = EVENT,
497
+ _elemId = _ctrl.elemId,
498
+ _elem = ELEM.get(_elemId);
499
+ if (_this.focused[_elemId] === true ){ // && _this.dragItems.indexOf(_elemId) === -1) {
500
+ Event.stopObserving(_elem, 'mouseout', _this._mouseOut);
501
+ Event.observe(_elem, 'mouseover', _this._mouseOver);
502
+ _this.focused[_elemId] = false;
503
+ if (_ctrl['blur']) {
504
+ _ctrl.blur();
505
+ }
506
+ }
507
+ },
508
+
509
+ /** Mid-level mouse movement manager.
510
+ * Gets called on the onMouseMove event.
511
+ * Delegates the following calls to the high-level event receivers of all
512
+ * enabled controls registered, depending on the events they registered:
513
+ * - drag
514
+ * - mouseMove
515
+ * - endHover
516
+ * - startHover
517
+ *
518
+ **/
519
+ mouseMove: function(e) {
520
+ var _this = EVENT,
521
+ x = Event.pointerX(e),
522
+ y = Event.pointerY(e),
523
+ _currentlyDragging = _this.flushMouseMove(x, y);
524
+ _this.status[_this.crsrX] = x;
525
+ _this.status[_this.crsrY] = y;
526
+ _this._modifiers(e);
527
+ // might work
528
+ if (_currentlyDragging) {
529
+ Event.stop(e);
530
+ }
531
+ // Only prevent default action when we are dragging something.
532
+ },
533
+
534
+ /** Processes dragging calculations, triggered by mouseMove.
535
+ **/
536
+ flushMouseMove: function(x, y) {
537
+ var _this = EVENT,
538
+ _currentlyDragging = false,
539
+ i = 0,
540
+ j,
541
+ _elemId,
542
+ _ctrl;
543
+
544
+ clearTimeout(_this._lastCoordFlushTimeout);
545
+
546
+ // send drag event to all drag-interested ctrls
547
+ for (; i !== _this.dragItems.length; i++) {
548
+ _elemId = _this.dragItems[i];
549
+ _this.focusOptions[_elemId].ctrl.drag(x, y);
550
+ _this.coordCacheFlush(_elemId);
551
+ _currentlyDragging = true;
552
+ }
553
+
554
+ if (_this.enableDroppableChecks) {
555
+ // Check which items are under the mouse coordinates now.
556
+ if (new Date().getTime() > _this.hoverTimer + _this.hoverInterval) {
557
+ // sends mouseMove pseudo-events to ctrls interested
558
+ for (i = 0; i !== _this.coordListeners.length; i++) {
559
+ _elemId = _this.coordListeners[i];
560
+ _ctrl = _this.focusOptions[_elemId].ctrl;
561
+ _ctrl.mouseMove(x, y);
562
+ }
563
+ if (_this.enableDroppableChecks) {
564
+ _this._updateHoverItems();
565
+ }
566
+ // sends drag&drop pseudo-events
567
+ var _wasTopmostDroppable;
568
+ for (i = 0; i !== _this.dragItems.length; i++) {
569
+ // Find the current droppable while dragging.
570
+ _wasTopmostDroppable = _this.topmostDroppable;
571
+ _this.topmostDroppable = null;
572
+ _elemId = _this.dragItems[i];
573
+ _ctrl = _this.focusOptions[_elemId].ctrl;
574
+
575
+ // Check for a drop target from the currently hovered items
576
+ var _hoverIndex,
577
+ _dropCtrl;
578
+ for (j = 0; j !== _this.hovered.length; j++) {
579
+ _hoverIndex = _this.hovered[j];
580
+ if (_hoverIndex !== _elemId && _this.focusOptions[_hoverIndex].ctrl) {
581
+ _dropCtrl = _this.focusOptions[_hoverIndex].ctrl;
582
+ if (!_this.topmostDroppable ||
583
+ // First time
584
+ _dropCtrl.zIndex() > _this.topmostDroppable.zIndex() ||
585
+ // Z beaten
586
+ _dropCtrl.supr === _this.topmostDroppable) {
587
+ // subview
588
+ if (_this.focusOptions[_dropCtrl.elemId].droppable) {
589
+ _this.topmostDroppable = _dropCtrl;
590
+ // Finally, the item must accept drop events.
591
+ }
592
+ }
593
+ }
594
+ }
595
+
596
+ // Topmost item has changed, send startHover or endHover to the droppable.
597
+ if (_wasTopmostDroppable !== _this.topmostDroppable) {
598
+ if (_wasTopmostDroppable) {
599
+ _wasTopmostDroppable.endHover(_ctrl);
600
+ }
601
+ if (_this.topmostDroppable) {
602
+ _this.topmostDroppable.startHover(_ctrl);
603
+ }
604
+ }
605
+ }
606
+ _this.hoverTimer = new Date().getTime();
607
+ }
608
+ else {
609
+ _this._lastCoordFlushTimeout = setTimeout(
610
+ function(){
611
+ EVENT.flushMouseMove(x,y);
612
+ }, _this.hoverInterval
613
+ );
614
+ }
615
+ }
616
+ return _currentlyDragging;
617
+ },
618
+
619
+ // Loops through all registered items and store indices of elements
620
+ // that are currenly under the mouse cursor in .hovered array. Uses
621
+ // cached position and dimensions value when possible.
622
+ _updateHoverItems: function() {
623
+ var _this = EVENT,
624
+ x = _this.status[_this.crsrX],
625
+ y = _this.status[_this.crsrY],
626
+ i = 0,
627
+ _ctrl,
628
+ _elem,
629
+ _pos,
630
+ _size,
631
+ _coords;
632
+ _this.hovered = [];
633
+ for (; i !== _this.listeners.length; i++) {
634
+ if (!_this.listeners[i] || !_this.focusOptions[i].ctrl) {
635
+ continue;
636
+ }
637
+ _ctrl = _this.focusOptions[i].ctrl;
638
+ _elem = ELEM.get(i);
639
+ if (!_this._coordCacheFlag || !_this._coordCache[i]) {
640
+ _pos = ELEM.getVisiblePosition(_ctrl.elemId);
641
+ // [x,y]
642
+ _size = ELEM.getVisibleSize(_ctrl.elemId);
643
+ // [w,h]
644
+ _this._coordCache[i] = [_pos[0], _pos[1], _size[0], _size[1]];
645
+ }
646
+ _coords = _this._coordCache[i];
647
+
648
+ // Is the mouse pointer inside the element's rectangle?
649
+ if (x >= _coords[0] && x <= _coords[0] + _coords[2] && y >= _coords[1] && y <= _coords[1] + _coords[3]) {
650
+ _this.hovered.push(i);
651
+ }
652
+ }
653
+ },
654
+
655
+ /** = Description
656
+ * Starts dragging the control given.
657
+ *
658
+ * Call this method to start dragging another component.
659
+ *
660
+ * = Parameters
661
+ * +_ctrl+:: An object that uses the HControl API, becomes new drag target.
662
+ *
663
+ **/
664
+ startDragging: function(_ctrl) {
665
+ var _this = EVENT;
666
+ _this.dragItems = [_ctrl.elemId];
667
+ _this.focus(_ctrl);
668
+ _this.changeActiveControl(_ctrl);
669
+ _ctrl.startDrag(_this.status[_this.crsrX], _this.status[_this.crsrY]);
670
+ },
671
+
672
+ /** Mid-level mouse button press manager.
673
+ * Gets called on the onMouseDown event.
674
+ * Delegates the following calls to the high-level event receivers of all
675
+ * enabled controls registered, depending on the events they registered:
676
+ * - mouseDown
677
+ * - startDrag
678
+ *
679
+ **/
680
+ mouseDown: function(e, _isLeftButton) {
681
+ var _this = EVENT,
682
+ _didStartDrag = false,
683
+ x = _this.status[_this.crsrX],
684
+ y = _this.status[_this.crsrY],
685
+ i = 0,
686
+
687
+ // Unset the active control when clicking on anything.
688
+ _newActiveControl = null,
689
+
690
+ // The startDrag and mouseDown event receivers are first collected into
691
+ // these arrays and the events are sent after the active control status has
692
+ // been changed.
693
+ _startDragElementIds = [],
694
+ _mouseDownElementIds = [];
695
+
696
+ _this._modifiers(e);
697
+ if (_isLeftButton === undefined) {
698
+ _isLeftButton = Event.isLeftClick(e);
699
+ }
700
+ if (_isLeftButton) {
701
+ _this.status[_this.button1] = true;
702
+ }
703
+ else {
704
+ _this.status[_this.button2] = true;
705
+ }
706
+
707
+ for (; i !== _this.focused.length; i++) {
708
+ if (_this.focused[i] === true) {
709
+ // Set the active control to the currently focused item.
710
+ if (_this.focusOptions[i].ctrl.enabled) {
711
+ _newActiveControl = _this.focusOptions[i].ctrl;
712
+ }
713
+ if ((_this.focusOptions[i].draggable === true) && _this.dragItems.indexOf(i) === -1) {
714
+ _startDragElementIds.push(i);
715
+ }
716
+ else if (_this.focusOptions[i].mouseDown === true) {
717
+ _mouseDownElementIds.push(i);
718
+ }
719
+ }
720
+ }
721
+ // Handle the active control selection.
722
+ if (_newActiveControl) {
723
+ _this.changeActiveControl(_newActiveControl);
724
+ }
725
+ // Call the mouseDown and startDrag events after the active control change has been handled.
726
+ for (i = 0; i !== _startDragElementIds.length; i++) {
727
+ _this.dragItems.push(_startDragElementIds[i]);
728
+ _this.focusOptions[_startDragElementIds[i]].ctrl.startDrag(x, y);
729
+ _didStartDrag = true;
730
+ }
731
+
732
+ var _stopEvent = _mouseDownElementIds.length;
733
+ for (i = 0; i !== _mouseDownElementIds.length; i++) {
734
+ if (_this.focusOptions[_mouseDownElementIds[i]].ctrl.mouseDown(x, y, _isLeftButton)) {
735
+ _stopEvent--;
736
+ }
737
+ }
738
+ if (_didStartDrag) {
739
+ // Remove possible selections.
740
+ document.body.focus();
741
+ // Prevent text selection in MSIE when dragging starts.
742
+ _this._storedOnSelectStart = document.onselectstart;
743
+ document.onselectstart = function() {
744
+ return false;
745
+ };
746
+ Event.stop(e);
747
+ }
748
+ // Stop the event only when we are hovering over some control, allows normal DOM events to co-exist.
749
+ if (this.enableDroppableChecks) {
750
+ if ((_stopEvent === 0) && (_this.hovered.length !== 0) && (_newActiveControl && (_newActiveControl.textElemId === false))) {
751
+ Event.stop(e);
752
+ }
753
+ }
754
+ return true;
755
+ },
756
+
757
+ /** Mid-level mouse click manager.
758
+ * Gets called on the onClick event.
759
+ * Delegates click calls to the high-level event receivers of all
760
+ * controls registered for that event.
761
+ *
762
+ **/
763
+ click: function(e, _isLeftButton) {
764
+ var _this = EVENT,
765
+ x = _this.status[_this.crsrX],
766
+ y = _this.status[_this.crsrY],
767
+ i = 0,
768
+ // Unset the active control when clicking on anything.
769
+ _newActiveControl = null,
770
+ // The startDrag and mouseDown event receivers are first collected into
771
+ // these arrays and the events are sent after the active control status has
772
+ // been changed.
773
+ _clickElementIds = [];
774
+ _this._modifiers(e);
775
+ if (_isLeftButton === undefined) {
776
+ _isLeftButton = Event.isLeftClick(e);
777
+ }
778
+ if (_isLeftButton) {
779
+ _this.status[_this.button1] = true;
780
+ }
781
+ else {
782
+ _this.status[_this.button2] = true;
783
+ }
784
+ for (; i !== _this.focused.length; i++) {
785
+ if (_this.focused[i] === true) {
786
+ // Set the active control to the currently focused item.
787
+ if (_this.focusOptions[i].ctrl.enabled) {
788
+ _newActiveControl = _this.focusOptions[i].ctrl;
789
+ }
790
+ if (_this.focusOptions[i].click === true) {
791
+ _clickElementIds.push(i);
792
+ }
793
+ }
794
+ }
795
+ // Handle the active control selection.
796
+ if (_newActiveControl) {
797
+ _this.changeActiveControl(_newActiveControl);
798
+ }
799
+ var _stopEvent = _clickElementIds.length;
800
+ for (i = 0; i !== _clickElementIds.length; i++) {
801
+ if (_this.focusOptions[_clickElementIds[i]].ctrl.click(x, y, _isLeftButton)) {
802
+ _stopEvent--;
803
+ }
804
+ }
805
+ // Stop the event only when we are hovering over some control, allows normal DOM events to co-exist.
806
+ if (_this.enableDroppableChecks) {
807
+ if ((_stopEvent === 0) && (_this.hovered.length !== 0) && (_newActiveControl && (_newActiveControl.textElemId === false))) {
808
+ Event.stop(e);
809
+ }
810
+ }
811
+ //if(_this.hovered.length!==0){Event.stop(e);}
812
+ return true;
813
+ },
814
+
815
+ /** Changes active ctrl.
816
+ * The previous active ctrl gets the _lostActiveStatus pseudo-event,
817
+ * The new active ctrl gets the _gainedActiveStatus pseudo-event
818
+ **/
819
+ changeActiveControl: function(_ctrl) {
820
+ //console.log('EVENT.changeActiveControl: ',_ctrl);
821
+ var _this = EVENT,
822
+ // Store the currently active control so we can inform it, if it no longer is the active control.
823
+ _prevActiveCtrl = _this.activeControl;
824
+ // Did the active control change?
825
+ if (_ctrl !== _prevActiveCtrl) {
826
+ if (_prevActiveCtrl) {
827
+ // Previously active control just lost the active status.
828
+ _prevActiveCtrl.active = false;
829
+ _prevActiveCtrl._lostActiveStatus(_ctrl);
830
+ }
831
+ _this.activeControl = null;
832
+ if (_ctrl) {
833
+ // A new control gained the active status.
834
+ _ctrl.active = true;
835
+ _this.activeControl = _ctrl;
836
+ _ctrl._gainedActiveStatus(_prevActiveCtrl);
837
+ }
838
+ }
839
+ },
840
+
841
+
842
+ /** Mid-level mouse button release manager.
843
+ * Gets called on the onMouseUp event.
844
+ * Delegates the following calls to the high-level event receivers of all
845
+ * enabled controls registered, depending on the events they registered:
846
+ * - mouseUp
847
+ * - endHover
848
+ * - drop
849
+ * - endDrag
850
+ *
851
+ **/
852
+ mouseUp: function(e) {
853
+ var _this = EVENT,
854
+ _didEndDrag = false,
855
+ _isLeftButton = Event.isLeftClick(e),
856
+ x = _this.status[_this.crsrX],
857
+ y = _this.status[_this.crsrY],
858
+ _elemId,
859
+ _ctrl,
860
+ i = 0;
861
+ _this._modifiers(e);
862
+ _this.status[_this.button1] = false;
863
+ _this.status[_this.button2] = false;
864
+ // Send endDrag for the currently dragged items even when they don't have focus, and clear the drag item array.
865
+ for (; i !== _this.dragItems.length; i++) {
866
+ _elemId = _this.dragItems[i];
867
+ _ctrl = _this.focusOptions[_elemId].ctrl;
868
+ _ctrl.endDrag(x, y);
869
+ _didEndDrag = true;
870
+ // If the mouse slipped off the dragged item before the mouse button was released, blur the item manually
871
+ if (_this.enableDroppableChecks) {
872
+ _this._updateHoverItems();
873
+ if (_this.hovered.indexOf(_elemId) === -1) {
874
+ _this.blur(_ctrl);
875
+ }
876
+ }
877
+ // If there is a drop target in the currently hovered items, send drop to it.
878
+ if (_this.topmostDroppable) {
879
+ // Droppable found at the release point.
880
+ _this.topmostDroppable.endHover(_ctrl);
881
+ _this.topmostDroppable.drop(_ctrl);
882
+ _this.topmostDroppable = null;
883
+ }
884
+ }
885
+ _this.dragItems = [];
886
+ // Restore MSIE's ability to select text after dragging has ended.
887
+ if (_didEndDrag) {
888
+ document.onselectstart = _this._storedOnSelectStart;
889
+ }
890
+ // Check for mouseUp listeners.
891
+ for (i = 0; i !== _this.focused.length; i++) {
892
+ if (_this.focused[i] === true) {
893
+ if (_this.focusOptions[i].mouseUp === true) {
894
+ _this.focusOptions[i].ctrl.mouseUp(x, y, _isLeftButton);
895
+ }
896
+ }
897
+ }
898
+ return true;
899
+ },
900
+
901
+
902
+ /** Mid-level key press manager.
903
+ * Gets called on the onKeyDown event.
904
+ * Delegates keyDown calls to the high-level event receivers of all
905
+ * controls registered for that event.
906
+ **/
907
+ keyDown: function(e) {
908
+ var _this = EVENT,
909
+ _theKeyCode = e.keyCode;
910
+ _this._modifiers(e);
911
+ if (_this.activeControl && _this.focusOptions[_this.activeControl.elemId].keyDown === true) {
912
+ Event.stop(e);
913
+ // Workaround for msie rapid fire keydown
914
+ if (_this._lastKeyDown !== _theKeyCode) {
915
+ _this.activeControl.keyDown(_theKeyCode);
916
+ }
917
+ }
918
+ // Insert key to the realtime array, remove in keyUp
919
+ if (_this.status[_this.keysDown].indexOf(_theKeyCode) === -1) {
920
+ _this.status[_this.keysDown].push(_theKeyCode);
921
+ }
922
+ _this._lastKeyDown = _theKeyCode;
923
+ },
924
+
925
+
926
+ /** Mid-level key release manager.
927
+ * Gets called on the onKeyUp event.
928
+ * Delegates keyUp calls to the high-level event receivers of all
929
+ * controls registered for that event.
930
+ * Also delegates the textEnter calls to all controls
931
+ * registered for that event.
932
+ **/
933
+ keyUp: function(e) {
934
+ var _this = EVENT,
935
+ _theKeyCode = e.keyCode,
936
+ _keyCodeIndex,
937
+ i = 0,
938
+ _ctrlId,
939
+ _ctrl;
940
+ _this._modifiers(e);
941
+ _this._lastKeyDown = null;
942
+ if (_this.activeControl && _this.focusOptions[_this.activeControl.elemId].keyUp === true) {
943
+ _this.activeControl.keyUp(_theKeyCode);
944
+ }
945
+ for (; i < _this.textEnterCtrls.length; i++) {
946
+ _ctrlId = _this.textEnterCtrls[i];
947
+ _ctrl = HSystem.views[_ctrlId];
948
+ if (_ctrl.textEnter) {
949
+ _ctrl.textEnter();
950
+ }
951
+ }
952
+ // Remove the key from the realtime array, inserted in keyDown
953
+ _keyCodeIndex = _this.status[_this.keysDown].indexOf(_theKeyCode);
954
+ if (_keyCodeIndex !== -1) {
955
+ _this.status[_this.keysDown].splice(_keyCodeIndex, 1);
956
+ }
957
+ },
958
+
959
+ /* Prevents the onKeyPress event (key being hold down; we don't need that event) */
960
+ keyPress: function(e) {
961
+ var _this = EVENT;
962
+ if (_this.activeControl && _this.focusOptions[_this.activeControl.elemId].keyDown === true) {
963
+ Event.stop(e);
964
+ }
965
+ },
966
+
967
+
968
+ /** Mid-level mouse scroll wheel event manager.
969
+ * Delegates mouseWheel calls to the high-level event receivers of all
970
+ * controls registered for that event.
971
+ **/
972
+ mouseWheel: function(e) {
973
+ var _this = EVENT,
974
+ _delta = 0,
975
+ i = 0;
976
+ if (!e) {
977
+ e = window.event;
978
+ }
979
+ if (e.wheelDelta) {
980
+ _delta = 0 - (e.wheelDelta / 120);
981
+ }
982
+ else if (e.detail) {
983
+ _delta = 0 - (e.detail / 3);
984
+ }
985
+ if (BROWSER_TYPE.opera || BROWSER_TYPE.safari) {
986
+ _delta = 0 - _delta;
987
+ }
988
+ for (; i !== _this.focused.length; i++) {
989
+ if (_this.focused[i] === true) {
990
+ if (_this.focusOptions[i].mouseWheel === true) {
991
+ Event.stop(e);
992
+ _this.focusOptions[i].ctrl.mouseWheel(_delta);
993
+ }
994
+ }
995
+ }
996
+ },
997
+
998
+ /* Alternative right button detection, wrapper for the mouseDown method */
999
+ contextMenu: function(e) {
1000
+ EVENT.mouseDown(e, false);
1001
+ Event.stop(e);
1002
+ },
1003
+
1004
+ /* Handle the event modifiers. */
1005
+ _modifiers: function(e) {
1006
+ var _this = EVENT;
1007
+ _this.status[_this.altKeyDown] = e.altKey;
1008
+ _this.status[_this.ctrlKeyDown] = e.ctrlKey;
1009
+ _this.status[_this.shiftKeyDown] = e.shiftKey;
1010
+ }
1011
+
1012
+ };
1013
+
1014
+ /** Starts the only instance
1015
+ */
1016
+ LOAD(
1017
+ function() {
1018
+ EVENT.start();
1019
+ }
1020
+ );
1021
+