active_admin_pro 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (295) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +20 -0
  3. data/README.md +5 -0
  4. data/Rakefile +34 -0
  5. data/app/assets/javascripts/active_admin_pro.js +41 -0
  6. data/app/assets/javascripts/active_admin_pro/actions/new.js +8 -0
  7. data/app/assets/javascripts/active_admin_pro/actions/show.js +12 -0
  8. data/app/assets/javascripts/active_admin_pro/components/codemirror_input.js +92 -0
  9. data/app/assets/javascripts/active_admin_pro/components/flashes.js +9 -0
  10. data/app/assets/javascripts/active_admin_pro/components/link.js +23 -0
  11. data/app/assets/javascripts/active_admin_pro/components/phone_input.js +52 -0
  12. data/app/assets/javascripts/active_admin_pro/components/select_input.js +31 -0
  13. data/app/assets/javascripts/active_admin_pro/components/sortable_handle.js +8 -0
  14. data/app/assets/javascripts/active_admin_pro/components/summernote_input.js +132 -0
  15. data/app/assets/javascripts/active_admin_pro/components/text_input.js +47 -0
  16. data/app/assets/javascripts/active_admin_pro/components/time_zone_input.js +51 -0
  17. data/app/assets/javascripts/active_admin_pro/components/title_to_slug.js +16 -0
  18. data/app/assets/stylesheets/active_admin_pro.scss +20 -0
  19. data/app/assets/stylesheets/active_admin_pro/breakpoints.scss +3 -0
  20. data/app/assets/stylesheets/active_admin_pro/components/_input_variables.scss +9 -0
  21. data/app/assets/stylesheets/active_admin_pro/components/actions.scss +13 -0
  22. data/app/assets/stylesheets/active_admin_pro/components/boolean_input.scss +13 -0
  23. data/app/assets/stylesheets/active_admin_pro/components/button.scss +7 -0
  24. data/app/assets/stylesheets/active_admin_pro/components/check_boxes_input.scss +38 -0
  25. data/app/assets/stylesheets/active_admin_pro/components/codemirror_input.scss +53 -0
  26. data/app/assets/stylesheets/active_admin_pro/components/comments.scss +17 -0
  27. data/app/assets/stylesheets/active_admin_pro/components/datepicker.scss +108 -0
  28. data/app/assets/stylesheets/active_admin_pro/components/dialog.scss +66 -0
  29. data/app/assets/stylesheets/active_admin_pro/components/dropdown_menu_button.scss +40 -0
  30. data/app/assets/stylesheets/active_admin_pro/components/fieldset.scss +26 -0
  31. data/app/assets/stylesheets/active_admin_pro/components/file_input.scss +27 -0
  32. data/app/assets/stylesheets/active_admin_pro/components/has_many_fields.scss +4 -0
  33. data/app/assets/stylesheets/active_admin_pro/components/inline_errors.scss +7 -0
  34. data/app/assets/stylesheets/active_admin_pro/components/link.scss +16 -0
  35. data/app/assets/stylesheets/active_admin_pro/components/panel.scss +62 -0
  36. data/app/assets/stylesheets/active_admin_pro/components/phone_input.scss +31 -0
  37. data/app/assets/stylesheets/active_admin_pro/components/radio_input.scss +38 -0
  38. data/app/assets/stylesheets/active_admin_pro/components/segmented_control.scss +41 -0
  39. data/app/assets/stylesheets/active_admin_pro/components/select_input.scss +42 -0
  40. data/app/assets/stylesheets/active_admin_pro/components/sortable_handle.scss +21 -0
  41. data/app/assets/stylesheets/active_admin_pro/components/string_input.scss +85 -0
  42. data/app/assets/stylesheets/active_admin_pro/components/summernote_input.scss +190 -0
  43. data/app/assets/stylesheets/active_admin_pro/components/table.scss +100 -0
  44. data/app/assets/stylesheets/active_admin_pro/components/text_input.scss +55 -0
  45. data/app/assets/stylesheets/active_admin_pro/functions/color.scss +130 -0
  46. data/app/assets/stylesheets/active_admin_pro/functions/text-color.scss +35 -0
  47. data/app/assets/stylesheets/active_admin_pro/layout/actions/comments.scss +14 -0
  48. data/app/assets/stylesheets/active_admin_pro/layout/actions/index.scss +88 -0
  49. data/app/assets/stylesheets/active_admin_pro/layout/actions/show.scss +25 -0
  50. data/app/assets/stylesheets/active_admin_pro/layout/body.scss +60 -0
  51. data/app/assets/stylesheets/active_admin_pro/layout/desktop/action_items.scss +32 -0
  52. data/app/assets/stylesheets/active_admin_pro/layout/desktop/actions/comments.scss +10 -0
  53. data/app/assets/stylesheets/active_admin_pro/layout/desktop/active_admin_content.scss +22 -0
  54. data/app/assets/stylesheets/active_admin_pro/layout/desktop/breadcrumbs.scss +57 -0
  55. data/app/assets/stylesheets/active_admin_pro/layout/desktop/navigation.scss +197 -0
  56. data/app/assets/stylesheets/active_admin_pro/layout/desktop/sidebar.scss +5 -0
  57. data/app/assets/stylesheets/active_admin_pro/layout/desktop/title_bar.scss +24 -0
  58. data/app/assets/stylesheets/active_admin_pro/layout/desktop/wrapper.scss +5 -0
  59. data/app/assets/stylesheets/active_admin_pro/layout/filters.scss +41 -0
  60. data/app/assets/stylesheets/active_admin_pro/layout/flashes.scss +52 -0
  61. data/app/assets/stylesheets/active_admin_pro/layout/footer.scss +3 -0
  62. data/app/assets/stylesheets/active_admin_pro/layout/mobile/actions/index.scss +7 -0
  63. data/app/assets/stylesheets/active_admin_pro/layout/tablet/actions/dashboard.scss +105 -0
  64. data/app/assets/stylesheets/active_admin_pro/layout/tablet/actions/index.scss +20 -0
  65. data/app/assets/stylesheets/active_admin_pro/layout/tablet/actions/show.scss +78 -0
  66. data/app/assets/stylesheets/active_admin_pro/layout/tablet/active_admin_content.scss +9 -0
  67. data/app/assets/stylesheets/active_admin_pro/layout/tablet/flashes.scss +5 -0
  68. data/app/assets/stylesheets/active_admin_pro/layout/tablet/navigation.scss +48 -0
  69. data/app/assets/stylesheets/active_admin_pro/layout/tablet/title_bar.scss +53 -0
  70. data/app/assets/stylesheets/active_admin_pro/mixins/button.scss +48 -0
  71. data/app/assets/stylesheets/active_admin_pro/variables.scss +10 -0
  72. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon.scss +87 -0
  73. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/_bourbon-deprecated-upcoming.scss +411 -0
  74. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/addons/_border-color.scss +26 -0
  75. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/addons/_border-radius.scss +48 -0
  76. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/addons/_border-style.scss +25 -0
  77. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/addons/_border-width.scss +25 -0
  78. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/addons/_buttons.scss +64 -0
  79. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/addons/_clearfix.scss +25 -0
  80. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/addons/_ellipsis.scss +30 -0
  81. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/addons/_font-stacks.scss +31 -0
  82. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/addons/_hide-text.scss +27 -0
  83. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/addons/_margin.scss +26 -0
  84. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/addons/_padding.scss +26 -0
  85. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/addons/_position.scss +48 -0
  86. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/addons/_prefixer.scss +66 -0
  87. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/addons/_retina-image.scss +25 -0
  88. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/addons/_size.scss +51 -0
  89. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/addons/_text-inputs.scss +113 -0
  90. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/addons/_timing-functions.scss +34 -0
  91. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/addons/_triangle.scss +63 -0
  92. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/addons/_word-wrap.scss +29 -0
  93. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/css3/_animation.scss +43 -0
  94. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/css3/_appearance.scss +3 -0
  95. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/css3/_backface-visibility.scss +3 -0
  96. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/css3/_background-image.scss +42 -0
  97. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/css3/_background.scss +55 -0
  98. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/css3/_border-image.scss +59 -0
  99. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/css3/_calc.scss +4 -0
  100. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/css3/_columns.scss +47 -0
  101. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/css3/_filter.scss +4 -0
  102. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/css3/_flex-box.scss +287 -0
  103. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/css3/_font-face.scss +24 -0
  104. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/css3/_font-feature-settings.scss +4 -0
  105. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/css3/_hidpi-media-query.scss +10 -0
  106. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/css3/_hyphens.scss +4 -0
  107. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/css3/_image-rendering.scss +14 -0
  108. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/css3/_keyframes.scss +36 -0
  109. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/css3/_linear-gradient.scss +38 -0
  110. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/css3/_perspective.scss +8 -0
  111. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/css3/_placeholder.scss +8 -0
  112. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/css3/_radial-gradient.scss +39 -0
  113. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/css3/_selection.scss +42 -0
  114. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/css3/_text-decoration.scss +19 -0
  115. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/css3/_transform.scss +15 -0
  116. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/css3/_transition.scss +71 -0
  117. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/css3/_user-select.scss +3 -0
  118. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/functions/_assign-inputs.scss +11 -0
  119. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/functions/_contains-falsy.scss +20 -0
  120. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/functions/_contains.scss +26 -0
  121. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/functions/_is-length.scss +11 -0
  122. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/functions/_is-light.scss +21 -0
  123. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/functions/_is-number.scss +11 -0
  124. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/functions/_is-size.scss +13 -0
  125. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/functions/_modular-scale.scss +69 -0
  126. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/functions/_px-to-em.scss +13 -0
  127. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/functions/_px-to-rem.scss +15 -0
  128. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/functions/_shade.scss +24 -0
  129. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/functions/_strip-units.scss +17 -0
  130. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/functions/_tint.scss +24 -0
  131. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/functions/_transition-property-name.scss +22 -0
  132. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/functions/_unpack.scss +27 -0
  133. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/helpers/_convert-units.scss +21 -0
  134. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/helpers/_directional-values.scss +96 -0
  135. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/helpers/_font-source-declaration.scss +43 -0
  136. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/helpers/_gradient-positions-parser.scss +13 -0
  137. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/helpers/_linear-angle-parser.scss +25 -0
  138. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/helpers/_linear-gradient-parser.scss +41 -0
  139. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/helpers/_linear-positions-parser.scss +61 -0
  140. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/helpers/_linear-side-corner-parser.scss +31 -0
  141. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/helpers/_radial-arg-parser.scss +69 -0
  142. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/helpers/_radial-gradient-parser.scss +50 -0
  143. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/helpers/_radial-positions-parser.scss +18 -0
  144. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/helpers/_render-gradients.scss +26 -0
  145. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/helpers/_shape-size-stripper.scss +10 -0
  146. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/helpers/_str-to-num.scss +50 -0
  147. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/settings/_asset-pipeline.scss +7 -0
  148. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/settings/_prefixer.scss +9 -0
  149. data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/settings/_px-to-em.scss +1 -0
  150. data/app/assets/stylesheets/active_admin_pro/vendor/neat.scss +22 -0
  151. data/app/assets/stylesheets/active_admin_pro/vendor/neat/_neat-helpers.scss +8 -0
  152. data/app/assets/stylesheets/active_admin_pro/vendor/neat/functions/_new-breakpoint.scss +49 -0
  153. data/app/assets/stylesheets/active_admin_pro/vendor/neat/functions/_private.scss +108 -0
  154. data/app/assets/stylesheets/active_admin_pro/vendor/neat/grid/_box-sizing.scss +11 -0
  155. data/app/assets/stylesheets/active_admin_pro/vendor/neat/grid/_direction-context.scss +31 -0
  156. data/app/assets/stylesheets/active_admin_pro/vendor/neat/grid/_display-context.scss +26 -0
  157. data/app/assets/stylesheets/active_admin_pro/vendor/neat/grid/_fill-parent.scss +22 -0
  158. data/app/assets/stylesheets/active_admin_pro/vendor/neat/grid/_media.scss +92 -0
  159. data/app/assets/stylesheets/active_admin_pro/vendor/neat/grid/_omega.scss +91 -0
  160. data/app/assets/stylesheets/active_admin_pro/vendor/neat/grid/_outer-container.scss +36 -0
  161. data/app/assets/stylesheets/active_admin_pro/vendor/neat/grid/_pad.scss +23 -0
  162. data/app/assets/stylesheets/active_admin_pro/vendor/neat/grid/_private.scss +35 -0
  163. data/app/assets/stylesheets/active_admin_pro/vendor/neat/grid/_row.scss +53 -0
  164. data/app/assets/stylesheets/active_admin_pro/vendor/neat/grid/_shift.scss +48 -0
  165. data/app/assets/stylesheets/active_admin_pro/vendor/neat/grid/_span-columns.scss +90 -0
  166. data/app/assets/stylesheets/active_admin_pro/vendor/neat/grid/_to-deprecate.scss +105 -0
  167. data/app/assets/stylesheets/active_admin_pro/vendor/neat/grid/_visual-grid.scss +40 -0
  168. data/app/assets/stylesheets/active_admin_pro/vendor/neat/settings/_disable-warnings.scss +11 -0
  169. data/app/assets/stylesheets/active_admin_pro/vendor/neat/settings/_grid.scss +53 -0
  170. data/app/assets/stylesheets/active_admin_pro/vendor/neat/settings/_visual-grid.scss +25 -0
  171. data/app/assets/stylesheets/active_admin_pro/vendor/normalize.css +423 -0
  172. data/app/assets/stylesheets/codemirror/themes/activeadmin_pro.scss +117 -0
  173. data/app/inputs/codemirror_input.rb +27 -0
  174. data/app/inputs/datepicker_input.rb +16 -0
  175. data/app/inputs/phone_input.rb +5 -0
  176. data/app/inputs/summernote_input.rb +5 -0
  177. data/app/inputs/time_zone_input.rb +43 -0
  178. data/app/models/activeadmin_pro/summernote_image.rb +5 -0
  179. data/config/initializers/active_admin.rb +50 -0
  180. data/config/locales/en.yml +55 -0
  181. data/lib/active_admin_pro/admin_user/admin_user.rb +52 -0
  182. data/lib/active_admin_pro/engine.rb +8 -0
  183. data/lib/active_admin_pro/summernote_image/summernote_image.rb +61 -0
  184. data/lib/active_admin_pro/user/user.rb +53 -0
  185. data/lib/active_admin_pro/version.rb +3 -0
  186. data/lib/activeadmin_pro.rb +9 -0
  187. data/lib/generators/activeadmin_pro/install_generator.rb +14 -0
  188. data/lib/tasks/activeadmin_pro_tasks.rake +4 -0
  189. data/spec/spec_helper.rb +34 -0
  190. data/vendor/assets/javascripts/bootstrap.js +1243 -0
  191. data/vendor/assets/javascripts/codemirror.js +8887 -0
  192. data/vendor/assets/javascripts/codemirror/addons/comment/comment.js +183 -0
  193. data/vendor/assets/javascripts/codemirror/addons/comment/continuecomment.js +85 -0
  194. data/vendor/assets/javascripts/codemirror/addons/dialog/dialog.css +32 -0
  195. data/vendor/assets/javascripts/codemirror/addons/dialog/dialog.js +157 -0
  196. data/vendor/assets/javascripts/codemirror/addons/display/autorefresh.js +47 -0
  197. data/vendor/assets/javascripts/codemirror/addons/display/fullscreen.css +6 -0
  198. data/vendor/assets/javascripts/codemirror/addons/display/fullscreen.js +41 -0
  199. data/vendor/assets/javascripts/codemirror/addons/display/panel.js +112 -0
  200. data/vendor/assets/javascripts/codemirror/addons/display/placeholder.js +60 -0
  201. data/vendor/assets/javascripts/codemirror/addons/display/rulers.js +63 -0
  202. data/vendor/assets/javascripts/codemirror/addons/edit/closebrackets.js +195 -0
  203. data/vendor/assets/javascripts/codemirror/addons/edit/closetag.js +169 -0
  204. data/vendor/assets/javascripts/codemirror/addons/edit/continuelist.js +51 -0
  205. data/vendor/assets/javascripts/codemirror/addons/edit/matchbrackets.js +120 -0
  206. data/vendor/assets/javascripts/codemirror/addons/edit/matchtags.js +66 -0
  207. data/vendor/assets/javascripts/codemirror/addons/edit/trailingspace.js +27 -0
  208. data/vendor/assets/javascripts/codemirror/addons/fold/brace-fold.js +105 -0
  209. data/vendor/assets/javascripts/codemirror/addons/fold/comment-fold.js +57 -0
  210. data/vendor/assets/javascripts/codemirror/addons/fold/foldcode.js +149 -0
  211. data/vendor/assets/javascripts/codemirror/addons/fold/foldgutter.css +20 -0
  212. data/vendor/assets/javascripts/codemirror/addons/fold/foldgutter.js +146 -0
  213. data/vendor/assets/javascripts/codemirror/addons/fold/indent-fold.js +44 -0
  214. data/vendor/assets/javascripts/codemirror/addons/fold/markdown-fold.js +49 -0
  215. data/vendor/assets/javascripts/codemirror/addons/fold/xml-fold.js +182 -0
  216. data/vendor/assets/javascripts/codemirror/addons/hint/anyword-hint.js +41 -0
  217. data/vendor/assets/javascripts/codemirror/addons/hint/css-hint.js +60 -0
  218. data/vendor/assets/javascripts/codemirror/addons/hint/html-hint.js +348 -0
  219. data/vendor/assets/javascripts/codemirror/addons/hint/javascript-hint.js +146 -0
  220. data/vendor/assets/javascripts/codemirror/addons/hint/show-hint.css +38 -0
  221. data/vendor/assets/javascripts/codemirror/addons/hint/show-hint.js +386 -0
  222. data/vendor/assets/javascripts/codemirror/addons/hint/sql-hint.js +254 -0
  223. data/vendor/assets/javascripts/codemirror/addons/hint/xml-hint.js +110 -0
  224. data/vendor/assets/javascripts/codemirror/addons/lint/coffeescript-lint.js +41 -0
  225. data/vendor/assets/javascripts/codemirror/addons/lint/css-lint.js +35 -0
  226. data/vendor/assets/javascripts/codemirror/addons/lint/html-lint.js +46 -0
  227. data/vendor/assets/javascripts/codemirror/addons/lint/javascript-lint.js +136 -0
  228. data/vendor/assets/javascripts/codemirror/addons/lint/json-lint.js +31 -0
  229. data/vendor/assets/javascripts/codemirror/addons/lint/lint.css +73 -0
  230. data/vendor/assets/javascripts/codemirror/addons/lint/lint.js +231 -0
  231. data/vendor/assets/javascripts/codemirror/addons/lint/yaml-lint.js +28 -0
  232. data/vendor/assets/javascripts/codemirror/addons/merge/merge.css +112 -0
  233. data/vendor/assets/javascripts/codemirror/addons/merge/merge.js +775 -0
  234. data/vendor/assets/javascripts/codemirror/addons/mode/loadmode.js +64 -0
  235. data/vendor/assets/javascripts/codemirror/addons/mode/multiplex.js +123 -0
  236. data/vendor/assets/javascripts/codemirror/addons/mode/multiplex_test.js +33 -0
  237. data/vendor/assets/javascripts/codemirror/addons/mode/overlay.js +85 -0
  238. data/vendor/assets/javascripts/codemirror/addons/mode/simple.js +213 -0
  239. data/vendor/assets/javascripts/codemirror/addons/runmode/colorize.js +40 -0
  240. data/vendor/assets/javascripts/codemirror/addons/runmode/runmode-standalone.js +157 -0
  241. data/vendor/assets/javascripts/codemirror/addons/runmode/runmode.js +72 -0
  242. data/vendor/assets/javascripts/codemirror/addons/runmode/runmode.node.js +178 -0
  243. data/vendor/assets/javascripts/codemirror/addons/scroll/annotatescrollbar.js +115 -0
  244. data/vendor/assets/javascripts/codemirror/addons/scroll/scrollpastend.js +46 -0
  245. data/vendor/assets/javascripts/codemirror/addons/scroll/simplescrollbars.css +66 -0
  246. data/vendor/assets/javascripts/codemirror/addons/scroll/simplescrollbars.js +147 -0
  247. data/vendor/assets/javascripts/codemirror/addons/search/match-highlighter.js +128 -0
  248. data/vendor/assets/javascripts/codemirror/addons/search/matchesonscrollbar.css +8 -0
  249. data/vendor/assets/javascripts/codemirror/addons/search/matchesonscrollbar.js +97 -0
  250. data/vendor/assets/javascripts/codemirror/addons/search/search.js +228 -0
  251. data/vendor/assets/javascripts/codemirror/addons/search/searchcursor.js +189 -0
  252. data/vendor/assets/javascripts/codemirror/addons/selection/active-line.js +71 -0
  253. data/vendor/assets/javascripts/codemirror/addons/selection/mark-selection.js +118 -0
  254. data/vendor/assets/javascripts/codemirror/addons/selection/selection-pointer.js +98 -0
  255. data/vendor/assets/javascripts/codemirror/addons/tern/tern.css +87 -0
  256. data/vendor/assets/javascripts/codemirror/addons/tern/tern.js +700 -0
  257. data/vendor/assets/javascripts/codemirror/addons/tern/worker.js +44 -0
  258. data/vendor/assets/javascripts/codemirror/addons/wrap/hardwrap.js +139 -0
  259. data/vendor/assets/javascripts/codemirror/modes/coffeescript.js +366 -0
  260. data/vendor/assets/javascripts/codemirror/modes/css.js +823 -0
  261. data/vendor/assets/javascripts/codemirror/modes/diff.js +47 -0
  262. data/vendor/assets/javascripts/codemirror/modes/dockerfile.js +79 -0
  263. data/vendor/assets/javascripts/codemirror/modes/gfm.js +130 -0
  264. data/vendor/assets/javascripts/codemirror/modes/go.js +185 -0
  265. data/vendor/assets/javascripts/codemirror/modes/haml.js +159 -0
  266. data/vendor/assets/javascripts/codemirror/modes/handlebars.js +53 -0
  267. data/vendor/assets/javascripts/codemirror/modes/htmlembedded.js +28 -0
  268. data/vendor/assets/javascripts/codemirror/modes/htmlmixed.js +150 -0
  269. data/vendor/assets/javascripts/codemirror/modes/javascript.js +708 -0
  270. data/vendor/assets/javascripts/codemirror/modes/markdown.js +792 -0
  271. data/vendor/assets/javascripts/codemirror/modes/nginx.js +178 -0
  272. data/vendor/assets/javascripts/codemirror/modes/php.js +234 -0
  273. data/vendor/assets/javascripts/codemirror/modes/python.js +358 -0
  274. data/vendor/assets/javascripts/codemirror/modes/ruby.js +285 -0
  275. data/vendor/assets/javascripts/codemirror/modes/rust.js +58 -0
  276. data/vendor/assets/javascripts/codemirror/modes/sass.js +414 -0
  277. data/vendor/assets/javascripts/codemirror/modes/shell.js +139 -0
  278. data/vendor/assets/javascripts/codemirror/modes/xml.js +385 -0
  279. data/vendor/assets/javascripts/codemirror/modes/yaml.js +117 -0
  280. data/vendor/assets/javascripts/intl-tel-input.js +963 -0
  281. data/vendor/assets/javascripts/intl-tel-utils.js +480 -0
  282. data/vendor/assets/javascripts/slug.js +212 -0
  283. data/vendor/assets/javascripts/summernote.js +6939 -0
  284. data/vendor/assets/stylesheets/codemirror.css +334 -0
  285. data/vendor/assets/stylesheets/codemirror/themes/base16-dark.css +38 -0
  286. data/vendor/assets/stylesheets/codemirror/themes/base16-light.css +38 -0
  287. data/vendor/assets/stylesheets/codemirror/themes/dracula.css +41 -0
  288. data/vendor/assets/stylesheets/codemirror/themes/material.css +53 -0
  289. data/vendor/assets/stylesheets/codemirror/themes/monokai.css +35 -0
  290. data/vendor/assets/stylesheets/codemirror/themes/solarized.css +163 -0
  291. data/vendor/assets/stylesheets/codemirror/themes/vibrant-ink.css +34 -0
  292. data/vendor/assets/stylesheets/intl-tel-input.scss +1054 -0
  293. data/vendor/assets/stylesheets/summernote-bs3.css +5425 -0
  294. data/vendor/assets/stylesheets/summernote.css +1 -0
  295. metadata +604 -0
