activeldap 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (435) hide show
  1. data/CHANGES +454 -0
  2. data/COPYING +340 -0
  3. data/LICENSE +58 -0
  4. data/README +101 -0
  5. data/Rakefile +175 -0
  6. data/TODO +25 -0
  7. data/benchmark/bench-al.rb +202 -0
  8. data/benchmark/config.yaml.sample +5 -0
  9. data/data/locale/en/LC_MESSAGES/active-ldap.mo +0 -0
  10. data/data/locale/ja/LC_MESSAGES/active-ldap.mo +0 -0
  11. data/examples/al-admin/README +182 -0
  12. data/examples/al-admin/Rakefile +10 -0
  13. data/examples/al-admin/app/controllers/account_controller.rb +59 -0
  14. data/examples/al-admin/app/controllers/application.rb +34 -0
  15. data/examples/al-admin/app/controllers/attributes_controller.rb +17 -0
  16. data/examples/al-admin/app/controllers/directory_controller.rb +47 -0
  17. data/examples/al-admin/app/controllers/object_classes_controller.rb +17 -0
  18. data/examples/al-admin/app/controllers/syntaxes_controller.rb +17 -0
  19. data/examples/al-admin/app/controllers/users_controller.rb +51 -0
  20. data/examples/al-admin/app/controllers/welcome_controller.rb +10 -0
  21. data/examples/al-admin/app/helpers/account_helper.rb +2 -0
  22. data/examples/al-admin/app/helpers/application_helper.rb +42 -0
  23. data/examples/al-admin/app/helpers/attributes_helper.rb +15 -0
  24. data/examples/al-admin/app/helpers/directory_helper.rb +7 -0
  25. data/examples/al-admin/app/helpers/object_classes_helper.rb +10 -0
  26. data/examples/al-admin/app/helpers/syntaxes_helper.rb +10 -0
  27. data/examples/al-admin/app/helpers/url_helper.rb +13 -0
  28. data/examples/al-admin/app/helpers/users_helper.rb +17 -0
  29. data/examples/al-admin/app/helpers/welcome_helper.rb +2 -0
  30. data/examples/al-admin/app/models/entry.rb +23 -0
  31. data/examples/al-admin/app/models/ldap_user.rb +54 -0
  32. data/examples/al-admin/app/models/user.rb +91 -0
  33. data/examples/al-admin/app/views/_entry/_attributes_information.rhtml +23 -0
  34. data/examples/al-admin/app/views/_entry/_entry.rhtml +15 -0
  35. data/examples/al-admin/app/views/_schema/_aliases.rhtml +7 -0
  36. data/examples/al-admin/app/views/_switcher/_after.rhtml +2 -0
  37. data/examples/al-admin/app/views/_switcher/_before.rhtml +5 -0
  38. data/examples/al-admin/app/views/account/login.rhtml +26 -0
  39. data/examples/al-admin/app/views/account/sign_up.rhtml +28 -0
  40. data/examples/al-admin/app/views/attributes/_attributes.rhtml +19 -0
  41. data/examples/al-admin/app/views/attributes/_detail.rhtml +29 -0
  42. data/examples/al-admin/app/views/attributes/index.rhtml +3 -0
  43. data/examples/al-admin/app/views/attributes/show.rhtml +31 -0
  44. data/examples/al-admin/app/views/directory/_tree.rhtml +10 -0
  45. data/examples/al-admin/app/views/directory/_tree_view_js.rhtml +26 -0
  46. data/examples/al-admin/app/views/directory/index.rhtml +13 -0
  47. data/examples/al-admin/app/views/directory/populate.rhtml +2 -0
  48. data/examples/al-admin/app/views/layouts/_flash_box.rhtml +4 -0
  49. data/examples/al-admin/app/views/layouts/_footer.rhtml +9 -0
  50. data/examples/al-admin/app/views/layouts/_header_menu.rhtml +10 -0
  51. data/examples/al-admin/app/views/layouts/_main_menu.rhtml +18 -0
  52. data/examples/al-admin/app/views/layouts/application.rhtml +56 -0
  53. data/examples/al-admin/app/views/object_classes/_attributes.rhtml +28 -0
  54. data/examples/al-admin/app/views/object_classes/_object_classes.rhtml +19 -0
  55. data/examples/al-admin/app/views/object_classes/index.rhtml +3 -0
  56. data/examples/al-admin/app/views/object_classes/show.rhtml +39 -0
  57. data/examples/al-admin/app/views/syntaxes/_detail.rhtml +14 -0
  58. data/examples/al-admin/app/views/syntaxes/_syntaxes.rhtml +19 -0
  59. data/examples/al-admin/app/views/syntaxes/index.rhtml +3 -0
  60. data/examples/al-admin/app/views/syntaxes/show.rhtml +22 -0
  61. data/examples/al-admin/app/views/users/_attributes_update_form.rhtml +30 -0
  62. data/examples/al-admin/app/views/users/_form.rhtml +13 -0
  63. data/examples/al-admin/app/views/users/_object_classes_update_form.rhtml +40 -0
  64. data/examples/al-admin/app/views/users/_password_change_form.rhtml +20 -0
  65. data/examples/al-admin/app/views/users/edit.rhtml +15 -0
  66. data/examples/al-admin/app/views/users/index.rhtml +10 -0
  67. data/examples/al-admin/app/views/users/show.rhtml +11 -0
  68. data/examples/al-admin/app/views/welcome/index.rhtml +13 -0
  69. data/examples/al-admin/config/boot.rb +45 -0
  70. data/examples/al-admin/config/database.yml.example +19 -0
  71. data/examples/al-admin/config/environment.rb +70 -0
  72. data/examples/al-admin/config/environments/development.rb +21 -0
  73. data/examples/al-admin/config/environments/production.rb +18 -0
  74. data/examples/al-admin/config/environments/test.rb +19 -0
  75. data/examples/al-admin/config/ldap.yml.example +21 -0
  76. data/examples/al-admin/config/routes.rb +46 -0
  77. data/examples/al-admin/db/migrate/001_create_users.rb +16 -0
  78. data/examples/al-admin/lib/accept_http_rails_relative_url_root.rb +9 -0
  79. data/examples/al-admin/lib/authenticated_system.rb +124 -0
  80. data/examples/al-admin/lib/authenticated_test_helper.rb +113 -0
  81. data/examples/al-admin/lib/tasks/gettext.rake +35 -0
  82. data/examples/al-admin/po/en/al-admin.po +341 -0
  83. data/examples/al-admin/po/ja/al-admin.po +341 -0
  84. data/examples/al-admin/po/nl/al-admin.po +373 -0
  85. data/examples/al-admin/public/.htaccess +40 -0
  86. data/examples/al-admin/public/404.html +30 -0
  87. data/examples/al-admin/public/500.html +30 -0
  88. data/examples/al-admin/public/dispatch.cgi +10 -0
  89. data/examples/al-admin/public/dispatch.fcgi +24 -0
  90. data/examples/al-admin/public/dispatch.rb +10 -0
  91. data/examples/al-admin/public/favicon.ico +0 -0
  92. data/examples/al-admin/public/images/active-ldap.svg +6351 -0
  93. data/examples/al-admin/public/images/al-admin.png +0 -0
  94. data/examples/al-admin/public/images/al-admin.svg +6371 -0
  95. data/examples/al-admin/public/images/header-background.png +0 -0
  96. data/examples/al-admin/public/images/header-background.svg +99 -0
  97. data/examples/al-admin/public/images/rails.png +0 -0
  98. data/examples/al-admin/public/images/spinelz/accordion_tab_left_active.gif +0 -0
  99. data/examples/al-admin/public/images/spinelz/accordion_tab_left_inactive.gif +0 -0
  100. data/examples/al-admin/public/images/spinelz/accordion_tab_middle_active.gif +0 -0
  101. data/examples/al-admin/public/images/spinelz/accordion_tab_middle_inactive.gif +0 -0
  102. data/examples/al-admin/public/images/spinelz/accordion_tab_right_active.gif +0 -0
  103. data/examples/al-admin/public/images/spinelz/accordion_tab_right_inactive.gif +0 -0
  104. data/examples/al-admin/public/images/spinelz/balloon_back.gif +0 -0
  105. data/examples/al-admin/public/images/spinelz/balloon_bottom_left.gif +0 -0
  106. data/examples/al-admin/public/images/spinelz/balloon_bottom_middle.gif +0 -0
  107. data/examples/al-admin/public/images/spinelz/balloon_bottom_right.gif +0 -0
  108. data/examples/al-admin/public/images/spinelz/balloon_left_down_arrow.gif +0 -0
  109. data/examples/al-admin/public/images/spinelz/balloon_left_up_arrow.gif +0 -0
  110. data/examples/al-admin/public/images/spinelz/balloon_middle_left.gif +0 -0
  111. data/examples/al-admin/public/images/spinelz/balloon_middle_right.gif +0 -0
  112. data/examples/al-admin/public/images/spinelz/balloon_right_down_arrow.gif +0 -0
  113. data/examples/al-admin/public/images/spinelz/balloon_right_up_arrow.gif +0 -0
  114. data/examples/al-admin/public/images/spinelz/balloon_top_left.gif +0 -0
  115. data/examples/al-admin/public/images/spinelz/balloon_top_middle.gif +0 -0
  116. data/examples/al-admin/public/images/spinelz/balloon_top_right.gif +0 -0
  117. data/examples/al-admin/public/images/spinelz/barchart_h.gif +0 -0
  118. data/examples/al-admin/public/images/spinelz/barchart_v.gif +0 -0
  119. data/examples/al-admin/public/images/spinelz/button.gif +0 -0
  120. data/examples/al-admin/public/images/spinelz/calendar_default_handler.gif +0 -0
  121. data/examples/al-admin/public/images/spinelz/calendar_delete.gif +0 -0
  122. data/examples/al-admin/public/images/spinelz/calendar_next.gif +0 -0
  123. data/examples/al-admin/public/images/spinelz/calendar_next_second.gif +0 -0
  124. data/examples/al-admin/public/images/spinelz/calendar_pre.gif +0 -0
  125. data/examples/al-admin/public/images/spinelz/calendar_pre_second.gif +0 -0
  126. data/examples/al-admin/public/images/spinelz/calendar_private_icon.gif +0 -0
  127. data/examples/al-admin/public/images/spinelz/calendar_schedule.gif +0 -0
  128. data/examples/al-admin/public/images/spinelz/calender_back.gif +0 -0
  129. data/examples/al-admin/public/images/spinelz/calender_back_second.gif +0 -0
  130. data/examples/al-admin/public/images/spinelz/datepicker2_back.gif +0 -0
  131. data/examples/al-admin/public/images/spinelz/datepicker2_back_second.gif +0 -0
  132. data/examples/al-admin/public/images/spinelz/datepicker2_next.gif +0 -0
  133. data/examples/al-admin/public/images/spinelz/datepicker2_next_second.gif +0 -0
  134. data/examples/al-admin/public/images/spinelz/datepicker2_pre.gif +0 -0
  135. data/examples/al-admin/public/images/spinelz/datepicker2_pre_second.gif +0 -0
  136. data/examples/al-admin/public/images/spinelz/datepicker_back.gif +0 -0
  137. data/examples/al-admin/public/images/spinelz/datepicker_back_second.gif +0 -0
  138. data/examples/al-admin/public/images/spinelz/datepicker_next.gif +0 -0
  139. data/examples/al-admin/public/images/spinelz/datepicker_next_second.gif +0 -0
  140. data/examples/al-admin/public/images/spinelz/datepicker_pre.gif +0 -0
  141. data/examples/al-admin/public/images/spinelz/datepicker_pre_second.gif +0 -0
  142. data/examples/al-admin/public/images/spinelz/grid_down.gif +0 -0
  143. data/examples/al-admin/public/images/spinelz/grid_state.gif +0 -0
  144. data/examples/al-admin/public/images/spinelz/grid_up.gif +0 -0
  145. data/examples/al-admin/public/images/spinelz/icon_day.gif +0 -0
  146. data/examples/al-admin/public/images/spinelz/icon_month.gif +0 -0
  147. data/examples/al-admin/public/images/spinelz/icon_week.gif +0 -0
  148. data/examples/al-admin/public/images/spinelz/menubar_back.gif +0 -0
  149. data/examples/al-admin/public/images/spinelz/menubar_subcontents_back.gif +0 -0
  150. data/examples/al-admin/public/images/spinelz/navPanel_tab_left_active.gif +0 -0
  151. data/examples/al-admin/public/images/spinelz/navPanel_tab_left_inactive.gif +0 -0
  152. data/examples/al-admin/public/images/spinelz/navPanel_tab_middle_active.gif +0 -0
  153. data/examples/al-admin/public/images/spinelz/navPanel_tab_middle_inactive.gif +0 -0
  154. data/examples/al-admin/public/images/spinelz/navPanel_tab_right_active.gif +0 -0
  155. data/examples/al-admin/public/images/spinelz/navPanel_tab_right_inactive.gif +0 -0
  156. data/examples/al-admin/public/images/spinelz/select_date.gif +0 -0
  157. data/examples/al-admin/public/images/spinelz/selectabletable_selected.gif +0 -0
  158. data/examples/al-admin/public/images/spinelz/sideBarBox_about.gif +0 -0
  159. data/examples/al-admin/public/images/spinelz/sideBarBox_menu.gif +0 -0
  160. data/examples/al-admin/public/images/spinelz/sideBarBox_sample.gif +0 -0
  161. data/examples/al-admin/public/images/spinelz/sideBarBox_tabBottomActive.gif +0 -0
  162. data/examples/al-admin/public/images/spinelz/sideBarBox_tabBottomInactive.gif +0 -0
  163. data/examples/al-admin/public/images/spinelz/sideBarBox_tabMiddleActive.gif +0 -0
  164. data/examples/al-admin/public/images/spinelz/sideBarBox_tabMiddleActive2.gif +0 -0
  165. data/examples/al-admin/public/images/spinelz/sideBarBox_tabMiddleInactive.gif +0 -0
  166. data/examples/al-admin/public/images/spinelz/sideBarBox_tabMiddleInactive2.gif +0 -0
  167. data/examples/al-admin/public/images/spinelz/sideBarBox_tabTopActive.gif +0 -0
  168. data/examples/al-admin/public/images/spinelz/sideBarBox_tabTopInactive.gif +0 -0
  169. data/examples/al-admin/public/images/spinelz/sideBarBox_tabbar.gif +0 -0
  170. data/examples/al-admin/public/images/spinelz/sortableTable_down.gif +0 -0
  171. data/examples/al-admin/public/images/spinelz/sortableTable_normal.gif +0 -0
  172. data/examples/al-admin/public/images/spinelz/sortableTable_up.gif +0 -0
  173. data/examples/al-admin/public/images/spinelz/switcher_close.gif +0 -0
  174. data/examples/al-admin/public/images/spinelz/switcher_open.gif +0 -0
  175. data/examples/al-admin/public/images/spinelz/tabBox_close.gif +0 -0
  176. data/examples/al-admin/public/images/spinelz/tabBox_tabLeftActive.gif +0 -0
  177. data/examples/al-admin/public/images/spinelz/tabBox_tabLeftInactive.gif +0 -0
  178. data/examples/al-admin/public/images/spinelz/tabBox_tabMiddleActive.gif +0 -0
  179. data/examples/al-admin/public/images/spinelz/tabBox_tabMiddleInactive.gif +0 -0
  180. data/examples/al-admin/public/images/spinelz/tabBox_tabRightActive.gif +0 -0
  181. data/examples/al-admin/public/images/spinelz/tabBox_tabRightInactive.gif +0 -0
  182. data/examples/al-admin/public/images/spinelz/tab_bar.gif +0 -0
  183. data/examples/al-admin/public/images/spinelz/table_back.gif +0 -0
  184. data/examples/al-admin/public/images/spinelz/timepicker_clock.gif +0 -0
  185. data/examples/al-admin/public/images/spinelz/toolbar_close.gif +0 -0
  186. data/examples/al-admin/public/images/spinelz/toolbar_left.gif +0 -0
  187. data/examples/al-admin/public/images/spinelz/toolbar_max.gif +0 -0
  188. data/examples/al-admin/public/images/spinelz/toolbar_middle.gif +0 -0
  189. data/examples/al-admin/public/images/spinelz/toolbar_min.gif +0 -0
  190. data/examples/al-admin/public/images/spinelz/toolbar_next.gif +0 -0
  191. data/examples/al-admin/public/images/spinelz/toolbar_right.gif +0 -0
  192. data/examples/al-admin/public/images/spinelz/treeview_dir.gif +0 -0
  193. data/examples/al-admin/public/images/spinelz/treeview_file.gif +0 -0
  194. data/examples/al-admin/public/images/spinelz/treeview_group.gif +0 -0
  195. data/examples/al-admin/public/images/spinelz/treeview_group_special.gif +0 -0
  196. data/examples/al-admin/public/images/spinelz/treeview_state.gif +0 -0
  197. data/examples/al-admin/public/images/spinelz/treeview_user.gif +0 -0
  198. data/examples/al-admin/public/images/spinelz/window_bottom_left.gif +0 -0
  199. data/examples/al-admin/public/images/spinelz/window_bottom_middle.gif +0 -0
  200. data/examples/al-admin/public/images/spinelz/window_bottom_right.gif +0 -0
  201. data/examples/al-admin/public/images/spinelz/window_close.gif +0 -0
  202. data/examples/al-admin/public/images/spinelz/window_max.gif +0 -0
  203. data/examples/al-admin/public/images/spinelz/window_middle_left.gif +0 -0
  204. data/examples/al-admin/public/images/spinelz/window_middle_right.gif +0 -0
  205. data/examples/al-admin/public/images/spinelz/window_min.gif +0 -0
  206. data/examples/al-admin/public/images/spinelz/window_top_left.gif +0 -0
  207. data/examples/al-admin/public/images/spinelz/window_top_middle.gif +0 -0
  208. data/examples/al-admin/public/images/spinelz/window_top_right.gif +0 -0
  209. data/examples/al-admin/public/javascripts/application.js +2 -0
  210. data/examples/al-admin/public/javascripts/controls.js +833 -0
  211. data/examples/al-admin/public/javascripts/dragdrop.js +942 -0
  212. data/examples/al-admin/public/javascripts/effects.js +1088 -0
  213. data/examples/al-admin/public/javascripts/prototype.js +2515 -0
  214. data/examples/al-admin/public/javascripts/spinelz/accordion.js +185 -0
  215. data/examples/al-admin/public/javascripts/spinelz/ajaxHistory.js +157 -0
  216. data/examples/al-admin/public/javascripts/spinelz/balloon.js +287 -0
  217. data/examples/al-admin/public/javascripts/spinelz/barchart.js +524 -0
  218. data/examples/al-admin/public/javascripts/spinelz/calendar.js +3012 -0
  219. data/examples/al-admin/public/javascripts/spinelz/colorpicker.js +128 -0
  220. data/examples/al-admin/public/javascripts/spinelz/datepicker.js +438 -0
  221. data/examples/al-admin/public/javascripts/spinelz/grid.js +1391 -0
  222. data/examples/al-admin/public/javascripts/spinelz/grid_resizeEx.js +100 -0
  223. data/examples/al-admin/public/javascripts/spinelz/grid_sortabletableEx.js +129 -0
  224. data/examples/al-admin/public/javascripts/spinelz/inplaceEditorEx.js +148 -0
  225. data/examples/al-admin/public/javascripts/spinelz/menubar.js +232 -0
  226. data/examples/al-admin/public/javascripts/spinelz/navPanel.js +170 -0
  227. data/examples/al-admin/public/javascripts/spinelz/selectableTable.js +433 -0
  228. data/examples/al-admin/public/javascripts/spinelz/sideBarBox.js +282 -0
  229. data/examples/al-admin/public/javascripts/spinelz/sideBarBox_effects.js +83 -0
  230. data/examples/al-admin/public/javascripts/spinelz/sortableTable.js +270 -0
  231. data/examples/al-admin/public/javascripts/spinelz/switcher.js +78 -0
  232. data/examples/al-admin/public/javascripts/spinelz/tabBox.js +469 -0
  233. data/examples/al-admin/public/javascripts/spinelz/timepicker.js +384 -0
  234. data/examples/al-admin/public/javascripts/spinelz/toolbar.js +152 -0
  235. data/examples/al-admin/public/javascripts/spinelz/treeview.js +703 -0
  236. data/examples/al-admin/public/javascripts/spinelz/window.js +641 -0
  237. data/examples/al-admin/public/javascripts/spinelz/window_resizeEx.js +130 -0
  238. data/examples/al-admin/public/javascripts/spinelz_lib/builder.js +131 -0
  239. data/examples/al-admin/public/javascripts/spinelz_lib/controls.js +835 -0
  240. data/examples/al-admin/public/javascripts/spinelz_lib/dragdrop.js +944 -0
  241. data/examples/al-admin/public/javascripts/spinelz_lib/effects.js +1090 -0
  242. data/examples/al-admin/public/javascripts/spinelz_lib/json.js +139 -0
  243. data/examples/al-admin/public/javascripts/spinelz_lib/prototype.js +2515 -0
  244. data/examples/al-admin/public/javascripts/spinelz_lib/resize.js +215 -0
  245. data/examples/al-admin/public/javascripts/spinelz_lib/scriptaculous.js +51 -0
  246. data/examples/al-admin/public/javascripts/spinelz_lib/slider.js +278 -0
  247. data/examples/al-admin/public/javascripts/spinelz_lib/spinelz_util.js +1266 -0
  248. data/examples/al-admin/public/javascripts/spinelz_lib/unittest.js +564 -0
  249. data/examples/al-admin/public/robots.txt +1 -0
  250. data/examples/al-admin/public/stylesheets/account.css +41 -0
  251. data/examples/al-admin/public/stylesheets/attributes.css +1 -0
  252. data/examples/al-admin/public/stylesheets/base.css +99 -0
  253. data/examples/al-admin/public/stylesheets/common.css +2 -0
  254. data/examples/al-admin/public/stylesheets/detail.css +36 -0
  255. data/examples/al-admin/public/stylesheets/directory.css +22 -0
  256. data/examples/al-admin/public/stylesheets/object-classes.css +6 -0
  257. data/examples/al-admin/public/stylesheets/rails.css +35 -0
  258. data/examples/al-admin/public/stylesheets/spinelz/accordion.css +59 -0
  259. data/examples/al-admin/public/stylesheets/spinelz/balloon.css +151 -0
  260. data/examples/al-admin/public/stylesheets/spinelz/calendar.css +564 -0
  261. data/examples/al-admin/public/stylesheets/spinelz/datepicker.css +175 -0
  262. data/examples/al-admin/public/stylesheets/spinelz/grid.css +137 -0
  263. data/examples/al-admin/public/stylesheets/spinelz/menubar.css +78 -0
  264. data/examples/al-admin/public/stylesheets/spinelz/modal.css +22 -0
  265. data/examples/al-admin/public/stylesheets/spinelz/navPanel.css +58 -0
  266. data/examples/al-admin/public/stylesheets/spinelz/selectableTable.css +28 -0
  267. data/examples/al-admin/public/stylesheets/spinelz/sideBarBox.css +82 -0
  268. data/examples/al-admin/public/stylesheets/spinelz/sortableTable.css +51 -0
  269. data/examples/al-admin/public/stylesheets/spinelz/switcher.css +23 -0
  270. data/examples/al-admin/public/stylesheets/spinelz/tabBox.css +94 -0
  271. data/examples/al-admin/public/stylesheets/spinelz/timepicker.css +508 -0
  272. data/examples/al-admin/public/stylesheets/spinelz/toolbar.css +82 -0
  273. data/examples/al-admin/public/stylesheets/spinelz/treeview.css +121 -0
  274. data/examples/al-admin/public/stylesheets/spinelz/window.css +140 -0
  275. data/examples/al-admin/public/stylesheets/structure.css +81 -0
  276. data/examples/al-admin/public/stylesheets/syntaxes.css +1 -0
  277. data/examples/al-admin/public/stylesheets/users.css +13 -0
  278. data/examples/al-admin/public/stylesheets/welcome.css +0 -0
  279. data/examples/al-admin/script/about +3 -0
  280. data/examples/al-admin/script/breakpointer +3 -0
  281. data/examples/al-admin/script/console +3 -0
  282. data/examples/al-admin/script/destroy +3 -0
  283. data/examples/al-admin/script/generate +3 -0
  284. data/examples/al-admin/script/performance/benchmarker +3 -0
  285. data/examples/al-admin/script/performance/profiler +3 -0
  286. data/examples/al-admin/script/plugin +3 -0
  287. data/examples/al-admin/script/process/inspector +3 -0
  288. data/examples/al-admin/script/process/reaper +3 -0
  289. data/examples/al-admin/script/process/spawner +3 -0
  290. data/examples/al-admin/script/runner +3 -0
  291. data/examples/al-admin/script/server +3 -0
  292. data/examples/al-admin/test/fixtures/users.yml +9 -0
  293. data/examples/al-admin/test/functional/account_controller_test.rb +24 -0
  294. data/examples/al-admin/test/functional/attributes_controller_test.rb +18 -0
  295. data/examples/al-admin/test/functional/directory_controller_test.rb +18 -0
  296. data/examples/al-admin/test/functional/object_classes_controller_test.rb +18 -0
  297. data/examples/al-admin/test/functional/syntaxes_controller_test.rb +18 -0
  298. data/examples/al-admin/test/functional/users_controller_test.rb +18 -0
  299. data/examples/al-admin/test/functional/welcome_controller_test.rb +18 -0
  300. data/examples/al-admin/test/run-test.sh +3 -0
  301. data/examples/al-admin/test/test_helper.rb +28 -0
  302. data/examples/al-admin/test/unit/user_test.rb +13 -0
  303. data/examples/al-admin/vendor/plugins/exception_notification/README +111 -0
  304. data/examples/al-admin/vendor/plugins/exception_notification/init.rb +1 -0
  305. data/examples/al-admin/vendor/plugins/exception_notification/lib/exception_notifiable.rb +99 -0
  306. data/examples/al-admin/vendor/plugins/exception_notification/lib/exception_notifier.rb +67 -0
  307. data/examples/al-admin/vendor/plugins/exception_notification/lib/exception_notifier_helper.rb +77 -0
  308. data/examples/al-admin/vendor/plugins/exception_notification/test/exception_notifier_helper_test.rb +61 -0
  309. data/examples/al-admin/vendor/plugins/exception_notification/test/test_helper.rb +7 -0
  310. data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/_backtrace.rhtml +1 -0
  311. data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/_environment.rhtml +7 -0
  312. data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/_inspect_model.rhtml +16 -0
  313. data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/_request.rhtml +3 -0
  314. data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/_session.rhtml +2 -0
  315. data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/_title.rhtml +3 -0
  316. data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/exception_notification.rhtml +6 -0
  317. data/examples/config.yaml.example +5 -0
  318. data/examples/example.der +0 -0
  319. data/examples/example.jpg +0 -0
  320. data/examples/groupadd +41 -0
  321. data/examples/groupdel +35 -0
  322. data/examples/groupls +49 -0
  323. data/examples/groupmod +42 -0
  324. data/examples/lpasswd +55 -0
  325. data/examples/objects/group.rb +13 -0
  326. data/examples/objects/ou.rb +4 -0
  327. data/examples/objects/user.rb +20 -0
  328. data/examples/ouadd +38 -0
  329. data/examples/useradd +45 -0
  330. data/examples/useradd-binary +50 -0
  331. data/examples/userdel +34 -0
  332. data/examples/userls +50 -0
  333. data/examples/usermod +42 -0
  334. data/examples/usermod-binary-add +47 -0
  335. data/examples/usermod-binary-add-time +51 -0
  336. data/examples/usermod-binary-del +48 -0
  337. data/examples/usermod-lang-add +43 -0
  338. data/lib/active_ldap/acts/tree.rb +75 -0
  339. data/lib/active_ldap/adapter/base.rb +531 -0
  340. data/lib/active_ldap/adapter/ldap.rb +231 -0
  341. data/lib/active_ldap/adapter/ldap_ext.rb +69 -0
  342. data/lib/active_ldap/adapter/net_ldap.rb +292 -0
  343. data/lib/active_ldap/adapter/net_ldap_ext.rb +29 -0
  344. data/lib/active_ldap/association/belongs_to.rb +47 -0
  345. data/lib/active_ldap/association/belongs_to_many.rb +42 -0
  346. data/lib/active_ldap/association/children.rb +21 -0
  347. data/lib/active_ldap/association/collection.rb +83 -0
  348. data/lib/active_ldap/association/has_many.rb +31 -0
  349. data/lib/active_ldap/association/has_many_utils.rb +35 -0
  350. data/lib/active_ldap/association/has_many_wrap.rb +46 -0
  351. data/lib/active_ldap/association/proxy.rb +102 -0
  352. data/lib/active_ldap/associations.rb +172 -0
  353. data/lib/active_ldap/attributes.rb +211 -0
  354. data/lib/active_ldap/base.rb +1273 -0
  355. data/lib/active_ldap/callbacks.rb +19 -0
  356. data/lib/active_ldap/command.rb +49 -0
  357. data/lib/active_ldap/configuration.rb +147 -0
  358. data/lib/active_ldap/connection.rb +237 -0
  359. data/lib/active_ldap/distinguished_name.rb +251 -0
  360. data/lib/active_ldap/escape.rb +12 -0
  361. data/lib/active_ldap/get_text/parser.rb +159 -0
  362. data/lib/active_ldap/get_text.rb +8 -0
  363. data/lib/active_ldap/get_text_fallback.rb +53 -0
  364. data/lib/active_ldap/get_text_support.rb +26 -0
  365. data/lib/active_ldap/helper.rb +33 -0
  366. data/lib/active_ldap/human_readable.rb +112 -0
  367. data/lib/active_ldap/ldap_error.rb +74 -0
  368. data/lib/active_ldap/ldif.rb +52 -0
  369. data/lib/active_ldap/object_class.rb +93 -0
  370. data/lib/active_ldap/operations.rb +429 -0
  371. data/lib/active_ldap/populate.rb +44 -0
  372. data/lib/active_ldap/schema/syntaxes.rb +386 -0
  373. data/lib/active_ldap/schema.rb +530 -0
  374. data/lib/active_ldap/timeout.rb +75 -0
  375. data/lib/active_ldap/timeout_stub.rb +17 -0
  376. data/lib/active_ldap/user_password.rb +93 -0
  377. data/lib/active_ldap/validations.rb +171 -0
  378. data/lib/active_ldap.rb +982 -0
  379. data/po/en/active-ldap.po +3677 -0
  380. data/po/ja/active-ldap.po +3713 -0
  381. data/rails/plugin/active_ldap/README +54 -0
  382. data/rails/plugin/active_ldap/generators/model_active_ldap/USAGE +17 -0
  383. data/rails/plugin/active_ldap/generators/model_active_ldap/model_active_ldap_generator.rb +70 -0
  384. data/rails/plugin/active_ldap/generators/model_active_ldap/templates/fixtures.yml +11 -0
  385. data/rails/plugin/active_ldap/generators/model_active_ldap/templates/model_active_ldap.rb +3 -0
  386. data/rails/plugin/active_ldap/generators/model_active_ldap/templates/unit_test.rb +10 -0
  387. data/rails/plugin/active_ldap/generators/scaffold_active_ldap/scaffold_active_ldap_generator.rb +7 -0
  388. data/rails/plugin/active_ldap/generators/scaffold_al/scaffold_al_generator.rb +20 -0
  389. data/rails/plugin/active_ldap/init.rb +26 -0
  390. data/test/al-test-utils.rb +362 -0
  391. data/test/command.rb +62 -0
  392. data/test/config.yaml.sample +6 -0
  393. data/test/run-test.rb +31 -0
  394. data/test/test-unit-ext/always-show-result.rb +28 -0
  395. data/test/test-unit-ext/backtrace-filter.rb +17 -0
  396. data/test/test-unit-ext/long-display-for-emacs.rb +25 -0
  397. data/test/test-unit-ext/priority.rb +163 -0
  398. data/test/test-unit-ext.rb +4 -0
  399. data/test/test_acts_as_tree.rb +57 -0
  400. data/test/test_adapter.rb +98 -0
  401. data/test/test_associations.rb +353 -0
  402. data/test/test_attributes.rb +79 -0
  403. data/test/test_base.rb +547 -0
  404. data/test/test_base_per_instance.rb +55 -0
  405. data/test/test_bind.rb +62 -0
  406. data/test/test_callback.rb +35 -0
  407. data/test/test_configuration.rb +40 -0
  408. data/test/test_connection.rb +59 -0
  409. data/test/test_connection_per_class.rb +58 -0
  410. data/test/test_connection_per_dn.rb +78 -0
  411. data/test/test_dn.rb +160 -0
  412. data/test/test_find.rb +96 -0
  413. data/test/test_groupadd.rb +50 -0
  414. data/test/test_groupdel.rb +46 -0
  415. data/test/test_groupls.rb +107 -0
  416. data/test/test_groupmod.rb +51 -0
  417. data/test/test_ldif.rb +35 -0
  418. data/test/test_lpasswd.rb +75 -0
  419. data/test/test_object_class.rb +56 -0
  420. data/test/test_reflection.rb +179 -0
  421. data/test/test_schema.rb +433 -0
  422. data/test/test_syntax.rb +329 -0
  423. data/test/test_user.rb +227 -0
  424. data/test/test_user_password.rb +93 -0
  425. data/test/test_useradd-binary.rb +61 -0
  426. data/test/test_useradd.rb +57 -0
  427. data/test/test_userdel.rb +48 -0
  428. data/test/test_userls.rb +91 -0
  429. data/test/test_usermod-binary-add-time.rb +64 -0
  430. data/test/test_usermod-binary-add.rb +63 -0
  431. data/test/test_usermod-binary-del.rb +66 -0
  432. data/test/test_usermod-lang-add.rb +59 -0
  433. data/test/test_usermod.rb +58 -0
  434. data/test/test_validation.rb +110 -0
  435. metadata +536 -0
