rsence-pre 2.1.0.1.pre

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