@@ -0,0 +1,71 @@
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: http://codemirror.net/LICENSE
3
+
4
+ // Because sometimes you need to style the cursor's line.
5
+ //
6
+ // Adds an option 'styleActiveLine' which, when enabled, gives the
7
+ // active line's wrapping <div> the CSS class "CodeMirror-activeline",
8
+ // and gives its background <div> the class "CodeMirror-activeline-background".
9
+
10
+ (function(mod) {
11
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
12
+ mod(require("../../lib/codemirror"));
13
+ else if (typeof define == "function" && define.amd) // AMD
14
+ define(["../../lib/codemirror"], mod);
15
+ else // Plain browser env
16
+ mod(CodeMirror);
17
+ })(function(CodeMirror) {
18
+ "use strict";
19
+ var WRAP_CLASS = "CodeMirror-activeline";
20
+ var BACK_CLASS = "CodeMirror-activeline-background";
21
+
22
+ CodeMirror.defineOption("styleActiveLine", false, function(cm, val, old) {
23
+ var prev = old && old != CodeMirror.Init;
24
+ if (val && !prev) {
25
+ cm.state.activeLines = [];
26
+ updateActiveLines(cm, cm.listSelections());
27
+ cm.on("beforeSelectionChange", selectionChange);
28
+ } else if (!val && prev) {
29
+ cm.off("beforeSelectionChange", selectionChange);
30
+ clearActiveLines(cm);
31
+ delete cm.state.activeLines;
32
+ }
33
+ });
34
+
35
+ function clearActiveLines(cm) {
36
+ for (var i = 0; i < cm.state.activeLines.length; i++) {
37
+ cm.removeLineClass(cm.state.activeLines[i], "wrap", WRAP_CLASS);
38
+ cm.removeLineClass(cm.state.activeLines[i], "background", BACK_CLASS);
39
+ }
40
+ }
41
+
42
+ function sameArray(a, b) {
43
+ if (a.length != b.length) return false;
44
+ for (var i = 0; i < a.length; i++)
45
+ if (a[i] != b[i]) return false;
46
+ return true;
47
+ }
48
+
49
+ function updateActiveLines(cm, ranges) {
50
+ var active = [];
51
+ for (var i = 0; i < ranges.length; i++) {
52
+ var range = ranges[i];
53
+ if (!range.empty()) continue;
54
+ var line = cm.getLineHandleVisualStart(range.head.line);
55
+ if (active[active.length - 1] != line) active.push(line);
56
+ }
57
+ if (sameArray(cm.state.activeLines, active)) return;
58
+ cm.operation(function() {
59
+ clearActiveLines(cm);
60
+ for (var i = 0; i < active.length; i++) {
61
+ cm.addLineClass(active[i], "wrap", WRAP_CLASS);
62
+ cm.addLineClass(active[i], "background", BACK_CLASS);
63
+ }
64
+ cm.state.activeLines = active;
65
+ });
66
+ }
67
+
68
+ function selectionChange(cm, sel) {
69
+ updateActiveLines(cm, sel.ranges);
70
+ }
71
+ });
@@ -0,0 +1,118 @@
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: http://codemirror.net/LICENSE
3
+
4
+ // Because sometimes you need to mark the selected *text*.
5
+ //
6
+ // Adds an option 'styleSelectedText' which, when enabled, gives
7
+ // selected text the CSS class given as option value, or
8
+ // "CodeMirror-selectedtext" when the value is not a string.
9
+
10
+ (function(mod) {
11
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
12
+ mod(require("../../lib/codemirror"));
13
+ else if (typeof define == "function" && define.amd) // AMD
14
+ define(["../../lib/codemirror"], mod);
15
+ else // Plain browser env
16
+ mod(CodeMirror);
17
+ })(function(CodeMirror) {
18
+ "use strict";
19
+
20
+ CodeMirror.defineOption("styleSelectedText", false, function(cm, val, old) {
21
+ var prev = old && old != CodeMirror.Init;
22
+ if (val && !prev) {
23
+ cm.state.markedSelection = [];
24
+ cm.state.markedSelectionStyle = typeof val == "string" ? val : "CodeMirror-selectedtext";
25
+ reset(cm);
26
+ cm.on("cursorActivity", onCursorActivity);
27
+ cm.on("change", onChange);
28
+ } else if (!val && prev) {
29
+ cm.off("cursorActivity", onCursorActivity);
30
+ cm.off("change", onChange);
31
+ clear(cm);
32
+ cm.state.markedSelection = cm.state.markedSelectionStyle = null;
33
+ }
34
+ });
35
+
36
+ function onCursorActivity(cm) {
37
+ cm.operation(function() { update(cm); });
38
+ }
39
+
40
+ function onChange(cm) {
41
+ if (cm.state.markedSelection.length)
42
+ cm.operation(function() { clear(cm); });
43
+ }
44
+
45
+ var CHUNK_SIZE = 8;
46
+ var Pos = CodeMirror.Pos;
47
+ var cmp = CodeMirror.cmpPos;
48
+
49
+ function coverRange(cm, from, to, addAt) {
50
+ if (cmp(from, to) == 0) return;
51
+ var array = cm.state.markedSelection;
52
+ var cls = cm.state.markedSelectionStyle;
53
+ for (var line = from.line;;) {
54
+ var start = line == from.line ? from : Pos(line, 0);
55
+ var endLine = line + CHUNK_SIZE, atEnd = endLine >= to.line;
56
+ var end = atEnd ? to : Pos(endLine, 0);
57
+ var mark = cm.markText(start, end, {className: cls});
58
+ if (addAt == null) array.push(mark);
59
+ else array.splice(addAt++, 0, mark);
60
+ if (atEnd) break;
61
+ line = endLine;
62
+ }
63
+ }
64
+
65
+ function clear(cm) {
66
+ var array = cm.state.markedSelection;
67
+ for (var i = 0; i < array.length; ++i) array[i].clear();
68
+ array.length = 0;
69
+ }
70
+
71
+ function reset(cm) {
72
+ clear(cm);
73
+ var ranges = cm.listSelections();
74
+ for (var i = 0; i < ranges.length; i++)
75
+ coverRange(cm, ranges[i].from(), ranges[i].to());
76
+ }
77
+
78
+ function update(cm) {
79
+ if (!cm.somethingSelected()) return clear(cm);
80
+ if (cm.listSelections().length > 1) return reset(cm);
81
+
82
+ var from = cm.getCursor("start"), to = cm.getCursor("end");
83
+
84
+ var array = cm.state.markedSelection;
85
+ if (!array.length) return coverRange(cm, from, to);
86
+
87
+ var coverStart = array[0].find(), coverEnd = array[array.length - 1].find();
88
+ if (!coverStart || !coverEnd || to.line - from.line < CHUNK_SIZE ||
89
+ cmp(from, coverEnd.to) >= 0 || cmp(to, coverStart.from) <= 0)
90
+ return reset(cm);
91
+
92
+ while (cmp(from, coverStart.from) > 0) {
93
+ array.shift().clear();
94
+ coverStart = array[0].find();
95
+ }
96
+ if (cmp(from, coverStart.from) < 0) {
97
+ if (coverStart.to.line - from.line < CHUNK_SIZE) {
98
+ array.shift().clear();
99
+ coverRange(cm, from, coverStart.to, 0);
100
+ } else {
101
+ coverRange(cm, from, coverStart.from, 0);
102
+ }
103
+ }
104
+
105
+ while (cmp(to, coverEnd.to) < 0) {
106
+ array.pop().clear();
107
+ coverEnd = array[array.length - 1].find();
108
+ }
109
+ if (cmp(to, coverEnd.to) > 0) {
110
+ if (to.line - coverEnd.from.line < CHUNK_SIZE) {
111
+ array.pop().clear();
112
+ coverRange(cm, coverEnd.from, to);
113
+ } else {
114
+ coverRange(cm, coverEnd.to, to);
115
+ }
116
+ }
117
+ }
118
+ });
@@ -0,0 +1,98 @@
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: http://codemirror.net/LICENSE
3
+
4
+ (function(mod) {
5
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
6
+ mod(require("../../lib/codemirror"));
7
+ else if (typeof define == "function" && define.amd) // AMD
8
+ define(["../../lib/codemirror"], mod);
9
+ else // Plain browser env
10
+ mod(CodeMirror);
11
+ })(function(CodeMirror) {
12
+ "use strict";
13
+
14
+ CodeMirror.defineOption("selectionPointer", false, function(cm, val) {
15
+ var data = cm.state.selectionPointer;
16
+ if (data) {
17
+ CodeMirror.off(cm.getWrapperElement(), "mousemove", data.mousemove);
18
+ CodeMirror.off(cm.getWrapperElement(), "mouseout", data.mouseout);
19
+ CodeMirror.off(window, "scroll", data.windowScroll);
20
+ cm.off("cursorActivity", reset);
21
+ cm.off("scroll", reset);
22
+ cm.state.selectionPointer = null;
23
+ cm.display.lineDiv.style.cursor = "";
24
+ }
25
+ if (val) {
26
+ data = cm.state.selectionPointer = {
27
+ value: typeof val == "string" ? val : "default",
28
+ mousemove: function(event) { mousemove(cm, event); },
29
+ mouseout: function(event) { mouseout(cm, event); },
30
+ windowScroll: function() { reset(cm); },
31
+ rects: null,
32
+ mouseX: null, mouseY: null,
33
+ willUpdate: false
34
+ };
35
+ CodeMirror.on(cm.getWrapperElement(), "mousemove", data.mousemove);
36
+ CodeMirror.on(cm.getWrapperElement(), "mouseout", data.mouseout);
37
+ CodeMirror.on(window, "scroll", data.windowScroll);
38
+ cm.on("cursorActivity", reset);
39
+ cm.on("scroll", reset);
40
+ }
41
+ });
42
+
43
+ function mousemove(cm, event) {
44
+ var data = cm.state.selectionPointer;
45
+ if (event.buttons == null ? event.which : event.buttons) {
46
+ data.mouseX = data.mouseY = null;
47
+ } else {
48
+ data.mouseX = event.clientX;
49
+ data.mouseY = event.clientY;
50
+ }
51
+ scheduleUpdate(cm);
52
+ }
53
+
54
+ function mouseout(cm, event) {
55
+ if (!cm.getWrapperElement().contains(event.relatedTarget)) {
56
+ var data = cm.state.selectionPointer;
57
+ data.mouseX = data.mouseY = null;
58
+ scheduleUpdate(cm);
59
+ }
60
+ }
61
+
62
+ function reset(cm) {
63
+ cm.state.selectionPointer.rects = null;
64
+ scheduleUpdate(cm);
65
+ }
66
+
67
+ function scheduleUpdate(cm) {
68
+ if (!cm.state.selectionPointer.willUpdate) {
69
+ cm.state.selectionPointer.willUpdate = true;
70
+ setTimeout(function() {
71
+ update(cm);
72
+ cm.state.selectionPointer.willUpdate = false;
73
+ }, 50);
74
+ }
75
+ }
76
+
77
+ function update(cm) {
78
+ var data = cm.state.selectionPointer;
79
+ if (!data) return;
80
+ if (data.rects == null && data.mouseX != null) {
81
+ data.rects = [];
82
+ if (cm.somethingSelected()) {
83
+ for (var sel = cm.display.selectionDiv.firstChild; sel; sel = sel.nextSibling)
84
+ data.rects.push(sel.getBoundingClientRect());
85
+ }
86
+ }
87
+ var inside = false;
88
+ if (data.mouseX != null) for (var i = 0; i < data.rects.length; i++) {
89
+ var rect = data.rects[i];
90
+ if (rect.left <= data.mouseX && rect.right >= data.mouseX &&
91
+ rect.top <= data.mouseY && rect.bottom >= data.mouseY)
92
+ inside = true;
93
+ }
94
+ var cursor = inside ? data.value : "";
95
+ if (cm.display.lineDiv.style.cursor != cursor)
96
+ cm.display.lineDiv.style.cursor = cursor;
97
+ }
98
+ });
@@ -0,0 +1,87 @@
1
+ .CodeMirror-Tern-completion {
2
+ padding-left: 22px;
3
+ position: relative;
4
+ line-height: 1.5;
5
+ }
6
+ .CodeMirror-Tern-completion:before {
7
+ position: absolute;
8
+ left: 2px;
9
+ bottom: 2px;
10
+ border-radius: 50%;
11
+ font-size: 12px;
12
+ font-weight: bold;
13
+ height: 15px;
14
+ width: 15px;
15
+ line-height: 16px;
16
+ text-align: center;
17
+ color: white;
18
+ -moz-box-sizing: border-box;
19
+ box-sizing: border-box;
20
+ }
21
+ .CodeMirror-Tern-completion-unknown:before {
22
+ content: "?";
23
+ background: #4bb;
24
+ }
25
+ .CodeMirror-Tern-completion-object:before {
26
+ content: "O";
27
+ background: #77c;
28
+ }
29
+ .CodeMirror-Tern-completion-fn:before {
30
+ content: "F";
31
+ background: #7c7;
32
+ }
33
+ .CodeMirror-Tern-completion-array:before {
34
+ content: "A";
35
+ background: #c66;
36
+ }
37
+ .CodeMirror-Tern-completion-number:before {
38
+ content: "1";
39
+ background: #999;
40
+ }
41
+ .CodeMirror-Tern-completion-string:before {
42
+ content: "S";
43
+ background: #999;
44
+ }
45
+ .CodeMirror-Tern-completion-bool:before {
46
+ content: "B";
47
+ background: #999;
48
+ }
49
+
50
+ .CodeMirror-Tern-completion-guess {
51
+ color: #999;
52
+ }
53
+
54
+ .CodeMirror-Tern-tooltip {
55
+ border: 1px solid silver;
56
+ border-radius: 3px;
57
+ color: #444;
58
+ padding: 2px 5px;
59
+ font-size: 90%;
60
+ font-family: monospace;
61
+ background-color: white;
62
+ white-space: pre-wrap;
63
+
64
+ max-width: 40em;
65
+ position: absolute;
66
+ z-index: 10;
67
+ -webkit-box-shadow: 2px 3px 5px rgba(0,0,0,.2);
68
+ -moz-box-shadow: 2px 3px 5px rgba(0,0,0,.2);
69
+ box-shadow: 2px 3px 5px rgba(0,0,0,.2);
70
+
71
+ transition: opacity 1s;
72
+ -moz-transition: opacity 1s;
73
+ -webkit-transition: opacity 1s;
74
+ -o-transition: opacity 1s;
75
+ -ms-transition: opacity 1s;
76
+ }
77
+
78
+ .CodeMirror-Tern-hint-doc {
79
+ max-width: 25em;
80
+ margin-top: -3px;
81
+ }
82
+
83
+ .CodeMirror-Tern-fname { color: black; }
84
+ .CodeMirror-Tern-farg { color: #70a; }
85
+ .CodeMirror-Tern-farg-current { text-decoration: underline; }
86
+ .CodeMirror-Tern-type { color: #07c; }
87
+ .CodeMirror-Tern-fhint-guess { opacity: .7; }
@@ -0,0 +1,700 @@
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: http://codemirror.net/LICENSE
3
+
4
+ // Glue code between CodeMirror and Tern.
5
+ //
6
+ // Create a CodeMirror.TernServer to wrap an actual Tern server,
7
+ // register open documents (CodeMirror.Doc instances) with it, and
8
+ // call its methods to activate the assisting functions that Tern
9
+ // provides.
10
+ //
11
+ // Options supported (all optional):
12
+ // * defs: An array of JSON definition data structures.
13
+ // * plugins: An object mapping plugin names to configuration
14
+ // options.
15
+ // * getFile: A function(name, c) that can be used to access files in
16
+ // the project that haven't been loaded yet. Simply do c(null) to
17
+ // indicate that a file is not available.
18
+ // * fileFilter: A function(value, docName, doc) that will be applied
19
+ // to documents before passing them on to Tern.
20
+ // * switchToDoc: A function(name, doc) that should, when providing a
21
+ // multi-file view, switch the view or focus to the named file.
22
+ // * showError: A function(editor, message) that can be used to
23
+ // override the way errors are displayed.
24
+ // * completionTip: Customize the content in tooltips for completions.
25
+ // Is passed a single argument—the completion's data as returned by
26
+ // Tern—and may return a string, DOM node, or null to indicate that
27
+ // no tip should be shown. By default the docstring is shown.
28
+ // * typeTip: Like completionTip, but for the tooltips shown for type
29
+ // queries.
30
+ // * responseFilter: A function(doc, query, request, error, data) that
31
+ // will be applied to the Tern responses before treating them
32
+ //
33
+ //
34
+ // It is possible to run the Tern server in a web worker by specifying
35
+ // these additional options:
36
+ // * useWorker: Set to true to enable web worker mode. You'll probably
37
+ // want to feature detect the actual value you use here, for example
38
+ // !!window.Worker.
39
+ // * workerScript: The main script of the worker. Point this to
40
+ // wherever you are hosting worker.js from this directory.
41
+ // * workerDeps: An array of paths pointing (relative to workerScript)
42
+ // to the Acorn and Tern libraries and any Tern plugins you want to
43
+ // load. Or, if you minified those into a single script and included
44
+ // them in the workerScript, simply leave this undefined.
45
+
46
+ (function(mod) {
47
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
48
+ mod(require("../../lib/codemirror"));
49
+ else if (typeof define == "function" && define.amd) // AMD
50
+ define(["../../lib/codemirror"], mod);
51
+ else // Plain browser env
52
+ mod(CodeMirror);
53
+ })(function(CodeMirror) {
54
+ "use strict";
55
+ // declare global: tern
56
+
57
+ CodeMirror.TernServer = function(options) {
58
+ var self = this;
59
+ this.options = options || {};
60
+ var plugins = this.options.plugins || (this.options.plugins = {});
61
+ if (!plugins.doc_comment) plugins.doc_comment = true;
62
+ this.docs = Object.create(null);
63
+ if (this.options.useWorker) {
64
+ this.server = new WorkerServer(this);
65
+ } else {
66
+ this.server = new tern.Server({
67
+ getFile: function(name, c) { return getFile(self, name, c); },
68
+ async: true,
69
+ defs: this.options.defs || [],
70
+ plugins: plugins
71
+ });
72
+ }
73
+ this.trackChange = function(doc, change) { trackChange(self, doc, change); };
74
+
75
+ this.cachedArgHints = null;
76
+ this.activeArgHints = null;
77
+ this.jumpStack = [];
78
+
79
+ this.getHint = function(cm, c) { return hint(self, cm, c); };
80
+ this.getHint.async = true;
81
+ };
82
+
83
+ CodeMirror.TernServer.prototype = {
84
+ addDoc: function(name, doc) {
85
+ var data = {doc: doc, name: name, changed: null};
86
+ this.server.addFile(name, docValue(this, data));
87
+ CodeMirror.on(doc, "change", this.trackChange);
88
+ return this.docs[name] = data;
89
+ },
90
+
91
+ delDoc: function(id) {
92
+ var found = resolveDoc(this, id);
93
+ if (!found) return;
94
+ CodeMirror.off(found.doc, "change", this.trackChange);
95
+ delete this.docs[found.name];
96
+ this.server.delFile(found.name);
97
+ },
98
+
99
+ hideDoc: function(id) {
100
+ closeArgHints(this);
101
+ var found = resolveDoc(this, id);
102
+ if (found && found.changed) sendDoc(this, found);
103
+ },
104
+
105
+ complete: function(cm) {
106
+ cm.showHint({hint: this.getHint});
107
+ },
108
+
109
+ showType: function(cm, pos, c) { showContextInfo(this, cm, pos, "type", c); },
110
+
111
+ showDocs: function(cm, pos, c) { showContextInfo(this, cm, pos, "documentation", c); },
112
+
113
+ updateArgHints: function(cm) { updateArgHints(this, cm); },
114
+
115
+ jumpToDef: function(cm) { jumpToDef(this, cm); },
116
+
117
+ jumpBack: function(cm) { jumpBack(this, cm); },
118
+
119
+ rename: function(cm) { rename(this, cm); },
120
+
121
+ selectName: function(cm) { selectName(this, cm); },
122
+
123
+ request: function (cm, query, c, pos) {
124
+ var self = this;
125
+ var doc = findDoc(this, cm.getDoc());
126
+ var request = buildRequest(this, doc, query, pos);
127
+ var extraOptions = request.query && this.options.queryOptions && this.options.queryOptions[request.query.type]
128
+ if (extraOptions) for (var prop in extraOptions) request.query[prop] = extraOptions[prop];
129
+
130
+ this.server.request(request, function (error, data) {
131
+ if (!error && self.options.responseFilter)
132
+ data = self.options.responseFilter(doc, query, request, error, data);
133
+ c(error, data);
134
+ });
135
+ },
136
+
137
+ destroy: function () {
138
+ if (this.worker) {
139
+ this.worker.terminate();
140
+ this.worker = null;
141
+ }
142
+ }
143
+ };
144
+
145
+ var Pos = CodeMirror.Pos;
146
+ var cls = "CodeMirror-Tern-";
147
+ var bigDoc = 250;
148
+
149
+ function getFile(ts, name, c) {
150
+ var buf = ts.docs[name];
151
+ if (buf)
152
+ c(docValue(ts, buf));
153
+ else if (ts.options.getFile)
154
+ ts.options.getFile(name, c);
155
+ else
156
+ c(null);
157
+ }
158
+
159
+ function findDoc(ts, doc, name) {
160
+ for (var n in ts.docs) {
161
+ var cur = ts.docs[n];
162
+ if (cur.doc == doc) return cur;
163
+ }
164
+ if (!name) for (var i = 0;; ++i) {
165
+ n = "[doc" + (i || "") + "]";
166
+ if (!ts.docs[n]) { name = n; break; }
167
+ }
168
+ return ts.addDoc(name, doc);
169
+ }
170
+
171
+ function resolveDoc(ts, id) {
172
+ if (typeof id == "string") return ts.docs[id];
173
+ if (id instanceof CodeMirror) id = id.getDoc();
174
+ if (id instanceof CodeMirror.Doc) return findDoc(ts, id);
175
+ }
176
+
177
+ function trackChange(ts, doc, change) {
178
+ var data = findDoc(ts, doc);
179
+
180
+ var argHints = ts.cachedArgHints;
181
+ if (argHints && argHints.doc == doc && cmpPos(argHints.start, change.to) <= 0)
182
+ ts.cachedArgHints = null;
183
+
184
+ var changed = data.changed;
185
+ if (changed == null)
186
+ data.changed = changed = {from: change.from.line, to: change.from.line};
187
+ var end = change.from.line + (change.text.length - 1);
188
+ if (change.from.line < changed.to) changed.to = changed.to - (change.to.line - end);
189
+ if (end >= changed.to) changed.to = end + 1;
190
+ if (changed.from > change.from.line) changed.from = change.from.line;
191
+
192
+ if (doc.lineCount() > bigDoc && change.to - changed.from > 100) setTimeout(function() {
193
+ if (data.changed && data.changed.to - data.changed.from > 100) sendDoc(ts, data);
194
+ }, 200);
195
+ }
196
+
197
+ function sendDoc(ts, doc) {
198
+ ts.server.request({files: [{type: "full", name: doc.name, text: docValue(ts, doc)}]}, function(error) {
199
+ if (error) window.console.error(error);
200
+ else doc.changed = null;
201
+ });
202
+ }
203
+
204
+ // Completion
205
+
206
+ function hint(ts, cm, c) {
207
+ ts.request(cm, {type: "completions", types: true, docs: true, urls: true}, function(error, data) {
208
+ if (error) return showError(ts, cm, error);
209
+ var completions = [], after = "";
210
+ var from = data.start, to = data.end;
211
+ if (cm.getRange(Pos(from.line, from.ch - 2), from) == "[\"" &&
212
+ cm.getRange(to, Pos(to.line, to.ch + 2)) != "\"]")
213
+ after = "\"]";
214
+
215
+ for (var i = 0; i < data.completions.length; ++i) {
216
+ var completion = data.completions[i], className = typeToIcon(completion.type);
217
+ if (data.guess) className += " " + cls + "guess";
218
+ completions.push({text: completion.name + after,
219
+ displayText: completion.displayName || completion.name,
220
+ className: className,
221
+ data: completion});
222
+ }
223
+
224
+ var obj = {from: from, to: to, list: completions};
225
+ var tooltip = null;
226
+ CodeMirror.on(obj, "close", function() { remove(tooltip); });
227
+ CodeMirror.on(obj, "update", function() { remove(tooltip); });
228
+ CodeMirror.on(obj, "select", function(cur, node) {
229
+ remove(tooltip);
230
+ var content = ts.options.completionTip ? ts.options.completionTip(cur.data) : cur.data.doc;
231
+ if (content) {
232
+ tooltip = makeTooltip(node.parentNode.getBoundingClientRect().right + window.pageXOffset,
233
+ node.getBoundingClientRect().top + window.pageYOffset, content);
234
+ tooltip.className += " " + cls + "hint-doc";
235
+ }
236
+ });
237
+ c(obj);
238
+ });
239
+ }
240
+
241
+ function typeToIcon(type) {
242
+ var suffix;
243
+ if (type == "?") suffix = "unknown";
244
+ else if (type == "number" || type == "string" || type == "bool") suffix = type;
245
+ else if (/^fn\(/.test(type)) suffix = "fn";
246
+ else if (/^\[/.test(type)) suffix = "array";
247
+ else suffix = "object";
248
+ return cls + "completion " + cls + "completion-" + suffix;
249
+ }
250
+
251
+ // Type queries
252
+
253
+ function showContextInfo(ts, cm, pos, queryName, c) {
254
+ ts.request(cm, queryName, function(error, data) {
255
+ if (error) return showError(ts, cm, error);
256
+ if (ts.options.typeTip) {
257
+ var tip = ts.options.typeTip(data);
258
+ } else {
259
+ var tip = elt("span", null, elt("strong", null, data.type || "not found"));
260
+ if (data.doc)
261
+ tip.appendChild(document.createTextNode(" — " + data.doc));
262
+ if (data.url) {
263
+ tip.appendChild(document.createTextNode(" "));
264
+ var child = tip.appendChild(elt("a", null, "[docs]"));
265
+ child.href = data.url;
266
+ child.target = "_blank";
267
+ }
268
+ }
269
+ tempTooltip(cm, tip, ts);
270
+ if (c) c();
271
+ }, pos);
272
+ }
273
+
274
+ // Maintaining argument hints
275
+
276
+ function updateArgHints(ts, cm) {
277
+ closeArgHints(ts);
278
+
279
+ if (cm.somethingSelected()) return;
280
+ var state = cm.getTokenAt(cm.getCursor()).state;
281
+ var inner = CodeMirror.innerMode(cm.getMode(), state);
282
+ if (inner.mode.name != "javascript") return;
283
+ var lex = inner.state.lexical;
284
+ if (lex.info != "call") return;
285
+
286
+ var ch, argPos = lex.pos || 0, tabSize = cm.getOption("tabSize");
287
+ for (var line = cm.getCursor().line, e = Math.max(0, line - 9), found = false; line >= e; --line) {
288
+ var str = cm.getLine(line), extra = 0;
289
+ for (var pos = 0;;) {
290
+ var tab = str.indexOf("\t", pos);
291
+ if (tab == -1) break;
292
+ extra += tabSize - (tab + extra) % tabSize - 1;
293
+ pos = tab + 1;
294
+ }
295
+ ch = lex.column - extra;
296
+ if (str.charAt(ch) == "(") {found = true; break;}
297
+ }
298
+ if (!found) return;
299
+
300
+ var start = Pos(line, ch);
301
+ var cache = ts.cachedArgHints;
302
+ if (cache && cache.doc == cm.getDoc() && cmpPos(start, cache.start) == 0)
303
+ return showArgHints(ts, cm, argPos);
304
+
305
+ ts.request(cm, {type: "type", preferFunction: true, end: start}, function(error, data) {
306
+ if (error || !data.type || !(/^fn\(/).test(data.type)) return;
307
+ ts.cachedArgHints = {
308
+ start: pos,
309
+ type: parseFnType(data.type),
310
+ name: data.exprName || data.name || "fn",
311
+ guess: data.guess,
312
+ doc: cm.getDoc()
313
+ };
314
+ showArgHints(ts, cm, argPos);
315
+ });
316
+ }
317
+
318
+ function showArgHints(ts, cm, pos) {
319
+ closeArgHints(ts);
320
+
321
+ var cache = ts.cachedArgHints, tp = cache.type;
322
+ var tip = elt("span", cache.guess ? cls + "fhint-guess" : null,
323
+ elt("span", cls + "fname", cache.name), "(");
324
+ for (var i = 0; i < tp.args.length; ++i) {
325
+ if (i) tip.appendChild(document.createTextNode(", "));
326
+ var arg = tp.args[i];
327
+ tip.appendChild(elt("span", cls + "farg" + (i == pos ? " " + cls + "farg-current" : ""), arg.name || "?"));
328
+ if (arg.type != "?") {
329
+ tip.appendChild(document.createTextNode(":\u00a0"));
330
+ tip.appendChild(elt("span", cls + "type", arg.type));
331
+ }
332
+ }
333
+ tip.appendChild(document.createTextNode(tp.rettype ? ") ->\u00a0" : ")"));
334
+ if (tp.rettype) tip.appendChild(elt("span", cls + "type", tp.rettype));
335
+ var place = cm.cursorCoords(null, "page");
336
+ ts.activeArgHints = makeTooltip(place.right + 1, place.bottom, tip);
337
+ }
338
+
339
+ function parseFnType(text) {
340
+ var args = [], pos = 3;
341
+
342
+ function skipMatching(upto) {
343
+ var depth = 0, start = pos;
344
+ for (;;) {
345
+ var next = text.charAt(pos);
346
+ if (upto.test(next) && !depth) return text.slice(start, pos);
347
+ if (/[{\[\(]/.test(next)) ++depth;
348
+ else if (/[}\]\)]/.test(next)) --depth;
349
+ ++pos;
350
+ }
351
+ }
352
+
353
+ // Parse arguments
354
+ if (text.charAt(pos) != ")") for (;;) {
355
+ var name = text.slice(pos).match(/^([^, \(\[\{]+): /);
356
+ if (name) {
357
+ pos += name[0].length;
358
+ name = name[1];
359
+ }
360
+ args.push({name: name, type: skipMatching(/[\),]/)});
361
+ if (text.charAt(pos) == ")") break;
362
+ pos += 2;
363
+ }
364
+
365
+ var rettype = text.slice(pos).match(/^\) -> (.*)$/);
366
+
367
+ return {args: args, rettype: rettype && rettype[1]};
368
+ }
369
+
370
+ // Moving to the definition of something
371
+
372
+ function jumpToDef(ts, cm) {
373
+ function inner(varName) {
374
+ var req = {type: "definition", variable: varName || null};
375
+ var doc = findDoc(ts, cm.getDoc());
376
+ ts.server.request(buildRequest(ts, doc, req), function(error, data) {
377
+ if (error) return showError(ts, cm, error);
378
+ if (!data.file && data.url) { window.open(data.url); return; }
379
+
380
+ if (data.file) {
381
+ var localDoc = ts.docs[data.file], found;
382
+ if (localDoc && (found = findContext(localDoc.doc, data))) {
383
+ ts.jumpStack.push({file: doc.name,
384
+ start: cm.getCursor("from"),
385
+ end: cm.getCursor("to")});
386
+ moveTo(ts, doc, localDoc, found.start, found.end);
387
+ return;
388
+ }
389
+ }
390
+ showError(ts, cm, "Could not find a definition.");
391
+ });
392
+ }
393
+
394
+ if (!atInterestingExpression(cm))
395
+ dialog(cm, "Jump to variable", function(name) { if (name) inner(name); });
396
+ else
397
+ inner();
398
+ }
399
+
400
+ function jumpBack(ts, cm) {
401
+ var pos = ts.jumpStack.pop(), doc = pos && ts.docs[pos.file];
402
+ if (!doc) return;
403
+ moveTo(ts, findDoc(ts, cm.getDoc()), doc, pos.start, pos.end);
404
+ }
405
+
406
+ function moveTo(ts, curDoc, doc, start, end) {
407
+ doc.doc.setSelection(start, end);
408
+ if (curDoc != doc && ts.options.switchToDoc) {
409
+ closeArgHints(ts);
410
+ ts.options.switchToDoc(doc.name, doc.doc);
411
+ }
412
+ }
413
+
414
+ // The {line,ch} representation of positions makes this rather awkward.
415
+ function findContext(doc, data) {
416
+ var before = data.context.slice(0, data.contextOffset).split("\n");
417
+ var startLine = data.start.line - (before.length - 1);
418
+ var start = Pos(startLine, (before.length == 1 ? data.start.ch : doc.getLine(startLine).length) - before[0].length);
419
+
420
+ var text = doc.getLine(startLine).slice(start.ch);
421
+ for (var cur = startLine + 1; cur < doc.lineCount() && text.length < data.context.length; ++cur)
422
+ text += "\n" + doc.getLine(cur);
423
+ if (text.slice(0, data.context.length) == data.context) return data;
424
+
425
+ var cursor = doc.getSearchCursor(data.context, 0, false);
426
+ var nearest, nearestDist = Infinity;
427
+ while (cursor.findNext()) {
428
+ var from = cursor.from(), dist = Math.abs(from.line - start.line) * 10000;
429
+ if (!dist) dist = Math.abs(from.ch - start.ch);
430
+ if (dist < nearestDist) { nearest = from; nearestDist = dist; }
431
+ }
432
+ if (!nearest) return null;
433
+
434
+ if (before.length == 1)
435
+ nearest.ch += before[0].length;
436
+ else
437
+ nearest = Pos(nearest.line + (before.length - 1), before[before.length - 1].length);
438
+ if (data.start.line == data.end.line)
439
+ var end = Pos(nearest.line, nearest.ch + (data.end.ch - data.start.ch));
440
+ else
441
+ var end = Pos(nearest.line + (data.end.line - data.start.line), data.end.ch);
442
+ return {start: nearest, end: end};
443
+ }
444
+
445
+ function atInterestingExpression(cm) {
446
+ var pos = cm.getCursor("end"), tok = cm.getTokenAt(pos);
447
+ if (tok.start < pos.ch && tok.type == "comment") return false;
448
+ return /[\w)\]]/.test(cm.getLine(pos.line).slice(Math.max(pos.ch - 1, 0), pos.ch + 1));
449
+ }
450
+
451
+ // Variable renaming
452
+
453
+ function rename(ts, cm) {
454
+ var token = cm.getTokenAt(cm.getCursor());
455
+ if (!/\w/.test(token.string)) return showError(ts, cm, "Not at a variable");
456
+ dialog(cm, "New name for " + token.string, function(newName) {
457
+ ts.request(cm, {type: "rename", newName: newName, fullDocs: true}, function(error, data) {
458
+ if (error) return showError(ts, cm, error);
459
+ applyChanges(ts, data.changes);
460
+ });
461
+ });
462
+ }
463
+
464
+ function selectName(ts, cm) {
465
+ var name = findDoc(ts, cm.doc).name;
466
+ ts.request(cm, {type: "refs"}, function(error, data) {
467
+ if (error) return showError(ts, cm, error);
468
+ var ranges = [], cur = 0;
469
+ var curPos = cm.getCursor();
470
+ for (var i = 0; i < data.refs.length; i++) {
471
+ var ref = data.refs[i];
472
+ if (ref.file == name) {
473
+ ranges.push({anchor: ref.start, head: ref.end});
474
+ if (cmpPos(curPos, ref.start) >= 0 && cmpPos(curPos, ref.end) <= 0)
475
+ cur = ranges.length - 1;
476
+ }
477
+ }
478
+ cm.setSelections(ranges, cur);
479
+ });
480
+ }
481
+
482
+ var nextChangeOrig = 0;
483
+ function applyChanges(ts, changes) {
484
+ var perFile = Object.create(null);
485
+ for (var i = 0; i < changes.length; ++i) {
486
+ var ch = changes[i];
487
+ (perFile[ch.file] || (perFile[ch.file] = [])).push(ch);
488
+ }
489
+ for (var file in perFile) {
490
+ var known = ts.docs[file], chs = perFile[file];;
491
+ if (!known) continue;
492
+ chs.sort(function(a, b) { return cmpPos(b.start, a.start); });
493
+ var origin = "*rename" + (++nextChangeOrig);
494
+ for (var i = 0; i < chs.length; ++i) {
495
+ var ch = chs[i];
496
+ known.doc.replaceRange(ch.text, ch.start, ch.end, origin);
497
+ }
498
+ }
499
+ }
500
+
501
+ // Generic request-building helper
502
+
503
+ function buildRequest(ts, doc, query, pos) {
504
+ var files = [], offsetLines = 0, allowFragments = !query.fullDocs;
505
+ if (!allowFragments) delete query.fullDocs;
506
+ if (typeof query == "string") query = {type: query};
507
+ query.lineCharPositions = true;
508
+ if (query.end == null) {
509
+ query.end = pos || doc.doc.getCursor("end");
510
+ if (doc.doc.somethingSelected())
511
+ query.start = doc.doc.getCursor("start");
512
+ }
513
+ var startPos = query.start || query.end;
514
+
515
+ if (doc.changed) {
516
+ if (doc.doc.lineCount() > bigDoc && allowFragments !== false &&
517
+ doc.changed.to - doc.changed.from < 100 &&
518
+ doc.changed.from <= startPos.line && doc.changed.to > query.end.line) {
519
+ files.push(getFragmentAround(doc, startPos, query.end));
520
+ query.file = "#0";
521
+ var offsetLines = files[0].offsetLines;
522
+ if (query.start != null) query.start = Pos(query.start.line - -offsetLines, query.start.ch);
523
+ query.end = Pos(query.end.line - offsetLines, query.end.ch);
524
+ } else {
525
+ files.push({type: "full",
526
+ name: doc.name,
527
+ text: docValue(ts, doc)});
528
+ query.file = doc.name;
529
+ doc.changed = null;
530
+ }
531
+ } else {
532
+ query.file = doc.name;
533
+ }
534
+ for (var name in ts.docs) {
535
+ var cur = ts.docs[name];
536
+ if (cur.changed && cur != doc) {
537
+ files.push({type: "full", name: cur.name, text: docValue(ts, cur)});
538
+ cur.changed = null;
539
+ }
540
+ }
541
+
542
+ return {query: query, files: files};
543
+ }
544
+
545
+ function getFragmentAround(data, start, end) {
546
+ var doc = data.doc;
547
+ var minIndent = null, minLine = null, endLine, tabSize = 4;
548
+ for (var p = start.line - 1, min = Math.max(0, p - 50); p >= min; --p) {
549
+ var line = doc.getLine(p), fn = line.search(/\bfunction\b/);
550
+ if (fn < 0) continue;
551
+ var indent = CodeMirror.countColumn(line, null, tabSize);
552
+ if (minIndent != null && minIndent <= indent) continue;
553
+ minIndent = indent;
554
+ minLine = p;
555
+ }
556
+ if (minLine == null) minLine = min;
557
+ var max = Math.min(doc.lastLine(), end.line + 20);
558
+ if (minIndent == null || minIndent == CodeMirror.countColumn(doc.getLine(start.line), null, tabSize))
559
+ endLine = max;
560
+ else for (endLine = end.line + 1; endLine < max; ++endLine) {
561
+ var indent = CodeMirror.countColumn(doc.getLine(endLine), null, tabSize);
562
+ if (indent <= minIndent) break;
563
+ }
564
+ var from = Pos(minLine, 0);
565
+
566
+ return {type: "part",
567
+ name: data.name,
568
+ offsetLines: from.line,
569
+ text: doc.getRange(from, Pos(endLine, 0))};
570
+ }
571
+
572
+ // Generic utilities
573
+
574
+ var cmpPos = CodeMirror.cmpPos;
575
+
576
+ function elt(tagname, cls /*, ... elts*/) {
577
+ var e = document.createElement(tagname);
578
+ if (cls) e.className = cls;
579
+ for (var i = 2; i < arguments.length; ++i) {
580
+ var elt = arguments[i];
581
+ if (typeof elt == "string") elt = document.createTextNode(elt);
582
+ e.appendChild(elt);
583
+ }
584
+ return e;
585
+ }
586
+
587
+ function dialog(cm, text, f) {
588
+ if (cm.openDialog)
589
+ cm.openDialog(text + ": <input type=text>", f);
590
+ else
591
+ f(prompt(text, ""));
592
+ }
593
+
594
+ // Tooltips
595
+
596
+ function tempTooltip(cm, content, ts) {
597
+ if (cm.state.ternTooltip) remove(cm.state.ternTooltip);
598
+ var where = cm.cursorCoords();
599
+ var tip = cm.state.ternTooltip = makeTooltip(where.right + 1, where.bottom, content);
600
+ function maybeClear() {
601
+ old = true;
602
+ if (!mouseOnTip) clear();
603
+ }
604
+ function clear() {
605
+ cm.state.ternTooltip = null;
606
+ if (!tip.parentNode) return;
607
+ cm.off("cursorActivity", clear);
608
+ cm.off('blur', clear);
609
+ cm.off('scroll', clear);
610
+ fadeOut(tip);
611
+ }
612
+ var mouseOnTip = false, old = false;
613
+ CodeMirror.on(tip, "mousemove", function() { mouseOnTip = true; });
614
+ CodeMirror.on(tip, "mouseout", function(e) {
615
+ if (!CodeMirror.contains(tip, e.relatedTarget || e.toElement)) {
616
+ if (old) clear();
617
+ else mouseOnTip = false;
618
+ }
619
+ });
620
+ setTimeout(maybeClear, ts.options.hintDelay ? ts.options.hintDelay : 1700);
621
+ cm.on("cursorActivity", clear);
622
+ cm.on('blur', clear);
623
+ cm.on('scroll', clear);
624
+ }
625
+
626
+ function makeTooltip(x, y, content) {
627
+ var node = elt("div", cls + "tooltip", content);
628
+ node.style.left = x + "px";
629
+ node.style.top = y + "px";
630
+ document.body.appendChild(node);
631
+ return node;
632
+ }
633
+
634
+ function remove(node) {
635
+ var p = node && node.parentNode;
636
+ if (p) p.removeChild(node);
637
+ }
638
+
639
+ function fadeOut(tooltip) {
640
+ tooltip.style.opacity = "0";
641
+ setTimeout(function() { remove(tooltip); }, 1100);
642
+ }
643
+
644
+ function showError(ts, cm, msg) {
645
+ if (ts.options.showError)
646
+ ts.options.showError(cm, msg);
647
+ else
648
+ tempTooltip(cm, String(msg), ts);
649
+ }
650
+
651
+ function closeArgHints(ts) {
652
+ if (ts.activeArgHints) { remove(ts.activeArgHints); ts.activeArgHints = null; }
653
+ }
654
+
655
+ function docValue(ts, doc) {
656
+ var val = doc.doc.getValue();
657
+ if (ts.options.fileFilter) val = ts.options.fileFilter(val, doc.name, doc.doc);
658
+ return val;
659
+ }
660
+
661
+ // Worker wrapper
662
+
663
+ function WorkerServer(ts) {
664
+ var worker = ts.worker = new Worker(ts.options.workerScript);
665
+ worker.postMessage({type: "init",
666
+ defs: ts.options.defs,
667
+ plugins: ts.options.plugins,
668
+ scripts: ts.options.workerDeps});
669
+ var msgId = 0, pending = {};
670
+
671
+ function send(data, c) {
672
+ if (c) {
673
+ data.id = ++msgId;
674
+ pending[msgId] = c;
675
+ }
676
+ worker.postMessage(data);
677
+ }
678
+ worker.onmessage = function(e) {
679
+ var data = e.data;
680
+ if (data.type == "getFile") {
681
+ getFile(ts, data.name, function(err, text) {
682
+ send({type: "getFile", err: String(err), text: text, id: data.id});
683
+ });
684
+ } else if (data.type == "debug") {
685
+ window.console.log(data.message);
686
+ } else if (data.id && pending[data.id]) {
687
+ pending[data.id](data.err, data.body);
688
+ delete pending[data.id];
689
+ }
690
+ };
691
+ worker.onerror = function(e) {
692
+ for (var id in pending) pending[id](e);
693
+ pending = {};
694
+ };
695
+
696
+ this.addFile = function(name, text) { send({type: "add", name: name, text: text}); };
697
+ this.delFile = function(name) { send({type: "del", name: name}); };
698
+ this.request = function(body, c) { send({type: "req", body: body}, c); };
699
+ }
700
+ });