@@ -0,0 +1,1391 @@
1
+ // Copyright (c) 2005 spinelz.org (http://script.spinelz.org/)
2
+ //
3
+ // Permission is hereby granted, free of charge, to any person obtaining
4
+ // a copy of this software and associated documentation files (the
5
+ // "Software"), to deal in the Software without restriction, including
6
+ // without limitation the rights to use, copy, modify, merge, publish,
7
+ // distribute, sublicense, and/or sell copies of the Software, and to
8
+ // permit persons to whom the Software is furnished to do so, subject to
9
+ // the following conditions:
10
+ //
11
+ // The above copyright notice and this permission notice shall be
12
+ // included in all copies or substantial portions of the Software.
13
+ //
14
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ Grid = Class.create();
23
+ Grid.className = {
24
+ container: 'grid_container',
25
+
26
+ baseTable: 'grid_baseTable',
27
+ baseRow: 'grid_baseRow',
28
+ baseCell: 'grid_baseCell',
29
+
30
+ headerTable: 'grid_headerTable',
31
+ headerRow: 'grid_headerRow',
32
+ headerCell: 'grid_headerCell',
33
+ headerCellDrag: 'grid_headerCellDrag',
34
+ headerCellSort: 'grid_headerCellVal',
35
+
36
+ idTable: 'grid_idTable',
37
+ idRow: 'grid_idRow',
38
+ idCell: 'grid_idCell',
39
+ idCellVal: 'grid_idCellVal',
40
+
41
+ cellTable: 'grid_cellTable',
42
+ cellTbody: 'grid_cellTbody',
43
+ cellRow: 'grid_cellRow',
44
+ cell: 'grid_cell',
45
+ cellVal: 'grid_cellVal',
46
+ cellSelected: 'grid_cellSelected',
47
+ state: 'grid_state',
48
+ stateEmpty: 'grid_stateEmpty',
49
+ stateOpen: 'grid_stateOpen',
50
+ stateClose: 'grid_stateClose',
51
+
52
+ inplaceEditor: 'grid_inplaceEditor'
53
+ }
54
+ Grid.scrollTop = 0;
55
+ Grid.scrollLeft = 0;
56
+ Grid.options = {}
57
+ Grid.options.baseTable = {
58
+ border:1,
59
+ frame : 'border',
60
+ cellSpacing:0,
61
+ cellPadding:0
62
+ }
63
+ Grid.options.headerTable = {
64
+ border:1,
65
+ frame : 'border',
66
+ cellSpacing:0,
67
+ cellPadding:0
68
+ }
69
+ Grid.options.idTable = {
70
+ border:1,
71
+ frame : 'border',
72
+ cellSpacing:0,
73
+ cellPadding:0
74
+ }
75
+ Grid.options.cellTable = {
76
+ border:1,
77
+ frame : 'border',
78
+ cellSpacing:0,
79
+ cellPadding:0
80
+ }
81
+ Grid.prototype = {
82
+
83
+ initialize : function(element) {
84
+
85
+ this.element = $(element);
86
+ Element.setStyle(this.element, {visibility: 'hidden'});
87
+ Element.hide(this.element);
88
+
89
+ var options = Object.extend({
90
+ cssPrefix: 'custum_',
91
+ cellMinWidth: 10,
92
+ cellMinHeight: 10,
93
+ cellDefaultWidth: 72,
94
+ cellDefaultHeight: 25,
95
+ defaultRowLength: 10,
96
+ baseWidth: 40,
97
+ baseHeight: 25,
98
+ baseTop: 0,
99
+ baseLeft: 0,
100
+ cellEditUrl: '',
101
+ updateGridUrl: '',
102
+ updateGridReceiver: '',
103
+ hierarchy: false,
104
+ hierarchyCol: false,
105
+ hierarchyIndent: 20,
106
+ sortOptions: {}
107
+ }, arguments[1] || {});
108
+
109
+ this.options = options;
110
+ this.custumCss = CssUtil.appendPrefix(options.cssPrefix, Grid.className);
111
+ this.cssUtil = new CssUtil([Grid.className, this.custumCss]);
112
+ this.cssUtil.addClassNames(this.element, 'container');
113
+ this.hierarchyCol = this.options.hierarchyCol ? $(this.options.hierarchyCol) : false;
114
+ this.hierarchyColIndex = this.hierarchyCol ? this.hierarchyCol.cellIndex : 0;
115
+ Element.makePositioned(this.element);
116
+ Position.includeScrollOffsets = true;
117
+ this.stateDivWidth = parseInt(CssUtil.getCssRuleBySelectorText('.' + Grid.className.state).style.width, 10);
118
+
119
+ this.marginSize = this.options.marginSize ? this.options.marginSize : 4;
120
+ this.stateIndent = 15;
121
+
122
+ this.rowIdBase = this.element.id + '_row_';
123
+ this.topLevelList = new Array();
124
+ this.removeList = new Array();
125
+ this.build();
126
+ this.removeList.each(function(r) {
127
+ r.parentNode.removeChild(r);
128
+ });
129
+ var sortOptions = {
130
+ relate : this.idTable,
131
+ handle:this.headerTable,
132
+ callBack:this.finishSort.bind(this)
133
+ };
134
+ sortOptions = $H(sortOptions).merge(this.options.sortOptions);
135
+ this.sortTable = new SortableTableGridEx(this.cellTable, sortOptions);
136
+ Element.setStyle(this.element, {visibility: 'visible'});
137
+ Element.show(this.element);
138
+ },
139
+
140
+ build: function() {
141
+ Element.cleanWhitespace(this.element);
142
+ this.cellTable = this.element.childNodes[0];
143
+ Element.cleanWhitespace(this.cellTable);
144
+
145
+ this.colLength = this.cellTable.tHead.rows[0].cells.length;
146
+ this.rowLength = this.cellTable.tBodies[0].rows.length;
147
+ if (this.rowLength == 0)this.rowLength = this.options.defaultRowLength;
148
+ this.buildBaseTable();
149
+ this.buildHeaderTable();
150
+ this.buildIdTable();
151
+ this.buildCellTable();
152
+
153
+ Event.observe(this.element, 'scroll', this.fixTablePosition.bindAsEventListener(this));
154
+ },
155
+
156
+ buildBaseTable: function() {
157
+
158
+ this.baseTable = Builder.node('table', Grid.options.baseTable);
159
+ this.cssUtil.addClassNames(this.baseTable, 'baseTable');
160
+ with (this.baseTable.style) {
161
+ width = this.options.baseWidth + 'px';
162
+ height = this.options.baseHeight + 'px';
163
+ position = 'absolute';
164
+ top = this.options.baseTop + 'px';
165
+ left = this.options.baseLeft + 'px';
166
+ }
167
+
168
+ var row = this.baseTable.insertRow(0);
169
+ var cell = row.insertCell(0);
170
+
171
+ this.cssUtil.addClassNames(row, 'baseRow');
172
+ this.cssUtil.addClassNames(cell, 'baseCell');
173
+
174
+ this.element.appendChild(this.baseTable);
175
+ },
176
+
177
+ buildHeaderTable: function() {
178
+ this.headerTable = Builder.node('table', Grid.options.headerTable);
179
+ this.cssUtil.addClassNames(this.headerTable, 'headerTable');
180
+
181
+ var thead = this.cellTable.tHead;
182
+ var row = thead.rows[0];
183
+ row.id = this.element.id + '_headerTable_row';
184
+ var cells = row.cells;
185
+ Element.cleanWhitespace(thead);
186
+ Element.cleanWhitespace(row);
187
+
188
+ this.cssUtil.addClassNames(row, 'headerRow');
189
+ for (var i = 0; i < cells.length; i++) {
190
+ var cell = cells[i];
191
+ var value = cell.firstChild;
192
+ var title = cell.innerHTML;
193
+ this.buildHeaderCell(cell, title, i);
194
+ this.removeList.push(value);
195
+ }
196
+ this.headerTable.appendChild(thead);
197
+ with (this.headerTable.style) {
198
+ width = this.options.cellDefaultWidth * this.colLength + 'px';
199
+ height = this.baseTable.style.height;
200
+ position= 'absolute';
201
+ top = Element.getStyle(this.baseTable, 'top');
202
+ left = parseInt(Element.getStyle(this.baseTable, 'left')) + parseInt(Element.getStyle(this.baseTable, 'width')) + 'px';
203
+ }
204
+ this.element.appendChild(this.headerTable);
205
+ Sortable.create(
206
+ row,
207
+ {
208
+ tag:'td',
209
+ handle:Grid.className.headerCellDrag,
210
+ constraint:true,
211
+ overlap:'horizontal',
212
+ scroll:this.element,
213
+ onUpdate:this.updateCellLine.bind(this)
214
+ });
215
+ },
216
+
217
+ buildHeaderCell : function(cell, title, index) {
218
+
219
+ cell.id = this.element.id + '_header_col_' + index;
220
+
221
+ var drag = Builder.node('div');
222
+ var sort = Builder.node('div');
223
+
224
+ this.cssUtil.addClassNames(cell, 'headerCell');
225
+ this.cssUtil.addClassNames(drag, 'headerCellDrag');
226
+ this.cssUtil.addClassNames(sort, 'headerCellSort');
227
+
228
+ cell.style.width = this.options.cellDefaultWidth + 'px';
229
+ var dragWidth = parseInt(Element.getStyle(cell, 'width')) - (this.marginSize * 2);
230
+ var sortWidth = dragWidth - (this.marginSize * 2);
231
+ var cellHeight = this.options.baseHeight - (Grid.options.headerTable.border * 4);
232
+ with (drag.style) {
233
+ width = dragWidth + 'px';
234
+ height = cellHeight + 'px';
235
+ marginLeft = this.marginSize + 'px';
236
+ marginRight = this.marginSize + 'px';
237
+ }
238
+ with (sort.style) {
239
+ width = sortWidth + 'px';
240
+ height = cellHeight + 'px';
241
+ marginLeft = this.marginSize + 'px';
242
+ marginRight = this.marginSize + 'px';
243
+ }
244
+
245
+ sort.innerHTML = title;
246
+ drag.appendChild(sort);
247
+ cell.appendChild(drag);
248
+
249
+ new ResizeableGridEx(cell, {minWidth: this.options.cellMinWidth, top:0,right:2, bottom:0, left:0 ,draw:this.updateCellWidth.bind(this)});
250
+ Event.observe(cell, 'mousedown', this.setSelectedColumn.bindAsEventListener(this));
251
+ Event.observe(drag, 'mousedown', this.setSelectedColumn.bindAsEventListener(this));
252
+ Event.observe(sort, 'mousedown', this.setSelectedColumn.bindAsEventListener(this));
253
+ },
254
+
255
+ buildIdTable: function() {
256
+
257
+ this.idTable = Builder.node('table', Grid.options.idTable);
258
+ this.cssUtil.addClassNames(this.idTable, 'idTable');
259
+ for (var i = 0; i < this.rowLength; i++) {
260
+
261
+ var row = this.idTable.insertRow(i);
262
+ this.buildIdRow(row, i);
263
+ }
264
+
265
+ with(this.idTable.style) {
266
+ width = this.options.baseWidth + 'px';
267
+ position = 'absolute';
268
+ top = parseInt(Element.getStyle(this.baseTable, 'top')) + parseInt(Element.getStyle(this.baseTable, 'height')) + 'px';
269
+ left = Element.getStyle(this.baseTable, 'left');
270
+ }
271
+
272
+ this.element.appendChild(this.idTable);
273
+ var tbody = this.idTable.tBodies[0];
274
+ tbody.id = this.element.id + '_idTable_tbody';
275
+ Sortable.create(
276
+ tbody,
277
+ {
278
+ tag:'tr',
279
+ handle:Grid.className.idCellVal,
280
+ scroll:this.element,
281
+ constraint:true,
282
+ overlap:'vertical',
283
+ onUpdate:this.updateRowLine.bind(this)
284
+ });
285
+ },
286
+
287
+ buildIdRow : function(row, index) {
288
+ row.id = this.rowIdBase + '_id_' + index;
289
+
290
+ var cell = row.insertCell(0);
291
+ var valueDiv = Builder.node('div');
292
+
293
+ this.cssUtil.addClassNames(row, 'idRow');
294
+ this.cssUtil.addClassNames(cell, 'idCell');
295
+ this.cssUtil.addClassNames(valueDiv, 'idCellVal');
296
+
297
+ with (cell.style) {
298
+ width = this.options.baseWidth + 'px';
299
+ height = this.options.cellDefaultHeight + 'px';
300
+ }
301
+ with (valueDiv.style) {
302
+ marginTop = this.marginSize + 'px';
303
+ marginBottom = this.marginSize + 'px';
304
+ width = this.options.baseWidth - (Grid.options.idTable.border * 4) + 'px';
305
+ height = this.options.cellDefaultHeight - (this.marginSize * 2) + 'px';
306
+ }
307
+
308
+ valueDiv.innerHTML = index + 1;
309
+ cell.appendChild(valueDiv);
310
+
311
+ new ResizeableGridEx(cell, {minHeight: this.options.cellMinHeight, top:0, right: 0, bottom: 2, left: 0, draw:this.updateCellHeight.bind(this)});
312
+
313
+ Event.observe(row, 'mousedown', this.setSelectedRow.bindAsEventListener(this));
314
+ Event.observe(cell, 'mousedown', this.setSelectedRow.bindAsEventListener(this));
315
+ Event.observe(valueDiv, 'mousedown', this.setSelectedRow.bindAsEventListener(this));
316
+ },
317
+
318
+ buildCellTable: function() {
319
+ var tbody = this.cellTable.tBodies[0];
320
+ Element.cleanWhitespace(tbody);
321
+ with(this.cellTable){
322
+ border = Grid.options.cellTable.border;
323
+ cellSpacing = Grid.options.cellTable.cellSpacing;
324
+ cellPadding = Grid.options.cellTable.cellPadding;
325
+ }
326
+ this.cssUtil.addClassNames(this.cellTable, 'cellTable');
327
+ this.cssUtil.addClassNames(tbody, 'cellTbody');
328
+ this.element.appendChild(this.cellTable);
329
+ var rows = this.cellTable.rows;
330
+
331
+ if (!rows || rows.length == 0) {
332
+ for(var i = 0; i < this.rowLength; i++) {
333
+
334
+ var newRow = this.cellTable.insertRow(i);
335
+ newRow.id = this.rowIdBase + i;
336
+ this.cssUtil.addClassNames(newRow, 'cellRow');
337
+
338
+ for (var j = 0; j < this.colLength; j++) {
339
+ var newCell = newRow.insertCell(j);
340
+ this.buildCell(newCell, j, "");
341
+ }
342
+ if (this.options.hierarchy) {
343
+ this.setHierarchyRow(newRow);
344
+ }
345
+ }
346
+
347
+ } else {
348
+ for (var i = 0; i < this.rowLength; i++) {
349
+ var row = rows[i];
350
+ Element.cleanWhitespace(row);
351
+ this.cssUtil.addClassNames(row, 'cellRow');
352
+ row.id = this.rowIdBase + i;
353
+ var cells = row.cells;
354
+
355
+ for (var j = 0; j < cells.length; j++) {
356
+ var cell = cells[j];
357
+ Element.cleanWhitespace(cell);
358
+ this.buildCell(cell, j, Element.collectTextNodes(cell));
359
+ this.removeList.push(cell.firstChild);
360
+ }
361
+ if (this.options.hierarchy) {
362
+ this.setHierarchyRow(row);
363
+ }
364
+ }
365
+ }
366
+
367
+ with (this.cellTable.style) {
368
+ width = this.options.cellDefaultWidth * this.colLength + 'px';
369
+ position = 'absolute';
370
+ top = parseInt(Element.getStyle(this.baseTable, 'top')) + parseInt(Element.getStyle(this.baseTable, 'height')) + 'px';
371
+ left = parseInt(Element.getStyle(this.baseTable, 'left')) + parseInt(Element.getStyle(this.baseTable, 'width')) + 'px';
372
+ }
373
+
374
+ this.cellTable.getIdRow = this.getIdRow.bind(this);
375
+ },
376
+
377
+ buildCell : function(cell, cellIdIndex, value) {
378
+
379
+ var cellValueDiv = Builder.node('div');
380
+ cellValueDiv.innerHTML = value;
381
+
382
+ cell.appendChild(cellValueDiv);
383
+ cell.id = cell.parentNode.id + '_col_' + cellIdIndex;
384
+
385
+ this.cssUtil.addClassNames(cell, 'cell');
386
+ this.cssUtil.addClassNames(cellValueDiv, 'cellVal');
387
+
388
+ with (cell.style) {
389
+ width = Element.getStyle(this.getHeaderCell(cell), 'width');
390
+ height = Element.getStyle(this.getIdRow(cell.parentNode).cells[0], 'height');
391
+ }
392
+ with (cellValueDiv.style) {
393
+ width = cell.style.width;
394
+ height = cell.style.height;
395
+ marginTop = '0px';
396
+ marginBottom = '0px';
397
+ }
398
+
399
+ Event.observe(cell, 'click', this.setSelectedCell.bindAsEventListener(this));
400
+
401
+ var ajax = new Ajax.InPlaceEditor(cellValueDiv, this.options.cellEditUrl,
402
+ {
403
+ formClassName: this.cssUtil.joinClassNames('inplaceEditor'),
404
+ rows: 2,
405
+ cols:12,
406
+ okButton: false,
407
+ cancelLink:false,
408
+ submitOnBlur:true,
409
+ hoverClassName: "cellHover",
410
+ highlightcolor: "#becfeb",
411
+ highlightendcolor: "#becfeb",
412
+ onComplete: this.showStateDiv.bind(this),
413
+ callback : this.createInplaceEditorParams.bind(this),
414
+ formId : cell.id + '_form'
415
+ }
416
+ );
417
+ cellValueDiv.ajax = ajax;
418
+ Event.stopObserving(cellValueDiv, 'click', ajax.onclickListener);
419
+ Event.stopObserving(cellValueDiv, 'mouseover', ajax.mouseoverListener);
420
+ Event.stopObserving(cellValueDiv, 'mouseout', ajax.mouseoutListener);
421
+
422
+
423
+ Event.observe(cellValueDiv, 'dblclick', this.setTextAreaSize.bindAsEventListener(this));
424
+ if (this.options.hierarchy && cell.cellIndex == this.hierarchyColIndex) {
425
+ Event.observe(cellValueDiv, 'dblclick', this.hideStateDiv.bindAsEventListener(this));
426
+ }
427
+ Event.observe(cellValueDiv, 'dblclick', ajax.onclickListener);
428
+
429
+ },
430
+
431
+ addColumn: function(index, colTitle, values) {
432
+ var headerRow = this.headerTable.rows[0];
433
+ var insertIndex = (!isNaN(index)) ? index : this.colLength;
434
+ var colIdIndex = this.colLength;
435
+ var headerCell = headerRow.insertCell(insertIndex);
436
+ this.buildHeaderCell(headerCell, colTitle, insertIndex);
437
+
438
+ var rows = this.cellTable.rows;
439
+ var idRows = this.idTable.rows;
440
+ for (var i = 0; i < rows.length; i++) {
441
+
442
+ var cell = rows[i].insertCell(insertIndex);
443
+ var cellValue = "";
444
+ if (values && values[i]) {
445
+ cellValue = values[i];
446
+ }
447
+ this.buildCell(cell, colIdIndex, cellValue);
448
+ }
449
+
450
+ this.headerTable.style.width = parseInt(Element.getStyle(this.headerTable, 'width')) + this.options.cellDefaultWidth + 'px';
451
+ this.cellTable.style.width = this.headerTable.style.width;
452
+
453
+ var sortableOptions = Sortable.options(headerRow);
454
+
455
+ sortableOptions.draggables.push(
456
+ new Draggable(
457
+ headerCell,
458
+ {
459
+ revert: true,
460
+ constraint: true,
461
+ scroll: this.element,
462
+ handle: Element.getElementsByClassName(headerCell, Grid.className.headerCellDrag)[0]
463
+ }
464
+ )
465
+ );
466
+ Droppables.add(headerCell, {overlap:'horizontal', containment:headerRow, onHover:Sortable.onHover, greedy:true});
467
+ sortableOptions.droppables.push(headerCell);
468
+ this.sortTable.addEvent(Element.getElementsByClassName(headerCell, Grid.className.headerCellSort)[0]);
469
+ this.colLength += 1;
470
+ },
471
+
472
+ deleteColumn : function(index) {
473
+ if((isNaN(index)) || index >= this.colLength) {
474
+ return;
475
+ }
476
+ var headerRow = this.headerTable.rows[0];
477
+ if (!headerRow) return;
478
+ var headerCell = headerRow.cells[index];
479
+ if (!headerCell) return;
480
+
481
+ var width = headerCell.offsetWidth;
482
+ var rows = this.cellTable.rows;
483
+ headerRow.deleteCell(index);
484
+
485
+ for (var i = 0; i < rows.length; i++) {
486
+ rows[i].deleteCell(index);
487
+ }
488
+
489
+ var headerTableWidth = parseInt(Element.getStyle(this.headerTable, 'width')) - width;
490
+
491
+ this.headerTable.style.width = headerTableWidth >= 0 ? headerTableWidth + 'px' : '0px';
492
+ this.cellTable.style.width = this.headerTable.style.width;
493
+ this.colLength -= 1;
494
+ this.fixTablePosition();
495
+ },
496
+
497
+ addRow : function(index, values) {
498
+ var insertIndex = (!isNaN(index)) ? index : this.idTable.rows.length;
499
+ var rowIdIndex = this.idTable.rows.length;
500
+ var idRow = this.idTable.insertRow(index);
501
+ idRow.id = this.rowIdBase + '_id_' + rowIdIndex;
502
+ this.buildIdRow(idRow, rowIdIndex);
503
+ this.updateId();
504
+
505
+ var cellRow = this.cellTable.insertRow(insertIndex);
506
+ cellRow.id = this.rowIdBase + rowIdIndex;
507
+ this.cssUtil.addClassNames(cellRow, 'cellRow');
508
+ var headerCells = this.headerTable.rows[0].cells;
509
+
510
+ for (var i = 0; i < headerCells.length; i++) {
511
+ var headerCell = headerCells[i];
512
+ var colIdIndex = headerCell.id.substring(headerCell.id.indexOf('_col_',0) + '_col_'.length);
513
+ var cell = cellRow.insertCell(i);
514
+ var cellValue = (values && values[i]) ? values[i] : "";
515
+ this.buildCell(cell, colIdIndex, cellValue);
516
+ }
517
+
518
+ this.sortTable.defaultOrder.insert(index, cellRow);
519
+
520
+ var idTbody = this.idTable.tBodies[0];
521
+ var sortableOptions = Sortable.options(idTbody);
522
+
523
+ sortableOptions.draggables.push(
524
+ new Draggable(
525
+ idRow,
526
+ {
527
+ revert: true,
528
+ constraint: true,
529
+ scroll: this.element,
530
+ handle: Element.getElementsByClassName(idRow, Grid.className.idCellVal)[0]
531
+ }
532
+ )
533
+ );
534
+ Droppables.add(idRow, {overlap:'vertical', containment:idTbody, onHover:Sortable.onHover, greedy:true});
535
+ sortableOptions.droppables.push(idRow);
536
+ this.rowLength += 1;
537
+ return cellRow;
538
+ },
539
+
540
+ deleteRow : function(index) {
541
+ if(isNaN(index) || index >= this.rowLength) {
542
+ return;
543
+ }
544
+
545
+ var targetId = null;
546
+ if (this.cellTable.rows[index])
547
+ targetId = this.cellTable.rows[index].id;
548
+ else
549
+ return;
550
+
551
+ this.sortTable.defaultOrder.reverse();
552
+ var newOrder = new Array();
553
+
554
+ for (var i = 0; this.sortTable.defaultOrder.length > 0; i++) {
555
+ var row = this.sortTable.defaultOrder.pop();
556
+ if (row.id == targetId) {
557
+ continue;
558
+ }
559
+ newOrder.push(row);
560
+ }
561
+
562
+ this.sortTable.defaultOrder = newOrder;
563
+ this.idTable.deleteRow(index);
564
+ this.cellTable.deleteRow(index);
565
+
566
+ this.fixTablePosition();
567
+ this.rowLength -= 1;
568
+ this.updateId();
569
+ },
570
+
571
+ getHeaderCell : function(cell) {
572
+ return this.headerTable.rows[0].cells[cell.cellIndex];
573
+ },
574
+
575
+ getCells : function(index) {
576
+ var rows = this.cellTable.rows;
577
+ var columns = new Array();
578
+ for (var i = 0; i < rows.length; i++){
579
+ columns.push(rows[i].cells[index]);
580
+ }
581
+ return columns;
582
+ },
583
+
584
+ getRow : function(index) {
585
+ return this.cellTable.rows[index];
586
+ },
587
+
588
+ getIdRow : function(cellRow) {
589
+ var id = cellRow.id;
590
+ var index = id.substring(this.rowIdBase.length);
591
+ var targetRow = $(this.rowIdBase + '_id_' + index);
592
+ return targetRow;
593
+ },
594
+
595
+ getColTitle : function(index) {
596
+ var headerCell = this.headerTable.rows[0].cells[index];
597
+ var title = Element.collectTextNodes(headerCell);
598
+ return title;
599
+ },
600
+
601
+ finishSort : function() {
602
+ for (var i = 0; i < this.cellTable.rows.length; i++) {
603
+ this.idTable.tBodies[0].appendChild(this.getIdRow(this.cellTable.rows[i]));
604
+ }
605
+ this.updateId();
606
+ },
607
+
608
+ setSelectedCell : function(event) {
609
+ this.removeSelectedClasses();
610
+ var src = Event.element(event);
611
+
612
+ if (src.tagName.toUpperCase() != 'TH' && src.tagName.toUpperCase() != 'TD') {
613
+ src = Element.getParentByTagName(['TH,TD'], src);
614
+ }
615
+
616
+ this.targetCell = src;
617
+
618
+ if (this.targetCell) {
619
+ this.targetColIndex = this.targetCell.cellIndex;
620
+ this.targetRowIndex = this.targetCell.parentNode.rowIndex;
621
+ this.targetColumn = this.getCells(this.targetColIndex);
622
+ this.targetRow = this.getRow(this.targetRowIndex);
623
+ }
624
+
625
+ this.cssUtil.addClassNames(this.targetCell, 'cellSelected');
626
+ var childNodes = Element.getTagNodes(this.targetCell, true);
627
+ for (var i = 0; i < childNodes.length; i++) {
628
+ this.cssUtil.addClassNames(childNodes[i], 'cellSelected');
629
+ }
630
+ },
631
+
632
+ setSelectedColumn : function(event) {
633
+ this.removeSelectedClasses();
634
+
635
+ this.targetCell = null;
636
+ this.targetRowIndex = null;
637
+ this.targetRow = null;
638
+ this.targetIdRow = null;
639
+ var src = Event.element(event);
640
+ if (src && (src.tagName.toUpperCase() == 'TH' || src.tagName.toUpperCase() == 'TD')) {
641
+ this.targetHeaderCell = src;
642
+ } else {
643
+ this.targetHeaderCell = Element.getParentByTagName(['TH,TD'], src);
644
+ }
645
+ if (this.targetHeaderCell) {
646
+ this.targetColIndex = this.targetHeaderCell.cellIndex;
647
+ this.targetColumn = this.getCells(this.targetColIndex);
648
+ this.cssUtil.addClassNames(this.targetHeaderCell, 'cellSelected');
649
+ var childNodes = Element.getTagNodes(this.targetHeaderCell, true);
650
+ for (var i = 0; i < childNodes.length; i++) {
651
+ this.cssUtil.addClassNames(childNodes[i], 'cellSelected');
652
+ }
653
+ for(var i = 0; i < this.targetColumn.length; i++) {
654
+ this.cssUtil.addClassNames(this.targetColumn[i], 'cellSelected');
655
+ var cellChildNodes = Element.getTagNodes(this.targetColumn[i], true);
656
+ for (var j = 0; j < cellChildNodes.length; j++) {
657
+ this.cssUtil.addClassNames(cellChildNodes.length[j], 'cellSelected');
658
+ }
659
+ }
660
+ }
661
+ },
662
+
663
+ setSelectedRow : function(event) {
664
+ this.removeSelectedClasses();
665
+ var src = Event.element(event);
666
+ if (src && src.tagName.toUpperCase() == 'TR') {
667
+ this.targetIdRow = src;
668
+ } else {
669
+ this.targetIdRow = Element.getParentByTagName(['TR'], src);
670
+ }
671
+ if (this.targetIdRow) {
672
+ this.targetRowIndex = this.targetIdRow.rowIndex;
673
+ this.targetRow = this.getRow(this.targetRowIndex);
674
+
675
+ this.cssUtil.addClassNames(this.targetRow, 'cellSelected');
676
+ var childNodes = Element.getTagNodes(this.targetRow, true);
677
+ for (var i = 0; i < childNodes.length; i++) {
678
+ this.cssUtil.addClassNames(childNodes[i], 'cellSelected');
679
+ }
680
+ this.cssUtil.addClassNames(this.targetIdRow, 'cellSelected');
681
+ childNodes = Element.getTagNodes(this.targetIdRow, true);
682
+ for (var i = 0; i < childNodes.length; i++) {
683
+ this.cssUtil.addClassNames(childNodes[i], 'cellSelected');
684
+ }
685
+ }
686
+
687
+ },
688
+
689
+ removeSelectedClasses : function() {
690
+ if (this.targetHeaderCell) {
691
+ this.cssUtil.removeClassNames(this.targetHeaderCell, 'cellSelected');
692
+ var childNodes = Element.getTagNodes(this.targetHeaderCell, true);
693
+ for (var i = 0; i < childNodes.length; i++) {
694
+ this.cssUtil.removeClassNames(childNodes[i], 'cellSelected');
695
+ }
696
+ for(var i = 0; i < this.targetColumn.length; i++) {
697
+ this.cssUtil.removeClassNames(this.targetColumn[i], 'cellSelected');
698
+ var cellChildNodes = Element.getTagNodes(this.targetColumn[i], true);
699
+ for (var j = 0; j < cellChildNodes.length; j++) {
700
+ this.cssUtil.removeClassNames(cellChildNodes.length[j], 'cellSelected');
701
+ }
702
+ }
703
+
704
+ }
705
+ if (this.targetCell) {
706
+ this.cssUtil.removeClassNames(this.targetCell, 'cellSelected');
707
+ var childNodes = Element.getTagNodes(this.targetCell, true);
708
+ for (var i = 0; i < childNodes.length; i++) {
709
+ this.cssUtil.removeClassNames(childNodes[i], 'cellSelected');
710
+ }
711
+
712
+ }
713
+
714
+ if (this.targetRow) {
715
+ this.cssUtil.removeClassNames(this.targetRow, 'cellSelected');
716
+ var childNodes = Element.getTagNodes(this.targetRow, true);
717
+ for (var i = 0; i < childNodes.length; i++) {
718
+ this.cssUtil.removeClassNames(childNodes[i], 'cellSelected');
719
+ }
720
+ this.cssUtil.removeClassNames(this.targetIdRow, 'cellSelected');
721
+ childNodes = Element.getTagNodes(this.targetIdRow, true);
722
+ for (var i = 0; i < childNodes.length; i++) {
723
+ this.cssUtil.removeClassNames(childNodes[i], 'cellSelected');
724
+ }
725
+ }
726
+
727
+ this.targetHeaderCell = null;
728
+ this.targetColumn = null;
729
+ this.targetColIndex = null;
730
+ this.targetCell = null;
731
+ this.targetRowIndex = null;
732
+ this.targetRow = null;
733
+ this.targetIdRow = null;
734
+ },
735
+
736
+ updateId : function() {
737
+ var rows = this.idTable.rows;
738
+ for (var i = 0; i < rows.length; i++) {
739
+ var idValue = document.getElementsByClassName(this.custumCss.idCellVal, rows[i])[0];
740
+
741
+ idValue.innerHTML = i + 1;
742
+ }
743
+ },
744
+
745
+ updateRowLine : function(target) {
746
+ var targetCellRow = this.cellTable.rows[this.targetRowIndex];
747
+ var updateRowIndex = this.targetIdRow.rowIndex;
748
+ var cellTableBody = targetCellRow.parentNode;
749
+ var cellTableRows = cellTableBody.rows;
750
+
751
+ if (this.options.hierarchy) {
752
+ var checkRow = cellTableBody.rows[this.targetIdRow.rowIndex];
753
+ if (this.isParentRow(checkRow, targetCellRow)) {
754
+ var idBody = this.idTable.tBodies[0];
755
+ idBody.insertBefore(this.targetIdRow, idBody.rows[this.targetRowIndex]);
756
+ return;
757
+ }
758
+ }
759
+ if (updateRowIndex == cellTableRows.length - 1) {
760
+ cellTableBody.appendChild(targetCellRow);
761
+ } else if (this.targetRowIndex < updateRowIndex) {
762
+ cellTableBody.insertBefore(targetCellRow, cellTableRows[updateRowIndex + 1]);
763
+ } else {
764
+ cellTableBody.insertBefore(targetCellRow, cellTableRows[updateRowIndex]);
765
+ }
766
+ if (this.options.hierarchy) {
767
+ this.updateOutline(targetCellRow);
768
+ }
769
+ this.targetRowIndex = updateRowIndex;
770
+ this.updateId();
771
+ },
772
+ updateCellLine : function(target){
773
+ var targetCells = this.getCells(this.targetColIndex);
774
+ var updateColIndex = this.targetHeaderCell.cellIndex;
775
+
776
+ var rows = this.cellTable.rows;
777
+
778
+ for (var i = 0; i < rows.length; i++) {
779
+ var cells = rows[i].cells;
780
+ var targetCell = targetCells[i];
781
+
782
+ if (updateColIndex == cells.length -1) {
783
+ rows[i].appendChild(targetCell);
784
+ } else if (this.targetColIndex < updateColIndex) {
785
+ rows[i].insertBefore(targetCell, cells[updateColIndex + 1]);
786
+ } else {
787
+ rows[i].insertBefore(targetCell, cells[updateColIndex]);
788
+ }
789
+ }
790
+ this.targetColIndex = updateColIndex;
791
+ },
792
+
793
+ updateCellWidth : function(newStyle, headColumn) {
794
+
795
+ if(newStyle.width > this.options.cellMinWidth) {
796
+ var dragDiv = Element.getElementsByClassName(headColumn, Grid.className.headerCellDrag)[0];
797
+ var sortDiv = Element.getElementsByClassName(headColumn, Grid.className.headerCellSort)[0];
798
+ var val = newStyle.width - (parseInt(Element.getStyle(headColumn, 'width')));
799
+
800
+ val = parseInt(val);
801
+
802
+ this.headerTable.style.width = (parseInt(Element.getStyle(this.headerTable, 'width')) + val) + 'px';
803
+
804
+ dragDiv.style.width = newStyle.width - (this.marginSize * 2) + 'px';
805
+ sortDiv.style.width = parseInt(Element.getStyle(dragDiv, 'width')) - (this.marginSize * 2) + 'px';
806
+
807
+ var index = headColumn.cellIndex ;
808
+ var rows = this.cellTable.rows;
809
+
810
+ this.cellTable.style.width = this.headerTable.style.width
811
+
812
+ for(var i = 0; i < rows.length; i++){
813
+ var cell = rows[i].cells[index];
814
+ var cellValueDiv = Element.getElementsByClassName(cell, Grid.className.cellVal)[0];
815
+ cellValueDiv.style.width = newStyle.width + 'px';
816
+ cell.style.width = newStyle.width + 'px';
817
+ }
818
+
819
+ }
820
+ },
821
+
822
+ updateCellHeight : function(newStyle, idCell) {
823
+ if(newStyle.height > this.options.cellMinHeight) {
824
+ var row = idCell.parentNode;
825
+ var index = row.rowIndex;
826
+ var idValueDiv = Element.getElementsByClassName(idCell, Grid.className.idCellVal)[0];
827
+ idValueDiv.style.height = newStyle.height - (this.marginSize * 2) + 'px';
828
+ var padding = parseInt(idValueDiv.style.paddingTop);
829
+ var cellRow = this.cellTable.rows[index];
830
+ var cells = cellRow.cells;
831
+ for (var i = 0; i < cells.length; i++) {
832
+ cells[i].style.height = newStyle.height + 'px';
833
+ var cellValueDiv = Element.getElementsByClassName(cells[i], Grid.className.cellVal)[0];
834
+ cellValueDiv.style.height = newStyle.height + 'px';
835
+ }
836
+ }
837
+ },
838
+
839
+ setTextAreaSize : function(event) {
840
+ var target = Event.element(event);
841
+ var rows = parseInt(Element.getStyle(target, 'height'));
842
+ var cols = parseInt(Element.getStyle(target, 'width'));
843
+ target.ajax.options.rows = Math.round(rows/20);
844
+ target.ajax.options.cols = Math.round(cols/20);
845
+ },
846
+
847
+ fixTablePosition : function(event) {
848
+ Grid.scrollTop = this.element.scrollTop;
849
+ Grid.scrollLeft = this.element.scrollLeft;
850
+ this.baseTable.style.top = Grid.scrollTop + 'px';
851
+ this.baseTable.style.left = Grid.scrollLeft + 'px';
852
+ this.headerTable.style.top = Grid.scrollTop + 'px';
853
+ this.idTable.style.left = Grid.scrollLeft + 'px';
854
+ },
855
+
856
+ //----------ajax request param method---------------------------------------------------------------------------
857
+ createInplaceEditorParams : function(form, value) {
858
+ var rowIndexEnd = form.id.indexOf('_col_', 0);
859
+ var rowIndex = form.id.substring(this.rowIdBase.length, rowIndexEnd);
860
+
861
+ var colIndexStart = rowIndexEnd + '_col_'.length;
862
+ var colIndexEnd = form.id.indexOf('_form', 0);
863
+ var colIndex = form.id.substring(colIndexStart, colIndexEnd);
864
+ var jsonRowObj = this.rowDataToJsonObj(rowIndex);
865
+
866
+ var targetColTitle = this.getColTitle(colIndex);
867
+ jsonRowObj.each(function(j) {
868
+ if (j.column == targetColTitle) {
869
+ j.value = value;
870
+ throw $break;
871
+ }
872
+ });
873
+ var jsonRowText = JSON.stringify(jsonRowObj);
874
+ var params = {
875
+ rowData: jsonRowText,
876
+ column: targetColTitle,
877
+ value: value
878
+ };
879
+ return $H(params).toQueryString();
880
+ },
881
+
882
+ gridDataToJsonObj : function() {
883
+ var rows = this.cellTable.rows;
884
+ var jsonDataList = [];
885
+ for (var i = 0; i < this.rowLength; i++) {
886
+ var rowData = this.rowDataToJsonObj(i);
887
+ jsonDataList.push(rowData);
888
+ }
889
+ return jsonDataList;
890
+ },
891
+
892
+ rowDataToJsonObj : function(index) {
893
+ var jsonRowObj = [];
894
+ var row = $A(this.cellTable.rows).detect(function(r) {return r.id.getSuffix() == index});
895
+ for (var i = 0; i < this.colLength; i++) {
896
+ var jsonCellObj = {};
897
+ jsonCellObj['column'] = this.getColTitle(i);
898
+ jsonCellObj['value'] = Element.collectTextNodes(row.cells[i]);
899
+ jsonRowObj.push(jsonCellObj);
900
+ }
901
+ return jsonRowObj;
902
+ },
903
+
904
+ updateGridData : function() {
905
+
906
+ var jsonDataText = JSON.stringify(this.gridDataToJsonObj());
907
+ var params = 'id=' + encodeURIComponent(this.element.id) + '&data=' + encodeURIComponent(jsonDataText);
908
+
909
+ new Ajax.Updater(
910
+ this.options.updateGridReceiver,
911
+ this.options.updateGridUrl,
912
+ {
913
+ parameters: params,
914
+ evalScripts: true, asynchronous:true
915
+
916
+ }
917
+ );
918
+ },
919
+
920
+ //----------hierarchy grid method---------------------------------------------------------------------------
921
+ setHierarchyRow : function(row, outlineLevel, outlineNum){
922
+ row.outlineLevel = outlineLevel || 1;
923
+ row.list = row.list || new Array();
924
+ if (row.outlineLevel == 1) {
925
+ this.topLevelList.push(row);
926
+ row.outlineNum = outlineNum || this.topLevelList.length;
927
+ } else {
928
+ var parentRow = this.getParentRow(row);
929
+ parentRow.list.push(row);
930
+ var num = parentRow.length;
931
+ row.outlineNum = outlineNum || parentRow.outlineNum + '.' + parentRow.list.length;
932
+
933
+ }
934
+
935
+ this.buildStateDiv(row.cells[this.hierarchyColIndex]);
936
+ this.setOutlineIndent(row);
937
+ this.setFontWeight(row);
938
+ },
939
+
940
+ buildStateDiv : function (cell) {
941
+ var stateDiv = Builder.node('div');
942
+ var valueDiv = Element.getElementsByClassName(cell, Grid.className.cellVal)[0];
943
+ this.cssUtil.addClassNames(stateDiv, 'state');
944
+ cell.insertBefore(stateDiv, valueDiv);
945
+
946
+ if (document.all) {
947
+ stateDiv.style.position = "absolute";
948
+ } else {
949
+ stateDiv.style.position = "relative";
950
+ stateDiv.style.cssFloat = "left";
951
+ }
952
+ this.addStateClass(cell, stateDiv);
953
+ Event.observe(stateDiv, 'click', this.toggleState.bindAsEventListener(this));
954
+ },
955
+
956
+ addStateClass : function (cell, stateDiv) {
957
+ var row = cell.parentNode;
958
+ if (row.list.length == 0) {
959
+ this.cssUtil.addClassNames(stateDiv, 'stateEmpty');
960
+ } else if (this.options.open){
961
+ this.cssUtil.addClassNames(stateDiv, 'stateOpen');
962
+ } else {
963
+ this.cssUtil.addClassNames(stateDiv, 'stateClose');
964
+ this.closeRow(row);
965
+ }
966
+ },
967
+
968
+ toggleState : function(event) {
969
+ var src = Event.element(event);
970
+ var row = src.parentNode.parentNode;
971
+
972
+ if (!Element.hasClassName(src, Grid.className.stateEmpty)) {
973
+ if (Element.hasClassName(src, Grid.className.stateOpen)) {
974
+ this.closeRow(row.list);
975
+ this.cssUtil.removeClassNames(src, 'stateOpen');
976
+ this.cssUtil.addClassNames(src, 'stateClose');
977
+ } else {
978
+ this.openRow(row.list);
979
+ this.cssUtil.removeClassNames(src, 'stateClose');
980
+ this.cssUtil.addClassNames(src, 'stateOpen');
981
+ }
982
+ }
983
+ },
984
+
985
+ openRow : function(list) {
986
+ for (var i = 0; i < list.length; i++) {
987
+ var row = list[i];
988
+ Element.show(row);
989
+ Element.show(this.getIdRow(row));
990
+ var stateDiv = Element.getElementsByClassName(row.cells[this.hierarchyColIndex], Grid.className.state)[0];
991
+ if (Element.hasClassName(stateDiv, Grid.className.stateOpen)) {
992
+ this.openRow(row.list)
993
+ }
994
+ }
995
+ },
996
+
997
+ closeRow : function(list) {
998
+ for (var i = 0; i < list.length; i++) {
999
+ Element.hide(list[i]);
1000
+ Element.hide(this.getIdRow(list[i]));
1001
+ this.closeRow(list[i].list)
1002
+ }
1003
+ },
1004
+
1005
+
1006
+ showStateDiv : function(transport, element) {
1007
+ var row = Element.getParentByTagName(['TR'], element);
1008
+ var state = Element.getElementsByClassName(row, Grid.className.state)[0];
1009
+ Element.show(state);
1010
+ },
1011
+
1012
+ hideStateDiv : function(event) {
1013
+ var src = Event.element(event);
1014
+ var row = Element.getParentByTagName(['TR'], src);
1015
+ var state = Element.getElementsByClassName(row, Grid.className.state)[0];
1016
+
1017
+ Element.hide(state);
1018
+ },
1019
+
1020
+ addHierarchyRow : function(index, values) {
1021
+ if (this.colLength == 0) {
1022
+ return;
1023
+ }
1024
+ var newRow = this.addRow(index, values);
1025
+
1026
+ newRow.list = new Array();
1027
+ var previousRow = newRow.previousSibling;
1028
+ var parentRow = null;
1029
+ var parentList = null;
1030
+ var insertIndex = 0;
1031
+ if (!previousRow) {
1032
+ newRow.outlineLevel = 1;
1033
+ parentList = this.topLevelList;
1034
+ } else if (previousRow.list.length > 0) {
1035
+ newRow.outlineLevel = previousRow.outlineLevel + 1;
1036
+ parentRow = previousRow;
1037
+ parentList = parentRow.list;
1038
+ } else {
1039
+ newRow.outlineLevel = previousRow.outlineLevel;
1040
+ parentRow = this.getParentRow(previousRow);
1041
+ parentList = parentRow ? parentRow.list : this.topLevelList;
1042
+ insertIndex = parentList.indexOf(previousRow) + 1;
1043
+ }
1044
+ parentList.insert(insertIndex, newRow);
1045
+ this.buildStateDiv(newRow.cells[this.hierarchyColIndex]);
1046
+ for (var i = insertIndex; i < parentList.length; i++) {
1047
+ if (parentList[i].outlineLevel != 1) {
1048
+ parentList[i].outlineNum = parentRow.outlineNum + '.' + (i + 1);
1049
+ } else {
1050
+ parentList[i].outlineNum = i + 1;
1051
+ }
1052
+ this.setOutline(parentList[i]);
1053
+ }
1054
+
1055
+ },
1056
+
1057
+ deleteHierarchyRow : function(index) {
1058
+ if(isNaN(index) || index >= this.rowLength) {
1059
+ return;
1060
+ }
1061
+ var row = this.getRow(index);
1062
+ if (!row) {
1063
+ return;
1064
+ }
1065
+ var parentRow = this.getParentRow(row);
1066
+ var parentList = parentRow ? parentRow.list : this.topLevelList;
1067
+ var removeIndex = parentList.indexOf(row);
1068
+ var childList = row.list;
1069
+
1070
+ for (var i = 0; i < childList.length; i++) {
1071
+ this.deleteChildRow(childList[i]);
1072
+ }
1073
+ parentList.remove(removeIndex);
1074
+ this.deleteRow(index);
1075
+
1076
+ for (var i = removeIndex; i < parentList.length; i++) {
1077
+ var updateRow = parentList[i];
1078
+ if (updateRow.outlineLevel == 1) {
1079
+ updateRow.outlineNum = i + 1;
1080
+ } else {
1081
+ updateRow.outlineNum = this.getParentRow(updateRow).outlineNum + '.' + (i + 1);
1082
+ }
1083
+ this.setOutline(parentList[i]);
1084
+ }
1085
+ this.setFontWeight(parentRow);
1086
+ },
1087
+
1088
+ deleteChildRow : function(childRow) {
1089
+ var list = childRow.list;
1090
+
1091
+ for (var i = 0; i < list.length; i++) {
1092
+ this.deleteChildRow(list[i]);
1093
+ }
1094
+ this.deleteRow(childRow.rowIndex);
1095
+ },
1096
+
1097
+ levelUp : function(row) {
1098
+ if (!row) {
1099
+ return;
1100
+ }
1101
+ var previousRow = row.previousSibling;
1102
+ if (row.outlineLevel == 1 || !previousRow) {
1103
+ return;
1104
+ }
1105
+
1106
+ var parentRow = this.getParentRow(row);
1107
+ var currentList = parentRow.list;
1108
+
1109
+ var newParentRow = this.getParentRow(parentRow);
1110
+ var targetList = newParentRow ? newParentRow.list : this.topLevelList;
1111
+
1112
+ var currentIndex = currentList.indexOf(row);
1113
+ var targetIndex = targetList.indexOf(parentRow) + 1;
1114
+
1115
+ row.outlineLevel -= 1;
1116
+ targetList.insert(targetIndex, row);
1117
+ currentList.remove(currentIndex);
1118
+
1119
+ while (currentList[currentIndex]) {
1120
+ var moveRow = currentList[currentIndex];
1121
+ row.list.push(moveRow);
1122
+ currentList.remove(currentIndex);
1123
+ }
1124
+
1125
+ if (row.outlineLevel != 1) {
1126
+ row.outlineNum = newParentRow.outlineNum + '.' + (targetIndex + 1);
1127
+ } else {
1128
+ row.outlineNum = targetIndex + 1;
1129
+ }
1130
+
1131
+ this.setOutline(row);
1132
+
1133
+ for (var i = targetIndex + 1; i < targetList.length; i++) {
1134
+ if (targetList[i].outlineLevel != 1) {
1135
+ targetList[i].outlineNum = newParentRow.outlineNum + '.' + (i + 1);
1136
+ } else {
1137
+ targetList[i].outlineNum = i + 1;
1138
+ }
1139
+ this.setOutline(targetList[i]);
1140
+ }
1141
+
1142
+ this.setFontWeight(row);
1143
+ this.setFontWeight(parentRow);
1144
+ this.setFontWeight(newParentRow);
1145
+ this.setStateClass(row);
1146
+ this.setStateClass(previousRow);
1147
+ },
1148
+
1149
+ levelDown : function(row) {
1150
+ if (!row) {
1151
+ return;
1152
+ }
1153
+ var previousRow = row.previousSibling;
1154
+ var parentRow = this.getParentRow(row);
1155
+ if (!previousRow || parentRow == previousRow) {
1156
+ return;
1157
+ }
1158
+ var currentList = (row.outlineLevel == 1) ? this.topLevelList : parentRow.list;
1159
+ var currentIndex = currentList.indexOf(row);
1160
+
1161
+ row.outlineLevel += 1;
1162
+
1163
+ var newParentRow = this.getParentRow(row);
1164
+ var targetList = newParentRow.list;
1165
+ var targetIndex = targetList.length;
1166
+
1167
+ currentList.remove(currentIndex);
1168
+ targetList.push(row);
1169
+
1170
+ row.outlineNum = newParentRow.outlineNum + '.' + (targetIndex + 1);
1171
+ this.setOutline(row);
1172
+ for (var i = currentIndex; i < currentList.length; i++) {
1173
+ if (currentList[i].outlineLevel != 1) {
1174
+ currentList[i].outlineNum = parentRow.outlineNum + '.' + (i + 1);
1175
+ } else {
1176
+ currentList[i].outlineNum = i + 1;
1177
+ }
1178
+ this.setOutline(currentList[i]);
1179
+ }
1180
+
1181
+ for (var i = targetIndex + 1; i < targetList.length; i++) {
1182
+ targetList[i].outlineNum = newParentRow.outlineNum + '.' + (i + 1);
1183
+ this.setOutline(targetList[i]);
1184
+ }
1185
+
1186
+ this.setFontWeight(row);
1187
+ this.setFontWeight(parentRow);
1188
+ this.setFontWeight(newParentRow);
1189
+ this.setStateClass(row);
1190
+ this.setStateClass(previousRow);
1191
+
1192
+ },
1193
+
1194
+ setStateClass : function(row) {
1195
+ if (!row.list) return;
1196
+ var stateDiv = Element.getElementsByClassName(row.cells[this.hierarchyColIndex], Grid.className.state)[0];
1197
+
1198
+ if (Element.hasClassName(stateDiv, Grid.className.stateEmpty) && row.list.length > 0) {
1199
+ this.cssUtil.removeClassNames(stateDiv, 'stateEmpty');
1200
+ this.cssUtil.addClassNames(stateDiv, 'stateOpen');
1201
+ } else if (!Element.hasClassName(stateDiv, Grid.className.stateEmpty) && row.list.length == 0) {
1202
+ this.cssUtil.removeClassNames(stateDiv, 'stateOpen');
1203
+ this.cssUtil.addClassNames(stateDiv, 'stateEmpty');
1204
+ }
1205
+ },
1206
+
1207
+ setOutline : function(row) {
1208
+ var childList = row.list;
1209
+ if (!childList) return;
1210
+ for(var i = 0; i < childList.length; i++) {
1211
+ var childRow = childList[i];
1212
+ childRow.outlineLevel = row.outlineLevel + 1;
1213
+ childRow.outlineNum = row.outlineNum + '.' + (i + 1);
1214
+ this.setOutline(childRow);
1215
+ }
1216
+ this.setOutlineIndent(row);
1217
+ },
1218
+
1219
+ setOutlineIndent : function(row) {
1220
+ var cell = row.cells[this.hierarchyColIndex];
1221
+ if (!cell) {
1222
+ return;
1223
+ }
1224
+ var cellValueDiv = Element.getElementsByClassName(cell, Grid.className.cellVal)[0];
1225
+ var stateDiv = Element.getElementsByClassName(cell, Grid.className.state)[0];
1226
+ if (!stateDiv) return;
1227
+ var stateDivWidth = stateDiv.offsetWidth || this.stateDivWidth;
1228
+ var left = this.options.hierarchyIndent * (row.outlineLevel - 1);
1229
+ var valueLeft = document.all ? left + stateDivWidth : left;
1230
+ cellValueDiv.style.left = valueLeft + 'px';
1231
+ stateDiv.style.left = left + 'px';
1232
+ },
1233
+
1234
+ setFontWeight : function(row) {
1235
+ if (row) {
1236
+ if (!row.list) return;
1237
+ if (row.list.length > 0){
1238
+ row.style.fontWeight = 'bold';
1239
+ } else {
1240
+ row.style.fontWeight = 'normal';
1241
+ }
1242
+ }
1243
+ },
1244
+
1245
+ updateOutline : function(row) {
1246
+ var previousRow = row.previousSibling;
1247
+ var newParentRow = null;
1248
+ var insertIndex = 0;
1249
+ var newParentList = null;
1250
+
1251
+ if (!previousRow.list) return;
1252
+ if (!previousRow) {
1253
+ newParentList = this.topLevelList;
1254
+ }else if(previousRow.list.length > 0) {
1255
+ newParentRow = previousRow;
1256
+ newParentList = newParentRow.list;
1257
+ } else {
1258
+ newParentRow = this.getParentRow(previousRow);
1259
+ newParentList = newParentRow ? newParentRow.list : this.topLevelList;
1260
+ insertIndex = newParentList.indexOf(previousRow) + 1;
1261
+ }
1262
+ var parentRow = this.getParentRowByIndex(row, this.targetRowIndex);
1263
+ var parentList = null;
1264
+
1265
+ var outlineNumBase = '';
1266
+ if (parentRow) {
1267
+ parentList = parentRow.list;
1268
+ outlineNumBase = parentRow.outlineNum + '.';
1269
+ } else {
1270
+ parentList = this.topLevelList;
1271
+ if (!parentList) return;
1272
+ }
1273
+ var removeIndex = parentList.indexOf(row);
1274
+
1275
+ if (parentList == newParentList && removeIndex < insertIndex) {
1276
+ insertIndex -= 1;
1277
+ parentList.remove(removeIndex);
1278
+ parentList.insert(insertIndex, row);
1279
+ for (var i = removeIndex; i < parentList.length; i++) {
1280
+ try {
1281
+ parentList[i].outlineNum = outlineNumBase + (i + 1);
1282
+ this.setOutline(parentList[i]);
1283
+ } catch (e) {}
1284
+ }
1285
+
1286
+ } else {
1287
+ parentList.remove(removeIndex);
1288
+ newParentList.insert(insertIndex, row);
1289
+ for (var i = removeIndex; i < parentList.length; i++) {
1290
+ parentList[i].outlineNum = outlineNumBase + (i + 1);
1291
+ this.setOutline(parentList[i]);
1292
+ }
1293
+ var newOutlineNumBase = newParentRow ? newParentRow.outlineNum + '.' : '';
1294
+ var newOutlineLevelBase = newParentRow ? newParentRow.outlineLevel : 0;
1295
+ row.outlineNum = newOutlineNumBase + (insertIndex + 1);
1296
+ row.outlineLevel = newOutlineLevelBase + 1;
1297
+ for (var i = insertIndex; i < newParentList.length; i++) {
1298
+ newParentList[i].outlineNum = newOutlineNumBase + (i + 1);
1299
+ this.setOutline(newParentList[i]);
1300
+ }
1301
+ this.setOutline(row);
1302
+ }
1303
+ this.setFontWeight(row);
1304
+ this.setStateClass(row);
1305
+ if (parentRow) {
1306
+ this.setFontWeight(parentRow);
1307
+ this.setStateClass(parentRow);
1308
+ }
1309
+ if (newParentRow) {
1310
+ this.setFontWeight(newParentRow);
1311
+ this.setStateClass(newParentRow);
1312
+ }
1313
+ this.updateHierarchyRowLine(row);
1314
+ },
1315
+
1316
+ updateHierarchyRowLine : function(row, existingRow) {
1317
+ if (!row.list) return;
1318
+ var rowIndex = row.rowIndex;
1319
+ var cellBody = this.cellTable.tBodies[0];
1320
+ var idBody = this.idTable.tBodies[0];
1321
+ if (!existingRow) {
1322
+ existingRow = cellBody.rows[rowIndex + 1]
1323
+ }
1324
+
1325
+ for (var i = 0; i < row.list.length; i++) {
1326
+ if (!existingRow) {
1327
+ cellBody.appendChild(row.list[i]);
1328
+ idBody.appendChild(this.getIdRow(row.list[i]));
1329
+ } else {
1330
+ cellBody.insertBefore(row.list[i], existingRow);
1331
+ idBody.insertBefore(this.getIdRow(row.list[i]), this.getIdRow(existingRow));
1332
+ }
1333
+ this.updateHierarchyRowLine(row.list[i], existingRow);
1334
+ }
1335
+ },
1336
+
1337
+ getParentRow : function(row) {
1338
+ if (row.outlineLevel == 1) {
1339
+ return null;
1340
+ }
1341
+
1342
+ var previousRow = row.previousSibling;
1343
+ if (!previousRow) {
1344
+ return null;
1345
+ }
1346
+ try {
1347
+ while (previousRow.outlineLevel != (row.outlineLevel - 1)) {
1348
+ previousRow = previousRow.previousSibling;
1349
+ }
1350
+ return previousRow;
1351
+ } catch (e) {}
1352
+ },
1353
+
1354
+ getParentRowByIndex : function(row, index) {
1355
+ if (row.outlineLevel == 1) {
1356
+ return null;
1357
+ }
1358
+ if (this.targetRowIndex) {
1359
+ for(var i = 0; i < this.targetRowIndex + 1; i++) {
1360
+ if (!this.cellTable.rows[i].list) return;
1361
+ if (this.cellTable.rows[i].list.indexOf(row) != -1) {
1362
+ return this.cellTable.rows[i];
1363
+ }
1364
+ }
1365
+ }
1366
+ return null;
1367
+ },
1368
+
1369
+ getPreviousRootRow : function(row) {
1370
+ var previousRow = row.previousSibling;
1371
+ if (!previousRow) {
1372
+ return;
1373
+ }
1374
+ while (previousRow.outlineLevel != 1) {
1375
+ previousRow = previousRow.previousSibling;
1376
+ }
1377
+
1378
+ return previousRow;
1379
+ },
1380
+
1381
+ isParentRow : function(row, parentRow) {
1382
+ var temp = this.getParentRow(row);
1383
+ if (!temp) {
1384
+ return false;
1385
+ } else if (temp == parentRow) {
1386
+ return true;
1387
+ } else {
1388
+ return this.isParentRow(temp, parentRow);
1389
+ }
1390
+ }
1391
+ }