cable 0.1.0 → 0.8.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (528) hide show
  1. data/app/controllers/admin/cable_settings_controller.rb +20 -0
  2. data/app/controllers/{cable/admin_controller.rb → admin_controller.rb} +1 -2
  3. data/app/controllers/attachable_assets_controller.rb +81 -0
  4. data/app/controllers/attachable_documents_controller.rb +22 -0
  5. data/app/controllers/attachable_images_controller.rb +22 -0
  6. data/app/controllers/cable/cable_admin_controller.rb +8 -0
  7. data/app/helpers/admin/menus_helper.rb +24 -0
  8. data/app/helpers/admin_helper.rb +2 -2
  9. data/app/models/attachable_asset.rb +11 -0
  10. data/app/models/attachable_document.rb +2 -0
  11. data/app/models/attachable_image.rb +5 -0
  12. data/app/views/admin/_admin_user_login.html.erb +5 -0
  13. data/app/views/admin/cable_settings/_cable_setting.html.erb +4 -0
  14. data/app/views/admin/cable_settings/edit.html.erb +1 -0
  15. data/app/views/admin/cable_settings/index.html.erb +47 -0
  16. data/app/views/admin/index.html.erb +10 -0
  17. data/app/views/attachable_assets/index.html.erb +4 -0
  18. data/app/views/attachable_assets/new.html.erb +7 -0
  19. data/app/views/attachable_assets/show.html.erb +2 -0
  20. data/app/views/{cable/layouts → layouts}/_messages.html.erb +0 -0
  21. data/app/views/layouts/admin.html.erb +56 -0
  22. data/config/admin_navigation.rb +18 -0
  23. data/config/navigation.rb +0 -0
  24. data/config/routes.rb +5 -1
  25. data/lib/cable.rb +88 -1
  26. data/lib/cable/acts_as_cable.rb +36 -0
  27. data/lib/cable/base.rb +19 -0
  28. data/lib/cable/block.rb +46 -0
  29. data/lib/cable/capistrano.rb +12 -0
  30. data/lib/cable/controllers/cable_controller_helpers.rb +27 -0
  31. data/lib/cable/engine.rb +6 -1
  32. data/lib/cable/errors/resource_association_error.rb +4 -0
  33. data/lib/cable/media/acts_as_attachable.rb +44 -0
  34. data/lib/cable/media/asset.rb +3 -0
  35. data/lib/cable/menu.rb +3 -0
  36. data/lib/cable/menu/acts_as_cable_menu.rb +46 -0
  37. data/lib/cable/menu/base.rb +166 -0
  38. data/lib/cable/menu/simple_navigation_methods.rb +24 -0
  39. data/lib/cable/menu/url_helper.rb +17 -0
  40. data/lib/cable/orm/active_record.rb +29 -0
  41. data/lib/cable/page.rb +3 -0
  42. data/lib/cable/rails/routes.rb +49 -0
  43. data/lib/cable/railtie.rb +32 -0
  44. data/lib/cable/schema.rb +52 -0
  45. data/lib/cable/setting.rb +3 -0
  46. data/lib/cable/special_action.rb +19 -0
  47. data/lib/generators/cable/install_generator.rb +61 -21
  48. data/lib/generators/cable/media/media_generator.rb +41 -0
  49. data/lib/generators/cable/media/templates/migration.rb +19 -0
  50. data/lib/generators/cable/media/templates/model.rb +3 -0
  51. data/lib/generators/cable/menu/menu_generator.rb +83 -0
  52. data/lib/generators/cable/menu/templates/controller.rb +118 -0
  53. data/lib/generators/cable/menu/templates/erb/menus/_menu.html.erb +31 -0
  54. data/lib/generators/cable/menu/templates/erb/menus/_menu_children_table.html.erb +60 -0
  55. data/lib/generators/cable/menu/templates/erb/menus/_menu_tree.html.erb +10 -0
  56. data/lib/generators/cable/menu/templates/erb/menus/_menu_vitals.html.erb +30 -0
  57. data/lib/generators/cable/menu/templates/erb/menus/_resource.html.erb +29 -0
  58. data/lib/generators/cable/menu/templates/erb/menus/_resource_fields.html.erb +10 -0
  59. data/lib/generators/cable/menu/templates/erb/menus/_tree.html.erb +16 -0
  60. data/lib/generators/cable/menu/templates/erb/menus/edit.html.erb +1 -0
  61. data/lib/generators/cable/menu/templates/erb/menus/index.html.erb +28 -0
  62. data/lib/generators/cable/menu/templates/erb/menus/move.html.erb +41 -0
  63. data/lib/generators/cable/menu/templates/erb/menus/new.html.erb +1 -0
  64. data/lib/generators/cable/menu/templates/erb/menus/show.html.erb +16 -0
  65. data/lib/generators/cable/menu/templates/erb/menus/table.html.erb +9 -0
  66. data/lib/generators/cable/menu/templates/erb/partials/_menu_fields.html.erb +12 -0
  67. data/lib/generators/cable/menu/templates/migration.rb +24 -0
  68. data/lib/generators/cable/menu/templates/model.rb +4 -0
  69. data/lib/generators/cable/orm_helpers.rb +18 -0
  70. data/lib/generators/cable/override_generator.rb +33 -0
  71. data/lib/generators/cable/resource/resource_generator.rb +70 -0
  72. data/lib/generators/cable/resource/templates/controller.rb +52 -0
  73. data/lib/generators/cable/resource/templates/erb/scaffold/_form.html.erb +30 -0
  74. data/lib/generators/cable/resource/templates/erb/scaffold/edit.html.erb +6 -0
  75. data/lib/generators/cable/resource/templates/erb/scaffold/index.html.erb +54 -0
  76. data/lib/generators/cable/resource/templates/erb/scaffold/new.html.erb +5 -0
  77. data/lib/generators/cable/resource/templates/erb/scaffold/show.html.erb +12 -0
  78. data/lib/generators/cable/resource/templates/migration.rb +14 -0
  79. data/lib/generators/cable/resource/templates/model.rb +3 -0
  80. data/lib/generators/templates/block.rb +3 -0
  81. data/lib/generators/templates/create_blocks.rb +27 -0
  82. data/lib/generators/templates/create_cable_settings.rb +25 -0
  83. data/lib/generators/templates/initializer.rb +18 -0
  84. data/lib/generators/templates/partials/_block.html.erb +10 -0
  85. data/lib/generators/templates/partials/_block_form.html.erb +24 -0
  86. data/lib/railties/tasks.rake +6 -1
  87. data/public/images/cable/background.png +0 -0
  88. data/public/images/cable/delete.png +0 -0
  89. data/public/images/cable/event-icon.png +0 -0
  90. data/public/images/cable/new-window.png +0 -0
  91. data/public/images/cable/nil-icon.png +0 -0
  92. data/public/images/cable/page-icon.png +0 -0
  93. data/public/images/cable/product-icon.jpg +0 -0
  94. data/public/images/cable/story-icon.jpg +0 -0
  95. data/public/images/iphone-style-checkboxes/off.png +0 -0
  96. data/public/images/iphone-style-checkboxes/on.png +0 -0
  97. data/public/images/iphone-style-checkboxes/slider.png +0 -0
  98. data/public/images/iphone-style-checkboxes/slider_center.png +0 -0
  99. data/public/images/iphone-style-checkboxes/slider_left.png +0 -0
  100. data/public/images/iphone-style-checkboxes/slider_right.png +0 -0
  101. data/public/javascripts/admin.js +35 -0
  102. data/public/javascripts/iphone-style-checkboxes.js +224 -0
  103. data/public/javascripts/jquery.columnview.js +84 -0
  104. data/public/javascripts/jquery.tablesorter.min.js +4 -0
  105. data/public/javascripts/jquery.tagsinput.js +195 -0
  106. data/public/javascripts/jstree/_lib/jquery.cookie.js +96 -0
  107. data/public/javascripts/jstree/_lib/jquery.hotkeys.js +99 -0
  108. data/public/javascripts/jstree/_lib/jquery.js +6240 -0
  109. data/public/javascripts/jstree/jquery.jstree.js +4526 -0
  110. data/public/javascripts/jstree/themes/apple/bg.jpg +0 -0
  111. data/public/javascripts/jstree/themes/apple/d.png +0 -0
  112. data/public/javascripts/jstree/themes/apple/dot_for_ie.gif +0 -0
  113. data/public/javascripts/jstree/themes/apple/style.css +61 -0
  114. data/public/javascripts/jstree/themes/apple/throbber.gif +0 -0
  115. data/public/javascripts/jstree/themes/classic/d.png +0 -0
  116. data/public/javascripts/jstree/themes/classic/dot_for_ie.gif +0 -0
  117. data/public/javascripts/jstree/themes/classic/style.css +59 -0
  118. data/public/javascripts/jstree/themes/classic/throbber.gif +0 -0
  119. data/public/javascripts/jstree/themes/default-rtl/d.gif +0 -0
  120. data/public/javascripts/jstree/themes/default-rtl/d.png +0 -0
  121. data/public/javascripts/jstree/themes/default-rtl/dots.gif +0 -0
  122. data/public/javascripts/jstree/themes/default-rtl/style.css +83 -0
  123. data/public/javascripts/jstree/themes/default-rtl/throbber.gif +0 -0
  124. data/public/javascripts/jstree/themes/default/d.gif +0 -0
  125. data/public/javascripts/jstree/themes/default/d.png +0 -0
  126. data/public/javascripts/jstree/themes/default/style.css +73 -0
  127. data/public/javascripts/jstree/themes/default/throbber.gif +0 -0
  128. data/public/javascripts/tinymce/jquery.tinymce.js +1 -0
  129. data/public/javascripts/tinymce/langs/en.js +170 -0
  130. data/public/javascripts/tinymce/license.txt +504 -0
  131. data/public/javascripts/tinymce/plugins/advhr/css/advhr.css +5 -0
  132. data/public/javascripts/tinymce/plugins/advhr/editor_plugin.js +1 -0
  133. data/public/javascripts/tinymce/plugins/advhr/editor_plugin_src.js +57 -0
  134. data/public/javascripts/tinymce/plugins/advhr/js/rule.js +43 -0
  135. data/public/javascripts/tinymce/plugins/advhr/langs/en_dlg.js +5 -0
  136. data/public/javascripts/tinymce/plugins/advhr/rule.htm +57 -0
  137. data/public/javascripts/tinymce/plugins/advimage/css/advimage.css +13 -0
  138. data/public/javascripts/tinymce/plugins/advimage/editor_plugin.js +1 -0
  139. data/public/javascripts/tinymce/plugins/advimage/editor_plugin_src.js +50 -0
  140. data/public/javascripts/tinymce/plugins/advimage/image.htm +232 -0
  141. data/public/javascripts/tinymce/plugins/advimage/img/sample.gif +0 -0
  142. data/public/javascripts/tinymce/plugins/advimage/js/image.js +443 -0
  143. data/public/javascripts/tinymce/plugins/advimage/langs/en_dlg.js +43 -0
  144. data/public/javascripts/tinymce/plugins/advlink/css/advlink.css +8 -0
  145. data/public/javascripts/tinymce/plugins/advlink/editor_plugin.js +1 -0
  146. data/public/javascripts/tinymce/plugins/advlink/editor_plugin_src.js +61 -0
  147. data/public/javascripts/tinymce/plugins/advlink/js/advlink.js +528 -0
  148. data/public/javascripts/tinymce/plugins/advlink/langs/en_dlg.js +52 -0
  149. data/public/javascripts/tinymce/plugins/advlink/link.htm +333 -0
  150. data/public/javascripts/tinymce/plugins/advlist/editor_plugin.js +1 -0
  151. data/public/javascripts/tinymce/plugins/advlist/editor_plugin_src.js +154 -0
  152. data/public/javascripts/tinymce/plugins/autoresize/editor_plugin.js +1 -0
  153. data/public/javascripts/tinymce/plugins/autoresize/editor_plugin_src.js +119 -0
  154. data/public/javascripts/tinymce/plugins/autosave/editor_plugin.js +1 -0
  155. data/public/javascripts/tinymce/plugins/autosave/editor_plugin_src.js +422 -0
  156. data/public/javascripts/tinymce/plugins/autosave/langs/en.js +4 -0
  157. data/public/javascripts/tinymce/plugins/bbcode/editor_plugin.js +1 -0
  158. data/public/javascripts/tinymce/plugins/bbcode/editor_plugin_src.js +120 -0
  159. data/public/javascripts/tinymce/plugins/contextmenu/editor_plugin.js +1 -0
  160. data/public/javascripts/tinymce/plugins/contextmenu/editor_plugin_src.js +147 -0
  161. data/public/javascripts/tinymce/plugins/directionality/editor_plugin.js +1 -0
  162. data/public/javascripts/tinymce/plugins/directionality/editor_plugin_src.js +82 -0
  163. data/public/javascripts/tinymce/plugins/emotions/editor_plugin.js +1 -0
  164. data/public/javascripts/tinymce/plugins/emotions/editor_plugin_src.js +43 -0
  165. data/public/javascripts/tinymce/plugins/emotions/emotions.htm +40 -0
  166. data/public/javascripts/tinymce/plugins/emotions/img/smiley-cool.gif +0 -0
  167. data/public/javascripts/tinymce/plugins/emotions/img/smiley-cry.gif +0 -0
  168. data/public/javascripts/tinymce/plugins/emotions/img/smiley-embarassed.gif +0 -0
  169. data/public/javascripts/tinymce/plugins/emotions/img/smiley-foot-in-mouth.gif +0 -0
  170. data/public/javascripts/tinymce/plugins/emotions/img/smiley-frown.gif +0 -0
  171. data/public/javascripts/tinymce/plugins/emotions/img/smiley-innocent.gif +0 -0
  172. data/public/javascripts/tinymce/plugins/emotions/img/smiley-kiss.gif +0 -0
  173. data/public/javascripts/tinymce/plugins/emotions/img/smiley-laughing.gif +0 -0
  174. data/public/javascripts/tinymce/plugins/emotions/img/smiley-money-mouth.gif +0 -0
  175. data/public/javascripts/tinymce/plugins/emotions/img/smiley-sealed.gif +0 -0
  176. data/public/javascripts/tinymce/plugins/emotions/img/smiley-smile.gif +0 -0
  177. data/public/javascripts/tinymce/plugins/emotions/img/smiley-surprised.gif +0 -0
  178. data/public/javascripts/tinymce/plugins/emotions/img/smiley-tongue-out.gif +0 -0
  179. data/public/javascripts/tinymce/plugins/emotions/img/smiley-undecided.gif +0 -0
  180. data/public/javascripts/tinymce/plugins/emotions/img/smiley-wink.gif +0 -0
  181. data/public/javascripts/tinymce/plugins/emotions/img/smiley-yell.gif +0 -0
  182. data/public/javascripts/tinymce/plugins/emotions/js/emotions.js +22 -0
  183. data/public/javascripts/tinymce/plugins/emotions/langs/en_dlg.js +20 -0
  184. data/public/javascripts/tinymce/plugins/example/dialog.htm +22 -0
  185. data/public/javascripts/tinymce/plugins/example/editor_plugin.js +1 -0
  186. data/public/javascripts/tinymce/plugins/example/editor_plugin_src.js +84 -0
  187. data/public/javascripts/tinymce/plugins/example/img/example.gif +0 -0
  188. data/public/javascripts/tinymce/plugins/example/js/dialog.js +19 -0
  189. data/public/javascripts/tinymce/plugins/example/langs/en.js +3 -0
  190. data/public/javascripts/tinymce/plugins/example/langs/en_dlg.js +3 -0
  191. data/public/javascripts/tinymce/plugins/fullpage/css/fullpage.css +182 -0
  192. data/public/javascripts/tinymce/plugins/fullpage/editor_plugin.js +1 -0
  193. data/public/javascripts/tinymce/plugins/fullpage/editor_plugin_src.js +153 -0
  194. data/public/javascripts/tinymce/plugins/fullpage/fullpage.htm +571 -0
  195. data/public/javascripts/tinymce/plugins/fullpage/js/fullpage.js +471 -0
  196. data/public/javascripts/tinymce/plugins/fullpage/langs/en_dlg.js +85 -0
  197. data/public/javascripts/tinymce/plugins/fullscreen/editor_plugin.js +1 -0
  198. data/public/javascripts/tinymce/plugins/fullscreen/editor_plugin_src.js +151 -0
  199. data/public/javascripts/tinymce/plugins/fullscreen/fullscreen.htm +109 -0
  200. data/public/javascripts/tinymce/plugins/iespell/editor_plugin.js +1 -0
  201. data/public/javascripts/tinymce/plugins/iespell/editor_plugin_src.js +54 -0
  202. data/public/javascripts/tinymce/plugins/inlinepopups/editor_plugin.js +1 -0
  203. data/public/javascripts/tinymce/plugins/inlinepopups/editor_plugin_src.js +635 -0
  204. data/public/javascripts/tinymce/plugins/inlinepopups/skins/clearlooks2/img/alert.gif +0 -0
  205. data/public/javascripts/tinymce/plugins/inlinepopups/skins/clearlooks2/img/button.gif +0 -0
  206. data/public/javascripts/tinymce/plugins/inlinepopups/skins/clearlooks2/img/buttons.gif +0 -0
  207. data/public/javascripts/tinymce/plugins/inlinepopups/skins/clearlooks2/img/confirm.gif +0 -0
  208. data/public/javascripts/tinymce/plugins/inlinepopups/skins/clearlooks2/img/corners.gif +0 -0
  209. data/public/javascripts/tinymce/plugins/inlinepopups/skins/clearlooks2/img/horizontal.gif +0 -0
  210. data/public/javascripts/tinymce/plugins/inlinepopups/skins/clearlooks2/img/vertical.gif +0 -0
  211. data/public/javascripts/tinymce/plugins/inlinepopups/skins/clearlooks2/window.css +100 -0
  212. data/public/javascripts/tinymce/plugins/inlinepopups/template.htm +387 -0
  213. data/public/javascripts/tinymce/plugins/insertdatetime/editor_plugin.js +1 -0
  214. data/public/javascripts/tinymce/plugins/insertdatetime/editor_plugin_src.js +83 -0
  215. data/public/javascripts/tinymce/plugins/layer/editor_plugin.js +1 -0
  216. data/public/javascripts/tinymce/plugins/layer/editor_plugin_src.js +212 -0
  217. data/public/javascripts/tinymce/plugins/legacyoutput/editor_plugin.js +1 -0
  218. data/public/javascripts/tinymce/plugins/legacyoutput/editor_plugin_src.js +136 -0
  219. data/public/javascripts/tinymce/plugins/media/css/content.css +6 -0
  220. data/public/javascripts/tinymce/plugins/media/css/media.css +16 -0
  221. data/public/javascripts/tinymce/plugins/media/editor_plugin.js +1 -0
  222. data/public/javascripts/tinymce/plugins/media/editor_plugin_src.js +414 -0
  223. data/public/javascripts/tinymce/plugins/media/img/flash.gif +0 -0
  224. data/public/javascripts/tinymce/plugins/media/img/flv_player.swf +0 -0
  225. data/public/javascripts/tinymce/plugins/media/img/quicktime.gif +0 -0
  226. data/public/javascripts/tinymce/plugins/media/img/realmedia.gif +0 -0
  227. data/public/javascripts/tinymce/plugins/media/img/shockwave.gif +0 -0
  228. data/public/javascripts/tinymce/plugins/media/img/trans.gif +0 -0
  229. data/public/javascripts/tinymce/plugins/media/img/windowsmedia.gif +0 -0
  230. data/public/javascripts/tinymce/plugins/media/js/embed.js +73 -0
  231. data/public/javascripts/tinymce/plugins/media/js/media.js +630 -0
  232. data/public/javascripts/tinymce/plugins/media/langs/en_dlg.js +103 -0
  233. data/public/javascripts/tinymce/plugins/media/media.htm +817 -0
  234. data/public/javascripts/tinymce/plugins/nonbreaking/editor_plugin.js +1 -0
  235. data/public/javascripts/tinymce/plugins/nonbreaking/editor_plugin_src.js +53 -0
  236. data/public/javascripts/tinymce/plugins/noneditable/editor_plugin.js +1 -0
  237. data/public/javascripts/tinymce/plugins/noneditable/editor_plugin_src.js +90 -0
  238. data/public/javascripts/tinymce/plugins/pagebreak/css/content.css +1 -0
  239. data/public/javascripts/tinymce/plugins/pagebreak/editor_plugin.js +1 -0
  240. data/public/javascripts/tinymce/plugins/pagebreak/editor_plugin_src.js +77 -0
  241. data/public/javascripts/tinymce/plugins/pagebreak/img/pagebreak.gif +0 -0
  242. data/public/javascripts/tinymce/plugins/pagebreak/img/trans.gif +0 -0
  243. data/public/javascripts/tinymce/plugins/paste/editor_plugin.js +1 -0
  244. data/public/javascripts/tinymce/plugins/paste/editor_plugin_src.js +952 -0
  245. data/public/javascripts/tinymce/plugins/paste/js/pastetext.js +36 -0
  246. data/public/javascripts/tinymce/plugins/paste/js/pasteword.js +51 -0
  247. data/public/javascripts/tinymce/plugins/paste/langs/en_dlg.js +5 -0
  248. data/public/javascripts/tinymce/plugins/paste/pastetext.htm +27 -0
  249. data/public/javascripts/tinymce/plugins/paste/pasteword.htm +21 -0
  250. data/public/javascripts/tinymce/plugins/pdw/editor_plugin.js +4 -0
  251. data/public/javascripts/tinymce/plugins/pdw/editor_plugin_src.js +158 -0
  252. data/public/javascripts/tinymce/plugins/pdw/img/toolbars.gif +0 -0
  253. data/public/javascripts/tinymce/plugins/pdw/langs/en.js +3 -0
  254. data/public/javascripts/tinymce/plugins/pdw/langs/nl.js +3 -0
  255. data/public/javascripts/tinymce/plugins/preview/editor_plugin.js +1 -0
  256. data/public/javascripts/tinymce/plugins/preview/editor_plugin_src.js +53 -0
  257. data/public/javascripts/tinymce/plugins/preview/example.html +28 -0
  258. data/public/javascripts/tinymce/plugins/preview/jscripts/embed.js +73 -0
  259. data/public/javascripts/tinymce/plugins/preview/preview.html +17 -0
  260. data/public/javascripts/tinymce/plugins/print/editor_plugin.js +1 -0
  261. data/public/javascripts/tinymce/plugins/print/editor_plugin_src.js +34 -0
  262. data/public/javascripts/tinymce/plugins/save/editor_plugin.js +1 -0
  263. data/public/javascripts/tinymce/plugins/save/editor_plugin_src.js +101 -0
  264. data/public/javascripts/tinymce/plugins/searchreplace/css/searchreplace.css +6 -0
  265. data/public/javascripts/tinymce/plugins/searchreplace/editor_plugin.js +1 -0
  266. data/public/javascripts/tinymce/plugins/searchreplace/editor_plugin_src.js +57 -0
  267. data/public/javascripts/tinymce/plugins/searchreplace/js/searchreplace.js +138 -0
  268. data/public/javascripts/tinymce/plugins/searchreplace/langs/en_dlg.js +16 -0
  269. data/public/javascripts/tinymce/plugins/searchreplace/searchreplace.htm +99 -0
  270. data/public/javascripts/tinymce/plugins/spellchecker/css/content.css +1 -0
  271. data/public/javascripts/tinymce/plugins/spellchecker/editor_plugin.js +1 -0
  272. data/public/javascripts/tinymce/plugins/spellchecker/editor_plugin_src.js +417 -0
  273. data/public/javascripts/tinymce/plugins/spellchecker/img/wline.gif +0 -0
  274. data/public/javascripts/tinymce/plugins/style/css/props.css +13 -0
  275. data/public/javascripts/tinymce/plugins/style/editor_plugin.js +1 -0
  276. data/public/javascripts/tinymce/plugins/style/editor_plugin_src.js +55 -0
  277. data/public/javascripts/tinymce/plugins/style/js/props.js +641 -0
  278. data/public/javascripts/tinymce/plugins/style/langs/en_dlg.js +63 -0
  279. data/public/javascripts/tinymce/plugins/style/props.htm +723 -0
  280. data/public/javascripts/tinymce/plugins/tabfocus/editor_plugin.js +1 -0
  281. data/public/javascripts/tinymce/plugins/tabfocus/editor_plugin_src.js +112 -0
  282. data/public/javascripts/tinymce/plugins/table/cell.htm +178 -0
  283. data/public/javascripts/tinymce/plugins/table/css/cell.css +17 -0
  284. data/public/javascripts/tinymce/plugins/table/css/row.css +25 -0
  285. data/public/javascripts/tinymce/plugins/table/css/table.css +13 -0
  286. data/public/javascripts/tinymce/plugins/table/editor_plugin.js +1 -0
  287. data/public/javascripts/tinymce/plugins/table/editor_plugin_src.js +1139 -0
  288. data/public/javascripts/tinymce/plugins/table/js/cell.js +286 -0
  289. data/public/javascripts/tinymce/plugins/table/js/merge_cells.js +27 -0
  290. data/public/javascripts/tinymce/plugins/table/js/row.js +237 -0
  291. data/public/javascripts/tinymce/plugins/table/js/table.js +454 -0
  292. data/public/javascripts/tinymce/plugins/table/langs/en_dlg.js +74 -0
  293. data/public/javascripts/tinymce/plugins/table/merge_cells.htm +32 -0
  294. data/public/javascripts/tinymce/plugins/table/row.htm +155 -0
  295. data/public/javascripts/tinymce/plugins/table/table.htm +187 -0
  296. data/public/javascripts/tinymce/plugins/template/blank.htm +12 -0
  297. data/public/javascripts/tinymce/plugins/template/css/template.css +23 -0
  298. data/public/javascripts/tinymce/plugins/template/editor_plugin.js +1 -0
  299. data/public/javascripts/tinymce/plugins/template/editor_plugin_src.js +159 -0
  300. data/public/javascripts/tinymce/plugins/template/js/template.js +106 -0
  301. data/public/javascripts/tinymce/plugins/template/langs/en_dlg.js +15 -0
  302. data/public/javascripts/tinymce/plugins/template/template.htm +31 -0
  303. data/public/javascripts/tinymce/plugins/visualchars/editor_plugin.js +1 -0
  304. data/public/javascripts/tinymce/plugins/visualchars/editor_plugin_src.js +83 -0
  305. data/public/javascripts/tinymce/plugins/wordcount/editor_plugin.js +1 -0
  306. data/public/javascripts/tinymce/plugins/wordcount/editor_plugin_src.js +98 -0
  307. data/public/javascripts/tinymce/plugins/xhtmlxtras/abbr.htm +141 -0
  308. data/public/javascripts/tinymce/plugins/xhtmlxtras/acronym.htm +141 -0
  309. data/public/javascripts/tinymce/plugins/xhtmlxtras/attributes.htm +148 -0
  310. data/public/javascripts/tinymce/plugins/xhtmlxtras/cite.htm +141 -0
  311. data/public/javascripts/tinymce/plugins/xhtmlxtras/css/attributes.css +11 -0
  312. data/public/javascripts/tinymce/plugins/xhtmlxtras/css/popup.css +9 -0
  313. data/public/javascripts/tinymce/plugins/xhtmlxtras/del.htm +161 -0
  314. data/public/javascripts/tinymce/plugins/xhtmlxtras/editor_plugin.js +1 -0
  315. data/public/javascripts/tinymce/plugins/xhtmlxtras/editor_plugin_src.js +132 -0
  316. data/public/javascripts/tinymce/plugins/xhtmlxtras/ins.htm +161 -0
  317. data/public/javascripts/tinymce/plugins/xhtmlxtras/js/abbr.js +28 -0
  318. data/public/javascripts/tinymce/plugins/xhtmlxtras/js/acronym.js +28 -0
  319. data/public/javascripts/tinymce/plugins/xhtmlxtras/js/attributes.js +126 -0
  320. data/public/javascripts/tinymce/plugins/xhtmlxtras/js/cite.js +28 -0
  321. data/public/javascripts/tinymce/plugins/xhtmlxtras/js/del.js +53 -0
  322. data/public/javascripts/tinymce/plugins/xhtmlxtras/js/element_common.js +231 -0
  323. data/public/javascripts/tinymce/plugins/xhtmlxtras/js/ins.js +52 -0
  324. data/public/javascripts/tinymce/plugins/xhtmlxtras/langs/en_dlg.js +32 -0
  325. data/public/javascripts/tinymce/themes/advanced/about.htm +54 -0
  326. data/public/javascripts/tinymce/themes/advanced/anchor.htm +26 -0
  327. data/public/javascripts/tinymce/themes/advanced/charmap.htm +52 -0
  328. data/public/javascripts/tinymce/themes/advanced/color_picker.htm +73 -0
  329. data/public/javascripts/tinymce/themes/advanced/editor_template.js +1 -0
  330. data/public/javascripts/tinymce/themes/advanced/editor_template_src.js +1229 -0
  331. data/public/javascripts/tinymce/themes/advanced/image.htm +80 -0
  332. data/public/javascripts/tinymce/themes/advanced/img/colorpicker.jpg +0 -0
  333. data/public/javascripts/tinymce/themes/advanced/img/icons.gif +0 -0
  334. data/public/javascripts/tinymce/themes/advanced/js/about.js +72 -0
  335. data/public/javascripts/tinymce/themes/advanced/js/anchor.js +37 -0
  336. data/public/javascripts/tinymce/themes/advanced/js/charmap.js +335 -0
  337. data/public/javascripts/tinymce/themes/advanced/js/color_picker.js +253 -0
  338. data/public/javascripts/tinymce/themes/advanced/js/image.js +245 -0
  339. data/public/javascripts/tinymce/themes/advanced/js/link.js +156 -0
  340. data/public/javascripts/tinymce/themes/advanced/js/source_editor.js +56 -0
  341. data/public/javascripts/tinymce/themes/advanced/langs/en.js +62 -0
  342. data/public/javascripts/tinymce/themes/advanced/langs/en_dlg.js +51 -0
  343. data/public/javascripts/tinymce/themes/advanced/link.htm +58 -0
  344. data/public/javascripts/tinymce/themes/advanced/skins/default/content.css +36 -0
  345. data/public/javascripts/tinymce/themes/advanced/skins/default/dialog.css +117 -0
  346. data/public/javascripts/tinymce/themes/advanced/skins/default/img/buttons.png +0 -0
  347. data/public/javascripts/tinymce/themes/advanced/skins/default/img/items.gif +0 -0
  348. data/public/javascripts/tinymce/themes/advanced/skins/default/img/menu_arrow.gif +0 -0
  349. data/public/javascripts/tinymce/themes/advanced/skins/default/img/menu_check.gif +0 -0
  350. data/public/javascripts/tinymce/themes/advanced/skins/default/img/progress.gif +0 -0
  351. data/public/javascripts/tinymce/themes/advanced/skins/default/img/tabs.gif +0 -0
  352. data/public/javascripts/tinymce/themes/advanced/skins/default/ui.css +213 -0
  353. data/public/javascripts/tinymce/themes/advanced/skins/o2k7/content.css +36 -0
  354. data/public/javascripts/tinymce/themes/advanced/skins/o2k7/dialog.css +116 -0
  355. data/public/javascripts/tinymce/themes/advanced/skins/o2k7/img/button_bg.png +0 -0
  356. data/public/javascripts/tinymce/themes/advanced/skins/o2k7/img/button_bg_black.png +0 -0
  357. data/public/javascripts/tinymce/themes/advanced/skins/o2k7/img/button_bg_silver.png +0 -0
  358. data/public/javascripts/tinymce/themes/advanced/skins/o2k7/ui.css +215 -0
  359. data/public/javascripts/tinymce/themes/advanced/skins/o2k7/ui_black.css +8 -0
  360. data/public/javascripts/tinymce/themes/advanced/skins/o2k7/ui_silver.css +5 -0
  361. data/public/javascripts/tinymce/themes/advanced/source_editor.htm +25 -0
  362. data/public/javascripts/tinymce/themes/simple/editor_template.js +1 -0
  363. data/public/javascripts/tinymce/themes/simple/editor_template_src.js +85 -0
  364. data/public/javascripts/tinymce/themes/simple/img/icons.gif +0 -0
  365. data/public/javascripts/tinymce/themes/simple/langs/en.js +11 -0
  366. data/public/javascripts/tinymce/themes/simple/skins/default/content.css +25 -0
  367. data/public/javascripts/tinymce/themes/simple/skins/default/ui.css +32 -0
  368. data/public/javascripts/tinymce/themes/simple/skins/o2k7/content.css +17 -0
  369. data/public/javascripts/tinymce/themes/simple/skins/o2k7/img/button_bg.png +0 -0
  370. data/public/javascripts/tinymce/themes/simple/skins/o2k7/ui.css +35 -0
  371. data/public/javascripts/tinymce/tiny_mce.js +1 -0
  372. data/public/javascripts/tinymce/tiny_mce_popup.js +5 -0
  373. data/public/javascripts/tinymce/tiny_mce_src.js +13394 -0
  374. data/public/javascripts/tinymce/utils/editable_selects.js +70 -0
  375. data/public/javascripts/tinymce/utils/form_utils.js +200 -0
  376. data/public/javascripts/tinymce/utils/mctabs.js +77 -0
  377. data/public/javascripts/tinymce/utils/validate.js +220 -0
  378. data/public/stylesheets/cable.css +862 -0
  379. data/{lib/generators/cable/templates/stylesheets/admin → public/stylesheets/cable}/blueprint/ie.css +0 -0
  380. data/{lib/generators/cable/templates/stylesheets/admin → public/stylesheets/cable}/blueprint/plugins/buttons/icons/cross.png +0 -0
  381. data/{lib/generators/cable/templates/stylesheets/admin → public/stylesheets/cable}/blueprint/plugins/buttons/icons/key.png +0 -0
  382. data/{lib/generators/cable/templates/stylesheets/admin → public/stylesheets/cable}/blueprint/plugins/buttons/icons/tick.png +0 -0
  383. data/{lib/generators/cable/templates/stylesheets/admin → public/stylesheets/cable}/blueprint/plugins/buttons/readme.txt +0 -0
  384. data/{lib/generators/cable/templates/stylesheets/admin → public/stylesheets/cable}/blueprint/plugins/buttons/screen.css +0 -0
  385. data/{lib/generators/cable/templates/stylesheets/admin → public/stylesheets/cable}/blueprint/plugins/fancy-type/readme.txt +0 -0
  386. data/{lib/generators/cable/templates/stylesheets/admin → public/stylesheets/cable}/blueprint/plugins/fancy-type/screen.css +0 -0
  387. data/{lib/generators/cable/templates/stylesheets/admin → public/stylesheets/cable}/blueprint/plugins/link-icons/icons/doc.png +0 -0
  388. data/{lib/generators/cable/templates/stylesheets/admin → public/stylesheets/cable}/blueprint/plugins/link-icons/icons/email.png +0 -0
  389. data/{lib/generators/cable/templates/stylesheets/admin → public/stylesheets/cable}/blueprint/plugins/link-icons/icons/external.png +0 -0
  390. data/{lib/generators/cable/templates/stylesheets/admin → public/stylesheets/cable}/blueprint/plugins/link-icons/icons/feed.png +0 -0
  391. data/{lib/generators/cable/templates/stylesheets/admin → public/stylesheets/cable}/blueprint/plugins/link-icons/icons/im.png +0 -0
  392. data/{lib/generators/cable/templates/stylesheets/admin → public/stylesheets/cable}/blueprint/plugins/link-icons/icons/pdf.png +0 -0
  393. data/{lib/generators/cable/templates/stylesheets/admin → public/stylesheets/cable}/blueprint/plugins/link-icons/icons/visited.png +0 -0
  394. data/{lib/generators/cable/templates/stylesheets/admin → public/stylesheets/cable}/blueprint/plugins/link-icons/icons/xls.png +0 -0
  395. data/{lib/generators/cable/templates/stylesheets/admin → public/stylesheets/cable}/blueprint/plugins/link-icons/readme.txt +0 -0
  396. data/{lib/generators/cable/templates/stylesheets/admin → public/stylesheets/cable}/blueprint/plugins/link-icons/screen.css +0 -0
  397. data/{lib/generators/cable/templates/stylesheets/admin → public/stylesheets/cable}/blueprint/plugins/rtl/readme.txt +0 -0
  398. data/{lib/generators/cable/templates/stylesheets/admin → public/stylesheets/cable}/blueprint/plugins/rtl/screen.css +0 -0
  399. data/{lib/generators/cable/templates/stylesheets/admin → public/stylesheets/cable}/blueprint/print.css +0 -0
  400. data/{lib/generators/cable/templates/stylesheets/admin → public/stylesheets/cable}/blueprint/screen.css +0 -0
  401. data/{lib/generators/cable/templates/stylesheets/admin → public/stylesheets/cable}/blueprint/src/forms.css +0 -0
  402. data/{lib/generators/cable/templates/stylesheets/admin → public/stylesheets/cable}/blueprint/src/grid.css +0 -0
  403. data/{lib/generators/cable/templates/stylesheets/admin → public/stylesheets/cable}/blueprint/src/grid.png +0 -0
  404. data/{lib/generators/cable/templates/stylesheets/admin → public/stylesheets/cable}/blueprint/src/ie.css +0 -0
  405. data/{lib/generators/cable/templates/stylesheets/admin → public/stylesheets/cable}/blueprint/src/print.css +0 -0
  406. data/{lib/generators/cable/templates/stylesheets/admin → public/stylesheets/cable}/blueprint/src/reset.css +0 -0
  407. data/{lib/generators/cable/templates/stylesheets/admin → public/stylesheets/cable}/blueprint/src/typography.css +0 -0
  408. data/public/stylesheets/columnview.css +61 -0
  409. data/public/stylesheets/formtastic.css +148 -0
  410. data/public/stylesheets/formtastic_changes.css +66 -0
  411. data/public/stylesheets/iphone_checkboxes.css +76 -0
  412. data/public/stylesheets/ui/aristo/aristo.css +524 -0
  413. data/public/stylesheets/ui/aristo/icons.psd +0 -0
  414. data/public/stylesheets/ui/aristo/images/button_bg.png +0 -0
  415. data/public/stylesheets/ui/aristo/images/datepicker.gif +0 -0
  416. data/public/stylesheets/ui/aristo/images/icon_sprite.png +0 -0
  417. data/public/stylesheets/ui/aristo/images/progress_bar.gif +0 -0
  418. data/public/stylesheets/ui/aristo/images/right-arrow.png +0 -0
  419. data/public/stylesheets/ui/aristo/images/slider_h_bg.gif +0 -0
  420. data/public/stylesheets/ui/aristo/images/slider_handles.png +0 -0
  421. data/public/stylesheets/ui/aristo/images/slider_v_bg.gif +0 -0
  422. data/public/stylesheets/ui/aristo/images/tab_bg.gif +0 -0
  423. data/public/stylesheets/ui/aristo/images/the_gradient.gif +0 -0
  424. data/public/stylesheets/ui/aristo/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
  425. data/public/stylesheets/ui/aristo/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
  426. data/public/stylesheets/ui/aristo/images/ui-bg_flat_10_000000_40x100.png +0 -0
  427. data/public/stylesheets/ui/aristo/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
  428. data/public/stylesheets/ui/aristo/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
  429. data/public/stylesheets/ui/aristo/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  430. data/public/stylesheets/ui/aristo/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
  431. data/public/stylesheets/ui/aristo/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
  432. data/public/stylesheets/ui/aristo/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
  433. data/public/stylesheets/ui/aristo/images/ui-icons_222222_256x240.png +0 -0
  434. data/public/stylesheets/ui/aristo/images/ui-icons_228ef1_256x240.png +0 -0
  435. data/public/stylesheets/ui/aristo/images/ui-icons_ef8c08_256x240.png +0 -0
  436. data/public/stylesheets/ui/aristo/images/ui-icons_ffd27a_256x240.png +0 -0
  437. data/public/stylesheets/ui/aristo/images/ui-icons_ffffff_256x240.png +0 -0
  438. data/public/stylesheets/ui/images/sprite-aristo.png +0 -0
  439. data/public/stylesheets/ui/images/uniform/sprite.png +0 -0
  440. data/public/stylesheets/ui/uniform/uniform.aristo.css +470 -0
  441. data/public/stylesheets/ui/uniform/uniform.default.css +477 -0
  442. metadata +473 -131
  443. data/app/models/cable/global_setting.rb +0 -3
  444. data/app/views/cable/admin/index.html.erb +0 -2
  445. data/app/views/cable/layouts/admin.html.erb +0 -49
  446. data/lib/generators/cable/controllers_generator.rb +0 -21
  447. data/lib/generators/cable/templates/admin_navigation.rb +0 -5
  448. data/lib/generators/cable/templates/javascripts/admin.js +0 -24
  449. data/lib/generators/cable/templates/javascripts/wymeditor/GPL-license.txt +0 -278
  450. data/lib/generators/cable/templates/javascripts/wymeditor/MIT-license.txt +0 -20
  451. data/lib/generators/cable/templates/javascripts/wymeditor/README +0 -33
  452. data/lib/generators/cable/templates/javascripts/wymeditor/iframe/default/lbl-blockquote.png +0 -0
  453. data/lib/generators/cable/templates/javascripts/wymeditor/iframe/default/lbl-h1.png +0 -0
  454. data/lib/generators/cable/templates/javascripts/wymeditor/iframe/default/lbl-h2.png +0 -0
  455. data/lib/generators/cable/templates/javascripts/wymeditor/iframe/default/lbl-h3.png +0 -0
  456. data/lib/generators/cable/templates/javascripts/wymeditor/iframe/default/lbl-h4.png +0 -0
  457. data/lib/generators/cable/templates/javascripts/wymeditor/iframe/default/lbl-h5.png +0 -0
  458. data/lib/generators/cable/templates/javascripts/wymeditor/iframe/default/lbl-h6.png +0 -0
  459. data/lib/generators/cable/templates/javascripts/wymeditor/iframe/default/lbl-p.png +0 -0
  460. data/lib/generators/cable/templates/javascripts/wymeditor/iframe/default/lbl-pre.png +0 -0
  461. data/lib/generators/cable/templates/javascripts/wymeditor/iframe/default/wymiframe.css +0 -93
  462. data/lib/generators/cable/templates/javascripts/wymeditor/iframe/default/wymiframe.html +0 -26
  463. data/lib/generators/cable/templates/javascripts/wymeditor/jquery.wymeditor.js +0 -4724
  464. data/lib/generators/cable/templates/javascripts/wymeditor/jquery.wymeditor.min.js +0 -1
  465. data/lib/generators/cable/templates/javascripts/wymeditor/jquery.wymeditor.pack.js +0 -1
  466. data/lib/generators/cable/templates/javascripts/wymeditor/lang/bg.js +0 -45
  467. data/lib/generators/cable/templates/javascripts/wymeditor/lang/ca.js +0 -45
  468. data/lib/generators/cable/templates/javascripts/wymeditor/lang/cs.js +0 -45
  469. data/lib/generators/cable/templates/javascripts/wymeditor/lang/cy.js +0 -45
  470. data/lib/generators/cable/templates/javascripts/wymeditor/lang/de.js +0 -45
  471. data/lib/generators/cable/templates/javascripts/wymeditor/lang/en.js +0 -46
  472. data/lib/generators/cable/templates/javascripts/wymeditor/lang/es.js +0 -45
  473. data/lib/generators/cable/templates/javascripts/wymeditor/lang/fa.js +0 -46
  474. data/lib/generators/cable/templates/javascripts/wymeditor/lang/fi.js +0 -44
  475. data/lib/generators/cable/templates/javascripts/wymeditor/lang/fr.js +0 -45
  476. data/lib/generators/cable/templates/javascripts/wymeditor/lang/gl.js +0 -45
  477. data/lib/generators/cable/templates/javascripts/wymeditor/lang/he.js +0 -45
  478. data/lib/generators/cable/templates/javascripts/wymeditor/lang/hr.js +0 -45
  479. data/lib/generators/cable/templates/javascripts/wymeditor/lang/hu.js +0 -45
  480. data/lib/generators/cable/templates/javascripts/wymeditor/lang/it.js +0 -45
  481. data/lib/generators/cable/templates/javascripts/wymeditor/lang/ja.js +0 -44
  482. data/lib/generators/cable/templates/javascripts/wymeditor/lang/nb.js +0 -45
  483. data/lib/generators/cable/templates/javascripts/wymeditor/lang/nl.js +0 -45
  484. data/lib/generators/cable/templates/javascripts/wymeditor/lang/nn.js +0 -45
  485. data/lib/generators/cable/templates/javascripts/wymeditor/lang/pl.js +0 -45
  486. data/lib/generators/cable/templates/javascripts/wymeditor/lang/pt-br.js +0 -45
  487. data/lib/generators/cable/templates/javascripts/wymeditor/lang/pt.js +0 -45
  488. data/lib/generators/cable/templates/javascripts/wymeditor/lang/ru.js +0 -45
  489. data/lib/generators/cable/templates/javascripts/wymeditor/lang/sv.js +0 -46
  490. data/lib/generators/cable/templates/javascripts/wymeditor/lang/tr.js +0 -45
  491. data/lib/generators/cable/templates/javascripts/wymeditor/lang/zh_cn.js +0 -47
  492. data/lib/generators/cable/templates/javascripts/wymeditor/plugins/embed/jquery.wymeditor.embed.js +0 -52
  493. data/lib/generators/cable/templates/javascripts/wymeditor/plugins/fullscreen/icon_fullscreen.gif +0 -0
  494. data/lib/generators/cable/templates/javascripts/wymeditor/plugins/fullscreen/jquery.wymeditor.fullscreen.js +0 -127
  495. data/lib/generators/cable/templates/javascripts/wymeditor/plugins/hovertools/jquery.wymeditor.hovertools.js +0 -57
  496. data/lib/generators/cable/templates/javascripts/wymeditor/plugins/mediabrowser/browser.png +0 -0
  497. data/lib/generators/cable/templates/javascripts/wymeditor/plugins/mediabrowser/jquery.wymeditor.mediabrowser.js +0 -115
  498. data/lib/generators/cable/templates/javascripts/wymeditor/plugins/resizable/jquery.wymeditor.resizable.js +0 -91
  499. data/lib/generators/cable/templates/javascripts/wymeditor/plugins/resizable/readme.txt +0 -124
  500. data/lib/generators/cable/templates/javascripts/wymeditor/plugins/tidy/README +0 -19
  501. data/lib/generators/cable/templates/javascripts/wymeditor/plugins/tidy/jquery.wymeditor.tidy.js +0 -82
  502. data/lib/generators/cable/templates/javascripts/wymeditor/plugins/tidy/tidy.php +0 -36
  503. data/lib/generators/cable/templates/javascripts/wymeditor/plugins/tidy/wand.png +0 -0
  504. data/lib/generators/cable/templates/javascripts/wymeditor/skins/compact/icons.png +0 -0
  505. data/lib/generators/cable/templates/javascripts/wymeditor/skins/compact/skin.css +0 -134
  506. data/lib/generators/cable/templates/javascripts/wymeditor/skins/compact/skin.js +0 -35
  507. data/lib/generators/cable/templates/javascripts/wymeditor/skins/default/icons.png +0 -0
  508. data/lib/generators/cable/templates/javascripts/wymeditor/skins/default/skin.css +0 -158
  509. data/lib/generators/cable/templates/javascripts/wymeditor/skins/default/skin.js +0 -40
  510. data/lib/generators/cable/templates/javascripts/wymeditor/skins/minimal/images/bg.header.gif +0 -0
  511. data/lib/generators/cable/templates/javascripts/wymeditor/skins/minimal/images/bg.selector.silver.gif +0 -0
  512. data/lib/generators/cable/templates/javascripts/wymeditor/skins/minimal/images/bg.wymeditor.png +0 -0
  513. data/lib/generators/cable/templates/javascripts/wymeditor/skins/minimal/images/icons.silver.gif +0 -0
  514. data/lib/generators/cable/templates/javascripts/wymeditor/skins/minimal/skin.css +0 -131
  515. data/lib/generators/cable/templates/javascripts/wymeditor/skins/minimal/skin.js +0 -30
  516. data/lib/generators/cable/templates/javascripts/wymeditor/skins/silver/COPYING +0 -674
  517. data/lib/generators/cable/templates/javascripts/wymeditor/skins/silver/README +0 -27
  518. data/lib/generators/cable/templates/javascripts/wymeditor/skins/silver/images/bg.header.gif +0 -0
  519. data/lib/generators/cable/templates/javascripts/wymeditor/skins/silver/images/bg.selector.silver.gif +0 -0
  520. data/lib/generators/cable/templates/javascripts/wymeditor/skins/silver/images/bg.wymeditor.png +0 -0
  521. data/lib/generators/cable/templates/javascripts/wymeditor/skins/silver/images/icons.silver.gif +0 -0
  522. data/lib/generators/cable/templates/javascripts/wymeditor/skins/silver/skin.css +0 -297
  523. data/lib/generators/cable/templates/javascripts/wymeditor/skins/silver/skin.js +0 -61
  524. data/lib/generators/cable/templates/javascripts/wymeditor/skins/twopanels/icons.png +0 -0
  525. data/lib/generators/cable/templates/javascripts/wymeditor/skins/twopanels/skin.css +0 -134
  526. data/lib/generators/cable/templates/javascripts/wymeditor/skins/twopanels/skin.js +0 -39
  527. data/lib/generators/cable/templates/javascripts/wymeditor/skins/wymeditor_icon.png +0 -0
  528. data/lib/generators/cable/templates/stylesheets/admin.css +0 -417
