locomotivecms 4.1.1 → 4.2.0.alpha1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (301) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -1
  3. data/README.md +4 -3
  4. data/Rakefile +4 -0
  5. data/app/api/locomotive/api.rb +1 -1
  6. data/app/assets/config/locomotive_manifest.js +2 -0
  7. data/app/assets/javascripts/locomotive.js +2 -2
  8. data/app/assets/stylesheets/locomotive/account.scss +0 -1
  9. data/app/assets/stylesheets/locomotive/application.scss +0 -1
  10. data/app/assets/stylesheets/locomotive/live_editing_error.scss +0 -1
  11. data/app/assets/stylesheets/locomotive/live_editing_iframe.scss +0 -1
  12. data/app/controllers/locomotive/base_controller.rb +1 -1
  13. data/app/controllers/locomotive/concerns/authorization_controller.rb +1 -1
  14. data/app/controllers/locomotive/concerns/redirect_to_main_host_controller.rb +1 -1
  15. data/app/controllers/locomotive/concerns/site_dispatcher_controller.rb +1 -1
  16. data/app/controllers/locomotive/errors_controller.rb +1 -1
  17. data/app/controllers/locomotive/my_account_controller.rb +1 -1
  18. data/app/controllers/locomotive/passwords_controller.rb +3 -1
  19. data/app/controllers/locomotive/registrations_controller.rb +3 -1
  20. data/app/controllers/locomotive/sessions_controller.rb +3 -1
  21. data/app/controllers/locomotive/sites_controller.rb +1 -1
  22. data/app/helpers/locomotive/base_helper.rb +2 -2
  23. data/app/helpers/locomotive/custom_fields_helper.rb +2 -2
  24. data/app/helpers/locomotive/shared/activities_helper.rb +1 -1
  25. data/app/inputs/locomotive/api_key_input.rb +1 -1
  26. data/app/mailers/locomotive/notifications.rb +1 -1
  27. data/app/models/locomotive/account.rb +1 -1
  28. data/app/models/locomotive/concerns/account/api_key.rb +1 -1
  29. data/app/models/locomotive/concerns/content_entry/csv.rb +1 -1
  30. data/app/models/locomotive/concerns/content_entry/slug.rb +5 -5
  31. data/app/models/locomotive/concerns/content_type/entry_template.rb +3 -3
  32. data/app/models/locomotive/concerns/page/templatized.rb +1 -1
  33. data/app/models/locomotive/concerns/shared/json_attribute.rb +21 -2
  34. data/app/models/locomotive/concerns/site/routes.rb +1 -1
  35. data/app/models/locomotive/content_entry.rb +2 -2
  36. data/app/models/locomotive/page.rb +3 -3
  37. data/app/models/locomotive/section.rb +1 -1
  38. data/app/models/locomotive/snippet.rb +1 -1
  39. data/app/models/locomotive/translation.rb +1 -1
  40. data/app/services/locomotive/content_entry_import_service.rb +1 -1
  41. data/app/services/locomotive/content_entry_service.rb +2 -2
  42. data/app/services/locomotive/content_type_service.rb +13 -3
  43. data/app/services/locomotive/custom_field_service.rb +2 -2
  44. data/app/services/locomotive/editor_service.rb +1 -1
  45. data/app/uploaders/locomotive/base_uploader.rb +0 -10
  46. data/app/views/locomotive/dashboard/_activity.html.slim +1 -1
  47. data/app/views/locomotive/page_content/_edit.json.jbuilder +50 -0
  48. data/app/views/locomotive/page_content/edit.html.erb +1 -1
  49. data/app/views/locomotive/page_content/edit.json.jbuilder +52 -50
  50. data/config/initializers/devise.rb +5 -2
  51. data/lib/generators/locomotive/install/templates/locomotive.rb +0 -5
  52. data/lib/locomotive/action_controller/responder.rb +1 -1
  53. data/lib/locomotive/configuration.rb +2 -2
  54. data/lib/locomotive/dependencies.rb +0 -2
  55. data/lib/locomotive/engine.rb +14 -2
  56. data/lib/locomotive/mongoid/patches.rb +25 -65
  57. data/lib/locomotive/steam/services/api_entry_submission_service.rb +1 -0
  58. data/lib/locomotive/version.rb +1 -1
  59. data/vendor/assets/javascripts/locomotive/codemirror/addons/comment/comment.js +203 -0
  60. data/vendor/assets/javascripts/locomotive/codemirror/addons/comment/continuecomment.js +85 -0
  61. data/vendor/assets/javascripts/locomotive/codemirror/addons/dialog/dialog.js +157 -0
  62. data/vendor/assets/javascripts/locomotive/codemirror/addons/display/autorefresh.js +47 -0
  63. data/vendor/assets/javascripts/locomotive/codemirror/addons/display/fullscreen.js +41 -0
  64. data/vendor/assets/javascripts/locomotive/codemirror/addons/display/panel.js +112 -0
  65. data/vendor/assets/javascripts/locomotive/codemirror/addons/display/placeholder.js +62 -0
  66. data/vendor/assets/javascripts/locomotive/codemirror/addons/display/rulers.js +51 -0
  67. data/vendor/assets/javascripts/locomotive/codemirror/addons/edit/closebrackets.js +195 -0
  68. data/vendor/assets/javascripts/locomotive/codemirror/addons/edit/closetag.js +169 -0
  69. data/vendor/assets/javascripts/locomotive/codemirror/addons/edit/continuelist.js +51 -0
  70. data/vendor/assets/javascripts/locomotive/codemirror/addons/edit/matchbrackets.js +120 -0
  71. data/vendor/assets/javascripts/locomotive/codemirror/addons/edit/matchtags.js +66 -0
  72. data/vendor/assets/javascripts/locomotive/codemirror/addons/edit/trailingspace.js +27 -0
  73. data/vendor/assets/javascripts/locomotive/codemirror/addons/fold/brace-fold.js +105 -0
  74. data/vendor/assets/javascripts/locomotive/codemirror/addons/fold/comment-fold.js +59 -0
  75. data/vendor/assets/javascripts/locomotive/codemirror/addons/fold/foldcode.js +150 -0
  76. data/vendor/assets/javascripts/locomotive/codemirror/addons/fold/foldgutter.js +146 -0
  77. data/vendor/assets/javascripts/locomotive/codemirror/addons/fold/indent-fold.js +44 -0
  78. data/vendor/assets/javascripts/locomotive/codemirror/addons/fold/markdown-fold.js +49 -0
  79. data/vendor/assets/javascripts/locomotive/codemirror/addons/fold/xml-fold.js +182 -0
  80. data/vendor/assets/javascripts/locomotive/codemirror/addons/hint/anyword-hint.js +41 -0
  81. data/vendor/assets/javascripts/locomotive/codemirror/addons/hint/css-hint.js +60 -0
  82. data/vendor/assets/javascripts/locomotive/codemirror/addons/hint/html-hint.js +348 -0
  83. data/vendor/assets/javascripts/locomotive/codemirror/addons/hint/javascript-hint.js +146 -0
  84. data/vendor/assets/javascripts/locomotive/codemirror/addons/hint/show-hint.js +437 -0
  85. data/vendor/assets/javascripts/locomotive/codemirror/addons/hint/sql-hint.js +271 -0
  86. data/vendor/assets/javascripts/locomotive/codemirror/addons/hint/xml-hint.js +110 -0
  87. data/vendor/assets/javascripts/locomotive/codemirror/addons/lint/coffeescript-lint.js +41 -0
  88. data/vendor/assets/javascripts/locomotive/codemirror/addons/lint/css-lint.js +35 -0
  89. data/vendor/assets/javascripts/locomotive/codemirror/addons/lint/html-lint.js +46 -0
  90. data/vendor/assets/javascripts/locomotive/codemirror/addons/lint/javascript-lint.js +136 -0
  91. data/vendor/assets/javascripts/locomotive/codemirror/addons/lint/json-lint.js +31 -0
  92. data/vendor/assets/javascripts/locomotive/codemirror/addons/lint/lint.js +239 -0
  93. data/vendor/assets/javascripts/locomotive/codemirror/addons/lint/yaml-lint.js +28 -0
  94. data/vendor/assets/javascripts/locomotive/codemirror/addons/merge/merge.js +773 -0
  95. data/vendor/assets/javascripts/locomotive/codemirror/addons/mode/loadmode.js +64 -0
  96. data/vendor/assets/javascripts/locomotive/codemirror/addons/mode/multiplex.js +123 -0
  97. data/vendor/assets/javascripts/locomotive/codemirror/addons/mode/overlay.js +85 -0
  98. data/vendor/assets/javascripts/locomotive/codemirror/addons/mode/simple.js +213 -0
  99. data/vendor/assets/javascripts/locomotive/codemirror/addons/runmode/colorize.js +40 -0
  100. data/vendor/assets/javascripts/locomotive/codemirror/addons/runmode/runmode-standalone.js +157 -0
  101. data/vendor/assets/javascripts/locomotive/codemirror/addons/runmode/runmode.js +72 -0
  102. data/vendor/assets/javascripts/locomotive/codemirror/addons/runmode/runmode.node.js +179 -0
  103. data/vendor/assets/javascripts/locomotive/codemirror/addons/scroll/annotatescrollbar.js +118 -0
  104. data/vendor/assets/javascripts/locomotive/codemirror/addons/scroll/scrollpastend.js +48 -0
  105. data/vendor/assets/javascripts/locomotive/codemirror/addons/scroll/simplescrollbars.js +152 -0
  106. data/vendor/assets/javascripts/locomotive/codemirror/addons/search/jump-to-line.js +49 -0
  107. data/vendor/assets/javascripts/locomotive/codemirror/addons/search/match-highlighter.js +146 -0
  108. data/vendor/assets/javascripts/locomotive/codemirror/addons/search/matchesonscrollbar.js +97 -0
  109. data/vendor/assets/javascripts/locomotive/codemirror/addons/search/search.js +249 -0
  110. data/vendor/assets/javascripts/locomotive/codemirror/addons/search/searchcursor.js +189 -0
  111. data/vendor/assets/javascripts/locomotive/codemirror/addons/selection/active-line.js +74 -0
  112. data/vendor/assets/javascripts/locomotive/codemirror/addons/selection/mark-selection.js +118 -0
  113. data/vendor/assets/javascripts/locomotive/codemirror/addons/selection/selection-pointer.js +98 -0
  114. data/vendor/assets/javascripts/locomotive/codemirror/addons/tern/tern.js +701 -0
  115. data/vendor/assets/javascripts/locomotive/codemirror/addons/tern/worker.js +44 -0
  116. data/vendor/assets/javascripts/locomotive/codemirror/addons/wrap/hardwrap.js +144 -0
  117. data/vendor/assets/javascripts/locomotive/codemirror/keymaps/emacs.js +412 -0
  118. data/vendor/assets/javascripts/locomotive/codemirror/keymaps/sublime.js +580 -0
  119. data/vendor/assets/javascripts/locomotive/codemirror/keymaps/vim.js +5065 -0
  120. data/vendor/assets/javascripts/locomotive/codemirror/modes/apl.js +174 -0
  121. data/vendor/assets/javascripts/locomotive/codemirror/modes/asciiarmor.js +73 -0
  122. data/vendor/assets/javascripts/locomotive/codemirror/modes/asn.1.js +204 -0
  123. data/vendor/assets/javascripts/locomotive/codemirror/modes/asterisk.js +196 -0
  124. data/vendor/assets/javascripts/locomotive/codemirror/modes/brainfuck.js +85 -0
  125. data/vendor/assets/javascripts/locomotive/codemirror/modes/clike.js +786 -0
  126. data/vendor/assets/javascripts/locomotive/codemirror/modes/clojure.js +306 -0
  127. data/vendor/assets/javascripts/locomotive/codemirror/modes/cmake.js +97 -0
  128. data/vendor/assets/javascripts/locomotive/codemirror/modes/cobol.js +255 -0
  129. data/vendor/assets/javascripts/locomotive/codemirror/modes/coffeescript.js +355 -0
  130. data/vendor/assets/javascripts/locomotive/codemirror/modes/commonlisp.js +123 -0
  131. data/vendor/assets/javascripts/locomotive/codemirror/modes/crystal.js +391 -0
  132. data/vendor/assets/javascripts/locomotive/codemirror/modes/css.js +825 -0
  133. data/vendor/assets/javascripts/locomotive/codemirror/modes/cypher.js +146 -0
  134. data/vendor/assets/javascripts/locomotive/codemirror/modes/d.js +218 -0
  135. data/vendor/assets/javascripts/locomotive/codemirror/modes/dart.js +157 -0
  136. data/vendor/assets/javascripts/locomotive/codemirror/modes/diff.js +47 -0
  137. data/vendor/assets/javascripts/locomotive/codemirror/modes/django.js +356 -0
  138. data/vendor/assets/javascripts/locomotive/codemirror/modes/dockerfile.js +79 -0
  139. data/vendor/assets/javascripts/locomotive/codemirror/modes/dtd.js +142 -0
  140. data/vendor/assets/javascripts/locomotive/codemirror/modes/dylan.js +344 -0
  141. data/vendor/assets/javascripts/locomotive/codemirror/modes/ebnf.js +195 -0
  142. data/vendor/assets/javascripts/locomotive/codemirror/modes/ecl.js +206 -0
  143. data/vendor/assets/javascripts/locomotive/codemirror/modes/eiffel.js +160 -0
  144. data/vendor/assets/javascripts/locomotive/codemirror/modes/elm.js +205 -0
  145. data/vendor/assets/javascripts/locomotive/codemirror/modes/erlang.js +618 -0
  146. data/vendor/assets/javascripts/locomotive/codemirror/modes/factor.js +83 -0
  147. data/vendor/assets/javascripts/locomotive/codemirror/modes/fcl.js +173 -0
  148. data/vendor/assets/javascripts/locomotive/codemirror/modes/forth.js +180 -0
  149. data/vendor/assets/javascripts/locomotive/codemirror/modes/fortran.js +188 -0
  150. data/vendor/assets/javascripts/locomotive/codemirror/modes/gas.js +345 -0
  151. data/vendor/assets/javascripts/locomotive/codemirror/modes/gfm.js +130 -0
  152. data/vendor/assets/javascripts/locomotive/codemirror/modes/gherkin.js +178 -0
  153. data/vendor/assets/javascripts/locomotive/codemirror/modes/go.js +185 -0
  154. data/vendor/assets/javascripts/locomotive/codemirror/modes/groovy.js +230 -0
  155. data/vendor/assets/javascripts/locomotive/codemirror/modes/haml.js +161 -0
  156. data/vendor/assets/javascripts/locomotive/codemirror/modes/handlebars.js +62 -0
  157. data/vendor/assets/javascripts/locomotive/codemirror/modes/haskell-literate.js +43 -0
  158. data/vendor/assets/javascripts/locomotive/codemirror/modes/haskell.js +267 -0
  159. data/vendor/assets/javascripts/locomotive/codemirror/modes/haxe.js +515 -0
  160. data/vendor/assets/javascripts/locomotive/codemirror/modes/htmlembedded.js +28 -0
  161. data/vendor/assets/javascripts/locomotive/codemirror/modes/htmlmixed.js +152 -0
  162. data/vendor/assets/javascripts/locomotive/codemirror/modes/http.js +113 -0
  163. data/vendor/assets/javascripts/locomotive/codemirror/modes/idl.js +290 -0
  164. data/vendor/assets/javascripts/locomotive/codemirror/modes/jade.js +590 -0
  165. data/vendor/assets/javascripts/locomotive/codemirror/modes/javascript.js +748 -0
  166. data/vendor/assets/javascripts/locomotive/codemirror/modes/jinja2.js +142 -0
  167. data/vendor/assets/javascripts/locomotive/codemirror/modes/jsx.js +147 -0
  168. data/vendor/assets/javascripts/locomotive/codemirror/modes/julia.js +392 -0
  169. data/vendor/assets/javascripts/locomotive/codemirror/modes/livescript.js +280 -0
  170. data/vendor/assets/javascripts/locomotive/codemirror/modes/lua.js +159 -0
  171. data/vendor/assets/javascripts/locomotive/codemirror/modes/markdown.js +797 -0
  172. data/vendor/assets/javascripts/locomotive/codemirror/modes/mathematica.js +176 -0
  173. data/vendor/assets/javascripts/locomotive/codemirror/modes/mbox.js +129 -0
  174. data/vendor/assets/javascripts/locomotive/codemirror/modes/mirc.js +193 -0
  175. data/vendor/assets/javascripts/locomotive/codemirror/modes/mllike.js +205 -0
  176. data/vendor/assets/javascripts/locomotive/codemirror/modes/modelica.js +245 -0
  177. data/vendor/assets/javascripts/locomotive/codemirror/modes/mscgen.js +169 -0
  178. data/vendor/assets/javascripts/locomotive/codemirror/modes/mumps.js +148 -0
  179. data/vendor/assets/javascripts/locomotive/codemirror/modes/nginx.js +178 -0
  180. data/vendor/assets/javascripts/locomotive/codemirror/modes/nsis.js +95 -0
  181. data/vendor/assets/javascripts/locomotive/codemirror/modes/ntriples.js +186 -0
  182. data/vendor/assets/javascripts/locomotive/codemirror/modes/octave.js +135 -0
  183. data/vendor/assets/javascripts/locomotive/codemirror/modes/oz.js +252 -0
  184. data/vendor/assets/javascripts/locomotive/codemirror/modes/pascal.js +109 -0
  185. data/vendor/assets/javascripts/locomotive/codemirror/modes/pegjs.js +114 -0
  186. data/vendor/assets/javascripts/locomotive/codemirror/modes/perl.js +837 -0
  187. data/vendor/assets/javascripts/locomotive/codemirror/modes/php.js +234 -0
  188. data/vendor/assets/javascripts/locomotive/codemirror/modes/pig.js +178 -0
  189. data/vendor/assets/javascripts/locomotive/codemirror/modes/powershell.js +396 -0
  190. data/vendor/assets/javascripts/locomotive/codemirror/modes/properties.js +78 -0
  191. data/vendor/assets/javascripts/locomotive/codemirror/modes/protobuf.js +68 -0
  192. data/vendor/assets/javascripts/locomotive/codemirror/modes/puppet.js +220 -0
  193. data/vendor/assets/javascripts/locomotive/codemirror/modes/python.js +340 -0
  194. data/vendor/assets/javascripts/locomotive/codemirror/modes/q.js +139 -0
  195. data/vendor/assets/javascripts/locomotive/codemirror/modes/r.js +164 -0
  196. data/vendor/assets/javascripts/locomotive/codemirror/modes/rpm.js +109 -0
  197. data/vendor/assets/javascripts/locomotive/codemirror/modes/rst.js +557 -0
  198. data/vendor/assets/javascripts/locomotive/codemirror/modes/ruby.js +285 -0
  199. data/vendor/assets/javascripts/locomotive/codemirror/modes/rust.js +71 -0
  200. data/vendor/assets/javascripts/locomotive/codemirror/modes/sas.js +315 -0
  201. data/vendor/assets/javascripts/locomotive/codemirror/modes/sass.js +414 -0
  202. data/vendor/assets/javascripts/locomotive/codemirror/modes/scheme.js +249 -0
  203. data/vendor/assets/javascripts/locomotive/codemirror/modes/shell.js +139 -0
  204. data/vendor/assets/javascripts/locomotive/codemirror/modes/sieve.js +193 -0
  205. data/vendor/assets/javascripts/locomotive/codemirror/modes/slim.js +575 -0
  206. data/vendor/assets/javascripts/locomotive/codemirror/modes/smalltalk.js +168 -0
  207. data/vendor/assets/javascripts/locomotive/codemirror/modes/smarty.js +225 -0
  208. data/vendor/assets/javascripts/locomotive/codemirror/modes/solr.js +104 -0
  209. data/vendor/assets/javascripts/locomotive/codemirror/modes/soy.js +199 -0
  210. data/vendor/assets/javascripts/locomotive/codemirror/modes/sparql.js +180 -0
  211. data/vendor/assets/javascripts/locomotive/codemirror/modes/spreadsheet.js +112 -0
  212. data/vendor/assets/javascripts/locomotive/codemirror/modes/sql.js +413 -0
  213. data/vendor/assets/javascripts/locomotive/codemirror/modes/stex.js +251 -0
  214. data/vendor/assets/javascripts/locomotive/codemirror/modes/stylus.js +769 -0
  215. data/vendor/assets/javascripts/locomotive/codemirror/modes/swift.js +202 -0
  216. data/vendor/assets/javascripts/locomotive/codemirror/modes/tcl.js +139 -0
  217. data/vendor/assets/javascripts/locomotive/codemirror/modes/textile.js +469 -0
  218. data/vendor/assets/javascripts/locomotive/codemirror/modes/tiddlywiki.js +308 -0
  219. data/vendor/assets/javascripts/locomotive/codemirror/modes/tiki.js +312 -0
  220. data/vendor/assets/javascripts/locomotive/codemirror/modes/toml.js +88 -0
  221. data/vendor/assets/javascripts/locomotive/codemirror/modes/tornado.js +68 -0
  222. data/vendor/assets/javascripts/locomotive/codemirror/modes/troff.js +84 -0
  223. data/vendor/assets/javascripts/locomotive/codemirror/modes/ttcn-cfg.js +214 -0
  224. data/vendor/assets/javascripts/locomotive/codemirror/modes/ttcn.js +283 -0
  225. data/vendor/assets/javascripts/locomotive/codemirror/modes/turtle.js +162 -0
  226. data/vendor/assets/javascripts/locomotive/codemirror/modes/twig.js +141 -0
  227. data/vendor/assets/javascripts/locomotive/codemirror/modes/vb.js +276 -0
  228. data/vendor/assets/javascripts/locomotive/codemirror/modes/vbscript.js +350 -0
  229. data/vendor/assets/javascripts/locomotive/codemirror/modes/velocity.js +201 -0
  230. data/vendor/assets/javascripts/locomotive/codemirror/modes/verilog.js +537 -0
  231. data/vendor/assets/javascripts/locomotive/codemirror/modes/vhdl.js +189 -0
  232. data/vendor/assets/javascripts/locomotive/codemirror/modes/vue.js +69 -0
  233. data/vendor/assets/javascripts/locomotive/codemirror/modes/webidl.js +195 -0
  234. data/vendor/assets/javascripts/locomotive/codemirror/modes/xml.js +394 -0
  235. data/vendor/assets/javascripts/locomotive/codemirror/modes/xquery.js +437 -0
  236. data/vendor/assets/javascripts/locomotive/codemirror/modes/yacas.js +204 -0
  237. data/vendor/assets/javascripts/locomotive/codemirror/modes/yaml-frontmatter.js +68 -0
  238. data/vendor/assets/javascripts/locomotive/codemirror/modes/yaml.js +117 -0
  239. data/vendor/assets/javascripts/locomotive/codemirror/modes/z80.js +116 -0
  240. data/vendor/assets/javascripts/locomotive/codemirror.js +8922 -0
  241. data/vendor/assets/javascripts/locomotive/select2.js +436 -175
  242. data/vendor/assets/javascripts/locomotive/wysihtml5x-toolbar.js +1346 -564
  243. data/vendor/assets/stylesheets/locomotive/codemirror/addons/dialog/dialog.css +32 -0
  244. data/vendor/assets/stylesheets/locomotive/codemirror/addons/display/fullscreen.css +6 -0
  245. data/vendor/assets/stylesheets/locomotive/codemirror/addons/fold/foldgutter.css +20 -0
  246. data/vendor/assets/stylesheets/locomotive/codemirror/addons/hint/show-hint.css +37 -0
  247. data/vendor/assets/stylesheets/locomotive/codemirror/addons/lint/lint.css +73 -0
  248. data/vendor/assets/stylesheets/locomotive/codemirror/addons/merge/merge.css +113 -0
  249. data/vendor/assets/stylesheets/locomotive/codemirror/addons/scroll/simplescrollbars.css +66 -0
  250. data/vendor/assets/stylesheets/locomotive/codemirror/addons/search/matchesonscrollbar.css +8 -0
  251. data/vendor/assets/stylesheets/locomotive/codemirror/addons/tern/tern.css +87 -0
  252. data/vendor/assets/stylesheets/locomotive/codemirror/modes/tiddlywiki.css +14 -0
  253. data/vendor/assets/stylesheets/locomotive/codemirror/modes/tiki.css +26 -0
  254. data/vendor/assets/stylesheets/locomotive/codemirror/themes/3024-day.css +41 -0
  255. data/vendor/assets/stylesheets/locomotive/codemirror/themes/3024-night.css +39 -0
  256. data/vendor/assets/stylesheets/locomotive/codemirror/themes/abcdef.css +32 -0
  257. data/vendor/assets/stylesheets/locomotive/codemirror/themes/ambiance-mobile.css +5 -0
  258. data/vendor/assets/stylesheets/locomotive/codemirror/themes/ambiance.css +74 -0
  259. data/vendor/assets/stylesheets/locomotive/codemirror/themes/base16-dark.css +38 -0
  260. data/vendor/assets/stylesheets/locomotive/codemirror/themes/base16-light.css +38 -0
  261. data/vendor/assets/stylesheets/locomotive/codemirror/themes/bespin.css +34 -0
  262. data/vendor/assets/stylesheets/locomotive/codemirror/themes/blackboard.css +32 -0
  263. data/vendor/assets/stylesheets/locomotive/codemirror/themes/cobalt.css +25 -0
  264. data/vendor/assets/stylesheets/locomotive/codemirror/themes/colorforth.css +33 -0
  265. data/vendor/assets/stylesheets/locomotive/codemirror/themes/dracula.css +41 -0
  266. data/vendor/assets/stylesheets/locomotive/codemirror/themes/eclipse.css +23 -0
  267. data/vendor/assets/stylesheets/locomotive/codemirror/themes/elegant.css +13 -0
  268. data/vendor/assets/stylesheets/locomotive/codemirror/themes/erlang-dark.css +34 -0
  269. data/vendor/assets/stylesheets/locomotive/codemirror/themes/hopscotch.css +34 -0
  270. data/vendor/assets/stylesheets/locomotive/codemirror/themes/icecoder.css +43 -0
  271. data/vendor/assets/stylesheets/locomotive/codemirror/themes/isotope.css +34 -0
  272. data/vendor/assets/stylesheets/locomotive/codemirror/themes/lesser-dark.css +47 -0
  273. data/vendor/assets/stylesheets/locomotive/codemirror/themes/liquibyte.css +95 -0
  274. data/vendor/assets/stylesheets/locomotive/codemirror/themes/material.css +53 -0
  275. data/vendor/assets/stylesheets/locomotive/codemirror/themes/mbo.css +37 -0
  276. data/vendor/assets/stylesheets/locomotive/codemirror/themes/mdn-like.css +46 -0
  277. data/vendor/assets/stylesheets/locomotive/codemirror/themes/midnight.css +45 -0
  278. data/vendor/assets/stylesheets/locomotive/codemirror/themes/monokai.css +36 -0
  279. data/vendor/assets/stylesheets/locomotive/codemirror/themes/neat.css +12 -0
  280. data/vendor/assets/stylesheets/locomotive/codemirror/themes/neo.css +43 -0
  281. data/vendor/assets/stylesheets/locomotive/codemirror/themes/night.css +27 -0
  282. data/vendor/assets/stylesheets/locomotive/codemirror/themes/paraiso-dark.css +38 -0
  283. data/vendor/assets/stylesheets/locomotive/codemirror/themes/paraiso-light.css +38 -0
  284. data/vendor/assets/stylesheets/locomotive/codemirror/themes/pastel-on-dark.css +53 -0
  285. data/vendor/assets/stylesheets/locomotive/codemirror/themes/railscasts.css +34 -0
  286. data/vendor/assets/stylesheets/locomotive/codemirror/themes/rubyblue.css +25 -0
  287. data/vendor/assets/stylesheets/locomotive/codemirror/themes/seti.css +44 -0
  288. data/vendor/assets/stylesheets/locomotive/codemirror/themes/solarized.css +169 -0
  289. data/vendor/assets/stylesheets/locomotive/codemirror/themes/the-matrix.css +30 -0
  290. data/vendor/assets/stylesheets/locomotive/codemirror/themes/tomorrow-night-bright.css +35 -0
  291. data/vendor/assets/stylesheets/locomotive/codemirror/themes/tomorrow-night-eighties.css +38 -0
  292. data/vendor/assets/stylesheets/locomotive/codemirror/themes/ttcn.css +64 -0
  293. data/vendor/assets/stylesheets/locomotive/codemirror/themes/twilight.css +32 -0
  294. data/vendor/assets/stylesheets/locomotive/codemirror/themes/vibrant-ink.css +34 -0
  295. data/vendor/assets/stylesheets/locomotive/codemirror/themes/xq-dark.css +53 -0
  296. data/vendor/assets/stylesheets/locomotive/codemirror/themes/xq-light.css +43 -0
  297. data/vendor/assets/stylesheets/locomotive/codemirror/themes/yeti.css +44 -0
  298. data/vendor/assets/stylesheets/locomotive/codemirror/themes/zenburn.css +37 -0
  299. data/vendor/assets/stylesheets/locomotive/codemirror.css +347 -0
  300. data/vendor/assets/stylesheets/locomotive/select2.css +3 -6
  301. metadata +349 -128
