iqvoc 4.8.1 → 4.8.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (606) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -0
  3. data/Gemfile +1 -3
  4. data/Gemfile.lock +9 -15
  5. data/app/assets/javascripts/framework.js +10 -10
  6. data/app/assets/javascripts/iqvoc/iqvoc.js +3 -3
  7. data/app/assets/javascripts/iqvoc/langselect.js +1 -1
  8. data/app/assets/stylesheets/_framework.scss +4 -4
  9. data/app/assets/stylesheets/iqvoc/components/_components.scss +6 -4
  10. data/app/assets/stylesheets/iqvoc/components/_entity_select.scss +1 -1
  11. data/app/assets/stylesheets/iqvoc/components/_notes.scss +1 -1
  12. data/app/assets/stylesheets/iqvoc/mixins/_mixins.scss +6 -2
  13. data/app/assets/stylesheets/iqvoc/settings/_bootstrap.scss +6 -7
  14. data/app/models/ability.rb +11 -2
  15. data/app/models/user.rb +4 -0
  16. data/app/views/collections/show_unpublished.html.erb +17 -14
  17. data/app/views/concepts/show_unpublished.html.erb +14 -11
  18. data/app/views/dashboard/index.html.erb +3 -3
  19. data/app/views/layouts/_controls.html.erb +3 -1
  20. data/app/views/layouts/application.html.erb +1 -1
  21. data/app/views/search_results/sections/_datasets.html.erb +1 -1
  22. data/app/views/search_results/sections/_languages.html.erb +1 -1
  23. data/config/initializers/assets.rb +2 -0
  24. data/config/locales/de.yml +1 -0
  25. data/config/locales/en.yml +2 -1
  26. data/lib/iqvoc/configuration/core.rb +1 -4
  27. data/lib/iqvoc/version.rb +1 -1
  28. data/public/export/151644452539207638297695765208032122293.nt +28 -0
  29. data/public/export/213987519797093111958174693910375706600.nt +28 -0
  30. data/public/export/220598335291843294191166072463233833628.nt +28 -0
  31. data/public/export/242910803893093872189091525372405462985.nt +28 -0
  32. data/public/export/25981.nt +28 -0
  33. data/public/export/3199.nt +28 -0
  34. data/public/export/50650725356216411444149011685563244498.nt +28 -0
  35. data/public/export/801.nt +28 -0
  36. data/public/uploads/import/596c40774bb5979c8de5ce6daa58de35.nt +259 -0
  37. data/public/uploads/import/77ea050ae3a00aedd2a6e4158454a54d.nt +259 -0
  38. data/public/uploads/import/7cc9feb5e9180d29865b9d4e81694921.nt +259 -0
  39. data/public/uploads/import/8e0bf83a2ca503753efaa29bff6f84f6.nt +259 -0
  40. data/public/uploads/import/a712bf10adc7546d5c567194d7a13603.nt +259 -0
  41. data/public/uploads/import/a7e315db905ac7808126b600dd1f6203.nt +259 -0
  42. data/public/uploads/import/d038a0416528900076cdb4a28211a84c.nt +259 -0
  43. data/public/uploads/import/d250e9b7a2819d62a43d5270031eaa6d.nt +259 -0
  44. data/public/uploads/tmp/1422290833-38334-3392/hobbies.nt +259 -0
  45. data/public/uploads/tmp/1422292996-38701-6635/hobbies.nt +259 -0
  46. data/public/uploads/tmp/1422293183-38751-2662/hobbies.nt +259 -0
  47. data/public/uploads/tmp/1422293478-38811-6215/hobbies.nt +259 -0
  48. data/public/uploads/tmp/1422300870-38980-1343/hobbies.nt +259 -0
  49. data/public/uploads/tmp/1422372626-67843-5956/hobbies.nt +259 -0
  50. data/public/uploads/tmp/1422374262-68176-3483/hobbies.nt +259 -0
  51. data/public/uploads/tmp/1422374611-68319-4455/hobbies.nt +259 -0
  52. data/test/integration/authentication_test.rb +2 -2
  53. data/vendor/assets/bower_components/URIjs/LICENSE.txt +21 -0
  54. data/vendor/assets/bower_components/URIjs/README.md +496 -0
  55. data/vendor/assets/bower_components/URIjs/bower.json +29 -0
  56. data/vendor/assets/bower_components/URIjs/contributing.md +19 -0
  57. data/vendor/assets/bower_components/URIjs/src/IPv6.js +188 -0
  58. data/vendor/assets/bower_components/URIjs/src/SecondLevelDomains.js +241 -0
  59. data/vendor/assets/bower_components/URIjs/src/URI.fragmentQuery.js +104 -0
  60. data/vendor/assets/bower_components/URIjs/src/URI.fragmentURI.js +97 -0
  61. data/vendor/assets/{javascripts → bower_components/URIjs/src}/URI.js +45 -49
  62. data/vendor/assets/bower_components/URIjs/src/URI.min.js +84 -0
  63. data/vendor/assets/bower_components/URIjs/src/URITemplate.js +499 -0
  64. data/vendor/assets/bower_components/URIjs/src/jquery.URI.js +235 -0
  65. data/vendor/assets/bower_components/URIjs/src/jquery.URI.min.js +7 -0
  66. data/vendor/assets/bower_components/URIjs/src/punycode.js +508 -0
  67. data/vendor/assets/bower_components/bootstrap-sass/CHANGELOG.md +183 -0
  68. data/vendor/assets/bower_components/bootstrap-sass/CONTRIBUTING.md +86 -0
  69. data/vendor/assets/bower_components/bootstrap-sass/LICENSE +21 -0
  70. data/vendor/assets/bower_components/bootstrap-sass/README.md +330 -0
  71. data/vendor/assets/bower_components/bootstrap-sass/assets/fonts/bootstrap/glyphicons-halflings-regular.eot +0 -0
  72. data/vendor/assets/bower_components/bootstrap-sass/assets/fonts/bootstrap/glyphicons-halflings-regular.svg +288 -0
  73. data/vendor/assets/bower_components/bootstrap-sass/assets/fonts/bootstrap/glyphicons-halflings-regular.ttf +0 -0
  74. data/vendor/assets/bower_components/bootstrap-sass/assets/fonts/bootstrap/glyphicons-halflings-regular.woff +0 -0
  75. data/vendor/assets/bower_components/bootstrap-sass/assets/fonts/bootstrap/glyphicons-halflings-regular.woff2 +0 -0
  76. data/vendor/assets/bower_components/bootstrap-sass/assets/javascripts/bootstrap-sprockets.js +12 -0
  77. data/vendor/assets/bower_components/bootstrap-sass/assets/javascripts/bootstrap.js +2306 -0
  78. data/vendor/assets/bower_components/bootstrap-sass/assets/javascripts/bootstrap.min.js +7 -0
  79. data/vendor/assets/bower_components/bootstrap-sass/assets/javascripts/bootstrap/affix.js +162 -0
  80. data/vendor/assets/bower_components/bootstrap-sass/assets/javascripts/bootstrap/alert.js +94 -0
  81. data/vendor/assets/bower_components/bootstrap-sass/assets/javascripts/bootstrap/button.js +116 -0
  82. data/vendor/assets/bower_components/bootstrap-sass/assets/javascripts/bootstrap/carousel.js +237 -0
  83. data/vendor/assets/bower_components/bootstrap-sass/assets/javascripts/bootstrap/collapse.js +211 -0
  84. data/vendor/assets/bower_components/bootstrap-sass/assets/javascripts/bootstrap/dropdown.js +161 -0
  85. data/vendor/assets/bower_components/bootstrap-sass/assets/javascripts/bootstrap/modal.js +324 -0
  86. data/vendor/assets/bower_components/bootstrap-sass/assets/javascripts/bootstrap/popover.js +113 -0
  87. data/vendor/assets/bower_components/bootstrap-sass/assets/javascripts/bootstrap/scrollspy.js +175 -0
  88. data/vendor/assets/bower_components/bootstrap-sass/assets/javascripts/bootstrap/tab.js +153 -0
  89. data/vendor/assets/bower_components/bootstrap-sass/assets/javascripts/bootstrap/tooltip.js +472 -0
  90. data/vendor/assets/bower_components/bootstrap-sass/assets/javascripts/bootstrap/transition.js +59 -0
  91. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/_bootstrap-compass.scss +9 -0
  92. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/_bootstrap-mincer.scss +19 -0
  93. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/_bootstrap-sprockets.scss +9 -0
  94. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/_bootstrap.scss +50 -0
  95. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/_alerts.scss +73 -0
  96. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/_badges.scss +67 -0
  97. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/_breadcrumbs.scss +26 -0
  98. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/_button-groups.scss +243 -0
  99. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/_buttons.scss +160 -0
  100. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/_carousel.scss +269 -0
  101. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/_close.scss +36 -0
  102. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/_code.scss +69 -0
  103. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/_component-animations.scss +38 -0
  104. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/_dropdowns.scss +214 -0
  105. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/_forms.scss +570 -0
  106. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/_glyphicons.scss +301 -0
  107. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/_grid.scss +84 -0
  108. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/_input-groups.scss +166 -0
  109. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/_jumbotron.scss +50 -0
  110. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/_labels.scss +66 -0
  111. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/_list-group.scss +124 -0
  112. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/_media.scss +61 -0
  113. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/_mixins.scss +39 -0
  114. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/_modals.scss +148 -0
  115. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/_navbar.scss +663 -0
  116. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/_navs.scss +244 -0
  117. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/_normalize.scss +427 -0
  118. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/_pager.scss +54 -0
  119. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/_pagination.scss +88 -0
  120. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/_panels.scss +265 -0
  121. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/_popovers.scss +135 -0
  122. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/_print.scss +107 -0
  123. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/_progress-bars.scss +87 -0
  124. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/_responsive-embed.scss +35 -0
  125. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/_responsive-utilities.scss +177 -0
  126. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/_scaffolding.scss +150 -0
  127. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/_tables.scss +234 -0
  128. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/_theme.scss +273 -0
  129. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/_thumbnails.scss +38 -0
  130. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/_tooltip.scss +103 -0
  131. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/_type.scss +298 -0
  132. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/_utilities.scss +56 -0
  133. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/_variables.scss +862 -0
  134. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/_wells.scss +29 -0
  135. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/mixins/_alerts.scss +14 -0
  136. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/mixins/_background-variant.scss +11 -0
  137. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/mixins/_border-radius.scss +18 -0
  138. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/mixins/_buttons.scss +52 -0
  139. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/mixins/_center-block.scss +7 -0
  140. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/mixins/_clearfix.scss +22 -0
  141. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/mixins/_forms.scss +88 -0
  142. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/mixins/_gradients.scss +58 -0
  143. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/mixins/_grid-framework.scss +81 -0
  144. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/mixins/_grid.scss +122 -0
  145. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/mixins/_hide-text.scss +21 -0
  146. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/mixins/_image.scss +33 -0
  147. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/mixins/_labels.scss +12 -0
  148. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/mixins/_list-group.scss +31 -0
  149. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/mixins/_nav-divider.scss +10 -0
  150. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/mixins/_nav-vertical-align.scss +9 -0
  151. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/mixins/_opacity.scss +8 -0
  152. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/mixins/_pagination.scss +23 -0
  153. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/mixins/_panels.scss +24 -0
  154. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/mixins/_progress-bar.scss +10 -0
  155. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/mixins/_reset-filter.scss +8 -0
  156. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/mixins/_resize.scss +6 -0
  157. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/mixins/_responsive-visibility.scss +21 -0
  158. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/mixins/_size.scss +10 -0
  159. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/mixins/_tab-focus.scss +9 -0
  160. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/mixins/_table-row.scss +28 -0
  161. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/mixins/_text-emphasis.scss +11 -0
  162. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/mixins/_text-overflow.scss +8 -0
  163. data/vendor/assets/bower_components/bootstrap-sass/assets/stylesheets/bootstrap/mixins/_vendor-prefixes.scss +222 -0
  164. data/vendor/assets/bower_components/bootstrap-sass/bower.json +40 -0
  165. data/vendor/assets/bower_components/bootstrap-sass/composer.json +35 -0
  166. data/vendor/assets/bower_components/bootstrap-sass/package.json +30 -0
  167. data/vendor/assets/bower_components/bootstrap-sass/sache.json +5 -0
  168. data/vendor/assets/bower_components/html5shiv/Gruntfile.js +61 -0
  169. data/vendor/assets/bower_components/html5shiv/bower.json +15 -0
  170. data/vendor/assets/bower_components/html5shiv/dist/html5shiv-printshiv.js +520 -0
  171. data/vendor/assets/bower_components/html5shiv/dist/html5shiv-printshiv.min.js +4 -0
  172. data/vendor/assets/bower_components/html5shiv/dist/html5shiv.js +322 -0
  173. data/vendor/assets/bower_components/html5shiv/dist/html5shiv.min.js +4 -0
  174. data/vendor/assets/bower_components/html5shiv/package.json +16 -0
  175. data/vendor/assets/bower_components/html5shiv/readme.md +152 -0
  176. data/vendor/assets/bower_components/jqtree/LICENSE +202 -0
  177. data/vendor/assets/bower_components/jqtree/README.md +24 -0
  178. data/vendor/assets/bower_components/jqtree/_config.yml +18 -0
  179. data/vendor/assets/bower_components/jqtree/_entries/01_general.md +7 -0
  180. data/vendor/assets/bower_components/jqtree/_entries/02_introduction.md +9 -0
  181. data/vendor/assets/bower_components/jqtree/_entries/03_features.md +15 -0
  182. data/vendor/assets/bower_components/jqtree/_entries/04_demo.html +34 -0
  183. data/vendor/assets/bower_components/jqtree/_entries/05_requirements.md +6 -0
  184. data/vendor/assets/bower_components/jqtree/_entries/06_downloads.md +9 -0
  185. data/vendor/assets/bower_components/jqtree/_entries/07_tutorial.md +77 -0
  186. data/vendor/assets/bower_components/jqtree/_entries/08_examples.md +8 -0
  187. data/vendor/assets/bower_components/jqtree/_entries/09_changelog.md +179 -0
  188. data/vendor/assets/bower_components/jqtree/_entries/10_options.md +6 -0
  189. data/vendor/assets/bower_components/jqtree/_entries/11_autoescape.md +6 -0
  190. data/vendor/assets/bower_components/jqtree/_entries/12_autoopen.md +28 -0
  191. data/vendor/assets/bower_components/jqtree/_entries/13_closedicon.md +12 -0
  192. data/vendor/assets/bower_components/jqtree/_entries/14_data.md +41 -0
  193. data/vendor/assets/bower_components/jqtree/_entries/15_datafilter.md +17 -0
  194. data/vendor/assets/bower_components/jqtree/_entries/16_data-url.md +21 -0
  195. data/vendor/assets/bower_components/jqtree/_entries/17_draganddrop.md +18 -0
  196. data/vendor/assets/bower_components/jqtree/_entries/18_keyboardsupport.md +14 -0
  197. data/vendor/assets/bower_components/jqtree/_entries/19_oncanmove.md +22 -0
  198. data/vendor/assets/bower_components/jqtree/_entries/20_oncanmoveto.md +22 -0
  199. data/vendor/assets/bower_components/jqtree/_entries/21_oncanselectnode.md +26 -0
  200. data/vendor/assets/bower_components/jqtree/_entries/22_oncreateli.md +16 -0
  201. data/vendor/assets/bower_components/jqtree/_entries/23_onismovehandle.md +17 -0
  202. data/vendor/assets/bower_components/jqtree/_entries/24_onloadfailed.md +15 -0
  203. data/vendor/assets/bower_components/jqtree/_entries/25_openedicon.md +12 -0
  204. data/vendor/assets/bower_components/jqtree/_entries/26_openfolderdelay.md +13 -0
  205. data/vendor/assets/bower_components/jqtree/_entries/27_savestate.md +42 -0
  206. data/vendor/assets/bower_components/jqtree/_entries/28_selectable.md +18 -0
  207. data/vendor/assets/bower_components/jqtree/_entries/29_slide.md +12 -0
  208. data/vendor/assets/bower_components/jqtree/_entries/30_usecontextmenu.md +14 -0
  209. data/vendor/assets/bower_components/jqtree/_entries/31_functions.md +6 -0
  210. data/vendor/assets/bower_components/jqtree/_entries/32_addnodeafter.md +20 -0
  211. data/vendor/assets/bower_components/jqtree/_entries/33_addnodebefore.md +8 -0
  212. data/vendor/assets/bower_components/jqtree/_entries/34_appendnode.md +33 -0
  213. data/vendor/assets/bower_components/jqtree/_entries/35_closenode.md +23 -0
  214. data/vendor/assets/bower_components/jqtree/_entries/36_getnodebyid.md +21 -0
  215. data/vendor/assets/bower_components/jqtree/_entries/37_getselectednode.md +10 -0
  216. data/vendor/assets/bower_components/jqtree/_entries/38_getstate.md +19 -0
  217. data/vendor/assets/bower_components/jqtree/_entries/39_gettree.md +8 -0
  218. data/vendor/assets/bower_components/jqtree/_entries/40_loaddata.md +46 -0
  219. data/vendor/assets/bower_components/jqtree/_entries/41_loaddatafromurl.md +55 -0
  220. data/vendor/assets/bower_components/jqtree/_entries/42_movedown.md +8 -0
  221. data/vendor/assets/bower_components/jqtree/_entries/43_movenode.md +15 -0
  222. data/vendor/assets/bower_components/jqtree/_entries/44_moveup.md +8 -0
  223. data/vendor/assets/bower_components/jqtree/_entries/45_opennode.md +29 -0
  224. data/vendor/assets/bower_components/jqtree/_entries/46_addparentnode.md +20 -0
  225. data/vendor/assets/bower_components/jqtree/_entries/47_reload.md +12 -0
  226. data/vendor/assets/bower_components/jqtree/_entries/48_removenode.md +12 -0
  227. data/vendor/assets/bower_components/jqtree/_entries/49_selectnode.md +24 -0
  228. data/vendor/assets/bower_components/jqtree/_entries/50_scrolltonode.md +13 -0
  229. data/vendor/assets/bower_components/jqtree/_entries/51_setoption.md +12 -0
  230. data/vendor/assets/bower_components/jqtree/_entries/52_setstate.md +8 -0
  231. data/vendor/assets/bower_components/jqtree/_entries/53_toggle.md +8 -0
  232. data/vendor/assets/bower_components/jqtree/_entries/54_tojson.md +13 -0
  233. data/vendor/assets/bower_components/jqtree/_entries/55_updatenode.md +33 -0
  234. data/vendor/assets/bower_components/jqtree/_entries/56_events.md +6 -0
  235. data/vendor/assets/bower_components/jqtree/_entries/57_tree-click.md +37 -0
  236. data/vendor/assets/bower_components/jqtree/_entries/58_tree-close.md +15 -0
  237. data/vendor/assets/bower_components/jqtree/_entries/59_tree-contextmenu.md +21 -0
  238. data/vendor/assets/bower_components/jqtree/_entries/60_tree-dblclick.md +19 -0
  239. data/vendor/assets/bower_components/jqtree/_entries/61_tree-init.md +15 -0
  240. data/vendor/assets/bower_components/jqtree/_entries/62_tree-move.md +71 -0
  241. data/vendor/assets/bower_components/jqtree/_entries/63_tree-open.md +15 -0
  242. data/vendor/assets/bower_components/jqtree/_entries/64_tree-select.md +28 -0
  243. data/vendor/assets/bower_components/jqtree/_entries/65_multiple-selection.md +9 -0
  244. data/vendor/assets/bower_components/jqtree/_entries/66_add-to-selection.md +11 -0
  245. data/vendor/assets/bower_components/jqtree/_entries/67_get-selected-nodes.md +10 -0
  246. data/vendor/assets/bower_components/jqtree/_entries/68_is-node-selected.md +11 -0
  247. data/vendor/assets/bower_components/jqtree/_entries/69_remove-from-selection.md +11 -0
  248. data/vendor/assets/bower_components/jqtree/_entries/70_node-functions.md +13 -0
  249. data/vendor/assets/bower_components/jqtree/_entries/71_children.md +12 -0
  250. data/vendor/assets/bower_components/jqtree/_entries/72_getdata.md +10 -0
  251. data/vendor/assets/bower_components/jqtree/_entries/73_getlevel.md +13 -0
  252. data/vendor/assets/bower_components/jqtree/_entries/74_getnextnode.md +12 -0
  253. data/vendor/assets/bower_components/jqtree/_entries/75_getnextsibling.md +10 -0
  254. data/vendor/assets/bower_components/jqtree/_entries/76_getpreviousnode.md +12 -0
  255. data/vendor/assets/bower_components/jqtree/_entries/77_getprevioussibling.md +10 -0
  256. data/vendor/assets/bower_components/jqtree/_entries/78_parent.md +10 -0
  257. data/vendor/assets/bower_components/jqtree/_examples/01_load_json_data.html +47 -0
  258. data/vendor/assets/bower_components/jqtree/_examples/02_load_json_data_from_server.html +31 -0
  259. data/vendor/assets/bower_components/jqtree/_examples/03_drag_and_drop.html +45 -0
  260. data/vendor/assets/bower_components/jqtree/_examples/04_save_state.html +52 -0
  261. data/vendor/assets/bower_components/jqtree/_examples/05_load_on_demand.html +70 -0
  262. data/vendor/assets/bower_components/jqtree/_examples/06_autoescape.html +47 -0
  263. data/vendor/assets/bower_components/jqtree/_examples/07_autoscroll.html +23 -0
  264. data/vendor/assets/bower_components/jqtree/_examples/08_multiple_select.html +72 -0
  265. data/vendor/assets/bower_components/jqtree/_examples/09_custom_html.html +68 -0
  266. data/vendor/assets/bower_components/jqtree/_examples/10_icon_buttons.html +27 -0
  267. data/vendor/assets/bower_components/jqtree/_layouts/base.html +48 -0
  268. data/vendor/assets/bower_components/jqtree/_layouts/frontpage.html +20 -0
  269. data/vendor/assets/bower_components/jqtree/_layouts/page.html +7 -0
  270. data/vendor/assets/bower_components/jqtree/bower.json +12 -0
  271. data/vendor/assets/bower_components/jqtree/gulpfile.coffee +30 -0
  272. data/vendor/assets/bower_components/jqtree/gulpfile.js +2 -0
  273. data/vendor/assets/bower_components/jqtree/index.html +48 -0
  274. data/vendor/assets/bower_components/jqtree/jqtree-circle.png +0 -0
  275. data/vendor/assets/bower_components/jqtree/jqtree.css +143 -0
  276. data/vendor/assets/bower_components/jqtree/jqtree.jquery.json +23 -0
  277. data/vendor/assets/bower_components/jqtree/package.json +23 -0
  278. data/vendor/assets/bower_components/jqtree/phantomjs/runner.js +193 -0
  279. data/vendor/assets/bower_components/jqtree/phantomjs/server.js +14 -0
  280. data/vendor/assets/bower_components/jqtree/screenshot.png +0 -0
  281. data/vendor/assets/bower_components/jqtree/sitemap.txt +11 -0
  282. data/vendor/assets/bower_components/jqtree/src/drag_and_drop_handler.coffee +466 -0
  283. data/vendor/assets/bower_components/jqtree/src/elements_renderer.coffee +198 -0
  284. data/vendor/assets/bower_components/jqtree/src/key_handler.coffee +92 -0
  285. data/vendor/assets/bower_components/jqtree/src/mouse.widget.coffee +181 -0
  286. data/vendor/assets/bower_components/jqtree/src/node.coffee +431 -0
  287. data/vendor/assets/bower_components/jqtree/src/node_element.coffee +144 -0
  288. data/vendor/assets/bower_components/jqtree/src/save_state_handler.coffee +191 -0
  289. data/vendor/assets/bower_components/jqtree/src/scroll_handler.coffee +100 -0
  290. data/vendor/assets/bower_components/jqtree/src/select_node_handler.coffee +76 -0
  291. data/vendor/assets/bower_components/jqtree/src/simple.widget.coffee +102 -0
  292. data/vendor/assets/bower_components/jqtree/src/test.js +1945 -0
  293. data/vendor/assets/bower_components/jqtree/src/tree.jquery.coffee +772 -0
  294. data/vendor/assets/bower_components/jqtree/src/util.coffee +117 -0
  295. data/vendor/assets/bower_components/jqtree/src/version.coffee +1 -0
  296. data/vendor/assets/bower_components/jqtree/static/bower.json +13 -0
  297. data/vendor/assets/bower_components/jqtree/static/bower_components/blanket/dist/qunit/blanket.js +5430 -0
  298. data/vendor/assets/bower_components/jqtree/static/bower_components/bootstrap/dist/css/bootstrap-theme.min.css +5 -0
  299. data/vendor/assets/bower_components/jqtree/static/bower_components/bootstrap/dist/css/bootstrap.min.css +5 -0
  300. data/vendor/assets/bower_components/jqtree/static/bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.eot +0 -0
  301. data/vendor/assets/bower_components/jqtree/static/bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.svg +229 -0
  302. data/vendor/assets/bower_components/jqtree/static/bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf +0 -0
  303. data/vendor/assets/bower_components/jqtree/static/bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.woff +0 -0
  304. data/vendor/assets/bower_components/jqtree/static/bower_components/bootstrap/dist/js/bootstrap.min.js +7 -0
  305. data/vendor/assets/bower_components/jqtree/static/bower_components/fontawesome/css/font-awesome.min.css +4 -0
  306. data/vendor/assets/bower_components/jqtree/static/bower_components/fontawesome/fonts/FontAwesome.otf +0 -0
  307. data/vendor/assets/bower_components/jqtree/static/bower_components/fontawesome/fonts/fontawesome-webfont.eot +0 -0
  308. data/vendor/assets/bower_components/jqtree/static/bower_components/fontawesome/fonts/fontawesome-webfont.svg +520 -0
  309. data/vendor/assets/bower_components/jqtree/static/bower_components/fontawesome/fonts/fontawesome-webfont.ttf +0 -0
  310. data/vendor/assets/bower_components/jqtree/static/bower_components/fontawesome/fonts/fontawesome-webfont.woff +0 -0
  311. data/vendor/assets/bower_components/jqtree/static/bower_components/jquery-cookie/jquery.cookie.js +117 -0
  312. data/vendor/assets/bower_components/jqtree/static/bower_components/jquery-mockjax/jquery.mockjax.js +692 -0
  313. data/vendor/assets/bower_components/jqtree/static/bower_components/jquery/dist/jquery.min.js +5 -0
  314. data/vendor/assets/bower_components/jqtree/static/bower_components/pygments/css/monokai.css +63 -0
  315. data/vendor/assets/bower_components/jqtree/static/bower_components/qunit/qunit/qunit.css +264 -0
  316. data/vendor/assets/bower_components/jqtree/static/bower_components/qunit/qunit/qunit.js +2819 -0
  317. data/vendor/assets/bower_components/jqtree/static/documentation.css +165 -0
  318. data/vendor/assets/bower_components/jqtree/static/documentation.js +51 -0
  319. data/vendor/assets/bower_components/jqtree/static/example.css +53 -0
  320. data/vendor/assets/bower_components/jqtree/static/example_data.js +128 -0
  321. data/vendor/assets/bower_components/jqtree/static/examples/autoescape.js +19 -0
  322. data/vendor/assets/bower_components/jqtree/static/examples/autoscroll.js +8 -0
  323. data/vendor/assets/bower_components/jqtree/static/examples/custom_html.js +32 -0
  324. data/vendor/assets/bower_components/jqtree/static/examples/drag_and_drop.js +15 -0
  325. data/vendor/assets/bower_components/jqtree/static/examples/icon_buttons.js +14 -0
  326. data/vendor/assets/bower_components/jqtree/static/examples/load_json_data.js +21 -0
  327. data/vendor/assets/bower_components/jqtree/static/examples/load_json_data_from_server.js +11 -0
  328. data/vendor/assets/bower_components/jqtree/static/examples/load_on_demand.js +20 -0
  329. data/vendor/assets/bower_components/jqtree/static/examples/multiple_select.js +27 -0
  330. data/vendor/assets/bower_components/jqtree/static/examples/save_state.js +13 -0
  331. data/vendor/assets/bower_components/jqtree/static/jquery-1.11.2.min.js +4 -0
  332. data/vendor/assets/bower_components/jqtree/static/spinner.gif +0 -0
  333. data/vendor/assets/bower_components/jqtree/test/test.html +23 -0
  334. data/vendor/assets/bower_components/jqtree/test/test.js +2604 -0
  335. data/vendor/assets/{javascripts → bower_components/jqtree}/tree.jquery.js +2274 -1932
  336. data/vendor/assets/bower_components/jquery-ujs/CHANGELOG.md +24 -0
  337. data/vendor/assets/bower_components/jquery-ujs/MIT-LICENSE.txt +20 -0
  338. data/vendor/assets/bower_components/jquery-ujs/README.md +72 -0
  339. data/vendor/assets/bower_components/jquery-ujs/bower.json +20 -0
  340. data/vendor/assets/bower_components/jquery-ujs/src/rails.js +469 -0
  341. data/vendor/assets/bower_components/jquery/MIT-LICENSE.txt +21 -0
  342. data/vendor/assets/bower_components/jquery/bower.json +27 -0
  343. data/vendor/assets/bower_components/jquery/dist/jquery.js +9205 -0
  344. data/vendor/assets/bower_components/jquery/dist/jquery.min.js +5 -0
  345. data/vendor/assets/bower_components/jquery/dist/jquery.min.map +1 -0
  346. data/vendor/assets/bower_components/jquery/src/ajax.js +786 -0
  347. data/vendor/assets/bower_components/jquery/src/ajax/jsonp.js +89 -0
  348. data/vendor/assets/bower_components/jquery/src/ajax/load.js +75 -0
  349. data/vendor/assets/bower_components/jquery/src/ajax/parseJSON.js +13 -0
  350. data/vendor/assets/bower_components/jquery/src/ajax/parseXML.js +28 -0
  351. data/vendor/assets/bower_components/jquery/src/ajax/script.js +64 -0
  352. data/vendor/assets/bower_components/jquery/src/ajax/var/nonce.js +5 -0
  353. data/vendor/assets/bower_components/jquery/src/ajax/var/rquery.js +3 -0
  354. data/vendor/assets/bower_components/jquery/src/ajax/xhr.js +136 -0
  355. data/vendor/assets/bower_components/jquery/src/attributes.js +11 -0
  356. data/vendor/assets/bower_components/jquery/src/attributes/attr.js +141 -0
  357. data/vendor/assets/bower_components/jquery/src/attributes/classes.js +158 -0
  358. data/vendor/assets/bower_components/jquery/src/attributes/prop.js +94 -0
  359. data/vendor/assets/bower_components/jquery/src/attributes/support.js +35 -0
  360. data/vendor/assets/bower_components/jquery/src/attributes/val.js +161 -0
  361. data/vendor/assets/bower_components/jquery/src/callbacks.js +205 -0
  362. data/vendor/assets/bower_components/jquery/src/core.js +497 -0
  363. data/vendor/assets/bower_components/jquery/src/core/access.js +60 -0
  364. data/vendor/assets/bower_components/jquery/src/core/init.js +123 -0
  365. data/vendor/assets/bower_components/jquery/src/core/parseHTML.js +39 -0
  366. data/vendor/assets/bower_components/jquery/src/core/ready.js +97 -0
  367. data/vendor/assets/bower_components/jquery/src/core/var/rsingleTag.js +4 -0
  368. data/vendor/assets/bower_components/jquery/src/css.js +450 -0
  369. data/vendor/assets/bower_components/jquery/src/css/addGetHookIf.js +22 -0
  370. data/vendor/assets/bower_components/jquery/src/css/curCSS.js +57 -0
  371. data/vendor/assets/bower_components/jquery/src/css/defaultDisplay.js +70 -0
  372. data/vendor/assets/bower_components/jquery/src/css/hiddenVisibleSelectors.js +15 -0
  373. data/vendor/assets/bower_components/jquery/src/css/support.js +96 -0
  374. data/vendor/assets/bower_components/jquery/src/css/swap.js +28 -0
  375. data/vendor/assets/bower_components/jquery/src/css/var/cssExpand.js +3 -0
  376. data/vendor/assets/bower_components/jquery/src/css/var/getStyles.js +12 -0
  377. data/vendor/assets/bower_components/jquery/src/css/var/isHidden.js +13 -0
  378. data/vendor/assets/bower_components/jquery/src/css/var/rmargin.js +3 -0
  379. data/vendor/assets/bower_components/jquery/src/css/var/rnumnonpx.js +5 -0
  380. data/vendor/assets/bower_components/jquery/src/data.js +178 -0
  381. data/vendor/assets/bower_components/jquery/src/data/Data.js +181 -0
  382. data/vendor/assets/bower_components/jquery/src/data/accepts.js +20 -0
  383. data/vendor/assets/bower_components/jquery/src/data/var/data_priv.js +5 -0
  384. data/vendor/assets/bower_components/jquery/src/data/var/data_user.js +5 -0
  385. data/vendor/assets/bower_components/jquery/src/deferred.js +149 -0
  386. data/vendor/assets/bower_components/jquery/src/deprecated.js +13 -0
  387. data/vendor/assets/bower_components/jquery/src/dimensions.js +50 -0
  388. data/vendor/assets/bower_components/jquery/src/effects.js +648 -0
  389. data/vendor/assets/bower_components/jquery/src/effects/Tween.js +114 -0
  390. data/vendor/assets/bower_components/jquery/src/effects/animatedSelector.js +13 -0
  391. data/vendor/assets/bower_components/jquery/src/event.js +868 -0
  392. data/vendor/assets/bower_components/jquery/src/event/ajax.js +13 -0
  393. data/vendor/assets/bower_components/jquery/src/event/alias.js +39 -0
  394. data/vendor/assets/bower_components/jquery/src/event/support.js +9 -0
  395. data/vendor/assets/bower_components/jquery/src/exports/amd.js +24 -0
  396. data/vendor/assets/bower_components/jquery/src/exports/global.js +32 -0
  397. data/vendor/assets/bower_components/jquery/src/intro.js +44 -0
  398. data/vendor/assets/bower_components/jquery/src/jquery.js +37 -0
  399. data/vendor/assets/bower_components/jquery/src/manipulation.js +580 -0
  400. data/vendor/assets/bower_components/jquery/src/manipulation/_evalUrl.js +18 -0
  401. data/vendor/assets/bower_components/jquery/src/manipulation/support.js +32 -0
  402. data/vendor/assets/bower_components/jquery/src/manipulation/var/rcheckableType.js +3 -0
  403. data/vendor/assets/bower_components/jquery/src/offset.js +207 -0
  404. data/vendor/assets/bower_components/jquery/src/outro.js +1 -0
  405. data/vendor/assets/bower_components/jquery/src/queue.js +142 -0
  406. data/vendor/assets/bower_components/jquery/src/queue/delay.js +22 -0
  407. data/vendor/assets/bower_components/jquery/src/selector-native.js +172 -0
  408. data/vendor/assets/bower_components/jquery/src/selector-sizzle.js +14 -0
  409. data/vendor/assets/bower_components/jquery/src/selector.js +1 -0
  410. data/vendor/assets/bower_components/jquery/src/serialize.js +111 -0
  411. data/vendor/assets/bower_components/jquery/src/sizzle/dist/sizzle.js +2067 -0
  412. data/vendor/assets/bower_components/jquery/src/sizzle/dist/sizzle.min.js +3 -0
  413. data/vendor/assets/bower_components/jquery/src/sizzle/dist/sizzle.min.map +1 -0
  414. data/vendor/assets/bower_components/jquery/src/traversing.js +199 -0
  415. data/vendor/assets/bower_components/jquery/src/traversing/findFilter.js +100 -0
  416. data/vendor/assets/bower_components/jquery/src/traversing/var/rneedsContext.js +6 -0
  417. data/vendor/assets/bower_components/jquery/src/var/arr.js +3 -0
  418. data/vendor/assets/bower_components/jquery/src/var/class2type.js +4 -0
  419. data/vendor/assets/bower_components/jquery/src/var/concat.js +5 -0
  420. data/vendor/assets/bower_components/jquery/src/var/hasOwn.js +5 -0
  421. data/vendor/assets/bower_components/jquery/src/var/indexOf.js +5 -0
  422. data/vendor/assets/bower_components/jquery/src/var/pnum.js +3 -0
  423. data/vendor/assets/bower_components/jquery/src/var/push.js +5 -0
  424. data/vendor/assets/bower_components/jquery/src/var/rnotwhite.js +3 -0
  425. data/vendor/assets/bower_components/jquery/src/var/slice.js +5 -0
  426. data/vendor/assets/bower_components/jquery/src/var/strundefined.js +3 -0
  427. data/vendor/assets/bower_components/jquery/src/var/support.js +4 -0
  428. data/vendor/assets/bower_components/jquery/src/var/toString.js +5 -0
  429. data/vendor/assets/bower_components/jquery/src/wrap.js +79 -0
  430. data/vendor/assets/bower_components/pickadate/Gruntfile.js +275 -0
  431. data/vendor/assets/bower_components/pickadate/bower.json +63 -0
  432. data/vendor/assets/bower_components/pickadate/lib/compressed/legacy.js +10 -0
  433. data/vendor/assets/bower_components/pickadate/lib/compressed/picker.date.js +5 -0
  434. data/vendor/assets/bower_components/pickadate/lib/compressed/picker.js +7 -0
  435. data/vendor/assets/bower_components/pickadate/lib/compressed/picker.time.js +5 -0
  436. data/vendor/assets/bower_components/pickadate/lib/compressed/themes/classic.css +4 -0
  437. data/vendor/assets/bower_components/pickadate/lib/compressed/themes/classic.date.css +1 -0
  438. data/vendor/assets/bower_components/pickadate/lib/compressed/themes/classic.time.css +1 -0
  439. data/vendor/assets/bower_components/pickadate/lib/compressed/themes/default.css +4 -0
  440. data/vendor/assets/bower_components/pickadate/lib/compressed/themes/default.date.css +1 -0
  441. data/vendor/assets/bower_components/pickadate/lib/compressed/themes/default.time.css +1 -0
  442. data/vendor/assets/bower_components/pickadate/lib/compressed/themes/rtl.css +3 -0
  443. data/vendor/assets/bower_components/pickadate/lib/compressed/translations/ar.js +1 -0
  444. data/vendor/assets/bower_components/pickadate/lib/compressed/translations/bg_BG.js +1 -0
  445. data/vendor/assets/bower_components/pickadate/lib/compressed/translations/bs_BA.js +1 -0
  446. data/vendor/assets/bower_components/pickadate/lib/compressed/translations/ca_ES.js +1 -0
  447. data/vendor/assets/bower_components/pickadate/lib/compressed/translations/cs_CZ.js +1 -0
  448. data/vendor/assets/bower_components/pickadate/lib/compressed/translations/da_DK.js +1 -0
  449. data/vendor/assets/bower_components/pickadate/lib/compressed/translations/de_DE.js +1 -0
  450. data/vendor/assets/bower_components/pickadate/lib/compressed/translations/el_GR.js +1 -0
  451. data/vendor/assets/bower_components/pickadate/lib/compressed/translations/es_ES.js +1 -0
  452. data/vendor/assets/bower_components/pickadate/lib/compressed/translations/et_EE.js +1 -0
  453. data/vendor/assets/bower_components/pickadate/lib/compressed/translations/eu_ES.js +1 -0
  454. data/vendor/assets/bower_components/pickadate/lib/compressed/translations/fi_FI.js +1 -0
  455. data/vendor/assets/bower_components/pickadate/lib/compressed/translations/fr_FR.js +1 -0
  456. data/vendor/assets/bower_components/pickadate/lib/compressed/translations/gl_ES.js +1 -0
  457. data/vendor/assets/bower_components/pickadate/lib/compressed/translations/he_IL.js +1 -0
  458. data/vendor/assets/bower_components/pickadate/lib/compressed/translations/hr_HR.js +1 -0
  459. data/vendor/assets/bower_components/pickadate/lib/compressed/translations/hu_HU.js +1 -0
  460. data/vendor/assets/bower_components/pickadate/lib/compressed/translations/id_ID.js +1 -0
  461. data/vendor/assets/bower_components/pickadate/lib/compressed/translations/is_IS.js +1 -0
  462. data/vendor/assets/bower_components/pickadate/lib/compressed/translations/it_IT.js +1 -0
  463. data/vendor/assets/bower_components/pickadate/lib/compressed/translations/ja_JP.js +1 -0
  464. data/vendor/assets/bower_components/pickadate/lib/compressed/translations/ko_KR.js +1 -0
  465. data/vendor/assets/bower_components/pickadate/lib/compressed/translations/ne_NP.js +1 -0
  466. data/vendor/assets/bower_components/pickadate/lib/compressed/translations/nl_NL.js +1 -0
  467. data/vendor/assets/bower_components/pickadate/lib/compressed/translations/no_NO.js +1 -0
  468. data/vendor/assets/bower_components/pickadate/lib/compressed/translations/pl_PL.js +1 -0
  469. data/vendor/assets/bower_components/pickadate/lib/compressed/translations/pt_BR.js +1 -0
  470. data/vendor/assets/bower_components/pickadate/lib/compressed/translations/pt_PT.js +1 -0
  471. data/vendor/assets/bower_components/pickadate/lib/compressed/translations/ro_RO.js +1 -0
  472. data/vendor/assets/bower_components/pickadate/lib/compressed/translations/ru_RU.js +1 -0
  473. data/vendor/assets/bower_components/pickadate/lib/compressed/translations/sk_SK.js +1 -0
  474. data/vendor/assets/bower_components/pickadate/lib/compressed/translations/sl_SI.js +1 -0
  475. data/vendor/assets/bower_components/pickadate/lib/compressed/translations/sv_SE.js +1 -0
  476. data/vendor/assets/bower_components/pickadate/lib/compressed/translations/th_TH.js +1 -0
  477. data/vendor/assets/bower_components/pickadate/lib/compressed/translations/tr_TR.js +1 -0
  478. data/vendor/assets/bower_components/pickadate/lib/compressed/translations/uk_UA.js +1 -0
  479. data/vendor/assets/bower_components/pickadate/lib/compressed/translations/vi_VN.js +1 -0
  480. data/vendor/assets/bower_components/pickadate/lib/compressed/translations/zh_CN.js +1 -0
  481. data/vendor/assets/bower_components/pickadate/lib/compressed/translations/zh_TW.js +1 -0
  482. data/vendor/assets/bower_components/pickadate/lib/legacy.js +133 -0
  483. data/vendor/assets/{javascripts/pickadate → bower_components/pickadate/lib}/picker.date.js +60 -28
  484. data/vendor/assets/{javascripts/pickadate → bower_components/pickadate/lib}/picker.js +41 -25
  485. data/vendor/assets/bower_components/pickadate/lib/picker.time.js +1014 -0
  486. data/vendor/assets/bower_components/pickadate/lib/themes-source/_variables.less +208 -0
  487. data/vendor/assets/bower_components/pickadate/lib/themes-source/base.date.less +333 -0
  488. data/vendor/assets/bower_components/pickadate/lib/themes-source/base.less +55 -0
  489. data/vendor/assets/bower_components/pickadate/lib/themes-source/base.time.less +119 -0
  490. data/vendor/assets/bower_components/pickadate/lib/themes-source/classic.date.less +9 -0
  491. data/vendor/assets/bower_components/pickadate/lib/themes-source/classic.less +119 -0
  492. data/vendor/assets/bower_components/pickadate/lib/themes-source/classic.time.less +49 -0
  493. data/vendor/assets/bower_components/pickadate/lib/themes-source/default.date.less +9 -0
  494. data/vendor/assets/bower_components/pickadate/lib/themes-source/default.less +246 -0
  495. data/vendor/assets/bower_components/pickadate/lib/themes-source/default.time.less +41 -0
  496. data/vendor/assets/bower_components/pickadate/lib/themes-source/rtl.less +38 -0
  497. data/vendor/assets/{stylesheets/pickadate/classic.scss → bower_components/pickadate/lib/themes/classic.css} +0 -0
  498. data/vendor/assets/{stylesheets/pickadate/classic.date.scss → bower_components/pickadate/lib/themes/classic.date.css} +33 -10
  499. data/vendor/assets/bower_components/pickadate/lib/themes/classic.time.css +132 -0
  500. data/vendor/assets/bower_components/pickadate/lib/themes/default.css +175 -0
  501. data/vendor/assets/bower_components/pickadate/lib/themes/default.date.css +301 -0
  502. data/vendor/assets/bower_components/pickadate/lib/themes/default.time.css +126 -0
  503. data/vendor/assets/bower_components/pickadate/lib/themes/rtl.css +29 -0
  504. data/vendor/assets/bower_components/pickadate/lib/translations/ar.js +12 -0
  505. data/vendor/assets/bower_components/pickadate/lib/translations/bg_BG.js +13 -0
  506. data/vendor/assets/bower_components/pickadate/lib/translations/bs_BA.js +13 -0
  507. data/vendor/assets/bower_components/pickadate/lib/translations/ca_ES.js +13 -0
  508. data/vendor/assets/bower_components/pickadate/lib/translations/cs_CZ.js +13 -0
  509. data/vendor/assets/bower_components/pickadate/lib/translations/da_DK.js +13 -0
  510. data/vendor/assets/bower_components/pickadate/lib/translations/de_DE.js +13 -0
  511. data/vendor/assets/bower_components/pickadate/lib/translations/el_GR.js +13 -0
  512. data/vendor/assets/bower_components/pickadate/lib/translations/es_ES.js +14 -0
  513. data/vendor/assets/bower_components/pickadate/lib/translations/et_EE.js +13 -0
  514. data/vendor/assets/bower_components/pickadate/lib/translations/eu_ES.js +13 -0
  515. data/vendor/assets/bower_components/pickadate/lib/translations/fi_FI.js +13 -0
  516. data/vendor/assets/bower_components/pickadate/lib/translations/fr_FR.js +18 -0
  517. data/vendor/assets/bower_components/pickadate/lib/translations/gl_ES.js +13 -0
  518. data/vendor/assets/bower_components/pickadate/lib/translations/he_IL.js +12 -0
  519. data/vendor/assets/bower_components/pickadate/lib/translations/hr_HR.js +13 -0
  520. data/vendor/assets/bower_components/pickadate/lib/translations/hu_HU.js +13 -0
  521. data/vendor/assets/bower_components/pickadate/lib/translations/id_ID.js +13 -0
  522. data/vendor/assets/bower_components/pickadate/lib/translations/is_IS.js +13 -0
  523. data/vendor/assets/bower_components/pickadate/lib/translations/it_IT.js +14 -0
  524. data/vendor/assets/bower_components/pickadate/lib/translations/ja_JP.js +13 -0
  525. data/vendor/assets/bower_components/pickadate/lib/translations/ko_KR.js +13 -0
  526. data/vendor/assets/bower_components/pickadate/lib/translations/ne_NP.js +13 -0
  527. data/vendor/assets/bower_components/pickadate/lib/translations/nl_NL.js +13 -0
  528. data/vendor/assets/bower_components/pickadate/lib/translations/no_NO.js +13 -0
  529. data/vendor/assets/bower_components/pickadate/lib/translations/pl_PL.js +13 -0
  530. data/vendor/assets/bower_components/pickadate/lib/translations/pt_BR.js +12 -0
  531. data/vendor/assets/bower_components/pickadate/lib/translations/pt_PT.js +12 -0
  532. data/vendor/assets/bower_components/pickadate/lib/translations/ro_RO.js +13 -0
  533. data/vendor/assets/bower_components/pickadate/lib/translations/ru_RU.js +14 -0
  534. data/vendor/assets/bower_components/pickadate/lib/translations/sk_SK.js +14 -0
  535. data/vendor/assets/bower_components/pickadate/lib/translations/sl_SI.js +13 -0
  536. data/vendor/assets/bower_components/pickadate/lib/translations/sv_SE.js +13 -0
  537. data/vendor/assets/bower_components/pickadate/lib/translations/th_TH.js +12 -0
  538. data/vendor/assets/bower_components/pickadate/lib/translations/tr_TR.js +13 -0
  539. data/vendor/assets/bower_components/pickadate/lib/translations/uk_UA.js +13 -0
  540. data/vendor/assets/bower_components/pickadate/lib/translations/vi_VN.js +11 -0
  541. data/vendor/assets/bower_components/pickadate/lib/translations/zh_CN.js +13 -0
  542. data/vendor/assets/bower_components/pickadate/lib/translations/zh_TW.js +13 -0
  543. data/vendor/assets/bower_components/pickadate/package.json +63 -0
  544. data/vendor/assets/bower_components/pickadate/pickadate.jquery.json +63 -0
  545. data/vendor/assets/bower_components/typeahead.js/CHANGELOG.md +222 -0
  546. data/vendor/assets/bower_components/typeahead.js/CONTRIBUTING.md +120 -0
  547. data/vendor/assets/bower_components/typeahead.js/Gruntfile.js +265 -0
  548. data/vendor/assets/bower_components/typeahead.js/LICENSE +19 -0
  549. data/vendor/assets/bower_components/typeahead.js/README.md +188 -0
  550. data/vendor/assets/bower_components/typeahead.js/bower.json +13 -0
  551. data/vendor/assets/bower_components/typeahead.js/composer.json +17 -0
  552. data/vendor/assets/bower_components/typeahead.js/dist/bloodhound.js +727 -0
  553. data/vendor/assets/bower_components/typeahead.js/dist/bloodhound.min.js +7 -0
  554. data/vendor/assets/bower_components/typeahead.js/dist/typeahead.bundle.js +1782 -0
  555. data/vendor/assets/bower_components/typeahead.js/dist/typeahead.bundle.min.js +7 -0
  556. data/vendor/assets/{javascripts → bower_components/typeahead.js/dist}/typeahead.jquery.js +0 -0
  557. data/vendor/assets/bower_components/typeahead.js/dist/typeahead.jquery.min.js +7 -0
  558. data/vendor/assets/bower_components/typeahead.js/doc/bloodhound.md +279 -0
  559. data/vendor/assets/bower_components/typeahead.js/doc/jquery_typeahead.md +383 -0
  560. data/vendor/assets/bower_components/typeahead.js/doc/migration/0.10.0.md +234 -0
  561. data/vendor/assets/bower_components/typeahead.js/karma.conf.js +98 -0
  562. data/vendor/assets/bower_components/typeahead.js/package.json +57 -0
  563. data/vendor/assets/bower_components/typeahead.js/src/bloodhound/bloodhound.js +234 -0
  564. data/vendor/assets/bower_components/typeahead.js/src/bloodhound/lru_cache.js +99 -0
  565. data/vendor/assets/bower_components/typeahead.js/src/bloodhound/options_parser.js +89 -0
  566. data/vendor/assets/bower_components/typeahead.js/src/bloodhound/persistent_storage.js +131 -0
  567. data/vendor/assets/bower_components/typeahead.js/src/bloodhound/search_index.js +169 -0
  568. data/vendor/assets/bower_components/typeahead.js/src/bloodhound/tokenizers.js +44 -0
  569. data/vendor/assets/bower_components/typeahead.js/src/bloodhound/transport.js +152 -0
  570. data/vendor/assets/bower_components/typeahead.js/src/bloodhound/version.js +7 -0
  571. data/vendor/assets/bower_components/typeahead.js/src/common/utils.js +152 -0
  572. data/vendor/assets/bower_components/typeahead.js/src/typeahead/css.js +77 -0
  573. data/vendor/assets/bower_components/typeahead.js/src/typeahead/dataset.js +210 -0
  574. data/vendor/assets/bower_components/typeahead.js/src/typeahead/dropdown.js +245 -0
  575. data/vendor/assets/bower_components/typeahead.js/src/typeahead/event_bus.js +38 -0
  576. data/vendor/assets/bower_components/typeahead.js/src/typeahead/event_emitter.js +119 -0
  577. data/vendor/assets/bower_components/typeahead.js/src/typeahead/highlight.js +84 -0
  578. data/vendor/assets/bower_components/typeahead.js/src/typeahead/html.js +15 -0
  579. data/vendor/assets/bower_components/typeahead.js/src/typeahead/input.js +311 -0
  580. data/vendor/assets/bower_components/typeahead.js/src/typeahead/plugin.js +129 -0
  581. data/vendor/assets/bower_components/typeahead.js/src/typeahead/typeahead.js +391 -0
  582. data/vendor/assets/bower_components/typeahead.js/test/bloodhound_spec.js +592 -0
  583. data/vendor/assets/bower_components/typeahead.js/test/ci +12 -0
  584. data/vendor/assets/bower_components/typeahead.js/test/dataset_view_spec.js +222 -0
  585. data/vendor/assets/bower_components/typeahead.js/test/dropdown_view_spec.js +353 -0
  586. data/vendor/assets/bower_components/typeahead.js/test/event_emitter_spec.js +111 -0
  587. data/vendor/assets/bower_components/typeahead.js/test/fixtures/ajax_responses.js +19 -0
  588. data/vendor/assets/bower_components/typeahead.js/test/fixtures/data.js +116 -0
  589. data/vendor/assets/bower_components/typeahead.js/test/fixtures/html.js +17 -0
  590. data/vendor/assets/bower_components/typeahead.js/test/helpers/typeahead_mocks.js +71 -0
  591. data/vendor/assets/bower_components/typeahead.js/test/highlight_spec.js +117 -0
  592. data/vendor/assets/bower_components/typeahead.js/test/input_view_spec.js +449 -0
  593. data/vendor/assets/bower_components/typeahead.js/test/integration/test.html +112 -0
  594. data/vendor/assets/bower_components/typeahead.js/test/integration/test.js +397 -0
  595. data/vendor/assets/bower_components/typeahead.js/test/lru_cache_spec.js +42 -0
  596. data/vendor/assets/bower_components/typeahead.js/test/persistent_storage_spec.js +131 -0
  597. data/vendor/assets/bower_components/typeahead.js/test/playground.html +347 -0
  598. data/vendor/assets/bower_components/typeahead.js/test/search_index_spec.js +60 -0
  599. data/vendor/assets/bower_components/typeahead.js/test/tokenizers_spec.js +60 -0
  600. data/vendor/assets/bower_components/typeahead.js/test/transport_spec.js +197 -0
  601. data/vendor/assets/bower_components/typeahead.js/test/typeahead_view_spec.js +570 -0
  602. data/vendor/assets/bower_components/typeahead.js/typeahead.js.jquery.json +40 -0
  603. metadata +576 -12
  604. data/vendor/assets/javascripts/html5.js +0 -3
  605. data/vendor/assets/javascripts/jquery-1.7.1.js +0 -9266
  606. data/vendor/assets/javascripts/rails.js +0 -373