@@ -0,0 +1,4526 @@
1
+ /*
2
+ * jsTree 1.0-rc3
3
+ * http://jstree.com/
4
+ *
5
+ * Copyright (c) 2010 Ivan Bozhanov (vakata.com)
6
+ *
7
+ * Licensed same as jquery - under the terms of either the MIT License or the GPL Version 2 License
8
+ * http://www.opensource.org/licenses/mit-license.php
9
+ * http://www.gnu.org/licenses/gpl.html
10
+ *
11
+ * $Date$
12
+ * $Revision$
13
+ */
14
+
15
+ /*jslint browser: true, onevar: true, undef: true, bitwise: true, strict: true */
16
+ /*global window : false, clearInterval: false, clearTimeout: false, document: false, setInterval: false, setTimeout: false, jQuery: false, navigator: false, XSLTProcessor: false, DOMParser: false, XMLSerializer: false*/
17
+
18
+ "use strict";
19
+
20
+ // top wrapper to prevent multiple inclusion (is this OK?)
21
+ (function () { if(jQuery && jQuery.jstree) { return; }
22
+ var is_ie6 = false, is_ie7 = false, is_ff2 = false;
23
+
24
+ /*
25
+ * jsTree core
26
+ */
27
+ (function ($) {
28
+ // Common functions not related to jsTree
29
+ // decided to move them to a `vakata` "namespace"
30
+ $.vakata = {};
31
+ // CSS related functions
32
+ $.vakata.css = {
33
+ get_css : function(rule_name, delete_flag, sheet) {
34
+ rule_name = rule_name.toLowerCase();
35
+ var css_rules = sheet.cssRules || sheet.rules,
36
+ j = 0;
37
+ do {
38
+ if(css_rules.length && j > css_rules.length + 5) { return false; }
39
+ if(css_rules[j].selectorText && css_rules[j].selectorText.toLowerCase() == rule_name) {
40
+ if(delete_flag === true) {
41
+ if(sheet.removeRule) { sheet.removeRule(j); }
42
+ if(sheet.deleteRule) { sheet.deleteRule(j); }
43
+ return true;
44
+ }
45
+ else { return css_rules[j]; }
46
+ }
47
+ }
48
+ while (css_rules[++j]);
49
+ return false;
50
+ },
51
+ add_css : function(rule_name, sheet) {
52
+ if($.jstree.css.get_css(rule_name, false, sheet)) { return false; }
53
+ if(sheet.insertRule) { sheet.insertRule(rule_name + ' { }', 0); } else { sheet.addRule(rule_name, null, 0); }
54
+ return $.vakata.css.get_css(rule_name);
55
+ },
56
+ remove_css : function(rule_name, sheet) {
57
+ return $.vakata.css.get_css(rule_name, true, sheet);
58
+ },
59
+ add_sheet : function(opts) {
60
+ var tmp = false, is_new = true;
61
+ if(opts.str) {
62
+ if(opts.title) { tmp = $("style[id='" + opts.title + "-stylesheet']")[0]; }
63
+ if(tmp) { is_new = false; }
64
+ else {
65
+ tmp = document.createElement("style");
66
+ tmp.setAttribute('type',"text/css");
67
+ if(opts.title) { tmp.setAttribute("id", opts.title + "-stylesheet"); }
68
+ }
69
+ if(tmp.styleSheet) {
70
+ if(is_new) {
71
+ document.getElementsByTagName("head")[0].appendChild(tmp);
72
+ tmp.styleSheet.cssText = opts.str;
73
+ }
74
+ else {
75
+ tmp.styleSheet.cssText = tmp.styleSheet.cssText + " " + opts.str;
76
+ }
77
+ }
78
+ else {
79
+ tmp.appendChild(document.createTextNode(opts.str));
80
+ document.getElementsByTagName("head")[0].appendChild(tmp);
81
+ }
82
+ return tmp.sheet || tmp.styleSheet;
83
+ }
84
+ if(opts.url) {
85
+ if(document.createStyleSheet) {
86
+ try { tmp = document.createStyleSheet(opts.url); } catch (e) { }
87
+ }
88
+ else {
89
+ tmp = document.createElement('link');
90
+ tmp.rel = 'stylesheet';
91
+ tmp.type = 'text/css';
92
+ tmp.media = "all";
93
+ tmp.href = opts.url;
94
+ document.getElementsByTagName("head")[0].appendChild(tmp);
95
+ return tmp.styleSheet;
96
+ }
97
+ }
98
+ }
99
+ };
100
+
101
+ // private variables
102
+ var instances = [], // instance array (used by $.jstree.reference/create/focused)
103
+ focused_instance = -1, // the index in the instance array of the currently focused instance
104
+ plugins = {}, // list of included plugins
105
+ prepared_move = {}; // for the move_node function
106
+
107
+ // jQuery plugin wrapper (thanks to jquery UI widget function)
108
+ $.fn.jstree = function (settings) {
109
+ var isMethodCall = (typeof settings == 'string'), // is this a method call like $().jstree("open_node")
110
+ args = Array.prototype.slice.call(arguments, 1),
111
+ returnValue = this;
112
+
113
+ // if a method call execute the method on all selected instances
114
+ if(isMethodCall) {
115
+ if(settings.substring(0, 1) == '_') { return returnValue; }
116
+ this.each(function() {
117
+ var instance = instances[$.data(this, "jstree-instance-id")],
118
+ methodValue = (instance && $.isFunction(instance[settings])) ? instance[settings].apply(instance, args) : instance;
119
+ if(typeof methodValue !== "undefined" && (settings.indexOf("is_" === 0) || (methodValue !== true && methodValue !== false))) { returnValue = methodValue; return false; }
120
+ });
121
+ }
122
+ else {
123
+ this.each(function() {
124
+ // extend settings and allow for multiple hashes and $.data
125
+ var instance_id = $.data(this, "jstree-instance-id"),
126
+ a = [],
127
+ b = settings ? $.extend({}, true, settings) : {},
128
+ c = $(this),
129
+ s = false,
130
+ t = [];
131
+ a = a.concat(args);
132
+ if(c.data("jstree")) { a.push(c.data("jstree")); }
133
+ b = a.length ? $.extend.apply(null, [true, b].concat(a)) : b;
134
+
135
+ // if an instance already exists, destroy it first
136
+ if(typeof instance_id !== "undefined" && instances[instance_id]) { instances[instance_id].destroy(); }
137
+ // push a new empty object to the instances array
138
+ instance_id = parseInt(instances.push({}),10) - 1;
139
+ // store the jstree instance id to the container element
140
+ $.data(this, "jstree-instance-id", instance_id);
141
+ // clean up all plugins
142
+ b.plugins = $.isArray(b.plugins) ? b.plugins : $.jstree.defaults.plugins.slice();
143
+ b.plugins.unshift("core");
144
+ // only unique plugins
145
+ b.plugins = b.plugins.sort().join(",,").replace(/(,|^)([^,]+)(,,\2)+(,|$)/g,"$1$2$4").replace(/,,+/g,",").replace(/,$/,"").split(",");
146
+
147
+ // extend defaults with passed data
148
+ s = $.extend(true, {}, $.jstree.defaults, b);
149
+ s.plugins = b.plugins;
150
+ $.each(plugins, function (i, val) {
151
+ if($.inArray(i, s.plugins) === -1) { s[i] = null; delete s[i]; }
152
+ else { t.push(i); }
153
+ });
154
+ s.plugins = t;
155
+
156
+ // push the new object to the instances array (at the same time set the default classes to the container) and init
157
+ instances[instance_id] = new $.jstree._instance(instance_id, $(this).addClass("jstree jstree-" + instance_id), s);
158
+ // init all activated plugins for this instance
159
+ $.each(instances[instance_id]._get_settings().plugins, function (i, val) { instances[instance_id].data[val] = {}; });
160
+ $.each(instances[instance_id]._get_settings().plugins, function (i, val) { if(plugins[val]) { plugins[val].__init.apply(instances[instance_id]); } });
161
+ // initialize the instance
162
+ setTimeout(function() { instances[instance_id].init(); }, 0);
163
+ });
164
+ }
165
+ // return the jquery selection (or if it was a method call that returned a value - the returned value)
166
+ return returnValue;
167
+ };
168
+ // object to store exposed functions and objects
169
+ $.jstree = {
170
+ defaults : {
171
+ plugins : []
172
+ },
173
+ _focused : function () { return instances[focused_instance] || null; },
174
+ _reference : function (needle) {
175
+ // get by instance id
176
+ if(instances[needle]) { return instances[needle]; }
177
+ // get by DOM (if still no luck - return null
178
+ var o = $(needle);
179
+ if(!o.length && typeof needle === "string") { o = $("#" + needle); }
180
+ if(!o.length) { return null; }
181
+ return instances[o.closest(".jstree").data("jstree-instance-id")] || null;
182
+ },
183
+ _instance : function (index, container, settings) {
184
+ // for plugins to store data in
185
+ this.data = { core : {} };
186
+ this.get_settings = function () { return $.extend(true, {}, settings); };
187
+ this._get_settings = function () { return settings; };
188
+ this.get_index = function () { return index; };
189
+ this.get_container = function () { return container; };
190
+ this.get_container_ul = function () { return container.children("ul:eq(0)"); };
191
+ this._set_settings = function (s) {
192
+ settings = $.extend(true, {}, settings, s);
193
+ };
194
+ },
195
+ _fn : { },
196
+ plugin : function (pname, pdata) {
197
+ pdata = $.extend({}, {
198
+ __init : $.noop,
199
+ __destroy : $.noop,
200
+ _fn : {},
201
+ defaults : false
202
+ }, pdata);
203
+ plugins[pname] = pdata;
204
+
205
+ $.jstree.defaults[pname] = pdata.defaults;
206
+ $.each(pdata._fn, function (i, val) {
207
+ val.plugin = pname;
208
+ val.old = $.jstree._fn[i];
209
+ $.jstree._fn[i] = function () {
210
+ var rslt,
211
+ func = val,
212
+ args = Array.prototype.slice.call(arguments),
213
+ evnt = new $.Event("before.jstree"),
214
+ rlbk = false;
215
+
216
+ if(this.data.core.locked === true && i !== "unlock" && i !== "is_locked") { return; }
217
+
218
+ // Check if function belongs to the included plugins of this instance
219
+ do {
220
+ if(func && func.plugin && $.inArray(func.plugin, this._get_settings().plugins) !== -1) { break; }
221
+ func = func.old;
222
+ } while(func);
223
+ if(!func) { return; }
224
+
225
+ // context and function to trigger events, then finally call the function
226
+ if(i.indexOf("_") === 0) {
227
+ rslt = func.apply(this, args);
228
+ }
229
+ else {
230
+ rslt = this.get_container().triggerHandler(evnt, { "func" : i, "inst" : this, "args" : args, "plugin" : func.plugin });
231
+ if(rslt === false) { return; }
232
+ if(typeof rslt !== "undefined") { args = rslt; }
233
+
234
+ rslt = func.apply(
235
+ $.extend({}, this, {
236
+ __callback : function (data) {
237
+ this.get_container().triggerHandler( i + '.jstree', { "inst" : this, "args" : args, "rslt" : data, "rlbk" : rlbk });
238
+ },
239
+ __rollback : function () {
240
+ rlbk = this.get_rollback();
241
+ return rlbk;
242
+ },
243
+ __call_old : function (replace_arguments) {
244
+ return func.old.apply(this, (replace_arguments ? Array.prototype.slice.call(arguments, 1) : args ) );
245
+ }
246
+ }), args);
247
+ }
248
+
249
+ // return the result
250
+ return rslt;
251
+ };
252
+ $.jstree._fn[i].old = val.old;
253
+ $.jstree._fn[i].plugin = pname;
254
+ });
255
+ },
256
+ rollback : function (rb) {
257
+ if(rb) {
258
+ if(!$.isArray(rb)) { rb = [ rb ]; }
259
+ $.each(rb, function (i, val) {
260
+ instances[val.i].set_rollback(val.h, val.d);
261
+ });
262
+ }
263
+ }
264
+ };
265
+ // set the prototype for all instances
266
+ $.jstree._fn = $.jstree._instance.prototype = {};
267
+
268
+ // load the css when DOM is ready
269
+ $(function() {
270
+ // code is copied from jQuery ($.browser is deprecated + there is a bug in IE)
271
+ var u = navigator.userAgent.toLowerCase(),
272
+ v = (u.match( /.+?(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [0,'0'])[1],
273
+ css_string = '' +
274
+ '.jstree ul, .jstree li { display:block; margin:0 0 0 0; padding:0 0 0 0; list-style-type:none; } ' +
275
+ '.jstree li { display:block; min-height:18px; line-height:18px; white-space:nowrap; margin-left:18px; min-width:18px; } ' +
276
+ '.jstree-rtl li { margin-left:0; margin-right:18px; } ' +
277
+ '.jstree > ul > li { margin-left:0px; } ' +
278
+ '.jstree-rtl > ul > li { margin-right:0px; } ' +
279
+ '.jstree ins { display:inline-block; text-decoration:none; width:18px; height:18px; margin:0 0 0 0; padding:0; } ' +
280
+ '.jstree a { display:inline-block; line-height:16px; height:16px; color:black; white-space:nowrap; text-decoration:none; padding:1px 2px; margin:0; } ' +
281
+ '.jstree a:focus { outline: none; } ' +
282
+ '.jstree a > ins { height:16px; width:16px; } ' +
283
+ '.jstree a > .jstree-icon { margin-right:3px; } ' +
284
+ '.jstree-rtl a > .jstree-icon { margin-left:3px; margin-right:0; } ' +
285
+ 'li.jstree-open > ul { display:block; } ' +
286
+ 'li.jstree-closed > ul { display:none; } ';
287
+ // Correct IE 6 (does not support the > CSS selector)
288
+ if(/msie/.test(u) && parseInt(v, 10) == 6) {
289
+ is_ie6 = true;
290
+
291
+ // fix image flicker and lack of caching
292
+ try {
293
+ document.execCommand("BackgroundImageCache", false, true);
294
+ } catch (err) { }
295
+
296
+ css_string += '' +
297
+ '.jstree li { height:18px; margin-left:0; margin-right:0; } ' +
298
+ '.jstree li li { margin-left:18px; } ' +
299
+ '.jstree-rtl li li { margin-left:0px; margin-right:18px; } ' +
300
+ 'li.jstree-open ul { display:block; } ' +
301
+ 'li.jstree-closed ul { display:none !important; } ' +
302
+ '.jstree li a { display:inline; border-width:0 !important; padding:0px 2px !important; } ' +
303
+ '.jstree li a ins { height:16px; width:16px; margin-right:3px; } ' +
304
+ '.jstree-rtl li a ins { margin-right:0px; margin-left:3px; } ';
305
+ }
306
+ // Correct IE 7 (shifts anchor nodes onhover)
307
+ if(/msie/.test(u) && parseInt(v, 10) == 7) {
308
+ is_ie7 = true;
309
+ css_string += '.jstree li a { border-width:0 !important; padding:0px 2px !important; } ';
310
+ }
311
+ // correct ff2 lack of display:inline-block
312
+ if(!/compatible/.test(u) && /mozilla/.test(u) && parseFloat(v, 10) < 1.9) {
313
+ is_ff2 = true;
314
+ css_string += '' +
315
+ '.jstree ins { display:-moz-inline-box; } ' +
316
+ '.jstree li { line-height:12px; } ' + // WHY??
317
+ '.jstree a { display:-moz-inline-box; } ' +
318
+ '.jstree .jstree-no-icons .jstree-checkbox { display:-moz-inline-stack !important; } ';
319
+ /* this shouldn't be here as it is theme specific */
320
+ }
321
+ // the default stylesheet
322
+ $.vakata.css.add_sheet({ str : css_string, title : "jstree" });
323
+ });
324
+
325
+ // core functions (open, close, create, update, delete)
326
+ $.jstree.plugin("core", {
327
+ __init : function () {
328
+ this.data.core.locked = false;
329
+ this.data.core.to_open = this.get_settings().core.initially_open;
330
+ this.data.core.to_load = this.get_settings().core.initially_load;
331
+ },
332
+ defaults : {
333
+ html_titles : false,
334
+ animation : 500,
335
+ initially_open : [],
336
+ initially_load : [],
337
+ open_parents : true,
338
+ notify_plugins : true,
339
+ rtl : false,
340
+ load_open : false,
341
+ strings : {
342
+ loading : "Loading ...",
343
+ new_node : "New node",
344
+ multiple_selection : "Multiple selection"
345
+ }
346
+ },
347
+ _fn : {
348
+ init : function () {
349
+ this.set_focus();
350
+ if(this._get_settings().core.rtl) {
351
+ this.get_container().addClass("jstree-rtl").css("direction", "rtl");
352
+ }
353
+ this.get_container().html("<ul><li class='jstree-last jstree-leaf'><ins>&#160;</ins><a class='jstree-loading' href='#'><ins class='jstree-icon'>&#160;</ins>" + this._get_string("loading") + "</a></li></ul>");
354
+ this.data.core.li_height = this.get_container_ul().find("li.jstree-closed, li.jstree-leaf").eq(0).height() || 18;
355
+
356
+ this.get_container()
357
+ .delegate("li > ins", "click.jstree", $.proxy(function (event) {
358
+ var trgt = $(event.target);
359
+ if(trgt.is("ins") && event.pageY - trgt.offset().top < this.data.core.li_height) { this.toggle_node(trgt); }
360
+ }, this))
361
+ .bind("mousedown.jstree", $.proxy(function () {
362
+ this.set_focus(); // This used to be setTimeout(set_focus,0) - why?
363
+ }, this))
364
+ .bind("dblclick.jstree", function (event) {
365
+ var sel;
366
+ if(document.selection && document.selection.empty) { document.selection.empty(); }
367
+ else {
368
+ if(window.getSelection) {
369
+ sel = window.getSelection();
370
+ try {
371
+ sel.removeAllRanges();
372
+ sel.collapse();
373
+ } catch (err) { }
374
+ }
375
+ }
376
+ });
377
+ if(this._get_settings().core.notify_plugins) {
378
+ this.get_container()
379
+ .bind("load_node.jstree", $.proxy(function (e, data) {
380
+ var o = this._get_node(data.rslt.obj),
381
+ t = this;
382
+ if(o === -1) { o = this.get_container_ul(); }
383
+ if(!o.length) { return; }
384
+ o.find("li").each(function () {
385
+ var th = $(this);
386
+ if(th.data("jstree")) {
387
+ $.each(th.data("jstree"), function (plugin, values) {
388
+ if(t.data[plugin] && $.isFunction(t["_" + plugin + "_notify"])) {
389
+ t["_" + plugin + "_notify"].call(t, th, values);
390
+ }
391
+ });
392
+ }
393
+ });
394
+ }, this));
395
+ }
396
+ if(this._get_settings().core.load_open) {
397
+ this.get_container()
398
+ .bind("load_node.jstree", $.proxy(function (e, data) {
399
+ var o = this._get_node(data.rslt.obj),
400
+ t = this;
401
+ if(o === -1) { o = this.get_container_ul(); }
402
+ if(!o.length) { return; }
403
+ o.find("li.jstree-open:not(:has(ul))").each(function () {
404
+ t.load_node(this, $.noop, $.noop);
405
+ });
406
+ }, this));
407
+ }
408
+ this.__callback();
409
+ this.load_node(-1, function () { this.loaded(); this.reload_nodes(); });
410
+ },
411
+ destroy : function () {
412
+ var i,
413
+ n = this.get_index(),
414
+ s = this._get_settings(),
415
+ _this = this;
416
+
417
+ $.each(s.plugins, function (i, val) {
418
+ try { plugins[val].__destroy.apply(_this); } catch(err) { }
419
+ });
420
+ this.__callback();
421
+ // set focus to another instance if this one is focused
422
+ if(this.is_focused()) {
423
+ for(i in instances) {
424
+ if(instances.hasOwnProperty(i) && i != n) {
425
+ instances[i].set_focus();
426
+ break;
427
+ }
428
+ }
429
+ }
430
+ // if no other instance found
431
+ if(n === focused_instance) { focused_instance = -1; }
432
+ // remove all traces of jstree in the DOM (only the ones set using jstree*) and cleans all events
433
+ this.get_container()
434
+ .unbind(".jstree")
435
+ .undelegate(".jstree")
436
+ .removeData("jstree-instance-id")
437
+ .find("[class^='jstree']")
438
+ .andSelf()
439
+ .attr("class", function () { return this.className.replace(/jstree[^ ]*|$/ig,''); });
440
+ $(document)
441
+ .unbind(".jstree-" + n)
442
+ .undelegate(".jstree-" + n);
443
+ // remove the actual data
444
+ instances[n] = null;
445
+ delete instances[n];
446
+ },
447
+
448
+ _core_notify : function (n, data) {
449
+ if(data.opened) {
450
+ this.open_node(n, false, true);
451
+ }
452
+ },
453
+
454
+ lock : function () {
455
+ this.data.core.locked = true;
456
+ this.get_container().children("ul").addClass("jstree-locked").css("opacity","0.7");
457
+ this.__callback({});
458
+ },
459
+ unlock : function () {
460
+ this.data.core.locked = false;
461
+ this.get_container().children("ul").removeClass("jstree-locked").css("opacity","1");
462
+ this.__callback({});
463
+ },
464
+ is_locked : function () { return this.data.core.locked; },
465
+ save_opened : function () {
466
+ var _this = this;
467
+ this.data.core.to_open = [];
468
+ this.get_container_ul().find("li.jstree-open").each(function () {
469
+ if(this.id) { _this.data.core.to_open.push("#" + this.id.toString().replace(/^#/,"").replace(/\\\//g,"/").replace(/\//g,"\\\/").replace(/\\\./g,".").replace(/\./g,"\\.")); }
470
+ });
471
+ this.__callback(_this.data.core.to_open);
472
+ },
473
+ save_loaded : function () { },
474
+ reload_nodes : function (is_callback) {
475
+ var _this = this,
476
+ done = true,
477
+ current = [],
478
+ remaining = [];
479
+ if(!is_callback) {
480
+ this.data.core.reopen = false;
481
+ this.data.core.refreshing = true;
482
+ this.data.core.to_open = $.map($.makeArray(this.data.core.to_open), function (n) { return "#" + n.toString().replace(/^#/,"").replace(/\\\//g,"/").replace(/\//g,"\\\/").replace(/\\\./g,".").replace(/\./g,"\\."); });
483
+ this.data.core.to_load = $.map($.makeArray(this.data.core.to_load), function (n) { return "#" + n.toString().replace(/^#/,"").replace(/\\\//g,"/").replace(/\//g,"\\\/").replace(/\\\./g,".").replace(/\./g,"\\."); });
484
+ if(this.data.core.to_open.length) {
485
+ this.data.core.to_load = this.data.core.to_load.concat(this.data.core.to_open);
486
+ }
487
+ }
488
+ if(this.data.core.to_load.length) {
489
+ $.each(this.data.core.to_load, function (i, val) {
490
+ if(val == "#") { return true; }
491
+ if($(val).length) { current.push(val); }
492
+ else { remaining.push(val); }
493
+ });
494
+ if(current.length) {
495
+ this.data.core.to_load = remaining;
496
+ $.each(current, function (i, val) {
497
+ if(!_this._is_loaded(val)) {
498
+ _this.load_node(val, function () { _this.reload_nodes(true); }, function () { _this.reload_nodes(true); });
499
+ done = false;
500
+ }
501
+ });
502
+ }
503
+ }
504
+ if(this.data.core.to_open.length) {
505
+ $.each(this.data.core.to_open, function (i, val) {
506
+ _this.open_node(val, false, true);
507
+ });
508
+ }
509
+ if(done) {
510
+ // TODO: find a more elegant approach to syncronizing returning requests
511
+ if(this.data.core.reopen) { clearTimeout(this.data.core.reopen); }
512
+ this.data.core.reopen = setTimeout(function () { _this.__callback({}, _this); }, 50);
513
+ this.data.core.refreshing = false;
514
+ this.reopen();
515
+ }
516
+ },
517
+ reopen : function () {
518
+ var _this = this;
519
+ if(this.data.core.to_open.length) {
520
+ $.each(this.data.core.to_open, function (i, val) {
521
+ _this.open_node(val, false, true);
522
+ });
523
+ }
524
+ this.__callback({});
525
+ },
526
+ refresh : function (obj) {
527
+ var _this = this;
528
+ this.save_opened();
529
+ if(!obj) { obj = -1; }
530
+ obj = this._get_node(obj);
531
+ if(!obj) { obj = -1; }
532
+ if(obj !== -1) { obj.children("UL").remove(); }
533
+ this.load_node(obj, function () { _this.__callback({ "obj" : obj}); _this.reload_nodes(); });
534
+ },
535
+ // Dummy function to fire after the first load (so that there is a jstree.loaded event)
536
+ loaded : function () {
537
+ this.__callback();
538
+ },
539
+ // deal with focus
540
+ set_focus : function () {
541
+ if(this.is_focused()) { return; }
542
+ var f = $.jstree._focused();
543
+ if(f) { f.unset_focus(); }
544
+
545
+ this.get_container().addClass("jstree-focused");
546
+ focused_instance = this.get_index();
547
+ this.__callback();
548
+ },
549
+ is_focused : function () {
550
+ return focused_instance == this.get_index();
551
+ },
552
+ unset_focus : function () {
553
+ if(this.is_focused()) {
554
+ this.get_container().removeClass("jstree-focused");
555
+ focused_instance = -1;
556
+ }
557
+ this.__callback();
558
+ },
559
+
560
+ // traverse
561
+ _get_node : function (obj) {
562
+ var $obj = $(obj, this.get_container());
563
+ if($obj.is(".jstree") || obj == -1) { return -1; }
564
+ $obj = $obj.closest("li", this.get_container());
565
+ return $obj.length ? $obj : false;
566
+ },
567
+ _get_next : function (obj, strict) {
568
+ obj = this._get_node(obj);
569
+ if(obj === -1) { return this.get_container().find("> ul > li:first-child"); }
570
+ if(!obj.length) { return false; }
571
+ if(strict) { return (obj.nextAll("li").size() > 0) ? obj.nextAll("li:eq(0)") : false; }
572
+
573
+ if(obj.hasClass("jstree-open")) { return obj.find("li:eq(0)"); }
574
+ else if(obj.nextAll("li").size() > 0) { return obj.nextAll("li:eq(0)"); }
575
+ else { return obj.parentsUntil(".jstree","li").next("li").eq(0); }
576
+ },
577
+ _get_prev : function (obj, strict) {
578
+ obj = this._get_node(obj);
579
+ if(obj === -1) { return this.get_container().find("> ul > li:last-child"); }
580
+ if(!obj.length) { return false; }
581
+ if(strict) { return (obj.prevAll("li").length > 0) ? obj.prevAll("li:eq(0)") : false; }
582
+
583
+ if(obj.prev("li").length) {
584
+ obj = obj.prev("li").eq(0);
585
+ while(obj.hasClass("jstree-open")) { obj = obj.children("ul:eq(0)").children("li:last"); }
586
+ return obj;
587
+ }
588
+ else { var o = obj.parentsUntil(".jstree","li:eq(0)"); return o.length ? o : false; }
589
+ },
590
+ _get_parent : function (obj) {
591
+ obj = this._get_node(obj);
592
+ if(obj == -1 || !obj.length) { return false; }
593
+ var o = obj.parentsUntil(".jstree", "li:eq(0)");
594
+ return o.length ? o : -1;
595
+ },
596
+ _get_children : function (obj) {
597
+ obj = this._get_node(obj);
598
+ if(obj === -1) { return this.get_container().children("ul:eq(0)").children("li"); }
599
+ if(!obj.length) { return false; }
600
+ return obj.children("ul:eq(0)").children("li");
601
+ },
602
+ get_path : function (obj, id_mode) {
603
+ var p = [],
604
+ _this = this;
605
+ obj = this._get_node(obj);
606
+ if(obj === -1 || !obj || !obj.length) { return false; }
607
+ obj.parentsUntil(".jstree", "li").each(function () {
608
+ p.push( id_mode ? this.id : _this.get_text(this) );
609
+ });
610
+ p.reverse();
611
+ p.push( id_mode ? obj.attr("id") : this.get_text(obj) );
612
+ return p;
613
+ },
614
+
615
+ // string functions
616
+ _get_string : function (key) {
617
+ return this._get_settings().core.strings[key] || key;
618
+ },
619
+
620
+ is_open : function (obj) { obj = this._get_node(obj); return obj && obj !== -1 && obj.hasClass("jstree-open"); },
621
+ is_closed : function (obj) { obj = this._get_node(obj); return obj && obj !== -1 && obj.hasClass("jstree-closed"); },
622
+ is_leaf : function (obj) { obj = this._get_node(obj); return obj && obj !== -1 && obj.hasClass("jstree-leaf"); },
623
+ correct_state : function (obj) {
624
+ obj = this._get_node(obj);
625
+ if(!obj || obj === -1) { return false; }
626
+ obj.removeClass("jstree-closed jstree-open").addClass("jstree-leaf").children("ul").remove();
627
+ this.__callback({ "obj" : obj });
628
+ },
629
+ // open/close
630
+ open_node : function (obj, callback, skip_animation) {
631
+ obj = this._get_node(obj);
632
+ if(!obj.length) { return false; }
633
+ if(!obj.hasClass("jstree-closed")) { if(callback) { callback.call(); } return false; }
634
+ var s = skip_animation || is_ie6 ? 0 : this._get_settings().core.animation,
635
+ t = this;
636
+ if(!this._is_loaded(obj)) {
637
+ obj.children("a").addClass("jstree-loading");
638
+ this.load_node(obj, function () { t.open_node(obj, callback, skip_animation); }, callback);
639
+ }
640
+ else {
641
+ if(this._get_settings().core.open_parents) {
642
+ obj.parentsUntil(".jstree",".jstree-closed").each(function () {
643
+ t.open_node(this, false, true);
644
+ });
645
+ }
646
+ if(s) { obj.children("ul").css("display","none"); }
647
+ obj.removeClass("jstree-closed").addClass("jstree-open").children("a").removeClass("jstree-loading");
648
+ if(s) { obj.children("ul").stop(true, true).slideDown(s, function () { this.style.display = ""; t.after_open(obj); }); }
649
+ else { t.after_open(obj); }
650
+ this.__callback({ "obj" : obj });
651
+ if(callback) { callback.call(); }
652
+ }
653
+ },
654
+ after_open : function (obj) { this.__callback({ "obj" : obj }); },
655
+ close_node : function (obj, skip_animation) {
656
+ obj = this._get_node(obj);
657
+ var s = skip_animation || is_ie6 ? 0 : this._get_settings().core.animation,
658
+ t = this;
659
+ if(!obj.length || !obj.hasClass("jstree-open")) { return false; }
660
+ if(s) { obj.children("ul").attr("style","display:block !important"); }
661
+ obj.removeClass("jstree-open").addClass("jstree-closed");
662
+ if(s) { obj.children("ul").stop(true, true).slideUp(s, function () { this.style.display = ""; t.after_close(obj); }); }
663
+ else { t.after_close(obj); }
664
+ this.__callback({ "obj" : obj });
665
+ },
666
+ after_close : function (obj) { this.__callback({ "obj" : obj }); },
667
+ toggle_node : function (obj) {
668
+ obj = this._get_node(obj);
669
+ if(obj.hasClass("jstree-closed")) { return this.open_node(obj); }
670
+ if(obj.hasClass("jstree-open")) { return this.close_node(obj); }
671
+ },
672
+ open_all : function (obj, do_animation, original_obj) {
673
+ obj = obj ? this._get_node(obj) : -1;
674
+ if(!obj || obj === -1) { obj = this.get_container_ul(); }
675
+ if(original_obj) {
676
+ obj = obj.find("li.jstree-closed");
677
+ }
678
+ else {
679
+ original_obj = obj;
680
+ if(obj.is(".jstree-closed")) { obj = obj.find("li.jstree-closed").andSelf(); }
681
+ else { obj = obj.find("li.jstree-closed"); }
682
+ }
683
+ var _this = this;
684
+ obj.each(function () {
685
+ var __this = this;
686
+ if(!_this._is_loaded(this)) { _this.open_node(this, function() { _this.open_all(__this, do_animation, original_obj); }, !do_animation); }
687
+ else { _this.open_node(this, false, !do_animation); }
688
+ });
689
+ // so that callback is fired AFTER all nodes are open
690
+ if(original_obj.find('li.jstree-closed').length === 0) { this.__callback({ "obj" : original_obj }); }
691
+ },
692
+ close_all : function (obj, do_animation) {
693
+ var _this = this;
694
+ obj = obj ? this._get_node(obj) : this.get_container();
695
+ if(!obj || obj === -1) { obj = this.get_container_ul(); }
696
+ obj.find("li.jstree-open").andSelf().each(function () { _this.close_node(this, !do_animation); });
697
+ this.__callback({ "obj" : obj });
698
+ },
699
+ clean_node : function (obj) {
700
+ obj = obj && obj != -1 ? $(obj) : this.get_container_ul();
701
+ obj = obj.is("li") ? obj.find("li").andSelf() : obj.find("li");
702
+ obj.removeClass("jstree-last")
703
+ .filter("li:last-child").addClass("jstree-last").end()
704
+ .filter(":has(li)")
705
+ .not(".jstree-open").removeClass("jstree-leaf").addClass("jstree-closed");
706
+ obj.not(".jstree-open, .jstree-closed").addClass("jstree-leaf").children("ul").remove();
707
+ this.__callback({ "obj" : obj });
708
+ },
709
+ // rollback
710
+ get_rollback : function () {
711
+ this.__callback();
712
+ return { i : this.get_index(), h : this.get_container().children("ul").clone(true), d : this.data };
713
+ },
714
+ set_rollback : function (html, data) {
715
+ this.get_container().empty().append(html);
716
+ this.data = data;
717
+ this.__callback();
718
+ },
719
+ // Dummy functions to be overwritten by any datastore plugin included
720
+ load_node : function (obj, s_call, e_call) { this.__callback({ "obj" : obj }); },
721
+ _is_loaded : function (obj) { return true; },
722
+
723
+ // Basic operations: create
724
+ create_node : function (obj, position, js, callback, is_loaded) {
725
+ obj = this._get_node(obj);
726
+ position = typeof position === "undefined" ? "last" : position;
727
+ var d = $("<li />"),
728
+ s = this._get_settings().core,
729
+ tmp;
730
+
731
+ if(obj !== -1 && !obj.length) { return false; }
732
+ if(!is_loaded && !this._is_loaded(obj)) { this.load_node(obj, function () { this.create_node(obj, position, js, callback, true); }); return false; }
733
+
734
+ this.__rollback();
735
+
736
+ if(typeof js === "string") { js = { "data" : js }; }
737
+ if(!js) { js = {}; }
738
+ if(js.attr) { d.attr(js.attr); }
739
+ if(js.metadata) { d.data(js.metadata); }
740
+ if(js.state) { d.addClass("jstree-" + js.state); }
741
+ if(!js.data) { js.data = this._get_string("new_node"); }
742
+ if(!$.isArray(js.data)) { tmp = js.data; js.data = []; js.data.push(tmp); }
743
+ $.each(js.data, function (i, m) {
744
+ tmp = $("<a />");
745
+ if($.isFunction(m)) { m = m.call(this, js); }
746
+ if(typeof m == "string") { tmp.attr('href','#')[ s.html_titles ? "html" : "text" ](m); }
747
+ else {
748
+ if(!m.attr) { m.attr = {}; }
749
+ if(!m.attr.href) { m.attr.href = '#'; }
750
+ tmp.attr(m.attr)[ s.html_titles ? "html" : "text" ](m.title);
751
+ if(m.language) { tmp.addClass(m.language); }
752
+ }
753
+ tmp.prepend("<ins class='jstree-icon'>&#160;</ins>");
754
+ if(m.icon) {
755
+ if(m.icon.indexOf("/") === -1) { tmp.children("ins").addClass(m.icon); }
756
+ else { tmp.children("ins").css("background","url('" + m.icon + "') center center no-repeat"); }
757
+ }
758
+ d.append(tmp);
759
+ });
760
+ d.prepend("<ins class='jstree-icon'>&#160;</ins>");
761
+ if(obj === -1) {
762
+ obj = this.get_container();
763
+ if(position === "before") { position = "first"; }
764
+ if(position === "after") { position = "last"; }
765
+ }
766
+ switch(position) {
767
+ case "before": obj.before(d); tmp = this._get_parent(obj); break;
768
+ case "after" : obj.after(d); tmp = this._get_parent(obj); break;
769
+ case "inside":
770
+ case "first" :
771
+ if(!obj.children("ul").length) { obj.append("<ul />"); }
772
+ obj.children("ul").prepend(d);
773
+ tmp = obj;
774
+ break;
775
+ case "last":
776
+ if(!obj.children("ul").length) { obj.append("<ul />"); }
777
+ obj.children("ul").append(d);
778
+ tmp = obj;
779
+ break;
780
+ default:
781
+ if(!obj.children("ul").length) { obj.append("<ul />"); }
782
+ if(!position) { position = 0; }
783
+ tmp = obj.children("ul").children("li").eq(position);
784
+ if(tmp.length) { tmp.before(d); }
785
+ else { obj.children("ul").append(d); }
786
+ tmp = obj;
787
+ break;
788
+ }
789
+ if(tmp === -1 || tmp.get(0) === this.get_container().get(0)) { tmp = -1; }
790
+ this.clean_node(tmp);
791
+ this.__callback({ "obj" : d, "parent" : tmp });
792
+ if(callback) { callback.call(this, d); }
793
+ return d;
794
+ },
795
+ // Basic operations: rename (deal with text)
796
+ get_text : function (obj) {
797
+ obj = this._get_node(obj);
798
+ if(!obj.length) { return false; }
799
+ var s = this._get_settings().core.html_titles;
800
+ obj = obj.children("a:eq(0)");
801
+ if(s) {
802
+ obj = obj.clone();
803
+ obj.children("INS").remove();
804
+ return obj.html();
805
+ }
806
+ else {
807
+ obj = obj.contents().filter(function() { return this.nodeType == 3; })[0];
808
+ return obj.nodeValue;
809
+ }
810
+ },
811
+ set_text : function (obj, val) {
812
+ obj = this._get_node(obj);
813
+ if(!obj.length) { return false; }
814
+ obj = obj.children("a:eq(0)");
815
+ if(this._get_settings().core.html_titles) {
816
+ var tmp = obj.children("INS").clone();
817
+ obj.html(val).prepend(tmp);
818
+ this.__callback({ "obj" : obj, "name" : val });
819
+ return true;
820
+ }
821
+ else {
822
+ obj = obj.contents().filter(function() { return this.nodeType == 3; })[0];
823
+ this.__callback({ "obj" : obj, "name" : val });
824
+ return (obj.nodeValue = val);
825
+ }
826
+ },
827
+ rename_node : function (obj, val) {
828
+ obj = this._get_node(obj);
829
+ this.__rollback();
830
+ if(obj && obj.length && this.set_text.apply(this, Array.prototype.slice.call(arguments))) { this.__callback({ "obj" : obj, "name" : val }); }
831
+ },
832
+ // Basic operations: deleting nodes
833
+ delete_node : function (obj) {
834
+ obj = this._get_node(obj);
835
+ if(!obj.length) { return false; }
836
+ this.__rollback();
837
+ var p = this._get_parent(obj), prev = $([]), t = this;
838
+ obj.each(function () {
839
+ prev = prev.add(t._get_prev(this));
840
+ });
841
+ obj = obj.detach();
842
+ if(p !== -1 && p.find("> ul > li").length === 0) {
843
+ p.removeClass("jstree-open jstree-closed").addClass("jstree-leaf");
844
+ }
845
+ this.clean_node(p);
846
+ this.__callback({ "obj" : obj, "prev" : prev, "parent" : p });
847
+ return obj;
848
+ },
849
+ prepare_move : function (o, r, pos, cb, is_cb) {
850
+ var p = {};
851
+
852
+ p.ot = $.jstree._reference(o) || this;
853
+ p.o = p.ot._get_node(o);
854
+ p.r = r === - 1 ? -1 : this._get_node(r);
855
+ p.p = (typeof pos === "undefined") ? "last" : pos; // TODO: move to a setting
856
+ if(!is_cb && prepared_move.o && prepared_move.o[0] === p.o[0] && prepared_move.r[0] === p.r[0] && prepared_move.p === p.p) {
857
+ this.__callback(prepared_move);
858
+ if(cb) { cb.call(this, prepared_move); }
859
+ return;
860
+ }
861
+ p.ot = $.jstree._reference(p.o) || this;
862
+ p.rt = $.jstree._reference(p.r) || this; // r === -1 ? p.ot : $.jstree._reference(p.r) || this
863
+ if(p.r === -1 || !p.r) {
864
+ p.cr = -1;
865
+ switch(p.p) {
866
+ case "first":
867
+ case "before":
868
+ case "inside":
869
+ p.cp = 0;
870
+ break;
871
+ case "after":
872
+ case "last":
873
+ p.cp = p.rt.get_container().find(" > ul > li").length;
874
+ break;
875
+ default:
876
+ p.cp = p.p;
877
+ break;
878
+ }
879
+ }
880
+ else {
881
+ if(!/^(before|after)$/.test(p.p) && !this._is_loaded(p.r)) {
882
+ return this.load_node(p.r, function () { this.prepare_move(o, r, pos, cb, true); });
883
+ }
884
+ switch(p.p) {
885
+ case "before":
886
+ p.cp = p.r.index();
887
+ p.cr = p.rt._get_parent(p.r);
888
+ break;
889
+ case "after":
890
+ p.cp = p.r.index() + 1;
891
+ p.cr = p.rt._get_parent(p.r);
892
+ break;
893
+ case "inside":
894
+ case "first":
895
+ p.cp = 0;
896
+ p.cr = p.r;
897
+ break;
898
+ case "last":
899
+ p.cp = p.r.find(" > ul > li").length;
900
+ p.cr = p.r;
901
+ break;
902
+ default:
903
+ p.cp = p.p;
904
+ p.cr = p.r;
905
+ break;
906
+ }
907
+ }
908
+ p.np = p.cr == -1 ? p.rt.get_container() : p.cr;
909
+ p.op = p.ot._get_parent(p.o);
910
+ p.cop = p.o.index();
911
+ if(p.op === -1) { p.op = p.ot ? p.ot.get_container() : this.get_container(); }
912
+ if(!/^(before|after)$/.test(p.p) && p.op && p.np && p.op[0] === p.np[0] && p.o.index() < p.cp) { p.cp++; }
913
+ //if(p.p === "before" && p.op && p.np && p.op[0] === p.np[0] && p.o.index() < p.cp) { p.cp--; }
914
+ p.or = p.np.find(" > ul > li:nth-child(" + (p.cp + 1) + ")");
915
+ prepared_move = p;
916
+ this.__callback(prepared_move);
917
+ if(cb) { cb.call(this, prepared_move); }
918
+ },
919
+ check_move : function () {
920
+ var obj = prepared_move, ret = true, r = obj.r === -1 ? this.get_container() : obj.r;
921
+ if(!obj || !obj.o || obj.or[0] === obj.o[0]) { return false; }
922
+ if(obj.op && obj.np && obj.op[0] === obj.np[0] && obj.cp - 1 === obj.o.index()) { return false; }
923
+ obj.o.each(function () {
924
+ if(r.parentsUntil(".jstree", "li").andSelf().index(this) !== -1) { ret = false; return false; }
925
+ });
926
+ return ret;
927
+ },
928
+ move_node : function (obj, ref, position, is_copy, is_prepared, skip_check) {
929
+ if(!is_prepared) {
930
+ return this.prepare_move(obj, ref, position, function (p) {
931
+ this.move_node(p, false, false, is_copy, true, skip_check);
932
+ });
933
+ }
934
+ if(is_copy) {
935
+ prepared_move.cy = true;
936
+ }
937
+ if(!skip_check && !this.check_move()) { return false; }
938
+
939
+ this.__rollback();
940
+ var o = false;
941
+ if(is_copy) {
942
+ o = obj.o.clone();
943
+ o.find("*[id]").andSelf().each(function () {
944
+ if(this.id) { this.id = "copy_" + this.id; }
945
+ });
946
+ }
947
+ else { o = obj.o; }
948
+
949
+ if(obj.or.length) { obj.or.before(o); }
950
+ else {
951
+ if(!obj.np.children("ul").length) { $("<ul />").appendTo(obj.np); }
952
+ obj.np.children("ul:eq(0)").append(o);
953
+ }
954
+
955
+ try {
956
+ obj.ot.clean_node(obj.op);
957
+ obj.rt.clean_node(obj.np);
958
+ if(!obj.op.find("> ul > li").length) {
959
+ obj.op.removeClass("jstree-open jstree-closed").addClass("jstree-leaf").children("ul").remove();
960
+ }
961
+ } catch (e) { }
962
+
963
+ if(is_copy) {
964
+ prepared_move.cy = true;
965
+ prepared_move.oc = o;
966
+ }
967
+ this.__callback(prepared_move);
968
+ return prepared_move;
969
+ },
970
+ _get_move : function () { return prepared_move; }
971
+ }
972
+ });
973
+ })(jQuery);
974
+ //*/
975
+
976
+ /*
977
+ * jsTree ui plugin
978
+ * This plugins handles selecting/deselecting/hovering/dehovering nodes
979
+ */
980
+ (function ($) {
981
+ var scrollbar_width, e1, e2;
982
+ $(function() {
983
+ if (/msie/.test(navigator.userAgent.toLowerCase())) {
984
+ e1 = $('<textarea cols="10" rows="2"></textarea>').css({ position: 'absolute', top: -1000, left: 0 }).appendTo('body');
985
+ e2 = $('<textarea cols="10" rows="2" style="overflow: hidden;"></textarea>').css({ position: 'absolute', top: -1000, left: 0 }).appendTo('body');
986
+ scrollbar_width = e1.width() - e2.width();
987
+ e1.add(e2).remove();
988
+ }
989
+ else {
990
+ e1 = $('<div />').css({ width: 100, height: 100, overflow: 'auto', position: 'absolute', top: -1000, left: 0 })
991
+ .prependTo('body').append('<div />').find('div').css({ width: '100%', height: 200 });
992
+ scrollbar_width = 100 - e1.width();
993
+ e1.parent().remove();
994
+ }
995
+ });
996
+ $.jstree.plugin("ui", {
997
+ __init : function () {
998
+ this.data.ui.selected = $();
999
+ this.data.ui.last_selected = false;
1000
+ this.data.ui.hovered = null;
1001
+ this.data.ui.to_select = this.get_settings().ui.initially_select;
1002
+
1003
+ this.get_container()
1004
+ .delegate("a", "click.jstree", $.proxy(function (event) {
1005
+ event.preventDefault();
1006
+ event.currentTarget.blur();
1007
+ if(!$(event.currentTarget).hasClass("jstree-loading")) {
1008
+ this.select_node(event.currentTarget, true, event);
1009
+ }
1010
+ }, this))
1011
+ .delegate("a", "mouseenter.jstree", $.proxy(function (event) {
1012
+ if(!$(event.currentTarget).hasClass("jstree-loading")) {
1013
+ this.hover_node(event.target);
1014
+ }
1015
+ }, this))
1016
+ .delegate("a", "mouseleave.jstree", $.proxy(function (event) {
1017
+ if(!$(event.currentTarget).hasClass("jstree-loading")) {
1018
+ this.dehover_node(event.target);
1019
+ }
1020
+ }, this))
1021
+ .bind("reopen.jstree", $.proxy(function () {
1022
+ this.reselect();
1023
+ }, this))
1024
+ .bind("get_rollback.jstree", $.proxy(function () {
1025
+ this.dehover_node();
1026
+ this.save_selected();
1027
+ }, this))
1028
+ .bind("set_rollback.jstree", $.proxy(function () {
1029
+ this.reselect();
1030
+ }, this))
1031
+ .bind("close_node.jstree", $.proxy(function (event, data) {
1032
+ var s = this._get_settings().ui,
1033
+ obj = this._get_node(data.rslt.obj),
1034
+ clk = (obj && obj.length) ? obj.children("ul").find("a.jstree-clicked") : $(),
1035
+ _this = this;
1036
+ if(s.selected_parent_close === false || !clk.length) { return; }
1037
+ clk.each(function () {
1038
+ _this.deselect_node(this);
1039
+ if(s.selected_parent_close === "select_parent") { _this.select_node(obj); }
1040
+ });
1041
+ }, this))
1042
+ .bind("delete_node.jstree", $.proxy(function (event, data) {
1043
+ var s = this._get_settings().ui.select_prev_on_delete,
1044
+ obj = this._get_node(data.rslt.obj),
1045
+ clk = (obj && obj.length) ? obj.find("a.jstree-clicked") : [],
1046
+ _this = this;
1047
+ clk.each(function () { _this.deselect_node(this); });
1048
+ if(s && clk.length) {
1049
+ data.rslt.prev.each(function () {
1050
+ if(this.parentNode) { _this.select_node(this); return false; /* if return false is removed all prev nodes will be selected */}
1051
+ });
1052
+ }
1053
+ }, this))
1054
+ .bind("move_node.jstree", $.proxy(function (event, data) {
1055
+ if(data.rslt.cy) {
1056
+ data.rslt.oc.find("a.jstree-clicked").removeClass("jstree-clicked");
1057
+ }
1058
+ }, this));
1059
+ },
1060
+ defaults : {
1061
+ select_limit : -1, // 0, 1, 2 ... or -1 for unlimited
1062
+ select_multiple_modifier : "ctrl", // on, or ctrl, shift, alt
1063
+ select_range_modifier : "shift",
1064
+ selected_parent_close : "select_parent", // false, "deselect", "select_parent"
1065
+ selected_parent_open : true,
1066
+ select_prev_on_delete : true,
1067
+ disable_selecting_children : false,
1068
+ initially_select : []
1069
+ },
1070
+ _fn : {
1071
+ _get_node : function (obj, allow_multiple) {
1072
+ if(typeof obj === "undefined" || obj === null) { return allow_multiple ? this.data.ui.selected : this.data.ui.last_selected; }
1073
+ var $obj = $(obj, this.get_container());
1074
+ if($obj.is(".jstree") || obj == -1) { return -1; }
1075
+ $obj = $obj.closest("li", this.get_container());
1076
+ return $obj.length ? $obj : false;
1077
+ },
1078
+ _ui_notify : function (n, data) {
1079
+ if(data.selected) {
1080
+ this.select_node(n, false);
1081
+ }
1082
+ },
1083
+ save_selected : function () {
1084
+ var _this = this;
1085
+ this.data.ui.to_select = [];
1086
+ this.data.ui.selected.each(function () { if(this.id) { _this.data.ui.to_select.push("#" + this.id.toString().replace(/^#/,"").replace(/\\\//g,"/").replace(/\//g,"\\\/").replace(/\\\./g,".").replace(/\./g,"\\.")); } });
1087
+ this.__callback(this.data.ui.to_select);
1088
+ },
1089
+ reselect : function () {
1090
+ var _this = this,
1091
+ s = this.data.ui.to_select;
1092
+ s = $.map($.makeArray(s), function (n) { return "#" + n.toString().replace(/^#/,"").replace(/\\\//g,"/").replace(/\//g,"\\\/").replace(/\\\./g,".").replace(/\./g,"\\."); });
1093
+ // this.deselect_all(); WHY deselect, breaks plugin state notifier?
1094
+ $.each(s, function (i, val) { if(val && val !== "#") { _this.select_node(val); } });
1095
+ this.data.ui.selected = this.data.ui.selected.filter(function () { return this.parentNode; });
1096
+ this.__callback();
1097
+ },
1098
+ refresh : function (obj) {
1099
+ this.save_selected();
1100
+ return this.__call_old();
1101
+ },
1102
+ hover_node : function (obj) {
1103
+ obj = this._get_node(obj);
1104
+ if(!obj.length) { return false; }
1105
+ //if(this.data.ui.hovered && obj.get(0) === this.data.ui.hovered.get(0)) { return; }
1106
+ if(!obj.hasClass("jstree-hovered")) { this.dehover_node(); }
1107
+ this.data.ui.hovered = obj.children("a").addClass("jstree-hovered").parent();
1108
+ this._fix_scroll(obj);
1109
+ this.__callback({ "obj" : obj });
1110
+ },
1111
+ dehover_node : function () {
1112
+ var obj = this.data.ui.hovered, p;
1113
+ if(!obj || !obj.length) { return false; }
1114
+ p = obj.children("a").removeClass("jstree-hovered").parent();
1115
+ if(this.data.ui.hovered[0] === p[0]) { this.data.ui.hovered = null; }
1116
+ this.__callback({ "obj" : obj });
1117
+ },
1118
+ select_node : function (obj, check, e) {
1119
+ obj = this._get_node(obj);
1120
+ if(obj == -1 || !obj || !obj.length) { return false; }
1121
+ var s = this._get_settings().ui,
1122
+ is_multiple = (s.select_multiple_modifier == "on" || (s.select_multiple_modifier !== false && e && e[s.select_multiple_modifier + "Key"])),
1123
+ is_range = (s.select_range_modifier !== false && e && e[s.select_range_modifier + "Key"] && this.data.ui.last_selected && this.data.ui.last_selected[0] !== obj[0] && this.data.ui.last_selected.parent()[0] === obj.parent()[0]),
1124
+ is_selected = this.is_selected(obj),
1125
+ proceed = true,
1126
+ t = this;
1127
+ if(check) {
1128
+ if(s.disable_selecting_children && is_multiple &&
1129
+ (
1130
+ (obj.parentsUntil(".jstree","li").children("a.jstree-clicked").length) ||
1131
+ (obj.children("ul").find("a.jstree-clicked:eq(0)").length)
1132
+ )
1133
+ ) {
1134
+ return false;
1135
+ }
1136
+ proceed = false;
1137
+ switch(!0) {
1138
+ case (is_range):
1139
+ this.data.ui.last_selected.addClass("jstree-last-selected");
1140
+ obj = obj[ obj.index() < this.data.ui.last_selected.index() ? "nextUntil" : "prevUntil" ](".jstree-last-selected").andSelf();
1141
+ if(s.select_limit == -1 || obj.length < s.select_limit) {
1142
+ this.data.ui.last_selected.removeClass("jstree-last-selected");
1143
+ this.data.ui.selected.each(function () {
1144
+ if(this !== t.data.ui.last_selected[0]) { t.deselect_node(this); }
1145
+ });
1146
+ is_selected = false;
1147
+ proceed = true;
1148
+ }
1149
+ else {
1150
+ proceed = false;
1151
+ }
1152
+ break;
1153
+ case (is_selected && !is_multiple):
1154
+ this.deselect_all();
1155
+ is_selected = false;
1156
+ proceed = true;
1157
+ break;
1158
+ case (!is_selected && !is_multiple):
1159
+ if(s.select_limit == -1 || s.select_limit > 0) {
1160
+ this.deselect_all();
1161
+ proceed = true;
1162
+ }
1163
+ break;
1164
+ case (is_selected && is_multiple):
1165
+ this.deselect_node(obj);
1166
+ break;
1167
+ case (!is_selected && is_multiple):
1168
+ if(s.select_limit == -1 || this.data.ui.selected.length + 1 <= s.select_limit) {
1169
+ proceed = true;
1170
+ }
1171
+ break;
1172
+ }
1173
+ }
1174
+ if(proceed && !is_selected) {
1175
+ if(!is_range) { this.data.ui.last_selected = obj; }
1176
+ obj.children("a").addClass("jstree-clicked");
1177
+ if(s.selected_parent_open) {
1178
+ obj.parents(".jstree-closed").each(function () { t.open_node(this, false, true); });
1179
+ }
1180
+ this.data.ui.selected = this.data.ui.selected.add(obj);
1181
+ this._fix_scroll(obj.eq(0));
1182
+ this.__callback({ "obj" : obj, "e" : e });
1183
+ }
1184
+ },
1185
+ _fix_scroll : function (obj) {
1186
+ var c = this.get_container()[0], t;
1187
+ if(c.scrollHeight > c.offsetHeight) {
1188
+ obj = this._get_node(obj);
1189
+ if(!obj || obj === -1 || !obj.length || !obj.is(":visible")) { return; }
1190
+ t = obj.offset().top - this.get_container().offset().top;
1191
+ if(t < 0) {
1192
+ c.scrollTop = c.scrollTop + t - 1;
1193
+ }
1194
+ if(t + this.data.core.li_height + (c.scrollWidth > c.offsetWidth ? scrollbar_width : 0) > c.offsetHeight) {
1195
+ c.scrollTop = c.scrollTop + (t - c.offsetHeight + this.data.core.li_height + 1 + (c.scrollWidth > c.offsetWidth ? scrollbar_width : 0));
1196
+ }
1197
+ }
1198
+ },
1199
+ deselect_node : function (obj) {
1200
+ obj = this._get_node(obj);
1201
+ if(!obj.length) { return false; }
1202
+ if(this.is_selected(obj)) {
1203
+ obj.children("a").removeClass("jstree-clicked");
1204
+ this.data.ui.selected = this.data.ui.selected.not(obj);
1205
+ if(this.data.ui.last_selected.get(0) === obj.get(0)) { this.data.ui.last_selected = this.data.ui.selected.eq(0); }
1206
+ this.__callback({ "obj" : obj });
1207
+ }
1208
+ },
1209
+ toggle_select : function (obj) {
1210
+ obj = this._get_node(obj);
1211
+ if(!obj.length) { return false; }
1212
+ if(this.is_selected(obj)) { this.deselect_node(obj); }
1213
+ else { this.select_node(obj); }
1214
+ },
1215
+ is_selected : function (obj) { return this.data.ui.selected.index(this._get_node(obj)) >= 0; },
1216
+ get_selected : function (context) {
1217
+ return context ? $(context).find("a.jstree-clicked").parent() : this.data.ui.selected;
1218
+ },
1219
+ deselect_all : function (context) {
1220
+ var ret = context ? $(context).find("a.jstree-clicked").parent() : this.get_container().find("a.jstree-clicked").parent();
1221
+ ret.children("a.jstree-clicked").removeClass("jstree-clicked");
1222
+ this.data.ui.selected = $([]);
1223
+ this.data.ui.last_selected = false;
1224
+ this.__callback({ "obj" : ret });
1225
+ }
1226
+ }
1227
+ });
1228
+ // include the selection plugin by default
1229
+ $.jstree.defaults.plugins.push("ui");
1230
+ })(jQuery);
1231
+ //*/
1232
+
1233
+ /*
1234
+ * jsTree CRRM plugin
1235
+ * Handles creating/renaming/removing/moving nodes by user interaction.
1236
+ */
1237
+ (function ($) {
1238
+ $.jstree.plugin("crrm", {
1239
+ __init : function () {
1240
+ this.get_container()
1241
+ .bind("move_node.jstree", $.proxy(function (e, data) {
1242
+ if(this._get_settings().crrm.move.open_onmove) {
1243
+ var t = this;
1244
+ data.rslt.np.parentsUntil(".jstree").andSelf().filter(".jstree-closed").each(function () {
1245
+ t.open_node(this, false, true);
1246
+ });
1247
+ }
1248
+ }, this));
1249
+ },
1250
+ defaults : {
1251
+ input_width_limit : 200,
1252
+ move : {
1253
+ always_copy : false, // false, true or "multitree"
1254
+ open_onmove : true,
1255
+ default_position : "last",
1256
+ check_move : function (m) { return true; }
1257
+ }
1258
+ },
1259
+ _fn : {
1260
+ _show_input : function (obj, callback) {
1261
+ obj = this._get_node(obj);
1262
+ var rtl = this._get_settings().core.rtl,
1263
+ w = this._get_settings().crrm.input_width_limit,
1264
+ w1 = obj.children("ins").width(),
1265
+ w2 = obj.find("> a:visible > ins").width() * obj.find("> a:visible > ins").length,
1266
+ t = this.get_text(obj),
1267
+ h1 = $("<div />", { css : { "position" : "absolute", "top" : "-200px", "left" : (rtl ? "0px" : "-1000px"), "visibility" : "hidden" } }).appendTo("body"),
1268
+ h2 = obj.css("position","relative").append(
1269
+ $("<input />", {
1270
+ "value" : t,
1271
+ "class" : "jstree-rename-input",
1272
+ // "size" : t.length,
1273
+ "css" : {
1274
+ "padding" : "0",
1275
+ "border" : "1px solid silver",
1276
+ "position" : "absolute",
1277
+ "left" : (rtl ? "auto" : (w1 + w2 + 4) + "px"),
1278
+ "right" : (rtl ? (w1 + w2 + 4) + "px" : "auto"),
1279
+ "top" : "0px",
1280
+ "height" : (this.data.core.li_height - 2) + "px",
1281
+ "lineHeight" : (this.data.core.li_height - 2) + "px",
1282
+ "width" : "150px" // will be set a bit further down
1283
+ },
1284
+ "blur" : $.proxy(function () {
1285
+ var i = obj.children(".jstree-rename-input"),
1286
+ v = i.val();
1287
+ if(v === "") { v = t; }
1288
+ i.remove(); // rollback purposes
1289
+ this.set_text(obj,t); // rollback purposes
1290
+ this.rename_node(obj, v);
1291
+ callback.call(this, obj, v, t);
1292
+ obj.css("position","");
1293
+ }, this),
1294
+ "keyup" : function (event) {
1295
+ var key = event.keyCode || event.which;
1296
+ if(key == 27) { this.value = t; this.blur(); return; }
1297
+ else if(key == 13) { this.blur(); return; }
1298
+ else {
1299
+ h2.width(Math.min(h1.text("pW" + this.value).width(),w));
1300
+ }
1301
+ },
1302
+ "keypress" : function(event) {
1303
+ var key = event.keyCode || event.which;
1304
+ if(key == 13) { return false; }
1305
+ }
1306
+ })
1307
+ ).children(".jstree-rename-input");
1308
+ this.set_text(obj, "");
1309
+ h1.css({
1310
+ fontFamily : h2.css('fontFamily') || '',
1311
+ fontSize : h2.css('fontSize') || '',
1312
+ fontWeight : h2.css('fontWeight') || '',
1313
+ fontStyle : h2.css('fontStyle') || '',
1314
+ fontStretch : h2.css('fontStretch') || '',
1315
+ fontVariant : h2.css('fontVariant') || '',
1316
+ letterSpacing : h2.css('letterSpacing') || '',
1317
+ wordSpacing : h2.css('wordSpacing') || ''
1318
+ });
1319
+ h2.width(Math.min(h1.text("pW" + h2[0].value).width(),w))[0].select();
1320
+ },
1321
+ rename : function (obj) {
1322
+ obj = this._get_node(obj);
1323
+ this.__rollback();
1324
+ var f = this.__callback;
1325
+ this._show_input(obj, function (obj, new_name, old_name) {
1326
+ f.call(this, { "obj" : obj, "new_name" : new_name, "old_name" : old_name });
1327
+ });
1328
+ },
1329
+ create : function (obj, position, js, callback, skip_rename) {
1330
+ var t, _this = this;
1331
+ obj = this._get_node(obj);
1332
+ if(!obj) { obj = -1; }
1333
+ this.__rollback();
1334
+ t = this.create_node(obj, position, js, function (t) {
1335
+ var p = this._get_parent(t),
1336
+ pos = $(t).index();
1337
+ if(callback) { callback.call(this, t); }
1338
+ if(p.length && p.hasClass("jstree-closed")) { this.open_node(p, false, true); }
1339
+ if(!skip_rename) {
1340
+ this._show_input(t, function (obj, new_name, old_name) {
1341
+ _this.__callback({ "obj" : obj, "name" : new_name, "parent" : p, "position" : pos });
1342
+ });
1343
+ }
1344
+ else { _this.__callback({ "obj" : t, "name" : this.get_text(t), "parent" : p, "position" : pos }); }
1345
+ });
1346
+ return t;
1347
+ },
1348
+ remove : function (obj) {
1349
+ obj = this._get_node(obj, true);
1350
+ var p = this._get_parent(obj), prev = this._get_prev(obj);
1351
+ this.__rollback();
1352
+ obj = this.delete_node(obj);
1353
+ if(obj !== false) { this.__callback({ "obj" : obj, "prev" : prev, "parent" : p }); }
1354
+ },
1355
+ check_move : function () {
1356
+ if(!this.__call_old()) { return false; }
1357
+ var s = this._get_settings().crrm.move;
1358
+ if(!s.check_move.call(this, this._get_move())) { return false; }
1359
+ return true;
1360
+ },
1361
+ move_node : function (obj, ref, position, is_copy, is_prepared, skip_check) {
1362
+ var s = this._get_settings().crrm.move;
1363
+ if(!is_prepared) {
1364
+ if(typeof position === "undefined") { position = s.default_position; }
1365
+ if(position === "inside" && !s.default_position.match(/^(before|after)$/)) { position = s.default_position; }
1366
+ return this.__call_old(true, obj, ref, position, is_copy, false, skip_check);
1367
+ }
1368
+ // if the move is already prepared
1369
+ if(s.always_copy === true || (s.always_copy === "multitree" && obj.rt.get_index() !== obj.ot.get_index() )) {
1370
+ is_copy = true;
1371
+ }
1372
+ this.__call_old(true, obj, ref, position, is_copy, true, skip_check);
1373
+ },
1374
+
1375
+ cut : function (obj) {
1376
+ obj = this._get_node(obj, true);
1377
+ if(!obj || !obj.length) { return false; }
1378
+ this.data.crrm.cp_nodes = false;
1379
+ this.data.crrm.ct_nodes = obj;
1380
+ this.__callback({ "obj" : obj });
1381
+ },
1382
+ copy : function (obj) {
1383
+ obj = this._get_node(obj, true);
1384
+ if(!obj || !obj.length) { return false; }
1385
+ this.data.crrm.ct_nodes = false;
1386
+ this.data.crrm.cp_nodes = obj;
1387
+ this.__callback({ "obj" : obj });
1388
+ },
1389
+ paste : function (obj) {
1390
+ obj = this._get_node(obj);
1391
+ if(!obj || !obj.length) { return false; }
1392
+ var nodes = this.data.crrm.ct_nodes ? this.data.crrm.ct_nodes : this.data.crrm.cp_nodes;
1393
+ if(!this.data.crrm.ct_nodes && !this.data.crrm.cp_nodes) { return false; }
1394
+ if(this.data.crrm.ct_nodes) { this.move_node(this.data.crrm.ct_nodes, obj); this.data.crrm.ct_nodes = false; }
1395
+ if(this.data.crrm.cp_nodes) { this.move_node(this.data.crrm.cp_nodes, obj, false, true); }
1396
+ this.__callback({ "obj" : obj, "nodes" : nodes });
1397
+ }
1398
+ }
1399
+ });
1400
+ // include the crr plugin by default
1401
+ // $.jstree.defaults.plugins.push("crrm");
1402
+ })(jQuery);
1403
+ //*/
1404
+
1405
+ /*
1406
+ * jsTree themes plugin
1407
+ * Handles loading and setting themes, as well as detecting path to themes, etc.
1408
+ */
1409
+ (function ($) {
1410
+ var themes_loaded = [];
1411
+ // this variable stores the path to the themes folder - if left as false - it will be autodetected
1412
+ $.jstree._themes = false;
1413
+ $.jstree.plugin("themes", {
1414
+ __init : function () {
1415
+ this.get_container()
1416
+ .bind("init.jstree", $.proxy(function () {
1417
+ var s = this._get_settings().themes;
1418
+ this.data.themes.dots = s.dots;
1419
+ this.data.themes.icons = s.icons;
1420
+ this.set_theme(s.theme, s.url);
1421
+ }, this))
1422
+ .bind("loaded.jstree", $.proxy(function () {
1423
+ // bound here too, as simple HTML tree's won't honor dots & icons otherwise
1424
+ if(!this.data.themes.dots) { this.hide_dots(); }
1425
+ else { this.show_dots(); }
1426
+ if(!this.data.themes.icons) { this.hide_icons(); }
1427
+ else { this.show_icons(); }
1428
+ }, this));
1429
+ },
1430
+ defaults : {
1431
+ theme : "default",
1432
+ url : false,
1433
+ dots : true,
1434
+ icons : true
1435
+ },
1436
+ _fn : {
1437
+ set_theme : function (theme_name, theme_url) {
1438
+ if(!theme_name) { return false; }
1439
+ if(!theme_url) { theme_url = $.jstree._themes + theme_name + '/style.css'; }
1440
+ if($.inArray(theme_url, themes_loaded) == -1) {
1441
+ $.vakata.css.add_sheet({ "url" : theme_url });
1442
+ themes_loaded.push(theme_url);
1443
+ }
1444
+ if(this.data.themes.theme != theme_name) {
1445
+ this.get_container().removeClass('jstree-' + this.data.themes.theme);
1446
+ this.data.themes.theme = theme_name;
1447
+ }
1448
+ this.get_container().addClass('jstree-' + theme_name);
1449
+ if(!this.data.themes.dots) { this.hide_dots(); }
1450
+ else { this.show_dots(); }
1451
+ if(!this.data.themes.icons) { this.hide_icons(); }
1452
+ else { this.show_icons(); }
1453
+ this.__callback();
1454
+ },
1455
+ get_theme : function () { return this.data.themes.theme; },
1456
+
1457
+ show_dots : function () { this.data.themes.dots = true; this.get_container().children("ul").removeClass("jstree-no-dots"); },
1458
+ hide_dots : function () { this.data.themes.dots = false; this.get_container().children("ul").addClass("jstree-no-dots"); },
1459
+ toggle_dots : function () { if(this.data.themes.dots) { this.hide_dots(); } else { this.show_dots(); } },
1460
+
1461
+ show_icons : function () { this.data.themes.icons = true; this.get_container().children("ul").removeClass("jstree-no-icons"); },
1462
+ hide_icons : function () { this.data.themes.icons = false; this.get_container().children("ul").addClass("jstree-no-icons"); },
1463
+ toggle_icons: function () { if(this.data.themes.icons) { this.hide_icons(); } else { this.show_icons(); } }
1464
+ }
1465
+ });
1466
+ // autodetect themes path
1467
+ $(function () {
1468
+ if($.jstree._themes === false) {
1469
+ $("script").each(function () {
1470
+ if(this.src.toString().match(/jquery\.jstree[^\/]*?\.js(\?.*)?$/)) {
1471
+ $.jstree._themes = this.src.toString().replace(/jquery\.jstree[^\/]*?\.js(\?.*)?$/, "") + 'themes/';
1472
+ return false;
1473
+ }
1474
+ });
1475
+ }
1476
+ if($.jstree._themes === false) { $.jstree._themes = "themes/"; }
1477
+ });
1478
+ // include the themes plugin by default
1479
+ $.jstree.defaults.plugins.push("themes");
1480
+ })(jQuery);
1481
+ //*/
1482
+
1483
+ /*
1484
+ * jsTree hotkeys plugin
1485
+ * Enables keyboard navigation for all tree instances
1486
+ * Depends on the jstree ui & jquery hotkeys plugins
1487
+ */
1488
+ (function ($) {
1489
+ var bound = [];
1490
+ function exec(i, event) {
1491
+ var f = $.jstree._focused(), tmp;
1492
+ if(f && f.data && f.data.hotkeys && f.data.hotkeys.enabled) {
1493
+ tmp = f._get_settings().hotkeys[i];
1494
+ if(tmp) { return tmp.call(f, event); }
1495
+ }
1496
+ }
1497
+ $.jstree.plugin("hotkeys", {
1498
+ __init : function () {
1499
+ if(typeof $.hotkeys === "undefined") { throw "jsTree hotkeys: jQuery hotkeys plugin not included."; }
1500
+ if(!this.data.ui) { throw "jsTree hotkeys: jsTree UI plugin not included."; }
1501
+ $.each(this._get_settings().hotkeys, function (i, v) {
1502
+ if(v !== false && $.inArray(i, bound) == -1) {
1503
+ $(document).bind("keydown", i, function (event) { return exec(i, event); });
1504
+ bound.push(i);
1505
+ }
1506
+ });
1507
+ this.get_container()
1508
+ .bind("lock.jstree", $.proxy(function () {
1509
+ if(this.data.hotkeys.enabled) { this.data.hotkeys.enabled = false; this.data.hotkeys.revert = true; }
1510
+ }, this))
1511
+ .bind("unlock.jstree", $.proxy(function () {
1512
+ if(this.data.hotkeys.revert) { this.data.hotkeys.enabled = true; }
1513
+ }, this));
1514
+ this.enable_hotkeys();
1515
+ },
1516
+ defaults : {
1517
+ "up" : function () {
1518
+ var o = this.data.ui.hovered || this.data.ui.last_selected || -1;
1519
+ this.hover_node(this._get_prev(o));
1520
+ return false;
1521
+ },
1522
+ "ctrl+up" : function () {
1523
+ var o = this.data.ui.hovered || this.data.ui.last_selected || -1;
1524
+ this.hover_node(this._get_prev(o));
1525
+ return false;
1526
+ },
1527
+ "shift+up" : function () {
1528
+ var o = this.data.ui.hovered || this.data.ui.last_selected || -1;
1529
+ this.hover_node(this._get_prev(o));
1530
+ return false;
1531
+ },
1532
+ "down" : function () {
1533
+ var o = this.data.ui.hovered || this.data.ui.last_selected || -1;
1534
+ this.hover_node(this._get_next(o));
1535
+ return false;
1536
+ },
1537
+ "ctrl+down" : function () {
1538
+ var o = this.data.ui.hovered || this.data.ui.last_selected || -1;
1539
+ this.hover_node(this._get_next(o));
1540
+ return false;
1541
+ },
1542
+ "shift+down" : function () {
1543
+ var o = this.data.ui.hovered || this.data.ui.last_selected || -1;
1544
+ this.hover_node(this._get_next(o));
1545
+ return false;
1546
+ },
1547
+ "left" : function () {
1548
+ var o = this.data.ui.hovered || this.data.ui.last_selected;
1549
+ if(o) {
1550
+ if(o.hasClass("jstree-open")) { this.close_node(o); }
1551
+ else { this.hover_node(this._get_prev(o)); }
1552
+ }
1553
+ return false;
1554
+ },
1555
+ "ctrl+left" : function () {
1556
+ var o = this.data.ui.hovered || this.data.ui.last_selected;
1557
+ if(o) {
1558
+ if(o.hasClass("jstree-open")) { this.close_node(o); }
1559
+ else { this.hover_node(this._get_prev(o)); }
1560
+ }
1561
+ return false;
1562
+ },
1563
+ "shift+left" : function () {
1564
+ var o = this.data.ui.hovered || this.data.ui.last_selected;
1565
+ if(o) {
1566
+ if(o.hasClass("jstree-open")) { this.close_node(o); }
1567
+ else { this.hover_node(this._get_prev(o)); }
1568
+ }
1569
+ return false;
1570
+ },
1571
+ "right" : function () {
1572
+ var o = this.data.ui.hovered || this.data.ui.last_selected;
1573
+ if(o && o.length) {
1574
+ if(o.hasClass("jstree-closed")) { this.open_node(o); }
1575
+ else { this.hover_node(this._get_next(o)); }
1576
+ }
1577
+ return false;
1578
+ },
1579
+ "ctrl+right" : function () {
1580
+ var o = this.data.ui.hovered || this.data.ui.last_selected;
1581
+ if(o && o.length) {
1582
+ if(o.hasClass("jstree-closed")) { this.open_node(o); }
1583
+ else { this.hover_node(this._get_next(o)); }
1584
+ }
1585
+ return false;
1586
+ },
1587
+ "shift+right" : function () {
1588
+ var o = this.data.ui.hovered || this.data.ui.last_selected;
1589
+ if(o && o.length) {
1590
+ if(o.hasClass("jstree-closed")) { this.open_node(o); }
1591
+ else { this.hover_node(this._get_next(o)); }
1592
+ }
1593
+ return false;
1594
+ },
1595
+ "space" : function () {
1596
+ if(this.data.ui.hovered) { this.data.ui.hovered.children("a:eq(0)").click(); }
1597
+ return false;
1598
+ },
1599
+ "ctrl+space" : function (event) {
1600
+ event.type = "click";
1601
+ if(this.data.ui.hovered) { this.data.ui.hovered.children("a:eq(0)").trigger(event); }
1602
+ return false;
1603
+ },
1604
+ "shift+space" : function (event) {
1605
+ event.type = "click";
1606
+ if(this.data.ui.hovered) { this.data.ui.hovered.children("a:eq(0)").trigger(event); }
1607
+ return false;
1608
+ },
1609
+ "f2" : function () { this.rename(this.data.ui.hovered || this.data.ui.last_selected); },
1610
+ "del" : function () { this.remove(this.data.ui.hovered || this._get_node(null)); }
1611
+ },
1612
+ _fn : {
1613
+ enable_hotkeys : function () {
1614
+ this.data.hotkeys.enabled = true;
1615
+ },
1616
+ disable_hotkeys : function () {
1617
+ this.data.hotkeys.enabled = false;
1618
+ }
1619
+ }
1620
+ });
1621
+ })(jQuery);
1622
+ //*/
1623
+
1624
+ /*
1625
+ * jsTree JSON plugin
1626
+ * The JSON data store. Datastores are build by overriding the `load_node` and `_is_loaded` functions.
1627
+ */
1628
+ (function ($) {
1629
+ $.jstree.plugin("json_data", {
1630
+ __init : function() {
1631
+ var s = this._get_settings().json_data;
1632
+ if(s.progressive_unload) {
1633
+ this.get_container().bind("after_close.jstree", function (e, data) {
1634
+ data.rslt.obj.children("ul").remove();
1635
+ });
1636
+ }
1637
+ },
1638
+ defaults : {
1639
+ // `data` can be a function:
1640
+ // * accepts two arguments - node being loaded and a callback to pass the result to
1641
+ // * will be executed in the current tree's scope & ajax won't be supported
1642
+ data : false,
1643
+ ajax : false,
1644
+ correct_state : true,
1645
+ progressive_render : false,
1646
+ progressive_unload : false
1647
+ },
1648
+ _fn : {
1649
+ load_node : function (obj, s_call, e_call) { var _this = this; this.load_node_json(obj, function () { _this.__callback({ "obj" : _this._get_node(obj) }); s_call.call(this); }, e_call); },
1650
+ _is_loaded : function (obj) {
1651
+ var s = this._get_settings().json_data;
1652
+ obj = this._get_node(obj);
1653
+ return obj == -1 || !obj || (!s.ajax && !s.progressive_render && !$.isFunction(s.data)) || obj.is(".jstree-open, .jstree-leaf") || obj.children("ul").children("li").length > 0;
1654
+ },
1655
+ refresh : function (obj) {
1656
+ obj = this._get_node(obj);
1657
+ var s = this._get_settings().json_data;
1658
+ if(obj && obj !== -1 && s.progressive_unload && ($.isFunction(s.data) || !!s.ajax)) {
1659
+ obj.removeData("jstree-children");
1660
+ }
1661
+ return this.__call_old();
1662
+ },
1663
+ load_node_json : function (obj, s_call, e_call) {
1664
+ var s = this.get_settings().json_data, d,
1665
+ error_func = function () {},
1666
+ success_func = function () {};
1667
+ obj = this._get_node(obj);
1668
+
1669
+ if(obj && obj !== -1 && (s.progressive_render || s.progressive_unload) && !obj.is(".jstree-open, .jstree-leaf") && obj.children("ul").children("li").length === 0 && obj.data("jstree-children")) {
1670
+ d = this._parse_json(obj.data("jstree-children"), obj);
1671
+ if(d) {
1672
+ obj.append(d);
1673
+ if(!s.progressive_unload) { obj.removeData("jstree-children"); }
1674
+ }
1675
+ this.clean_node(obj);
1676
+ if(s_call) { s_call.call(this); }
1677
+ return;
1678
+ }
1679
+
1680
+ if(obj && obj !== -1) {
1681
+ if(obj.data("jstree-is-loading")) { return; }
1682
+ else { obj.data("jstree-is-loading",true); }
1683
+ }
1684
+ switch(!0) {
1685
+ case (!s.data && !s.ajax): throw "Neither data nor ajax settings supplied.";
1686
+ // function option added here for easier model integration (also supporting async - see callback)
1687
+ case ($.isFunction(s.data)):
1688
+ s.data.call(this, obj, $.proxy(function (d) {
1689
+ d = this._parse_json(d, obj);
1690
+ if(!d) {
1691
+ if(obj === -1 || !obj) {
1692
+ if(s.correct_state) { this.get_container().children("ul").empty(); }
1693
+ }
1694
+ else {
1695
+ obj.children("a.jstree-loading").removeClass("jstree-loading");
1696
+ obj.removeData("jstree-is-loading");
1697
+ if(s.correct_state) { this.correct_state(obj); }
1698
+ }
1699
+ if(e_call) { e_call.call(this); }
1700
+ }
1701
+ else {
1702
+ if(obj === -1 || !obj) { this.get_container().children("ul").empty().append(d.children()); }
1703
+ else { obj.append(d).children("a.jstree-loading").removeClass("jstree-loading"); obj.removeData("jstree-is-loading"); }
1704
+ this.clean_node(obj);
1705
+ if(s_call) { s_call.call(this); }
1706
+ }
1707
+ }, this));
1708
+ break;
1709
+ case (!!s.data && !s.ajax) || (!!s.data && !!s.ajax && (!obj || obj === -1)):
1710
+ if(!obj || obj == -1) {
1711
+ d = this._parse_json(s.data, obj);
1712
+ if(d) {
1713
+ this.get_container().children("ul").empty().append(d.children());
1714
+ this.clean_node();
1715
+ }
1716
+ else {
1717
+ if(s.correct_state) { this.get_container().children("ul").empty(); }
1718
+ }
1719
+ }
1720
+ if(s_call) { s_call.call(this); }
1721
+ break;
1722
+ case (!s.data && !!s.ajax) || (!!s.data && !!s.ajax && obj && obj !== -1):
1723
+ error_func = function (x, t, e) {
1724
+ var ef = this.get_settings().json_data.ajax.error;
1725
+ if(ef) { ef.call(this, x, t, e); }
1726
+ if(obj != -1 && obj.length) {
1727
+ obj.children("a.jstree-loading").removeClass("jstree-loading");
1728
+ obj.removeData("jstree-is-loading");
1729
+ if(t === "success" && s.correct_state) { this.correct_state(obj); }
1730
+ }
1731
+ else {
1732
+ if(t === "success" && s.correct_state) { this.get_container().children("ul").empty(); }
1733
+ }
1734
+ if(e_call) { e_call.call(this); }
1735
+ };
1736
+ success_func = function (d, t, x) {
1737
+ var sf = this.get_settings().json_data.ajax.success;
1738
+ if(sf) { d = sf.call(this,d,t,x) || d; }
1739
+ if(d === "" || (d && d.toString && d.toString().replace(/^[\s\n]+$/,"") === "") || (!$.isArray(d) && !$.isPlainObject(d))) {
1740
+ return error_func.call(this, x, t, "");
1741
+ }
1742
+ d = this._parse_json(d, obj);
1743
+ if(d) {
1744
+ if(obj === -1 || !obj) { this.get_container().children("ul").empty().append(d.children()); }
1745
+ else { obj.append(d).children("a.jstree-loading").removeClass("jstree-loading"); obj.removeData("jstree-is-loading"); }
1746
+ this.clean_node(obj);
1747
+ if(s_call) { s_call.call(this); }
1748
+ }
1749
+ else {
1750
+ if(obj === -1 || !obj) {
1751
+ if(s.correct_state) {
1752
+ this.get_container().children("ul").empty();
1753
+ if(s_call) { s_call.call(this); }
1754
+ }
1755
+ }
1756
+ else {
1757
+ obj.children("a.jstree-loading").removeClass("jstree-loading");
1758
+ obj.removeData("jstree-is-loading");
1759
+ if(s.correct_state) {
1760
+ this.correct_state(obj);
1761
+ if(s_call) { s_call.call(this); }
1762
+ }
1763
+ }
1764
+ }
1765
+ };
1766
+ s.ajax.context = this;
1767
+ s.ajax.error = error_func;
1768
+ s.ajax.success = success_func;
1769
+ if(!s.ajax.dataType) { s.ajax.dataType = "json"; }
1770
+ if($.isFunction(s.ajax.url)) { s.ajax.url = s.ajax.url.call(this, obj); }
1771
+ if($.isFunction(s.ajax.data)) { s.ajax.data = s.ajax.data.call(this, obj); }
1772
+ $.ajax(s.ajax);
1773
+ break;
1774
+ }
1775
+ },
1776
+ _parse_json : function (js, obj, is_callback) {
1777
+ var d = false,
1778
+ p = this._get_settings(),
1779
+ s = p.json_data,
1780
+ t = p.core.html_titles,
1781
+ tmp, i, j, ul1, ul2;
1782
+
1783
+ if(!js) { return d; }
1784
+ if(s.progressive_unload && obj && obj !== -1) {
1785
+ obj.data("jstree-children", d);
1786
+ }
1787
+ if($.isArray(js)) {
1788
+ d = $();
1789
+ if(!js.length) { return false; }
1790
+ for(i = 0, j = js.length; i < j; i++) {
1791
+ tmp = this._parse_json(js[i], obj, true);
1792
+ if(tmp.length) { d = d.add(tmp); }
1793
+ }
1794
+ }
1795
+ else {
1796
+ if(typeof js == "string") { js = { data : js }; }
1797
+ if(!js.data && js.data !== "") { return d; }
1798
+ d = $("<li />");
1799
+ if(js.attr) { d.attr(js.attr); }
1800
+ if(js.metadata) { d.data(js.metadata); }
1801
+ if(js.state) { d.addClass("jstree-" + js.state); }
1802
+ if(!$.isArray(js.data)) { tmp = js.data; js.data = []; js.data.push(tmp); }
1803
+ $.each(js.data, function (i, m) {
1804
+ tmp = $("<a />");
1805
+ if($.isFunction(m)) { m = m.call(this, js); }
1806
+ if(typeof m == "string") { tmp.attr('href','#')[ t ? "html" : "text" ](m); }
1807
+ else {
1808
+ if(!m.attr) { m.attr = {}; }
1809
+ if(!m.attr.href) { m.attr.href = '#'; }
1810
+ tmp.attr(m.attr)[ t ? "html" : "text" ](m.title);
1811
+ if(m.language) { tmp.addClass(m.language); }
1812
+ }
1813
+ tmp.prepend("<ins class='jstree-icon'>&#160;</ins>");
1814
+ if(!m.icon && js.icon) { m.icon = js.icon; }
1815
+ if(m.icon) {
1816
+ if(m.icon.indexOf("/") === -1) { tmp.children("ins").addClass(m.icon); }
1817
+ else { tmp.children("ins").css("background","url('" + m.icon + "') center center no-repeat"); }
1818
+ }
1819
+ d.append(tmp);
1820
+ });
1821
+ d.prepend("<ins class='jstree-icon'>&#160;</ins>");
1822
+ if(js.children) {
1823
+ if(s.progressive_render && js.state !== "open") {
1824
+ d.addClass("jstree-closed").data("jstree-children", js.children);
1825
+ }
1826
+ else {
1827
+ if(s.progressive_unload) { d.data("jstree-children", js.children); }
1828
+ if($.isArray(js.children) && js.children.length) {
1829
+ tmp = this._parse_json(js.children, obj, true);
1830
+ if(tmp.length) {
1831
+ ul2 = $("<ul />");
1832
+ ul2.append(tmp);
1833
+ d.append(ul2);
1834
+ }
1835
+ }
1836
+ }
1837
+ }
1838
+ }
1839
+ if(!is_callback) {
1840
+ ul1 = $("<ul />");
1841
+ ul1.append(d);
1842
+ d = ul1;
1843
+ }
1844
+ return d;
1845
+ },
1846
+ get_json : function (obj, li_attr, a_attr, is_callback) {
1847
+ var result = [],
1848
+ s = this._get_settings(),
1849
+ _this = this,
1850
+ tmp1, tmp2, li, a, t, lang;
1851
+ obj = this._get_node(obj);
1852
+ if(!obj || obj === -1) { obj = this.get_container().find("> ul > li"); }
1853
+ li_attr = $.isArray(li_attr) ? li_attr : [ "id", "class" ];
1854
+ if(!is_callback && this.data.types) { li_attr.push(s.types.type_attr); }
1855
+ a_attr = $.isArray(a_attr) ? a_attr : [ ];
1856
+
1857
+ obj.each(function () {
1858
+ li = $(this);
1859
+ tmp1 = { data : [] };
1860
+ if(li_attr.length) { tmp1.attr = { }; }
1861
+ $.each(li_attr, function (i, v) {
1862
+ tmp2 = li.attr(v);
1863
+ if(tmp2 && tmp2.length && tmp2.replace(/jstree[^ ]*/ig,'').length) {
1864
+ tmp1.attr[v] = (" " + tmp2).replace(/ jstree[^ ]*/ig,'').replace(/\s+$/ig," ").replace(/^ /,"").replace(/ $/,"");
1865
+ }
1866
+ });
1867
+ if(li.hasClass("jstree-open")) { tmp1.state = "open"; }
1868
+ if(li.hasClass("jstree-closed")) { tmp1.state = "closed"; }
1869
+ if(li.data()) { tmp1.metadata = li.data(); }
1870
+ a = li.children("a");
1871
+ a.each(function () {
1872
+ t = $(this);
1873
+ if(
1874
+ a_attr.length ||
1875
+ $.inArray("languages", s.plugins) !== -1 ||
1876
+ t.children("ins").get(0).style.backgroundImage.length ||
1877
+ (t.children("ins").get(0).className && t.children("ins").get(0).className.replace(/jstree[^ ]*|$/ig,'').length)
1878
+ ) {
1879
+ lang = false;
1880
+ if($.inArray("languages", s.plugins) !== -1 && $.isArray(s.languages) && s.languages.length) {
1881
+ $.each(s.languages, function (l, lv) {
1882
+ if(t.hasClass(lv)) {
1883
+ lang = lv;
1884
+ return false;
1885
+ }
1886
+ });
1887
+ }
1888
+ tmp2 = { attr : { }, title : _this.get_text(t, lang) };
1889
+ $.each(a_attr, function (k, z) {
1890
+ tmp2.attr[z] = (" " + (t.attr(z) || "")).replace(/ jstree[^ ]*/ig,'').replace(/\s+$/ig," ").replace(/^ /,"").replace(/ $/,"");
1891
+ });
1892
+ if($.inArray("languages", s.plugins) !== -1 && $.isArray(s.languages) && s.languages.length) {
1893
+ $.each(s.languages, function (k, z) {
1894
+ if(t.hasClass(z)) { tmp2.language = z; return true; }
1895
+ });
1896
+ }
1897
+ if(t.children("ins").get(0).className.replace(/jstree[^ ]*|$/ig,'').replace(/^\s+$/ig,"").length) {
1898
+ tmp2.icon = t.children("ins").get(0).className.replace(/jstree[^ ]*|$/ig,'').replace(/\s+$/ig," ").replace(/^ /,"").replace(/ $/,"");
1899
+ }
1900
+ if(t.children("ins").get(0).style.backgroundImage.length) {
1901
+ tmp2.icon = t.children("ins").get(0).style.backgroundImage.replace("url(","").replace(")","");
1902
+ }
1903
+ }
1904
+ else {
1905
+ tmp2 = _this.get_text(t);
1906
+ }
1907
+ if(a.length > 1) { tmp1.data.push(tmp2); }
1908
+ else { tmp1.data = tmp2; }
1909
+ });
1910
+ li = li.find("> ul > li");
1911
+ if(li.length) { tmp1.children = _this.get_json(li, li_attr, a_attr, true); }
1912
+ result.push(tmp1);
1913
+ });
1914
+ return result;
1915
+ }
1916
+ }
1917
+ });
1918
+ })(jQuery);
1919
+ //*/
1920
+
1921
+ /*
1922
+ * jsTree languages plugin
1923
+ * Adds support for multiple language versions in one tree
1924
+ * This basically allows for many titles coexisting in one node, but only one of them being visible at any given time
1925
+ * This is useful for maintaining the same structure in many languages (hence the name of the plugin)
1926
+ */
1927
+ (function ($) {
1928
+ $.jstree.plugin("languages", {
1929
+ __init : function () { this._load_css(); },
1930
+ defaults : [],
1931
+ _fn : {
1932
+ set_lang : function (i) {
1933
+ var langs = this._get_settings().languages,
1934
+ st = false,
1935
+ selector = ".jstree-" + this.get_index() + ' a';
1936
+ if(!$.isArray(langs) || langs.length === 0) { return false; }
1937
+ if($.inArray(i,langs) == -1) {
1938
+ if(!!langs[i]) { i = langs[i]; }
1939
+ else { return false; }
1940
+ }
1941
+ if(i == this.data.languages.current_language) { return true; }
1942
+ st = $.vakata.css.get_css(selector + "." + this.data.languages.current_language, false, this.data.languages.language_css);
1943
+ if(st !== false) { st.style.display = "none"; }
1944
+ st = $.vakata.css.get_css(selector + "." + i, false, this.data.languages.language_css);
1945
+ if(st !== false) { st.style.display = ""; }
1946
+ this.data.languages.current_language = i;
1947
+ this.__callback(i);
1948
+ return true;
1949
+ },
1950
+ get_lang : function () {
1951
+ return this.data.languages.current_language;
1952
+ },
1953
+ _get_string : function (key, lang) {
1954
+ var langs = this._get_settings().languages,
1955
+ s = this._get_settings().core.strings;
1956
+ if($.isArray(langs) && langs.length) {
1957
+ lang = (lang && $.inArray(lang,langs) != -1) ? lang : this.data.languages.current_language;
1958
+ }
1959
+ if(s[lang] && s[lang][key]) { return s[lang][key]; }
1960
+ if(s[key]) { return s[key]; }
1961
+ return key;
1962
+ },
1963
+ get_text : function (obj, lang) {
1964
+ obj = this._get_node(obj) || this.data.ui.last_selected;
1965
+ if(!obj.size()) { return false; }
1966
+ var langs = this._get_settings().languages,
1967
+ s = this._get_settings().core.html_titles;
1968
+ if($.isArray(langs) && langs.length) {
1969
+ lang = (lang && $.inArray(lang,langs) != -1) ? lang : this.data.languages.current_language;
1970
+ obj = obj.children("a." + lang);
1971
+ }
1972
+ else { obj = obj.children("a:eq(0)"); }
1973
+ if(s) {
1974
+ obj = obj.clone();
1975
+ obj.children("INS").remove();
1976
+ return obj.html();
1977
+ }
1978
+ else {
1979
+ obj = obj.contents().filter(function() { return this.nodeType == 3; })[0];
1980
+ return obj.nodeValue;
1981
+ }
1982
+ },
1983
+ set_text : function (obj, val, lang) {
1984
+ obj = this._get_node(obj) || this.data.ui.last_selected;
1985
+ if(!obj.size()) { return false; }
1986
+ var langs = this._get_settings().languages,
1987
+ s = this._get_settings().core.html_titles,
1988
+ tmp;
1989
+ if($.isArray(langs) && langs.length) {
1990
+ lang = (lang && $.inArray(lang,langs) != -1) ? lang : this.data.languages.current_language;
1991
+ obj = obj.children("a." + lang);
1992
+ }
1993
+ else { obj = obj.children("a:eq(0)"); }
1994
+ if(s) {
1995
+ tmp = obj.children("INS").clone();
1996
+ obj.html(val).prepend(tmp);
1997
+ this.__callback({ "obj" : obj, "name" : val, "lang" : lang });
1998
+ return true;
1999
+ }
2000
+ else {
2001
+ obj = obj.contents().filter(function() { return this.nodeType == 3; })[0];
2002
+ this.__callback({ "obj" : obj, "name" : val, "lang" : lang });
2003
+ return (obj.nodeValue = val);
2004
+ }
2005
+ },
2006
+ _load_css : function () {
2007
+ var langs = this._get_settings().languages,
2008
+ str = "/* languages css */",
2009
+ selector = ".jstree-" + this.get_index() + ' a',
2010
+ ln;
2011
+ if($.isArray(langs) && langs.length) {
2012
+ this.data.languages.current_language = langs[0];
2013
+ for(ln = 0; ln < langs.length; ln++) {
2014
+ str += selector + "." + langs[ln] + " {";
2015
+ if(langs[ln] != this.data.languages.current_language) { str += " display:none; "; }
2016
+ str += " } ";
2017
+ }
2018
+ this.data.languages.language_css = $.vakata.css.add_sheet({ 'str' : str, 'title' : "jstree-languages" });
2019
+ }
2020
+ },
2021
+ create_node : function (obj, position, js, callback) {
2022
+ var t = this.__call_old(true, obj, position, js, function (t) {
2023
+ var langs = this._get_settings().languages,
2024
+ a = t.children("a"),
2025
+ ln;
2026
+ if($.isArray(langs) && langs.length) {
2027
+ for(ln = 0; ln < langs.length; ln++) {
2028
+ if(!a.is("." + langs[ln])) {
2029
+ t.append(a.eq(0).clone().removeClass(langs.join(" ")).addClass(langs[ln]));
2030
+ }
2031
+ }
2032
+ a.not("." + langs.join(", .")).remove();
2033
+ }
2034
+ if(callback) { callback.call(this, t); }
2035
+ });
2036
+ return t;
2037
+ }
2038
+ }
2039
+ });
2040
+ })(jQuery);
2041
+ //*/
2042
+
2043
+ /*
2044
+ * jsTree cookies plugin
2045
+ * Stores the currently opened/selected nodes in a cookie and then restores them
2046
+ * Depends on the jquery.cookie plugin
2047
+ */
2048
+ (function ($) {
2049
+ $.jstree.plugin("cookies", {
2050
+ __init : function () {
2051
+ if(typeof $.cookie === "undefined") { throw "jsTree cookie: jQuery cookie plugin not included."; }
2052
+
2053
+ var s = this._get_settings().cookies,
2054
+ tmp;
2055
+ if(!!s.save_loaded) {
2056
+ tmp = $.cookie(s.save_loaded);
2057
+ if(tmp && tmp.length) { this.data.core.to_load = tmp.split(","); }
2058
+ }
2059
+ if(!!s.save_opened) {
2060
+ tmp = $.cookie(s.save_opened);
2061
+ if(tmp && tmp.length) { this.data.core.to_open = tmp.split(","); }
2062
+ }
2063
+ if(!!s.save_selected) {
2064
+ tmp = $.cookie(s.save_selected);
2065
+ if(tmp && tmp.length && this.data.ui) { this.data.ui.to_select = tmp.split(","); }
2066
+ }
2067
+ this.get_container()
2068
+ .one( ( this.data.ui ? "reselect" : "reopen" ) + ".jstree", $.proxy(function () {
2069
+ this.get_container()
2070
+ .bind("open_node.jstree close_node.jstree select_node.jstree deselect_node.jstree", $.proxy(function (e) {
2071
+ if(this._get_settings().cookies.auto_save) { this.save_cookie((e.handleObj.namespace + e.handleObj.type).replace("jstree","")); }
2072
+ }, this));
2073
+ }, this));
2074
+ },
2075
+ defaults : {
2076
+ save_loaded : "jstree_load",
2077
+ save_opened : "jstree_open",
2078
+ save_selected : "jstree_select",
2079
+ auto_save : true,
2080
+ cookie_options : {}
2081
+ },
2082
+ _fn : {
2083
+ save_cookie : function (c) {
2084
+ if(this.data.core.refreshing) { return; }
2085
+ var s = this._get_settings().cookies;
2086
+ if(!c) { // if called manually and not by event
2087
+ if(s.save_loaded) {
2088
+ this.save_loaded();
2089
+ $.cookie(s.save_loaded, this.data.core.to_load.join(","), s.cookie_options);
2090
+ }
2091
+ if(s.save_opened) {
2092
+ this.save_opened();
2093
+ $.cookie(s.save_opened, this.data.core.to_open.join(","), s.cookie_options);
2094
+ }
2095
+ if(s.save_selected && this.data.ui) {
2096
+ this.save_selected();
2097
+ $.cookie(s.save_selected, this.data.ui.to_select.join(","), s.cookie_options);
2098
+ }
2099
+ return;
2100
+ }
2101
+ switch(c) {
2102
+ case "open_node":
2103
+ case "close_node":
2104
+ if(!!s.save_opened) {
2105
+ this.save_opened();
2106
+ $.cookie(s.save_opened, this.data.core.to_open.join(","), s.cookie_options);
2107
+ }
2108
+ if(!!s.save_loaded) {
2109
+ this.save_loaded();
2110
+ $.cookie(s.save_loaded, this.data.core.to_load.join(","), s.cookie_options);
2111
+ }
2112
+ break;
2113
+ case "select_node":
2114
+ case "deselect_node":
2115
+ if(!!s.save_selected && this.data.ui) {
2116
+ this.save_selected();
2117
+ $.cookie(s.save_selected, this.data.ui.to_select.join(","), s.cookie_options);
2118
+ }
2119
+ break;
2120
+ }
2121
+ }
2122
+ }
2123
+ });
2124
+ // include cookies by default
2125
+ // $.jstree.defaults.plugins.push("cookies");
2126
+ })(jQuery);
2127
+ //*/
2128
+
2129
+ /*
2130
+ * jsTree sort plugin
2131
+ * Sorts items alphabetically (or using any other function)
2132
+ */
2133
+ (function ($) {
2134
+ $.jstree.plugin("sort", {
2135
+ __init : function () {
2136
+ this.get_container()
2137
+ .bind("load_node.jstree", $.proxy(function (e, data) {
2138
+ var obj = this._get_node(data.rslt.obj);
2139
+ obj = obj === -1 ? this.get_container().children("ul") : obj.children("ul");
2140
+ this.sort(obj);
2141
+ }, this))
2142
+ .bind("rename_node.jstree create_node.jstree create.jstree", $.proxy(function (e, data) {
2143
+ this.sort(data.rslt.obj.parent());
2144
+ }, this))
2145
+ .bind("move_node.jstree", $.proxy(function (e, data) {
2146
+ var m = data.rslt.np == -1 ? this.get_container() : data.rslt.np;
2147
+ this.sort(m.children("ul"));
2148
+ }, this));
2149
+ },
2150
+ defaults : function (a, b) { return this.get_text(a) > this.get_text(b) ? 1 : -1; },
2151
+ _fn : {
2152
+ sort : function (obj) {
2153
+ var s = this._get_settings().sort,
2154
+ t = this;
2155
+ obj.append($.makeArray(obj.children("li")).sort($.proxy(s, t)));
2156
+ obj.find("> li > ul").each(function() { t.sort($(this)); });
2157
+ this.clean_node(obj);
2158
+ }
2159
+ }
2160
+ });
2161
+ })(jQuery);
2162
+ //*/
2163
+
2164
+ /*
2165
+ * jsTree DND plugin
2166
+ * Drag and drop plugin for moving/copying nodes
2167
+ */
2168
+ (function ($) {
2169
+ var o = false,
2170
+ r = false,
2171
+ m = false,
2172
+ ml = false,
2173
+ sli = false,
2174
+ sti = false,
2175
+ dir1 = false,
2176
+ dir2 = false,
2177
+ last_pos = false;
2178
+ $.vakata.dnd = {
2179
+ is_down : false,
2180
+ is_drag : false,
2181
+ helper : false,
2182
+ scroll_spd : 10,
2183
+ init_x : 0,
2184
+ init_y : 0,
2185
+ threshold : 5,
2186
+ helper_left : 5,
2187
+ helper_top : 10,
2188
+ user_data : {},
2189
+
2190
+ drag_start : function (e, data, html) {
2191
+ if($.vakata.dnd.is_drag) { $.vakata.drag_stop({}); }
2192
+ try {
2193
+ e.currentTarget.unselectable = "on";
2194
+ e.currentTarget.onselectstart = function() { return false; };
2195
+ if(e.currentTarget.style) { e.currentTarget.style.MozUserSelect = "none"; }
2196
+ } catch(err) { }
2197
+ $.vakata.dnd.init_x = e.pageX;
2198
+ $.vakata.dnd.init_y = e.pageY;
2199
+ $.vakata.dnd.user_data = data;
2200
+ $.vakata.dnd.is_down = true;
2201
+ $.vakata.dnd.helper = $("<div id='vakata-dragged' />").html(html); //.fadeTo(10,0.25);
2202
+ $(document).bind("mousemove", $.vakata.dnd.drag);
2203
+ $(document).bind("mouseup", $.vakata.dnd.drag_stop);
2204
+ return false;
2205
+ },
2206
+ drag : function (e) {
2207
+ if(!$.vakata.dnd.is_down) { return; }
2208
+ if(!$.vakata.dnd.is_drag) {
2209
+ if(Math.abs(e.pageX - $.vakata.dnd.init_x) > 5 || Math.abs(e.pageY - $.vakata.dnd.init_y) > 5) {
2210
+ $.vakata.dnd.helper.appendTo("body");
2211
+ $.vakata.dnd.is_drag = true;
2212
+ $(document).triggerHandler("drag_start.vakata", { "event" : e, "data" : $.vakata.dnd.user_data });
2213
+ }
2214
+ else { return; }
2215
+ }
2216
+
2217
+ // maybe use a scrolling parent element instead of document?
2218
+ if(e.type === "mousemove") { // thought of adding scroll in order to move the helper, but mouse poisition is n/a
2219
+ var d = $(document), t = d.scrollTop(), l = d.scrollLeft();
2220
+ if(e.pageY - t < 20) {
2221
+ if(sti && dir1 === "down") { clearInterval(sti); sti = false; }
2222
+ if(!sti) { dir1 = "up"; sti = setInterval(function () { $(document).scrollTop($(document).scrollTop() - $.vakata.dnd.scroll_spd); }, 150); }
2223
+ }
2224
+ else {
2225
+ if(sti && dir1 === "up") { clearInterval(sti); sti = false; }
2226
+ }
2227
+ if($(window).height() - (e.pageY - t) < 20) {
2228
+ if(sti && dir1 === "up") { clearInterval(sti); sti = false; }
2229
+ if(!sti) { dir1 = "down"; sti = setInterval(function () { $(document).scrollTop($(document).scrollTop() + $.vakata.dnd.scroll_spd); }, 150); }
2230
+ }
2231
+ else {
2232
+ if(sti && dir1 === "down") { clearInterval(sti); sti = false; }
2233
+ }
2234
+
2235
+ if(e.pageX - l < 20) {
2236
+ if(sli && dir2 === "right") { clearInterval(sli); sli = false; }
2237
+ if(!sli) { dir2 = "left"; sli = setInterval(function () { $(document).scrollLeft($(document).scrollLeft() - $.vakata.dnd.scroll_spd); }, 150); }
2238
+ }
2239
+ else {
2240
+ if(sli && dir2 === "left") { clearInterval(sli); sli = false; }
2241
+ }
2242
+ if($(window).width() - (e.pageX - l) < 20) {
2243
+ if(sli && dir2 === "left") { clearInterval(sli); sli = false; }
2244
+ if(!sli) { dir2 = "right"; sli = setInterval(function () { $(document).scrollLeft($(document).scrollLeft() + $.vakata.dnd.scroll_spd); }, 150); }
2245
+ }
2246
+ else {
2247
+ if(sli && dir2 === "right") { clearInterval(sli); sli = false; }
2248
+ }
2249
+ }
2250
+
2251
+ $.vakata.dnd.helper.css({ left : (e.pageX + $.vakata.dnd.helper_left) + "px", top : (e.pageY + $.vakata.dnd.helper_top) + "px" });
2252
+ $(document).triggerHandler("drag.vakata", { "event" : e, "data" : $.vakata.dnd.user_data });
2253
+ },
2254
+ drag_stop : function (e) {
2255
+ if(sli) { clearInterval(sli); }
2256
+ if(sti) { clearInterval(sti); }
2257
+ $(document).unbind("mousemove", $.vakata.dnd.drag);
2258
+ $(document).unbind("mouseup", $.vakata.dnd.drag_stop);
2259
+ $(document).triggerHandler("drag_stop.vakata", { "event" : e, "data" : $.vakata.dnd.user_data });
2260
+ $.vakata.dnd.helper.remove();
2261
+ $.vakata.dnd.init_x = 0;
2262
+ $.vakata.dnd.init_y = 0;
2263
+ $.vakata.dnd.user_data = {};
2264
+ $.vakata.dnd.is_down = false;
2265
+ $.vakata.dnd.is_drag = false;
2266
+ }
2267
+ };
2268
+ $(function() {
2269
+ var css_string = '#vakata-dragged { display:block; margin:0 0 0 0; padding:4px 4px 4px 24px; position:absolute; top:-2000px; line-height:16px; z-index:10000; } ';
2270
+ $.vakata.css.add_sheet({ str : css_string, title : "vakata" });
2271
+ });
2272
+
2273
+ $.jstree.plugin("dnd", {
2274
+ __init : function () {
2275
+ this.data.dnd = {
2276
+ active : false,
2277
+ after : false,
2278
+ inside : false,
2279
+ before : false,
2280
+ off : false,
2281
+ prepared : false,
2282
+ w : 0,
2283
+ to1 : false,
2284
+ to2 : false,
2285
+ cof : false,
2286
+ cw : false,
2287
+ ch : false,
2288
+ i1 : false,
2289
+ i2 : false,
2290
+ mto : false
2291
+ };
2292
+ this.get_container()
2293
+ .bind("mouseenter.jstree", $.proxy(function (e) {
2294
+ if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree) {
2295
+ if(this.data.themes) {
2296
+ m.attr("class", "jstree-" + this.data.themes.theme);
2297
+ if(ml) { ml.attr("class", "jstree-" + this.data.themes.theme); }
2298
+ $.vakata.dnd.helper.attr("class", "jstree-dnd-helper jstree-" + this.data.themes.theme);
2299
+ }
2300
+ //if($(e.currentTarget).find("> ul > li").length === 0) {
2301
+ if(e.currentTarget === e.target && $.vakata.dnd.user_data.obj && $($.vakata.dnd.user_data.obj).length && $($.vakata.dnd.user_data.obj).parents(".jstree:eq(0)")[0] !== e.target) { // node should not be from the same tree
2302
+ var tr = $.jstree._reference(e.target), dc;
2303
+ if(tr.data.dnd.foreign) {
2304
+ dc = tr._get_settings().dnd.drag_check.call(this, { "o" : o, "r" : tr.get_container(), is_root : true });
2305
+ if(dc === true || dc.inside === true || dc.before === true || dc.after === true) {
2306
+ $.vakata.dnd.helper.children("ins").attr("class","jstree-ok");
2307
+ }
2308
+ }
2309
+ else {
2310
+ tr.prepare_move(o, tr.get_container(), "last");
2311
+ if(tr.check_move()) {
2312
+ $.vakata.dnd.helper.children("ins").attr("class","jstree-ok");
2313
+ }
2314
+ }
2315
+ }
2316
+ }
2317
+ }, this))
2318
+ .bind("mouseup.jstree", $.proxy(function (e) {
2319
+ //if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree && $(e.currentTarget).find("> ul > li").length === 0) {
2320
+ if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree && e.currentTarget === e.target && $.vakata.dnd.user_data.obj && $($.vakata.dnd.user_data.obj).length && $($.vakata.dnd.user_data.obj).parents(".jstree:eq(0)")[0] !== e.target) { // node should not be from the same tree
2321
+ var tr = $.jstree._reference(e.currentTarget), dc;
2322
+ if(tr.data.dnd.foreign) {
2323
+ dc = tr._get_settings().dnd.drag_check.call(this, { "o" : o, "r" : tr.get_container(), is_root : true });
2324
+ if(dc === true || dc.inside === true || dc.before === true || dc.after === true) {
2325
+ tr._get_settings().dnd.drag_finish.call(this, { "o" : o, "r" : tr.get_container(), is_root : true });
2326
+ }
2327
+ }
2328
+ else {
2329
+ tr.move_node(o, tr.get_container(), "last", e[tr._get_settings().dnd.copy_modifier + "Key"]);
2330
+ }
2331
+ }
2332
+ }, this))
2333
+ .bind("mouseleave.jstree", $.proxy(function (e) {
2334
+ if(e.relatedTarget && e.relatedTarget.id && e.relatedTarget.id === "jstree-marker-line") {
2335
+ return false;
2336
+ }
2337
+ if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree) {
2338
+ if(this.data.dnd.i1) { clearInterval(this.data.dnd.i1); }
2339
+ if(this.data.dnd.i2) { clearInterval(this.data.dnd.i2); }
2340
+ if(this.data.dnd.to1) { clearTimeout(this.data.dnd.to1); }
2341
+ if(this.data.dnd.to2) { clearTimeout(this.data.dnd.to2); }
2342
+ if($.vakata.dnd.helper.children("ins").hasClass("jstree-ok")) {
2343
+ $.vakata.dnd.helper.children("ins").attr("class","jstree-invalid");
2344
+ }
2345
+ }
2346
+ }, this))
2347
+ .bind("mousemove.jstree", $.proxy(function (e) {
2348
+ if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree) {
2349
+ var cnt = this.get_container()[0];
2350
+
2351
+ // Horizontal scroll
2352
+ if(e.pageX + 24 > this.data.dnd.cof.left + this.data.dnd.cw) {
2353
+ if(this.data.dnd.i1) { clearInterval(this.data.dnd.i1); }
2354
+ this.data.dnd.i1 = setInterval($.proxy(function () { this.scrollLeft += $.vakata.dnd.scroll_spd; }, cnt), 100);
2355
+ }
2356
+ else if(e.pageX - 24 < this.data.dnd.cof.left) {
2357
+ if(this.data.dnd.i1) { clearInterval(this.data.dnd.i1); }
2358
+ this.data.dnd.i1 = setInterval($.proxy(function () { this.scrollLeft -= $.vakata.dnd.scroll_spd; }, cnt), 100);
2359
+ }
2360
+ else {
2361
+ if(this.data.dnd.i1) { clearInterval(this.data.dnd.i1); }
2362
+ }
2363
+
2364
+ // Vertical scroll
2365
+ if(e.pageY + 24 > this.data.dnd.cof.top + this.data.dnd.ch) {
2366
+ if(this.data.dnd.i2) { clearInterval(this.data.dnd.i2); }
2367
+ this.data.dnd.i2 = setInterval($.proxy(function () { this.scrollTop += $.vakata.dnd.scroll_spd; }, cnt), 100);
2368
+ }
2369
+ else if(e.pageY - 24 < this.data.dnd.cof.top) {
2370
+ if(this.data.dnd.i2) { clearInterval(this.data.dnd.i2); }
2371
+ this.data.dnd.i2 = setInterval($.proxy(function () { this.scrollTop -= $.vakata.dnd.scroll_spd; }, cnt), 100);
2372
+ }
2373
+ else {
2374
+ if(this.data.dnd.i2) { clearInterval(this.data.dnd.i2); }
2375
+ }
2376
+
2377
+ }
2378
+ }, this))
2379
+ .bind("scroll.jstree", $.proxy(function (e) {
2380
+ if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree && m && ml) {
2381
+ m.hide();
2382
+ ml.hide();
2383
+ }
2384
+ }, this))
2385
+ .delegate("a", "mousedown.jstree", $.proxy(function (e) {
2386
+ if(e.which === 1) {
2387
+ this.start_drag(e.currentTarget, e);
2388
+ return false;
2389
+ }
2390
+ }, this))
2391
+ .delegate("a", "mouseenter.jstree", $.proxy(function (e) {
2392
+ if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree) {
2393
+ this.dnd_enter(e.currentTarget);
2394
+ }
2395
+ }, this))
2396
+ .delegate("a", "mousemove.jstree", $.proxy(function (e) {
2397
+ if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree) {
2398
+ if(!r || !r.length || r.children("a")[0] !== e.currentTarget) {
2399
+ this.dnd_enter(e.currentTarget);
2400
+ }
2401
+ if(typeof this.data.dnd.off.top === "undefined") { this.data.dnd.off = $(e.target).offset(); }
2402
+ this.data.dnd.w = (e.pageY - (this.data.dnd.off.top || 0)) % this.data.core.li_height;
2403
+ if(this.data.dnd.w < 0) { this.data.dnd.w += this.data.core.li_height; }
2404
+ this.dnd_show();
2405
+ }
2406
+ }, this))
2407
+ .delegate("a", "mouseleave.jstree", $.proxy(function (e) {
2408
+ if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree) {
2409
+ if(e.relatedTarget && e.relatedTarget.id && e.relatedTarget.id === "jstree-marker-line") {
2410
+ return false;
2411
+ }
2412
+ if(m) { m.hide(); }
2413
+ if(ml) { ml.hide(); }
2414
+ /*
2415
+ var ec = $(e.currentTarget).closest("li"),
2416
+ er = $(e.relatedTarget).closest("li");
2417
+ if(er[0] !== ec.prev()[0] && er[0] !== ec.next()[0]) {
2418
+ if(m) { m.hide(); }
2419
+ if(ml) { ml.hide(); }
2420
+ }
2421
+ */
2422
+ this.data.dnd.mto = setTimeout(
2423
+ (function (t) { return function () { t.dnd_leave(e); }; })(this),
2424
+ 0);
2425
+ }
2426
+ }, this))
2427
+ .delegate("a", "mouseup.jstree", $.proxy(function (e) {
2428
+ if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree) {
2429
+ this.dnd_finish(e);
2430
+ }
2431
+ }, this));
2432
+
2433
+ $(document)
2434
+ .bind("drag_stop.vakata", $.proxy(function () {
2435
+ if(this.data.dnd.to1) { clearTimeout(this.data.dnd.to1); }
2436
+ if(this.data.dnd.to2) { clearTimeout(this.data.dnd.to2); }
2437
+ if(this.data.dnd.i1) { clearInterval(this.data.dnd.i1); }
2438
+ if(this.data.dnd.i2) { clearInterval(this.data.dnd.i2); }
2439
+ this.data.dnd.after = false;
2440
+ this.data.dnd.before = false;
2441
+ this.data.dnd.inside = false;
2442
+ this.data.dnd.off = false;
2443
+ this.data.dnd.prepared = false;
2444
+ this.data.dnd.w = false;
2445
+ this.data.dnd.to1 = false;
2446
+ this.data.dnd.to2 = false;
2447
+ this.data.dnd.i1 = false;
2448
+ this.data.dnd.i2 = false;
2449
+ this.data.dnd.active = false;
2450
+ this.data.dnd.foreign = false;
2451
+ if(m) { m.css({ "top" : "-2000px" }); }
2452
+ if(ml) { ml.css({ "top" : "-2000px" }); }
2453
+ }, this))
2454
+ .bind("drag_start.vakata", $.proxy(function (e, data) {
2455
+ if(data.data.jstree) {
2456
+ var et = $(data.event.target);
2457
+ if(et.closest(".jstree").hasClass("jstree-" + this.get_index())) {
2458
+ this.dnd_enter(et);
2459
+ }
2460
+ }
2461
+ }, this));
2462
+ /*
2463
+ .bind("keydown.jstree-" + this.get_index() + " keyup.jstree-" + this.get_index(), $.proxy(function(e) {
2464
+ if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree && !this.data.dnd.foreign) {
2465
+ var h = $.vakata.dnd.helper.children("ins");
2466
+ if(e[this._get_settings().dnd.copy_modifier + "Key"] && h.hasClass("jstree-ok")) {
2467
+ h.parent().html(h.parent().html().replace(/ \(Copy\)$/, "") + " (Copy)");
2468
+ }
2469
+ else {
2470
+ h.parent().html(h.parent().html().replace(/ \(Copy\)$/, ""));
2471
+ }
2472
+ }
2473
+ }, this)); */
2474
+
2475
+
2476
+
2477
+ var s = this._get_settings().dnd;
2478
+ if(s.drag_target) {
2479
+ $(document)
2480
+ .delegate(s.drag_target, "mousedown.jstree-" + this.get_index(), $.proxy(function (e) {
2481
+ o = e.target;
2482
+ $.vakata.dnd.drag_start(e, { jstree : true, obj : e.target }, "<ins class='jstree-icon'></ins>" + $(e.target).text() );
2483
+ if(this.data.themes) {
2484
+ if(m) { m.attr("class", "jstree-" + this.data.themes.theme); }
2485
+ if(ml) { ml.attr("class", "jstree-" + this.data.themes.theme); }
2486
+ $.vakata.dnd.helper.attr("class", "jstree-dnd-helper jstree-" + this.data.themes.theme);
2487
+ }
2488
+ $.vakata.dnd.helper.children("ins").attr("class","jstree-invalid");
2489
+ var cnt = this.get_container();
2490
+ this.data.dnd.cof = cnt.offset();
2491
+ this.data.dnd.cw = parseInt(cnt.width(),10);
2492
+ this.data.dnd.ch = parseInt(cnt.height(),10);
2493
+ this.data.dnd.foreign = true;
2494
+ e.preventDefault();
2495
+ }, this));
2496
+ }
2497
+ if(s.drop_target) {
2498
+ $(document)
2499
+ .delegate(s.drop_target, "mouseenter.jstree-" + this.get_index(), $.proxy(function (e) {
2500
+ if(this.data.dnd.active && this._get_settings().dnd.drop_check.call(this, { "o" : o, "r" : $(e.target), "e" : e })) {
2501
+ $.vakata.dnd.helper.children("ins").attr("class","jstree-ok");
2502
+ }
2503
+ }, this))
2504
+ .delegate(s.drop_target, "mouseleave.jstree-" + this.get_index(), $.proxy(function (e) {
2505
+ if(this.data.dnd.active) {
2506
+ $.vakata.dnd.helper.children("ins").attr("class","jstree-invalid");
2507
+ }
2508
+ }, this))
2509
+ .delegate(s.drop_target, "mouseup.jstree-" + this.get_index(), $.proxy(function (e) {
2510
+ if(this.data.dnd.active && $.vakata.dnd.helper.children("ins").hasClass("jstree-ok")) {
2511
+ this._get_settings().dnd.drop_finish.call(this, { "o" : o, "r" : $(e.target), "e" : e });
2512
+ }
2513
+ }, this));
2514
+ }
2515
+ },
2516
+ defaults : {
2517
+ copy_modifier : "ctrl",
2518
+ check_timeout : 100,
2519
+ open_timeout : 500,
2520
+ drop_target : ".jstree-drop",
2521
+ drop_check : function (data) { return true; },
2522
+ drop_finish : $.noop,
2523
+ drag_target : ".jstree-draggable",
2524
+ drag_finish : $.noop,
2525
+ drag_check : function (data) { return { after : false, before : false, inside : true }; }
2526
+ },
2527
+ _fn : {
2528
+ dnd_prepare : function () {
2529
+ if(!r || !r.length) { return; }
2530
+ this.data.dnd.off = r.offset();
2531
+ if(this._get_settings().core.rtl) {
2532
+ this.data.dnd.off.right = this.data.dnd.off.left + r.width();
2533
+ }
2534
+ if(this.data.dnd.foreign) {
2535
+ var a = this._get_settings().dnd.drag_check.call(this, { "o" : o, "r" : r });
2536
+ this.data.dnd.after = a.after;
2537
+ this.data.dnd.before = a.before;
2538
+ this.data.dnd.inside = a.inside;
2539
+ this.data.dnd.prepared = true;
2540
+ return this.dnd_show();
2541
+ }
2542
+ this.prepare_move(o, r, "before");
2543
+ this.data.dnd.before = this.check_move();
2544
+ this.prepare_move(o, r, "after");
2545
+ this.data.dnd.after = this.check_move();
2546
+ if(this._is_loaded(r)) {
2547
+ this.prepare_move(o, r, "inside");
2548
+ this.data.dnd.inside = this.check_move();
2549
+ }
2550
+ else {
2551
+ this.data.dnd.inside = false;
2552
+ }
2553
+ this.data.dnd.prepared = true;
2554
+ return this.dnd_show();
2555
+ },
2556
+ dnd_show : function () {
2557
+ if(!this.data.dnd.prepared) { return; }
2558
+ var o = ["before","inside","after"],
2559
+ r = false,
2560
+ rtl = this._get_settings().core.rtl,
2561
+ pos;
2562
+ if(this.data.dnd.w < this.data.core.li_height/3) { o = ["before","inside","after"]; }
2563
+ else if(this.data.dnd.w <= this.data.core.li_height*2/3) {
2564
+ o = this.data.dnd.w < this.data.core.li_height/2 ? ["inside","before","after"] : ["inside","after","before"];
2565
+ }
2566
+ else { o = ["after","inside","before"]; }
2567
+ $.each(o, $.proxy(function (i, val) {
2568
+ if(this.data.dnd[val]) {
2569
+ $.vakata.dnd.helper.children("ins").attr("class","jstree-ok");
2570
+ r = val;
2571
+ return false;
2572
+ }
2573
+ }, this));
2574
+ if(r === false) { $.vakata.dnd.helper.children("ins").attr("class","jstree-invalid"); }
2575
+
2576
+ pos = rtl ? (this.data.dnd.off.right - 18) : (this.data.dnd.off.left + 10);
2577
+ switch(r) {
2578
+ case "before":
2579
+ m.css({ "left" : pos + "px", "top" : (this.data.dnd.off.top - 6) + "px" }).show();
2580
+ if(ml) { ml.css({ "left" : (pos + 8) + "px", "top" : (this.data.dnd.off.top - 1) + "px" }).show(); }
2581
+ break;
2582
+ case "after":
2583
+ m.css({ "left" : pos + "px", "top" : (this.data.dnd.off.top + this.data.core.li_height - 6) + "px" }).show();
2584
+ if(ml) { ml.css({ "left" : (pos + 8) + "px", "top" : (this.data.dnd.off.top + this.data.core.li_height - 1) + "px" }).show(); }
2585
+ break;
2586
+ case "inside":
2587
+ m.css({ "left" : pos + ( rtl ? -4 : 4) + "px", "top" : (this.data.dnd.off.top + this.data.core.li_height/2 - 5) + "px" }).show();
2588
+ if(ml) { ml.hide(); }
2589
+ break;
2590
+ default:
2591
+ m.hide();
2592
+ if(ml) { ml.hide(); }
2593
+ break;
2594
+ }
2595
+ last_pos = r;
2596
+ return r;
2597
+ },
2598
+ dnd_open : function () {
2599
+ this.data.dnd.to2 = false;
2600
+ this.open_node(r, $.proxy(this.dnd_prepare,this), true);
2601
+ },
2602
+ dnd_finish : function (e) {
2603
+ if(this.data.dnd.foreign) {
2604
+ if(this.data.dnd.after || this.data.dnd.before || this.data.dnd.inside) {
2605
+ this._get_settings().dnd.drag_finish.call(this, { "o" : o, "r" : r, "p" : last_pos });
2606
+ }
2607
+ }
2608
+ else {
2609
+ this.dnd_prepare();
2610
+ this.move_node(o, r, last_pos, e[this._get_settings().dnd.copy_modifier + "Key"]);
2611
+ }
2612
+ o = false;
2613
+ r = false;
2614
+ m.hide();
2615
+ if(ml) { ml.hide(); }
2616
+ },
2617
+ dnd_enter : function (obj) {
2618
+ if(this.data.dnd.mto) {
2619
+ clearTimeout(this.data.dnd.mto);
2620
+ this.data.dnd.mto = false;
2621
+ }
2622
+ var s = this._get_settings().dnd;
2623
+ this.data.dnd.prepared = false;
2624
+ r = this._get_node(obj);
2625
+ if(s.check_timeout) {
2626
+ // do the calculations after a minimal timeout (users tend to drag quickly to the desired location)
2627
+ if(this.data.dnd.to1) { clearTimeout(this.data.dnd.to1); }
2628
+ this.data.dnd.to1 = setTimeout($.proxy(this.dnd_prepare, this), s.check_timeout);
2629
+ }
2630
+ else {
2631
+ this.dnd_prepare();
2632
+ }
2633
+ if(s.open_timeout) {
2634
+ if(this.data.dnd.to2) { clearTimeout(this.data.dnd.to2); }
2635
+ if(r && r.length && r.hasClass("jstree-closed")) {
2636
+ // if the node is closed - open it, then recalculate
2637
+ this.data.dnd.to2 = setTimeout($.proxy(this.dnd_open, this), s.open_timeout);
2638
+ }
2639
+ }
2640
+ else {
2641
+ if(r && r.length && r.hasClass("jstree-closed")) {
2642
+ this.dnd_open();
2643
+ }
2644
+ }
2645
+ },
2646
+ dnd_leave : function (e) {
2647
+ this.data.dnd.after = false;
2648
+ this.data.dnd.before = false;
2649
+ this.data.dnd.inside = false;
2650
+ $.vakata.dnd.helper.children("ins").attr("class","jstree-invalid");
2651
+ m.hide();
2652
+ if(ml) { ml.hide(); }
2653
+ if(r && r[0] === e.target.parentNode) {
2654
+ if(this.data.dnd.to1) {
2655
+ clearTimeout(this.data.dnd.to1);
2656
+ this.data.dnd.to1 = false;
2657
+ }
2658
+ if(this.data.dnd.to2) {
2659
+ clearTimeout(this.data.dnd.to2);
2660
+ this.data.dnd.to2 = false;
2661
+ }
2662
+ }
2663
+ },
2664
+ start_drag : function (obj, e) {
2665
+ o = this._get_node(obj);
2666
+ if(this.data.ui && this.is_selected(o)) { o = this._get_node(null, true); }
2667
+ var dt = o.length > 1 ? this._get_string("multiple_selection") : this.get_text(o),
2668
+ cnt = this.get_container();
2669
+ if(!this._get_settings().core.html_titles) { dt = dt.replace(/</ig,"&lt;").replace(/>/ig,"&gt;"); }
2670
+ $.vakata.dnd.drag_start(e, { jstree : true, obj : o }, "<ins class='jstree-icon'></ins>" + dt );
2671
+ if(this.data.themes) {
2672
+ if(m) { m.attr("class", "jstree-" + this.data.themes.theme); }
2673
+ if(ml) { ml.attr("class", "jstree-" + this.data.themes.theme); }
2674
+ $.vakata.dnd.helper.attr("class", "jstree-dnd-helper jstree-" + this.data.themes.theme);
2675
+ }
2676
+ this.data.dnd.cof = cnt.offset();
2677
+ this.data.dnd.cw = parseInt(cnt.width(),10);
2678
+ this.data.dnd.ch = parseInt(cnt.height(),10);
2679
+ this.data.dnd.active = true;
2680
+ }
2681
+ }
2682
+ });
2683
+ $(function() {
2684
+ var css_string = '' +
2685
+ '#vakata-dragged ins { display:block; text-decoration:none; width:16px; height:16px; margin:0 0 0 0; padding:0; position:absolute; top:4px; left:4px; ' +
2686
+ ' -moz-border-radius:4px; border-radius:4px; -webkit-border-radius:4px; ' +
2687
+ '} ' +
2688
+ '#vakata-dragged .jstree-ok { background:green; } ' +
2689
+ '#vakata-dragged .jstree-invalid { background:red; } ' +
2690
+ '#jstree-marker { padding:0; margin:0; font-size:12px; overflow:hidden; height:12px; width:8px; position:absolute; top:-30px; z-index:10001; background-repeat:no-repeat; display:none; background-color:transparent; text-shadow:1px 1px 1px white; color:black; line-height:10px; } ' +
2691
+ '#jstree-marker-line { padding:0; margin:0; line-height:0%; font-size:1px; overflow:hidden; height:1px; width:100px; position:absolute; top:-30px; z-index:10000; background-repeat:no-repeat; display:none; background-color:#456c43; ' +
2692
+ ' cursor:pointer; border:1px solid #eeeeee; border-left:0; -moz-box-shadow: 0px 0px 2px #666; -webkit-box-shadow: 0px 0px 2px #666; box-shadow: 0px 0px 2px #666; ' +
2693
+ ' -moz-border-radius:1px; border-radius:1px; -webkit-border-radius:1px; ' +
2694
+ '}' +
2695
+ '';
2696
+ $.vakata.css.add_sheet({ str : css_string, title : "jstree" });
2697
+ m = $("<div />").attr({ id : "jstree-marker" }).hide().html("&raquo;")
2698
+ .bind("mouseleave mouseenter", function (e) {
2699
+ m.hide();
2700
+ ml.hide();
2701
+ e.preventDefault();
2702
+ e.stopImmediatePropagation();
2703
+ return false;
2704
+ })
2705
+ .appendTo("body");
2706
+ ml = $("<div />").attr({ id : "jstree-marker-line" }).hide()
2707
+ .bind("mouseup", function (e) {
2708
+ if(r && r.length) {
2709
+ r.children("a").trigger(e);
2710
+ e.preventDefault();
2711
+ e.stopImmediatePropagation();
2712
+ return false;
2713
+ }
2714
+ })
2715
+ .bind("mouseleave", function (e) {
2716
+ var rt = $(e.relatedTarget);
2717
+ if(rt.is(".jstree") || rt.closest(".jstree").length === 0) {
2718
+ if(r && r.length) {
2719
+ r.children("a").trigger(e);
2720
+ m.hide();
2721
+ ml.hide();
2722
+ e.preventDefault();
2723
+ e.stopImmediatePropagation();
2724
+ return false;
2725
+ }
2726
+ }
2727
+ })
2728
+ .appendTo("body");
2729
+ $(document).bind("drag_start.vakata", function (e, data) {
2730
+ if(data.data.jstree) { m.show(); if(ml) { ml.show(); } }
2731
+ });
2732
+ $(document).bind("drag_stop.vakata", function (e, data) {
2733
+ if(data.data.jstree) { m.hide(); if(ml) { ml.hide(); } }
2734
+ });
2735
+ });
2736
+ })(jQuery);
2737
+ //*/
2738
+
2739
+ /*
2740
+ * jsTree checkbox plugin
2741
+ * Inserts checkboxes in front of every node
2742
+ * Depends on the ui plugin
2743
+ * DOES NOT WORK NICELY WITH MULTITREE DRAG'N'DROP
2744
+ */
2745
+ (function ($) {
2746
+ $.jstree.plugin("checkbox", {
2747
+ __init : function () {
2748
+ this.data.checkbox.noui = this._get_settings().checkbox.override_ui;
2749
+ if(this.data.ui && this.data.checkbox.noui) {
2750
+ this.select_node = this.deselect_node = this.deselect_all = $.noop;
2751
+ this.get_selected = this.get_checked;
2752
+ }
2753
+
2754
+ this.get_container()
2755
+ .bind("open_node.jstree create_node.jstree clean_node.jstree refresh.jstree", $.proxy(function (e, data) {
2756
+ this._prepare_checkboxes(data.rslt.obj);
2757
+ }, this))
2758
+ .bind("loaded.jstree", $.proxy(function (e) {
2759
+ this._prepare_checkboxes();
2760
+ }, this))
2761
+ .delegate( (this.data.ui && this.data.checkbox.noui ? "a" : "ins.jstree-checkbox") , "click.jstree", $.proxy(function (e) {
2762
+ e.preventDefault();
2763
+ if(this._get_node(e.target).hasClass("jstree-checked")) { this.uncheck_node(e.target); }
2764
+ else { this.check_node(e.target); }
2765
+ if(this.data.ui && this.data.checkbox.noui) {
2766
+ this.save_selected();
2767
+ if(this.data.cookies) { this.save_cookie("select_node"); }
2768
+ }
2769
+ else {
2770
+ e.stopImmediatePropagation();
2771
+ return false;
2772
+ }
2773
+ }, this));
2774
+ },
2775
+ defaults : {
2776
+ override_ui : false,
2777
+ two_state : false,
2778
+ real_checkboxes : false,
2779
+ checked_parent_open : true,
2780
+ real_checkboxes_names : function (n) { return [ ("check_" + (n[0].id || Math.ceil(Math.random() * 10000))) , 1]; }
2781
+ },
2782
+ __destroy : function () {
2783
+ this.get_container()
2784
+ .find("input.jstree-real-checkbox").removeClass("jstree-real-checkbox").end()
2785
+ .find("ins.jstree-checkbox").remove();
2786
+ },
2787
+ _fn : {
2788
+ _checkbox_notify : function (n, data) {
2789
+ if(data.checked) {
2790
+ this.check_node(n, false);
2791
+ }
2792
+ },
2793
+ _prepare_checkboxes : function (obj) {
2794
+ obj = !obj || obj == -1 ? this.get_container().find("> ul > li") : this._get_node(obj);
2795
+ if(obj === false) { return; } // added for removing root nodes
2796
+ var c, _this = this, t, ts = this._get_settings().checkbox.two_state, rc = this._get_settings().checkbox.real_checkboxes, rcn = this._get_settings().checkbox.real_checkboxes_names;
2797
+ obj.each(function () {
2798
+ t = $(this);
2799
+ c = t.is("li") && (t.hasClass("jstree-checked") || (rc && t.children(":checked").length)) ? "jstree-checked" : "jstree-unchecked";
2800
+ t.find("li").andSelf().each(function () {
2801
+ var $t = $(this), nm;
2802
+ $t.children("a" + (_this.data.languages ? "" : ":eq(0)") ).not(":has(.jstree-checkbox)").prepend("<ins class='jstree-checkbox'>&#160;</ins>").parent().not(".jstree-checked, .jstree-unchecked").addClass( ts ? "jstree-unchecked" : c );
2803
+ if(rc) {
2804
+ if(!$t.children(":checkbox").length) {
2805
+ nm = rcn.call(_this, $t);
2806
+ $t.prepend("<input type='checkbox' class='jstree-real-checkbox' id='" + nm[0] + "' name='" + nm[0] + "' value='" + nm[1] + "' />");
2807
+ }
2808
+ else {
2809
+ $t.children(":checkbox").addClass("jstree-real-checkbox");
2810
+ }
2811
+ if(c === "jstree-checked") {
2812
+ $t.children(":checkbox").attr("checked","checked");
2813
+ }
2814
+ }
2815
+ if(c === "jstree-checked" && !ts) {
2816
+ $t.find("li").addClass("jstree-checked");
2817
+ }
2818
+ });
2819
+ });
2820
+ if(!ts) {
2821
+ if(obj.length === 1 && obj.is("li")) { this._repair_state(obj); }
2822
+ if(obj.is("li")) { obj.each(function () { _this._repair_state(this); }); }
2823
+ else { obj.find("> ul > li").each(function () { _this._repair_state(this); }); }
2824
+ obj.find(".jstree-checked").parent().parent().each(function () { _this._repair_state(this); });
2825
+ }
2826
+ },
2827
+ change_state : function (obj, state) {
2828
+ obj = this._get_node(obj);
2829
+ var coll = false, rc = this._get_settings().checkbox.real_checkboxes;
2830
+ if(!obj || obj === -1) { return false; }
2831
+ state = (state === false || state === true) ? state : obj.hasClass("jstree-checked");
2832
+ if(this._get_settings().checkbox.two_state) {
2833
+ if(state) {
2834
+ obj.removeClass("jstree-checked").addClass("jstree-unchecked");
2835
+ if(rc) { obj.children(":checkbox").removeAttr("checked"); }
2836
+ }
2837
+ else {
2838
+ obj.removeClass("jstree-unchecked").addClass("jstree-checked");
2839
+ if(rc) { obj.children(":checkbox").attr("checked","checked"); }
2840
+ }
2841
+ }
2842
+ else {
2843
+ if(state) {
2844
+ coll = obj.find("li").andSelf();
2845
+ if(!coll.filter(".jstree-checked, .jstree-undetermined").length) { return false; }
2846
+ coll.removeClass("jstree-checked jstree-undetermined").addClass("jstree-unchecked");
2847
+ if(rc) { coll.children(":checkbox").removeAttr("checked"); }
2848
+ }
2849
+ else {
2850
+ coll = obj.find("li").andSelf();
2851
+ if(!coll.filter(".jstree-unchecked, .jstree-undetermined").length) { return false; }
2852
+ coll.removeClass("jstree-unchecked jstree-undetermined").addClass("jstree-checked");
2853
+ if(rc) { coll.children(":checkbox").attr("checked","checked"); }
2854
+ if(this.data.ui) { this.data.ui.last_selected = obj; }
2855
+ this.data.checkbox.last_selected = obj;
2856
+ }
2857
+ obj.parentsUntil(".jstree", "li").each(function () {
2858
+ var $this = $(this);
2859
+ if(state) {
2860
+ if($this.children("ul").children("li.jstree-checked, li.jstree-undetermined").length) {
2861
+ $this.parentsUntil(".jstree", "li").andSelf().removeClass("jstree-checked jstree-unchecked").addClass("jstree-undetermined");
2862
+ if(rc) { $this.parentsUntil(".jstree", "li").andSelf().children(":checkbox").removeAttr("checked"); }
2863
+ return false;
2864
+ }
2865
+ else {
2866
+ $this.removeClass("jstree-checked jstree-undetermined").addClass("jstree-unchecked");
2867
+ if(rc) { $this.children(":checkbox").removeAttr("checked"); }
2868
+ }
2869
+ }
2870
+ else {
2871
+ if($this.children("ul").children("li.jstree-unchecked, li.jstree-undetermined").length) {
2872
+ $this.parentsUntil(".jstree", "li").andSelf().removeClass("jstree-checked jstree-unchecked").addClass("jstree-undetermined");
2873
+ if(rc) { $this.parentsUntil(".jstree", "li").andSelf().children(":checkbox").removeAttr("checked"); }
2874
+ return false;
2875
+ }
2876
+ else {
2877
+ $this.removeClass("jstree-unchecked jstree-undetermined").addClass("jstree-checked");
2878
+ if(rc) { $this.children(":checkbox").attr("checked","checked"); }
2879
+ }
2880
+ }
2881
+ });
2882
+ }
2883
+ if(this.data.ui && this.data.checkbox.noui) { this.data.ui.selected = this.get_checked(); }
2884
+ this.__callback(obj);
2885
+ return true;
2886
+ },
2887
+ check_node : function (obj) {
2888
+ if(this.change_state(obj, false)) {
2889
+ obj = this._get_node(obj);
2890
+ if(this._get_settings().checkbox.checked_parent_open) {
2891
+ var t = this;
2892
+ obj.parents(".jstree-closed").each(function () { t.open_node(this, false, true); });
2893
+ }
2894
+ this.__callback({ "obj" : obj });
2895
+ }
2896
+ },
2897
+ uncheck_node : function (obj) {
2898
+ if(this.change_state(obj, true)) { this.__callback({ "obj" : this._get_node(obj) }); }
2899
+ },
2900
+ check_all : function () {
2901
+ var _this = this,
2902
+ coll = this._get_settings().checkbox.two_state ? this.get_container_ul().find("li") : this.get_container_ul().children("li");
2903
+ coll.each(function () {
2904
+ _this.change_state(this, false);
2905
+ });
2906
+ this.__callback();
2907
+ },
2908
+ uncheck_all : function () {
2909
+ var _this = this,
2910
+ coll = this._get_settings().checkbox.two_state ? this.get_container_ul().find("li") : this.get_container_ul().children("li");
2911
+ coll.each(function () {
2912
+ _this.change_state(this, true);
2913
+ });
2914
+ this.__callback();
2915
+ },
2916
+
2917
+ is_checked : function(obj) {
2918
+ obj = this._get_node(obj);
2919
+ return obj.length ? obj.is(".jstree-checked") : false;
2920
+ },
2921
+ get_checked : function (obj, get_all) {
2922
+ obj = !obj || obj === -1 ? this.get_container() : this._get_node(obj);
2923
+ return get_all || this._get_settings().checkbox.two_state ? obj.find(".jstree-checked") : obj.find("> ul > .jstree-checked, .jstree-undetermined > ul > .jstree-checked");
2924
+ },
2925
+ get_unchecked : function (obj, get_all) {
2926
+ obj = !obj || obj === -1 ? this.get_container() : this._get_node(obj);
2927
+ return get_all || this._get_settings().checkbox.two_state ? obj.find(".jstree-unchecked") : obj.find("> ul > .jstree-unchecked, .jstree-undetermined > ul > .jstree-unchecked");
2928
+ },
2929
+
2930
+ show_checkboxes : function () { this.get_container().children("ul").removeClass("jstree-no-checkboxes"); },
2931
+ hide_checkboxes : function () { this.get_container().children("ul").addClass("jstree-no-checkboxes"); },
2932
+
2933
+ _repair_state : function (obj) {
2934
+ obj = this._get_node(obj);
2935
+ if(!obj.length) { return; }
2936
+ var rc = this._get_settings().checkbox.real_checkboxes,
2937
+ a = obj.find("> ul > .jstree-checked").length,
2938
+ b = obj.find("> ul > .jstree-undetermined").length,
2939
+ c = obj.find("> ul > li").length;
2940
+ if(c === 0) { if(obj.hasClass("jstree-undetermined")) { this.change_state(obj, false); } }
2941
+ else if(a === 0 && b === 0) { this.change_state(obj, true); }
2942
+ else if(a === c) { this.change_state(obj, false); }
2943
+ else {
2944
+ obj.parentsUntil(".jstree","li").andSelf().removeClass("jstree-checked jstree-unchecked").addClass("jstree-undetermined");
2945
+ if(rc) { obj.parentsUntil(".jstree", "li").andSelf().children(":checkbox").removeAttr("checked"); }
2946
+ }
2947
+ },
2948
+ reselect : function () {
2949
+ if(this.data.ui && this.data.checkbox.noui) {
2950
+ var _this = this,
2951
+ s = this.data.ui.to_select;
2952
+ s = $.map($.makeArray(s), function (n) { return "#" + n.toString().replace(/^#/,"").replace(/\\\//g,"/").replace(/\//g,"\\\/").replace(/\\\./g,".").replace(/\./g,"\\."); });
2953
+ this.deselect_all();
2954
+ $.each(s, function (i, val) { _this.check_node(val); });
2955
+ this.__callback();
2956
+ }
2957
+ else {
2958
+ this.__call_old();
2959
+ }
2960
+ },
2961
+ save_loaded : function () {
2962
+ var _this = this;
2963
+ this.data.core.to_load = [];
2964
+ this.get_container_ul().find("li.jstree-closed.jstree-undetermined").each(function () {
2965
+ if(this.id) { _this.data.core.to_load.push("#" + this.id); }
2966
+ });
2967
+ }
2968
+ }
2969
+ });
2970
+ $(function() {
2971
+ var css_string = '.jstree .jstree-real-checkbox { display:none; } ';
2972
+ $.vakata.css.add_sheet({ str : css_string, title : "jstree" });
2973
+ });
2974
+ })(jQuery);
2975
+ //*/
2976
+
2977
+ /*
2978
+ * jsTree XML plugin
2979
+ * The XML data store. Datastores are build by overriding the `load_node` and `_is_loaded` functions.
2980
+ */
2981
+ (function ($) {
2982
+ $.vakata.xslt = function (xml, xsl, callback) {
2983
+ var rs = "", xm, xs, processor, support;
2984
+ // TODO: IE9 no XSLTProcessor, no document.recalc
2985
+ if(document.recalc) {
2986
+ xm = document.createElement('xml');
2987
+ xs = document.createElement('xml');
2988
+ xm.innerHTML = xml;
2989
+ xs.innerHTML = xsl;
2990
+ $("body").append(xm).append(xs);
2991
+ setTimeout( (function (xm, xs, callback) {
2992
+ return function () {
2993
+ callback.call(null, xm.transformNode(xs.XMLDocument));
2994
+ setTimeout( (function (xm, xs) { return function () { $(xm).remove(); $(xs).remove(); }; })(xm, xs), 200);
2995
+ };
2996
+ })(xm, xs, callback), 100);
2997
+ return true;
2998
+ }
2999
+ if(typeof window.DOMParser !== "undefined" && typeof window.XMLHttpRequest !== "undefined" && typeof window.XSLTProcessor === "undefined") {
3000
+ xml = new DOMParser().parseFromString(xml, "text/xml");
3001
+ xsl = new DOMParser().parseFromString(xsl, "text/xml");
3002
+ // alert(xml.transformNode());
3003
+ // callback.call(null, new XMLSerializer().serializeToString(rs));
3004
+
3005
+ }
3006
+ if(typeof window.DOMParser !== "undefined" && typeof window.XMLHttpRequest !== "undefined" && typeof window.XSLTProcessor !== "undefined") {
3007
+ processor = new XSLTProcessor();
3008
+ support = $.isFunction(processor.transformDocument) ? (typeof window.XMLSerializer !== "undefined") : true;
3009
+ if(!support) { return false; }
3010
+ xml = new DOMParser().parseFromString(xml, "text/xml");
3011
+ xsl = new DOMParser().parseFromString(xsl, "text/xml");
3012
+ if($.isFunction(processor.transformDocument)) {
3013
+ rs = document.implementation.createDocument("", "", null);
3014
+ processor.transformDocument(xml, xsl, rs, null);
3015
+ callback.call(null, new XMLSerializer().serializeToString(rs));
3016
+ return true;
3017
+ }
3018
+ else {
3019
+ processor.importStylesheet(xsl);
3020
+ rs = processor.transformToFragment(xml, document);
3021
+ callback.call(null, $("<div />").append(rs).html());
3022
+ return true;
3023
+ }
3024
+ }
3025
+ return false;
3026
+ };
3027
+ var xsl = {
3028
+ 'nest' : '<' + '?xml version="1.0" encoding="utf-8" ?>' +
3029
+ '<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >' +
3030
+ '<xsl:output method="html" encoding="utf-8" omit-xml-declaration="yes" standalone="no" indent="no" media-type="text/html" />' +
3031
+ '<xsl:template match="/">' +
3032
+ ' <xsl:call-template name="nodes">' +
3033
+ ' <xsl:with-param name="node" select="/root" />' +
3034
+ ' </xsl:call-template>' +
3035
+ '</xsl:template>' +
3036
+ '<xsl:template name="nodes">' +
3037
+ ' <xsl:param name="node" />' +
3038
+ ' <ul>' +
3039
+ ' <xsl:for-each select="$node/item">' +
3040
+ ' <xsl:variable name="children" select="count(./item) &gt; 0" />' +
3041
+ ' <li>' +
3042
+ ' <xsl:attribute name="class">' +
3043
+ ' <xsl:if test="position() = last()">jstree-last </xsl:if>' +
3044
+ ' <xsl:choose>' +
3045
+ ' <xsl:when test="@state = \'open\'">jstree-open </xsl:when>' +
3046
+ ' <xsl:when test="$children or @hasChildren or @state = \'closed\'">jstree-closed </xsl:when>' +
3047
+ ' <xsl:otherwise>jstree-leaf </xsl:otherwise>' +
3048
+ ' </xsl:choose>' +
3049
+ ' <xsl:value-of select="@class" />' +
3050
+ ' </xsl:attribute>' +
3051
+ ' <xsl:for-each select="@*">' +
3052
+ ' <xsl:if test="name() != \'class\' and name() != \'state\' and name() != \'hasChildren\'">' +
3053
+ ' <xsl:attribute name="{name()}"><xsl:value-of select="." /></xsl:attribute>' +
3054
+ ' </xsl:if>' +
3055
+ ' </xsl:for-each>' +
3056
+ ' <ins class="jstree-icon"><xsl:text>&#xa0;</xsl:text></ins>' +
3057
+ ' <xsl:for-each select="content/name">' +
3058
+ ' <a>' +
3059
+ ' <xsl:attribute name="href">' +
3060
+ ' <xsl:choose>' +
3061
+ ' <xsl:when test="@href"><xsl:value-of select="@href" /></xsl:when>' +
3062
+ ' <xsl:otherwise>#</xsl:otherwise>' +
3063
+ ' </xsl:choose>' +
3064
+ ' </xsl:attribute>' +
3065
+ ' <xsl:attribute name="class"><xsl:value-of select="@lang" /> <xsl:value-of select="@class" /></xsl:attribute>' +
3066
+ ' <xsl:attribute name="style"><xsl:value-of select="@style" /></xsl:attribute>' +
3067
+ ' <xsl:for-each select="@*">' +
3068
+ ' <xsl:if test="name() != \'style\' and name() != \'class\' and name() != \'href\'">' +
3069
+ ' <xsl:attribute name="{name()}"><xsl:value-of select="." /></xsl:attribute>' +
3070
+ ' </xsl:if>' +
3071
+ ' </xsl:for-each>' +
3072
+ ' <ins>' +
3073
+ ' <xsl:attribute name="class">jstree-icon ' +
3074
+ ' <xsl:if test="string-length(attribute::icon) > 0 and not(contains(@icon,\'/\'))"><xsl:value-of select="@icon" /></xsl:if>' +
3075
+ ' </xsl:attribute>' +
3076
+ ' <xsl:if test="string-length(attribute::icon) > 0 and contains(@icon,\'/\')"><xsl:attribute name="style">background:url(<xsl:value-of select="@icon" />) center center no-repeat;</xsl:attribute></xsl:if>' +
3077
+ ' <xsl:text>&#xa0;</xsl:text>' +
3078
+ ' </ins>' +
3079
+ ' <xsl:copy-of select="./child::node()" />' +
3080
+ ' </a>' +
3081
+ ' </xsl:for-each>' +
3082
+ ' <xsl:if test="$children or @hasChildren"><xsl:call-template name="nodes"><xsl:with-param name="node" select="current()" /></xsl:call-template></xsl:if>' +
3083
+ ' </li>' +
3084
+ ' </xsl:for-each>' +
3085
+ ' </ul>' +
3086
+ '</xsl:template>' +
3087
+ '</xsl:stylesheet>',
3088
+
3089
+ 'flat' : '<' + '?xml version="1.0" encoding="utf-8" ?>' +
3090
+ '<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >' +
3091
+ '<xsl:output method="html" encoding="utf-8" omit-xml-declaration="yes" standalone="no" indent="no" media-type="text/xml" />' +
3092
+ '<xsl:template match="/">' +
3093
+ ' <ul>' +
3094
+ ' <xsl:for-each select="//item[not(@parent_id) or @parent_id=0 or not(@parent_id = //item/@id)]">' + /* the last `or` may be removed */
3095
+ ' <xsl:call-template name="nodes">' +
3096
+ ' <xsl:with-param name="node" select="." />' +
3097
+ ' <xsl:with-param name="is_last" select="number(position() = last())" />' +
3098
+ ' </xsl:call-template>' +
3099
+ ' </xsl:for-each>' +
3100
+ ' </ul>' +
3101
+ '</xsl:template>' +
3102
+ '<xsl:template name="nodes">' +
3103
+ ' <xsl:param name="node" />' +
3104
+ ' <xsl:param name="is_last" />' +
3105
+ ' <xsl:variable name="children" select="count(//item[@parent_id=$node/attribute::id]) &gt; 0" />' +
3106
+ ' <li>' +
3107
+ ' <xsl:attribute name="class">' +
3108
+ ' <xsl:if test="$is_last = true()">jstree-last </xsl:if>' +
3109
+ ' <xsl:choose>' +
3110
+ ' <xsl:when test="@state = \'open\'">jstree-open </xsl:when>' +
3111
+ ' <xsl:when test="$children or @hasChildren or @state = \'closed\'">jstree-closed </xsl:when>' +
3112
+ ' <xsl:otherwise>jstree-leaf </xsl:otherwise>' +
3113
+ ' </xsl:choose>' +
3114
+ ' <xsl:value-of select="@class" />' +
3115
+ ' </xsl:attribute>' +
3116
+ ' <xsl:for-each select="@*">' +
3117
+ ' <xsl:if test="name() != \'parent_id\' and name() != \'hasChildren\' and name() != \'class\' and name() != \'state\'">' +
3118
+ ' <xsl:attribute name="{name()}"><xsl:value-of select="." /></xsl:attribute>' +
3119
+ ' </xsl:if>' +
3120
+ ' </xsl:for-each>' +
3121
+ ' <ins class="jstree-icon"><xsl:text>&#xa0;</xsl:text></ins>' +
3122
+ ' <xsl:for-each select="content/name">' +
3123
+ ' <a>' +
3124
+ ' <xsl:attribute name="href">' +
3125
+ ' <xsl:choose>' +
3126
+ ' <xsl:when test="@href"><xsl:value-of select="@href" /></xsl:when>' +
3127
+ ' <xsl:otherwise>#</xsl:otherwise>' +
3128
+ ' </xsl:choose>' +
3129
+ ' </xsl:attribute>' +
3130
+ ' <xsl:attribute name="class"><xsl:value-of select="@lang" /> <xsl:value-of select="@class" /></xsl:attribute>' +
3131
+ ' <xsl:attribute name="style"><xsl:value-of select="@style" /></xsl:attribute>' +
3132
+ ' <xsl:for-each select="@*">' +
3133
+ ' <xsl:if test="name() != \'style\' and name() != \'class\' and name() != \'href\'">' +
3134
+ ' <xsl:attribute name="{name()}"><xsl:value-of select="." /></xsl:attribute>' +
3135
+ ' </xsl:if>' +
3136
+ ' </xsl:for-each>' +
3137
+ ' <ins>' +
3138
+ ' <xsl:attribute name="class">jstree-icon ' +
3139
+ ' <xsl:if test="string-length(attribute::icon) > 0 and not(contains(@icon,\'/\'))"><xsl:value-of select="@icon" /></xsl:if>' +
3140
+ ' </xsl:attribute>' +
3141
+ ' <xsl:if test="string-length(attribute::icon) > 0 and contains(@icon,\'/\')"><xsl:attribute name="style">background:url(<xsl:value-of select="@icon" />) center center no-repeat;</xsl:attribute></xsl:if>' +
3142
+ ' <xsl:text>&#xa0;</xsl:text>' +
3143
+ ' </ins>' +
3144
+ ' <xsl:copy-of select="./child::node()" />' +
3145
+ ' </a>' +
3146
+ ' </xsl:for-each>' +
3147
+ ' <xsl:if test="$children">' +
3148
+ ' <ul>' +
3149
+ ' <xsl:for-each select="//item[@parent_id=$node/attribute::id]">' +
3150
+ ' <xsl:call-template name="nodes">' +
3151
+ ' <xsl:with-param name="node" select="." />' +
3152
+ ' <xsl:with-param name="is_last" select="number(position() = last())" />' +
3153
+ ' </xsl:call-template>' +
3154
+ ' </xsl:for-each>' +
3155
+ ' </ul>' +
3156
+ ' </xsl:if>' +
3157
+ ' </li>' +
3158
+ '</xsl:template>' +
3159
+ '</xsl:stylesheet>'
3160
+ };
3161
+ $.jstree.plugin("xml_data", {
3162
+ defaults : {
3163
+ data : false,
3164
+ ajax : false,
3165
+ xsl : "flat",
3166
+ clean_node : false,
3167
+ correct_state : true,
3168
+ get_skip_empty : false
3169
+ },
3170
+ _fn : {
3171
+ load_node : function (obj, s_call, e_call) { var _this = this; this.load_node_xml(obj, function () { _this.__callback({ "obj" : _this._get_node(obj) }); s_call.call(this); }, e_call); },
3172
+ _is_loaded : function (obj) {
3173
+ var s = this._get_settings().xml_data;
3174
+ obj = this._get_node(obj);
3175
+ return obj == -1 || !obj || (!s.ajax && !$.isFunction(s.data)) || obj.is(".jstree-open, .jstree-leaf") || obj.children("ul").children("li").size() > 0;
3176
+ },
3177
+ load_node_xml : function (obj, s_call, e_call) {
3178
+ var s = this.get_settings().xml_data,
3179
+ error_func = function () {},
3180
+ success_func = function () {};
3181
+
3182
+ obj = this._get_node(obj);
3183
+ if(obj && obj !== -1) {
3184
+ if(obj.data("jstree-is-loading")) { return; }
3185
+ else { obj.data("jstree-is-loading",true); }
3186
+ }
3187
+ switch(!0) {
3188
+ case (!s.data && !s.ajax): throw "Neither data nor ajax settings supplied.";
3189
+ case ($.isFunction(s.data)):
3190
+ s.data.call(this, obj, $.proxy(function (d) {
3191
+ this.parse_xml(d, $.proxy(function (d) {
3192
+ if(d) {
3193
+ d = d.replace(/ ?xmlns="[^"]*"/ig, "");
3194
+ if(d.length > 10) {
3195
+ d = $(d);
3196
+ if(obj === -1 || !obj) { this.get_container().children("ul").empty().append(d.children()); }
3197
+ else { obj.children("a.jstree-loading").removeClass("jstree-loading"); obj.append(d); obj.removeData("jstree-is-loading"); }
3198
+ if(s.clean_node) { this.clean_node(obj); }
3199
+ if(s_call) { s_call.call(this); }
3200
+ }
3201
+ else {
3202
+ if(obj && obj !== -1) {
3203
+ obj.children("a.jstree-loading").removeClass("jstree-loading");
3204
+ obj.removeData("jstree-is-loading");
3205
+ if(s.correct_state) {
3206
+ this.correct_state(obj);
3207
+ if(s_call) { s_call.call(this); }
3208
+ }
3209
+ }
3210
+ else {
3211
+ if(s.correct_state) {
3212
+ this.get_container().children("ul").empty();
3213
+ if(s_call) { s_call.call(this); }
3214
+ }
3215
+ }
3216
+ }
3217
+ }
3218
+ }, this));
3219
+ }, this));
3220
+ break;
3221
+ case (!!s.data && !s.ajax) || (!!s.data && !!s.ajax && (!obj || obj === -1)):
3222
+ if(!obj || obj == -1) {
3223
+ this.parse_xml(s.data, $.proxy(function (d) {
3224
+ if(d) {
3225
+ d = d.replace(/ ?xmlns="[^"]*"/ig, "");
3226
+ if(d.length > 10) {
3227
+ d = $(d);
3228
+ this.get_container().children("ul").empty().append(d.children());
3229
+ if(s.clean_node) { this.clean_node(obj); }
3230
+ if(s_call) { s_call.call(this); }
3231
+ }
3232
+ }
3233
+ else {
3234
+ if(s.correct_state) {
3235
+ this.get_container().children("ul").empty();
3236
+ if(s_call) { s_call.call(this); }
3237
+ }
3238
+ }
3239
+ }, this));
3240
+ }
3241
+ break;
3242
+ case (!s.data && !!s.ajax) || (!!s.data && !!s.ajax && obj && obj !== -1):
3243
+ error_func = function (x, t, e) {
3244
+ var ef = this.get_settings().xml_data.ajax.error;
3245
+ if(ef) { ef.call(this, x, t, e); }
3246
+ if(obj !== -1 && obj.length) {
3247
+ obj.children("a.jstree-loading").removeClass("jstree-loading");
3248
+ obj.removeData("jstree-is-loading");
3249
+ if(t === "success" && s.correct_state) { this.correct_state(obj); }
3250
+ }
3251
+ else {
3252
+ if(t === "success" && s.correct_state) { this.get_container().children("ul").empty(); }
3253
+ }
3254
+ if(e_call) { e_call.call(this); }
3255
+ };
3256
+ success_func = function (d, t, x) {
3257
+ d = x.responseText;
3258
+ var sf = this.get_settings().xml_data.ajax.success;
3259
+ if(sf) { d = sf.call(this,d,t,x) || d; }
3260
+ if(d === "" || (d && d.toString && d.toString().replace(/^[\s\n]+$/,"") === "")) {
3261
+ return error_func.call(this, x, t, "");
3262
+ }
3263
+ this.parse_xml(d, $.proxy(function (d) {
3264
+ if(d) {
3265
+ d = d.replace(/ ?xmlns="[^"]*"/ig, "");
3266
+ if(d.length > 10) {
3267
+ d = $(d);
3268
+ if(obj === -1 || !obj) { this.get_container().children("ul").empty().append(d.children()); }
3269
+ else { obj.children("a.jstree-loading").removeClass("jstree-loading"); obj.append(d); obj.removeData("jstree-is-loading"); }
3270
+ if(s.clean_node) { this.clean_node(obj); }
3271
+ if(s_call) { s_call.call(this); }
3272
+ }
3273
+ else {
3274
+ if(obj && obj !== -1) {
3275
+ obj.children("a.jstree-loading").removeClass("jstree-loading");
3276
+ obj.removeData("jstree-is-loading");
3277
+ if(s.correct_state) {
3278
+ this.correct_state(obj);
3279
+ if(s_call) { s_call.call(this); }
3280
+ }
3281
+ }
3282
+ else {
3283
+ if(s.correct_state) {
3284
+ this.get_container().children("ul").empty();
3285
+ if(s_call) { s_call.call(this); }
3286
+ }
3287
+ }
3288
+ }
3289
+ }
3290
+ }, this));
3291
+ };
3292
+ s.ajax.context = this;
3293
+ s.ajax.error = error_func;
3294
+ s.ajax.success = success_func;
3295
+ if(!s.ajax.dataType) { s.ajax.dataType = "xml"; }
3296
+ if($.isFunction(s.ajax.url)) { s.ajax.url = s.ajax.url.call(this, obj); }
3297
+ if($.isFunction(s.ajax.data)) { s.ajax.data = s.ajax.data.call(this, obj); }
3298
+ $.ajax(s.ajax);
3299
+ break;
3300
+ }
3301
+ },
3302
+ parse_xml : function (xml, callback) {
3303
+ var s = this._get_settings().xml_data;
3304
+ $.vakata.xslt(xml, xsl[s.xsl], callback);
3305
+ },
3306
+ get_xml : function (tp, obj, li_attr, a_attr, is_callback) {
3307
+ var result = "",
3308
+ s = this._get_settings(),
3309
+ _this = this,
3310
+ tmp1, tmp2, li, a, lang;
3311
+ if(!tp) { tp = "flat"; }
3312
+ if(!is_callback) { is_callback = 0; }
3313
+ obj = this._get_node(obj);
3314
+ if(!obj || obj === -1) { obj = this.get_container().find("> ul > li"); }
3315
+ li_attr = $.isArray(li_attr) ? li_attr : [ "id", "class" ];
3316
+ if(!is_callback && this.data.types && $.inArray(s.types.type_attr, li_attr) === -1) { li_attr.push(s.types.type_attr); }
3317
+
3318
+ a_attr = $.isArray(a_attr) ? a_attr : [ ];
3319
+
3320
+ if(!is_callback) { result += "<root>"; }
3321
+ obj.each(function () {
3322
+ result += "<item";
3323
+ li = $(this);
3324
+ $.each(li_attr, function (i, v) {
3325
+ var t = li.attr(v);
3326
+ if(!s.xml_data.get_skip_empty || typeof t !== "undefined") {
3327
+ result += " " + v + "=\"" + (" " + (t || "")).replace(/ jstree[^ ]*/ig,'').replace(/\s+$/ig," ").replace(/^ /,"").replace(/ $/,"") + "\"";
3328
+ }
3329
+ });
3330
+ if(li.hasClass("jstree-open")) { result += " state=\"open\""; }
3331
+ if(li.hasClass("jstree-closed")) { result += " state=\"closed\""; }
3332
+ if(tp === "flat") { result += " parent_id=\"" + is_callback + "\""; }
3333
+ result += ">";
3334
+ result += "<content>";
3335
+ a = li.children("a");
3336
+ a.each(function () {
3337
+ tmp1 = $(this);
3338
+ lang = false;
3339
+ result += "<name";
3340
+ if($.inArray("languages", s.plugins) !== -1) {
3341
+ $.each(s.languages, function (k, z) {
3342
+ if(tmp1.hasClass(z)) { result += " lang=\"" + z + "\""; lang = z; return false; }
3343
+ });
3344
+ }
3345
+ if(a_attr.length) {
3346
+ $.each(a_attr, function (k, z) {
3347
+ var t = tmp1.attr(z);
3348
+ if(!s.xml_data.get_skip_empty || typeof t !== "undefined") {
3349
+ result += " " + z + "=\"" + (" " + t || "").replace(/ jstree[^ ]*/ig,'').replace(/\s+$/ig," ").replace(/^ /,"").replace(/ $/,"") + "\"";
3350
+ }
3351
+ });
3352
+ }
3353
+ if(tmp1.children("ins").get(0).className.replace(/jstree[^ ]*|$/ig,'').replace(/^\s+$/ig,"").length) {
3354
+ result += ' icon="' + tmp1.children("ins").get(0).className.replace(/jstree[^ ]*|$/ig,'').replace(/\s+$/ig," ").replace(/^ /,"").replace(/ $/,"") + '"';
3355
+ }
3356
+ if(tmp1.children("ins").get(0).style.backgroundImage.length) {
3357
+ result += ' icon="' + tmp1.children("ins").get(0).style.backgroundImage.replace("url(","").replace(")","").replace(/'/ig,"").replace(/"/ig,"") + '"';
3358
+ }
3359
+ result += ">";
3360
+ result += "<![CDATA[" + _this.get_text(tmp1, lang) + "]]>";
3361
+ result += "</name>";
3362
+ });
3363
+ result += "</content>";
3364
+ tmp2 = li[0].id || true;
3365
+ li = li.find("> ul > li");
3366
+ if(li.length) { tmp2 = _this.get_xml(tp, li, li_attr, a_attr, tmp2); }
3367
+ else { tmp2 = ""; }
3368
+ if(tp == "nest") { result += tmp2; }
3369
+ result += "</item>";
3370
+ if(tp == "flat") { result += tmp2; }
3371
+ });
3372
+ if(!is_callback) { result += "</root>"; }
3373
+ return result;
3374
+ }
3375
+ }
3376
+ });
3377
+ })(jQuery);
3378
+ //*/
3379
+
3380
+ /*
3381
+ * jsTree search plugin
3382
+ * Enables both sync and async search on the tree
3383
+ * DOES NOT WORK WITH JSON PROGRESSIVE RENDER
3384
+ */
3385
+ (function ($) {
3386
+ $.expr[':'].jstree_contains = function(a,i,m){
3387
+ return (a.textContent || a.innerText || "").toLowerCase().indexOf(m[3].toLowerCase())>=0;
3388
+ };
3389
+ $.expr[':'].jstree_title_contains = function(a,i,m) {
3390
+ return (a.getAttribute("title") || "").toLowerCase().indexOf(m[3].toLowerCase())>=0;
3391
+ };
3392
+ $.jstree.plugin("search", {
3393
+ __init : function () {
3394
+ this.data.search.str = "";
3395
+ this.data.search.result = $();
3396
+ if(this._get_settings().search.show_only_matches) {
3397
+ this.get_container()
3398
+ .bind("search.jstree", function (e, data) {
3399
+ $(this).children("ul").find("li").hide().removeClass("jstree-last");
3400
+ data.rslt.nodes.parentsUntil(".jstree").andSelf().show()
3401
+ .filter("ul").each(function () { $(this).children("li:visible").eq(-1).addClass("jstree-last"); });
3402
+ })
3403
+ .bind("clear_search.jstree", function () {
3404
+ $(this).children("ul").find("li").css("display","").end().jstree("clean_node", -1);
3405
+ });
3406
+ }
3407
+ },
3408
+ defaults : {
3409
+ ajax : false,
3410
+ search_method : "jstree_contains", // for case insensitive - jstree_contains
3411
+ show_only_matches : false
3412
+ },
3413
+ _fn : {
3414
+ search : function (str, skip_async) {
3415
+ if($.trim(str) === "") { this.clear_search(); return; }
3416
+ var s = this.get_settings().search,
3417
+ t = this,
3418
+ error_func = function () { },
3419
+ success_func = function () { };
3420
+ this.data.search.str = str;
3421
+
3422
+ if(!skip_async && s.ajax !== false && this.get_container_ul().find("li.jstree-closed:not(:has(ul)):eq(0)").length > 0) {
3423
+ this.search.supress_callback = true;
3424
+ error_func = function () { };
3425
+ success_func = function (d, t, x) {
3426
+ var sf = this.get_settings().search.ajax.success;
3427
+ if(sf) { d = sf.call(this,d,t,x) || d; }
3428
+ this.data.search.to_open = d;
3429
+ this._search_open();
3430
+ };
3431
+ s.ajax.context = this;
3432
+ s.ajax.error = error_func;
3433
+ s.ajax.success = success_func;
3434
+ if($.isFunction(s.ajax.url)) { s.ajax.url = s.ajax.url.call(this, str); }
3435
+ if($.isFunction(s.ajax.data)) { s.ajax.data = s.ajax.data.call(this, str); }
3436
+ if(!s.ajax.data) { s.ajax.data = { "search_string" : str }; }
3437
+ if(!s.ajax.dataType || /^json/.exec(s.ajax.dataType)) { s.ajax.dataType = "json"; }
3438
+ $.ajax(s.ajax);
3439
+ return;
3440
+ }
3441
+ if(this.data.search.result.length) { this.clear_search(); }
3442
+ this.data.search.result = this.get_container().find("a" + (this.data.languages ? "." + this.get_lang() : "" ) + ":" + (s.search_method) + "(" + this.data.search.str + ")");
3443
+ this.data.search.result.addClass("jstree-search").parent().parents(".jstree-closed").each(function () {
3444
+ t.open_node(this, false, true);
3445
+ });
3446
+ this.__callback({ nodes : this.data.search.result, str : str });
3447
+ },
3448
+ clear_search : function (str) {
3449
+ this.data.search.result.removeClass("jstree-search");
3450
+ this.__callback(this.data.search.result);
3451
+ this.data.search.result = $();
3452
+ },
3453
+ _search_open : function (is_callback) {
3454
+ var _this = this,
3455
+ done = true,
3456
+ current = [],
3457
+ remaining = [];
3458
+ if(this.data.search.to_open.length) {
3459
+ $.each(this.data.search.to_open, function (i, val) {
3460
+ if(val == "#") { return true; }
3461
+ if($(val).length && $(val).is(".jstree-closed")) { current.push(val); }
3462
+ else { remaining.push(val); }
3463
+ });
3464
+ if(current.length) {
3465
+ this.data.search.to_open = remaining;
3466
+ $.each(current, function (i, val) {
3467
+ _this.open_node(val, function () { _this._search_open(true); });
3468
+ });
3469
+ done = false;
3470
+ }
3471
+ }
3472
+ if(done) { this.search(this.data.search.str, true); }
3473
+ }
3474
+ }
3475
+ });
3476
+ })(jQuery);
3477
+ //*/
3478
+
3479
+ /*
3480
+ * jsTree contextmenu plugin
3481
+ */
3482
+ (function ($) {
3483
+ $.vakata.context = {
3484
+ hide_on_mouseleave : false,
3485
+
3486
+ cnt : $("<div id='vakata-contextmenu' />"),
3487
+ vis : false,
3488
+ tgt : false,
3489
+ par : false,
3490
+ func : false,
3491
+ data : false,
3492
+ rtl : false,
3493
+ show : function (s, t, x, y, d, p, rtl) {
3494
+ $.vakata.context.rtl = !!rtl;
3495
+ var html = $.vakata.context.parse(s), h, w;
3496
+ if(!html) { return; }
3497
+ $.vakata.context.vis = true;
3498
+ $.vakata.context.tgt = t;
3499
+ $.vakata.context.par = p || t || null;
3500
+ $.vakata.context.data = d || null;
3501
+ $.vakata.context.cnt
3502
+ .html(html)
3503
+ .css({ "visibility" : "hidden", "display" : "block", "left" : 0, "top" : 0 });
3504
+
3505
+ if($.vakata.context.hide_on_mouseleave) {
3506
+ $.vakata.context.cnt
3507
+ .one("mouseleave", function(e) { $.vakata.context.hide(); });
3508
+ }
3509
+
3510
+ h = $.vakata.context.cnt.height();
3511
+ w = $.vakata.context.cnt.width();
3512
+ if(x + w > $(document).width()) {
3513
+ x = $(document).width() - (w + 5);
3514
+ $.vakata.context.cnt.find("li > ul").addClass("right");
3515
+ }
3516
+ if(y + h > $(document).height()) {
3517
+ y = y - (h + t[0].offsetHeight);
3518
+ $.vakata.context.cnt.find("li > ul").addClass("bottom");
3519
+ }
3520
+
3521
+ $.vakata.context.cnt
3522
+ .css({ "left" : x, "top" : y })
3523
+ .find("li:has(ul)")
3524
+ .bind("mouseenter", function (e) {
3525
+ var w = $(document).width(),
3526
+ h = $(document).height(),
3527
+ ul = $(this).children("ul").show();
3528
+ if(w !== $(document).width()) { ul.toggleClass("right"); }
3529
+ if(h !== $(document).height()) { ul.toggleClass("bottom"); }
3530
+ })
3531
+ .bind("mouseleave", function (e) {
3532
+ $(this).children("ul").hide();
3533
+ })
3534
+ .end()
3535
+ .css({ "visibility" : "visible" })
3536
+ .show();
3537
+ $(document).triggerHandler("context_show.vakata");
3538
+ },
3539
+ hide : function () {
3540
+ $.vakata.context.vis = false;
3541
+ $.vakata.context.cnt.attr("class","").css({ "visibility" : "hidden" });
3542
+ $(document).triggerHandler("context_hide.vakata");
3543
+ },
3544
+ parse : function (s, is_callback) {
3545
+ if(!s) { return false; }
3546
+ var str = "",
3547
+ tmp = false,
3548
+ was_sep = true;
3549
+ if(!is_callback) { $.vakata.context.func = {}; }
3550
+ str += "<ul>";
3551
+ $.each(s, function (i, val) {
3552
+ if(!val) { return true; }
3553
+ $.vakata.context.func[i] = val.action;
3554
+ if(!was_sep && val.separator_before) {
3555
+ str += "<li class='vakata-separator vakata-separator-before'></li>";
3556
+ }
3557
+ was_sep = false;
3558
+ str += "<li class='" + (val._class || "") + (val._disabled ? " jstree-contextmenu-disabled " : "") + "'><ins ";
3559
+ if(val.icon && val.icon.indexOf("/") === -1) { str += " class='" + val.icon + "' "; }
3560
+ if(val.icon && val.icon.indexOf("/") !== -1) { str += " style='background:url(" + val.icon + ") center center no-repeat;' "; }
3561
+ str += ">&#160;</ins><a href='#' rel='" + i + "'>";
3562
+ if(val.submenu) {
3563
+ str += "<span style='float:" + ($.vakata.context.rtl ? "left" : "right") + ";'>&raquo;</span>";
3564
+ }
3565
+ str += val.label + "</a>";
3566
+ if(val.submenu) {
3567
+ tmp = $.vakata.context.parse(val.submenu, true);
3568
+ if(tmp) { str += tmp; }
3569
+ }
3570
+ str += "</li>";
3571
+ if(val.separator_after) {
3572
+ str += "<li class='vakata-separator vakata-separator-after'></li>";
3573
+ was_sep = true;
3574
+ }
3575
+ });
3576
+ str = str.replace(/<li class\='vakata-separator vakata-separator-after'\><\/li\>$/,"");
3577
+ str += "</ul>";
3578
+ $(document).triggerHandler("context_parse.vakata");
3579
+ return str.length > 10 ? str : false;
3580
+ },
3581
+ exec : function (i) {
3582
+ if($.isFunction($.vakata.context.func[i])) {
3583
+ $.vakata.context.func[i].call($.vakata.context.data, $.vakata.context.par);
3584
+ return true;
3585
+ }
3586
+ else { return false; }
3587
+ }
3588
+ };
3589
+ $(function () {
3590
+ var css_string = '' +
3591
+ '#vakata-contextmenu { display:block; visibility:hidden; left:0; top:-200px; position:absolute; margin:0; padding:0; min-width:180px; background:#ebebeb; border:1px solid silver; z-index:10000; *width:180px; } ' +
3592
+ '#vakata-contextmenu ul { min-width:180px; *width:180px; } ' +
3593
+ '#vakata-contextmenu ul, #vakata-contextmenu li { margin:0; padding:0; list-style-type:none; display:block; } ' +
3594
+ '#vakata-contextmenu li { line-height:20px; min-height:20px; position:relative; padding:0px; } ' +
3595
+ '#vakata-contextmenu li a { padding:1px 6px; line-height:17px; display:block; text-decoration:none; margin:1px 1px 0 1px; } ' +
3596
+ '#vakata-contextmenu li ins { float:left; width:16px; height:16px; text-decoration:none; margin-right:2px; } ' +
3597
+ '#vakata-contextmenu li a:hover, #vakata-contextmenu li.vakata-hover > a { background:gray; color:white; } ' +
3598
+ '#vakata-contextmenu li ul { display:none; position:absolute; top:-2px; left:100%; background:#ebebeb; border:1px solid gray; } ' +
3599
+ '#vakata-contextmenu .right { right:100%; left:auto; } ' +
3600
+ '#vakata-contextmenu .bottom { bottom:-1px; top:auto; } ' +
3601
+ '#vakata-contextmenu li.vakata-separator { min-height:0; height:1px; line-height:1px; font-size:1px; overflow:hidden; margin:0 2px; background:silver; /* border-top:1px solid #fefefe; */ padding:0; } ';
3602
+ $.vakata.css.add_sheet({ str : css_string, title : "vakata" });
3603
+ $.vakata.context.cnt
3604
+ .delegate("a","click", function (e) { e.preventDefault(); })
3605
+ .delegate("a","mouseup", function (e) {
3606
+ if(!$(this).parent().hasClass("jstree-contextmenu-disabled") && $.vakata.context.exec($(this).attr("rel"))) {
3607
+ $.vakata.context.hide();
3608
+ }
3609
+ else { $(this).blur(); }
3610
+ })
3611
+ .delegate("a","mouseover", function () {
3612
+ $.vakata.context.cnt.find(".vakata-hover").removeClass("vakata-hover");
3613
+ })
3614
+ .appendTo("body");
3615
+ $(document).bind("mousedown", function (e) { if($.vakata.context.vis && !$.contains($.vakata.context.cnt[0], e.target)) { $.vakata.context.hide(); } });
3616
+ if(typeof $.hotkeys !== "undefined") {
3617
+ $(document)
3618
+ .bind("keydown", "up", function (e) {
3619
+ if($.vakata.context.vis) {
3620
+ var o = $.vakata.context.cnt.find("ul:visible").last().children(".vakata-hover").removeClass("vakata-hover").prevAll("li:not(.vakata-separator)").first();
3621
+ if(!o.length) { o = $.vakata.context.cnt.find("ul:visible").last().children("li:not(.vakata-separator)").last(); }
3622
+ o.addClass("vakata-hover");
3623
+ e.stopImmediatePropagation();
3624
+ e.preventDefault();
3625
+ }
3626
+ })
3627
+ .bind("keydown", "down", function (e) {
3628
+ if($.vakata.context.vis) {
3629
+ var o = $.vakata.context.cnt.find("ul:visible").last().children(".vakata-hover").removeClass("vakata-hover").nextAll("li:not(.vakata-separator)").first();
3630
+ if(!o.length) { o = $.vakata.context.cnt.find("ul:visible").last().children("li:not(.vakata-separator)").first(); }
3631
+ o.addClass("vakata-hover");
3632
+ e.stopImmediatePropagation();
3633
+ e.preventDefault();
3634
+ }
3635
+ })
3636
+ .bind("keydown", "right", function (e) {
3637
+ if($.vakata.context.vis) {
3638
+ $.vakata.context.cnt.find(".vakata-hover").children("ul").show().children("li:not(.vakata-separator)").removeClass("vakata-hover").first().addClass("vakata-hover");
3639
+ e.stopImmediatePropagation();
3640
+ e.preventDefault();
3641
+ }
3642
+ })
3643
+ .bind("keydown", "left", function (e) {
3644
+ if($.vakata.context.vis) {
3645
+ $.vakata.context.cnt.find(".vakata-hover").children("ul").hide().children(".vakata-separator").removeClass("vakata-hover");
3646
+ e.stopImmediatePropagation();
3647
+ e.preventDefault();
3648
+ }
3649
+ })
3650
+ .bind("keydown", "esc", function (e) {
3651
+ $.vakata.context.hide();
3652
+ e.preventDefault();
3653
+ })
3654
+ .bind("keydown", "space", function (e) {
3655
+ $.vakata.context.cnt.find(".vakata-hover").last().children("a").click();
3656
+ e.preventDefault();
3657
+ });
3658
+ }
3659
+ });
3660
+
3661
+ $.jstree.plugin("contextmenu", {
3662
+ __init : function () {
3663
+ this.get_container()
3664
+ .delegate("a", "contextmenu.jstree", $.proxy(function (e) {
3665
+ e.preventDefault();
3666
+ if(!$(e.currentTarget).hasClass("jstree-loading")) {
3667
+ this.show_contextmenu(e.currentTarget, e.pageX, e.pageY);
3668
+ }
3669
+ }, this))
3670
+ .delegate("a", "click.jstree", $.proxy(function (e) {
3671
+ if(this.data.contextmenu) {
3672
+ $.vakata.context.hide();
3673
+ }
3674
+ }, this))
3675
+ .bind("destroy.jstree", $.proxy(function () {
3676
+ // TODO: move this to descruct method
3677
+ if(this.data.contextmenu) {
3678
+ $.vakata.context.hide();
3679
+ }
3680
+ }, this));
3681
+ $(document).bind("context_hide.vakata", $.proxy(function () { this.data.contextmenu = false; }, this));
3682
+ },
3683
+ defaults : {
3684
+ select_node : false, // requires UI plugin
3685
+ show_at_node : true,
3686
+ items : { // Could be a function that should return an object like this one
3687
+ "create" : {
3688
+ "separator_before" : false,
3689
+ "separator_after" : true,
3690
+ "label" : "Create",
3691
+ "action" : function (obj) { this.create(obj); }
3692
+ },
3693
+ "rename" : {
3694
+ "separator_before" : false,
3695
+ "separator_after" : false,
3696
+ "label" : "Rename",
3697
+ "action" : function (obj) { this.rename(obj); }
3698
+ },
3699
+ "remove" : {
3700
+ "separator_before" : false,
3701
+ "icon" : false,
3702
+ "separator_after" : false,
3703
+ "label" : "Delete",
3704
+ "action" : function (obj) { if(this.is_selected(obj)) { this.remove(); } else { this.remove(obj); } }
3705
+ },
3706
+ "ccp" : {
3707
+ "separator_before" : true,
3708
+ "icon" : false,
3709
+ "separator_after" : false,
3710
+ "label" : "Edit",
3711
+ "action" : false,
3712
+ "submenu" : {
3713
+ "cut" : {
3714
+ "separator_before" : false,
3715
+ "separator_after" : false,
3716
+ "label" : "Cut",
3717
+ "action" : function (obj) { this.cut(obj); }
3718
+ },
3719
+ "copy" : {
3720
+ "separator_before" : false,
3721
+ "icon" : false,
3722
+ "separator_after" : false,
3723
+ "label" : "Copy",
3724
+ "action" : function (obj) { this.copy(obj); }
3725
+ },
3726
+ "paste" : {
3727
+ "separator_before" : false,
3728
+ "icon" : false,
3729
+ "separator_after" : false,
3730
+ "label" : "Paste",
3731
+ "action" : function (obj) { this.paste(obj); }
3732
+ }
3733
+ }
3734
+ }
3735
+ }
3736
+ },
3737
+ _fn : {
3738
+ show_contextmenu : function (obj, x, y) {
3739
+ obj = this._get_node(obj);
3740
+ var s = this.get_settings().contextmenu,
3741
+ a = obj.children("a:visible:eq(0)"),
3742
+ o = false,
3743
+ i = false;
3744
+ if(s.select_node && this.data.ui && !this.is_selected(obj)) {
3745
+ this.deselect_all();
3746
+ this.select_node(obj, true);
3747
+ }
3748
+ if(s.show_at_node || typeof x === "undefined" || typeof y === "undefined") {
3749
+ o = a.offset();
3750
+ x = o.left;
3751
+ y = o.top + this.data.core.li_height;
3752
+ }
3753
+ i = obj.data("jstree") && obj.data("jstree").contextmenu ? obj.data("jstree").contextmenu : s.items;
3754
+ if($.isFunction(i)) { i = i.call(this, obj); }
3755
+ this.data.contextmenu = true;
3756
+ $.vakata.context.show(i, a, x, y, this, obj, this._get_settings().core.rtl);
3757
+ if(this.data.themes) { $.vakata.context.cnt.attr("class", "jstree-" + this.data.themes.theme + "-context"); }
3758
+ }
3759
+ }
3760
+ });
3761
+ })(jQuery);
3762
+ //*/
3763
+
3764
+ /*
3765
+ * jsTree types plugin
3766
+ * Adds support types of nodes
3767
+ * You can set an attribute on each li node, that represents its type.
3768
+ * According to the type setting the node may get custom icon/validation rules
3769
+ */
3770
+ (function ($) {
3771
+ $.jstree.plugin("types", {
3772
+ __init : function () {
3773
+ var s = this._get_settings().types;
3774
+ this.data.types.attach_to = [];
3775
+ this.get_container()
3776
+ .bind("init.jstree", $.proxy(function () {
3777
+ var types = s.types,
3778
+ attr = s.type_attr,
3779
+ icons_css = "",
3780
+ _this = this;
3781
+
3782
+ $.each(types, function (i, tp) {
3783
+ $.each(tp, function (k, v) {
3784
+ if(!/^(max_depth|max_children|icon|valid_children)$/.test(k)) { _this.data.types.attach_to.push(k); }
3785
+ });
3786
+ if(!tp.icon) { return true; }
3787
+ if( tp.icon.image || tp.icon.position) {
3788
+ if(i == "default") { icons_css += '.jstree-' + _this.get_index() + ' a > .jstree-icon { '; }
3789
+ else { icons_css += '.jstree-' + _this.get_index() + ' li[' + attr + '="' + i + '"] > a > .jstree-icon { '; }
3790
+ if(tp.icon.image) { icons_css += ' background-image:url(' + tp.icon.image + '); '; }
3791
+ if(tp.icon.position){ icons_css += ' background-position:' + tp.icon.position + '; '; }
3792
+ else { icons_css += ' background-position:0 0; '; }
3793
+ icons_css += '} ';
3794
+ }
3795
+ });
3796
+ if(icons_css !== "") { $.vakata.css.add_sheet({ 'str' : icons_css, title : "jstree-types" }); }
3797
+ }, this))
3798
+ .bind("before.jstree", $.proxy(function (e, data) {
3799
+ var s, t,
3800
+ o = this._get_settings().types.use_data ? this._get_node(data.args[0]) : false,
3801
+ d = o && o !== -1 && o.length ? o.data("jstree") : false;
3802
+ if(d && d.types && d.types[data.func] === false) { e.stopImmediatePropagation(); return false; }
3803
+ if($.inArray(data.func, this.data.types.attach_to) !== -1) {
3804
+ if(!data.args[0] || (!data.args[0].tagName && !data.args[0].jquery)) { return; }
3805
+ s = this._get_settings().types.types;
3806
+ t = this._get_type(data.args[0]);
3807
+ if(
3808
+ (
3809
+ (s[t] && typeof s[t][data.func] !== "undefined") ||
3810
+ (s["default"] && typeof s["default"][data.func] !== "undefined")
3811
+ ) && this._check(data.func, data.args[0]) === false
3812
+ ) {
3813
+ e.stopImmediatePropagation();
3814
+ return false;
3815
+ }
3816
+ }
3817
+ }, this));
3818
+ if(is_ie6) {
3819
+ this.get_container()
3820
+ .bind("load_node.jstree set_type.jstree", $.proxy(function (e, data) {
3821
+ var r = data && data.rslt && data.rslt.obj && data.rslt.obj !== -1 ? this._get_node(data.rslt.obj).parent() : this.get_container_ul(),
3822
+ c = false,
3823
+ s = this._get_settings().types;
3824
+ $.each(s.types, function (i, tp) {
3825
+ if(tp.icon && (tp.icon.image || tp.icon.position)) {
3826
+ c = i === "default" ? r.find("li > a > .jstree-icon") : r.find("li[" + s.type_attr + "='" + i + "'] > a > .jstree-icon");
3827
+ if(tp.icon.image) { c.css("backgroundImage","url(" + tp.icon.image + ")"); }
3828
+ c.css("backgroundPosition", tp.icon.position || "0 0");
3829
+ }
3830
+ });
3831
+ }, this));
3832
+ }
3833
+ },
3834
+ defaults : {
3835
+ // defines maximum number of root nodes (-1 means unlimited, -2 means disable max_children checking)
3836
+ max_children : -1,
3837
+ // defines the maximum depth of the tree (-1 means unlimited, -2 means disable max_depth checking)
3838
+ max_depth : -1,
3839
+ // defines valid node types for the root nodes
3840
+ valid_children : "all",
3841
+
3842
+ // whether to use $.data
3843
+ use_data : false,
3844
+ // where is the type stores (the rel attribute of the LI element)
3845
+ type_attr : "rel",
3846
+ // a list of types
3847
+ types : {
3848
+ // the default type
3849
+ "default" : {
3850
+ "max_children" : -1,
3851
+ "max_depth" : -1,
3852
+ "valid_children": "all"
3853
+
3854
+ // Bound functions - you can bind any other function here (using boolean or function)
3855
+ //"select_node" : true
3856
+ }
3857
+ }
3858
+ },
3859
+ _fn : {
3860
+ _types_notify : function (n, data) {
3861
+ if(data.type && this._get_settings().types.use_data) {
3862
+ this.set_type(data.type, n);
3863
+ }
3864
+ },
3865
+ _get_type : function (obj) {
3866
+ obj = this._get_node(obj);
3867
+ return (!obj || !obj.length) ? false : obj.attr(this._get_settings().types.type_attr) || "default";
3868
+ },
3869
+ set_type : function (str, obj) {
3870
+ obj = this._get_node(obj);
3871
+ var ret = (!obj.length || !str) ? false : obj.attr(this._get_settings().types.type_attr, str);
3872
+ if(ret) { this.__callback({ obj : obj, type : str}); }
3873
+ return ret;
3874
+ },
3875
+ _check : function (rule, obj, opts) {
3876
+ obj = this._get_node(obj);
3877
+ var v = false, t = this._get_type(obj), d = 0, _this = this, s = this._get_settings().types, data = false;
3878
+ if(obj === -1) {
3879
+ if(!!s[rule]) { v = s[rule]; }
3880
+ else { return; }
3881
+ }
3882
+ else {
3883
+ if(t === false) { return; }
3884
+ data = s.use_data ? obj.data("jstree") : false;
3885
+ if(data && data.types && typeof data.types[rule] !== "undefined") { v = data.types[rule]; }
3886
+ else if(!!s.types[t] && typeof s.types[t][rule] !== "undefined") { v = s.types[t][rule]; }
3887
+ else if(!!s.types["default"] && typeof s.types["default"][rule] !== "undefined") { v = s.types["default"][rule]; }
3888
+ }
3889
+ if($.isFunction(v)) { v = v.call(this, obj); }
3890
+ if(rule === "max_depth" && obj !== -1 && opts !== false && s.max_depth !== -2 && v !== 0) {
3891
+ // also include the node itself - otherwise if root node it is not checked
3892
+ obj.children("a:eq(0)").parentsUntil(".jstree","li").each(function (i) {
3893
+ // check if current depth already exceeds global tree depth
3894
+ if(s.max_depth !== -1 && s.max_depth - (i + 1) <= 0) { v = 0; return false; }
3895
+ d = (i === 0) ? v : _this._check(rule, this, false);
3896
+ // check if current node max depth is already matched or exceeded
3897
+ if(d !== -1 && d - (i + 1) <= 0) { v = 0; return false; }
3898
+ // otherwise - set the max depth to the current value minus current depth
3899
+ if(d >= 0 && (d - (i + 1) < v || v < 0) ) { v = d - (i + 1); }
3900
+ // if the global tree depth exists and it minus the nodes calculated so far is less than `v` or `v` is unlimited
3901
+ if(s.max_depth >= 0 && (s.max_depth - (i + 1) < v || v < 0) ) { v = s.max_depth - (i + 1); }
3902
+ });
3903
+ }
3904
+ return v;
3905
+ },
3906
+ check_move : function () {
3907
+ if(!this.__call_old()) { return false; }
3908
+ var m = this._get_move(),
3909
+ s = m.rt._get_settings().types,
3910
+ mc = m.rt._check("max_children", m.cr),
3911
+ md = m.rt._check("max_depth", m.cr),
3912
+ vc = m.rt._check("valid_children", m.cr),
3913
+ ch = 0, d = 1, t;
3914
+
3915
+ if(vc === "none") { return false; }
3916
+ if($.isArray(vc) && m.ot && m.ot._get_type) {
3917
+ m.o.each(function () {
3918
+ if($.inArray(m.ot._get_type(this), vc) === -1) { d = false; return false; }
3919
+ });
3920
+ if(d === false) { return false; }
3921
+ }
3922
+ if(s.max_children !== -2 && mc !== -1) {
3923
+ ch = m.cr === -1 ? this.get_container().find("> ul > li").not(m.o).length : m.cr.find("> ul > li").not(m.o).length;
3924
+ if(ch + m.o.length > mc) { return false; }
3925
+ }
3926
+ if(s.max_depth !== -2 && md !== -1) {
3927
+ d = 0;
3928
+ if(md === 0) { return false; }
3929
+ if(typeof m.o.d === "undefined") {
3930
+ // TODO: deal with progressive rendering and async when checking max_depth (how to know the depth of the moved node)
3931
+ t = m.o;
3932
+ while(t.length > 0) {
3933
+ t = t.find("> ul > li");
3934
+ d ++;
3935
+ }
3936
+ m.o.d = d;
3937
+ }
3938
+ if(md - m.o.d < 0) { return false; }
3939
+ }
3940
+ return true;
3941
+ },
3942
+ create_node : function (obj, position, js, callback, is_loaded, skip_check) {
3943
+ if(!skip_check && (is_loaded || this._is_loaded(obj))) {
3944
+ var p = (typeof position == "string" && position.match(/^before|after$/i) && obj !== -1) ? this._get_parent(obj) : this._get_node(obj),
3945
+ s = this._get_settings().types,
3946
+ mc = this._check("max_children", p),
3947
+ md = this._check("max_depth", p),
3948
+ vc = this._check("valid_children", p),
3949
+ ch;
3950
+ if(typeof js === "string") { js = { data : js }; }
3951
+ if(!js) { js = {}; }
3952
+ if(vc === "none") { return false; }
3953
+ if($.isArray(vc)) {
3954
+ if(!js.attr || !js.attr[s.type_attr]) {
3955
+ if(!js.attr) { js.attr = {}; }
3956
+ js.attr[s.type_attr] = vc[0];
3957
+ }
3958
+ else {
3959
+ if($.inArray(js.attr[s.type_attr], vc) === -1) { return false; }
3960
+ }
3961
+ }
3962
+ if(s.max_children !== -2 && mc !== -1) {
3963
+ ch = p === -1 ? this.get_container().children("> ul > li").length : p.children("> ul > li").length;
3964
+ if(ch + 1 > mc) { return false; }
3965
+ }
3966
+ if(s.max_depth !== -2 && md !== -1 && (md - 1) < 0) { return false; }
3967
+ }
3968
+ return this.__call_old(true, obj, position, js, callback, is_loaded, skip_check);
3969
+ }
3970
+ }
3971
+ });
3972
+ })(jQuery);
3973
+ //*/
3974
+
3975
+ /*
3976
+ * jsTree HTML plugin
3977
+ * The HTML data store. Datastores are build by replacing the `load_node` and `_is_loaded` functions.
3978
+ */
3979
+ (function ($) {
3980
+ $.jstree.plugin("html_data", {
3981
+ __init : function () {
3982
+ // this used to use html() and clean the whitespace, but this way any attached data was lost
3983
+ this.data.html_data.original_container_html = this.get_container().find(" > ul > li").clone(true);
3984
+ // remove white space from LI node - otherwise nodes appear a bit to the right
3985
+ this.data.html_data.original_container_html.find("li").andSelf().contents().filter(function() { return this.nodeType == 3; }).remove();
3986
+ },
3987
+ defaults : {
3988
+ data : false,
3989
+ ajax : false,
3990
+ correct_state : true
3991
+ },
3992
+ _fn : {
3993
+ load_node : function (obj, s_call, e_call) { var _this = this; this.load_node_html(obj, function () { _this.__callback({ "obj" : _this._get_node(obj) }); s_call.call(this); }, e_call); },
3994
+ _is_loaded : function (obj) {
3995
+ obj = this._get_node(obj);
3996
+ return obj == -1 || !obj || (!this._get_settings().html_data.ajax && !$.isFunction(this._get_settings().html_data.data)) || obj.is(".jstree-open, .jstree-leaf") || obj.children("ul").children("li").size() > 0;
3997
+ },
3998
+ load_node_html : function (obj, s_call, e_call) {
3999
+ var d,
4000
+ s = this.get_settings().html_data,
4001
+ error_func = function () {},
4002
+ success_func = function () {};
4003
+ obj = this._get_node(obj);
4004
+ if(obj && obj !== -1) {
4005
+ if(obj.data("jstree-is-loading")) { return; }
4006
+ else { obj.data("jstree-is-loading",true); }
4007
+ }
4008
+ switch(!0) {
4009
+ case ($.isFunction(s.data)):
4010
+ s.data.call(this, obj, $.proxy(function (d) {
4011
+ if(d && d !== "" && d.toString && d.toString().replace(/^[\s\n]+$/,"") !== "") {
4012
+ d = $(d);
4013
+ if(!d.is("ul")) { d = $("<ul />").append(d); }
4014
+ if(obj == -1 || !obj) { this.get_container().children("ul").empty().append(d.children()).find("li, a").filter(function () { return !this.firstChild || !this.firstChild.tagName || this.firstChild.tagName !== "INS"; }).prepend("<ins class='jstree-icon'>&#160;</ins>").end().filter("a").children("ins:first-child").not(".jstree-icon").addClass("jstree-icon"); }
4015
+ else { obj.children("a.jstree-loading").removeClass("jstree-loading"); obj.append(d).children("ul").find("li, a").filter(function () { return !this.firstChild || !this.firstChild.tagName || this.firstChild.tagName !== "INS"; }).prepend("<ins class='jstree-icon'>&#160;</ins>").end().filter("a").children("ins:first-child").not(".jstree-icon").addClass("jstree-icon"); obj.removeData("jstree-is-loading"); }
4016
+ this.clean_node(obj);
4017
+ if(s_call) { s_call.call(this); }
4018
+ }
4019
+ else {
4020
+ if(obj && obj !== -1) {
4021
+ obj.children("a.jstree-loading").removeClass("jstree-loading");
4022
+ obj.removeData("jstree-is-loading");
4023
+ if(s.correct_state) {
4024
+ this.correct_state(obj);
4025
+ if(s_call) { s_call.call(this); }
4026
+ }
4027
+ }
4028
+ else {
4029
+ if(s.correct_state) {
4030
+ this.get_container().children("ul").empty();
4031
+ if(s_call) { s_call.call(this); }
4032
+ }
4033
+ }
4034
+ }
4035
+ }, this));
4036
+ break;
4037
+ case (!s.data && !s.ajax):
4038
+ if(!obj || obj == -1) {
4039
+ this.get_container()
4040
+ .children("ul").empty()
4041
+ .append(this.data.html_data.original_container_html)
4042
+ .find("li, a").filter(function () { return !this.firstChild || !this.firstChild.tagName || this.firstChild.tagName !== "INS"; }).prepend("<ins class='jstree-icon'>&#160;</ins>").end()
4043
+ .filter("a").children("ins:first-child").not(".jstree-icon").addClass("jstree-icon");
4044
+ this.clean_node();
4045
+ }
4046
+ if(s_call) { s_call.call(this); }
4047
+ break;
4048
+ case (!!s.data && !s.ajax) || (!!s.data && !!s.ajax && (!obj || obj === -1)):
4049
+ if(!obj || obj == -1) {
4050
+ d = $(s.data);
4051
+ if(!d.is("ul")) { d = $("<ul />").append(d); }
4052
+ this.get_container()
4053
+ .children("ul").empty().append(d.children())
4054
+ .find("li, a").filter(function () { return !this.firstChild || !this.firstChild.tagName || this.firstChild.tagName !== "INS"; }).prepend("<ins class='jstree-icon'>&#160;</ins>").end()
4055
+ .filter("a").children("ins:first-child").not(".jstree-icon").addClass("jstree-icon");
4056
+ this.clean_node();
4057
+ }
4058
+ if(s_call) { s_call.call(this); }
4059
+ break;
4060
+ case (!s.data && !!s.ajax) || (!!s.data && !!s.ajax && obj && obj !== -1):
4061
+ obj = this._get_node(obj);
4062
+ error_func = function (x, t, e) {
4063
+ var ef = this.get_settings().html_data.ajax.error;
4064
+ if(ef) { ef.call(this, x, t, e); }
4065
+ if(obj != -1 && obj.length) {
4066
+ obj.children("a.jstree-loading").removeClass("jstree-loading");
4067
+ obj.removeData("jstree-is-loading");
4068
+ if(t === "success" && s.correct_state) { this.correct_state(obj); }
4069
+ }
4070
+ else {
4071
+ if(t === "success" && s.correct_state) { this.get_container().children("ul").empty(); }
4072
+ }
4073
+ if(e_call) { e_call.call(this); }
4074
+ };
4075
+ success_func = function (d, t, x) {
4076
+ var sf = this.get_settings().html_data.ajax.success;
4077
+ if(sf) { d = sf.call(this,d,t,x) || d; }
4078
+ if(d === "" || (d && d.toString && d.toString().replace(/^[\s\n]+$/,"") === "")) {
4079
+ return error_func.call(this, x, t, "");
4080
+ }
4081
+ if(d) {
4082
+ d = $(d);
4083
+ if(!d.is("ul")) { d = $("<ul />").append(d); }
4084
+ if(obj == -1 || !obj) { this.get_container().children("ul").empty().append(d.children()).find("li, a").filter(function () { return !this.firstChild || !this.firstChild.tagName || this.firstChild.tagName !== "INS"; }).prepend("<ins class='jstree-icon'>&#160;</ins>").end().filter("a").children("ins:first-child").not(".jstree-icon").addClass("jstree-icon"); }
4085
+ else { obj.children("a.jstree-loading").removeClass("jstree-loading"); obj.append(d).children("ul").find("li, a").filter(function () { return !this.firstChild || !this.firstChild.tagName || this.firstChild.tagName !== "INS"; }).prepend("<ins class='jstree-icon'>&#160;</ins>").end().filter("a").children("ins:first-child").not(".jstree-icon").addClass("jstree-icon"); obj.removeData("jstree-is-loading"); }
4086
+ this.clean_node(obj);
4087
+ if(s_call) { s_call.call(this); }
4088
+ }
4089
+ else {
4090
+ if(obj && obj !== -1) {
4091
+ obj.children("a.jstree-loading").removeClass("jstree-loading");
4092
+ obj.removeData("jstree-is-loading");
4093
+ if(s.correct_state) {
4094
+ this.correct_state(obj);
4095
+ if(s_call) { s_call.call(this); }
4096
+ }
4097
+ }
4098
+ else {
4099
+ if(s.correct_state) {
4100
+ this.get_container().children("ul").empty();
4101
+ if(s_call) { s_call.call(this); }
4102
+ }
4103
+ }
4104
+ }
4105
+ };
4106
+ s.ajax.context = this;
4107
+ s.ajax.error = error_func;
4108
+ s.ajax.success = success_func;
4109
+ if(!s.ajax.dataType) { s.ajax.dataType = "html"; }
4110
+ if($.isFunction(s.ajax.url)) { s.ajax.url = s.ajax.url.call(this, obj); }
4111
+ if($.isFunction(s.ajax.data)) { s.ajax.data = s.ajax.data.call(this, obj); }
4112
+ $.ajax(s.ajax);
4113
+ break;
4114
+ }
4115
+ }
4116
+ }
4117
+ });
4118
+ // include the HTML data plugin by default
4119
+ $.jstree.defaults.plugins.push("html_data");
4120
+ })(jQuery);
4121
+ //*/
4122
+
4123
+ /*
4124
+ * jsTree themeroller plugin
4125
+ * Adds support for jQuery UI themes. Include this at the end of your plugins list, also make sure "themes" is not included.
4126
+ */
4127
+ (function ($) {
4128
+ $.jstree.plugin("themeroller", {
4129
+ __init : function () {
4130
+ var s = this._get_settings().themeroller;
4131
+ this.get_container()
4132
+ .addClass("ui-widget-content")
4133
+ .addClass("jstree-themeroller")
4134
+ .delegate("a","mouseenter.jstree", function (e) {
4135
+ if(!$(e.currentTarget).hasClass("jstree-loading")) {
4136
+ $(this).addClass(s.item_h);
4137
+ }
4138
+ })
4139
+ .delegate("a","mouseleave.jstree", function () {
4140
+ $(this).removeClass(s.item_h);
4141
+ })
4142
+ .bind("init.jstree", $.proxy(function (e, data) {
4143
+ data.inst.get_container().find("> ul > li > .jstree-loading > ins").addClass("ui-icon-refresh");
4144
+ this._themeroller(data.inst.get_container().find("> ul > li"));
4145
+ }, this))
4146
+ .bind("open_node.jstree create_node.jstree", $.proxy(function (e, data) {
4147
+ this._themeroller(data.rslt.obj);
4148
+ }, this))
4149
+ .bind("loaded.jstree refresh.jstree", $.proxy(function (e) {
4150
+ this._themeroller();
4151
+ }, this))
4152
+ .bind("close_node.jstree", $.proxy(function (e, data) {
4153
+ this._themeroller(data.rslt.obj);
4154
+ }, this))
4155
+ .bind("delete_node.jstree", $.proxy(function (e, data) {
4156
+ this._themeroller(data.rslt.parent);
4157
+ }, this))
4158
+ .bind("correct_state.jstree", $.proxy(function (e, data) {
4159
+ data.rslt.obj
4160
+ .children("ins.jstree-icon").removeClass(s.opened + " " + s.closed + " ui-icon").end()
4161
+ .find("> a > ins.ui-icon")
4162
+ .filter(function() {
4163
+ return this.className.toString()
4164
+ .replace(s.item_clsd,"").replace(s.item_open,"").replace(s.item_leaf,"")
4165
+ .indexOf("ui-icon-") === -1;
4166
+ }).removeClass(s.item_open + " " + s.item_clsd).addClass(s.item_leaf || "jstree-no-icon");
4167
+ }, this))
4168
+ .bind("select_node.jstree", $.proxy(function (e, data) {
4169
+ data.rslt.obj.children("a").addClass(s.item_a);
4170
+ }, this))
4171
+ .bind("deselect_node.jstree deselect_all.jstree", $.proxy(function (e, data) {
4172
+ this.get_container()
4173
+ .find("a." + s.item_a).removeClass(s.item_a).end()
4174
+ .find("a.jstree-clicked").addClass(s.item_a);
4175
+ }, this))
4176
+ .bind("dehover_node.jstree", $.proxy(function (e, data) {
4177
+ data.rslt.obj.children("a").removeClass(s.item_h);
4178
+ }, this))
4179
+ .bind("hover_node.jstree", $.proxy(function (e, data) {
4180
+ this.get_container()
4181
+ .find("a." + s.item_h).not(data.rslt.obj).removeClass(s.item_h);
4182
+ data.rslt.obj.children("a").addClass(s.item_h);
4183
+ }, this))
4184
+ .bind("move_node.jstree", $.proxy(function (e, data) {
4185
+ this._themeroller(data.rslt.o);
4186
+ this._themeroller(data.rslt.op);
4187
+ }, this));
4188
+ },
4189
+ __destroy : function () {
4190
+ var s = this._get_settings().themeroller,
4191
+ c = [ "ui-icon" ];
4192
+ $.each(s, function (i, v) {
4193
+ v = v.split(" ");
4194
+ if(v.length) { c = c.concat(v); }
4195
+ });
4196
+ this.get_container()
4197
+ .removeClass("ui-widget-content")
4198
+ .find("." + c.join(", .")).removeClass(c.join(" "));
4199
+ },
4200
+ _fn : {
4201
+ _themeroller : function (obj) {
4202
+ var s = this._get_settings().themeroller;
4203
+ obj = !obj || obj == -1 ? this.get_container_ul() : this._get_node(obj).parent();
4204
+ obj
4205
+ .find("li.jstree-closed")
4206
+ .children("ins.jstree-icon").removeClass(s.opened).addClass("ui-icon " + s.closed).end()
4207
+ .children("a").addClass(s.item)
4208
+ .children("ins.jstree-icon").addClass("ui-icon")
4209
+ .filter(function() {
4210
+ return this.className.toString()
4211
+ .replace(s.item_clsd,"").replace(s.item_open,"").replace(s.item_leaf,"")
4212
+ .indexOf("ui-icon-") === -1;
4213
+ }).removeClass(s.item_leaf + " " + s.item_open).addClass(s.item_clsd || "jstree-no-icon")
4214
+ .end()
4215
+ .end()
4216
+ .end()
4217
+ .end()
4218
+ .find("li.jstree-open")
4219
+ .children("ins.jstree-icon").removeClass(s.closed).addClass("ui-icon " + s.opened).end()
4220
+ .children("a").addClass(s.item)
4221
+ .children("ins.jstree-icon").addClass("ui-icon")
4222
+ .filter(function() {
4223
+ return this.className.toString()
4224
+ .replace(s.item_clsd,"").replace(s.item_open,"").replace(s.item_leaf,"")
4225
+ .indexOf("ui-icon-") === -1;
4226
+ }).removeClass(s.item_leaf + " " + s.item_clsd).addClass(s.item_open || "jstree-no-icon")
4227
+ .end()
4228
+ .end()
4229
+ .end()
4230
+ .end()
4231
+ .find("li.jstree-leaf")
4232
+ .children("ins.jstree-icon").removeClass(s.closed + " ui-icon " + s.opened).end()
4233
+ .children("a").addClass(s.item)
4234
+ .children("ins.jstree-icon").addClass("ui-icon")
4235
+ .filter(function() {
4236
+ return this.className.toString()
4237
+ .replace(s.item_clsd,"").replace(s.item_open,"").replace(s.item_leaf,"")
4238
+ .indexOf("ui-icon-") === -1;
4239
+ }).removeClass(s.item_clsd + " " + s.item_open).addClass(s.item_leaf || "jstree-no-icon");
4240
+ }
4241
+ },
4242
+ defaults : {
4243
+ "opened" : "ui-icon-triangle-1-se",
4244
+ "closed" : "ui-icon-triangle-1-e",
4245
+ "item" : "ui-state-default",
4246
+ "item_h" : "ui-state-hover",
4247
+ "item_a" : "ui-state-active",
4248
+ "item_open" : "ui-icon-folder-open",
4249
+ "item_clsd" : "ui-icon-folder-collapsed",
4250
+ "item_leaf" : "ui-icon-document"
4251
+ }
4252
+ });
4253
+ $(function() {
4254
+ var css_string = '' +
4255
+ '.jstree-themeroller .ui-icon { overflow:visible; } ' +
4256
+ '.jstree-themeroller a { padding:0 2px; } ' +
4257
+ '.jstree-themeroller .jstree-no-icon { display:none; }';
4258
+ $.vakata.css.add_sheet({ str : css_string, title : "jstree" });
4259
+ });
4260
+ })(jQuery);
4261
+ //*/
4262
+
4263
+ /*
4264
+ * jsTree unique plugin
4265
+ * Forces different names amongst siblings (still a bit experimental)
4266
+ * NOTE: does not check language versions (it will not be possible to have nodes with the same title, even in different languages)
4267
+ */
4268
+ (function ($) {
4269
+ $.jstree.plugin("unique", {
4270
+ __init : function () {
4271
+ this.get_container()
4272
+ .bind("before.jstree", $.proxy(function (e, data) {
4273
+ var nms = [], res = true, p, t;
4274
+ if(data.func == "move_node") {
4275
+ // obj, ref, position, is_copy, is_prepared, skip_check
4276
+ if(data.args[4] === true) {
4277
+ if(data.args[0].o && data.args[0].o.length) {
4278
+ data.args[0].o.children("a").each(function () { nms.push($(this).text().replace(/^\s+/g,"")); });
4279
+ res = this._check_unique(nms, data.args[0].np.find("> ul > li").not(data.args[0].o), "move_node");
4280
+ }
4281
+ }
4282
+ }
4283
+ if(data.func == "create_node") {
4284
+ // obj, position, js, callback, is_loaded
4285
+ if(data.args[4] || this._is_loaded(data.args[0])) {
4286
+ p = this._get_node(data.args[0]);
4287
+ if(data.args[1] && (data.args[1] === "before" || data.args[1] === "after")) {
4288
+ p = this._get_parent(data.args[0]);
4289
+ if(!p || p === -1) { p = this.get_container(); }
4290
+ }
4291
+ if(typeof data.args[2] === "string") { nms.push(data.args[2]); }
4292
+ else if(!data.args[2] || !data.args[2].data) { nms.push(this._get_string("new_node")); }
4293
+ else { nms.push(data.args[2].data); }
4294
+ res = this._check_unique(nms, p.find("> ul > li"), "create_node");
4295
+ }
4296
+ }
4297
+ if(data.func == "rename_node") {
4298
+ // obj, val
4299
+ nms.push(data.args[1]);
4300
+ t = this._get_node(data.args[0]);
4301
+ p = this._get_parent(t);
4302
+ if(!p || p === -1) { p = this.get_container(); }
4303
+ res = this._check_unique(nms, p.find("> ul > li").not(t), "rename_node");
4304
+ }
4305
+ if(!res) {
4306
+ e.stopPropagation();
4307
+ return false;
4308
+ }
4309
+ }, this));
4310
+ },
4311
+ defaults : {
4312
+ error_callback : $.noop
4313
+ },
4314
+ _fn : {
4315
+ _check_unique : function (nms, p, func) {
4316
+ var cnms = [];
4317
+ p.children("a").each(function () { cnms.push($(this).text().replace(/^\s+/g,"")); });
4318
+ if(!cnms.length || !nms.length) { return true; }
4319
+ cnms = cnms.sort().join(",,").replace(/(,|^)([^,]+)(,,\2)+(,|$)/g,"$1$2$4").replace(/,,+/g,",").replace(/,$/,"").split(",");
4320
+ if((cnms.length + nms.length) != cnms.concat(nms).sort().join(",,").replace(/(,|^)([^,]+)(,,\2)+(,|$)/g,"$1$2$4").replace(/,,+/g,",").replace(/,$/,"").split(",").length) {
4321
+ this._get_settings().unique.error_callback.call(null, nms, p, func);
4322
+ return false;
4323
+ }
4324
+ return true;
4325
+ },
4326
+ check_move : function () {
4327
+ if(!this.__call_old()) { return false; }
4328
+ var p = this._get_move(), nms = [];
4329
+ if(p.o && p.o.length) {
4330
+ p.o.children("a").each(function () { nms.push($(this).text().replace(/^\s+/g,"")); });
4331
+ return this._check_unique(nms, p.np.find("> ul > li").not(p.o), "check_move");
4332
+ }
4333
+ return true;
4334
+ }
4335
+ }
4336
+ });
4337
+ })(jQuery);
4338
+ //*/
4339
+
4340
+ /*
4341
+ * jsTree wholerow plugin
4342
+ * Makes select and hover work on the entire width of the node
4343
+ * MAY BE HEAVY IN LARGE DOM
4344
+ */
4345
+ (function ($) {
4346
+ $.jstree.plugin("wholerow", {
4347
+ __init : function () {
4348
+ if(!this.data.ui) { throw "jsTree wholerow: jsTree UI plugin not included."; }
4349
+ this.data.wholerow.html = false;
4350
+ this.data.wholerow.to = false;
4351
+ this.get_container()
4352
+ .bind("init.jstree", $.proxy(function (e, data) {
4353
+ this._get_settings().core.animation = 0;
4354
+ }, this))
4355
+ .bind("open_node.jstree create_node.jstree clean_node.jstree loaded.jstree", $.proxy(function (e, data) {
4356
+ this._prepare_wholerow_span( data && data.rslt && data.rslt.obj ? data.rslt.obj : -1 );
4357
+ }, this))
4358
+ .bind("search.jstree clear_search.jstree reopen.jstree after_open.jstree after_close.jstree create_node.jstree delete_node.jstree clean_node.jstree", $.proxy(function (e, data) {
4359
+ if(this.data.to) { clearTimeout(this.data.to); }
4360
+ this.data.to = setTimeout( (function (t, o) { return function() { t._prepare_wholerow_ul(o); }; })(this, data && data.rslt && data.rslt.obj ? data.rslt.obj : -1), 0);
4361
+ }, this))
4362
+ .bind("deselect_all.jstree", $.proxy(function (e, data) {
4363
+ this.get_container().find(" > .jstree-wholerow .jstree-clicked").removeClass("jstree-clicked " + (this.data.themeroller ? this._get_settings().themeroller.item_a : "" ));
4364
+ }, this))
4365
+ .bind("select_node.jstree deselect_node.jstree ", $.proxy(function (e, data) {
4366
+ data.rslt.obj.each(function () {
4367
+ var ref = data.inst.get_container().find(" > .jstree-wholerow li:visible:eq(" + ( parseInt((($(this).offset().top - data.inst.get_container().offset().top + data.inst.get_container()[0].scrollTop) / data.inst.data.core.li_height),10)) + ")");
4368
+ // ref.children("a")[e.type === "select_node" ? "addClass" : "removeClass"]("jstree-clicked");
4369
+ ref.children("a").attr("class",data.rslt.obj.children("a").attr("class"));
4370
+ });
4371
+ }, this))
4372
+ .bind("hover_node.jstree dehover_node.jstree", $.proxy(function (e, data) {
4373
+ this.get_container().find(" > .jstree-wholerow .jstree-hovered").removeClass("jstree-hovered " + (this.data.themeroller ? this._get_settings().themeroller.item_h : "" ));
4374
+ if(e.type === "hover_node") {
4375
+ var ref = this.get_container().find(" > .jstree-wholerow li:visible:eq(" + ( parseInt(((data.rslt.obj.offset().top - this.get_container().offset().top + this.get_container()[0].scrollTop) / this.data.core.li_height),10)) + ")");
4376
+ // ref.children("a").addClass("jstree-hovered");
4377
+ ref.children("a").attr("class",data.rslt.obj.children(".jstree-hovered").attr("class"));
4378
+ }
4379
+ }, this))
4380
+ .delegate(".jstree-wholerow-span, ins.jstree-icon, li", "click.jstree", function (e) {
4381
+ var n = $(e.currentTarget);
4382
+ if(e.target.tagName === "A" || (e.target.tagName === "INS" && n.closest("li").is(".jstree-open, .jstree-closed"))) { return; }
4383
+ n.closest("li").children("a:visible:eq(0)").click();
4384
+ e.stopImmediatePropagation();
4385
+ })
4386
+ .delegate("li", "mouseover.jstree", $.proxy(function (e) {
4387
+ e.stopImmediatePropagation();
4388
+ if($(e.currentTarget).children(".jstree-hovered, .jstree-clicked").length) { return false; }
4389
+ this.hover_node(e.currentTarget);
4390
+ return false;
4391
+ }, this))
4392
+ .delegate("li", "mouseleave.jstree", $.proxy(function (e) {
4393
+ if($(e.currentTarget).children("a").hasClass("jstree-hovered").length) { return; }
4394
+ this.dehover_node(e.currentTarget);
4395
+ }, this));
4396
+ if(is_ie7 || is_ie6) {
4397
+ $.vakata.css.add_sheet({ str : ".jstree-" + this.get_index() + " { position:relative; } ", title : "jstree" });
4398
+ }
4399
+ },
4400
+ defaults : {
4401
+ },
4402
+ __destroy : function () {
4403
+ this.get_container().children(".jstree-wholerow").remove();
4404
+ this.get_container().find(".jstree-wholerow-span").remove();
4405
+ },
4406
+ _fn : {
4407
+ _prepare_wholerow_span : function (obj) {
4408
+ obj = !obj || obj == -1 ? this.get_container().find("> ul > li") : this._get_node(obj);
4409
+ if(obj === false) { return; } // added for removing root nodes
4410
+ obj.each(function () {
4411
+ $(this).find("li").andSelf().each(function () {
4412
+ var $t = $(this);
4413
+ if($t.children(".jstree-wholerow-span").length) { return true; }
4414
+ $t.prepend("<span class='jstree-wholerow-span' style='width:" + ($t.parentsUntil(".jstree","li").length * 18) + "px;'>&#160;</span>");
4415
+ });
4416
+ });
4417
+ },
4418
+ _prepare_wholerow_ul : function () {
4419
+ var o = this.get_container().children("ul").eq(0), h = o.html();
4420
+ o.addClass("jstree-wholerow-real");
4421
+ if(this.data.wholerow.last_html !== h) {
4422
+ this.data.wholerow.last_html = h;
4423
+ this.get_container().children(".jstree-wholerow").remove();
4424
+ this.get_container().append(
4425
+ o.clone().removeClass("jstree-wholerow-real")
4426
+ .wrapAll("<div class='jstree-wholerow' />").parent()
4427
+ .width(o.parent()[0].scrollWidth)
4428
+ .css("top", (o.height() + ( is_ie7 ? 5 : 0)) * -1 )
4429
+ .find("li[id]").each(function () { this.removeAttribute("id"); }).end()
4430
+ );
4431
+ }
4432
+ }
4433
+ }
4434
+ });
4435
+ $(function() {
4436
+ var css_string = '' +
4437
+ '.jstree .jstree-wholerow-real { position:relative; z-index:1; } ' +
4438
+ '.jstree .jstree-wholerow-real li { cursor:pointer; } ' +
4439
+ '.jstree .jstree-wholerow-real a { border-left-color:transparent !important; border-right-color:transparent !important; } ' +
4440
+ '.jstree .jstree-wholerow { position:relative; z-index:0; height:0; } ' +
4441
+ '.jstree .jstree-wholerow ul, .jstree .jstree-wholerow li { width:100%; } ' +
4442
+ '.jstree .jstree-wholerow, .jstree .jstree-wholerow ul, .jstree .jstree-wholerow li, .jstree .jstree-wholerow a { margin:0 !important; padding:0 !important; } ' +
4443
+ '.jstree .jstree-wholerow, .jstree .jstree-wholerow ul, .jstree .jstree-wholerow li { background:transparent !important; }' +
4444
+ '.jstree .jstree-wholerow ins, .jstree .jstree-wholerow span, .jstree .jstree-wholerow input { display:none !important; }' +
4445
+ '.jstree .jstree-wholerow a, .jstree .jstree-wholerow a:hover { text-indent:-9999px; !important; width:100%; padding:0 !important; border-right-width:0px !important; border-left-width:0px !important; } ' +
4446
+ '.jstree .jstree-wholerow-span { position:absolute; left:0; margin:0px; padding:0; height:18px; border-width:0; padding:0; z-index:0; }';
4447
+ if(is_ff2) {
4448
+ css_string += '' +
4449
+ '.jstree .jstree-wholerow a { display:block; height:18px; margin:0; padding:0; border:0; } ' +
4450
+ '.jstree .jstree-wholerow-real a { border-color:transparent !important; } ';
4451
+ }
4452
+ if(is_ie7 || is_ie6) {
4453
+ css_string += '' +
4454
+ '.jstree .jstree-wholerow, .jstree .jstree-wholerow li, .jstree .jstree-wholerow ul, .jstree .jstree-wholerow a { margin:0; padding:0; line-height:18px; } ' +
4455
+ '.jstree .jstree-wholerow a { display:block; height:18px; line-height:18px; overflow:hidden; } ';
4456
+ }
4457
+ $.vakata.css.add_sheet({ str : css_string, title : "jstree" });
4458
+ });
4459
+ })(jQuery);
4460
+ //*/
4461
+
4462
+ /*
4463
+ * jsTree model plugin
4464
+ * This plugin gets jstree to use a class model to retrieve data, creating great dynamism
4465
+ */
4466
+ (function ($) {
4467
+ var nodeInterface = ["getChildren","getChildrenCount","getAttr","getName","getProps"],
4468
+ validateInterface = function(obj, inter) {
4469
+ var valid = true;
4470
+ obj = obj || {};
4471
+ inter = [].concat(inter);
4472
+ $.each(inter, function (i, v) {
4473
+ if(!$.isFunction(obj[v])) { valid = false; return false; }
4474
+ });
4475
+ return valid;
4476
+ };
4477
+ $.jstree.plugin("model", {
4478
+ __init : function () {
4479
+ if(!this.data.json_data) { throw "jsTree model: jsTree json_data plugin not included."; }
4480
+ this._get_settings().json_data.data = function (n, b) {
4481
+ var obj = (n == -1) ? this._get_settings().model.object : n.data("jstree_model");
4482
+ if(!validateInterface(obj, nodeInterface)) { return b.call(null, false); }
4483
+ if(this._get_settings().model.async) {
4484
+ obj.getChildren($.proxy(function (data) {
4485
+ this.model_done(data, b);
4486
+ }, this));
4487
+ }
4488
+ else {
4489
+ this.model_done(obj.getChildren(), b);
4490
+ }
4491
+ };
4492
+ },
4493
+ defaults : {
4494
+ object : false,
4495
+ id_prefix : false,
4496
+ async : false
4497
+ },
4498
+ _fn : {
4499
+ model_done : function (data, callback) {
4500
+ var ret = [],
4501
+ s = this._get_settings(),
4502
+ _this = this;
4503
+
4504
+ if(!$.isArray(data)) { data = [data]; }
4505
+ $.each(data, function (i, nd) {
4506
+ var r = nd.getProps() || {};
4507
+ r.attr = nd.getAttr() || {};
4508
+ if(nd.getChildrenCount()) { r.state = "closed"; }
4509
+ r.data = nd.getName();
4510
+ if(!$.isArray(r.data)) { r.data = [r.data]; }
4511
+ if(_this.data.types && $.isFunction(nd.getType)) {
4512
+ r.attr[s.types.type_attr] = nd.getType();
4513
+ }
4514
+ if(r.attr.id && s.model.id_prefix) { r.attr.id = s.model.id_prefix + r.attr.id; }
4515
+ if(!r.metadata) { r.metadata = { }; }
4516
+ r.metadata.jstree_model = nd;
4517
+ ret.push(r);
4518
+ });
4519
+ callback.call(null, ret);
4520
+ }
4521
+ }
4522
+ });
4523
+ })(jQuery);
4524
+ //*/
4525
+
4526
+ })();