@@ -0,0 +1,146 @@
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
+ var Pos = CodeMirror.Pos;
13
+
14
+ function forEach(arr, f) {
15
+ for (var i = 0, e = arr.length; i < e; ++i) f(arr[i]);
16
+ }
17
+
18
+ function arrayContains(arr, item) {
19
+ if (!Array.prototype.indexOf) {
20
+ var i = arr.length;
21
+ while (i--) {
22
+ if (arr[i] === item) {
23
+ return true;
24
+ }
25
+ }
26
+ return false;
27
+ }
28
+ return arr.indexOf(item) != -1;
29
+ }
30
+
31
+ function scriptHint(editor, keywords, getToken, options) {
32
+ // Find the token at the cursor
33
+ var cur = editor.getCursor(), token = getToken(editor, cur);
34
+ if (/\b(?:string|comment)\b/.test(token.type)) return;
35
+ token.state = CodeMirror.innerMode(editor.getMode(), token.state).state;
36
+
37
+ // If it's not a 'word-style' token, ignore the token.
38
+ if (!/^[\w$_]*$/.test(token.string)) {
39
+ token = {start: cur.ch, end: cur.ch, string: "", state: token.state,
40
+ type: token.string == "." ? "property" : null};
41
+ } else if (token.end > cur.ch) {
42
+ token.end = cur.ch;
43
+ token.string = token.string.slice(0, cur.ch - token.start);
44
+ }
45
+
46
+ var tprop = token;
47
+ // If it is a property, find out what it is a property of.
48
+ while (tprop.type == "property") {
49
+ tprop = getToken(editor, Pos(cur.line, tprop.start));
50
+ if (tprop.string != ".") return;
51
+ tprop = getToken(editor, Pos(cur.line, tprop.start));
52
+ if (!context) var context = [];
53
+ context.push(tprop);
54
+ }
55
+ return {list: getCompletions(token, context, keywords, options),
56
+ from: Pos(cur.line, token.start),
57
+ to: Pos(cur.line, token.end)};
58
+ }
59
+
60
+ function javascriptHint(editor, options) {
61
+ return scriptHint(editor, javascriptKeywords,
62
+ function (e, cur) {return e.getTokenAt(cur);},
63
+ options);
64
+ };
65
+ CodeMirror.registerHelper("hint", "javascript", javascriptHint);
66
+
67
+ function getCoffeeScriptToken(editor, cur) {
68
+ // This getToken, it is for coffeescript, imitates the behavior of
69
+ // getTokenAt method in javascript.js, that is, returning "property"
70
+ // type and treat "." as indepenent token.
71
+ var token = editor.getTokenAt(cur);
72
+ if (cur.ch == token.start + 1 && token.string.charAt(0) == '.') {
73
+ token.end = token.start;
74
+ token.string = '.';
75
+ token.type = "property";
76
+ }
77
+ else if (/^\.[\w$_]*$/.test(token.string)) {
78
+ token.type = "property";
79
+ token.start++;
80
+ token.string = token.string.replace(/\./, '');
81
+ }
82
+ return token;
83
+ }
84
+
85
+ function coffeescriptHint(editor, options) {
86
+ return scriptHint(editor, coffeescriptKeywords, getCoffeeScriptToken, options);
87
+ }
88
+ CodeMirror.registerHelper("hint", "coffeescript", coffeescriptHint);
89
+
90
+ var stringProps = ("charAt charCodeAt indexOf lastIndexOf substring substr slice trim trimLeft trimRight " +
91
+ "toUpperCase toLowerCase split concat match replace search").split(" ");
92
+ var arrayProps = ("length concat join splice push pop shift unshift slice reverse sort indexOf " +
93
+ "lastIndexOf every some filter forEach map reduce reduceRight ").split(" ");
94
+ var funcProps = "prototype apply call bind".split(" ");
95
+ var javascriptKeywords = ("break case catch continue debugger default delete do else false finally for function " +
96
+ "if in instanceof new null return switch throw true try typeof var void while with").split(" ");
97
+ var coffeescriptKeywords = ("and break catch class continue delete do else extends false finally for " +
98
+ "if in instanceof isnt new no not null of off on or return switch then throw true try typeof until void while with yes").split(" ");
99
+
100
+ function getCompletions(token, context, keywords, options) {
101
+ var found = [], start = token.string, global = options && options.globalScope || window;
102
+ function maybeAdd(str) {
103
+ if (str.lastIndexOf(start, 0) == 0 && !arrayContains(found, str)) found.push(str);
104
+ }
105
+ function gatherCompletions(obj) {
106
+ if (typeof obj == "string") forEach(stringProps, maybeAdd);
107
+ else if (obj instanceof Array) forEach(arrayProps, maybeAdd);
108
+ else if (obj instanceof Function) forEach(funcProps, maybeAdd);
109
+ for (var name in obj) maybeAdd(name);
110
+ }
111
+
112
+ if (context && context.length) {
113
+ // If this is a property, see if it belongs to some object we can
114
+ // find in the current environment.
115
+ var obj = context.pop(), base;
116
+ if (obj.type && obj.type.indexOf("variable") === 0) {
117
+ if (options && options.additionalContext)
118
+ base = options.additionalContext[obj.string];
119
+ if (!options || options.useGlobalScope !== false)
120
+ base = base || global[obj.string];
121
+ } else if (obj.type == "string") {
122
+ base = "";
123
+ } else if (obj.type == "atom") {
124
+ base = 1;
125
+ } else if (obj.type == "function") {
126
+ if (global.jQuery != null && (obj.string == '$' || obj.string == 'jQuery') &&
127
+ (typeof global.jQuery == 'function'))
128
+ base = global.jQuery();
129
+ else if (global._ != null && (obj.string == '_') && (typeof global._ == 'function'))
130
+ base = global._();
131
+ }
132
+ while (base != null && context.length)
133
+ base = base[context.pop().string];
134
+ if (base != null) gatherCompletions(base);
135
+ } else {
136
+ // If not, just look in the global object and any local scope
137
+ // (reading into JS mode internals to get at the local and global variables)
138
+ for (var v = token.state.localVars; v; v = v.next) maybeAdd(v.name);
139
+ for (var v = token.state.globalVars; v; v = v.next) maybeAdd(v.name);
140
+ if (!options || options.useGlobalScope !== false)
141
+ gatherCompletions(global);
142
+ forEach(keywords, maybeAdd);
143
+ }
144
+ return found;
145
+ }
146
+ });
@@ -0,0 +1,437 @@
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
+ var HINT_ELEMENT_CLASS = "CodeMirror-hint";
15
+ var ACTIVE_HINT_ELEMENT_CLASS = "CodeMirror-hint-active";
16
+
17
+ // This is the old interface, kept around for now to stay
18
+ // backwards-compatible.
19
+ CodeMirror.showHint = function(cm, getHints, options) {
20
+ if (!getHints) return cm.showHint(options);
21
+ if (options && options.async) getHints.async = true;
22
+ var newOpts = {hint: getHints};
23
+ if (options) for (var prop in options) newOpts[prop] = options[prop];
24
+ return cm.showHint(newOpts);
25
+ };
26
+
27
+ CodeMirror.defineExtension("showHint", function(options) {
28
+ options = parseOptions(this, this.getCursor("start"), options);
29
+ var selections = this.listSelections()
30
+ if (selections.length > 1) return;
31
+ // By default, don't allow completion when something is selected.
32
+ // A hint function can have a `supportsSelection` property to
33
+ // indicate that it can handle selections.
34
+ if (this.somethingSelected()) {
35
+ if (!options.hint.supportsSelection) return;
36
+ // Don't try with cross-line selections
37
+ for (var i = 0; i < selections.length; i++)
38
+ if (selections[i].head.line != selections[i].anchor.line) return;
39
+ }
40
+
41
+ if (this.state.completionActive) this.state.completionActive.close();
42
+ var completion = this.state.completionActive = new Completion(this, options);
43
+ if (!completion.options.hint) return;
44
+
45
+ CodeMirror.signal(this, "startCompletion", this);
46
+ completion.update(true);
47
+ });
48
+
49
+ function Completion(cm, options) {
50
+ this.cm = cm;
51
+ this.options = options;
52
+ this.widget = null;
53
+ this.debounce = 0;
54
+ this.tick = 0;
55
+ this.startPos = this.cm.getCursor("start");
56
+ this.startLen = this.cm.getLine(this.startPos.line).length - this.cm.getSelection().length;
57
+
58
+ var self = this;
59
+ cm.on("cursorActivity", this.activityFunc = function() { self.cursorActivity(); });
60
+ }
61
+
62
+ var requestAnimationFrame = window.requestAnimationFrame || function(fn) {
63
+ return setTimeout(fn, 1000/60);
64
+ };
65
+ var cancelAnimationFrame = window.cancelAnimationFrame || clearTimeout;
66
+
67
+ Completion.prototype = {
68
+ close: function() {
69
+ if (!this.active()) return;
70
+ this.cm.state.completionActive = null;
71
+ this.tick = null;
72
+ this.cm.off("cursorActivity", this.activityFunc);
73
+
74
+ if (this.widget && this.data) CodeMirror.signal(this.data, "close");
75
+ if (this.widget) this.widget.close();
76
+ CodeMirror.signal(this.cm, "endCompletion", this.cm);
77
+ },
78
+
79
+ active: function() {
80
+ return this.cm.state.completionActive == this;
81
+ },
82
+
83
+ pick: function(data, i) {
84
+ var completion = data.list[i];
85
+ if (completion.hint) completion.hint(this.cm, data, completion);
86
+ else this.cm.replaceRange(getText(completion), completion.from || data.from,
87
+ completion.to || data.to, "complete");
88
+ CodeMirror.signal(data, "pick", completion);
89
+ this.close();
90
+ },
91
+
92
+ cursorActivity: function() {
93
+ if (this.debounce) {
94
+ cancelAnimationFrame(this.debounce);
95
+ this.debounce = 0;
96
+ }
97
+
98
+ var pos = this.cm.getCursor(), line = this.cm.getLine(pos.line);
99
+ if (pos.line != this.startPos.line || line.length - pos.ch != this.startLen - this.startPos.ch ||
100
+ pos.ch < this.startPos.ch || this.cm.somethingSelected() ||
101
+ (pos.ch && this.options.closeCharacters.test(line.charAt(pos.ch - 1)))) {
102
+ this.close();
103
+ } else {
104
+ var self = this;
105
+ this.debounce = requestAnimationFrame(function() {self.update();});
106
+ if (this.widget) this.widget.disable();
107
+ }
108
+ },
109
+
110
+ update: function(first) {
111
+ if (this.tick == null) return
112
+ var self = this, myTick = ++this.tick
113
+ fetchHints(this.options.hint, this.cm, this.options, function(data) {
114
+ if (self.tick == myTick) self.finishUpdate(data, first)
115
+ })
116
+ },
117
+
118
+ finishUpdate: function(data, first) {
119
+ if (this.data) CodeMirror.signal(this.data, "update");
120
+
121
+ var picked = (this.widget && this.widget.picked) || (first && this.options.completeSingle);
122
+ if (this.widget) this.widget.close();
123
+
124
+ if (data && this.data && isNewCompletion(this.data, data)) return;
125
+ this.data = data;
126
+
127
+ if (data && data.list.length) {
128
+ if (picked && data.list.length == 1) {
129
+ this.pick(data, 0);
130
+ } else {
131
+ this.widget = new Widget(this, data);
132
+ CodeMirror.signal(data, "shown");
133
+ }
134
+ }
135
+ }
136
+ };
137
+
138
+ function isNewCompletion(old, nw) {
139
+ var moved = CodeMirror.cmpPos(nw.from, old.from)
140
+ return moved > 0 && old.to.ch - old.from.ch != nw.to.ch - nw.from.ch
141
+ }
142
+
143
+ function parseOptions(cm, pos, options) {
144
+ var editor = cm.options.hintOptions;
145
+ var out = {};
146
+ for (var prop in defaultOptions) out[prop] = defaultOptions[prop];
147
+ if (editor) for (var prop in editor)
148
+ if (editor[prop] !== undefined) out[prop] = editor[prop];
149
+ if (options) for (var prop in options)
150
+ if (options[prop] !== undefined) out[prop] = options[prop];
151
+ if (out.hint.resolve) out.hint = out.hint.resolve(cm, pos)
152
+ return out;
153
+ }
154
+
155
+ function getText(completion) {
156
+ if (typeof completion == "string") return completion;
157
+ else return completion.text;
158
+ }
159
+
160
+ function buildKeyMap(completion, handle) {
161
+ var baseMap = {
162
+ Up: function() {handle.moveFocus(-1);},
163
+ Down: function() {handle.moveFocus(1);},
164
+ PageUp: function() {handle.moveFocus(-handle.menuSize() + 1, true);},
165
+ PageDown: function() {handle.moveFocus(handle.menuSize() - 1, true);},
166
+ Home: function() {handle.setFocus(0);},
167
+ End: function() {handle.setFocus(handle.length - 1);},
168
+ Enter: handle.pick,
169
+ Tab: handle.pick,
170
+ Esc: handle.close
171
+ };
172
+ var custom = completion.options.customKeys;
173
+ var ourMap = custom ? {} : baseMap;
174
+ function addBinding(key, val) {
175
+ var bound;
176
+ if (typeof val != "string")
177
+ bound = function(cm) { return val(cm, handle); };
178
+ // This mechanism is deprecated
179
+ else if (baseMap.hasOwnProperty(val))
180
+ bound = baseMap[val];
181
+ else
182
+ bound = val;
183
+ ourMap[key] = bound;
184
+ }
185
+ if (custom)
186
+ for (var key in custom) if (custom.hasOwnProperty(key))
187
+ addBinding(key, custom[key]);
188
+ var extra = completion.options.extraKeys;
189
+ if (extra)
190
+ for (var key in extra) if (extra.hasOwnProperty(key))
191
+ addBinding(key, extra[key]);
192
+ return ourMap;
193
+ }
194
+
195
+ function getHintElement(hintsElement, el) {
196
+ while (el && el != hintsElement) {
197
+ if (el.nodeName.toUpperCase() === "LI" && el.parentNode == hintsElement) return el;
198
+ el = el.parentNode;
199
+ }
200
+ }
201
+
202
+ function Widget(completion, data) {
203
+ this.completion = completion;
204
+ this.data = data;
205
+ this.picked = false;
206
+ var widget = this, cm = completion.cm;
207
+
208
+ var hints = this.hints = document.createElement("ul");
209
+ hints.className = "CodeMirror-hints";
210
+ this.selectedHint = data.selectedHint || 0;
211
+
212
+ var completions = data.list;
213
+ for (var i = 0; i < completions.length; ++i) {
214
+ var elt = hints.appendChild(document.createElement("li")), cur = completions[i];
215
+ var className = HINT_ELEMENT_CLASS + (i != this.selectedHint ? "" : " " + ACTIVE_HINT_ELEMENT_CLASS);
216
+ if (cur.className != null) className = cur.className + " " + className;
217
+ elt.className = className;
218
+ if (cur.render) cur.render(elt, data, cur);
219
+ else elt.appendChild(document.createTextNode(cur.displayText || getText(cur)));
220
+ elt.hintId = i;
221
+ }
222
+
223
+ var pos = cm.cursorCoords(completion.options.alignWithWord ? data.from : null);
224
+ var left = pos.left, top = pos.bottom, below = true;
225
+ hints.style.left = left + "px";
226
+ hints.style.top = top + "px";
227
+ // If we're at the edge of the screen, then we want the menu to appear on the left of the cursor.
228
+ var winW = window.innerWidth || Math.max(document.body.offsetWidth, document.documentElement.offsetWidth);
229
+ var winH = window.innerHeight || Math.max(document.body.offsetHeight, document.documentElement.offsetHeight);
230
+ (completion.options.container || document.body).appendChild(hints);
231
+ var box = hints.getBoundingClientRect(), overlapY = box.bottom - winH;
232
+ var scrolls = hints.scrollHeight > hints.clientHeight + 1
233
+ if (overlapY > 0) {
234
+ var height = box.bottom - box.top, curTop = pos.top - (pos.bottom - box.top);
235
+ if (curTop - height > 0) { // Fits above cursor
236
+ hints.style.top = (top = pos.top - height) + "px";
237
+ below = false;
238
+ } else if (height > winH) {
239
+ hints.style.height = (winH - 5) + "px";
240
+ hints.style.top = (top = pos.bottom - box.top) + "px";
241
+ var cursor = cm.getCursor();
242
+ if (data.from.ch != cursor.ch) {
243
+ pos = cm.cursorCoords(cursor);
244
+ hints.style.left = (left = pos.left) + "px";
245
+ box = hints.getBoundingClientRect();
246
+ }
247
+ }
248
+ }
249
+ var overlapX = box.right - winW;
250
+ if (overlapX > 0) {
251
+ if (box.right - box.left > winW) {
252
+ hints.style.width = (winW - 5) + "px";
253
+ overlapX -= (box.right - box.left) - winW;
254
+ }
255
+ hints.style.left = (left = pos.left - overlapX) + "px";
256
+ }
257
+ if (scrolls) for (var node = hints.firstChild; node; node = node.nextSibling)
258
+ node.style.paddingRight = cm.display.nativeBarWidth + "px"
259
+
260
+ cm.addKeyMap(this.keyMap = buildKeyMap(completion, {
261
+ moveFocus: function(n, avoidWrap) { widget.changeActive(widget.selectedHint + n, avoidWrap); },
262
+ setFocus: function(n) { widget.changeActive(n); },
263
+ menuSize: function() { return widget.screenAmount(); },
264
+ length: completions.length,
265
+ close: function() { completion.close(); },
266
+ pick: function() { widget.pick(); },
267
+ data: data
268
+ }));
269
+
270
+ if (completion.options.closeOnUnfocus) {
271
+ var closingOnBlur;
272
+ cm.on("blur", this.onBlur = function() { closingOnBlur = setTimeout(function() { completion.close(); }, 100); });
273
+ cm.on("focus", this.onFocus = function() { clearTimeout(closingOnBlur); });
274
+ }
275
+
276
+ var startScroll = cm.getScrollInfo();
277
+ cm.on("scroll", this.onScroll = function() {
278
+ var curScroll = cm.getScrollInfo(), editor = cm.getWrapperElement().getBoundingClientRect();
279
+ var newTop = top + startScroll.top - curScroll.top;
280
+ var point = newTop - (window.pageYOffset || (document.documentElement || document.body).scrollTop);
281
+ if (!below) point += hints.offsetHeight;
282
+ if (point <= editor.top || point >= editor.bottom) return completion.close();
283
+ hints.style.top = newTop + "px";
284
+ hints.style.left = (left + startScroll.left - curScroll.left) + "px";
285
+ });
286
+
287
+ CodeMirror.on(hints, "dblclick", function(e) {
288
+ var t = getHintElement(hints, e.target || e.srcElement);
289
+ if (t && t.hintId != null) {widget.changeActive(t.hintId); widget.pick();}
290
+ });
291
+
292
+ CodeMirror.on(hints, "click", function(e) {
293
+ var t = getHintElement(hints, e.target || e.srcElement);
294
+ if (t && t.hintId != null) {
295
+ widget.changeActive(t.hintId);
296
+ if (completion.options.completeOnSingleClick) widget.pick();
297
+ }
298
+ });
299
+
300
+ CodeMirror.on(hints, "mousedown", function() {
301
+ setTimeout(function(){cm.focus();}, 20);
302
+ });
303
+
304
+ CodeMirror.signal(data, "select", completions[0], hints.firstChild);
305
+ return true;
306
+ }
307
+
308
+ Widget.prototype = {
309
+ close: function() {
310
+ if (this.completion.widget != this) return;
311
+ this.completion.widget = null;
312
+ this.hints.parentNode.removeChild(this.hints);
313
+ this.completion.cm.removeKeyMap(this.keyMap);
314
+
315
+ var cm = this.completion.cm;
316
+ if (this.completion.options.closeOnUnfocus) {
317
+ cm.off("blur", this.onBlur);
318
+ cm.off("focus", this.onFocus);
319
+ }
320
+ cm.off("scroll", this.onScroll);
321
+ },
322
+
323
+ disable: function() {
324
+ this.completion.cm.removeKeyMap(this.keyMap);
325
+ var widget = this;
326
+ this.keyMap = {Enter: function() { widget.picked = true; }};
327
+ this.completion.cm.addKeyMap(this.keyMap);
328
+ },
329
+
330
+ pick: function() {
331
+ this.completion.pick(this.data, this.selectedHint);
332
+ },
333
+
334
+ changeActive: function(i, avoidWrap) {
335
+ if (i >= this.data.list.length)
336
+ i = avoidWrap ? this.data.list.length - 1 : 0;
337
+ else if (i < 0)
338
+ i = avoidWrap ? 0 : this.data.list.length - 1;
339
+ if (this.selectedHint == i) return;
340
+ var node = this.hints.childNodes[this.selectedHint];
341
+ node.className = node.className.replace(" " + ACTIVE_HINT_ELEMENT_CLASS, "");
342
+ node = this.hints.childNodes[this.selectedHint = i];
343
+ node.className += " " + ACTIVE_HINT_ELEMENT_CLASS;
344
+ if (node.offsetTop < this.hints.scrollTop)
345
+ this.hints.scrollTop = node.offsetTop - 3;
346
+ else if (node.offsetTop + node.offsetHeight > this.hints.scrollTop + this.hints.clientHeight)
347
+ this.hints.scrollTop = node.offsetTop + node.offsetHeight - this.hints.clientHeight + 3;
348
+ CodeMirror.signal(this.data, "select", this.data.list[this.selectedHint], node);
349
+ },
350
+
351
+ screenAmount: function() {
352
+ return Math.floor(this.hints.clientHeight / this.hints.firstChild.offsetHeight) || 1;
353
+ }
354
+ };
355
+
356
+ function applicableHelpers(cm, helpers) {
357
+ if (!cm.somethingSelected()) return helpers
358
+ var result = []
359
+ for (var i = 0; i < helpers.length; i++)
360
+ if (helpers[i].supportsSelection) result.push(helpers[i])
361
+ return result
362
+ }
363
+
364
+ function fetchHints(hint, cm, options, callback) {
365
+ if (hint.async) {
366
+ hint(cm, callback, options)
367
+ } else {
368
+ var result = hint(cm, options)
369
+ if (result && result.then) result.then(callback)
370
+ else callback(result)
371
+ }
372
+ }
373
+
374
+ function resolveAutoHints(cm, pos) {
375
+ var helpers = cm.getHelpers(pos, "hint"), words
376
+ if (helpers.length) {
377
+ var resolved = function(cm, callback, options) {
378
+ var app = applicableHelpers(cm, helpers);
379
+ function run(i) {
380
+ if (i == app.length) return callback(null)
381
+ fetchHints(app[i], cm, options, function(result) {
382
+ if (result && result.list.length > 0) callback(result)
383
+ else run(i + 1)
384
+ })
385
+ }
386
+ run(0)
387
+ }
388
+ resolved.async = true
389
+ resolved.supportsSelection = true
390
+ return resolved
391
+ } else if (words = cm.getHelper(cm.getCursor(), "hintWords")) {
392
+ return function(cm) { return CodeMirror.hint.fromList(cm, {words: words}) }
393
+ } else if (CodeMirror.hint.anyword) {
394
+ return function(cm, options) { return CodeMirror.hint.anyword(cm, options) }
395
+ } else {
396
+ return function() {}
397
+ }
398
+ }
399
+
400
+ CodeMirror.registerHelper("hint", "auto", {
401
+ resolve: resolveAutoHints
402
+ });
403
+
404
+ CodeMirror.registerHelper("hint", "fromList", function(cm, options) {
405
+ var cur = cm.getCursor(), token = cm.getTokenAt(cur);
406
+ var to = CodeMirror.Pos(cur.line, token.end);
407
+ if (token.string && /\w/.test(token.string[token.string.length - 1])) {
408
+ var term = token.string, from = CodeMirror.Pos(cur.line, token.start);
409
+ } else {
410
+ var term = "", from = to;
411
+ }
412
+ var found = [];
413
+ for (var i = 0; i < options.words.length; i++) {
414
+ var word = options.words[i];
415
+ if (word.slice(0, term.length) == term)
416
+ found.push(word);
417
+ }
418
+
419
+ if (found.length) return {list: found, from: from, to: to};
420
+ });
421
+
422
+ CodeMirror.commands.autocomplete = CodeMirror.showHint;
423
+
424
+ var defaultOptions = {
425
+ hint: CodeMirror.hint.auto,
426
+ completeSingle: true,
427
+ alignWithWord: true,
428
+ closeCharacters: /[\s()\[\]{};:>,]/,
429
+ closeOnUnfocus: true,
430
+ completeOnSingleClick: true,
431
+ container: null,
432
+ customKeys: null,
433
+ extraKeys: null
434
+ };
435
+
436
+ CodeMirror.defineOption("hintOptions", null);
437
+ });