@@ -1,993 +1,713 @@
1
- // Generated by CoffeeScript 1.7.1
2
-
3
- /*
4
- Copyright 2013 Marco Braak
5
-
6
- Licensed under the Apache License, Version 2.0 (the "License");
7
- you may not use this file except in compliance with the License.
8
- You may obtain a copy of the License at
9
-
10
- http://www.apache.org/licenses/LICENSE-2.0
11
-
12
- Unless required by applicable law or agreed to in writing, software
13
- distributed under the License is distributed on an "AS IS" BASIS,
14
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- See the License for the specific language governing permissions and
16
- limitations under the License.
17
- */
18
-
1
+ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
19
2
  (function() {
20
- var $, BorderDropHint, DragAndDropHandler, DragElement, ElementsRenderer, FolderElement, GhostDropHint, HitAreasGenerator, JqTreeWidget, KeyHandler, MouseWidget, Node, NodeElement, Position, SaveStateHandler, ScrollHandler, SelectNodeHandler, SimpleWidget, VisibleNodeIterator, get_json_stringify_function, html_escape, indexOf, isInt, _indexOf,
21
- __slice = [].slice,
3
+ var DragAndDropHandler, DragElement, HitAreasGenerator, Position, VisibleNodeIterator, node_module,
22
4
  __hasProp = {}.hasOwnProperty,
23
5
  __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
24
6
 
25
- $ = this.jQuery;
7
+ node_module = require('./node');
26
8
 
27
- SimpleWidget = (function() {
28
- SimpleWidget.prototype.defaults = {};
9
+ Position = node_module.Position;
29
10
 
30
- function SimpleWidget(el, options) {
31
- this.$el = $(el);
32
- this.options = $.extend({}, this.defaults, options);
11
+ DragAndDropHandler = (function() {
12
+ function DragAndDropHandler(tree_widget) {
13
+ this.tree_widget = tree_widget;
14
+ this.hovered_area = null;
15
+ this.$ghost = null;
16
+ this.hit_areas = [];
17
+ this.is_dragging = false;
18
+ this.current_item = null;
33
19
  }
34
20
 
35
- SimpleWidget.prototype.destroy = function() {
36
- return this._deinit();
37
- };
38
-
39
- SimpleWidget.prototype._init = function() {
40
- return null;
21
+ DragAndDropHandler.prototype.mouseCapture = function(position_info) {
22
+ var $element, node_element;
23
+ $element = $(position_info.target);
24
+ if (!this.mustCaptureElement($element)) {
25
+ return null;
26
+ }
27
+ if (this.tree_widget.options.onIsMoveHandle && !this.tree_widget.options.onIsMoveHandle($element)) {
28
+ return null;
29
+ }
30
+ node_element = this.tree_widget._getNodeElement($element);
31
+ if (node_element && this.tree_widget.options.onCanMove) {
32
+ if (!this.tree_widget.options.onCanMove(node_element.node)) {
33
+ node_element = null;
34
+ }
35
+ }
36
+ this.current_item = node_element;
37
+ return this.current_item !== null;
41
38
  };
42
39
 
43
- SimpleWidget.prototype._deinit = function() {
44
- return null;
40
+ DragAndDropHandler.prototype.mouseStart = function(position_info) {
41
+ var offset;
42
+ this.refresh();
43
+ offset = $(position_info.target).offset();
44
+ this.drag_element = new DragElement(this.current_item.node, position_info.page_x - offset.left, position_info.page_y - offset.top, this.tree_widget.element);
45
+ this.is_dragging = true;
46
+ this.current_item.$element.addClass('jqtree-moving');
47
+ return true;
45
48
  };
46
49
 
47
- SimpleWidget.register = function(widget_class, widget_name) {
48
- var callFunction, createWidget, destroyWidget, getDataKey, getWidgetData;
49
- getDataKey = function() {
50
- return "simple_widget_" + widget_name;
51
- };
52
- getWidgetData = function(el, data_key) {
53
- var widget;
54
- widget = $.data(el, data_key);
55
- if (widget && (widget instanceof SimpleWidget)) {
56
- return widget;
57
- } else {
58
- return null;
59
- }
60
- };
61
- createWidget = function($el, options) {
62
- var data_key, el, existing_widget, widget, _i, _len;
63
- data_key = getDataKey();
64
- for (_i = 0, _len = $el.length; _i < _len; _i++) {
65
- el = $el[_i];
66
- existing_widget = getWidgetData(el, data_key);
67
- if (!existing_widget) {
68
- widget = new widget_class(el, options);
69
- if (!$.data(el, data_key)) {
70
- $.data(el, data_key, widget);
71
- }
72
- widget._init();
73
- }
74
- }
75
- return $el;
76
- };
77
- destroyWidget = function($el) {
78
- var data_key, el, widget, _i, _len, _results;
79
- data_key = getDataKey();
80
- _results = [];
81
- for (_i = 0, _len = $el.length; _i < _len; _i++) {
82
- el = $el[_i];
83
- widget = getWidgetData(el, data_key);
84
- if (widget) {
85
- widget.destroy();
86
- }
87
- _results.push($.removeData(el, data_key));
88
- }
89
- return _results;
90
- };
91
- callFunction = function($el, function_name, args) {
92
- var el, result, widget, widget_function, _i, _len;
93
- result = null;
94
- for (_i = 0, _len = $el.length; _i < _len; _i++) {
95
- el = $el[_i];
96
- widget = $.data(el, getDataKey());
97
- if (widget && (widget instanceof SimpleWidget)) {
98
- widget_function = widget[function_name];
99
- if (widget_function && (typeof widget_function === 'function')) {
100
- result = widget_function.apply(widget, args);
101
- }
102
- }
50
+ DragAndDropHandler.prototype.mouseDrag = function(position_info) {
51
+ var area, can_move_to;
52
+ this.drag_element.move(position_info.page_x, position_info.page_y);
53
+ area = this.findHoveredArea(position_info.page_x, position_info.page_y);
54
+ can_move_to = this.canMoveToArea(area);
55
+ if (can_move_to && area) {
56
+ if (!area.node.isFolder()) {
57
+ this.stopOpenFolderTimer();
103
58
  }
104
- return result;
105
- };
106
- return $.fn[widget_name] = function() {
107
- var $el, args, argument1, function_name, options;
108
- argument1 = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
109
- $el = this;
110
- if (argument1 === void 0 || typeof argument1 === 'object') {
111
- options = argument1;
112
- return createWidget($el, options);
113
- } else if (typeof argument1 === 'string' && argument1[0] !== '_') {
114
- function_name = argument1;
115
- if (function_name === 'destroy') {
116
- return destroyWidget($el);
59
+ if (this.hovered_area !== area) {
60
+ this.hovered_area = area;
61
+ if (this.mustOpenFolderTimer(area)) {
62
+ this.startOpenFolderTimer(area.node);
117
63
  } else {
118
- return callFunction($el, function_name, args);
64
+ this.stopOpenFolderTimer();
119
65
  }
66
+ this.updateDropHint();
120
67
  }
121
- };
68
+ } else {
69
+ this.removeHover();
70
+ this.removeDropHint();
71
+ this.stopOpenFolderTimer();
72
+ }
73
+ return true;
122
74
  };
123
75
 
124
- return SimpleWidget;
125
-
126
- })();
76
+ DragAndDropHandler.prototype.mustCaptureElement = function($element) {
77
+ return !$element.is('input,select');
78
+ };
127
79
 
128
- this.SimpleWidget = SimpleWidget;
80
+ DragAndDropHandler.prototype.canMoveToArea = function(area) {
81
+ var position_name;
82
+ if (!area) {
83
+ return false;
84
+ } else if (this.tree_widget.options.onCanMoveTo) {
85
+ position_name = Position.getName(area.position);
86
+ return this.tree_widget.options.onCanMoveTo(this.current_item.node, area.node, position_name);
87
+ } else {
88
+ return true;
89
+ }
90
+ };
129
91
 
92
+ DragAndDropHandler.prototype.mouseStop = function(position_info) {
93
+ this.moveItem(position_info);
94
+ this.clear();
95
+ this.removeHover();
96
+ this.removeDropHint();
97
+ this.removeHitAreas();
98
+ if (this.current_item) {
99
+ this.current_item.$element.removeClass('jqtree-moving');
100
+ this.current_item = null;
101
+ }
102
+ this.is_dragging = false;
103
+ return false;
104
+ };
130
105
 
131
- /*
132
- This widget does the same a the mouse widget in jqueryui.
133
- */
106
+ DragAndDropHandler.prototype.refresh = function() {
107
+ this.removeHitAreas();
108
+ if (this.current_item) {
109
+ this.generateHitAreas();
110
+ this.current_item = this.tree_widget._getNodeElementForNode(this.current_item.node);
111
+ if (this.is_dragging) {
112
+ return this.current_item.$element.addClass('jqtree-moving');
113
+ }
114
+ }
115
+ };
134
116
 
135
- MouseWidget = (function(_super) {
136
- __extends(MouseWidget, _super);
117
+ DragAndDropHandler.prototype.removeHitAreas = function() {
118
+ return this.hit_areas = [];
119
+ };
137
120
 
138
- function MouseWidget() {
139
- return MouseWidget.__super__.constructor.apply(this, arguments);
140
- }
121
+ DragAndDropHandler.prototype.clear = function() {
122
+ this.drag_element.remove();
123
+ return this.drag_element = null;
124
+ };
141
125
 
142
- MouseWidget.is_mouse_handled = false;
126
+ DragAndDropHandler.prototype.removeDropHint = function() {
127
+ if (this.previous_ghost) {
128
+ return this.previous_ghost.remove();
129
+ }
130
+ };
143
131
 
144
- MouseWidget.prototype._init = function() {
145
- this.$el.bind('mousedown.mousewidget', $.proxy(this._mouseDown, this));
146
- this.$el.bind('touchstart.mousewidget', $.proxy(this._touchStart, this));
147
- this.is_mouse_started = false;
148
- this.mouse_delay = 0;
149
- this._mouse_delay_timer = null;
150
- this._is_mouse_delay_met = true;
151
- return this.mouse_down_info = null;
132
+ DragAndDropHandler.prototype.removeHover = function() {
133
+ return this.hovered_area = null;
152
134
  };
153
135
 
154
- MouseWidget.prototype._deinit = function() {
155
- var $document;
156
- this.$el.unbind('mousedown.mousewidget');
157
- this.$el.unbind('touchstart.mousewidget');
158
- $document = $(document);
159
- $document.unbind('mousemove.mousewidget');
160
- return $document.unbind('mouseup.mousewidget');
136
+ DragAndDropHandler.prototype.generateHitAreas = function() {
137
+ var hit_areas_generator;
138
+ hit_areas_generator = new HitAreasGenerator(this.tree_widget.tree, this.current_item.node, this.getTreeDimensions().bottom);
139
+ return this.hit_areas = hit_areas_generator.generate();
161
140
  };
162
141
 
163
- MouseWidget.prototype._mouseDown = function(e) {
164
- var result;
165
- if (e.which !== 1) {
166
- return;
142
+ DragAndDropHandler.prototype.findHoveredArea = function(x, y) {
143
+ var area, dimensions, high, low, mid;
144
+ dimensions = this.getTreeDimensions();
145
+ if (x < dimensions.left || y < dimensions.top || x > dimensions.right || y > dimensions.bottom) {
146
+ return null;
167
147
  }
168
- result = this._handleMouseDown(e, this._getPositionInfo(e));
169
- if (result) {
170
- e.preventDefault();
148
+ low = 0;
149
+ high = this.hit_areas.length;
150
+ while (low < high) {
151
+ mid = (low + high) >> 1;
152
+ area = this.hit_areas[mid];
153
+ if (y < area.top) {
154
+ high = mid;
155
+ } else if (y > area.bottom) {
156
+ low = mid + 1;
157
+ } else {
158
+ return area;
159
+ }
171
160
  }
172
- return result;
161
+ return null;
173
162
  };
174
163
 
175
- MouseWidget.prototype._handleMouseDown = function(e, position_info) {
176
- if (MouseWidget.is_mouse_handled) {
177
- return;
178
- }
179
- if (this.is_mouse_started) {
180
- this._handleMouseUp(position_info);
181
- }
182
- this.mouse_down_info = position_info;
183
- if (!this._mouseCapture(position_info)) {
184
- return;
185
- }
186
- this._handleStartMouse();
187
- this.is_mouse_handled = true;
188
- return true;
164
+ DragAndDropHandler.prototype.mustOpenFolderTimer = function(area) {
165
+ var node;
166
+ node = area.node;
167
+ return node.isFolder() && !node.is_open && area.position === Position.INSIDE;
189
168
  };
190
169
 
191
- MouseWidget.prototype._handleStartMouse = function() {
192
- var $document;
193
- $document = $(document);
194
- $document.bind('mousemove.mousewidget', $.proxy(this._mouseMove, this));
195
- $document.bind('touchmove.mousewidget', $.proxy(this._touchMove, this));
196
- $document.bind('mouseup.mousewidget', $.proxy(this._mouseUp, this));
197
- $document.bind('touchend.mousewidget', $.proxy(this._touchEnd, this));
198
- if (this.mouse_delay) {
199
- return this._startMouseDelayTimer();
170
+ DragAndDropHandler.prototype.updateDropHint = function() {
171
+ var node_element;
172
+ if (!this.hovered_area) {
173
+ return;
200
174
  }
175
+ this.removeDropHint();
176
+ node_element = this.tree_widget._getNodeElementForNode(this.hovered_area.node);
177
+ return this.previous_ghost = node_element.addDropHint(this.hovered_area.position);
201
178
  };
202
179
 
203
- MouseWidget.prototype._startMouseDelayTimer = function() {
204
- if (this._mouse_delay_timer) {
205
- clearTimeout(this._mouse_delay_timer);
206
- }
207
- this._mouse_delay_timer = setTimeout((function(_this) {
180
+ DragAndDropHandler.prototype.startOpenFolderTimer = function(folder) {
181
+ var openFolder;
182
+ openFolder = (function(_this) {
208
183
  return function() {
209
- return _this._is_mouse_delay_met = true;
184
+ return _this.tree_widget._openNode(folder, _this.tree_widget.options.slide, function() {
185
+ _this.refresh();
186
+ return _this.updateDropHint();
187
+ });
210
188
  };
211
- })(this), this.mouse_delay);
212
- return this._is_mouse_delay_met = false;
189
+ })(this);
190
+ this.stopOpenFolderTimer();
191
+ return this.open_folder_timer = setTimeout(openFolder, this.tree_widget.options.openFolderDelay);
213
192
  };
214
193
 
215
- MouseWidget.prototype._mouseMove = function(e) {
216
- return this._handleMouseMove(e, this._getPositionInfo(e));
194
+ DragAndDropHandler.prototype.stopOpenFolderTimer = function() {
195
+ if (this.open_folder_timer) {
196
+ clearTimeout(this.open_folder_timer);
197
+ return this.open_folder_timer = null;
198
+ }
217
199
  };
218
200
 
219
- MouseWidget.prototype._handleMouseMove = function(e, position_info) {
220
- if (this.is_mouse_started) {
221
- this._mouseDrag(position_info);
222
- return e.preventDefault();
223
- }
224
- if (this.mouse_delay && !this._is_mouse_delay_met) {
225
- return true;
226
- }
227
- this.is_mouse_started = this._mouseStart(this.mouse_down_info) !== false;
228
- if (this.is_mouse_started) {
229
- this._mouseDrag(position_info);
230
- } else {
231
- this._handleMouseUp(position_info);
201
+ DragAndDropHandler.prototype.moveItem = function(position_info) {
202
+ var doMove, event, moved_node, position, previous_parent, target_node;
203
+ if (this.hovered_area && this.hovered_area.position !== Position.NONE && this.canMoveToArea(this.hovered_area)) {
204
+ moved_node = this.current_item.node;
205
+ target_node = this.hovered_area.node;
206
+ position = this.hovered_area.position;
207
+ previous_parent = moved_node.parent;
208
+ if (position === Position.INSIDE) {
209
+ this.hovered_area.node.is_open = true;
210
+ }
211
+ doMove = (function(_this) {
212
+ return function() {
213
+ _this.tree_widget.tree.moveNode(moved_node, target_node, position);
214
+ _this.tree_widget.element.empty();
215
+ return _this.tree_widget._refreshElements();
216
+ };
217
+ })(this);
218
+ event = this.tree_widget._triggerEvent('tree.move', {
219
+ move_info: {
220
+ moved_node: moved_node,
221
+ target_node: target_node,
222
+ position: Position.getName(position),
223
+ previous_parent: previous_parent,
224
+ do_move: doMove,
225
+ original_event: position_info.original_event
226
+ }
227
+ });
228
+ if (!event.isDefaultPrevented()) {
229
+ return doMove();
230
+ }
232
231
  }
233
- return !this.is_mouse_started;
234
232
  };
235
233
 
236
- MouseWidget.prototype._getPositionInfo = function(e) {
234
+ DragAndDropHandler.prototype.getTreeDimensions = function() {
235
+ var offset;
236
+ offset = this.tree_widget.element.offset();
237
237
  return {
238
- page_x: e.pageX,
239
- page_y: e.pageY,
240
- target: e.target,
241
- original_event: e
238
+ left: offset.left,
239
+ top: offset.top,
240
+ right: offset.left + this.tree_widget.element.width(),
241
+ bottom: offset.top + this.tree_widget.element.height() + 16
242
242
  };
243
243
  };
244
244
 
245
- MouseWidget.prototype._mouseUp = function(e) {
246
- return this._handleMouseUp(this._getPositionInfo(e));
247
- };
248
-
249
- MouseWidget.prototype._handleMouseUp = function(position_info) {
250
- var $document;
251
- $document = $(document);
252
- $document.unbind('mousemove.mousewidget');
253
- $document.unbind('touchmove.mousewidget');
254
- $document.unbind('mouseup.mousewidget');
255
- $document.unbind('touchend.mousewidget');
256
- if (this.is_mouse_started) {
257
- this.is_mouse_started = false;
258
- this._mouseStop(position_info);
259
- }
260
- };
261
-
262
- MouseWidget.prototype._mouseCapture = function(position_info) {
263
- return true;
264
- };
245
+ return DragAndDropHandler;
265
246
 
266
- MouseWidget.prototype._mouseStart = function(position_info) {
267
- return null;
268
- };
247
+ })();
269
248
 
270
- MouseWidget.prototype._mouseDrag = function(position_info) {
271
- return null;
272
- };
249
+ VisibleNodeIterator = (function() {
250
+ function VisibleNodeIterator(tree) {
251
+ this.tree = tree;
252
+ }
273
253
 
274
- MouseWidget.prototype._mouseStop = function(position_info) {
275
- return null;
254
+ VisibleNodeIterator.prototype.iterate = function() {
255
+ var is_first_node, _iterateNode;
256
+ is_first_node = true;
257
+ _iterateNode = (function(_this) {
258
+ return function(node, next_node) {
259
+ var $element, child, children_length, i, must_iterate_inside, _i, _len, _ref;
260
+ must_iterate_inside = (node.is_open || !node.element) && node.hasChildren();
261
+ if (node.element) {
262
+ $element = $(node.element);
263
+ if (!$element.is(':visible')) {
264
+ return;
265
+ }
266
+ if (is_first_node) {
267
+ _this.handleFirstNode(node, $element);
268
+ is_first_node = false;
269
+ }
270
+ if (!node.hasChildren()) {
271
+ _this.handleNode(node, next_node, $element);
272
+ } else if (node.is_open) {
273
+ if (!_this.handleOpenFolder(node, $element)) {
274
+ must_iterate_inside = false;
275
+ }
276
+ } else {
277
+ _this.handleClosedFolder(node, next_node, $element);
278
+ }
279
+ }
280
+ if (must_iterate_inside) {
281
+ children_length = node.children.length;
282
+ _ref = node.children;
283
+ for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) {
284
+ child = _ref[i];
285
+ if (i === (children_length - 1)) {
286
+ _iterateNode(node.children[i], null);
287
+ } else {
288
+ _iterateNode(node.children[i], node.children[i + 1]);
289
+ }
290
+ }
291
+ if (node.is_open) {
292
+ return _this.handleAfterOpenFolder(node, next_node, $element);
293
+ }
294
+ }
295
+ };
296
+ })(this);
297
+ return _iterateNode(this.tree, null);
276
298
  };
277
299
 
278
- MouseWidget.prototype.setMouseDelay = function(mouse_delay) {
279
- return this.mouse_delay = mouse_delay;
280
- };
300
+ VisibleNodeIterator.prototype.handleNode = function(node, next_node, $element) {};
281
301
 
282
- MouseWidget.prototype._touchStart = function(e) {
283
- var touch;
284
- if (e.originalEvent.touches.length > 1) {
285
- return;
286
- }
287
- touch = e.originalEvent.changedTouches[0];
288
- return this._handleMouseDown(e, this._getPositionInfo(touch));
289
- };
302
+ VisibleNodeIterator.prototype.handleOpenFolder = function(node, $element) {};
290
303
 
291
- MouseWidget.prototype._touchMove = function(e) {
292
- var touch;
293
- if (e.originalEvent.touches.length > 1) {
294
- return;
295
- }
296
- touch = e.originalEvent.changedTouches[0];
297
- return this._handleMouseMove(e, this._getPositionInfo(touch));
298
- };
304
+ VisibleNodeIterator.prototype.handleClosedFolder = function(node, next_node, $element) {};
299
305
 
300
- MouseWidget.prototype._touchEnd = function(e) {
301
- var touch;
302
- if (e.originalEvent.touches.length > 1) {
303
- return;
304
- }
305
- touch = e.originalEvent.changedTouches[0];
306
- return this._handleMouseUp(this._getPositionInfo(touch));
307
- };
306
+ VisibleNodeIterator.prototype.handleAfterOpenFolder = function(node, next_node, $element) {};
308
307
 
309
- return MouseWidget;
308
+ VisibleNodeIterator.prototype.handleFirstNode = function(node, $element) {};
310
309
 
311
- })(SimpleWidget);
310
+ return VisibleNodeIterator;
312
311
 
313
- this.Tree = {};
312
+ })();
314
313
 
315
- $ = this.jQuery;
314
+ HitAreasGenerator = (function(_super) {
315
+ __extends(HitAreasGenerator, _super);
316
316
 
317
- Position = {
318
- getName: function(position) {
319
- return Position.strings[position - 1];
320
- },
321
- nameToIndex: function(name) {
322
- var i, _i, _ref;
323
- for (i = _i = 1, _ref = Position.strings.length; 1 <= _ref ? _i <= _ref : _i >= _ref; i = 1 <= _ref ? ++_i : --_i) {
324
- if (Position.strings[i - 1] === name) {
325
- return i;
326
- }
327
- }
328
- return 0;
317
+ function HitAreasGenerator(tree, current_node, tree_bottom) {
318
+ HitAreasGenerator.__super__.constructor.call(this, tree);
319
+ this.current_node = current_node;
320
+ this.tree_bottom = tree_bottom;
329
321
  }
330
- };
331
-
332
- Position.BEFORE = 1;
333
322
 
334
- Position.AFTER = 2;
323
+ HitAreasGenerator.prototype.generate = function() {
324
+ this.positions = [];
325
+ this.last_top = 0;
326
+ this.iterate();
327
+ return this.generateHitAreas(this.positions);
328
+ };
335
329
 
336
- Position.INSIDE = 3;
337
-
338
- Position.NONE = 4;
339
-
340
- Position.strings = ['before', 'after', 'inside', 'none'];
330
+ HitAreasGenerator.prototype.getTop = function($element) {
331
+ return $element.offset().top;
332
+ };
341
333
 
342
- this.Tree.Position = Position;
334
+ HitAreasGenerator.prototype.addPosition = function(node, position, top) {
335
+ var area;
336
+ area = {
337
+ top: top,
338
+ node: node,
339
+ position: position
340
+ };
341
+ this.positions.push(area);
342
+ return this.last_top = top;
343
+ };
343
344
 
344
- Node = (function() {
345
- function Node(o, is_root, node_class) {
346
- if (is_root == null) {
347
- is_root = false;
345
+ HitAreasGenerator.prototype.handleNode = function(node, next_node, $element) {
346
+ var top;
347
+ top = this.getTop($element);
348
+ if (node === this.current_node) {
349
+ this.addPosition(node, Position.NONE, top);
350
+ } else {
351
+ this.addPosition(node, Position.INSIDE, top);
348
352
  }
349
- if (node_class == null) {
350
- node_class = Node;
353
+ if (next_node === this.current_node || node === this.current_node) {
354
+ return this.addPosition(node, Position.NONE, top);
355
+ } else {
356
+ return this.addPosition(node, Position.AFTER, top);
351
357
  }
352
- this.setData(o);
353
- this.children = [];
354
- this.parent = null;
355
- if (is_root) {
356
- this.id_mapping = {};
357
- this.tree = this;
358
- this.node_class = node_class;
358
+ };
359
+
360
+ HitAreasGenerator.prototype.handleOpenFolder = function(node, $element) {
361
+ if (node === this.current_node) {
362
+ return false;
359
363
  }
360
- }
364
+ if (node.children[0] !== this.current_node) {
365
+ this.addPosition(node, Position.INSIDE, this.getTop($element));
366
+ }
367
+ return true;
368
+ };
361
369
 
362
- Node.prototype.setData = function(o) {
363
- var key, value, _results;
364
- if (typeof o !== 'object') {
365
- return this.name = o;
370
+ HitAreasGenerator.prototype.handleClosedFolder = function(node, next_node, $element) {
371
+ var top;
372
+ top = this.getTop($element);
373
+ if (node === this.current_node) {
374
+ return this.addPosition(node, Position.NONE, top);
366
375
  } else {
367
- _results = [];
368
- for (key in o) {
369
- value = o[key];
370
- if (key === 'label') {
371
- _results.push(this.name = value);
372
- } else {
373
- _results.push(this[key] = value);
374
- }
376
+ this.addPosition(node, Position.INSIDE, top);
377
+ if (next_node !== this.current_node) {
378
+ return this.addPosition(node, Position.AFTER, top);
375
379
  }
376
- return _results;
377
380
  }
378
381
  };
379
382
 
380
- Node.prototype.initFromData = function(data) {
381
- var addChildren, addNode;
382
- addNode = (function(_this) {
383
- return function(node_data) {
384
- _this.setData(node_data);
385
- if (node_data.children) {
386
- return addChildren(node_data.children);
387
- }
388
- };
389
- })(this);
390
- addChildren = (function(_this) {
391
- return function(children_data) {
392
- var child, node, _i, _len;
393
- for (_i = 0, _len = children_data.length; _i < _len; _i++) {
394
- child = children_data[_i];
395
- node = new _this.tree.node_class('');
396
- node.initFromData(child);
397
- _this.addChild(node);
398
- }
399
- return null;
400
- };
401
- })(this);
402
- addNode(data);
403
- return null;
383
+ HitAreasGenerator.prototype.handleFirstNode = function(node, $element) {
384
+ if (node !== this.current_node) {
385
+ return this.addPosition(node, Position.BEFORE, this.getTop($(node.element)));
386
+ }
404
387
  };
405
388
 
389
+ HitAreasGenerator.prototype.handleAfterOpenFolder = function(node, next_node, $element) {
390
+ if (node === this.current_node.node || next_node === this.current_node.node) {
391
+ return this.addPosition(node, Position.NONE, this.last_top);
392
+ } else {
393
+ return this.addPosition(node, Position.AFTER, this.last_top);
394
+ }
395
+ };
406
396
 
407
- /*
408
- Create tree from data.
409
-
410
- Structure of data is:
411
- [
412
- {
413
- label: 'node1',
414
- children: [
415
- { label: 'child1' },
416
- { label: 'child2' }
417
- ]
418
- },
419
- {
420
- label: 'node2'
397
+ HitAreasGenerator.prototype.generateHitAreas = function(positions) {
398
+ var group, hit_areas, position, previous_top, _i, _len;
399
+ previous_top = -1;
400
+ group = [];
401
+ hit_areas = [];
402
+ for (_i = 0, _len = positions.length; _i < _len; _i++) {
403
+ position = positions[_i];
404
+ if (position.top !== previous_top && group.length) {
405
+ if (group.length) {
406
+ this.generateHitAreasForGroup(hit_areas, group, previous_top, position.top);
407
+ }
408
+ previous_top = position.top;
409
+ group = [];
421
410
  }
422
- ]
423
- */
411
+ group.push(position);
412
+ }
413
+ this.generateHitAreasForGroup(hit_areas, group, previous_top, this.tree_bottom);
414
+ return hit_areas;
415
+ };
424
416
 
425
- Node.prototype.loadFromData = function(data) {
426
- var node, o, _i, _len;
427
- this.removeChildren();
428
- for (_i = 0, _len = data.length; _i < _len; _i++) {
429
- o = data[_i];
430
- node = new this.tree.node_class(o);
431
- this.addChild(node);
432
- if (typeof o === 'object' && o.children) {
433
- node.loadFromData(o.children);
434
- }
417
+ HitAreasGenerator.prototype.generateHitAreasForGroup = function(hit_areas, positions_in_group, top, bottom) {
418
+ var area_height, area_top, i, position, position_count;
419
+ position_count = Math.min(positions_in_group.length, 4);
420
+ area_height = Math.round((bottom - top) / position_count);
421
+ area_top = top;
422
+ i = 0;
423
+ while (i < position_count) {
424
+ position = positions_in_group[i];
425
+ hit_areas.push({
426
+ top: area_top,
427
+ bottom: area_top + area_height,
428
+ node: position.node,
429
+ position: position.position
430
+ });
431
+ area_top += area_height;
432
+ i += 1;
435
433
  }
436
434
  return null;
437
435
  };
438
436
 
437
+ return HitAreasGenerator;
439
438
 
440
- /*
441
- Add child.
442
-
443
- tree.addChild(
444
- new Node('child1')
445
- );
446
- */
447
-
448
- Node.prototype.addChild = function(node) {
449
- this.children.push(node);
450
- return node._setParent(this);
451
- };
452
-
439
+ })(VisibleNodeIterator);
453
440
 
454
- /*
455
- Add child at position. Index starts at 0.
456
-
457
- tree.addChildAtPosition(
458
- new Node('abc'),
459
- 1
460
- );
461
- */
441
+ DragElement = (function() {
442
+ function DragElement(node, offset_x, offset_y, $tree) {
443
+ this.offset_x = offset_x;
444
+ this.offset_y = offset_y;
445
+ this.$element = $("<span class=\"jqtree-title jqtree-dragging\">" + node.name + "</span>");
446
+ this.$element.css("position", "absolute");
447
+ $tree.append(this.$element);
448
+ }
462
449
 
463
- Node.prototype.addChildAtPosition = function(node, index) {
464
- this.children.splice(index, 0, node);
465
- return node._setParent(this);
450
+ DragElement.prototype.move = function(page_x, page_y) {
451
+ return this.$element.offset({
452
+ left: page_x - this.offset_x,
453
+ top: page_y - this.offset_y
454
+ });
466
455
  };
467
456
 
468
- Node.prototype._setParent = function(parent) {
469
- this.parent = parent;
470
- this.tree = parent.tree;
471
- return this.tree.addNodeToIndex(this);
457
+ DragElement.prototype.remove = function() {
458
+ return this.$element.remove();
472
459
  };
473
460
 
461
+ return DragElement;
474
462
 
475
- /*
476
- Remove child. This also removes the children of the node.
477
-
478
- tree.removeChild(tree.children[0]);
479
- */
463
+ })();
480
464
 
481
- Node.prototype.removeChild = function(node) {
482
- node.removeChildren();
483
- return this._removeChild(node);
484
- };
465
+ module.exports = DragAndDropHandler;
485
466
 
486
- Node.prototype._removeChild = function(node) {
487
- this.children.splice(this.getChildIndex(node), 1);
488
- return this.tree.removeNodeFromIndex(node);
489
- };
467
+ }).call(this);
490
468
 
469
+ },{"./node":6}],2:[function(require,module,exports){
470
+ (function() {
471
+ var ElementsRenderer, NodeElement, html_escape, node_element, util;
491
472
 
492
- /*
493
- Get child index.
494
-
495
- var index = getChildIndex(node);
496
- */
473
+ node_element = require('./node_element');
497
474
 
498
- Node.prototype.getChildIndex = function(node) {
499
- return $.inArray(node, this.children);
500
- };
475
+ NodeElement = node_element.NodeElement;
501
476
 
477
+ util = require('./util');
502
478
 
503
- /*
504
- Does the tree have children?
505
-
506
- if (tree.hasChildren()) {
507
- //
508
- }
509
- */
479
+ html_escape = util.html_escape;
510
480
 
511
- Node.prototype.hasChildren = function() {
512
- return this.children.length !== 0;
513
- };
481
+ ElementsRenderer = (function() {
482
+ function ElementsRenderer(tree_widget) {
483
+ this.tree_widget = tree_widget;
484
+ this.opened_icon_element = this.createButtonElement(tree_widget.options.openedIcon);
485
+ this.closed_icon_element = this.createButtonElement(tree_widget.options.closedIcon);
486
+ }
514
487
 
515
- Node.prototype.isFolder = function() {
516
- return this.hasChildren() || this.load_on_demand;
488
+ ElementsRenderer.prototype.render = function(from_node) {
489
+ if (from_node && from_node.parent) {
490
+ return this.renderFromNode(from_node);
491
+ } else {
492
+ return this.renderFromRoot();
493
+ }
517
494
  };
518
495
 
519
-
520
- /*
521
- Iterate over all the nodes in the tree.
522
-
523
- Calls callback with (node, level).
524
-
525
- The callback must return true to continue the iteration on current node.
526
-
527
- tree.iterate(
528
- function(node, level) {
529
- console.log(node.name);
530
-
531
- // stop iteration after level 2
532
- return (level <= 2);
533
- }
534
- );
535
- */
536
-
537
- Node.prototype.iterate = function(callback) {
538
- var _iterate;
539
- _iterate = (function(_this) {
540
- return function(node, level) {
541
- var child, result, _i, _len, _ref;
542
- if (node.children) {
543
- _ref = node.children;
544
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
545
- child = _ref[_i];
546
- result = callback(child, level);
547
- if (_this.hasChildren() && result) {
548
- _iterate(child, level + 1);
549
- }
550
- }
551
- return null;
552
- }
553
- };
554
- })(this);
555
- _iterate(this, 0);
556
- return null;
496
+ ElementsRenderer.prototype.renderFromRoot = function() {
497
+ var $element;
498
+ $element = this.tree_widget.element;
499
+ $element.empty();
500
+ return this.createDomElements($element[0], this.tree_widget.tree.children, true, true);
557
501
  };
558
502
 
559
-
560
- /*
561
- Move node relative to another node.
562
-
563
- Argument position: Position.BEFORE, Position.AFTER or Position.Inside
564
-
565
- // move node1 after node2
566
- tree.moveNode(node1, node2, Position.AFTER);
567
- */
568
-
569
- Node.prototype.moveNode = function(moved_node, target_node, position) {
570
- if (moved_node.isParentOf(target_node)) {
571
- return;
572
- }
573
- moved_node.parent._removeChild(moved_node);
574
- if (position === Position.AFTER) {
575
- return target_node.parent.addChildAtPosition(moved_node, target_node.parent.getChildIndex(target_node) + 1);
576
- } else if (position === Position.BEFORE) {
577
- return target_node.parent.addChildAtPosition(moved_node, target_node.parent.getChildIndex(target_node));
578
- } else if (position === Position.INSIDE) {
579
- return target_node.addChildAtPosition(moved_node, 0);
503
+ ElementsRenderer.prototype.renderFromNode = function(node) {
504
+ var $previous_li, li, parent_node_element;
505
+ $previous_li = $(node.element);
506
+ parent_node_element = new NodeElement(node.parent, this.tree_widget);
507
+ li = this.createLi(node);
508
+ this.attachNodeData(node, li);
509
+ $previous_li.after(li);
510
+ $previous_li.remove();
511
+ if (node.children) {
512
+ return this.createDomElements(li, node.children, false, false);
580
513
  }
581
514
  };
582
515
 
583
-
584
- /*
585
- Get the tree as data.
586
- */
587
-
588
- Node.prototype.getData = function() {
589
- var getDataFromNodes;
590
- getDataFromNodes = (function(_this) {
591
- return function(nodes) {
592
- var data, k, node, tmp_node, v, _i, _len;
593
- data = [];
594
- for (_i = 0, _len = nodes.length; _i < _len; _i++) {
595
- node = nodes[_i];
596
- tmp_node = {};
597
- for (k in node) {
598
- v = node[k];
599
- if ((k !== 'parent' && k !== 'children' && k !== 'element' && k !== 'tree') && Object.prototype.hasOwnProperty.call(node, k)) {
600
- tmp_node[k] = v;
601
- }
602
- }
603
- if (node.hasChildren()) {
604
- tmp_node.children = getDataFromNodes(node.children);
605
- }
606
- data.push(tmp_node);
607
- }
608
- return data;
609
- };
610
- })(this);
611
- return getDataFromNodes(this.children);
516
+ ElementsRenderer.prototype.createDomElements = function(element, children, is_root_node, is_open) {
517
+ var child, li, ul, _i, _len;
518
+ ul = this.createUl(is_root_node);
519
+ element.appendChild(ul);
520
+ for (_i = 0, _len = children.length; _i < _len; _i++) {
521
+ child = children[_i];
522
+ li = this.createLi(child);
523
+ ul.appendChild(li);
524
+ this.attachNodeData(child, li);
525
+ if (child.hasChildren()) {
526
+ this.createDomElements(li, child.children, false, child.is_open);
527
+ }
528
+ }
529
+ return null;
612
530
  };
613
531
 
614
- Node.prototype.getNodeByName = function(name) {
615
- var result;
616
- result = null;
617
- this.iterate(function(node) {
618
- if (node.name === name) {
619
- result = node;
620
- return false;
621
- } else {
622
- return true;
623
- }
624
- });
625
- return result;
532
+ ElementsRenderer.prototype.attachNodeData = function(node, li) {
533
+ node.element = li;
534
+ return $(li).data('node', node);
626
535
  };
627
536
 
628
- Node.prototype.addAfter = function(node_info) {
629
- var child_index, node;
630
- if (!this.parent) {
631
- return null;
537
+ ElementsRenderer.prototype.createUl = function(is_root_node) {
538
+ var class_string, ul;
539
+ if (is_root_node) {
540
+ class_string = 'jqtree-tree';
632
541
  } else {
633
- node = new this.tree.node_class(node_info);
634
- child_index = this.parent.getChildIndex(this);
635
- this.parent.addChildAtPosition(node, child_index + 1);
636
- return node;
542
+ class_string = '';
637
543
  }
544
+ ul = document.createElement('ul');
545
+ ul.className = "jqtree_common " + class_string;
546
+ return ul;
638
547
  };
639
548
 
640
- Node.prototype.addBefore = function(node_info) {
641
- var child_index, node;
642
- if (!this.parent) {
643
- return null;
549
+ ElementsRenderer.prototype.createLi = function(node) {
550
+ var li;
551
+ if (node.isFolder()) {
552
+ li = this.createFolderLi(node);
644
553
  } else {
645
- node = new this.tree.node_class(node_info);
646
- child_index = this.parent.getChildIndex(this);
647
- this.parent.addChildAtPosition(node, child_index);
648
- return node;
554
+ li = this.createNodeLi(node);
555
+ }
556
+ if (this.tree_widget.options.onCreateLi) {
557
+ this.tree_widget.options.onCreateLi(node, $(li));
649
558
  }
559
+ return li;
650
560
  };
651
561
 
652
- Node.prototype.addParent = function(node_info) {
653
- var child, new_parent, original_parent, _i, _len, _ref;
654
- if (!this.parent) {
655
- return null;
562
+ ElementsRenderer.prototype.createFolderLi = function(node) {
563
+ var button_classes, button_link, div, escaped_name, folder_classes, icon_element, li, title_span;
564
+ button_classes = this.getButtonClasses(node);
565
+ folder_classes = this.getFolderClasses(node);
566
+ escaped_name = this.escapeIfNecessary(node.name);
567
+ if (node.is_open) {
568
+ icon_element = this.opened_icon_element;
656
569
  } else {
657
- new_parent = new this.tree.node_class(node_info);
658
- new_parent._setParent(this.tree);
659
- original_parent = this.parent;
660
- _ref = original_parent.children;
661
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
662
- child = _ref[_i];
663
- new_parent.addChild(child);
664
- }
665
- original_parent.children = [];
666
- original_parent.addChild(new_parent);
667
- return new_parent;
570
+ icon_element = this.closed_icon_element;
668
571
  }
572
+ li = document.createElement('li');
573
+ li.className = "jqtree_common " + folder_classes;
574
+ div = document.createElement('div');
575
+ div.className = "jqtree-element jqtree_common";
576
+ li.appendChild(div);
577
+ button_link = document.createElement('a');
578
+ button_link.className = "jqtree_common " + button_classes;
579
+ button_link.appendChild(icon_element.cloneNode(false));
580
+ div.appendChild(button_link);
581
+ title_span = document.createElement('span');
582
+ title_span.className = "jqtree_common jqtree-title jqtree-title-folder";
583
+ div.appendChild(title_span);
584
+ title_span.innerHTML = escaped_name;
585
+ return li;
669
586
  };
670
587
 
671
- Node.prototype.remove = function() {
672
- if (this.parent) {
673
- this.parent.removeChild(this);
674
- return this.parent = null;
588
+ ElementsRenderer.prototype.createNodeLi = function(node) {
589
+ var class_string, div, escaped_name, li, li_classes, title_span;
590
+ li_classes = ['jqtree_common'];
591
+ if (this.tree_widget.select_node_handler && this.tree_widget.select_node_handler.isNodeSelected(node)) {
592
+ li_classes.push('jqtree-selected');
675
593
  }
594
+ class_string = li_classes.join(' ');
595
+ escaped_name = this.escapeIfNecessary(node.name);
596
+ li = document.createElement('li');
597
+ li.className = class_string;
598
+ div = document.createElement('div');
599
+ div.className = "jqtree-element jqtree_common";
600
+ li.appendChild(div);
601
+ title_span = document.createElement('span');
602
+ title_span.className = "jqtree-title jqtree_common";
603
+ title_span.innerHTML = escaped_name;
604
+ div.appendChild(title_span);
605
+ return li;
676
606
  };
677
607
 
678
- Node.prototype.append = function(node_info) {
679
- var node;
680
- node = new this.tree.node_class(node_info);
681
- this.addChild(node);
682
- return node;
683
- };
684
-
685
- Node.prototype.prepend = function(node_info) {
686
- var node;
687
- node = new this.tree.node_class(node_info);
688
- this.addChildAtPosition(node, 0);
689
- return node;
608
+ ElementsRenderer.prototype.getButtonClasses = function(node) {
609
+ var classes;
610
+ classes = ['jqtree-toggler'];
611
+ if (!node.is_open) {
612
+ classes.push('jqtree-closed');
613
+ }
614
+ return classes.join(' ');
690
615
  };
691
616
 
692
- Node.prototype.isParentOf = function(node) {
693
- var parent;
694
- parent = node.parent;
695
- while (parent) {
696
- if (parent === this) {
697
- return true;
698
- }
699
- parent = parent.parent;
617
+ ElementsRenderer.prototype.getFolderClasses = function(node) {
618
+ var classes;
619
+ classes = ['jqtree-folder'];
620
+ if (!node.is_open) {
621
+ classes.push('jqtree-closed');
700
622
  }
701
- return false;
623
+ if (this.tree_widget.select_node_handler && this.tree_widget.select_node_handler.isNodeSelected(node)) {
624
+ classes.push('jqtree-selected');
625
+ }
626
+ if (node.is_loading) {
627
+ classes.push('jqtree-loading');
628
+ }
629
+ return classes.join(' ');
702
630
  };
703
631
 
704
- Node.prototype.getLevel = function() {
705
- var level, node;
706
- level = 0;
707
- node = this;
708
- while (node.parent) {
709
- level += 1;
710
- node = node.parent;
711
- }
712
- return level;
713
- };
714
-
715
- Node.prototype.getNodeById = function(node_id) {
716
- return this.id_mapping[node_id];
717
- };
718
-
719
- Node.prototype.addNodeToIndex = function(node) {
720
- if (node.id != null) {
721
- return this.id_mapping[node.id] = node;
722
- }
723
- };
724
-
725
- Node.prototype.removeNodeFromIndex = function(node) {
726
- if (node.id != null) {
727
- return delete this.id_mapping[node.id];
728
- }
729
- };
730
-
731
- Node.prototype.removeChildren = function() {
732
- this.iterate((function(_this) {
733
- return function(child) {
734
- _this.tree.removeNodeFromIndex(child);
735
- return true;
736
- };
737
- })(this));
738
- return this.children = [];
739
- };
740
-
741
- Node.prototype.getPreviousSibling = function() {
742
- var previous_index;
743
- if (!this.parent) {
744
- return null;
632
+ ElementsRenderer.prototype.escapeIfNecessary = function(value) {
633
+ if (this.tree_widget.options.autoEscape) {
634
+ return html_escape(value);
745
635
  } else {
746
- previous_index = this.parent.getChildIndex(this) - 1;
747
- if (previous_index >= 0) {
748
- return this.parent.children[previous_index];
749
- } else {
750
- return null;
751
- }
636
+ return value;
752
637
  }
753
638
  };
754
639
 
755
- Node.prototype.getNextSibling = function() {
756
- var next_index;
757
- if (!this.parent) {
758
- return null;
640
+ ElementsRenderer.prototype.createButtonElement = function(value) {
641
+ var div;
642
+ if (typeof value === 'string') {
643
+ div = document.createElement('div');
644
+ div.innerHTML = value;
645
+ return document.createTextNode(div.innerHTML);
759
646
  } else {
760
- next_index = this.parent.getChildIndex(this) + 1;
761
- if (next_index < this.parent.children.length) {
762
- return this.parent.children[next_index];
763
- } else {
764
- return null;
765
- }
647
+ return $(value)[0];
766
648
  }
767
649
  };
768
650
 
769
- Node.prototype.getNodesByProperty = function(key, value) {
770
- return this.filter(function(node) {
771
- return node[key] === value;
772
- });
773
- };
651
+ return ElementsRenderer;
774
652
 
775
- Node.prototype.filter = function(f) {
776
- var result;
777
- result = [];
778
- this.iterate(function(node) {
779
- if (f(node)) {
780
- result.push(node);
781
- }
782
- return true;
783
- });
784
- return result;
785
- };
653
+ })();
786
654
 
787
- return Node;
655
+ module.exports = ElementsRenderer;
788
656
 
789
- })();
657
+ }).call(this);
790
658
 
791
- this.Tree.Node = Node;
659
+ },{"./node_element":7,"./util":12}],3:[function(require,module,exports){
792
660
 
793
- ElementsRenderer = (function() {
794
- function ElementsRenderer(tree_widget) {
795
- this.tree_widget = tree_widget;
796
- this.opened_icon_element = this.createButtonElement(tree_widget.options.openedIcon);
797
- this.closed_icon_element = this.createButtonElement(tree_widget.options.closedIcon);
798
- }
661
+ /*
662
+ Copyright 2013 Marco Braak
799
663
 
800
- ElementsRenderer.prototype.render = function(from_node) {
801
- if (from_node && from_node.parent) {
802
- return this.renderFromNode(from_node);
803
- } else {
804
- return this.renderFromRoot();
805
- }
806
- };
664
+ Licensed under the Apache License, Version 2.0 (the "License");
665
+ you may not use this file except in compliance with the License.
666
+ You may obtain a copy of the License at
807
667
 
808
- ElementsRenderer.prototype.renderNode = function(node) {
809
- var li, parent_node_element, previous_node;
810
- $(node.element).remove();
811
- parent_node_element = new NodeElement(node.parent, this.tree_widget);
812
- li = this.createLi(node);
813
- this.attachNodeData(node, li);
814
- previous_node = node.getPreviousSibling();
815
- if (previous_node) {
816
- $(previous_node.element).after(li);
817
- } else {
818
- parent_node_element.getUl().prepend(li);
819
- }
820
- if (node.children) {
821
- return this.renderFromNode(node);
822
- }
823
- };
668
+ http://www.apache.org/licenses/LICENSE-2.0
824
669
 
825
- ElementsRenderer.prototype.renderFromRoot = function() {
826
- var $element;
827
- $element = this.tree_widget.element;
828
- $element.empty();
829
- return this.createDomElements($element[0], this.tree_widget.tree.children, true, true);
830
- };
670
+ Unless required by applicable law or agreed to in writing, software
671
+ distributed under the License is distributed on an "AS IS" BASIS,
672
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
673
+ See the License for the specific language governing permissions and
674
+ limitations under the License.
675
+ */
831
676
 
832
- ElementsRenderer.prototype.renderFromNode = function(from_node) {
833
- var node_element;
834
- node_element = this.tree_widget._getNodeElementForNode(from_node);
835
- node_element.getUl().remove();
836
- return this.createDomElements(node_element.$element[0], from_node.children, false, false);
837
- };
677
+ (function() {
678
+ var DragAndDropHandler, ElementsRenderer, FolderElement, JqTreeWidget, KeyHandler, MouseWidget, Node, NodeElement, Position, SaveStateHandler, ScrollHandler, SelectNodeHandler, SimpleWidget, node, node_element, __version__,
679
+ __hasProp = {}.hasOwnProperty,
680
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
838
681
 
839
- ElementsRenderer.prototype.createDomElements = function(element, children, is_root_node, is_open) {
840
- var child, li, ul, _i, _len;
841
- ul = this.createUl(is_root_node);
842
- element.appendChild(ul);
843
- for (_i = 0, _len = children.length; _i < _len; _i++) {
844
- child = children[_i];
845
- li = this.createLi(child);
846
- ul.appendChild(li);
847
- this.attachNodeData(child, li);
848
- if (child.hasChildren()) {
849
- this.createDomElements(li, child.children, false, child.is_open);
850
- }
851
- }
852
- return null;
853
- };
682
+ __version__ = require('./version');
854
683
 
855
- ElementsRenderer.prototype.attachNodeData = function(node, li) {
856
- node.element = li;
857
- return $(li).data('node', node);
858
- };
684
+ DragAndDropHandler = require('./drag_and_drop_handler');
859
685
 
860
- ElementsRenderer.prototype.createUl = function(is_root_node) {
861
- var class_string, ul;
862
- if (is_root_node) {
863
- class_string = 'jqtree-tree';
864
- } else {
865
- class_string = '';
866
- }
867
- ul = document.createElement('ul');
868
- ul.className = "jqtree_common " + class_string;
869
- return ul;
870
- };
686
+ ElementsRenderer = require('./elements_renderer');
871
687
 
872
- ElementsRenderer.prototype.createLi = function(node) {
873
- var li;
874
- if (node.isFolder()) {
875
- li = this.createFolderLi(node);
876
- } else {
877
- li = this.createNodeLi(node);
878
- }
879
- if (this.tree_widget.options.onCreateLi) {
880
- this.tree_widget.options.onCreateLi(node, $(li));
881
- }
882
- return li;
883
- };
688
+ KeyHandler = require('./key_handler');
884
689
 
885
- ElementsRenderer.prototype.createFolderLi = function(node) {
886
- var button_classes, button_link, div, escaped_name, folder_classes, icon_element, li, title_span;
887
- button_classes = this.getButtonClasses(node);
888
- folder_classes = this.getFolderClasses(node);
889
- escaped_name = this.escapeIfNecessary(node.name);
890
- if (node.is_open) {
891
- icon_element = this.opened_icon_element;
892
- } else {
893
- icon_element = this.closed_icon_element;
894
- }
895
- li = document.createElement('li');
896
- li.className = "jqtree_common " + folder_classes;
897
- div = document.createElement('div');
898
- div.className = "jqtree-element jqtree_common";
899
- li.appendChild(div);
900
- button_link = document.createElement('a');
901
- button_link.className = "jqtree_common " + button_classes;
902
- button_link.appendChild(icon_element.cloneNode());
903
- div.appendChild(button_link);
904
- title_span = document.createElement('span');
905
- title_span.className = "jqtree_common jqtree-title jqtree-title-folder";
906
- div.appendChild(title_span);
907
- title_span.innerHTML = escaped_name;
908
- return li;
909
- };
690
+ MouseWidget = require('./mouse.widget');
910
691
 
911
- ElementsRenderer.prototype.createNodeLi = function(node) {
912
- var class_string, div, escaped_name, li, li_classes, title_span;
913
- li_classes = ['jqtree_common'];
914
- if (this.tree_widget.select_node_handler && this.tree_widget.select_node_handler.isNodeSelected(node)) {
915
- li_classes.push('jqtree-selected');
916
- }
917
- class_string = li_classes.join(' ');
918
- escaped_name = this.escapeIfNecessary(node.name);
919
- li = document.createElement('li');
920
- li.className = class_string;
921
- div = document.createElement('div');
922
- div.className = "jqtree-element jqtree_common";
923
- li.appendChild(div);
924
- title_span = document.createElement('span');
925
- title_span.className = "jqtree-title jqtree_common";
926
- title_span.innerHTML = escaped_name;
927
- div.appendChild(title_span);
928
- return li;
929
- };
692
+ SaveStateHandler = require('./save_state_handler');
930
693
 
931
- ElementsRenderer.prototype.getButtonClasses = function(node) {
932
- var classes;
933
- classes = ['jqtree-toggler'];
934
- if (!node.is_open) {
935
- classes.push('jqtree-closed');
936
- }
937
- return classes.join(' ');
938
- };
694
+ ScrollHandler = require('./scroll_handler');
939
695
 
940
- ElementsRenderer.prototype.getFolderClasses = function(node) {
941
- var classes;
942
- classes = ['jqtree-folder'];
943
- if (!node.is_open) {
944
- classes.push('jqtree-closed');
945
- }
946
- if (this.tree_widget.select_node_handler && this.tree_widget.select_node_handler.isNodeSelected(node)) {
947
- classes.push('jqtree-selected');
948
- }
949
- return classes.join(' ');
950
- };
696
+ SelectNodeHandler = require('./select_node_handler');
951
697
 
952
- ElementsRenderer.prototype.escapeIfNecessary = function(value) {
953
- if (this.tree_widget.options.autoEscape) {
954
- return html_escape(value);
955
- } else {
956
- return value;
957
- }
958
- };
698
+ SimpleWidget = require('./simple.widget');
959
699
 
960
- ElementsRenderer.prototype.createButtonElement = function(value) {
961
- var div;
962
- if (typeof value === 'string') {
963
- div = document.createElement('div');
964
- div.innerHTML = value;
965
- return document.createTextNode(div.innerHTML);
966
- } else {
967
- return $(value)[0];
968
- }
969
- };
700
+ node = require('./node');
970
701
 
971
- return ElementsRenderer;
702
+ Node = node.Node;
972
703
 
973
- })();
704
+ Position = node.Position;
705
+
706
+ node_element = require('./node_element');
974
707
 
708
+ NodeElement = node_element.NodeElement;
975
709
 
976
- /*
977
- Copyright 2013 Marco Braak
978
-
979
- Licensed under the Apache License, Version 2.0 (the "License");
980
- you may not use this file except in compliance with the License.
981
- You may obtain a copy of the License at
982
-
983
- http://www.apache.org/licenses/LICENSE-2.0
984
-
985
- Unless required by applicable law or agreed to in writing, software
986
- distributed under the License is distributed on an "AS IS" BASIS,
987
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
988
- See the License for the specific language governing permissions and
989
- limitations under the License.
990
- */
710
+ FolderElement = node_element.FolderElement;
991
711
 
992
712
  JqTreeWidget = (function(_super) {
993
713
  __extends(JqTreeWidget, _super);
@@ -1023,7 +743,10 @@ limitations under the License.
1023
743
 
1024
744
  JqTreeWidget.prototype.toggle = function(node, slide) {
1025
745
  if (slide == null) {
1026
- slide = true;
746
+ slide = null;
747
+ }
748
+ if (slide === null) {
749
+ slide = this.options.slide;
1027
750
  }
1028
751
  if (node.is_open) {
1029
752
  return this.closeNode(node, slide);
@@ -1103,7 +826,11 @@ limitations under the License.
1103
826
  };
1104
827
 
1105
828
  JqTreeWidget.prototype.getSelectedNode = function() {
1106
- return this.select_node_handler.getSelectedNode();
829
+ if (this.select_node_handler) {
830
+ return this.select_node_handler.getSelectedNode();
831
+ } else {
832
+ return null;
833
+ }
1107
834
  };
1108
835
 
1109
836
  JqTreeWidget.prototype.toJson = function() {
@@ -1132,35 +859,29 @@ limitations under the License.
1132
859
  $el = null;
1133
860
  addLoadingClass = (function(_this) {
1134
861
  return function() {
1135
- var folder_element;
1136
- if (!parent_node) {
1137
- $el = _this.element;
862
+ if (parent_node) {
863
+ $el = $(parent_node.element);
1138
864
  } else {
1139
- folder_element = new FolderElement(parent_node, _this);
1140
- $el = folder_element.getLi();
865
+ $el = _this.element;
1141
866
  }
1142
867
  return $el.addClass('jqtree-loading');
1143
868
  };
1144
869
  })(this);
1145
- removeLoadingClass = (function(_this) {
1146
- return function() {
1147
- if ($el) {
1148
- return $el.removeClass('jqtree-loading');
1149
- }
1150
- };
1151
- })(this);
1152
- parseUrlInfo = (function(_this) {
1153
- return function() {
1154
- if ($.type(url_info) === 'string') {
1155
- url_info = {
1156
- url: url_info
1157
- };
1158
- }
1159
- if (!url_info.method) {
1160
- return url_info.method = 'get';
1161
- }
1162
- };
1163
- })(this);
870
+ removeLoadingClass = function() {
871
+ if ($el) {
872
+ return $el.removeClass('jqtree-loading');
873
+ }
874
+ };
875
+ parseUrlInfo = function() {
876
+ if ($.type(url_info) === 'string') {
877
+ url_info = {
878
+ url: url_info
879
+ };
880
+ }
881
+ if (!url_info.method) {
882
+ return url_info.method = 'get';
883
+ }
884
+ };
1164
885
  handeLoadData = (function(_this) {
1165
886
  return function(data) {
1166
887
  removeLoadingClass();
@@ -1204,7 +925,7 @@ limitations under the License.
1204
925
  url_info = this._getDataUrlInfo(parent_node);
1205
926
  }
1206
927
  addLoadingClass();
1207
- if (url_info === false || url_info === null) {
928
+ if (!url_info) {
1208
929
  removeLoadingClass();
1209
930
  } else if ($.isArray(url_info)) {
1210
931
  handeLoadData(url_info);
@@ -1214,7 +935,31 @@ limitations under the License.
1214
935
  };
1215
936
 
1216
937
  JqTreeWidget.prototype._loadData = function(data, parent_node) {
1217
- var n, selected_nodes_under_parent, _i, _len;
938
+ var deselectNodes, loadSubtree;
939
+ if (parent_node == null) {
940
+ parent_node = null;
941
+ }
942
+ deselectNodes = (function(_this) {
943
+ return function() {
944
+ var n, selected_nodes_under_parent, _i, _len;
945
+ if (_this.select_node_handler) {
946
+ selected_nodes_under_parent = _this.select_node_handler.getSelectedNodesUnder(parent_node);
947
+ for (_i = 0, _len = selected_nodes_under_parent.length; _i < _len; _i++) {
948
+ n = selected_nodes_under_parent[_i];
949
+ _this.select_node_handler.removeFromSelection(n);
950
+ }
951
+ }
952
+ return null;
953
+ };
954
+ })(this);
955
+ loadSubtree = (function(_this) {
956
+ return function() {
957
+ parent_node.loadFromData(data);
958
+ parent_node.load_on_demand = false;
959
+ parent_node.is_loading = false;
960
+ return _this._refreshElements(parent_node);
961
+ };
962
+ })(this);
1218
963
  if (!data) {
1219
964
  return;
1220
965
  }
@@ -1224,14 +969,8 @@ limitations under the License.
1224
969
  if (!parent_node) {
1225
970
  this._initTree(data);
1226
971
  } else {
1227
- selected_nodes_under_parent = this.select_node_handler.getSelectedNodesUnder(parent_node);
1228
- for (_i = 0, _len = selected_nodes_under_parent.length; _i < _len; _i++) {
1229
- n = selected_nodes_under_parent[_i];
1230
- this.select_node_handler.removeFromSelection(n);
1231
- }
1232
- parent_node.loadFromData(data);
1233
- parent_node.load_on_demand = false;
1234
- this._refreshElements(parent_node.parent);
972
+ deselectNodes();
973
+ loadSubtree();
1235
974
  }
1236
975
  if (this.isDragging()) {
1237
976
  return this.dnd_handler.refresh();
@@ -1246,9 +985,16 @@ limitations under the License.
1246
985
  return this.tree.getNodeByName(name);
1247
986
  };
1248
987
 
988
+ JqTreeWidget.prototype.getNodesByProperty = function(key, value) {
989
+ return this.tree.getNodesByProperty(key, value);
990
+ };
991
+
1249
992
  JqTreeWidget.prototype.openNode = function(node, slide) {
1250
993
  if (slide == null) {
1251
- slide = true;
994
+ slide = null;
995
+ }
996
+ if (slide === null) {
997
+ slide = this.options.slide;
1252
998
  }
1253
999
  return this._openNode(node, slide);
1254
1000
  };
@@ -1270,7 +1016,7 @@ limitations under the License.
1270
1016
  return this._loadFolderOnDemand(node, slide, on_finished);
1271
1017
  } else {
1272
1018
  parent = node.parent;
1273
- while (parent && !parent.is_open) {
1019
+ while (parent) {
1274
1020
  if (parent.parent) {
1275
1021
  doOpenNode(parent, false, null);
1276
1022
  }
@@ -1286,6 +1032,7 @@ limitations under the License.
1286
1032
  if (slide == null) {
1287
1033
  slide = true;
1288
1034
  }
1035
+ node.is_loading = true;
1289
1036
  return this._loadDataFromUrl(null, node, (function(_this) {
1290
1037
  return function() {
1291
1038
  return _this._openNode(node, slide, on_finished);
@@ -1295,7 +1042,10 @@ limitations under the License.
1295
1042
 
1296
1043
  JqTreeWidget.prototype.closeNode = function(node, slide) {
1297
1044
  if (slide == null) {
1298
- slide = true;
1045
+ slide = null;
1046
+ }
1047
+ if (slide === null) {
1048
+ slide = this.options.slide;
1299
1049
  }
1300
1050
  if (node.isFolder()) {
1301
1051
  new FolderElement(node, this).close(slide);
@@ -1342,27 +1092,18 @@ limitations under the License.
1342
1092
  if (parent) {
1343
1093
  this.select_node_handler.removeFromSelection(node, true);
1344
1094
  node.remove();
1345
- return this._refreshElements(parent.parent);
1095
+ return this._refreshElements(parent);
1346
1096
  }
1347
1097
  };
1348
1098
 
1349
1099
  JqTreeWidget.prototype.appendNode = function(new_node_info, parent_node) {
1350
- var is_already_folder_node, node;
1351
- if (!parent_node) {
1352
- parent_node = this.tree;
1353
- }
1354
- is_already_folder_node = parent_node.isFolder();
1100
+ parent_node = parent_node || this.tree;
1355
1101
  node = parent_node.append(new_node_info);
1356
- if (is_already_folder_node) {
1357
- this._refreshElements(parent_node);
1358
- } else {
1359
- this._refreshElements(parent_node.parent);
1360
- }
1102
+ this._refreshElements(parent_node);
1361
1103
  return node;
1362
1104
  };
1363
1105
 
1364
1106
  JqTreeWidget.prototype.prependNode = function(new_node_info, parent_node) {
1365
- var node;
1366
1107
  if (!parent_node) {
1367
1108
  parent_node = this.tree;
1368
1109
  }
@@ -1381,7 +1122,7 @@ limitations under the License.
1381
1122
  if (id_is_changed) {
1382
1123
  this.tree.addNodeToIndex(node);
1383
1124
  }
1384
- this.renderer.renderNode(node);
1125
+ this.renderer.renderFromNode(node);
1385
1126
  return this._selectCurrentNode();
1386
1127
  };
1387
1128
 
@@ -1430,7 +1171,7 @@ limitations under the License.
1430
1171
  };
1431
1172
 
1432
1173
  JqTreeWidget.prototype.setState = function(state) {
1433
- this.save_state_handler.setState(state);
1174
+ this.save_state_handler.setInitialState(state);
1434
1175
  return this._refreshElements();
1435
1176
  };
1436
1177
 
@@ -1438,29 +1179,45 @@ limitations under the License.
1438
1179
  return this.options[option] = value;
1439
1180
  };
1440
1181
 
1182
+ JqTreeWidget.prototype.moveDown = function() {
1183
+ if (this.key_handler) {
1184
+ return this.key_handler.moveDown();
1185
+ }
1186
+ };
1187
+
1188
+ JqTreeWidget.prototype.moveUp = function() {
1189
+ if (this.key_handler) {
1190
+ return this.key_handler.moveUp();
1191
+ }
1192
+ };
1193
+
1194
+ JqTreeWidget.prototype.getVersion = function() {
1195
+ return __version__;
1196
+ };
1197
+
1441
1198
  JqTreeWidget.prototype._init = function() {
1442
1199
  JqTreeWidget.__super__._init.call(this);
1443
1200
  this.element = this.$el;
1444
1201
  this.mouse_delay = 300;
1445
1202
  this.is_initialized = false;
1446
1203
  this.renderer = new ElementsRenderer(this);
1447
- if (typeof SaveStateHandler !== "undefined" && SaveStateHandler !== null) {
1204
+ if (SaveStateHandler != null) {
1448
1205
  this.save_state_handler = new SaveStateHandler(this);
1449
1206
  } else {
1450
1207
  this.options.saveState = false;
1451
1208
  }
1452
- if (typeof SelectNodeHandler !== "undefined" && SelectNodeHandler !== null) {
1209
+ if (SelectNodeHandler != null) {
1453
1210
  this.select_node_handler = new SelectNodeHandler(this);
1454
1211
  }
1455
- if (typeof DragAndDropHandler !== "undefined" && DragAndDropHandler !== null) {
1212
+ if (DragAndDropHandler != null) {
1456
1213
  this.dnd_handler = new DragAndDropHandler(this);
1457
1214
  } else {
1458
1215
  this.options.dragAndDrop = false;
1459
1216
  }
1460
- if (typeof ScrollHandler !== "undefined" && ScrollHandler !== null) {
1217
+ if (ScrollHandler != null) {
1461
1218
  this.scroll_handler = new ScrollHandler(this);
1462
1219
  }
1463
- if ((typeof KeyHandler !== "undefined" && KeyHandler !== null) && (typeof SelectNodeHandler !== "undefined" && SelectNodeHandler !== null)) {
1220
+ if ((KeyHandler != null) && (SelectNodeHandler != null)) {
1464
1221
  this.key_handler = new KeyHandler(this);
1465
1222
  }
1466
1223
  this._initData();
@@ -1474,7 +1231,9 @@ limitations under the License.
1474
1231
  JqTreeWidget.prototype._deinit = function() {
1475
1232
  this.element.empty();
1476
1233
  this.element.unbind();
1477
- this.key_handler.deinit();
1234
+ if (this.key_handler) {
1235
+ this.key_handler.deinit();
1236
+ }
1478
1237
  this.tree = null;
1479
1238
  return JqTreeWidget.__super__._deinit.call(this);
1480
1239
  };
@@ -1531,41 +1290,131 @@ limitations under the License.
1531
1290
  };
1532
1291
 
1533
1292
  JqTreeWidget.prototype._initTree = function(data) {
1293
+ var must_load_on_demand;
1534
1294
  this.tree = new this.options.nodeClass(null, true, this.options.nodeClass);
1535
1295
  if (this.select_node_handler) {
1536
1296
  this.select_node_handler.clear();
1537
1297
  }
1538
1298
  this.tree.loadFromData(data);
1539
- this._openNodes();
1299
+ must_load_on_demand = this._setInitialState();
1540
1300
  this._refreshElements();
1301
+ if (must_load_on_demand) {
1302
+ this._setInitialStateOnDemand();
1303
+ }
1541
1304
  if (!this.is_initialized) {
1542
1305
  this.is_initialized = true;
1543
1306
  return this._triggerEvent('tree.init');
1544
1307
  }
1545
1308
  };
1546
1309
 
1547
- JqTreeWidget.prototype._openNodes = function() {
1548
- var max_level;
1549
- if (this.options.saveState) {
1550
- if (this.save_state_handler.restoreState()) {
1551
- return;
1552
- }
1310
+ JqTreeWidget.prototype._setInitialState = function() {
1311
+ var autoOpenNodes, is_restored, must_load_on_demand, restoreState, _ref;
1312
+ restoreState = (function(_this) {
1313
+ return function() {
1314
+ var must_load_on_demand, state;
1315
+ if (!(_this.options.saveState && _this.save_state_handler)) {
1316
+ return [false, false];
1317
+ } else {
1318
+ state = _this.save_state_handler.getStateFromStorage();
1319
+ if (!state) {
1320
+ return [false, false];
1321
+ } else {
1322
+ must_load_on_demand = _this.save_state_handler.setInitialState(state);
1323
+ return [true, must_load_on_demand];
1324
+ }
1325
+ }
1326
+ };
1327
+ })(this);
1328
+ autoOpenNodes = (function(_this) {
1329
+ return function() {
1330
+ var max_level, must_load_on_demand;
1331
+ if (_this.options.autoOpen === false) {
1332
+ return false;
1333
+ }
1334
+ max_level = _this._getAutoOpenMaxLevel();
1335
+ must_load_on_demand = false;
1336
+ _this.tree.iterate(function(node, level) {
1337
+ if (node.load_on_demand) {
1338
+ must_load_on_demand = true;
1339
+ return false;
1340
+ } else if (!node.hasChildren()) {
1341
+ return false;
1342
+ } else {
1343
+ node.is_open = true;
1344
+ return level !== max_level;
1345
+ }
1346
+ });
1347
+ return must_load_on_demand;
1348
+ };
1349
+ })(this);
1350
+ _ref = restoreState(), is_restored = _ref[0], must_load_on_demand = _ref[1];
1351
+ if (!is_restored) {
1352
+ must_load_on_demand = autoOpenNodes();
1553
1353
  }
1554
- if (this.options.autoOpen === false) {
1555
- return;
1556
- } else if (this.options.autoOpen === true) {
1557
- max_level = -1;
1354
+ return must_load_on_demand;
1355
+ };
1356
+
1357
+ JqTreeWidget.prototype._setInitialStateOnDemand = function() {
1358
+ var autoOpenNodes, restoreState;
1359
+ restoreState = (function(_this) {
1360
+ return function() {
1361
+ var state;
1362
+ if (!(_this.options.saveState && _this.save_state_handler)) {
1363
+ return false;
1364
+ } else {
1365
+ state = _this.save_state_handler.getStateFromStorage();
1366
+ if (!state) {
1367
+ return false;
1368
+ } else {
1369
+ _this.save_state_handler.setInitialStateOnDemand(state);
1370
+ return true;
1371
+ }
1372
+ }
1373
+ };
1374
+ })(this);
1375
+ autoOpenNodes = (function(_this) {
1376
+ return function() {
1377
+ var loadAndOpenNode, loading_ids, max_level, openNodes;
1378
+ max_level = _this._getAutoOpenMaxLevel();
1379
+ loading_ids = [];
1380
+ loadAndOpenNode = function(node) {
1381
+ return _this._openNode(node, false, openNodes);
1382
+ };
1383
+ openNodes = function() {
1384
+ return _this.tree.iterate(function(node, level) {
1385
+ if (node.load_on_demand) {
1386
+ if (!node.is_loading) {
1387
+ loadAndOpenNode(node);
1388
+ }
1389
+ return false;
1390
+ } else {
1391
+ _this._openNode(node, false);
1392
+ return level !== max_level;
1393
+ }
1394
+ });
1395
+ };
1396
+ return openNodes();
1397
+ };
1398
+ })(this);
1399
+ if (!restoreState()) {
1400
+ return autoOpenNodes();
1401
+ }
1402
+ };
1403
+
1404
+ JqTreeWidget.prototype._getAutoOpenMaxLevel = function() {
1405
+ if (this.options.autoOpen === true) {
1406
+ return -1;
1558
1407
  } else {
1559
- max_level = parseInt(this.options.autoOpen);
1408
+ return parseInt(this.options.autoOpen);
1560
1409
  }
1561
- return this.tree.iterate(function(node, level) {
1562
- if (node.hasChildren()) {
1563
- node.is_open = true;
1564
- }
1565
- return level !== max_level;
1566
- });
1567
1410
  };
1568
1411
 
1412
+
1413
+ /*
1414
+ Redraw the tree or part of the tree.
1415
+ * from_node: redraw this subtree
1416
+ */
1417
+
1569
1418
  JqTreeWidget.prototype._refreshElements = function(from_node) {
1570
1419
  if (from_node == null) {
1571
1420
  from_node = null;
@@ -1575,7 +1424,7 @@ limitations under the License.
1575
1424
  };
1576
1425
 
1577
1426
  JqTreeWidget.prototype._click = function(e) {
1578
- var click_target, event, node;
1427
+ var click_target, event;
1579
1428
  click_target = this._getClickTarget(e.target);
1580
1429
  if (click_target) {
1581
1430
  if (click_target.type === 'button') {
@@ -1607,7 +1456,7 @@ limitations under the License.
1607
1456
  };
1608
1457
 
1609
1458
  JqTreeWidget.prototype._getClickTarget = function(element) {
1610
- var $button, $el, $target, node;
1459
+ var $button, $el, $target;
1611
1460
  $target = $(element);
1612
1461
  $button = $target.closest('.jqtree-toggler');
1613
1462
  if ($button.length) {
@@ -1652,7 +1501,6 @@ limitations under the License.
1652
1501
  };
1653
1502
 
1654
1503
  JqTreeWidget.prototype._getNodeElement = function($element) {
1655
- var node;
1656
1504
  node = this._getNode($element);
1657
1505
  if (node) {
1658
1506
  return this._getNodeElementForNode(node);
@@ -1662,7 +1510,7 @@ limitations under the License.
1662
1510
  };
1663
1511
 
1664
1512
  JqTreeWidget.prototype._contextmenu = function(e) {
1665
- var $div, node;
1513
+ var $div;
1666
1514
  $div = $(e.target).closest('ul.jqtree-tree .jqtree-element');
1667
1515
  if ($div.length) {
1668
1516
  node = this._getNode($div);
@@ -1736,7 +1584,6 @@ limitations under the License.
1736
1584
  };
1737
1585
 
1738
1586
  JqTreeWidget.prototype._selectCurrentNode = function() {
1739
- var node, node_element;
1740
1587
  node = this.getSelectedNode();
1741
1588
  if (node) {
1742
1589
  node_element = this._getNodeElementForNode(node);
@@ -1747,7 +1594,6 @@ limitations under the License.
1747
1594
  };
1748
1595
 
1749
1596
  JqTreeWidget.prototype._deselectCurrentNode = function() {
1750
- var node;
1751
1597
  node = this.getSelectedNode();
1752
1598
  if (node) {
1753
1599
  return this.removeFromSelection(node);
@@ -1760,1287 +1606,1783 @@ limitations under the License.
1760
1606
 
1761
1607
  SimpleWidget.register(JqTreeWidget, 'tree');
1762
1608
 
1763
- NodeElement = (function() {
1764
- function NodeElement(node, tree_widget) {
1765
- this.init(node, tree_widget);
1766
- }
1609
+ }).call(this);
1767
1610
 
1768
- NodeElement.prototype.init = function(node, tree_widget) {
1769
- this.node = node;
1611
+ },{"./drag_and_drop_handler":1,"./elements_renderer":2,"./key_handler":4,"./mouse.widget":5,"./node":6,"./node_element":7,"./save_state_handler":8,"./scroll_handler":9,"./select_node_handler":10,"./simple.widget":11,"./version":13}],4:[function(require,module,exports){
1612
+ (function() {
1613
+ var KeyHandler,
1614
+ __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
1615
+
1616
+ KeyHandler = (function() {
1617
+ var DOWN, LEFT, RIGHT, UP;
1618
+
1619
+ LEFT = 37;
1620
+
1621
+ UP = 38;
1622
+
1623
+ RIGHT = 39;
1624
+
1625
+ DOWN = 40;
1626
+
1627
+ function KeyHandler(tree_widget) {
1628
+ this.selectNode = __bind(this.selectNode, this);
1770
1629
  this.tree_widget = tree_widget;
1771
- if (!node.element) {
1772
- node.element = this.tree_widget.element;
1630
+ if (tree_widget.options.keyboardSupport) {
1631
+ $(document).bind('keydown.jqtree', $.proxy(this.handleKeyDown, this));
1773
1632
  }
1774
- return this.$element = $(node.element);
1775
- };
1776
-
1777
- NodeElement.prototype.getUl = function() {
1778
- return this.$element.children('ul:first');
1779
- };
1633
+ }
1780
1634
 
1781
- NodeElement.prototype.getSpan = function() {
1782
- return this.$element.children('.jqtree-element').find('span.jqtree-title');
1635
+ KeyHandler.prototype.deinit = function() {
1636
+ return $(document).unbind('keydown.jqtree');
1783
1637
  };
1784
1638
 
1785
- NodeElement.prototype.getLi = function() {
1786
- return this.$element;
1639
+ KeyHandler.prototype.moveDown = function() {
1640
+ var node;
1641
+ node = this.tree_widget.getSelectedNode();
1642
+ if (node) {
1643
+ return this.selectNode(node.getNextNode());
1644
+ } else {
1645
+ return false;
1646
+ }
1787
1647
  };
1788
1648
 
1789
- NodeElement.prototype.addDropHint = function(position) {
1790
- if (position === Position.INSIDE) {
1791
- return new BorderDropHint(this.$element);
1649
+ KeyHandler.prototype.moveUp = function() {
1650
+ var node;
1651
+ node = this.tree_widget.getSelectedNode();
1652
+ if (node) {
1653
+ return this.selectNode(node.getPreviousNode());
1792
1654
  } else {
1793
- return new GhostDropHint(this.node, this.$element, position);
1655
+ return false;
1794
1656
  }
1795
1657
  };
1796
1658
 
1797
- NodeElement.prototype.select = function() {
1798
- return this.getLi().addClass('jqtree-selected');
1659
+ KeyHandler.prototype.moveRight = function() {
1660
+ var node;
1661
+ node = this.tree_widget.getSelectedNode();
1662
+ if (node && node.isFolder() && !node.is_open) {
1663
+ this.tree_widget.openNode(node);
1664
+ return false;
1665
+ } else {
1666
+ return true;
1667
+ }
1799
1668
  };
1800
1669
 
1801
- NodeElement.prototype.deselect = function() {
1802
- return this.getLi().removeClass('jqtree-selected');
1670
+ KeyHandler.prototype.moveLeft = function() {
1671
+ var node;
1672
+ node = this.tree_widget.getSelectedNode();
1673
+ if (node && node.isFolder() && node.is_open) {
1674
+ this.tree_widget.closeNode(node);
1675
+ return false;
1676
+ } else {
1677
+ return true;
1678
+ }
1803
1679
  };
1804
1680
 
1805
- return NodeElement;
1806
-
1807
- })();
1808
-
1809
- FolderElement = (function(_super) {
1810
- __extends(FolderElement, _super);
1811
-
1812
- function FolderElement() {
1813
- return FolderElement.__super__.constructor.apply(this, arguments);
1814
- }
1815
-
1816
- FolderElement.prototype.open = function(on_finished, slide) {
1817
- var $button, doOpen;
1818
- if (slide == null) {
1819
- slide = true;
1681
+ KeyHandler.prototype.handleKeyDown = function(e) {
1682
+ var key;
1683
+ if (!this.tree_widget.options.keyboardSupport) {
1684
+ return true;
1820
1685
  }
1821
- if (!this.node.is_open) {
1822
- this.node.is_open = true;
1823
- $button = this.getButton();
1824
- $button.removeClass('jqtree-closed');
1825
- $button.html('');
1826
- $button.append(this.tree_widget.renderer.opened_icon_element.cloneNode());
1827
- doOpen = (function(_this) {
1828
- return function() {
1829
- _this.getLi().removeClass('jqtree-closed');
1830
- if (on_finished) {
1831
- on_finished();
1832
- }
1833
- return _this.tree_widget._triggerEvent('tree.open', {
1834
- node: _this.node
1835
- });
1836
- };
1837
- })(this);
1838
- if (slide) {
1839
- return this.getUl().slideDown('fast', doOpen);
1840
- } else {
1841
- this.getUl().show();
1842
- return doOpen();
1843
- }
1686
+ if ($(document.activeElement).is('textarea,input,select')) {
1687
+ return true;
1844
1688
  }
1845
- };
1846
-
1847
- FolderElement.prototype.close = function(slide) {
1848
- var $button, doClose;
1849
- if (slide == null) {
1850
- slide = true;
1689
+ if (!this.tree_widget.getSelectedNode()) {
1690
+ return true;
1851
1691
  }
1852
- if (this.node.is_open) {
1853
- this.node.is_open = false;
1854
- $button = this.getButton();
1855
- $button.addClass('jqtree-closed');
1856
- $button.html('');
1857
- $button.append(this.tree_widget.renderer.closed_icon_element.cloneNode());
1858
- doClose = (function(_this) {
1859
- return function() {
1860
- _this.getLi().addClass('jqtree-closed');
1861
- return _this.tree_widget._triggerEvent('tree.close', {
1862
- node: _this.node
1863
- });
1864
- };
1865
- })(this);
1866
- if (slide) {
1867
- return this.getUl().slideUp('fast', doClose);
1868
- } else {
1869
- this.getUl().hide();
1870
- return doClose();
1871
- }
1692
+ key = e.which;
1693
+ switch (key) {
1694
+ case DOWN:
1695
+ return this.moveDown();
1696
+ case UP:
1697
+ return this.moveUp();
1698
+ case RIGHT:
1699
+ return this.moveRight();
1700
+ case LEFT:
1701
+ return this.moveLeft();
1872
1702
  }
1703
+ return true;
1873
1704
  };
1874
1705
 
1875
- FolderElement.prototype.getButton = function() {
1876
- return this.$element.children('.jqtree-element').find('a.jqtree-toggler');
1877
- };
1878
-
1879
- FolderElement.prototype.addDropHint = function(position) {
1880
- if (!this.node.is_open && position === Position.INSIDE) {
1881
- return new BorderDropHint(this.$element);
1706
+ KeyHandler.prototype.selectNode = function(node) {
1707
+ if (!node) {
1708
+ return true;
1882
1709
  } else {
1883
- return new GhostDropHint(this.node, this.$element, position);
1710
+ this.tree_widget.selectNode(node);
1711
+ if (this.tree_widget.scroll_handler && (!this.tree_widget.scroll_handler.isScrolledIntoView($(node.element).find('.jqtree-element')))) {
1712
+ this.tree_widget.scrollToNode(node);
1713
+ }
1714
+ return false;
1884
1715
  }
1885
1716
  };
1886
1717
 
1887
- return FolderElement;
1718
+ return KeyHandler;
1888
1719
 
1889
- })(NodeElement);
1720
+ })();
1890
1721
 
1891
- html_escape = function(string) {
1892
- return ('' + string).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#x27;').replace(/\//g, '&#x2F;');
1722
+ module.exports = KeyHandler;
1723
+
1724
+ }).call(this);
1725
+
1726
+ },{}],5:[function(require,module,exports){
1727
+
1728
+ /*
1729
+ This widget does the same a the mouse widget in jqueryui.
1730
+ */
1731
+
1732
+ (function() {
1733
+ var MouseWidget, SimpleWidget,
1734
+ __hasProp = {}.hasOwnProperty,
1735
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
1736
+
1737
+ SimpleWidget = require('./simple.widget');
1738
+
1739
+ MouseWidget = (function(_super) {
1740
+ __extends(MouseWidget, _super);
1741
+
1742
+ function MouseWidget() {
1743
+ return MouseWidget.__super__.constructor.apply(this, arguments);
1744
+ }
1745
+
1746
+ MouseWidget.is_mouse_handled = false;
1747
+
1748
+ MouseWidget.prototype._init = function() {
1749
+ this.$el.bind('mousedown.mousewidget', $.proxy(this._mouseDown, this));
1750
+ this.$el.bind('touchstart.mousewidget', $.proxy(this._touchStart, this));
1751
+ this.is_mouse_started = false;
1752
+ this.mouse_delay = 0;
1753
+ this._mouse_delay_timer = null;
1754
+ this._is_mouse_delay_met = true;
1755
+ return this.mouse_down_info = null;
1756
+ };
1757
+
1758
+ MouseWidget.prototype._deinit = function() {
1759
+ var $document;
1760
+ this.$el.unbind('mousedown.mousewidget');
1761
+ this.$el.unbind('touchstart.mousewidget');
1762
+ $document = $(document);
1763
+ $document.unbind('mousemove.mousewidget');
1764
+ return $document.unbind('mouseup.mousewidget');
1765
+ };
1766
+
1767
+ MouseWidget.prototype._mouseDown = function(e) {
1768
+ var result;
1769
+ if (e.which !== 1) {
1770
+ return;
1771
+ }
1772
+ result = this._handleMouseDown(e, this._getPositionInfo(e));
1773
+ if (result) {
1774
+ e.preventDefault();
1775
+ }
1776
+ return result;
1777
+ };
1778
+
1779
+ MouseWidget.prototype._handleMouseDown = function(e, position_info) {
1780
+ if (MouseWidget.is_mouse_handled) {
1781
+ return;
1782
+ }
1783
+ if (this.is_mouse_started) {
1784
+ this._handleMouseUp(position_info);
1785
+ }
1786
+ this.mouse_down_info = position_info;
1787
+ if (!this._mouseCapture(position_info)) {
1788
+ return;
1789
+ }
1790
+ this._handleStartMouse();
1791
+ this.is_mouse_handled = true;
1792
+ return true;
1793
+ };
1794
+
1795
+ MouseWidget.prototype._handleStartMouse = function() {
1796
+ var $document;
1797
+ $document = $(document);
1798
+ $document.bind('mousemove.mousewidget', $.proxy(this._mouseMove, this));
1799
+ $document.bind('touchmove.mousewidget', $.proxy(this._touchMove, this));
1800
+ $document.bind('mouseup.mousewidget', $.proxy(this._mouseUp, this));
1801
+ $document.bind('touchend.mousewidget', $.proxy(this._touchEnd, this));
1802
+ if (this.mouse_delay) {
1803
+ return this._startMouseDelayTimer();
1804
+ }
1805
+ };
1806
+
1807
+ MouseWidget.prototype._startMouseDelayTimer = function() {
1808
+ if (this._mouse_delay_timer) {
1809
+ clearTimeout(this._mouse_delay_timer);
1810
+ }
1811
+ this._mouse_delay_timer = setTimeout((function(_this) {
1812
+ return function() {
1813
+ return _this._is_mouse_delay_met = true;
1814
+ };
1815
+ })(this), this.mouse_delay);
1816
+ return this._is_mouse_delay_met = false;
1817
+ };
1818
+
1819
+ MouseWidget.prototype._mouseMove = function(e) {
1820
+ return this._handleMouseMove(e, this._getPositionInfo(e));
1821
+ };
1822
+
1823
+ MouseWidget.prototype._handleMouseMove = function(e, position_info) {
1824
+ if (this.is_mouse_started) {
1825
+ this._mouseDrag(position_info);
1826
+ return e.preventDefault();
1827
+ }
1828
+ if (this.mouse_delay && !this._is_mouse_delay_met) {
1829
+ return true;
1830
+ }
1831
+ this.is_mouse_started = this._mouseStart(this.mouse_down_info) !== false;
1832
+ if (this.is_mouse_started) {
1833
+ this._mouseDrag(position_info);
1834
+ } else {
1835
+ this._handleMouseUp(position_info);
1836
+ }
1837
+ return !this.is_mouse_started;
1838
+ };
1839
+
1840
+ MouseWidget.prototype._getPositionInfo = function(e) {
1841
+ return {
1842
+ page_x: e.pageX,
1843
+ page_y: e.pageY,
1844
+ target: e.target,
1845
+ original_event: e
1846
+ };
1847
+ };
1848
+
1849
+ MouseWidget.prototype._mouseUp = function(e) {
1850
+ return this._handleMouseUp(this._getPositionInfo(e));
1851
+ };
1852
+
1853
+ MouseWidget.prototype._handleMouseUp = function(position_info) {
1854
+ var $document;
1855
+ $document = $(document);
1856
+ $document.unbind('mousemove.mousewidget');
1857
+ $document.unbind('touchmove.mousewidget');
1858
+ $document.unbind('mouseup.mousewidget');
1859
+ $document.unbind('touchend.mousewidget');
1860
+ if (this.is_mouse_started) {
1861
+ this.is_mouse_started = false;
1862
+ this._mouseStop(position_info);
1863
+ }
1864
+ };
1865
+
1866
+ MouseWidget.prototype._mouseCapture = function(position_info) {
1867
+ return true;
1868
+ };
1869
+
1870
+ MouseWidget.prototype._mouseStart = function(position_info) {
1871
+ return null;
1872
+ };
1873
+
1874
+ MouseWidget.prototype._mouseDrag = function(position_info) {
1875
+ return null;
1876
+ };
1877
+
1878
+ MouseWidget.prototype._mouseStop = function(position_info) {
1879
+ return null;
1880
+ };
1881
+
1882
+ MouseWidget.prototype.setMouseDelay = function(mouse_delay) {
1883
+ return this.mouse_delay = mouse_delay;
1884
+ };
1885
+
1886
+ MouseWidget.prototype._touchStart = function(e) {
1887
+ var touch;
1888
+ if (e.originalEvent.touches.length > 1) {
1889
+ return;
1890
+ }
1891
+ touch = e.originalEvent.changedTouches[0];
1892
+ return this._handleMouseDown(e, this._getPositionInfo(touch));
1893
+ };
1894
+
1895
+ MouseWidget.prototype._touchMove = function(e) {
1896
+ var touch;
1897
+ if (e.originalEvent.touches.length > 1) {
1898
+ return;
1899
+ }
1900
+ touch = e.originalEvent.changedTouches[0];
1901
+ return this._handleMouseMove(e, this._getPositionInfo(touch));
1902
+ };
1903
+
1904
+ MouseWidget.prototype._touchEnd = function(e) {
1905
+ var touch;
1906
+ if (e.originalEvent.touches.length > 1) {
1907
+ return;
1908
+ }
1909
+ touch = e.originalEvent.changedTouches[0];
1910
+ return this._handleMouseUp(this._getPositionInfo(touch));
1911
+ };
1912
+
1913
+ return MouseWidget;
1914
+
1915
+ })(SimpleWidget);
1916
+
1917
+ module.exports = MouseWidget;
1918
+
1919
+ }).call(this);
1920
+
1921
+ },{"./simple.widget":11}],6:[function(require,module,exports){
1922
+ (function() {
1923
+ var Node, Position;
1924
+
1925
+ Position = {
1926
+ getName: function(position) {
1927
+ return Position.strings[position - 1];
1928
+ },
1929
+ nameToIndex: function(name) {
1930
+ var i, _i, _ref;
1931
+ for (i = _i = 1, _ref = Position.strings.length; 1 <= _ref ? _i <= _ref : _i >= _ref; i = 1 <= _ref ? ++_i : --_i) {
1932
+ if (Position.strings[i - 1] === name) {
1933
+ return i;
1934
+ }
1935
+ }
1936
+ return 0;
1937
+ }
1893
1938
  };
1894
1939
 
1895
- _indexOf = function(array, item) {
1896
- var i, value, _i, _len;
1897
- for (i = _i = 0, _len = array.length; _i < _len; i = ++_i) {
1898
- value = array[i];
1899
- if (value === item) {
1900
- return i;
1901
- }
1902
- }
1903
- return -1;
1904
- };
1940
+ Position.BEFORE = 1;
1941
+
1942
+ Position.AFTER = 2;
1943
+
1944
+ Position.INSIDE = 3;
1945
+
1946
+ Position.NONE = 4;
1947
+
1948
+ Position.strings = ['before', 'after', 'inside', 'none'];
1949
+
1950
+ Node = (function() {
1951
+ function Node(o, is_root, node_class) {
1952
+ if (is_root == null) {
1953
+ is_root = false;
1954
+ }
1955
+ if (node_class == null) {
1956
+ node_class = Node;
1957
+ }
1958
+ this.setData(o);
1959
+ this.children = [];
1960
+ this.parent = null;
1961
+ if (is_root) {
1962
+ this.id_mapping = {};
1963
+ this.tree = this;
1964
+ this.node_class = node_class;
1965
+ }
1966
+ }
1967
+
1968
+ Node.prototype.setData = function(o) {
1969
+ var key, value, _results;
1970
+ if (typeof o !== 'object') {
1971
+ return this.name = o;
1972
+ } else {
1973
+ _results = [];
1974
+ for (key in o) {
1975
+ value = o[key];
1976
+ if (key === 'label') {
1977
+ _results.push(this.name = value);
1978
+ } else {
1979
+ _results.push(this[key] = value);
1980
+ }
1981
+ }
1982
+ return _results;
1983
+ }
1984
+ };
1985
+
1986
+ Node.prototype.initFromData = function(data) {
1987
+ var addChildren, addNode;
1988
+ addNode = (function(_this) {
1989
+ return function(node_data) {
1990
+ _this.setData(node_data);
1991
+ if (node_data.children) {
1992
+ return addChildren(node_data.children);
1993
+ }
1994
+ };
1995
+ })(this);
1996
+ addChildren = (function(_this) {
1997
+ return function(children_data) {
1998
+ var child, node, _i, _len;
1999
+ for (_i = 0, _len = children_data.length; _i < _len; _i++) {
2000
+ child = children_data[_i];
2001
+ node = new _this.tree.node_class('');
2002
+ node.initFromData(child);
2003
+ _this.addChild(node);
2004
+ }
2005
+ return null;
2006
+ };
2007
+ })(this);
2008
+ addNode(data);
2009
+ return null;
2010
+ };
2011
+
2012
+
2013
+ /*
2014
+ Create tree from data.
2015
+
2016
+ Structure of data is:
2017
+ [
2018
+ {
2019
+ label: 'node1',
2020
+ children: [
2021
+ { label: 'child1' },
2022
+ { label: 'child2' }
2023
+ ]
2024
+ },
2025
+ {
2026
+ label: 'node2'
2027
+ }
2028
+ ]
2029
+ */
2030
+
2031
+ Node.prototype.loadFromData = function(data) {
2032
+ var node, o, _i, _len;
2033
+ this.removeChildren();
2034
+ for (_i = 0, _len = data.length; _i < _len; _i++) {
2035
+ o = data[_i];
2036
+ node = new this.tree.node_class(o);
2037
+ this.addChild(node);
2038
+ if (typeof o === 'object' && o.children) {
2039
+ node.loadFromData(o.children);
2040
+ }
2041
+ }
2042
+ return null;
2043
+ };
2044
+
2045
+
2046
+ /*
2047
+ Add child.
2048
+
2049
+ tree.addChild(
2050
+ new Node('child1')
2051
+ );
2052
+ */
2053
+
2054
+ Node.prototype.addChild = function(node) {
2055
+ this.children.push(node);
2056
+ return node._setParent(this);
2057
+ };
2058
+
2059
+
2060
+ /*
2061
+ Add child at position. Index starts at 0.
2062
+
2063
+ tree.addChildAtPosition(
2064
+ new Node('abc'),
2065
+ 1
2066
+ );
2067
+ */
2068
+
2069
+ Node.prototype.addChildAtPosition = function(node, index) {
2070
+ this.children.splice(index, 0, node);
2071
+ return node._setParent(this);
2072
+ };
2073
+
2074
+ Node.prototype._setParent = function(parent) {
2075
+ this.parent = parent;
2076
+ this.tree = parent.tree;
2077
+ return this.tree.addNodeToIndex(this);
2078
+ };
2079
+
2080
+
2081
+ /*
2082
+ Remove child. This also removes the children of the node.
2083
+
2084
+ tree.removeChild(tree.children[0]);
2085
+ */
2086
+
2087
+ Node.prototype.removeChild = function(node) {
2088
+ node.removeChildren();
2089
+ return this._removeChild(node);
2090
+ };
2091
+
2092
+ Node.prototype._removeChild = function(node) {
2093
+ this.children.splice(this.getChildIndex(node), 1);
2094
+ return this.tree.removeNodeFromIndex(node);
2095
+ };
2096
+
1905
2097
 
1906
- indexOf = function(array, item) {
1907
- if (array.indexOf) {
1908
- return array.indexOf(item);
1909
- } else {
1910
- return _indexOf(array, item);
1911
- }
1912
- };
2098
+ /*
2099
+ Get child index.
2100
+
2101
+ var index = getChildIndex(node);
2102
+ */
1913
2103
 
1914
- this.Tree.indexOf = indexOf;
2104
+ Node.prototype.getChildIndex = function(node) {
2105
+ return $.inArray(node, this.children);
2106
+ };
1915
2107
 
1916
- this.Tree._indexOf = _indexOf;
1917
2108
 
1918
- isInt = function(n) {
1919
- return typeof n === 'number' && n % 1 === 0;
1920
- };
2109
+ /*
2110
+ Does the tree have children?
2111
+
2112
+ if (tree.hasChildren()) {
2113
+ //
2114
+ }
2115
+ */
1921
2116
 
1922
- get_json_stringify_function = function() {
1923
- var json_escapable, json_meta, json_quote, json_str, stringify;
1924
- json_escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
1925
- json_meta = {
1926
- '\b': '\\b',
1927
- '\t': '\\t',
1928
- '\n': '\\n',
1929
- '\f': '\\f',
1930
- '\r': '\\r',
1931
- '"': '\\"',
1932
- '\\': '\\\\'
2117
+ Node.prototype.hasChildren = function() {
2118
+ return this.children.length !== 0;
1933
2119
  };
1934
- json_quote = function(string) {
1935
- json_escapable.lastIndex = 0;
1936
- if (json_escapable.test(string)) {
1937
- return '"' + string.replace(json_escapable, function(a) {
1938
- var c;
1939
- c = json_meta[a];
1940
- return (typeof c === 'string' ? c : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4));
1941
- }) + '"';
1942
- } else {
1943
- return '"' + string + '"';
1944
- }
2120
+
2121
+ Node.prototype.isFolder = function() {
2122
+ return this.hasChildren() || this.load_on_demand;
1945
2123
  };
1946
- json_str = function(key, holder) {
1947
- var i, k, partial, v, value, _i, _len;
1948
- value = holder[key];
1949
- switch (typeof value) {
1950
- case 'string':
1951
- return json_quote(value);
1952
- case 'number':
1953
- if (isFinite(value)) {
1954
- return String(value);
1955
- } else {
1956
- return 'null';
1957
- }
1958
- case 'boolean':
1959
- case 'null':
1960
- return String(value);
1961
- case 'object':
1962
- if (!value) {
1963
- return 'null';
1964
- }
1965
- partial = [];
1966
- if (Object.prototype.toString.apply(value) === '[object Array]') {
1967
- for (i = _i = 0, _len = value.length; _i < _len; i = ++_i) {
1968
- v = value[i];
1969
- partial[i] = json_str(i, value) || 'null';
2124
+
2125
+
2126
+ /*
2127
+ Iterate over all the nodes in the tree.
2128
+
2129
+ Calls callback with (node, level).
2130
+
2131
+ The callback must return true to continue the iteration on current node.
2132
+
2133
+ tree.iterate(
2134
+ function(node, level) {
2135
+ console.log(node.name);
2136
+
2137
+ // stop iteration after level 2
2138
+ return (level <= 2);
2139
+ }
2140
+ );
2141
+ */
2142
+
2143
+ Node.prototype.iterate = function(callback) {
2144
+ var _iterate;
2145
+ _iterate = function(node, level) {
2146
+ var child, result, _i, _len, _ref;
2147
+ if (node.children) {
2148
+ _ref = node.children;
2149
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
2150
+ child = _ref[_i];
2151
+ result = callback(child, level);
2152
+ if (result && child.hasChildren()) {
2153
+ _iterate(child, level + 1);
1970
2154
  }
1971
- return (partial.length === 0 ? '[]' : '[' + partial.join(',') + ']');
1972
2155
  }
1973
- for (k in value) {
1974
- if (Object.prototype.hasOwnProperty.call(value, k)) {
1975
- v = json_str(k, value);
1976
- if (v) {
1977
- partial.push(json_quote(k) + ':' + v);
2156
+ return null;
2157
+ }
2158
+ };
2159
+ _iterate(this, 0);
2160
+ return null;
2161
+ };
2162
+
2163
+
2164
+ /*
2165
+ Move node relative to another node.
2166
+
2167
+ Argument position: Position.BEFORE, Position.AFTER or Position.Inside
2168
+
2169
+ // move node1 after node2
2170
+ tree.moveNode(node1, node2, Position.AFTER);
2171
+ */
2172
+
2173
+ Node.prototype.moveNode = function(moved_node, target_node, position) {
2174
+ if (moved_node.isParentOf(target_node)) {
2175
+ return;
2176
+ }
2177
+ moved_node.parent._removeChild(moved_node);
2178
+ if (position === Position.AFTER) {
2179
+ return target_node.parent.addChildAtPosition(moved_node, target_node.parent.getChildIndex(target_node) + 1);
2180
+ } else if (position === Position.BEFORE) {
2181
+ return target_node.parent.addChildAtPosition(moved_node, target_node.parent.getChildIndex(target_node));
2182
+ } else if (position === Position.INSIDE) {
2183
+ return target_node.addChildAtPosition(moved_node, 0);
2184
+ }
2185
+ };
2186
+
2187
+
2188
+ /*
2189
+ Get the tree as data.
2190
+ */
2191
+
2192
+ Node.prototype.getData = function() {
2193
+ var getDataFromNodes;
2194
+ getDataFromNodes = (function(_this) {
2195
+ return function(nodes) {
2196
+ var data, k, node, tmp_node, v, _i, _len;
2197
+ data = [];
2198
+ for (_i = 0, _len = nodes.length; _i < _len; _i++) {
2199
+ node = nodes[_i];
2200
+ tmp_node = {};
2201
+ for (k in node) {
2202
+ v = node[k];
2203
+ if ((k !== 'parent' && k !== 'children' && k !== 'element' && k !== 'tree') && Object.prototype.hasOwnProperty.call(node, k)) {
2204
+ tmp_node[k] = v;
1978
2205
  }
1979
2206
  }
2207
+ if (node.hasChildren()) {
2208
+ tmp_node.children = getDataFromNodes(node.children);
2209
+ }
2210
+ data.push(tmp_node);
1980
2211
  }
1981
- return (partial.length === 0 ? '{}' : '{' + partial.join(',') + '}');
2212
+ return data;
2213
+ };
2214
+ })(this);
2215
+ return getDataFromNodes(this.children);
2216
+ };
2217
+
2218
+ Node.prototype.getNodeByName = function(name) {
2219
+ var result;
2220
+ result = null;
2221
+ this.iterate(function(node) {
2222
+ if (node.name === name) {
2223
+ result = node;
2224
+ return false;
2225
+ } else {
2226
+ return true;
2227
+ }
2228
+ });
2229
+ return result;
2230
+ };
2231
+
2232
+ Node.prototype.addAfter = function(node_info) {
2233
+ var child_index, node;
2234
+ if (!this.parent) {
2235
+ return null;
2236
+ } else {
2237
+ node = new this.tree.node_class(node_info);
2238
+ child_index = this.parent.getChildIndex(this);
2239
+ this.parent.addChildAtPosition(node, child_index + 1);
2240
+ return node;
2241
+ }
2242
+ };
2243
+
2244
+ Node.prototype.addBefore = function(node_info) {
2245
+ var child_index, node;
2246
+ if (!this.parent) {
2247
+ return null;
2248
+ } else {
2249
+ node = new this.tree.node_class(node_info);
2250
+ child_index = this.parent.getChildIndex(this);
2251
+ this.parent.addChildAtPosition(node, child_index);
2252
+ return node;
2253
+ }
2254
+ };
2255
+
2256
+ Node.prototype.addParent = function(node_info) {
2257
+ var child, new_parent, original_parent, _i, _len, _ref;
2258
+ if (!this.parent) {
2259
+ return null;
2260
+ } else {
2261
+ new_parent = new this.tree.node_class(node_info);
2262
+ new_parent._setParent(this.tree);
2263
+ original_parent = this.parent;
2264
+ _ref = original_parent.children;
2265
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
2266
+ child = _ref[_i];
2267
+ new_parent.addChild(child);
2268
+ }
2269
+ original_parent.children = [];
2270
+ original_parent.addChild(new_parent);
2271
+ return new_parent;
2272
+ }
2273
+ };
2274
+
2275
+ Node.prototype.remove = function() {
2276
+ if (this.parent) {
2277
+ this.parent.removeChild(this);
2278
+ return this.parent = null;
2279
+ }
2280
+ };
2281
+
2282
+ Node.prototype.append = function(node_info) {
2283
+ var node;
2284
+ node = new this.tree.node_class(node_info);
2285
+ this.addChild(node);
2286
+ return node;
2287
+ };
2288
+
2289
+ Node.prototype.prepend = function(node_info) {
2290
+ var node;
2291
+ node = new this.tree.node_class(node_info);
2292
+ this.addChildAtPosition(node, 0);
2293
+ return node;
2294
+ };
2295
+
2296
+ Node.prototype.isParentOf = function(node) {
2297
+ var parent;
2298
+ parent = node.parent;
2299
+ while (parent) {
2300
+ if (parent === this) {
2301
+ return true;
2302
+ }
2303
+ parent = parent.parent;
1982
2304
  }
2305
+ return false;
1983
2306
  };
1984
- stringify = function(value) {
1985
- return json_str('', {
1986
- '': value
1987
- });
1988
- };
1989
- return stringify;
1990
- };
1991
2307
 
1992
- this.Tree.get_json_stringify_function = get_json_stringify_function;
2308
+ Node.prototype.getLevel = function() {
2309
+ var level, node;
2310
+ level = 0;
2311
+ node = this;
2312
+ while (node.parent) {
2313
+ level += 1;
2314
+ node = node.parent;
2315
+ }
2316
+ return level;
2317
+ };
1993
2318
 
1994
- if (!((this.JSON != null) && (this.JSON.stringify != null) && typeof this.JSON.stringify === 'function')) {
1995
- if (this.JSON == null) {
1996
- this.JSON = {};
1997
- }
1998
- this.JSON.stringify = get_json_stringify_function();
1999
- }
2319
+ Node.prototype.getNodeById = function(node_id) {
2320
+ return this.id_mapping[node_id];
2321
+ };
2000
2322
 
2001
- SaveStateHandler = (function() {
2002
- function SaveStateHandler(tree_widget) {
2003
- this.tree_widget = tree_widget;
2004
- }
2323
+ Node.prototype.addNodeToIndex = function(node) {
2324
+ if (node.id != null) {
2325
+ return this.id_mapping[node.id] = node;
2326
+ }
2327
+ };
2005
2328
 
2006
- SaveStateHandler.prototype.saveState = function() {
2007
- var state;
2008
- state = JSON.stringify(this.getState());
2009
- if (this.tree_widget.options.onSetStateFromStorage) {
2010
- return this.tree_widget.options.onSetStateFromStorage(state);
2011
- } else if (this.supportsLocalStorage()) {
2012
- return localStorage.setItem(this.getCookieName(), state);
2013
- } else if ($.cookie) {
2014
- $.cookie.raw = true;
2015
- return $.cookie(this.getCookieName(), state, {
2016
- path: '/'
2017
- });
2329
+ Node.prototype.removeNodeFromIndex = function(node) {
2330
+ if (node.id != null) {
2331
+ return delete this.id_mapping[node.id];
2018
2332
  }
2019
2333
  };
2020
2334
 
2021
- SaveStateHandler.prototype.restoreState = function() {
2022
- var state;
2023
- state = this.getStateFromStorage();
2024
- if (state) {
2025
- this.setState($.parseJSON(state));
2026
- return true;
2335
+ Node.prototype.removeChildren = function() {
2336
+ this.iterate((function(_this) {
2337
+ return function(child) {
2338
+ _this.tree.removeNodeFromIndex(child);
2339
+ return true;
2340
+ };
2341
+ })(this));
2342
+ return this.children = [];
2343
+ };
2344
+
2345
+ Node.prototype.getPreviousSibling = function() {
2346
+ var previous_index;
2347
+ if (!this.parent) {
2348
+ return null;
2027
2349
  } else {
2028
- return false;
2350
+ previous_index = this.parent.getChildIndex(this) - 1;
2351
+ if (previous_index >= 0) {
2352
+ return this.parent.children[previous_index];
2353
+ } else {
2354
+ return null;
2355
+ }
2029
2356
  }
2030
2357
  };
2031
2358
 
2032
- SaveStateHandler.prototype.getStateFromStorage = function() {
2033
- if (this.tree_widget.options.onGetStateFromStorage) {
2034
- return this.tree_widget.options.onGetStateFromStorage();
2035
- } else if (this.supportsLocalStorage()) {
2036
- return localStorage.getItem(this.getCookieName());
2037
- } else if ($.cookie) {
2038
- $.cookie.raw = true;
2039
- return $.cookie(this.getCookieName());
2040
- } else {
2359
+ Node.prototype.getNextSibling = function() {
2360
+ var next_index;
2361
+ if (!this.parent) {
2041
2362
  return null;
2363
+ } else {
2364
+ next_index = this.parent.getChildIndex(this) + 1;
2365
+ if (next_index < this.parent.children.length) {
2366
+ return this.parent.children[next_index];
2367
+ } else {
2368
+ return null;
2369
+ }
2042
2370
  }
2043
2371
  };
2044
2372
 
2045
- SaveStateHandler.prototype.getState = function() {
2046
- var getOpenNodeIds, getSelectedNodeIds;
2047
- getOpenNodeIds = (function(_this) {
2048
- return function() {
2049
- var open_nodes;
2050
- open_nodes = [];
2051
- _this.tree_widget.tree.iterate(function(node) {
2052
- if (node.is_open && node.id && node.hasChildren()) {
2053
- open_nodes.push(node.id);
2054
- }
2055
- return true;
2056
- });
2057
- return open_nodes;
2058
- };
2059
- })(this);
2060
- getSelectedNodeIds = (function(_this) {
2061
- return function() {
2062
- var n;
2063
- return (function() {
2064
- var _i, _len, _ref, _results;
2065
- _ref = this.tree_widget.getSelectedNodes();
2066
- _results = [];
2067
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
2068
- n = _ref[_i];
2069
- _results.push(n.id);
2070
- }
2071
- return _results;
2072
- }).call(_this);
2073
- };
2074
- })(this);
2075
- return {
2076
- open_nodes: getOpenNodeIds(),
2077
- selected_node: getSelectedNodeIds()
2078
- };
2373
+ Node.prototype.getNodesByProperty = function(key, value) {
2374
+ return this.filter(function(node) {
2375
+ return node[key] === value;
2376
+ });
2079
2377
  };
2080
2378
 
2081
- SaveStateHandler.prototype.setState = function(state) {
2082
- var node_id, open_nodes, selected_node, selected_node_ids, _i, _len, _results;
2083
- if (state) {
2084
- open_nodes = state.open_nodes;
2085
- selected_node_ids = state.selected_node;
2086
- if (isInt(selected_node_ids)) {
2087
- selected_node_ids = [selected_node_ids];
2088
- }
2089
- this.tree_widget.tree.iterate((function(_this) {
2090
- return function(node) {
2091
- node.is_open = node.id && node.hasChildren() && (indexOf(open_nodes, node.id) >= 0);
2092
- return true;
2093
- };
2094
- })(this));
2095
- if (selected_node_ids && this.tree_widget.select_node_handler) {
2096
- this.tree_widget.select_node_handler.clear();
2097
- _results = [];
2098
- for (_i = 0, _len = selected_node_ids.length; _i < _len; _i++) {
2099
- node_id = selected_node_ids[_i];
2100
- selected_node = this.tree_widget.getNodeById(node_id);
2101
- if (selected_node) {
2102
- _results.push(this.tree_widget.select_node_handler.addToSelection(selected_node));
2103
- } else {
2104
- _results.push(void 0);
2105
- }
2106
- }
2107
- return _results;
2379
+ Node.prototype.filter = function(f) {
2380
+ var result;
2381
+ result = [];
2382
+ this.iterate(function(node) {
2383
+ if (f(node)) {
2384
+ result.push(node);
2108
2385
  }
2109
- }
2386
+ return true;
2387
+ });
2388
+ return result;
2110
2389
  };
2111
2390
 
2112
- SaveStateHandler.prototype.getCookieName = function() {
2113
- if (typeof this.tree_widget.options.saveState === 'string') {
2114
- return this.tree_widget.options.saveState;
2391
+ Node.prototype.getNextNode = function(include_children) {
2392
+ var next_sibling;
2393
+ if (include_children == null) {
2394
+ include_children = true;
2395
+ }
2396
+ if (include_children && this.hasChildren() && this.is_open) {
2397
+ return this.children[0];
2115
2398
  } else {
2116
- return 'tree';
2399
+ if (!this.parent) {
2400
+ return null;
2401
+ } else {
2402
+ next_sibling = this.getNextSibling();
2403
+ if (next_sibling) {
2404
+ return next_sibling;
2405
+ } else {
2406
+ return this.parent.getNextNode(false);
2407
+ }
2408
+ }
2117
2409
  }
2118
2410
  };
2119
2411
 
2120
- SaveStateHandler.prototype.supportsLocalStorage = function() {
2121
- var testSupport;
2122
- testSupport = function() {
2123
- var error, key;
2124
- if (typeof localStorage === "undefined" || localStorage === null) {
2125
- return false;
2412
+ Node.prototype.getPreviousNode = function() {
2413
+ var previous_sibling;
2414
+ if (!this.parent) {
2415
+ return null;
2416
+ } else {
2417
+ previous_sibling = this.getPreviousSibling();
2418
+ if (previous_sibling) {
2419
+ if (!previous_sibling.hasChildren() || !previous_sibling.is_open) {
2420
+ return previous_sibling;
2421
+ } else {
2422
+ return previous_sibling.getLastChild();
2423
+ }
2126
2424
  } else {
2127
- try {
2128
- key = '_storage_test';
2129
- sessionStorage.setItem(key, true);
2130
- sessionStorage.removeItem(key);
2131
- } catch (_error) {
2132
- error = _error;
2133
- return false;
2425
+ if (this.parent.parent) {
2426
+ return this.parent;
2427
+ } else {
2428
+ return null;
2134
2429
  }
2135
- return true;
2136
2430
  }
2137
- };
2138
- if (this._supportsLocalStorage == null) {
2139
- this._supportsLocalStorage = testSupport();
2140
2431
  }
2141
- return this._supportsLocalStorage;
2142
2432
  };
2143
2433
 
2144
- SaveStateHandler.prototype.getNodeIdToBeSelected = function() {
2145
- var state, state_json;
2146
- state_json = this.getStateFromStorage();
2147
- if (state_json) {
2148
- state = $.parseJSON(state_json);
2149
- return state.selected_node;
2150
- } else {
2434
+ Node.prototype.getLastChild = function() {
2435
+ var last_child;
2436
+ if (!this.hasChildren()) {
2151
2437
  return null;
2438
+ } else {
2439
+ last_child = this.children[this.children.length - 1];
2440
+ if (!last_child.hasChildren() || !last_child.is_open) {
2441
+ return last_child;
2442
+ } else {
2443
+ return last_child.getLastChild();
2444
+ }
2152
2445
  }
2153
2446
  };
2154
2447
 
2155
- return SaveStateHandler;
2448
+ return Node;
2156
2449
 
2157
2450
  })();
2158
2451
 
2159
- SelectNodeHandler = (function() {
2160
- function SelectNodeHandler(tree_widget) {
2161
- this.tree_widget = tree_widget;
2162
- this.clear();
2163
- }
2452
+ module.exports = {
2453
+ Node: Node,
2454
+ Position: Position
2455
+ };
2164
2456
 
2165
- SelectNodeHandler.prototype.getSelectedNode = function() {
2166
- var selected_nodes;
2167
- selected_nodes = this.getSelectedNodes();
2168
- if (selected_nodes.length) {
2169
- return selected_nodes[0];
2170
- } else {
2171
- return false;
2172
- }
2173
- };
2457
+ }).call(this);
2174
2458
 
2175
- SelectNodeHandler.prototype.getSelectedNodes = function() {
2176
- var id, node, selected_nodes;
2177
- if (this.selected_single_node) {
2178
- return [this.selected_single_node];
2179
- } else {
2180
- selected_nodes = [];
2181
- for (id in this.selected_nodes) {
2182
- node = this.tree_widget.getNodeById(id);
2183
- if (node) {
2184
- selected_nodes.push(node);
2185
- }
2186
- }
2187
- return selected_nodes;
2459
+ },{}],7:[function(require,module,exports){
2460
+ (function() {
2461
+ var BorderDropHint, FolderElement, GhostDropHint, NodeElement, Position, node,
2462
+ __hasProp = {}.hasOwnProperty,
2463
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
2464
+
2465
+ node = require('./node');
2466
+
2467
+ Position = node.Position;
2468
+
2469
+ NodeElement = (function() {
2470
+ function NodeElement(node, tree_widget) {
2471
+ this.init(node, tree_widget);
2472
+ }
2473
+
2474
+ NodeElement.prototype.init = function(node, tree_widget) {
2475
+ this.node = node;
2476
+ this.tree_widget = tree_widget;
2477
+ if (!node.element) {
2478
+ node.element = this.tree_widget.element;
2188
2479
  }
2480
+ return this.$element = $(node.element);
2189
2481
  };
2190
2482
 
2191
- SelectNodeHandler.prototype.getSelectedNodesUnder = function(parent) {
2192
- var id, node, selected_nodes;
2193
- if (this.selected_single_node) {
2194
- if (parent.isParentOf(this.selected_single_node)) {
2195
- return [this.selected_single_node];
2196
- } else {
2197
- return [];
2198
- }
2199
- } else {
2200
- selected_nodes = [];
2201
- for (id in this.selected_nodes) {
2202
- node = this.tree_widget.getNodeById(id);
2203
- if (node && parent.isParentOf(node)) {
2204
- selected_nodes.push(node);
2205
- }
2206
- }
2207
- return selected_nodes;
2208
- }
2483
+ NodeElement.prototype.getUl = function() {
2484
+ return this.$element.children('ul:first');
2209
2485
  };
2210
2486
 
2211
- SelectNodeHandler.prototype.isNodeSelected = function(node) {
2212
- if (node.id) {
2213
- return this.selected_nodes[node.id];
2214
- } else if (this.selected_single_node) {
2215
- return this.selected_single_node.element === node.element;
2216
- } else {
2217
- return false;
2218
- }
2487
+ NodeElement.prototype.getSpan = function() {
2488
+ return this.$element.children('.jqtree-element').find('span.jqtree-title');
2219
2489
  };
2220
2490
 
2221
- SelectNodeHandler.prototype.clear = function() {
2222
- this.selected_nodes = {};
2223
- return this.selected_single_node = null;
2491
+ NodeElement.prototype.getLi = function() {
2492
+ return this.$element;
2224
2493
  };
2225
2494
 
2226
- SelectNodeHandler.prototype.removeFromSelection = function(node, include_children) {
2227
- if (include_children == null) {
2228
- include_children = false;
2229
- }
2230
- if (!node.id) {
2231
- if (this.selected_single_node && node.element === this.selected_single_node.element) {
2232
- return this.selected_single_node = null;
2233
- }
2495
+ NodeElement.prototype.addDropHint = function(position) {
2496
+ if (position === Position.INSIDE) {
2497
+ return new BorderDropHint(this.$element);
2234
2498
  } else {
2235
- delete this.selected_nodes[node.id];
2236
- if (include_children) {
2237
- return node.iterate((function(_this) {
2238
- return function(n) {
2239
- delete _this.selected_nodes[node.id];
2240
- return true;
2241
- };
2242
- })(this));
2243
- }
2499
+ return new GhostDropHint(this.node, this.$element, position);
2244
2500
  }
2245
2501
  };
2246
2502
 
2247
- SelectNodeHandler.prototype.addToSelection = function(node) {
2248
- if (node.id) {
2249
- return this.selected_nodes[node.id] = true;
2250
- } else {
2251
- return this.selected_single_node = node;
2252
- }
2503
+ NodeElement.prototype.select = function() {
2504
+ return this.getLi().addClass('jqtree-selected');
2253
2505
  };
2254
2506
 
2255
- return SelectNodeHandler;
2507
+ NodeElement.prototype.deselect = function() {
2508
+ return this.getLi().removeClass('jqtree-selected');
2509
+ };
2510
+
2511
+ return NodeElement;
2256
2512
 
2257
2513
  })();
2258
2514
 
2259
- DragAndDropHandler = (function() {
2260
- function DragAndDropHandler(tree_widget) {
2261
- this.tree_widget = tree_widget;
2262
- this.hovered_area = null;
2263
- this.$ghost = null;
2264
- this.hit_areas = [];
2265
- this.is_dragging = false;
2266
- this.current_item = null;
2515
+ FolderElement = (function(_super) {
2516
+ __extends(FolderElement, _super);
2517
+
2518
+ function FolderElement() {
2519
+ return FolderElement.__super__.constructor.apply(this, arguments);
2267
2520
  }
2268
2521
 
2269
- DragAndDropHandler.prototype.mouseCapture = function(position_info) {
2270
- var $element, node_element;
2271
- $element = $(position_info.target);
2272
- if (!this.mustCaptureElement($element)) {
2273
- return null;
2274
- }
2275
- if (this.tree_widget.options.onIsMoveHandle && !this.tree_widget.options.onIsMoveHandle($element)) {
2276
- return null;
2522
+ FolderElement.prototype.open = function(on_finished, slide) {
2523
+ var $button, doOpen;
2524
+ if (slide == null) {
2525
+ slide = true;
2277
2526
  }
2278
- node_element = this.tree_widget._getNodeElement($element);
2279
- if (node_element && this.tree_widget.options.onCanMove) {
2280
- if (!this.tree_widget.options.onCanMove(node_element.node)) {
2281
- node_element = null;
2527
+ if (!this.node.is_open) {
2528
+ this.node.is_open = true;
2529
+ $button = this.getButton();
2530
+ $button.removeClass('jqtree-closed');
2531
+ $button.html('');
2532
+ $button.append(this.tree_widget.renderer.opened_icon_element.cloneNode(false));
2533
+ doOpen = (function(_this) {
2534
+ return function() {
2535
+ _this.getLi().removeClass('jqtree-closed');
2536
+ if (on_finished) {
2537
+ on_finished();
2538
+ }
2539
+ return _this.tree_widget._triggerEvent('tree.open', {
2540
+ node: _this.node
2541
+ });
2542
+ };
2543
+ })(this);
2544
+ if (slide) {
2545
+ return this.getUl().slideDown('fast', doOpen);
2546
+ } else {
2547
+ this.getUl().show();
2548
+ return doOpen();
2282
2549
  }
2283
2550
  }
2284
- this.current_item = node_element;
2285
- return this.current_item !== null;
2286
- };
2287
-
2288
- DragAndDropHandler.prototype.mouseStart = function(position_info) {
2289
- var offset;
2290
- this.refresh();
2291
- offset = $(position_info.target).offset();
2292
- this.drag_element = new DragElement(this.current_item.node, position_info.page_x - offset.left, position_info.page_y - offset.top, this.tree_widget.element);
2293
- this.is_dragging = true;
2294
- this.current_item.$element.addClass('jqtree-moving');
2295
- return true;
2296
2551
  };
2297
2552
 
2298
- DragAndDropHandler.prototype.mouseDrag = function(position_info) {
2299
- var area, can_move_to;
2300
- this.drag_element.move(position_info.page_x, position_info.page_y);
2301
- area = this.findHoveredArea(position_info.page_x, position_info.page_y);
2302
- can_move_to = this.canMoveToArea(area);
2303
- if (can_move_to && area) {
2304
- if (this.hovered_area !== area) {
2305
- this.hovered_area = area;
2306
- if (this.mustOpenFolderTimer(area)) {
2307
- this.startOpenFolderTimer(area.node);
2308
- }
2309
- this.updateDropHint();
2553
+ FolderElement.prototype.close = function(slide) {
2554
+ var $button, doClose;
2555
+ if (slide == null) {
2556
+ slide = true;
2557
+ }
2558
+ if (this.node.is_open) {
2559
+ this.node.is_open = false;
2560
+ $button = this.getButton();
2561
+ $button.addClass('jqtree-closed');
2562
+ $button.html('');
2563
+ $button.append(this.tree_widget.renderer.closed_icon_element.cloneNode(false));
2564
+ doClose = (function(_this) {
2565
+ return function() {
2566
+ _this.getLi().addClass('jqtree-closed');
2567
+ return _this.tree_widget._triggerEvent('tree.close', {
2568
+ node: _this.node
2569
+ });
2570
+ };
2571
+ })(this);
2572
+ if (slide) {
2573
+ return this.getUl().slideUp('fast', doClose);
2574
+ } else {
2575
+ this.getUl().hide();
2576
+ return doClose();
2310
2577
  }
2311
- } else {
2312
- this.removeHover();
2313
- this.removeDropHint();
2314
- this.stopOpenFolderTimer();
2315
2578
  }
2316
- return true;
2317
2579
  };
2318
2580
 
2319
- DragAndDropHandler.prototype.mustCaptureElement = function($element) {
2320
- return !$element.is('input,select');
2581
+ FolderElement.prototype.getButton = function() {
2582
+ return this.$element.children('.jqtree-element').find('a.jqtree-toggler');
2321
2583
  };
2322
2584
 
2323
- DragAndDropHandler.prototype.canMoveToArea = function(area) {
2324
- var position_name;
2325
- if (!area) {
2326
- return false;
2327
- } else if (this.tree_widget.options.onCanMoveTo) {
2328
- position_name = Position.getName(area.position);
2329
- return this.tree_widget.options.onCanMoveTo(this.current_item.node, area.node, position_name);
2585
+ FolderElement.prototype.addDropHint = function(position) {
2586
+ if (!this.node.is_open && position === Position.INSIDE) {
2587
+ return new BorderDropHint(this.$element);
2330
2588
  } else {
2331
- return true;
2589
+ return new GhostDropHint(this.node, this.$element, position);
2332
2590
  }
2333
2591
  };
2334
2592
 
2335
- DragAndDropHandler.prototype.mouseStop = function(position_info) {
2336
- this.moveItem(position_info);
2337
- this.clear();
2338
- this.removeHover();
2339
- this.removeDropHint();
2340
- this.removeHitAreas();
2341
- if (this.current_item) {
2342
- this.current_item.$element.removeClass('jqtree-moving');
2343
- this.current_item = null;
2344
- }
2345
- this.is_dragging = false;
2346
- return false;
2593
+ return FolderElement;
2594
+
2595
+ })(NodeElement);
2596
+
2597
+ BorderDropHint = (function() {
2598
+ function BorderDropHint($element) {
2599
+ var $div, width;
2600
+ $div = $element.children('.jqtree-element');
2601
+ width = $element.width() - 4;
2602
+ this.$hint = $('<span class="jqtree-border"></span>');
2603
+ $div.append(this.$hint);
2604
+ this.$hint.css({
2605
+ width: width,
2606
+ height: $div.outerHeight() - 4
2607
+ });
2608
+ }
2609
+
2610
+ BorderDropHint.prototype.remove = function() {
2611
+ return this.$hint.remove();
2347
2612
  };
2348
2613
 
2349
- DragAndDropHandler.prototype.refresh = function() {
2350
- this.removeHitAreas();
2351
- this.generateHitAreas();
2352
- if (this.current_item) {
2353
- this.current_item = this.tree_widget._getNodeElementForNode(this.current_item.node);
2354
- if (this.is_dragging) {
2355
- return this.current_item.$element.addClass('jqtree-moving');
2614
+ return BorderDropHint;
2615
+
2616
+ })();
2617
+
2618
+ GhostDropHint = (function() {
2619
+ function GhostDropHint(node, $element, position) {
2620
+ this.$element = $element;
2621
+ this.node = node;
2622
+ this.$ghost = $('<li class="jqtree_common jqtree-ghost"><span class="jqtree_common jqtree-circle"></span><span class="jqtree_common jqtree-line"></span></li>');
2623
+ if (position === Position.AFTER) {
2624
+ this.moveAfter();
2625
+ } else if (position === Position.BEFORE) {
2626
+ this.moveBefore();
2627
+ } else if (position === Position.INSIDE) {
2628
+ if (node.isFolder() && node.is_open) {
2629
+ this.moveInsideOpenFolder();
2630
+ } else {
2631
+ this.moveInside();
2356
2632
  }
2357
2633
  }
2634
+ }
2635
+
2636
+ GhostDropHint.prototype.remove = function() {
2637
+ return this.$ghost.remove();
2358
2638
  };
2359
2639
 
2360
- DragAndDropHandler.prototype.removeHitAreas = function() {
2361
- return this.hit_areas = [];
2640
+ GhostDropHint.prototype.moveAfter = function() {
2641
+ return this.$element.after(this.$ghost);
2362
2642
  };
2363
2643
 
2364
- DragAndDropHandler.prototype.clear = function() {
2365
- this.drag_element.remove();
2366
- return this.drag_element = null;
2644
+ GhostDropHint.prototype.moveBefore = function() {
2645
+ return this.$element.before(this.$ghost);
2367
2646
  };
2368
2647
 
2369
- DragAndDropHandler.prototype.removeDropHint = function() {
2370
- if (this.previous_ghost) {
2371
- return this.previous_ghost.remove();
2372
- }
2648
+ GhostDropHint.prototype.moveInsideOpenFolder = function() {
2649
+ return $(this.node.children[0].element).before(this.$ghost);
2373
2650
  };
2374
2651
 
2375
- DragAndDropHandler.prototype.removeHover = function() {
2376
- return this.hovered_area = null;
2652
+ GhostDropHint.prototype.moveInside = function() {
2653
+ this.$element.after(this.$ghost);
2654
+ return this.$ghost.addClass('jqtree-inside');
2377
2655
  };
2378
2656
 
2379
- DragAndDropHandler.prototype.generateHitAreas = function() {
2380
- var hit_areas_generator;
2381
- hit_areas_generator = new HitAreasGenerator(this.tree_widget.tree, this.current_item.node, this.getTreeDimensions().bottom);
2382
- return this.hit_areas = hit_areas_generator.generate();
2657
+ return GhostDropHint;
2658
+
2659
+ })();
2660
+
2661
+ module.exports = {
2662
+ FolderElement: FolderElement,
2663
+ NodeElement: NodeElement
2664
+ };
2665
+
2666
+ }).call(this);
2667
+
2668
+ },{"./node":6}],8:[function(require,module,exports){
2669
+ (function() {
2670
+ var SaveStateHandler, indexOf, isInt, util;
2671
+
2672
+ util = require('./util');
2673
+
2674
+ indexOf = util.indexOf;
2675
+
2676
+ isInt = util.isInt;
2677
+
2678
+ SaveStateHandler = (function() {
2679
+ function SaveStateHandler(tree_widget) {
2680
+ this.tree_widget = tree_widget;
2681
+ }
2682
+
2683
+ SaveStateHandler.prototype.saveState = function() {
2684
+ var state;
2685
+ state = JSON.stringify(this.getState());
2686
+ if (this.tree_widget.options.onSetStateFromStorage) {
2687
+ return this.tree_widget.options.onSetStateFromStorage(state);
2688
+ } else if (this.supportsLocalStorage()) {
2689
+ return localStorage.setItem(this.getCookieName(), state);
2690
+ } else if ($.cookie) {
2691
+ $.cookie.raw = true;
2692
+ return $.cookie(this.getCookieName(), state, {
2693
+ path: '/'
2694
+ });
2695
+ }
2383
2696
  };
2384
2697
 
2385
- DragAndDropHandler.prototype.findHoveredArea = function(x, y) {
2386
- var area, dimensions, high, low, mid;
2387
- dimensions = this.getTreeDimensions();
2388
- if (x < dimensions.left || y < dimensions.top || x > dimensions.right || y > dimensions.bottom) {
2698
+ SaveStateHandler.prototype.getStateFromStorage = function() {
2699
+ var json_data;
2700
+ json_data = this._loadFromStorage();
2701
+ if (json_data) {
2702
+ return this._parseState(json_data);
2703
+ } else {
2389
2704
  return null;
2390
2705
  }
2391
- low = 0;
2392
- high = this.hit_areas.length;
2393
- while (low < high) {
2394
- mid = (low + high) >> 1;
2395
- area = this.hit_areas[mid];
2396
- if (y < area.top) {
2397
- high = mid;
2398
- } else if (y > area.bottom) {
2399
- low = mid + 1;
2400
- } else {
2401
- return area;
2402
- }
2403
- }
2404
- return null;
2405
2706
  };
2406
2707
 
2407
- DragAndDropHandler.prototype.mustOpenFolderTimer = function(area) {
2408
- var node;
2409
- node = area.node;
2410
- return node.isFolder() && !node.is_open && area.position === Position.INSIDE;
2708
+ SaveStateHandler.prototype._parseState = function(json_data) {
2709
+ var state;
2710
+ state = $.parseJSON(json_data);
2711
+ if (state && state.selected_node && isInt(state.selected_node)) {
2712
+ state.selected_node = [state.selected_node];
2713
+ }
2714
+ return state;
2411
2715
  };
2412
2716
 
2413
- DragAndDropHandler.prototype.updateDropHint = function() {
2414
- var node_element;
2415
- if (!this.hovered_area) {
2416
- return;
2717
+ SaveStateHandler.prototype._loadFromStorage = function() {
2718
+ if (this.tree_widget.options.onGetStateFromStorage) {
2719
+ return this.tree_widget.options.onGetStateFromStorage();
2720
+ } else if (this.supportsLocalStorage()) {
2721
+ return localStorage.getItem(this.getCookieName());
2722
+ } else if ($.cookie) {
2723
+ $.cookie.raw = true;
2724
+ return $.cookie(this.getCookieName());
2725
+ } else {
2726
+ return null;
2417
2727
  }
2418
- this.removeDropHint();
2419
- node_element = this.tree_widget._getNodeElementForNode(this.hovered_area.node);
2420
- return this.previous_ghost = node_element.addDropHint(this.hovered_area.position);
2421
2728
  };
2422
2729
 
2423
- DragAndDropHandler.prototype.startOpenFolderTimer = function(folder) {
2424
- var openFolder;
2425
- openFolder = (function(_this) {
2730
+ SaveStateHandler.prototype.getState = function() {
2731
+ var getOpenNodeIds, getSelectedNodeIds;
2732
+ getOpenNodeIds = (function(_this) {
2426
2733
  return function() {
2427
- return _this.tree_widget._openNode(folder, _this.tree_widget.options.slide, function() {
2428
- _this.refresh();
2429
- return _this.updateDropHint();
2734
+ var open_nodes;
2735
+ open_nodes = [];
2736
+ _this.tree_widget.tree.iterate(function(node) {
2737
+ if (node.is_open && node.id && node.hasChildren()) {
2738
+ open_nodes.push(node.id);
2739
+ }
2740
+ return true;
2430
2741
  });
2742
+ return open_nodes;
2431
2743
  };
2432
2744
  })(this);
2433
- this.stopOpenFolderTimer();
2434
- return this.open_folder_timer = setTimeout(openFolder, this.tree_widget.options.openFolderDelay);
2745
+ getSelectedNodeIds = (function(_this) {
2746
+ return function() {
2747
+ var n;
2748
+ return (function() {
2749
+ var _i, _len, _ref, _results;
2750
+ _ref = this.tree_widget.getSelectedNodes();
2751
+ _results = [];
2752
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
2753
+ n = _ref[_i];
2754
+ _results.push(n.id);
2755
+ }
2756
+ return _results;
2757
+ }).call(_this);
2758
+ };
2759
+ })(this);
2760
+ return {
2761
+ open_nodes: getOpenNodeIds(),
2762
+ selected_node: getSelectedNodeIds()
2763
+ };
2435
2764
  };
2436
2765
 
2437
- DragAndDropHandler.prototype.stopOpenFolderTimer = function() {
2438
- if (this.open_folder_timer) {
2439
- clearTimeout(this.open_folder_timer);
2440
- return this.open_folder_timer = null;
2766
+ SaveStateHandler.prototype.setInitialState = function(state) {
2767
+ var must_load_on_demand;
2768
+ if (!state) {
2769
+ return false;
2770
+ } else {
2771
+ must_load_on_demand = this._openInitialNodes(state.open_nodes);
2772
+ this._selectInitialNodes(state.selected_node);
2773
+ return must_load_on_demand;
2441
2774
  }
2442
2775
  };
2443
2776
 
2444
- DragAndDropHandler.prototype.moveItem = function(position_info) {
2445
- var doMove, event, moved_node, position, previous_parent, target_node;
2446
- if (this.hovered_area && this.hovered_area.position !== Position.NONE && this.canMoveToArea(this.hovered_area)) {
2447
- moved_node = this.current_item.node;
2448
- target_node = this.hovered_area.node;
2449
- position = this.hovered_area.position;
2450
- previous_parent = moved_node.parent;
2451
- if (position === Position.INSIDE) {
2452
- this.hovered_area.node.is_open = true;
2453
- }
2454
- doMove = (function(_this) {
2455
- return function() {
2456
- _this.tree_widget.tree.moveNode(moved_node, target_node, position);
2457
- _this.tree_widget.element.empty();
2458
- return _this.tree_widget._refreshElements();
2459
- };
2460
- })(this);
2461
- event = this.tree_widget._triggerEvent('tree.move', {
2462
- move_info: {
2463
- moved_node: moved_node,
2464
- target_node: target_node,
2465
- position: Position.getName(position),
2466
- previous_parent: previous_parent,
2467
- do_move: doMove,
2468
- original_event: position_info.original_event
2777
+ SaveStateHandler.prototype._openInitialNodes = function(node_ids) {
2778
+ var must_load_on_demand, node, node_id, _i, _len;
2779
+ must_load_on_demand = false;
2780
+ for (_i = 0, _len = node_ids.length; _i < _len; _i++) {
2781
+ node_id = node_ids[_i];
2782
+ node = this.tree_widget.getNodeById(node_id);
2783
+ if (node) {
2784
+ if (!node.load_on_demand) {
2785
+ node.is_open = true;
2786
+ } else {
2787
+ must_load_on_demand = true;
2469
2788
  }
2470
- });
2471
- if (!event.isDefaultPrevented()) {
2472
- return doMove();
2473
2789
  }
2474
2790
  }
2791
+ return must_load_on_demand;
2475
2792
  };
2476
2793
 
2477
- DragAndDropHandler.prototype.getTreeDimensions = function() {
2478
- var offset;
2479
- offset = this.tree_widget.element.offset();
2480
- return {
2481
- left: offset.left,
2482
- top: offset.top,
2483
- right: offset.left + this.tree_widget.element.width(),
2484
- bottom: offset.top + this.tree_widget.element.height() + 16
2485
- };
2794
+ SaveStateHandler.prototype._selectInitialNodes = function(node_ids) {
2795
+ var node, node_id, select_count, _i, _len;
2796
+ select_count = 0;
2797
+ for (_i = 0, _len = node_ids.length; _i < _len; _i++) {
2798
+ node_id = node_ids[_i];
2799
+ node = this.tree_widget.getNodeById(node_id);
2800
+ if (node) {
2801
+ select_count += 1;
2802
+ this.tree_widget.select_node_handler.addToSelection(node);
2803
+ }
2804
+ }
2805
+ return select_count !== 0;
2486
2806
  };
2487
2807
 
2488
- return DragAndDropHandler;
2489
-
2490
- })();
2491
-
2492
- VisibleNodeIterator = (function() {
2493
- function VisibleNodeIterator(tree) {
2494
- this.tree = tree;
2495
- }
2808
+ SaveStateHandler.prototype.setInitialStateOnDemand = function(state) {
2809
+ if (state) {
2810
+ return this._setInitialStateOnDemand(state.open_nodes, state.selected_node);
2811
+ }
2812
+ };
2496
2813
 
2497
- VisibleNodeIterator.prototype.iterate = function() {
2498
- var is_first_node, _iterateNode;
2499
- is_first_node = true;
2500
- _iterateNode = (function(_this) {
2501
- return function(node, next_node) {
2502
- var $element, child, children_length, i, must_iterate_inside, _i, _len, _ref;
2503
- must_iterate_inside = (node.is_open || !node.element) && node.hasChildren();
2504
- if (node.element) {
2505
- $element = $(node.element);
2506
- if (!$element.is(':visible')) {
2507
- return;
2508
- }
2509
- if (is_first_node) {
2510
- _this.handleFirstNode(node, $element);
2511
- is_first_node = false;
2512
- }
2513
- if (!node.hasChildren()) {
2514
- _this.handleNode(node, next_node, $element);
2515
- } else if (node.is_open) {
2516
- if (!_this.handleOpenFolder(node, $element)) {
2517
- must_iterate_inside = false;
2518
- }
2814
+ SaveStateHandler.prototype._setInitialStateOnDemand = function(node_ids, selected_nodes) {
2815
+ var loadAndOpenNode, openNodes;
2816
+ openNodes = (function(_this) {
2817
+ return function() {
2818
+ var new_nodes_ids, node, node_id, _i, _len;
2819
+ new_nodes_ids = [];
2820
+ for (_i = 0, _len = node_ids.length; _i < _len; _i++) {
2821
+ node_id = node_ids[_i];
2822
+ node = _this.tree_widget.getNodeById(node_id);
2823
+ if (!node) {
2824
+ new_nodes_ids.push(node_id);
2519
2825
  } else {
2520
- _this.handleClosedFolder(node, next_node, $element);
2521
- }
2522
- }
2523
- if (must_iterate_inside) {
2524
- children_length = node.children.length;
2525
- _ref = node.children;
2526
- for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) {
2527
- child = _ref[i];
2528
- if (i === (children_length - 1)) {
2529
- _iterateNode(node.children[i], null);
2530
- } else {
2531
- _iterateNode(node.children[i], node.children[i + 1]);
2826
+ if (!node.is_loading) {
2827
+ if (node.load_on_demand) {
2828
+ loadAndOpenNode(node);
2829
+ } else {
2830
+ _this.tree_widget._openNode(node, false);
2831
+ }
2532
2832
  }
2533
2833
  }
2534
- if (node.is_open) {
2535
- return _this.handleAfterOpenFolder(node, next_node, $element);
2536
- }
2834
+ }
2835
+ node_ids = new_nodes_ids;
2836
+ if (_this._selectInitialNodes(selected_nodes)) {
2837
+ return _this.tree_widget._refreshElements();
2537
2838
  }
2538
2839
  };
2539
2840
  })(this);
2540
- return _iterateNode(this.tree, null);
2841
+ loadAndOpenNode = (function(_this) {
2842
+ return function(node) {
2843
+ return _this.tree_widget._openNode(node, false, openNodes);
2844
+ };
2845
+ })(this);
2846
+ return openNodes();
2847
+ };
2848
+
2849
+ SaveStateHandler.prototype.getCookieName = function() {
2850
+ if (typeof this.tree_widget.options.saveState === 'string') {
2851
+ return this.tree_widget.options.saveState;
2852
+ } else {
2853
+ return 'tree';
2854
+ }
2855
+ };
2856
+
2857
+ SaveStateHandler.prototype.supportsLocalStorage = function() {
2858
+ var testSupport;
2859
+ testSupport = function() {
2860
+ var error, key;
2861
+ if (typeof localStorage === "undefined" || localStorage === null) {
2862
+ return false;
2863
+ } else {
2864
+ try {
2865
+ key = '_storage_test';
2866
+ sessionStorage.setItem(key, true);
2867
+ sessionStorage.removeItem(key);
2868
+ } catch (_error) {
2869
+ error = _error;
2870
+ return false;
2871
+ }
2872
+ return true;
2873
+ }
2874
+ };
2875
+ if (this._supportsLocalStorage == null) {
2876
+ this._supportsLocalStorage = testSupport();
2877
+ }
2878
+ return this._supportsLocalStorage;
2541
2879
  };
2542
2880
 
2543
- VisibleNodeIterator.prototype.handleNode = function(node, next_node, $element) {};
2544
-
2545
- VisibleNodeIterator.prototype.handleOpenFolder = function(node, $element) {};
2546
-
2547
- VisibleNodeIterator.prototype.handleClosedFolder = function(node, next_node, $element) {};
2881
+ SaveStateHandler.prototype.getNodeIdToBeSelected = function() {
2882
+ var state;
2883
+ state = this.getStateFromStorage();
2884
+ if (state && state.selected_node) {
2885
+ return state.selected_node[0];
2886
+ } else {
2887
+ return null;
2888
+ }
2889
+ };
2548
2890
 
2549
- VisibleNodeIterator.prototype.handleAfterOpenFolder = function(node, next_node, $element) {};
2891
+ return SaveStateHandler;
2550
2892
 
2551
- VisibleNodeIterator.prototype.handleFirstNode = function(node, $element) {};
2893
+ })();
2552
2894
 
2553
- return VisibleNodeIterator;
2895
+ module.exports = SaveStateHandler;
2554
2896
 
2555
- })();
2897
+ }).call(this);
2556
2898
 
2557
- HitAreasGenerator = (function(_super) {
2558
- __extends(HitAreasGenerator, _super);
2899
+ },{"./util":12}],9:[function(require,module,exports){
2900
+ (function() {
2901
+ var ScrollHandler;
2559
2902
 
2560
- function HitAreasGenerator(tree, current_node, tree_bottom) {
2561
- HitAreasGenerator.__super__.constructor.call(this, tree);
2562
- this.current_node = current_node;
2563
- this.tree_bottom = tree_bottom;
2903
+ ScrollHandler = (function() {
2904
+ function ScrollHandler(tree_widget) {
2905
+ this.tree_widget = tree_widget;
2906
+ this.previous_top = -1;
2907
+ this._initScrollParent();
2564
2908
  }
2565
2909
 
2566
- HitAreasGenerator.prototype.generate = function() {
2567
- this.positions = [];
2568
- this.last_top = 0;
2569
- this.iterate();
2570
- return this.generateHitAreas(this.positions);
2571
- };
2572
-
2573
- HitAreasGenerator.prototype.getTop = function($element) {
2574
- return $element.offset().top;
2910
+ ScrollHandler.prototype._initScrollParent = function() {
2911
+ var $scroll_parent, getParentWithOverflow, setDocumentAsScrollParent;
2912
+ getParentWithOverflow = (function(_this) {
2913
+ return function() {
2914
+ var css_values, el, hasOverFlow, _i, _len, _ref;
2915
+ css_values = ['overflow', 'overflow-y'];
2916
+ hasOverFlow = function(el) {
2917
+ var css_value, _i, _len, _ref;
2918
+ for (_i = 0, _len = css_values.length; _i < _len; _i++) {
2919
+ css_value = css_values[_i];
2920
+ if ((_ref = $.css(el, css_value)) === 'auto' || _ref === 'scroll') {
2921
+ return true;
2922
+ }
2923
+ }
2924
+ return false;
2925
+ };
2926
+ if (hasOverFlow(_this.tree_widget.$el[0])) {
2927
+ return _this.tree_widget.$el;
2928
+ }
2929
+ _ref = _this.tree_widget.$el.parents();
2930
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
2931
+ el = _ref[_i];
2932
+ if (hasOverFlow(el)) {
2933
+ return $(el);
2934
+ }
2935
+ }
2936
+ return null;
2937
+ };
2938
+ })(this);
2939
+ setDocumentAsScrollParent = (function(_this) {
2940
+ return function() {
2941
+ _this.scroll_parent_top = 0;
2942
+ return _this.$scroll_parent = null;
2943
+ };
2944
+ })(this);
2945
+ if (this.tree_widget.$el.css('position') === 'fixed') {
2946
+ setDocumentAsScrollParent();
2947
+ }
2948
+ $scroll_parent = getParentWithOverflow();
2949
+ if ($scroll_parent && $scroll_parent.length && $scroll_parent[0].tagName !== 'HTML') {
2950
+ this.$scroll_parent = $scroll_parent;
2951
+ return this.scroll_parent_top = this.$scroll_parent.offset().top;
2952
+ } else {
2953
+ return setDocumentAsScrollParent();
2954
+ }
2575
2955
  };
2576
2956
 
2577
- HitAreasGenerator.prototype.addPosition = function(node, position, top) {
2578
- var area;
2579
- area = {
2580
- top: top,
2581
- node: node,
2582
- position: position
2583
- };
2584
- this.positions.push(area);
2585
- return this.last_top = top;
2957
+ ScrollHandler.prototype.checkScrolling = function() {
2958
+ var hovered_area;
2959
+ hovered_area = this.tree_widget.dnd_handler.hovered_area;
2960
+ if (hovered_area && hovered_area.top !== this.previous_top) {
2961
+ this.previous_top = hovered_area.top;
2962
+ if (this.$scroll_parent) {
2963
+ return this._handleScrollingWithScrollParent(hovered_area);
2964
+ } else {
2965
+ return this._handleScrollingWithDocument(hovered_area);
2966
+ }
2967
+ }
2586
2968
  };
2587
2969
 
2588
- HitAreasGenerator.prototype.handleNode = function(node, next_node, $element) {
2589
- var top;
2590
- top = this.getTop($element);
2591
- if (node === this.current_node) {
2592
- this.addPosition(node, Position.NONE, top);
2593
- } else {
2594
- this.addPosition(node, Position.INSIDE, top);
2595
- }
2596
- if (next_node === this.current_node || node === this.current_node) {
2597
- return this.addPosition(node, Position.NONE, top);
2598
- } else {
2599
- return this.addPosition(node, Position.AFTER, top);
2970
+ ScrollHandler.prototype._handleScrollingWithScrollParent = function(area) {
2971
+ var distance_bottom;
2972
+ distance_bottom = this.scroll_parent_top + this.$scroll_parent[0].offsetHeight - area.bottom;
2973
+ if (distance_bottom < 20) {
2974
+ this.$scroll_parent[0].scrollTop += 20;
2975
+ this.tree_widget.refreshHitAreas();
2976
+ return this.previous_top = -1;
2977
+ } else if ((area.top - this.scroll_parent_top) < 20) {
2978
+ this.$scroll_parent[0].scrollTop -= 20;
2979
+ this.tree_widget.refreshHitAreas();
2980
+ return this.previous_top = -1;
2600
2981
  }
2601
2982
  };
2602
2983
 
2603
- HitAreasGenerator.prototype.handleOpenFolder = function(node, $element) {
2604
- if (node === this.current_node) {
2605
- return false;
2606
- }
2607
- if (node.children[0] !== this.current_node) {
2608
- this.addPosition(node, Position.INSIDE, this.getTop($element));
2984
+ ScrollHandler.prototype._handleScrollingWithDocument = function(area) {
2985
+ var distance_top;
2986
+ distance_top = area.top - $(document).scrollTop();
2987
+ if (distance_top < 20) {
2988
+ return $(document).scrollTop($(document).scrollTop() - 20);
2989
+ } else if ($(window).height() - (area.bottom - $(document).scrollTop()) < 20) {
2990
+ return $(document).scrollTop($(document).scrollTop() + 20);
2609
2991
  }
2610
- return true;
2611
2992
  };
2612
2993
 
2613
- HitAreasGenerator.prototype.handleClosedFolder = function(node, next_node, $element) {
2614
- var top;
2615
- top = this.getTop($element);
2616
- if (node === this.current_node) {
2617
- return this.addPosition(node, Position.NONE, top);
2994
+ ScrollHandler.prototype.scrollTo = function(top) {
2995
+ var tree_top;
2996
+ if (this.$scroll_parent) {
2997
+ return this.$scroll_parent[0].scrollTop = top;
2618
2998
  } else {
2619
- this.addPosition(node, Position.INSIDE, top);
2620
- if (next_node !== this.current_node) {
2621
- return this.addPosition(node, Position.AFTER, top);
2622
- }
2999
+ tree_top = this.tree_widget.$el.offset().top;
3000
+ return $(document).scrollTop(top + tree_top);
2623
3001
  }
2624
3002
  };
2625
3003
 
2626
- HitAreasGenerator.prototype.handleFirstNode = function(node, $element) {
2627
- if (node !== this.current_node) {
2628
- return this.addPosition(node, Position.BEFORE, this.getTop($(node.element)));
3004
+ ScrollHandler.prototype.isScrolledIntoView = function(element) {
3005
+ var $element, element_bottom, element_top, view_bottom, view_top;
3006
+ $element = $(element);
3007
+ if (this.$scroll_parent) {
3008
+ view_top = 0;
3009
+ view_bottom = this.$scroll_parent.height();
3010
+ element_top = $element.offset().top - this.scroll_parent_top;
3011
+ element_bottom = element_top + $element.height();
3012
+ } else {
3013
+ view_top = $(window).scrollTop();
3014
+ view_bottom = view_top + $(window).height();
3015
+ element_top = $element.offset().top;
3016
+ element_bottom = element_top + $element.height();
2629
3017
  }
3018
+ return (element_bottom <= view_bottom) && (element_top >= view_top);
2630
3019
  };
2631
3020
 
2632
- HitAreasGenerator.prototype.handleAfterOpenFolder = function(node, next_node, $element) {
2633
- if (node === this.current_node.node || next_node === this.current_node.node) {
2634
- return this.addPosition(node, Position.NONE, this.last_top);
3021
+ return ScrollHandler;
3022
+
3023
+ })();
3024
+
3025
+ module.exports = ScrollHandler;
3026
+
3027
+ }).call(this);
3028
+
3029
+ },{}],10:[function(require,module,exports){
3030
+ (function() {
3031
+ var SelectNodeHandler;
3032
+
3033
+ SelectNodeHandler = (function() {
3034
+ function SelectNodeHandler(tree_widget) {
3035
+ this.tree_widget = tree_widget;
3036
+ this.clear();
3037
+ }
3038
+
3039
+ SelectNodeHandler.prototype.getSelectedNode = function() {
3040
+ var selected_nodes;
3041
+ selected_nodes = this.getSelectedNodes();
3042
+ if (selected_nodes.length) {
3043
+ return selected_nodes[0];
2635
3044
  } else {
2636
- return this.addPosition(node, Position.AFTER, this.last_top);
3045
+ return false;
2637
3046
  }
2638
3047
  };
2639
3048
 
2640
- HitAreasGenerator.prototype.generateHitAreas = function(positions) {
2641
- var group, hit_areas, position, previous_top, _i, _len;
2642
- previous_top = -1;
2643
- group = [];
2644
- hit_areas = [];
2645
- for (_i = 0, _len = positions.length; _i < _len; _i++) {
2646
- position = positions[_i];
2647
- if (position.top !== previous_top && group.length) {
2648
- if (group.length) {
2649
- this.generateHitAreasForGroup(hit_areas, group, previous_top, position.top);
3049
+ SelectNodeHandler.prototype.getSelectedNodes = function() {
3050
+ var id, node, selected_nodes;
3051
+ if (this.selected_single_node) {
3052
+ return [this.selected_single_node];
3053
+ } else {
3054
+ selected_nodes = [];
3055
+ for (id in this.selected_nodes) {
3056
+ node = this.tree_widget.getNodeById(id);
3057
+ if (node) {
3058
+ selected_nodes.push(node);
2650
3059
  }
2651
- previous_top = position.top;
2652
- group = [];
2653
3060
  }
2654
- group.push(position);
3061
+ return selected_nodes;
2655
3062
  }
2656
- this.generateHitAreasForGroup(hit_areas, group, previous_top, this.tree_bottom);
2657
- return hit_areas;
2658
3063
  };
2659
3064
 
2660
- HitAreasGenerator.prototype.generateHitAreasForGroup = function(hit_areas, positions_in_group, top, bottom) {
2661
- var area_height, area_top, i, position, position_count;
2662
- position_count = Math.min(positions_in_group.length, 4);
2663
- area_height = Math.round((bottom - top) / position_count);
2664
- area_top = top;
2665
- i = 0;
2666
- while (i < position_count) {
2667
- position = positions_in_group[i];
2668
- hit_areas.push({
2669
- top: area_top,
2670
- bottom: area_top + area_height,
2671
- node: position.node,
2672
- position: position.position
2673
- });
2674
- area_top += area_height;
2675
- i += 1;
3065
+ SelectNodeHandler.prototype.getSelectedNodesUnder = function(parent) {
3066
+ var id, node, selected_nodes;
3067
+ if (this.selected_single_node) {
3068
+ if (parent.isParentOf(this.selected_single_node)) {
3069
+ return [this.selected_single_node];
3070
+ } else {
3071
+ return [];
3072
+ }
3073
+ } else {
3074
+ selected_nodes = [];
3075
+ for (id in this.selected_nodes) {
3076
+ node = this.tree_widget.getNodeById(id);
3077
+ if (node && parent.isParentOf(node)) {
3078
+ selected_nodes.push(node);
3079
+ }
3080
+ }
3081
+ return selected_nodes;
2676
3082
  }
2677
- return null;
2678
3083
  };
2679
3084
 
2680
- return HitAreasGenerator;
2681
-
2682
- })(VisibleNodeIterator);
3085
+ SelectNodeHandler.prototype.isNodeSelected = function(node) {
3086
+ if (node.id) {
3087
+ return this.selected_nodes[node.id];
3088
+ } else if (this.selected_single_node) {
3089
+ return this.selected_single_node.element === node.element;
3090
+ } else {
3091
+ return false;
3092
+ }
3093
+ };
2683
3094
 
2684
- DragElement = (function() {
2685
- function DragElement(node, offset_x, offset_y, $tree) {
2686
- this.offset_x = offset_x;
2687
- this.offset_y = offset_y;
2688
- this.$element = $("<span class=\"jqtree-title jqtree-dragging\">" + node.name + "</span>");
2689
- this.$element.css("position", "absolute");
2690
- $tree.append(this.$element);
2691
- }
3095
+ SelectNodeHandler.prototype.clear = function() {
3096
+ this.selected_nodes = {};
3097
+ return this.selected_single_node = null;
3098
+ };
2692
3099
 
2693
- DragElement.prototype.move = function(page_x, page_y) {
2694
- return this.$element.offset({
2695
- left: page_x - this.offset_x,
2696
- top: page_y - this.offset_y
2697
- });
3100
+ SelectNodeHandler.prototype.removeFromSelection = function(node, include_children) {
3101
+ if (include_children == null) {
3102
+ include_children = false;
3103
+ }
3104
+ if (!node.id) {
3105
+ if (this.selected_single_node && node.element === this.selected_single_node.element) {
3106
+ return this.selected_single_node = null;
3107
+ }
3108
+ } else {
3109
+ delete this.selected_nodes[node.id];
3110
+ if (include_children) {
3111
+ return node.iterate((function(_this) {
3112
+ return function(n) {
3113
+ delete _this.selected_nodes[node.id];
3114
+ return true;
3115
+ };
3116
+ })(this));
3117
+ }
3118
+ }
2698
3119
  };
2699
3120
 
2700
- DragElement.prototype.remove = function() {
2701
- return this.$element.remove();
3121
+ SelectNodeHandler.prototype.addToSelection = function(node) {
3122
+ if (node.id) {
3123
+ return this.selected_nodes[node.id] = true;
3124
+ } else {
3125
+ return this.selected_single_node = node;
3126
+ }
2702
3127
  };
2703
3128
 
2704
- return DragElement;
3129
+ return SelectNodeHandler;
2705
3130
 
2706
3131
  })();
2707
3132
 
2708
- GhostDropHint = (function() {
2709
- function GhostDropHint(node, $element, position) {
2710
- this.$element = $element;
2711
- this.node = node;
2712
- this.$ghost = $('<li class="jqtree_common jqtree-ghost"><span class="jqtree_common jqtree-circle"></span><span class="jqtree_common jqtree-line"></span></li>');
2713
- if (position === Position.AFTER) {
2714
- this.moveAfter();
2715
- } else if (position === Position.BEFORE) {
2716
- this.moveBefore();
2717
- } else if (position === Position.INSIDE) {
2718
- if (node.isFolder() && node.is_open) {
2719
- this.moveInsideOpenFolder();
2720
- } else {
2721
- this.moveInside();
2722
- }
2723
- }
2724
- }
3133
+ module.exports = SelectNodeHandler;
2725
3134
 
2726
- GhostDropHint.prototype.remove = function() {
2727
- return this.$ghost.remove();
2728
- };
3135
+ }).call(this);
2729
3136
 
2730
- GhostDropHint.prototype.moveAfter = function() {
2731
- return this.$element.after(this.$ghost);
2732
- };
3137
+ },{}],11:[function(require,module,exports){
2733
3138
 
2734
- GhostDropHint.prototype.moveBefore = function() {
2735
- return this.$element.before(this.$ghost);
2736
- };
3139
+ /*
3140
+ Copyright 2013 Marco Braak
2737
3141
 
2738
- GhostDropHint.prototype.moveInsideOpenFolder = function() {
2739
- return $(this.node.children[0].element).before(this.$ghost);
2740
- };
3142
+ Licensed under the Apache License, Version 2.0 (the "License");
3143
+ you may not use this file except in compliance with the License.
3144
+ You may obtain a copy of the License at
2741
3145
 
2742
- GhostDropHint.prototype.moveInside = function() {
2743
- this.$element.after(this.$ghost);
2744
- return this.$ghost.addClass('jqtree-inside');
2745
- };
3146
+ http://www.apache.org/licenses/LICENSE-2.0
2746
3147
 
2747
- return GhostDropHint;
3148
+ Unless required by applicable law or agreed to in writing, software
3149
+ distributed under the License is distributed on an "AS IS" BASIS,
3150
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3151
+ See the License for the specific language governing permissions and
3152
+ limitations under the License.
3153
+ */
2748
3154
 
2749
- })();
3155
+ (function() {
3156
+ var SimpleWidget,
3157
+ __slice = [].slice;
2750
3158
 
2751
- BorderDropHint = (function() {
2752
- function BorderDropHint($element) {
2753
- var $div, width;
2754
- $div = $element.children('.jqtree-element');
2755
- width = $element.width() - 4;
2756
- this.$hint = $('<span class="jqtree-border"></span>');
2757
- $div.append(this.$hint);
2758
- this.$hint.css({
2759
- width: width,
2760
- height: $div.height() - 4
2761
- });
3159
+ SimpleWidget = (function() {
3160
+ SimpleWidget.prototype.defaults = {};
3161
+
3162
+ function SimpleWidget(el, options) {
3163
+ this.$el = $(el);
3164
+ this.options = $.extend({}, this.defaults, options);
2762
3165
  }
2763
3166
 
2764
- BorderDropHint.prototype.remove = function() {
2765
- return this.$hint.remove();
3167
+ SimpleWidget.prototype.destroy = function() {
3168
+ return this._deinit();
2766
3169
  };
2767
3170
 
2768
- return BorderDropHint;
2769
-
2770
- })();
3171
+ SimpleWidget.prototype._init = function() {
3172
+ return null;
3173
+ };
2771
3174
 
2772
- ScrollHandler = (function() {
2773
- function ScrollHandler(tree_widget) {
2774
- this.tree_widget = tree_widget;
2775
- this.previous_top = -1;
2776
- this._initScrollParent();
2777
- }
3175
+ SimpleWidget.prototype._deinit = function() {
3176
+ return null;
3177
+ };
2778
3178
 
2779
- ScrollHandler.prototype._initScrollParent = function() {
2780
- var $scroll_parent, getParentWithOverflow, setDocumentAsScrollParent;
2781
- getParentWithOverflow = (function(_this) {
2782
- return function() {
2783
- var css_values, el, hasOverFlow, _i, _len, _ref;
2784
- css_values = ['overflow', 'overflow-y'];
2785
- hasOverFlow = function(el) {
2786
- var css_value, _i, _len, _ref;
2787
- for (_i = 0, _len = css_values.length; _i < _len; _i++) {
2788
- css_value = css_values[_i];
2789
- if ((_ref = $.css(el, css_value)) === 'auto' || _ref === 'scroll') {
2790
- return true;
2791
- }
3179
+ SimpleWidget.register = function(widget_class, widget_name) {
3180
+ var callFunction, createWidget, destroyWidget, getDataKey, getWidgetData;
3181
+ getDataKey = function() {
3182
+ return "simple_widget_" + widget_name;
3183
+ };
3184
+ getWidgetData = function(el, data_key) {
3185
+ var widget;
3186
+ widget = $.data(el, data_key);
3187
+ if (widget && (widget instanceof SimpleWidget)) {
3188
+ return widget;
3189
+ } else {
3190
+ return null;
3191
+ }
3192
+ };
3193
+ createWidget = function($el, options) {
3194
+ var data_key, el, existing_widget, widget, _i, _len;
3195
+ data_key = getDataKey();
3196
+ for (_i = 0, _len = $el.length; _i < _len; _i++) {
3197
+ el = $el[_i];
3198
+ existing_widget = getWidgetData(el, data_key);
3199
+ if (!existing_widget) {
3200
+ widget = new widget_class(el, options);
3201
+ if (!$.data(el, data_key)) {
3202
+ $.data(el, data_key, widget);
2792
3203
  }
2793
- return false;
2794
- };
2795
- if (hasOverFlow(_this.tree_widget.$el[0])) {
2796
- return _this.tree_widget.$el;
3204
+ widget._init();
2797
3205
  }
2798
- _ref = _this.tree_widget.$el.parents();
2799
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
2800
- el = _ref[_i];
2801
- if (hasOverFlow(el)) {
2802
- return $(el);
3206
+ }
3207
+ return $el;
3208
+ };
3209
+ destroyWidget = function($el) {
3210
+ var data_key, el, widget, _i, _len, _results;
3211
+ data_key = getDataKey();
3212
+ _results = [];
3213
+ for (_i = 0, _len = $el.length; _i < _len; _i++) {
3214
+ el = $el[_i];
3215
+ widget = getWidgetData(el, data_key);
3216
+ if (widget) {
3217
+ widget.destroy();
3218
+ }
3219
+ _results.push($.removeData(el, data_key));
3220
+ }
3221
+ return _results;
3222
+ };
3223
+ callFunction = function($el, function_name, args) {
3224
+ var el, result, widget, widget_function, _i, _len;
3225
+ result = null;
3226
+ for (_i = 0, _len = $el.length; _i < _len; _i++) {
3227
+ el = $el[_i];
3228
+ widget = $.data(el, getDataKey());
3229
+ if (widget && (widget instanceof SimpleWidget)) {
3230
+ widget_function = widget[function_name];
3231
+ if (widget_function && (typeof widget_function === 'function')) {
3232
+ result = widget_function.apply(widget, args);
2803
3233
  }
2804
3234
  }
2805
- return null;
2806
- };
2807
- })(this);
2808
- setDocumentAsScrollParent = (function(_this) {
2809
- return function() {
2810
- _this.scroll_parent_top = 0;
2811
- return _this.$scroll_parent = null;
2812
- };
2813
- })(this);
2814
- if (this.tree_widget.$el.css('position') === 'fixed') {
2815
- setDocumentAsScrollParent();
2816
- }
2817
- $scroll_parent = getParentWithOverflow();
2818
- if ($scroll_parent && $scroll_parent.length && $scroll_parent[0].tagName !== 'HTML') {
2819
- this.$scroll_parent = $scroll_parent;
2820
- return this.scroll_parent_top = this.$scroll_parent.offset().top;
2821
- } else {
2822
- return setDocumentAsScrollParent();
2823
- }
2824
- };
2825
-
2826
- ScrollHandler.prototype.checkScrolling = function() {
2827
- var hovered_area;
2828
- hovered_area = this.tree_widget.dnd_handler.hovered_area;
2829
- if (hovered_area && hovered_area.top !== this.previous_top) {
2830
- this.previous_top = hovered_area.top;
2831
- if (this.$scroll_parent) {
2832
- return this._handleScrollingWithScrollParent(hovered_area);
2833
- } else {
2834
- return this._handleScrollingWithDocument(hovered_area);
2835
3235
  }
2836
- }
2837
- };
2838
-
2839
- ScrollHandler.prototype._handleScrollingWithScrollParent = function(area) {
2840
- var distance_bottom;
2841
- distance_bottom = this.scroll_parent_top + this.$scroll_parent[0].offsetHeight - area.bottom;
2842
- if (distance_bottom < 20) {
2843
- this.$scroll_parent[0].scrollTop += 20;
2844
- this.tree_widget.refreshHitAreas();
2845
- return this.previous_top = -1;
2846
- } else if ((area.top - this.scroll_parent_top) < 20) {
2847
- this.$scroll_parent[0].scrollTop -= 20;
2848
- this.tree_widget.refreshHitAreas();
2849
- return this.previous_top = -1;
2850
- }
2851
- };
2852
-
2853
- ScrollHandler.prototype._handleScrollingWithDocument = function(area) {
2854
- var distance_top;
2855
- distance_top = area.top - $(document).scrollTop();
2856
- if (distance_top < 20) {
2857
- return $(document).scrollTop($(document).scrollTop() - 20);
2858
- } else if ($(window).height() - (area.bottom - $(document).scrollTop()) < 20) {
2859
- return $(document).scrollTop($(document).scrollTop() + 20);
2860
- }
2861
- };
2862
-
2863
- ScrollHandler.prototype.scrollTo = function(top) {
2864
- var tree_top;
2865
- if (this.$scroll_parent) {
2866
- return this.$scroll_parent[0].scrollTop = top;
2867
- } else {
2868
- tree_top = this.tree_widget.$el.offset().top;
2869
- return $(document).scrollTop(top + tree_top);
2870
- }
2871
- };
2872
-
2873
- ScrollHandler.prototype.isScrolledIntoView = function(element) {
2874
- var $element, element_bottom, element_top, view_bottom, view_top;
2875
- $element = $(element);
2876
- if (this.$scroll_parent) {
2877
- view_top = 0;
2878
- view_bottom = this.$scroll_parent.height();
2879
- element_top = $element.offset().top - this.scroll_parent_top;
2880
- element_bottom = element_top + $element.height();
2881
- } else {
2882
- view_top = $(window).scrollTop();
2883
- view_bottom = view_top + $(window).height();
2884
- element_top = $element.offset().top;
2885
- element_bottom = element_top + $element.height();
2886
- }
2887
- return (element_bottom <= view_bottom) && (element_top >= view_top);
3236
+ return result;
3237
+ };
3238
+ return $.fn[widget_name] = function() {
3239
+ var $el, args, argument1, function_name, options;
3240
+ argument1 = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
3241
+ $el = this;
3242
+ if (argument1 === void 0 || typeof argument1 === 'object') {
3243
+ options = argument1;
3244
+ return createWidget($el, options);
3245
+ } else if (typeof argument1 === 'string' && argument1[0] !== '_') {
3246
+ function_name = argument1;
3247
+ if (function_name === 'destroy') {
3248
+ return destroyWidget($el);
3249
+ } else {
3250
+ return callFunction($el, function_name, args);
3251
+ }
3252
+ }
3253
+ };
2888
3254
  };
2889
3255
 
2890
- return ScrollHandler;
3256
+ return SimpleWidget;
2891
3257
 
2892
3258
  })();
2893
3259
 
2894
- KeyHandler = (function() {
2895
- var DOWN, LEFT, RIGHT, UP;
2896
-
2897
- LEFT = 37;
2898
-
2899
- UP = 38;
3260
+ module.exports = SimpleWidget;
2900
3261
 
2901
- RIGHT = 39;
3262
+ }).call(this);
2902
3263
 
2903
- DOWN = 40;
3264
+ },{}],12:[function(require,module,exports){
3265
+ (function() {
3266
+ var get_json_stringify_function, html_escape, indexOf, isInt, _indexOf;
2904
3267
 
2905
- function KeyHandler(tree_widget) {
2906
- this.tree_widget = tree_widget;
2907
- if (tree_widget.options.keyboardSupport) {
2908
- $(document).bind('keydown.jqtree', $.proxy(this.handleKeyDown, this));
3268
+ _indexOf = function(array, item) {
3269
+ var i, value, _i, _len;
3270
+ for (i = _i = 0, _len = array.length; _i < _len; i = ++_i) {
3271
+ value = array[i];
3272
+ if (value === item) {
3273
+ return i;
2909
3274
  }
2910
3275
  }
3276
+ return -1;
3277
+ };
2911
3278
 
2912
- KeyHandler.prototype.deinit = function() {
2913
- return $(document).unbind('keydown.jqtree');
2914
- };
3279
+ indexOf = function(array, item) {
3280
+ if (array.indexOf) {
3281
+ return array.indexOf(item);
3282
+ } else {
3283
+ return _indexOf(array, item);
3284
+ }
3285
+ };
2915
3286
 
2916
- KeyHandler.prototype.handleKeyDown = function(e) {
2917
- var current_node, key, moveDown, moveLeft, moveRight, moveUp, selectNode;
2918
- if (!this.tree_widget.options.keyboardSupport) {
2919
- return;
2920
- }
2921
- if ($(document.activeElement).is('textarea,input,select')) {
2922
- return true;
2923
- }
2924
- current_node = this.tree_widget.getSelectedNode();
2925
- selectNode = (function(_this) {
2926
- return function(node) {
2927
- if (node) {
2928
- _this.tree_widget.selectNode(node);
2929
- if (_this.tree_widget.scroll_handler && (!_this.tree_widget.scroll_handler.isScrolledIntoView($(node.element).find('.jqtree-element')))) {
2930
- _this.tree_widget.scrollToNode(node);
2931
- }
2932
- return false;
2933
- } else {
2934
- return true;
2935
- }
2936
- };
2937
- })(this);
2938
- moveDown = (function(_this) {
2939
- return function() {
2940
- return selectNode(_this.getNextNode(current_node));
2941
- };
2942
- })(this);
2943
- moveUp = (function(_this) {
2944
- return function() {
2945
- return selectNode(_this.getPreviousNode(current_node));
2946
- };
2947
- })(this);
2948
- moveRight = (function(_this) {
2949
- return function() {
2950
- if (current_node.isFolder() && !current_node.is_open) {
2951
- _this.tree_widget.openNode(current_node);
2952
- return false;
2953
- } else {
2954
- return true;
2955
- }
2956
- };
2957
- })(this);
2958
- moveLeft = (function(_this) {
2959
- return function() {
2960
- if (current_node.isFolder() && current_node.is_open) {
2961
- _this.tree_widget.closeNode(current_node);
2962
- return false;
2963
- } else {
2964
- return true;
2965
- }
2966
- };
2967
- })(this);
2968
- if (!current_node) {
2969
- return true;
2970
- } else {
2971
- key = e.which;
2972
- switch (key) {
2973
- case DOWN:
2974
- return moveDown();
2975
- case UP:
2976
- return moveUp();
2977
- case RIGHT:
2978
- return moveRight();
2979
- case LEFT:
2980
- return moveLeft();
2981
- }
2982
- }
2983
- };
3287
+ isInt = function(n) {
3288
+ return typeof n === 'number' && n % 1 === 0;
3289
+ };
2984
3290
 
2985
- KeyHandler.prototype.getNextNode = function(node, include_children) {
2986
- var next_sibling;
2987
- if (include_children == null) {
2988
- include_children = true;
2989
- }
2990
- if (include_children && node.hasChildren() && node.is_open) {
2991
- return node.children[0];
3291
+ get_json_stringify_function = function() {
3292
+ var json_escapable, json_meta, json_quote, json_str, stringify;
3293
+ json_escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
3294
+ json_meta = {
3295
+ '\b': '\\b',
3296
+ '\t': '\\t',
3297
+ '\n': '\\n',
3298
+ '\f': '\\f',
3299
+ '\r': '\\r',
3300
+ '"': '\\"',
3301
+ '\\': '\\\\'
3302
+ };
3303
+ json_quote = function(string) {
3304
+ json_escapable.lastIndex = 0;
3305
+ if (json_escapable.test(string)) {
3306
+ return '"' + string.replace(json_escapable, function(a) {
3307
+ var c;
3308
+ c = json_meta[a];
3309
+ return (typeof c === 'string' ? c : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4));
3310
+ }) + '"';
2992
3311
  } else {
2993
- if (!node.parent) {
2994
- return null;
2995
- } else {
2996
- next_sibling = node.getNextSibling();
2997
- if (next_sibling) {
2998
- return next_sibling;
2999
- } else {
3000
- return this.getNextNode(node.parent, false);
3001
- }
3002
- }
3312
+ return '"' + string + '"';
3003
3313
  }
3004
3314
  };
3005
-
3006
- KeyHandler.prototype.getPreviousNode = function(node) {
3007
- var previous_sibling;
3008
- if (!node.parent) {
3009
- return null;
3010
- } else {
3011
- previous_sibling = node.getPreviousSibling();
3012
- if (previous_sibling) {
3013
- if (!previous_sibling.hasChildren() || !previous_sibling.is_open) {
3014
- return previous_sibling;
3315
+ json_str = function(key, holder) {
3316
+ var i, k, partial, v, value, _i, _len;
3317
+ value = holder[key];
3318
+ switch (typeof value) {
3319
+ case 'string':
3320
+ return json_quote(value);
3321
+ case 'number':
3322
+ if (isFinite(value)) {
3323
+ return String(value);
3015
3324
  } else {
3016
- return this.getLastChild(previous_sibling);
3325
+ return 'null';
3017
3326
  }
3018
- } else {
3019
- if (node.parent.parent) {
3020
- return node.parent;
3021
- } else {
3022
- return null;
3327
+ case 'boolean':
3328
+ case 'null':
3329
+ return String(value);
3330
+ case 'object':
3331
+ if (!value) {
3332
+ return 'null';
3023
3333
  }
3024
- }
3334
+ partial = [];
3335
+ if (Object.prototype.toString.apply(value) === '[object Array]') {
3336
+ for (i = _i = 0, _len = value.length; _i < _len; i = ++_i) {
3337
+ v = value[i];
3338
+ partial[i] = json_str(i, value) || 'null';
3339
+ }
3340
+ return (partial.length === 0 ? '[]' : '[' + partial.join(',') + ']');
3341
+ }
3342
+ for (k in value) {
3343
+ if (Object.prototype.hasOwnProperty.call(value, k)) {
3344
+ v = json_str(k, value);
3345
+ if (v) {
3346
+ partial.push(json_quote(k) + ':' + v);
3347
+ }
3348
+ }
3349
+ }
3350
+ return (partial.length === 0 ? '{}' : '{' + partial.join(',') + '}');
3025
3351
  }
3026
3352
  };
3027
-
3028
- KeyHandler.prototype.getLastChild = function(node) {
3029
- var last_child;
3030
- if (!node.hasChildren()) {
3031
- return null;
3032
- } else {
3033
- last_child = node.children[node.children.length - 1];
3034
- if (!last_child.hasChildren() || !last_child.is_open) {
3035
- return last_child;
3036
- } else {
3037
- return this.getLastChild(last_child);
3038
- }
3039
- }
3353
+ stringify = function(value) {
3354
+ return json_str('', {
3355
+ '': value
3356
+ });
3040
3357
  };
3358
+ return stringify;
3359
+ };
3041
3360
 
3042
- return KeyHandler;
3361
+ if (!((this.JSON != null) && (this.JSON.stringify != null) && typeof this.JSON.stringify === 'function')) {
3362
+ if (this.JSON == null) {
3363
+ this.JSON = {};
3364
+ }
3365
+ this.JSON.stringify = get_json_stringify_function();
3366
+ }
3043
3367
 
3044
- })();
3368
+ html_escape = function(string) {
3369
+ return ('' + string).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#x27;').replace(/\//g, '&#x2F;');
3370
+ };
3371
+
3372
+ module.exports = {
3373
+ _indexOf: _indexOf,
3374
+ get_json_stringify_function: get_json_stringify_function,
3375
+ html_escape: html_escape,
3376
+ indexOf: indexOf,
3377
+ isInt: isInt
3378
+ };
3379
+
3380
+ }).call(this);
3381
+
3382
+ },{}],13:[function(require,module,exports){
3383
+ (function() {
3384
+ module.exports = '0.22.0';
3045
3385
 
3046
3386
  }).call(this);
3387
+
3388
+ },{}]},{},[3])