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