rsence 2.0.0.0.pre

Sign up to get free protection for your applications and to get access to all the features.
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,236 @@
1
+ /* Riassence Framework
2
+ * Copyright 2006 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
+ ** HMorphAnimation defines morphing animation.
11
+ **
12
+ ** HMorphAnimation is implemented by HView as an interface.
13
+ ** Its methods define the functionality to zoom from the current geometry to a
14
+ ** target geometry with animated intervals.
15
+ ***/
16
+ HMorphAnimation = HClass.extend({
17
+
18
+ /** = Description
19
+ * Moves the view smoothly into another location and/or size. The
20
+ * onAnimationStart event on the view gets called when the animation starts.
21
+ *
22
+ * = Parameters:
23
+ * +_obj+:: An instance of <HPoint> or <HRect>, depending on the desired
24
+ * animation result. When a point is passed, the view is moved in
25
+ * that position. When a rect is passed, the view can also be resized
26
+ * with or without moving to different coordinates.
27
+ *
28
+ * +_duration+:: _optional_ The duration of the animation in milliseconds. The
29
+ * default duration is 500 ms.
30
+ *
31
+ * +_fps+:: _optional_ The frame rate for the animation. The default fps is 50.
32
+ *
33
+ * = Returns:
34
+ * +self+
35
+ *
36
+ * = Usage:
37
+ * HView.extend({
38
+ * onAnimationEnd: function(){
39
+ * this.die();
40
+ * }
41
+ * }).nu(
42
+ * [ 0, 0, 300, 300 ],
43
+ * HApplication.nu()
44
+ * ).setStyle(
45
+ * 'background-color', 'red'
46
+ * ).animateTo(
47
+ * HRect.nu( 300, 300, 500, 500 )
48
+ * );
49
+ *
50
+ **/
51
+ animateTo: function(_obj, _duration, _fps) {
52
+ if(!this.drawn){
53
+ return this;
54
+ }
55
+ // Redirect the method call to _animateTo(HRect).
56
+ if(_obj instanceof HPoint) {
57
+ var _rect = new HRect(_obj, _obj);
58
+ _rect.setSize(this.rect.width, this.rect.height);
59
+ this._animateTo(_rect, _duration);
60
+ }
61
+ else if(_obj instanceof HRect) {
62
+ this._animateTo(_obj, _duration);
63
+ }
64
+ else {
65
+ throw "Wrong argument type.";
66
+ }
67
+ return this;
68
+ },
69
+
70
+
71
+ /** = Description
72
+ * Stops the current animation for this view. If the view is not being
73
+ * animated, this method has no effect. The onAnimationEnd event on the view
74
+ * gets called when the animation finishes (reaches the end position/size), but
75
+ * onAnimationCancel gets called when this method is called while the animation
76
+ * is still in action.
77
+ *
78
+ */
79
+ stopAnimation: function() {
80
+ if (this._animateInterval) {
81
+ // Stop the animation interval only if it has been set.
82
+ window.clearInterval(this._animateInterval);
83
+ this._animateInterval = null;
84
+
85
+ // Update the rect after the new position and size have been reached.
86
+ var _left = parseInt(this.style('left'), 10),
87
+ _top = parseInt(this.style('top'), 10),
88
+ _width = parseInt(this.style('width'), 10),
89
+ _height = parseInt(this.style('height'), 10);
90
+ this.rect.set(_left, _top, _left + _width, _top + _height);
91
+ this.drawRect();
92
+
93
+ if (this._animationDone) {
94
+ this.onAnimationEnd();
95
+ }
96
+ else {
97
+ this.onAnimationCancel();
98
+ }
99
+
100
+ }
101
+ return this;
102
+ },
103
+
104
+
105
+ // --Private method.++
106
+ // --Starts the animation with the target _rect.++
107
+ _animateTo: function(_rect, _duration, _fps) {
108
+
109
+ if (null === _duration || undefined === _duration) {
110
+ _duration = 500; // default duration is half second
111
+ }
112
+ if (null === _fps || undefined === _fps || _fps < 1) {
113
+ _fps = 50; // default fps
114
+ }
115
+
116
+ if (!this._animateInterval) {
117
+
118
+ this._animationDone = false;
119
+ this.onAnimationStart();
120
+
121
+ var _startTime = new Date().getTime();
122
+
123
+ var _that = this;
124
+ this._animateInterval = window.setInterval(
125
+ function() {
126
+ if(!_that){
127
+ return;
128
+ }
129
+ _that._animateStep({
130
+ startTime: _startTime,
131
+ duration: _duration,
132
+ // Linear transition effect.
133
+ transition: function(t, b, c, d) { return c * t / d + b; },
134
+ props: [{
135
+ prop: 'left',
136
+ from: _that.rect.left,
137
+ to: _rect.left,
138
+ unit: 'px'
139
+ },{
140
+ prop: 'top',
141
+ from: _that.rect.top,
142
+ to: _rect.top,
143
+ unit: 'px'
144
+ },{
145
+ prop: 'width',
146
+ from: _that.rect.width,
147
+ to: _rect.width,
148
+ unit: 'px'
149
+ },{
150
+ prop: 'height',
151
+ from: _that.rect.height,
152
+ to: _rect.height,
153
+ unit: 'px'
154
+ }]
155
+ });
156
+ }, Math.round(1000 / _fps)
157
+ );
158
+ }
159
+ return this;
160
+ },
161
+
162
+
163
+ // --Private method.++
164
+ // --Moves the view for one step. This gets called repeatedly when the animation++
165
+ // --is happening.++
166
+ _animateStep: function(_obj) {
167
+
168
+ var _time = new Date().getTime(), i;
169
+ if (_time < _obj.startTime + _obj.duration) {
170
+ var _cTime = _time - _obj.startTime;
171
+
172
+ // Handle all the defined properties.
173
+ for (i = 0; i < _obj.props.length; i++) {
174
+ var _from = _obj.props[i].from;
175
+ var _to = _obj.props[i].to;
176
+
177
+ if (_from !== _to) {
178
+ // The value of the property at this time.
179
+ var _propNow = _obj.transition(_cTime, _from, (_to - _from),
180
+ _obj.duration);
181
+ ELEM.setStyle(this.elemId,_obj.props[i].prop, _propNow + _obj.props[i].unit);
182
+ }
183
+ }
184
+
185
+ } else {
186
+ // Animation is done, clear the interval and finalize the animation.
187
+ for (i = 0; i < _obj.props.length; i++) {
188
+ ELEM.setStyle(this.elemId,_obj.props[i].prop,
189
+ _obj.props[i].to + _obj.props[i].unit);
190
+ }
191
+ this._animationDone = true;
192
+ this.stopAnimation();
193
+ }
194
+ return this;
195
+ },
196
+
197
+ /** = Description
198
+ * Extend the onAnimationStart method, if you want to do something special
199
+ * when this view starts animating.
200
+ *
201
+ * = Usage:
202
+ * HView.extend({
203
+ * onAnimationStart: function() {
204
+ * this.setStyle('background-color','green')
205
+ * },
206
+ * onAnimationEnd: function() {
207
+ * this.setStyle('background-color','grey')}
208
+ * }).nu(
209
+ * [0,0,300,300],
210
+ * HApplication.nu()
211
+ * ).setStyle(
212
+ * 'background-color','blue'
213
+ * ).animateTo(
214
+ * HRect.nu(
215
+ * 300,300,700,700
216
+ * )
217
+ * );
218
+ *
219
+ **/
220
+ onAnimationStart: function() {
221
+
222
+ },
223
+
224
+ /** Extend the onAnimationEnd method, if you want to do something special
225
+ * when an animation on this view is finished.
226
+ **/
227
+ onAnimationEnd: function() {
228
+
229
+ },
230
+
231
+ /** Extend this method if functionality is desired upon cancellation of animation.
232
+ **/
233
+ onAnimationCancel: function() {
234
+
235
+ }
236
+ });
@@ -0,0 +1,1804 @@
1
+ /* Riassence Framework
2
+ * Copyright 2006 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
+ ** HView is the foundation class for all views. HView is useful for
11
+ ** any type of view and control grouping. It is designed for easy extension
12
+ ** and it's the foundation for HControl and all other controls.
13
+ **
14
+ ** The major differences between HView and HControl is that HView handles
15
+ ** only visual representation and structurization. In addition to HView's
16
+ ** features, HControl handles labels, values, events, states and such.
17
+ ** However, HControl is more complex, so use HView instead whenever you don't
18
+ ** need the additional features of HControl. HView implements the HMarkupView
19
+ ** interface for template-related task.
20
+ **
21
+ ** = Usage
22
+ ** var myAppInstance = HApplication.nu();
23
+ ** var rect1 = [10, 10, 100, 100];
24
+ ** var myViewInstance = HView.nu( rect1, myAppInstance );
25
+ ** var myViewInstance.setStyle('background-color','#ffcc00');
26
+ ** var rect2 = [10, 10, 70, 70];
27
+ ** var mySubView1 = HView.nu( rect2, myViewIntance );
28
+ ** var rect3 [20, 20, 50, 50];
29
+ ** var mySubView2 = HView.nu( rect3, mySubView1 );
30
+ **
31
+ ***/
32
+
33
+ HView = HClass.extend({
34
+
35
+ /** Component specific theme path.
36
+ **/
37
+ themePath: null,
38
+
39
+ /** True, if the component using absolute positioning.
40
+ * False, if the component is using relative positioning.
41
+ **/
42
+ isAbsolute: true,
43
+
44
+ /** The display mode to use.
45
+ * Defaults to 'block'.
46
+ * The other sane alternative is 'inline'.
47
+ **/
48
+ displayMode: 'block',
49
+
50
+ /** The visual value of a component, usually a String.
51
+ * See +#setLabel+.
52
+ **/
53
+ label: null,
54
+
55
+ /** When true, calls the +refreshLabel+ method whenever
56
+ * +self.label+ is changed.
57
+ **/
58
+ refreshOnLabelChange: true,
59
+
60
+ /** Escapes HTML in the label when true.
61
+ **/
62
+ escapeLabelHTML: false,
63
+
64
+ /** True, if the coordinates are right-aligned.
65
+ * False, if the coordinates are left-aligned.
66
+ * Uses flexRightOffset if true. Defined with 6-item arrays
67
+ * for the _rect parameter of setRect or the constructor.
68
+ * Can be set directly using the setFlexRight method.
69
+ **/
70
+ flexRight: false,
71
+
72
+ /** True, if the coordinates are left-aligned.
73
+ * False, if the coordinates are right-aligned.
74
+ * Uses the X-coordinate of rect, if true.
75
+ * Disabled using 6-item arrays with null x-coordinate
76
+ * for the _rect parameter of setRect or the constructor.
77
+ * Can be set directly using the setFlexLeft method.
78
+ **/
79
+ flexLeft: true,
80
+
81
+ /** True, if the coordinates are top-aligned.
82
+ * False, if the coordinates are bottom-aligned.
83
+ * Uses the Y-coordinate of rect, if true.
84
+ * Disabled using 6-item arrays with null x-coordinate
85
+ * for the _rect parameter of setRect or the constructor.
86
+ * Can be set directly using the setFlexTop method.
87
+ **/
88
+ flexTop: true,
89
+
90
+ /** True, if the coordinates are bottom-aligned.
91
+ * False, if the coordinates are top-aligned.
92
+ * Uses flexBottomOffset if true. Defined with 6-item arrays
93
+ * for the _rect parameter of setRect or the constructor.
94
+ * Can be set directly using the setFlexRight method.
95
+ **/
96
+ flexBottom: false,
97
+
98
+ /** The amount of pixels to offset from the right edge when
99
+ * flexRight is true. Defined with 6-item arrays
100
+ * for the _rect parameter of setRect or the constructor.
101
+ * Can be set directly using the setFlexRight method.
102
+ **/
103
+ flexRightOffset: 0,
104
+
105
+ /** The amount of pixels to offset from the bottom edge when
106
+ * flexBottom is true.Defined with 6-item arrays
107
+ * for the _rect parameter of setRect or the constructor.
108
+ * Can be set directly using the setFlexBottom method.
109
+ **/
110
+ flexBottomOffset: 0,
111
+
112
+ /** The componentBehaviour array tells other classes what to
113
+ * expect of the component's API and visual behaviour.
114
+ * The first index is 'view' by default for all classes
115
+ * inherited from HView.
116
+ **/
117
+ componentBehaviour: ['view'],
118
+
119
+ /** The drawn flag is false before the component is visually
120
+ * drawn, it's true after it's drawn.
121
+ **/
122
+ drawn: false,
123
+
124
+ /** The theme the component is constructed with. By default,
125
+ * uses the HThemeManager.currentTheme specified at the time
126
+ * of construction.
127
+ **/
128
+ theme: null,
129
+
130
+ /** The preserveTheme flag prevents the view from being redrawn
131
+ * if HThemeManager.currentTheme is changed after the view
132
+ * has been drawn. Is true, if theme has been set.
133
+ **/
134
+ preserveTheme: false,
135
+
136
+ /** The optimizeWidthOnRefresh flag, when enabled, allows
137
+ * automatic width calculation for components that support
138
+ * that feature.
139
+ **/
140
+ optimizeWidthOnRefresh: true,
141
+
142
+ /** The parent is the +_parent+ supplied to the constructor.
143
+ * This is a complete object reference to the parent's namespace.
144
+ **/
145
+ parent: null,
146
+
147
+ /** The parents is an array containing parent instances up to
148
+ * the root controller level. The root controller is almost
149
+ * always an instance of HApplication.
150
+ **/
151
+ parents: null,
152
+
153
+ /** The viewId is the unique ID (serial number) of this view.
154
+ * This means the view can be looked up globally based on its
155
+ * id by using the +HSystem.views+ array.
156
+ **/
157
+ viewId: null,
158
+
159
+ /** The appId is the unique ID (serial number) of the app process
160
+ * acting as the root controller of the view tree of which this
161
+ * view is a member.
162
+ * This means the app can be looked up globally based on this
163
+ * id by using the +HSystem.apps+ array.
164
+ **/
165
+ appId: null,
166
+
167
+ /** The app is the reference of the app process acting as
168
+ * the root controller of the view tree of which this view is a
169
+ * member.
170
+ * This is a complete object reference to the app's namespace.
171
+ **/
172
+ app: null,
173
+
174
+ /** The views array contains a list of subviews of this view
175
+ * by id. To access the object reference, use the +HSystem.views+
176
+ * array with the id.
177
+ **/
178
+ views: null,
179
+
180
+ /** The viewsZOrder array contains a list of subviews ordered by
181
+ * zIndex. To change the order, use the bringToFront,
182
+ * sendToBack, bringForwards, sendBackwards, bringToFrontOf and
183
+ * sentToBackOf methods.
184
+ **/
185
+ viewsZOrder: null,
186
+
187
+ /** The isHidden flog reflects the visibility of the view.
188
+ **/
189
+ isHidden: false,
190
+
191
+ /** The +HRect+ instance bound to +self+ using the +constructor+ or +setRect+.
192
+ **/
193
+ rect: null,
194
+
195
+ /** An reference to the options block given as the constructor
196
+ * parameter _options.
197
+ **/
198
+ options: null,
199
+
200
+ /** The viewDefaults is a HViewDefaults object that is extended
201
+ * in the constructor with the options block given. The format of
202
+ * it is an Object.
203
+ * It's only used when not extended via HControl, see HControl#controlDefaults.
204
+ **/
205
+ viewDefaults: HViewDefaults,
206
+
207
+ /** = Description
208
+ * Constructs the logic part of a HView.
209
+ * The view still needs to be drawn on screen. To do that, call draw after
210
+ * subcomponents of the view are initialized.
211
+ *
212
+ * = Parameters
213
+ * +_rect+:: An instance of +HRect+, defines the position and size of views.
214
+ * It can be also defined with an array, see below.
215
+ * +_parent+:: The parent instance this instance will be contained within.
216
+ * A valid parent can be another HView compatible instance,
217
+ * an HApplication instance, a HControl or a similar extended
218
+ * HView instance. The origin of the +_rect+ is the same as the
219
+ * parent's offset. For HApplication instances, the web browser's
220
+ * window's left top corner is the origin.
221
+ *
222
+ * == The +_rect+ dimensions as arrays
223
+ * Instead of an instance of +HRect+, dimensions can also be supplied as arrays.
224
+ * The array length must be either 4 or 6. If the length is 4, the dimensions are
225
+ * specified as follows: +[ x, y, width, height ]+. Note that this is different
226
+ * from the construction parameters of +HRect+ that takes the coordinates as two
227
+ * points, like: +( left, top, right, bottom )+.
228
+ * Arrays with 6 items are a bit more complex (and powerful) as they can specify
229
+ * the flexible offsets too.
230
+ *
231
+ * === The array indexes for a +_rect+ configured as an 4-item array:
232
+ * Always left/top aligned, all items must be specified.
233
+ * Index:: Description
234
+ * +0+:: The X-coordinate (measured from the parent's left edge)
235
+ * +1+:: The Y-coordinate (measured from the parent's top edge)
236
+ * +2+:: The width.
237
+ * +3+:: The height.
238
+ *
239
+ * === The array indexes a +_rect+ configured as an 6-item array:
240
+ * Can be any configuration of left/top/right/bottom alignment and supports
241
+ * flexible widths. At least 4 items must be specified.
242
+ * Index:: Description
243
+ * +0+:: The left-aligned X-coordinate or +null+ if the view is
244
+ * right-aligned and using a right-aligned X-coordinate at
245
+ * index +4+ as well as the width specified at index +2+.
246
+ * +1+:: The top-aligned Y-coordinate or +null+ if the view is
247
+ * bottom-aligned and using a right-aligned X-coordinate at
248
+ * index +5+ as well as the height specified at index +3+.
249
+ * +2+:: The width, if only one X-coordinate specifies the
250
+ * position (at indexes +0+ or +4+).
251
+ * If both X-coordinates (at indexes +0+ and +4+) are
252
+ * specified, the width can be specified with a +null+ for
253
+ * automatic (flexible) width. If the width is specified,
254
+ * it's used as the minimum width.
255
+ * +3+:: The height, if only one Y-coordinate specifies the
256
+ * position (at indexes +1+ or +5+).
257
+ * If both Y-coordinates (at indexes +1+ and +5+) are
258
+ * specified, the height can be specified with a +null+ for
259
+ * automatic (flexible) height. if the height is specified,
260
+ * it's used as the minimum height.
261
+ * +4+:: The right-aligned X-coordinate or +null+ if the view is
262
+ * left-aligned and using a left-aligned X-coordinate at
263
+ * index +0+ as well as the width specified at index +2+.
264
+ * +5+:: The bottom-aligned Y-coordinate or +null+ if the view is
265
+ * top-aligned and using a top-aligned X-coordinate at
266
+ * index +1+ as well as the height specified at index +3+.
267
+ * == Usage examples of +_rect+:
268
+ * Specified as two instances of +HPoint+,
269
+ * x: 23, y: 75, width: 200, height: 100:
270
+ * HRect.nu( HPoint.nu( 23, 75 ), HPoint.nu( 223, 175 ) )
271
+ *
272
+ * The same as above, but without +HPoint+ instances:
273
+ * HRect.nu( 23, 75, 223, 175 )
274
+ *
275
+ * The same as above, but with an array as the constructor
276
+ * parameter for +HRect+:
277
+ * HRect.nu( [ 23, 75, 223, 175 ] )
278
+ *
279
+ * The same as above, but with an array instead of a +HRect+ instance:
280
+ * [ 23, 75, 200, 100 ]
281
+ *
282
+ * The same as above, but with a 6-item array:
283
+ * [ 23, 75, 200, 100, null, null ]
284
+ *
285
+ * The same as above, but aligned to the right instead of left:
286
+ * [ null, 75, 200, 100, 23, null ]
287
+ *
288
+ * The same as above, but aligned to the right/bottom edges:
289
+ * [ null, null, 200, 100, 23, 75 ]
290
+ *
291
+ * The same as above, but aligned to the left/bottom edges:
292
+ * [ 23, null, 200, 100, null, 75 ]
293
+ *
294
+ * Flexible width (based on the parent's dimensions):
295
+ * [ 23, 75, null, 100, 23, null ]
296
+ *
297
+ * Flexible height (based on the parent's dimensions):
298
+ * [ 23, 75, 200, null, null, 75 ]
299
+ *
300
+ * Flexible width and height (based on the parent's dimensions):
301
+ * [ 23, 75, null, null, 23, 75 ]
302
+ *
303
+ * Flexible width and height, but limited to a minimum width
304
+ * of 200 and a minimum height of 100 (based on the parent's dimensions):
305
+ * [ 23, 75, 200, 100, 23, 75 ]
306
+ *
307
+ **/
308
+ constructor: function(_rect, _parent, _options) {
309
+
310
+ if( !_options ){
311
+ _options = {};
312
+ }
313
+ if(!this.isinherited){
314
+ _options = (this.viewDefaults.extend(_options)).nu(this);
315
+ }
316
+
317
+ this.options = _options;
318
+ this.label = _options.label;
319
+
320
+ // Moved these to the top to ensure safe theming operation
321
+ if( _options.theme ){
322
+ this.theme = _options.theme;
323
+ this.preserveTheme = true;
324
+ }
325
+ else if(!this.theme){
326
+ this.theme = HThemeManager.currentTheme;
327
+ this.preserveTheme = false;
328
+ }
329
+ else {
330
+ this.preserveTheme = true;
331
+ }
332
+
333
+ if(_options.visible === false) {
334
+ this.isHidden = true;
335
+ }
336
+
337
+ // adds the parentClass as a "super" object
338
+ this.parent = _parent;
339
+
340
+ this.viewId = this.parent.addView(this);
341
+ // the parent addView method adds this.parents
342
+
343
+ this.appId = this.parent.appId;
344
+ this.app = HSystem.apps[this.appId];
345
+
346
+ // subview-ids, index of HView-derived objects that are found in HSystem.views[viewId]
347
+ this.views = [];
348
+
349
+ // Subviews in Z order.
350
+ this.viewsZOrder = [];
351
+
352
+ // Keep the view (and its subviews) hidden until its drawn.
353
+ this._createElement();
354
+
355
+ // Set the geometry
356
+ this.setRect(_rect);
357
+
358
+ this._cachedLeft = _rect.left;
359
+ this._cachedTop = _rect.top;
360
+
361
+ // Additional DOM element bindings are saved into this array so they can be
362
+ // deleted from the element manager when the view gets destroyed.
363
+ this._domElementBindings = [];
364
+
365
+ if(!this.isinherited) {
366
+ this.draw();
367
+ }
368
+ },
369
+
370
+ /** = Description
371
+ * When the +_flag+ is true, the view will be aligned to the right.
372
+ * The +_px+ offset defines how many pixels from the parent's right
373
+ * edge the right edge of this view will be. If both setFlexRight
374
+ * and setFlexLeft are set, the width is flexible.
375
+ * Use the constructor or setRect instead of calling this method
376
+ * directly.
377
+ *
378
+ * = Parameters
379
+ * +_flag+:: Boolean flag (true/false). Enables
380
+ * right-alignment when true.
381
+ * +_px+:: The amount of pixels to offset from the right
382
+ * edge of the parent's right edge.
383
+ *
384
+ * = Returns
385
+ * +self+
386
+ **/
387
+ setFlexRight: function(_flag,_px){
388
+ if(_flag===undefined){_flag=true;}
389
+ this.flexRight = _flag;
390
+ if(_px===undefined){_px=0;}
391
+ this.flexRightOffset = _px;
392
+ return this;
393
+ },
394
+
395
+ /** = Description
396
+ * When the +_flag+ is true, the view will be aligned to the left (default).
397
+ * The +_px+ offset defines how many pixels from the parent's left
398
+ * edge the left edge of this view will be. If both setFlexLeft
399
+ * and setFlexRight are set, the width is flexible.
400
+ * Use the constructor or setRect instead of calling this method
401
+ * directly.
402
+ *
403
+ * = Parameters
404
+ * +_flag+:: Boolean flag (true/false). Enables
405
+ * left-alignment when true.
406
+ * +_px+:: The amount of pixels to offset from the left
407
+ * edge of the parent's left edge.
408
+ *
409
+ * = Returns
410
+ * +self+
411
+ **/
412
+ setFlexLeft: function(_flag,_px){
413
+ if(_flag===undefined){_flag=true;}
414
+ this.flexLeft = _flag;
415
+ if((_px || _px === 0) && this.rect){
416
+ this.rect.setLeft(_px);
417
+ }
418
+ return this;
419
+ },
420
+
421
+ /** = Description
422
+ * When the +_flag+ is true, the view will be aligned to the top (default).
423
+ * The +_px+ offset defines how many pixels from the parent's top
424
+ * edge the top edge of this view will be. If both setFlexTop
425
+ * and setFlexBottom are set, the height is flexible.
426
+ * Use the constructor or setRect instead of calling this method
427
+ * directly.
428
+ *
429
+ * = Parameters
430
+ * +_flag+:: Boolean flag (true/false). Enables
431
+ * top-alignment when true.
432
+ * +_px+:: The amount of pixels to offset from the top
433
+ * edge of the parent's top edge.
434
+ *
435
+ * = Returns
436
+ * +self+
437
+ **/
438
+ setFlexTop: function(_flag,_px){
439
+ if(_flag===undefined){_flag=true;}
440
+ this.flexTop = _flag;
441
+ if((_px || _px === 0) && this.rect){
442
+ this.rect.setTop(_px);
443
+ }
444
+ return this;
445
+ },
446
+
447
+ /** = Description
448
+ * When the +_flag+ is true, the view will be aligned to the bottom.
449
+ * The +_px+ offset defines how many pixels from the parent's bottom
450
+ * edge the bottom edge of this view will be. If both setFlexBottom
451
+ * and setFlexTop are set, the height is flexible.
452
+ * Use the constructor or setRect instead of calling this method
453
+ * directly.
454
+ *
455
+ * = Parameters
456
+ * +_flag+:: Boolean flag (true/false). Enables
457
+ * bottom-alignment when true.
458
+ * +_px+:: The amount of pixels to offset from the bottom
459
+ * edge of the parent's bottom edge.
460
+ *
461
+ * = Returns
462
+ * +self+
463
+ **/
464
+ setFlexBottom: function(_flag,_px){
465
+ if(_flag===undefined){_flag=true;}
466
+ this.flexBottom = _flag;
467
+ if(_px===undefined){_px=0;}
468
+ this.flexBottomOffset = _px;
469
+ return this;
470
+ },
471
+
472
+ /** = Description
473
+ * The +_flag+ enables or disables the absolute positioning mode.
474
+ * (It's enabled by default). If absolute positioning mode is
475
+ * off, the coordinate system has little or no effect.
476
+ *
477
+ * = Parameters
478
+ * +_flag+:: Boolean flag (true/false). Enables
479
+ * absolute positioning when true.
480
+ * Enables relative positioning when false.
481
+ *
482
+ * = Returns
483
+ * +self+
484
+ **/
485
+ setAbsolute: function(_flag){
486
+ if(_flag===undefined){_flag=true;}
487
+ this.isAbsolute = _flag;
488
+ return this;
489
+ },
490
+
491
+ /** = Description
492
+ * The +_flag+ enables or disables the relative positioning mode.
493
+ * (It's disabled by default). If relative positioning mode is
494
+ * on, the coordinate system has little or no effect.
495
+ *
496
+ * = Parameters
497
+ * +_flag+:: Boolean flag (true/false). Enables
498
+ * absolute relative when true.
499
+ * Enables absolute positioning when false.
500
+ *
501
+ * = Returns
502
+ * +self+
503
+ **/
504
+ setRelative: function(_flag){
505
+ if(_flag===undefined){_flag=true;}
506
+ this.isAbsolute = (!_flag);
507
+ return this;
508
+ },
509
+
510
+ /** = Description
511
+ * Used by html theme templates to get the theme-specific full image path.
512
+ *
513
+ * = Returns
514
+ * The full path of the theme-specific gfx path as a string.
515
+ **/
516
+ getThemeGfxPath: function() {
517
+ var _themeName;
518
+ if( this.preserveTheme ){
519
+ _themeName = this.theme;
520
+ } else {
521
+ _themeName = HThemeManager.currentTheme;
522
+ }
523
+ return HThemeManager._componentGfxPath( _themeName, this.componentName, this.themePath );
524
+ },
525
+
526
+ /** = Description
527
+ * Used by html theme templates to get the theme-specific full path
528
+ * of the _fileName given.
529
+ *
530
+ * = Returns
531
+ * The full path of the file.
532
+ **/
533
+ getThemeGfxFile: function( _fileName ) {
534
+ if( this.preserveTheme ){
535
+ _themeName = this.theme;
536
+ } else {
537
+ _themeName = HThemeManager.currentTheme;
538
+ }
539
+ return HThemeManager._componentGfxFile( _themeName, this.componentName, this.themePath, _fileName );
540
+ },
541
+
542
+ /** --
543
+ * = Description
544
+ * The _makeElem method does the ELEM.make call to create
545
+ * the <div> element of the component. It assigns the elemId.
546
+ * It's a separate method to ease creating component that require
547
+ * other element types.
548
+ * ++
549
+ **/
550
+ _makeElem: function(_parentElemId){
551
+ this.elemId = ELEM.make(_parentElemId,'div');
552
+ },
553
+
554
+ /** --
555
+ * = Description
556
+ * The _setCSS method does the initial styling of the element.
557
+ * It's a separate method to ease creating component that require
558
+ * other initial styles.
559
+ * ++
560
+ **/
561
+ _setCSS: function(_additional){
562
+ var _cssStyle = 'display:none;overflow:hidden;visibility:hidden;';
563
+ if(this.isAbsolute){
564
+ _cssStyle += 'position:absolute;';
565
+ } else {
566
+ _cssStyle += 'position:relative;';
567
+ }
568
+ _cssStyle += _additional;
569
+ ELEM.setCSS(this.elemId,_cssStyle);
570
+ },
571
+
572
+ /** --
573
+ * = Description
574
+ * The _getParentElemId method returns the ELEM ID of the parent.
575
+ * ++
576
+ **/
577
+ _getParentElemId: function(){
578
+ var _parentElemId;
579
+ // if the parent does not have an element:
580
+ if(this.parent.elemId === undefined) {
581
+ _parentElemId = 0;
582
+ }
583
+ // if a subview element is defined in the template, use it:
584
+ else if(this.parent.markupElemIds&&this.parent.markupElemIds['subview']){
585
+ _parentElemId = this.parent.markupElemIds['subview'];
586
+ }
587
+ // otherwise, use main elemId
588
+ else {
589
+ _parentElemId = this.parent.elemId;
590
+ }
591
+ return _parentElemId;
592
+ },
593
+
594
+ /** --
595
+ * = Description
596
+ * The _createElement method calls the methods required to initialize the
597
+ * main DOM element of the view.
598
+ * ++
599
+ **/
600
+ _createElement: function() {
601
+ if(!this.elemId) {
602
+
603
+ this._makeElem(this._getParentElemId());
604
+ this._setCSS('');
605
+
606
+ // Theme name == CSS class name
607
+ if(this.preserveTheme){
608
+ ELEM.addClassName( this.elemId, this.theme );
609
+ }
610
+ else {
611
+ ELEM.addClassName( this.elemId, HThemeManager.currentTheme );
612
+ }
613
+ }
614
+ },
615
+
616
+ /** = Description
617
+ * The +drawRect+ method refreshes the dimensions of the view.
618
+ * It needs to be called to affect changes in the rect.
619
+ * It enables the drawn flag.
620
+ *
621
+ * = Returns
622
+ * +self+
623
+ *
624
+ **/
625
+ drawRect: function() {
626
+ if (this.parent && this.rect.isValid) {
627
+ var _this = this,
628
+ _elemId = _this.elemId,
629
+ _styl = ELEM.setStyle,
630
+ _rect = _this.rect;
631
+
632
+ _styl( _elemId, 'left', _this.flexLeft?(_rect.left+'px'):'auto', true);
633
+ _styl( _elemId, 'top', _this.flexTop?(_rect.top+'px'):'auto', true);
634
+ _styl( _elemId, 'right', _this.flexRight?(_this.flexRightOffset+'px'):'auto', true);
635
+ _styl( _elemId, 'bottom', _this.flexBottom?(_this.flexBottomOffset+'px'):'auto', true);
636
+ _styl( _elemId, 'width', (_this.flexLeft&&_this.flexRight)?'auto':(_rect.width+'px'), true);
637
+ _styl( _elemId, 'height', (_this.flexTop&&_this.flexBottom)?'auto':(_rect.height+'px'), true);
638
+
639
+ if(_this.flexLeft&&_this.flexRight){
640
+ _styl( _elemId, 'min-width', _rect.width+'px', true);
641
+ }
642
+ if(_this.flexTop&&_this.flexBottom){
643
+ _styl( _elemId, 'min-height', _rect.height+'px', true);
644
+ }
645
+
646
+ // Show the rectangle once it gets created, unless visibility was set to
647
+ // hidden in the constructor.
648
+ if(_this.isHidden === undefined || _this.isHidden === false) {
649
+ _styl( _elemId, 'visibility', 'inherit', true);
650
+ }
651
+
652
+ _styl( _elemId, 'display', _this.displayMode, true);
653
+
654
+ _this._updateZIndex();
655
+
656
+ if (_this._cachedLeft !== _rect.left || _this._cachedTop !== _rect.top) {
657
+ _this.invalidatePositionCache();
658
+ _this._cachedLeft = _rect.left;
659
+ _this._cachedTop = _rect.top;
660
+ }
661
+
662
+ _this.drawn = true;
663
+ }
664
+ return this;
665
+ },
666
+
667
+ /** --
668
+ * This method updates the z-index property of the children of self.
669
+ * It's essentially a wrapper for HSystem.updateZIndexOfChildren passed
670
+ * with the viewId of self.
671
+ * ++
672
+ **/
673
+ _updateZIndex: function() {
674
+ HSystem.updateZIndexOfChildren(this.viewId);
675
+ },
676
+
677
+ /** --
678
+ * This method updates the z-index property of the siblings of self.
679
+ * It's essentially a wrapper for HSystem.updateZIndexOfChildren passed
680
+ * with the parent's viewId of self.
681
+ * ++
682
+ **/
683
+ _updateZIndexAllSiblings: function() {
684
+ HSystem.updateZIndexOfChildren(this.parent.viewId);
685
+ },
686
+
687
+ /** = Description
688
+ * The higher level draw wrapper for drawRect, drawMarkup and drawSubviews.
689
+ * Finally calls refresh.
690
+ *
691
+ * = Returns
692
+ * +self+
693
+ *
694
+ **/
695
+ draw: function() {
696
+ var _isDrawn = this.drawn;
697
+ this.drawRect();
698
+ if(!_isDrawn){
699
+ this.firstDraw();
700
+ if(this['componentName']!==undefined){
701
+ this.drawMarkup();
702
+ }
703
+ this.drawSubviews();
704
+ if(this.options.style){
705
+ var
706
+ _style = this.options.style,
707
+ _styleItem, _styleKey, _styleValue, i = 0;
708
+ for(;i<_style.length;i++){
709
+ _styleItem = _style[i];
710
+ _styleKey = _styleItem[0];
711
+ _styleValue = _styleItem[1];
712
+ this.setStyle(_styleKey,_styleValue);
713
+ }
714
+ }
715
+ if(this.options.html){
716
+ this.setHTML(this.options.html);
717
+ }
718
+ if(!this.isHidden){
719
+ this.show();
720
+ }
721
+ }
722
+ this.refresh();
723
+ return this;
724
+ },
725
+
726
+ /** = Description
727
+ * Called once, before the layout of the view is initially drawn.
728
+ * Doesn't do anything by itself, but provides an extension point.
729
+ *
730
+ **/
731
+ firstDraw: function(){
732
+ },
733
+
734
+ /** = Description
735
+ * Called once, when the layout of the view is initially drawn.
736
+ * Doesn't do anything by itself, but provides an extension point for making
737
+ * subviews.
738
+ *
739
+ **/
740
+ drawSubviews: function(){
741
+ },
742
+
743
+ /** --
744
+ * Loads the markup from theme manager. If this.preserveTheme is set to true,
745
+ * the this.theme is used for loading the markup. Otherwise the currently
746
+ * active theme is used.
747
+ * ++
748
+ **/
749
+ _loadMarkup: function() {
750
+ var _themeName, _markup;
751
+ if (this.preserveTheme) {
752
+ _themeName = this.theme;
753
+ }
754
+ else {
755
+ _themeName = HThemeManager.currentTheme;
756
+ }
757
+ _markup = HThemeManager.getMarkup( _themeName, this.componentName, this.themePath );
758
+ if(_markup === false){
759
+ console.log('Warning: Markup template for "'+this.componentName+'" using theme "'+_themeName+'" not loaded.');
760
+ }
761
+ this.markup = _markup;
762
+ return (_markup !== false);
763
+ },
764
+
765
+ /** = Description
766
+ * Replaces the contents of the view's DOM element with html from the theme specific html file.
767
+ *
768
+ * = Returns
769
+ * +self+
770
+ **/
771
+ markupElemNames: ['bg', 'label', 'state', 'control', 'value', 'subview'],
772
+ drawMarkup: function() {
773
+ ELEM.setStyle(this.elemId, 'display', 'none', true);
774
+
775
+ // continue processing from here on:
776
+ var _markupStatus = this._loadMarkup();
777
+
778
+ this.bindMarkupVariables();
779
+ ELEM.setHTML(this.elemId, this.markup);
780
+
781
+ this.markupElemIds = {};
782
+ for(var i=0; i < this.markupElemNames.length; i++ ) {
783
+ var _partName = this.markupElemNames[ i ],
784
+ _elemName = _partName + this.elemId,
785
+ _htmlIdMatch = ' id="' + _elemName + '"';
786
+ if( this.markup.indexOf( _htmlIdMatch ) !== -1 ) {
787
+ this.markupElemIds[ _partName ] = this.bindDomElement( _elemName );
788
+ }
789
+ }
790
+
791
+ ELEM.setStyle(this.elemId, 'display', this.displayMode );
792
+ return this;
793
+ },
794
+
795
+ /** = Description
796
+ * Replaces the contents of the view's DOM element with custom html.
797
+ *
798
+ * = Parameters
799
+ * +_html+:: The HTML (string-formatted) to replace the content with.
800
+ *
801
+ * = Returns
802
+ * +self+
803
+ *
804
+ **/
805
+ setHTML: function( _html ) {
806
+ ELEM.setHTML( this.elemId, _html );
807
+ return this;
808
+ },
809
+
810
+ /** = Description
811
+ * Wrapper for setHTML, sets escaped html, if tags and such are present.
812
+ *
813
+ * = Parameters
814
+ * +_text+:: The text to set. If it contains any html, it's escaped.
815
+ *
816
+ * = Returns
817
+ * +self+
818
+ **/
819
+ setText: function( _text ) {
820
+ return this.setHTML( this.escapeHTML( _text ) );
821
+ },
822
+
823
+ /** = Description
824
+ * Method to escape HTML from text.
825
+ *
826
+ * Converts < to &lt; and > to &gt; and & to &amp;
827
+ *
828
+ * = Parameters
829
+ * +_html+:: The html to escape.
830
+ *
831
+ * = Returns
832
+ * A string with the html escaped.
833
+ **/
834
+ escapeHTML: function( _html ) {
835
+ return _html.replace(/&/gmi, '&amp;').replace(/>/gmi, '&gt;').replace(/</gmi, '&lt;');
836
+ },
837
+
838
+ /** = Description
839
+ *
840
+ * This method should be extended in order to redraw only specific parts. The
841
+ * base implementation calls optimizeWidth when optimizeWidthOnRefresh is set
842
+ * to true.
843
+ *
844
+ * = Returns
845
+ * +self+
846
+ *
847
+ **/
848
+ refresh: function() {
849
+ if(this.drawn) {
850
+ // this.drawn is checked here so the rectangle doesn't get drawn by the
851
+ // constructor when setRect() is initially called.
852
+ this.drawRect();
853
+ }
854
+ if(this.optimizeWidthOnRefresh) {
855
+ this.optimizeWidth();
856
+ }
857
+ if(this.refreshOnLabelChange){
858
+ this.refreshLabel();
859
+ }
860
+ return this;
861
+ },
862
+
863
+ /** Gets the size of the parent. If the parent is the document body, uses the browser window size.
864
+ **/
865
+ parentSize: function(){
866
+ if(this.parent.elemId === 0){
867
+ var _winSize = ELEM.windowSize();
868
+ return [ _winSize[0], _winSize[1] ];
869
+ }
870
+ else{
871
+ var _rect = this.parent.rect;
872
+ return [ _rect.width, _rect.height ];
873
+ }
874
+ },
875
+
876
+ /** Returns the maximum rect using the #parentSize.
877
+ **/
878
+ maxRect: function(){
879
+ var _parentSize = this.parentSize();
880
+ return [ 0, 0, _parentSize[0], _parentSize[1] ];
881
+ },
882
+
883
+ /** = Description
884
+ * Replaces the rect of the component with a new HRect instance and
885
+ * then refreshes the display.
886
+ *
887
+ * = Parameters
888
+ * +_rect+:: The new HRect instance to replace the old rect instance with.
889
+ * +_rect+:: Array format, see HView#constructor for further details.
890
+ *
891
+ * = Returns
892
+ * +self+
893
+ *
894
+ **/
895
+ setRect: function(_rect) {
896
+ if (this.rect) {
897
+ this.rect.release(this);
898
+ }
899
+ if(typeof _rect === 'string'){
900
+ _rect = this[_rect]();
901
+ }
902
+ if(_rect instanceof Array){
903
+ var _arrLen = _rect.length,
904
+ _throwPrefix = 'HView.setRect: If the HRect instance is replaced by an array, ';
905
+ if((_arrLen === 4) || (_arrLen === 6)){
906
+ var _leftOffset = _rect[0],
907
+ _topOffset = _rect[1],
908
+ _width = _rect[2],
909
+ _height = _rect[3],
910
+ _rightOffset = ((_arrLen === 6)?_rect[4]:null),
911
+ _bottomOffset = ((_arrLen === 6)?_rect[5]:null),
912
+ _validLeftOffset = (typeof _leftOffset === 'number'),
913
+ _validTopOffset = (typeof _topOffset === 'number'),
914
+ _validRightOffset = (typeof _rightOffset === 'number'),
915
+ _validBottomOffset = (typeof _bottomOffset === 'number'),
916
+ _validWidth = (typeof _width === 'number'),
917
+ _validHeight = (typeof _height === 'number'),
918
+ _right,
919
+ _bottom;
920
+
921
+ if( (!_validLeftOffset && !_validRightOffset) ||
922
+ (!_validTopOffset && !_validBottomOffset) ){
923
+ console.log(_throwPrefix + '(left or top) and (top or bottom) must be specified.');
924
+ }
925
+ else if( (!_validWidth && !(_validLeftOffset && _validRightOffset)) ||
926
+ (!_validHeight && !(_validTopOffset && _validBottomOffset)) ){
927
+ console.log(_throwPrefix + 'the (height or width) must be specified unless both (left and top) or (top and bottom) are specified.');
928
+ }
929
+
930
+ this.setFlexLeft(_validLeftOffset,_leftOffset);
931
+ this.setFlexTop(_validTopOffset,_topOffset);
932
+ this.setFlexRight(_validRightOffset,_rightOffset);
933
+ this.setFlexBottom(_validBottomOffset,_bottomOffset);
934
+
935
+ // default, makes a correct rect
936
+ if(_validLeftOffset && _validWidth && !_validRightOffset){
937
+ _right = _leftOffset + _width;
938
+ }
939
+ // can't be entirely correct rect unless parent size is calculated
940
+ else if(!_validLeftOffset && _validWidth && _validRightOffset){
941
+ _leftOffset = 0;
942
+ _right = _width;
943
+ }
944
+ // can't be entirely correct rect unless parent size is calculated
945
+ else if(_validLeftOffset && !_validWidth && _validRightOffset){
946
+ _right = _leftOffset + _rightOffset;
947
+ }
948
+
949
+ // use minimum width based on the height information given
950
+ else if(_validLeftOffset && _validWidth && _validRightOffset){
951
+ _right = _leftOffset + _width;
952
+ }
953
+
954
+ // default, makes a correct rect
955
+ if(_validTopOffset && _validHeight && !_validBottomOffset){
956
+ _bottom = _topOffset + _height;
957
+ }
958
+ // can't be entirely correct rect unless parent size is calculated
959
+ else if(!_validTopOffset && _validHeight && _validBottomOffset){
960
+ _topOffset = 0;
961
+ _bottom = _height;
962
+ }
963
+ // can't be entirely correct rect unless parent size is calculated
964
+ else if(_validTopOffset && !_validHeight && _validBottomOffset){
965
+ _bottom = _topOffset + _bottomOffset;
966
+ }
967
+
968
+ // use minimum height based on the height information given
969
+ else if(_validTopOffset && _validHeight && _validBottomOffset){
970
+ _bottom = _topOffset + _height;
971
+ }
972
+
973
+ this.rect = HRect.nu(_leftOffset,_topOffset,_right,_bottom);
974
+ }
975
+ else {
976
+ console.log(_throwPrefix + 'the length has to be either 4 or 6.');
977
+ }
978
+ }
979
+ else {
980
+ this.rect = _rect;
981
+ }
982
+ this.rect.bind(this);
983
+ this.refresh();
984
+ return this;
985
+ },
986
+
987
+ /** = Description
988
+ * Sets any arbitary style of the main DOM element of the component.
989
+ * Utilizes Element Manager's drawing queue/cache to perform the action.
990
+ *
991
+ * = Parameters
992
+ * +_name+:: The style name (css syntax, eg. 'background-color')
993
+ * +_value+:: The style value (css syntax, eg. 'rgb(255,0,0)')
994
+ * +_cacheOverride+:: Cache override flag.
995
+ *
996
+ * = Returns
997
+ * +self+
998
+ *
999
+ **/
1000
+ setStyle: function(_name, _value, _cacheOverride) {
1001
+ if (this.elemId) {
1002
+ ELEM.setStyle(this.elemId, _name, _value, _cacheOverride);
1003
+ }
1004
+ return this;
1005
+ },
1006
+
1007
+ /** = Description
1008
+ * Returns a style of the main DOM element of the component.
1009
+ * Utilizes +ELEM+ cache to perform the action.
1010
+ *
1011
+ * = Parameters
1012
+ * +_name+:: The style name (css syntax, eg. 'background-color')
1013
+ *
1014
+ * = Returns
1015
+ * The style property value (css syntax, eg. 'rgb(255,0,0)')
1016
+ *
1017
+ **/
1018
+ style: function(_name) {
1019
+ if (this.elemId) {
1020
+ return ELEM.getStyle(this.elemId, _name);
1021
+ }
1022
+ return '';
1023
+ },
1024
+
1025
+ /** = Description
1026
+ * Sets a style for a specified markup element that has been bound to this
1027
+ * view.
1028
+ *
1029
+ * = Parameters
1030
+ * +_partName+:: The identifier of the markup element.
1031
+ * +_name+:: The style name
1032
+ * +_value+:: The style value
1033
+ *
1034
+ * = Returns
1035
+ * +self+
1036
+ *
1037
+ **/
1038
+ setStyleOfPart: function(_partName, _name, _value, _cacheOverride) {
1039
+ if (!this['markupElemIds']){
1040
+ console.log('Warning, setStyleOfPart: no markupElemIds');
1041
+ }
1042
+ else if (!this.markupElemIds[_partName]) {
1043
+ console.log('Warning, setStyleOfPart: partName "'+_partName+'" does not exist for viewId '+this.viewId+'.');
1044
+ }
1045
+ else {
1046
+ ELEM.setStyle(this.markupElemIds[_partName], _name, _value, _cacheOverride);
1047
+ }
1048
+ return this;
1049
+ },
1050
+
1051
+ /** = Description
1052
+ * Returns a style of a specified markup element that has been bound to this
1053
+ * view.
1054
+ *
1055
+ * = Parameters
1056
+ * +_partName+:: The identifier of the markup element.
1057
+ * +_name+:: The style name
1058
+ *
1059
+ * = Returns
1060
+ * The style of a specified markup element.
1061
+ *
1062
+ **/
1063
+ styleOfPart: function(_partName, _name) {
1064
+ if (!this.markupElemIds[_partName]) {
1065
+ console.log('Warning, styleOfPart: partName "'+_partName+'" does not exist for viewId '+this.viewId+'.');
1066
+ return '';
1067
+ }
1068
+ return ELEM.getStyle(this.markupElemIds[_partName], _name);
1069
+ },
1070
+
1071
+ /** = Description
1072
+ * Sets a style of a specified markup element that has been bound to this
1073
+ * view.
1074
+ *
1075
+ * = Parameters
1076
+ * +_partName+:: The identifier of the markup element.
1077
+ * +_value+:: Value for markup element.
1078
+ *
1079
+ * = Returns
1080
+ * +self+
1081
+ *
1082
+ **/
1083
+ setMarkupOfPart: function( _partName, _value ) {
1084
+ if (!this.markupElemIds[_partName]) {
1085
+ console.log('Warning, setMarkupOfPart: partName "'+_partName+'" does not exist for viewId '+this.viewId+'.');
1086
+ }
1087
+ else {
1088
+ ELEM.setHTML( this.markupElemIds[_partName], _value );
1089
+ }
1090
+ return this;
1091
+ },
1092
+
1093
+ /** = Description
1094
+ * Returns a style of a specified markup element that has been bound to this
1095
+ * view.
1096
+ *
1097
+ * = Parameters
1098
+ * +_partName+:: The identifier of the markup element.
1099
+ *
1100
+ * = Returns
1101
+ * The style of a specified markup element.
1102
+ *
1103
+ **/
1104
+ markupOfPart: function(_partName) {
1105
+ if (!this.markupElemIds[_partName]) {
1106
+ console.log('Warning, markupOfPart: partName "'+_partName+'" does not exist for viewId '+this.viewId+'.');
1107
+ return '';
1108
+ }
1109
+ return ELEM.getHTML(this.markupElemIds[_partName]);
1110
+ },
1111
+
1112
+ /** = Description
1113
+ * Hides the component's main DOM element (and its children).
1114
+ *
1115
+ * = Returns
1116
+ * +self+
1117
+ *
1118
+ **/
1119
+ hide: function() {
1120
+ if(!this.isHidden) {
1121
+ var _setStyl = ELEM.setStyle,
1122
+ _elemId = this.elemId;
1123
+ _setStyl(_elemId,'visibility', 'hidden');
1124
+ _setStyl(_elemId,'display', 'none');
1125
+ this.isHidden = true;
1126
+ }
1127
+ return this;
1128
+ },
1129
+
1130
+ /** = Description
1131
+ * Restores the visibility of the component's main DOM element (and its children).
1132
+ *
1133
+ * = Return
1134
+ * +self+
1135
+ *
1136
+ **/
1137
+ show: function() {
1138
+ if(this.isHidden) {
1139
+ var _setStyl = ELEM.setStyle,
1140
+ _elemId = this.elemId;
1141
+ _setStyl(_elemId,'visibility', 'inherit');
1142
+ _setStyl(_elemId,'display', this.displayMode);
1143
+ this.isHidden = false;
1144
+ }
1145
+ return this;
1146
+ },
1147
+
1148
+ /** = Description
1149
+ * Toggles between hide and show.
1150
+ *
1151
+ * = Returns
1152
+ * +self+
1153
+ *
1154
+ **/
1155
+ toggle: function() {
1156
+ if(this.isHidden) {
1157
+ this.show();
1158
+ } else {
1159
+ this.hide();
1160
+ }
1161
+ return this;
1162
+ },
1163
+
1164
+ /** = Description
1165
+ * Call this if you need to remove a component from its parent's views array without
1166
+ * destroying the DOM element itself, making it in effect a view without parent.
1167
+ * Useful, for example, for moving a view from one parent component to another.
1168
+ *
1169
+ * = Returns
1170
+ * +self+
1171
+ *
1172
+ **/
1173
+ remove: function() {
1174
+ if( this.parent ) {
1175
+
1176
+ var _viewZIdx = this.parent.viewsZOrder.indexOf(this.viewId),
1177
+ _viewPIdx = this.parent.views.indexOf(this.viewId);
1178
+
1179
+ this.parent.views.splice(_viewPIdx,1);
1180
+ HSystem.delView(this.viewId);
1181
+ this.parent.viewsZOrder.splice( _viewZIdx, 1 );
1182
+ var _sysUpdateZIndexOfChildrenBufferIndex = HSystem._updateZIndexOfChildrenBuffer.indexOf( this.viewId );
1183
+ if(_sysUpdateZIndexOfChildrenBufferIndex !== -1){
1184
+ HSystem._updateZIndexOfChildrenBuffer.splice( _sysUpdateZIndexOfChildrenBufferIndex, 1 );
1185
+ }
1186
+
1187
+ this._updateZIndexAllSiblings();
1188
+ this.parent = null;
1189
+ this.parents = [];
1190
+ }
1191
+ return this;
1192
+ },
1193
+
1194
+ /** = Description
1195
+ * Deletes the component and all its children.
1196
+ * Should normally be called from the parent.
1197
+ *
1198
+ **/
1199
+ die: function() {
1200
+ // hide self, makes destruction seem faster
1201
+ this.hide();
1202
+ this.drawn = false;
1203
+ this.stopAnimation();
1204
+ // Delete the children first.
1205
+ var _childViewId, i;
1206
+ while (this.views.length !== 0) {
1207
+ _childViewId = this.views[0];
1208
+ this.destroyView(_childViewId);
1209
+ }
1210
+ // Remove this object's bindings, except the DOM element.
1211
+ this.remove();
1212
+ // Remove the DOM element bindings.
1213
+ for ( i = 0; i < this._domElementBindings.length; i++) {
1214
+ ELEM.del(this._domElementBindings[i]);
1215
+ }
1216
+ this._domElementBindings = [];
1217
+
1218
+
1219
+ // Remove the DOM object itself
1220
+ ELEM.del(this.elemId);
1221
+
1222
+ this.rect = null;
1223
+ var _this = this;
1224
+ for( i in _this ){
1225
+ _this[i] = null;
1226
+ delete _this[i];
1227
+ }
1228
+ },
1229
+
1230
+ /** Recursive idle poller. Should be extended if functionality is desired.
1231
+ **/
1232
+ onIdle: function() {
1233
+ for(var i = 0; i < this.views.length; i++) {
1234
+ HSystem.views[this.views[i]].onIdle();
1235
+ }
1236
+ },
1237
+
1238
+ /** Used by addView to build a parents array of parent classes.
1239
+ **/
1240
+ buildParents: function(_viewId){
1241
+ var _view = HSystem.views[_viewId];
1242
+ _view.parent = this;
1243
+ _view.parents = [];
1244
+ for(var _parentNum = 0; _parentNum < this.parents.length; _parentNum++) {
1245
+ _view.parents.push(this.parents[_parentNum]);
1246
+ }
1247
+ _view.parents.push(this);
1248
+ },
1249
+
1250
+ /** = Description
1251
+ * Adds a sub-view/component to the view. Called from inside the
1252
+ * HView#constructor and should be automatic for all components that accept
1253
+ * the 'parent' parameter, usually the second argument, after the HRect. May
1254
+ * also be used to attach a freely floating component (removed with remove)
1255
+ * to another component.
1256
+ *
1257
+ * = Parameter
1258
+ * +_view+:: Usually this inside HView derivate components.
1259
+ *
1260
+ * = Returns
1261
+ * The view id.
1262
+ *
1263
+ **/
1264
+ addView: function(_view) {
1265
+ var _viewId = HSystem.addView(_view);
1266
+ this.views.push(_viewId);
1267
+
1268
+ this.buildParents(_viewId);
1269
+ this.viewsZOrder.push(_viewId);
1270
+
1271
+ return _viewId;
1272
+ },
1273
+
1274
+ /** = Description
1275
+ * Call this if you need to remove a child view from this view without
1276
+ * destroying its element, making it in effect a view without parent.
1277
+ * Useful, for example, for moving a view from one parent component to another.
1278
+ *
1279
+ * = Parameters
1280
+ * +_viewId+:: The parent-specific view id. Actually an array index.
1281
+ *
1282
+ * = Returns
1283
+ * +self+
1284
+ *
1285
+ **/
1286
+ removeView: function(_viewId) {
1287
+ HSystem.views[_viewId].remove();
1288
+ return this;
1289
+ },
1290
+
1291
+ /** = Description
1292
+ * Call this if you need to remove a child view from this view, destroying its
1293
+ * child elements recursively and removing all DOM elements too.
1294
+ *
1295
+ * = Parameters
1296
+ * +_viewId+:: The parent-specific view id. Actually an array index.
1297
+ *
1298
+ * = Returns
1299
+ * +self+
1300
+ **/
1301
+ destroyView: function(_viewId) {
1302
+ HSystem.views[_viewId].die();
1303
+ return this;
1304
+ },
1305
+
1306
+ /** = Description
1307
+ * Returns bounds rectangle that defines the size and coordinate system
1308
+ * of the component. This should be identical to the rectangle used in
1309
+ * constructing the object, unless it has been changed after construction.
1310
+ *
1311
+ * = Returns
1312
+ * A new <HRect> instance with identical values to this component's rect.
1313
+ *
1314
+ **/
1315
+ bounds: function() {
1316
+ // Could be cached.
1317
+ var _bounds = new HRect(this.rect);
1318
+
1319
+ _bounds.right -= _bounds.left;
1320
+ _bounds.left = 0;
1321
+ _bounds.bottom -= _bounds.top;
1322
+ _bounds.top = 0;
1323
+
1324
+ return _bounds;
1325
+ },
1326
+
1327
+
1328
+ /** = Description
1329
+ * This method resizes the view, without moving its left and top sides.
1330
+ * It adds horizontal coordinate units to the width and vertical units to
1331
+ * the height of the view.
1332
+ * Since a View's frame rectangle must be aligned on screen pixels, only
1333
+ * integral values should be passed to this method. Values with
1334
+ * fractional components will be rounded to the nearest whole integer.
1335
+ * If the View is attached to a window, this method causes its parent view
1336
+ * to be updated, so the View is immediately displayed in its new size. If it
1337
+ * doesn't have a parent or isn't attached to a window, this method
1338
+ * merely alter its frame and bounds rectangle.
1339
+ *
1340
+ * = Parameters
1341
+ * +_horizonal+:: Horizonal units to add to the width (negative units subtract)
1342
+ * +_vertical+:: Vertical units to add to the height (negative units subtract)
1343
+ *
1344
+ * = Returns
1345
+ * +self+
1346
+ *
1347
+ **/
1348
+ resizeBy: function(_horizontal, _vertical) {
1349
+ var _rect = this.rect;
1350
+ _rect.right += _horizontal;
1351
+ _rect.bottom += _vertical;
1352
+ _rect.updateSecondaryValues();
1353
+ this.drawRect();
1354
+ return this;
1355
+ },
1356
+
1357
+ /** = Description
1358
+ * This method makes the view width units wide
1359
+ * and height units high. This method adjust the right and bottom
1360
+ * components of the frame rectangle accordingly.
1361
+ * Since a View's frame rectangle must be aligned on screen pixels, only
1362
+ * integral values should be passed to this method. Values with
1363
+ * fractional components will be rounded to the nearest whole integer.
1364
+ * If the View is attached to a window, this method causes its parent view
1365
+ * to be updated, so the View is immediately displayed in its new size. If it
1366
+ * doesn't have a parent or isn't attached to a window, this method
1367
+ * merely alter its frame and bounds rectangle.
1368
+ *
1369
+ * = Parameters
1370
+ * +_width+:: The new width of the view.
1371
+ * +_height+:: The new height of the view.
1372
+ *
1373
+ * = Returns
1374
+ * +self+
1375
+ *
1376
+ **/
1377
+ resizeTo: function(_width, _height) {
1378
+ var _rect = this.rect;
1379
+ _rect.right = _rect.left + _width;
1380
+ _rect.bottom = _rect.top + _height;
1381
+ _rect.updateSecondaryValues();
1382
+ this.drawRect();
1383
+ return this;
1384
+ },
1385
+
1386
+ /** = Descripion
1387
+ * This method moves the view to a new coordinate. It adjusts the
1388
+ * left and top components of the frame rectangle accordingly.
1389
+ * Since a View's frame rectangle must be aligned on screen pixels, only
1390
+ * integral values should be passed to this method. Values with
1391
+ * fractional components will be rounded to the nearest whole integer.
1392
+ * If the View is attached to a window, this method causes its parent view
1393
+ * to be updated, so the View is immediately displayed in its new size. If it
1394
+ * doesn't have a parent or isn't attached to a window, this method
1395
+ * merely alter its frame and bounds rectangle.
1396
+ *
1397
+ * = Parameters
1398
+ * +_x+:: The new x-coordinate of the view.
1399
+ * +_y+:: The new y-coordinate of the view.
1400
+ *
1401
+ * +_point+:: The new coordinate point of the view.
1402
+ *
1403
+ * = Returns
1404
+ * +self+
1405
+ *
1406
+ **/
1407
+ offsetTo: function() {
1408
+ this.rect.offsetTo.apply(this.rect, arguments);
1409
+ this.drawRect();
1410
+ return this;
1411
+ },
1412
+
1413
+ /** = Description
1414
+ * Alias method for offsetTo.
1415
+ *
1416
+ * = Returns
1417
+ * +self+
1418
+ *
1419
+ **/
1420
+ moveTo: function() {
1421
+ this.offsetTo.apply(this, arguments);
1422
+ return this;
1423
+ },
1424
+
1425
+ /** = Description
1426
+ * This method re-positions the view without changing its size.
1427
+ * It adds horizontal coordinate units to the x coordinate and vertical
1428
+ * units to the y coordinate of the view.
1429
+ * Since a View's frame rectangle must be aligned on screen pixels, only
1430
+ * integral values should be passed to this method. Values with
1431
+ * fractional components will be rounded to the nearest whole integer.
1432
+ * If the View is attached to a window, this method causes its parent view
1433
+ * to be updated, so the View is immediately displayed in its new size. If it
1434
+ * doesn't have a parent or isn't attached to a window, this method
1435
+ * merely alter its frame and bounds rectangle.
1436
+ *
1437
+ * = Parameters
1438
+ * +_horizonal+:: Horizonal units to change the x coordinate (negative units subtract)
1439
+ * +_vertical+:: Vertical units to add to change the y coordinate (negative units subtract)
1440
+ *
1441
+ * = Returns
1442
+ * +self+
1443
+ *
1444
+ **/
1445
+ offsetBy: function(_horizontal, _vertical) {
1446
+ this.rect.offsetBy(_horizontal, _vertical);
1447
+ this.drawRect();
1448
+ return this;
1449
+ },
1450
+
1451
+ /** = Description
1452
+ * Alias method for offsetBy.
1453
+ *
1454
+ * = Returns
1455
+ * +self+
1456
+ *
1457
+ **/
1458
+ moveBy: function() {
1459
+ this.offsetBy.apply(this, arguments);
1460
+ return this;
1461
+ },
1462
+
1463
+ /** = Description
1464
+ * Brings the view to the front by changing its Z-Index.
1465
+ *
1466
+ * = Returns
1467
+ * +self+
1468
+ *
1469
+ **/
1470
+ bringToFront: function() {
1471
+ if (this.parent) {
1472
+ var _index = this.zIndex();
1473
+ this.parent.viewsZOrder.splice(_index, 1);
1474
+ this.parent.viewsZOrder.push(this.viewId);
1475
+ this._updateZIndexAllSiblings();
1476
+ }
1477
+ return this;
1478
+ },
1479
+
1480
+ /** = Description
1481
+ * Brings itself to the front of the given view by changing its Z-Index.
1482
+ * Only works on sibling views.
1483
+ *
1484
+ * = Parameters
1485
+ * +_view+:: The view to bring to the front of.
1486
+ *
1487
+ * = Returns
1488
+ * +self+
1489
+ *
1490
+ **/
1491
+ bringToFrontOf: function(_view){
1492
+ if(this.parent.viewId === _view.parent.viewId){
1493
+ this.parent.viewsZOrder.splice( this.zIndex(), 1 ); // removes selfs index from the array
1494
+ this.parent.viewsZOrder.splice( _view.zIndex()+1, 0, this.viewId); // sets itself in front of to _view
1495
+ this._updateZIndexAllSiblings();
1496
+ }
1497
+ return this;
1498
+ },
1499
+
1500
+ /** = Description
1501
+ * Sends itself to the back of the given view by changing its Z-Index.
1502
+ * Only works on sibling views.
1503
+ *
1504
+ * = Parameters
1505
+ * +_view+:: The view to send to the back of.
1506
+ *
1507
+ * = Returns
1508
+ * +self+
1509
+ *
1510
+ **/
1511
+ sendToBackOf: function(_view){
1512
+ if(this.parent.viewId === _view.parent.viewId){
1513
+ this.parent.viewsZOrder.splice( this.zIndex(), 1 ); // removes selfs index from the array
1514
+ this.parent.viewsZOrder.splice( _view.zIndex(), 0, this.viewId); // sets itself in back of to _view
1515
+ this._updateZIndexAllSiblings();
1516
+ }
1517
+ return this;
1518
+ },
1519
+
1520
+ /** = Description
1521
+ * Sends itself one step backward by changing its Z-Index.
1522
+ *
1523
+ * = Returns
1524
+ * +self+
1525
+ *
1526
+ **/
1527
+ sendBackward: function(){
1528
+ var _index = this.zIndex();
1529
+ if(_index!==0){
1530
+ this.parent.viewsZOrder.splice( _index, 1 ); // removes selfs index from the array
1531
+ this.parent.viewsZOrder.splice( _index-1, 0, this.viewId); // moves selfs position to one step less than where it was
1532
+ this._updateZIndexAllSiblings();
1533
+ }
1534
+ return this;
1535
+ },
1536
+
1537
+ /** = Description
1538
+ * Brings itself one step forward by changing its Z-Index.
1539
+ *
1540
+ * = Returns
1541
+ * +self+
1542
+ *
1543
+ **/
1544
+ bringForward: function(){
1545
+ var _index = this.zIndex();
1546
+ if(_index!==this.parent.viewsZOrder.length-1){
1547
+ this.parent.viewsZOrder.splice( _index, 1 ); // removes selfs index from the array
1548
+ this.parent.viewsZOrder.splice( _index+1, 0, this.viewId); // moves selfs position to one step more than it was
1549
+ this._updateZIndexAllSiblings();
1550
+ }
1551
+ return this;
1552
+ },
1553
+
1554
+
1555
+ /** = Description
1556
+ * Sends the view to the back by changing its Z-Index.
1557
+ *
1558
+ * = Returns
1559
+ * +self+
1560
+ *
1561
+ **/
1562
+ sendToBack: function() {
1563
+ if (this.parent) {
1564
+ var _index = this.zIndex();
1565
+ this.parent.viewsZOrder.splice(_index, 1); // removes this index from the arr
1566
+ this.parent.viewsZOrder.splice(0, 0, this.viewId); // unshifts viewId
1567
+ this._updateZIndexAllSiblings();
1568
+ }
1569
+ return this;
1570
+ },
1571
+
1572
+ /** = Description
1573
+ * Use this method to get the Z-Index of itself.
1574
+ *
1575
+ * = Returns
1576
+ * The current Z-Index value.
1577
+ *
1578
+ **/
1579
+ zIndex: function() {
1580
+ if (!this.parent) {
1581
+ return -1;
1582
+ }
1583
+ // Returns the z-order of this item as seen by the parent.
1584
+ return this.parent.viewsZOrder.indexOf(this.viewId);
1585
+ },
1586
+
1587
+ /** = Description
1588
+ * Measures the characters encoded in length bytes of the string - or,
1589
+ * if no length is specified, the entire string up to the null character,
1590
+ * '0', which terminates it. The return value totals the width of all the
1591
+ * characters in coordinate units; it's the length of the baseline required
1592
+ * to draw the string.
1593
+ *
1594
+ * = Parameters
1595
+ * +_string+:: The string to measure.
1596
+ * +_length+:: Optional, How many characters to count.
1597
+ * +_elemId+:: Optional, The element ID where the temporary string is created
1598
+ * in.
1599
+ * +_wrap+:: Optional boolean value, wrap whitespaces?
1600
+ * +_extraCss+:: Optional, extra css to add.
1601
+ *
1602
+ * = Returns
1603
+ * The width in pixels required to draw a string in the font.
1604
+ *
1605
+ **/
1606
+ stringSize: function(_string, _length, _elemId, _wrap, _extraCss) {
1607
+ if (_length || _length === 0) {
1608
+ _string = _string.substring(0, _length);
1609
+ }
1610
+ if (!_elemId && _elemId !== 0) {
1611
+ _elemId = 0; //this.elemId;
1612
+ }
1613
+ if (!_extraCss) {
1614
+ _extraCss = '';
1615
+ }
1616
+ if (!_wrap){
1617
+ _extraCss += 'white-space:nowrap;';
1618
+ }
1619
+
1620
+ var _stringElem = ELEM.make(_elemId);
1621
+ ELEM.setCSS(_stringElem, "visibility:hidden;position:absolute;"+_extraCss);
1622
+ ELEM.setHTML(_stringElem, _string);
1623
+ ELEM.flushLoop();
1624
+ var _visibleSize=ELEM.getVisibleSize(_stringElem);
1625
+ ELEM.del(_stringElem);
1626
+ return _visibleSize;
1627
+ },
1628
+
1629
+ /** Returns the string width
1630
+ **/
1631
+ stringWidth: function(_string, _length, _elemId, _extraCss){
1632
+ return this.stringSize(_string, _length, _elemId, false, _extraCss)[0];
1633
+ },
1634
+
1635
+ /** Returns the string height.
1636
+ **/
1637
+ stringHeight: function(_string, _length, _elemId, _extraCss){
1638
+ return this.stringSize(_string, _length, _elemId, true, _extraCss)[1];
1639
+ },
1640
+
1641
+ /** Returns the X coordinate that has the scrolled position calculated.
1642
+ **/
1643
+ pageX: function() {
1644
+ var _x = 0,
1645
+ _elem = this;
1646
+ while(_elem) {
1647
+ if(_elem.elemId && _elem.rect) {
1648
+ _x += ELEM.get(_elem.elemId).offsetLeft;
1649
+ _x -= ELEM.get(_elem.elemId).scrollLeft;
1650
+ }
1651
+ if(_elem.markupElemIds&&_elem.markupElemIds.subview){
1652
+ _x += ELEM.get(_elem.markupElemIds.subview).offsetLeft;
1653
+ _x -= ELEM.get(_elem.markupElemIds.subview).scrollLeft;
1654
+ }
1655
+ _elem = _elem.parent;
1656
+ }
1657
+ return _x;
1658
+ },
1659
+
1660
+ /** = Description
1661
+ * Sets the label on a control component: the text that's displayed in
1662
+ * HControl extensions. Visual functionality is implemented in component
1663
+ * theme templates and refreshLabel method extensions.
1664
+ *
1665
+ * Avoid extending directly, extend +refreshLabel+ instead.
1666
+ *
1667
+ * = Parameters
1668
+ * +_label+:: The text the component should display.
1669
+ *
1670
+ * = Returns
1671
+ * +self+
1672
+ *
1673
+ **/
1674
+ setLabel: function(_label) {
1675
+ if(this.escapeLabelHTML){
1676
+ _label = this.escapeHTML( _label );
1677
+ }
1678
+ var _this = this,
1679
+ _differs = (_label !== _this.label);
1680
+ if(_differs){
1681
+ _this.label = _label;
1682
+ _this.options.label = _label;
1683
+ _this.refresh();
1684
+ }
1685
+ return this;
1686
+ },
1687
+
1688
+ /** = Description
1689
+ * Called when the +self.label+ has been changed. By default
1690
+ * tries to update the label element defined in the theme of
1691
+ * the component. Of course, the HControl itself doesn't
1692
+ * define a theme, so without a theme doesn't do anything.
1693
+ *
1694
+ * = Returns
1695
+ * +self+
1696
+ *
1697
+ **/
1698
+ refreshLabel: function(){
1699
+ if(this.markupElemIds){
1700
+ if(this.markupElemIds['label']){
1701
+ ELEM.setHTML(this.markupElemIds.label,this.label);
1702
+ }
1703
+ }
1704
+ return this;
1705
+ },
1706
+
1707
+ /** Returns the Y coordinate that has the scrolled position calculated.
1708
+ **/
1709
+ pageY: function() {
1710
+ var _y = 0,
1711
+ _elem = this;
1712
+ while(_elem) {
1713
+ if(_elem.elemId && _elem.rect) {
1714
+ _y += ELEM.get(_elem.elemId).offsetTop;
1715
+ _y -= ELEM.get(_elem.elemId).scrollTop;
1716
+ }
1717
+ if(_elem.markupElemIds&&_elem.markupElemIds.subview){
1718
+ _y += ELEM.get(_elem.markupElemIds.subview).offsetTop;
1719
+ _y -= ELEM.get(_elem.markupElemIds.subview).scrollTop;
1720
+ }
1721
+ _elem = _elem.parent;
1722
+ }
1723
+ return _y;
1724
+ },
1725
+
1726
+ /** Returns the HPoint that has the scrolled position calculated.
1727
+ **/
1728
+ pageLocation: function() {
1729
+ return new HPoint(this.pageX(), this.pageY());
1730
+ },
1731
+
1732
+ /** = Description
1733
+ * An abstract method that derived classes may implement, if they are able to
1734
+ * resize themselves so that their content fits nicely inside.
1735
+ * Similar to pack, might be renamed when components are written to
1736
+ * be savvy of this feature.
1737
+ **/
1738
+ optimizeWidth: function() {
1739
+
1740
+ },
1741
+
1742
+
1743
+ /** = Description
1744
+ * Invalidates event manager's element position cache for this view and its
1745
+ * subviews. Actual functionality is implemented in HControl.
1746
+ *
1747
+ * = Returns
1748
+ * +self+
1749
+ *
1750
+ **/
1751
+ invalidatePositionCache: function() {
1752
+ for(var i=0; i<this.views.length; i++) {
1753
+ HSystem.views[this.views[i]].invalidatePositionCache();
1754
+ }
1755
+ return this;
1756
+ },
1757
+
1758
+
1759
+ /** = Description
1760
+ * Binds a DOM element to the +ELEM+ cache. This is a wrapper for
1761
+ * the ELEM#elem_bind that keeps track of the bound elements and
1762
+ * frees them from the element manager when the view is destroyed.
1763
+ *
1764
+ * = Parameters
1765
+ * +_domElementId+:: The value of the DOM element's id attribute that is
1766
+ * to be bound to the element cache.
1767
+ *
1768
+ * = Returns
1769
+ * The element index id of the bound element.
1770
+ *
1771
+ **/
1772
+ bindDomElement: function(_domElementId) {
1773
+ var _cacheId = ELEM.bindId(_domElementId);
1774
+ if (_cacheId) {
1775
+ this._domElementBindings.push(_cacheId);
1776
+ }
1777
+ return _cacheId;
1778
+ },
1779
+
1780
+
1781
+ /** = Description
1782
+ * Removes a DOM element from the +ELEM+ cache. This is a wrapper
1783
+ * for the ELEM#elem_del. This is used for safely removing DOM
1784
+ * nodes from the cache.
1785
+ *
1786
+ * = Parameters
1787
+ * +_elementId+:: The id of the element in the element manager's cache
1788
+ * that is to be removed from the cache.
1789
+ *
1790
+ **/
1791
+ unbindDomElement: function(_elementId) {
1792
+ var _indexOfElementId = this._domElementBindings.indexOf(_elementId);
1793
+ if (_indexOfElementId > -1) {
1794
+ ELEM.del(_elementId);
1795
+ this._domElementBindings.splice(_indexOfElementId, 1);
1796
+ }
1797
+ }
1798
+
1799
+
1800
+ });
1801
+
1802
+ HView.implement(HMarkupView);
1803
+ HView.implement(HMorphAnimation);
1804
+