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
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Select2 4.0.6-rc.1
2
+ * Select2 4.0.13
3
3
  * https://select2.github.io
4
4
  *
5
5
  * Released under the MIT license
@@ -777,9 +777,9 @@ S2.define('select2/utils',[
777
777
 
778
778
  var id = 0;
779
779
  Utils.GetUniqueElementId = function (element) {
780
- // Get a unique element Id. If element has no id,
781
- // creates a new unique number, stores it in the id
782
- // attribute and returns the new id.
780
+ // Get a unique element Id. If element has no id,
781
+ // creates a new unique number, stores it in the id
782
+ // attribute and returns the new id.
783
783
  // If an id already exists, it simply returns it.
784
784
 
785
785
  var select2Id = element.getAttribute('data-select2-id');
@@ -798,7 +798,7 @@ S2.define('select2/utils',[
798
798
 
799
799
  Utils.StoreData = function (element, name, value) {
800
800
  // Stores an item in the cache for a specified element.
801
- // name is the cache key.
801
+ // name is the cache key.
802
802
  var id = Utils.GetUniqueElementId(element);
803
803
  if (!Utils.__cache[id]) {
804
804
  Utils.__cache[id] = {};
@@ -809,19 +809,20 @@ S2.define('select2/utils',[
809
809
 
810
810
  Utils.GetData = function (element, name) {
811
811
  // Retrieves a value from the cache by its key (name)
812
- // name is optional. If no name specified, return
812
+ // name is optional. If no name specified, return
813
813
  // all cache items for the specified element.
814
814
  // and for a specified element.
815
815
  var id = Utils.GetUniqueElementId(element);
816
816
  if (name) {
817
817
  if (Utils.__cache[id]) {
818
- return Utils.__cache[id][name] != null ?
819
- Utils.__cache[id][name]:
820
- $(element).data(name); // Fallback to HTML5 data attribs.
818
+ if (Utils.__cache[id][name] != null) {
819
+ return Utils.__cache[id][name];
820
+ }
821
+ return $(element).data(name); // Fallback to HTML5 data attribs.
821
822
  }
822
823
  return $(element).data(name); // Fallback to HTML5 data attribs.
823
824
  } else {
824
- return Utils.__cache[id];
825
+ return Utils.__cache[id];
825
826
  }
826
827
  };
827
828
 
@@ -831,6 +832,8 @@ S2.define('select2/utils',[
831
832
  if (Utils.__cache[id] != null) {
832
833
  delete Utils.__cache[id];
833
834
  }
835
+
836
+ element.removeAttribute('data-select2-id');
834
837
  };
835
838
 
836
839
  return Utils;
@@ -852,7 +855,7 @@ S2.define('select2/results',[
852
855
 
853
856
  Results.prototype.render = function () {
854
857
  var $results = $(
855
- '<ul class="select2-results__options" role="tree"></ul>'
858
+ '<ul class="select2-results__options" role="listbox"></ul>'
856
859
  );
857
860
 
858
861
  if (this.options.get('multiple')) {
@@ -875,7 +878,7 @@ S2.define('select2/results',[
875
878
  this.hideLoading();
876
879
 
877
880
  var $message = $(
878
- '<li role="treeitem" aria-live="assertive"' +
881
+ '<li role="alert" aria-live="assertive"' +
879
882
  ' class="select2-results__option"></li>'
880
883
  );
881
884
 
@@ -1009,11 +1012,16 @@ S2.define('select2/results',[
1009
1012
  option.className = 'select2-results__option';
1010
1013
 
1011
1014
  var attrs = {
1012
- 'role': 'treeitem',
1015
+ 'role': 'option',
1013
1016
  'aria-selected': 'false'
1014
1017
  };
1015
1018
 
1016
- if (data.disabled) {
1019
+ var matches = window.Element.prototype.matches ||
1020
+ window.Element.prototype.msMatchesSelector ||
1021
+ window.Element.prototype.webkitMatchesSelector;
1022
+
1023
+ if ((data.element != null && matches.call(data.element, ':disabled')) ||
1024
+ (data.element == null && data.disabled)) {
1017
1025
  delete attrs['aria-selected'];
1018
1026
  attrs['aria-disabled'] = 'true';
1019
1027
  }
@@ -1114,7 +1122,10 @@ S2.define('select2/results',[
1114
1122
  }
1115
1123
 
1116
1124
  self.setClasses();
1117
- self.highlightFirstItem();
1125
+
1126
+ if (self.options.get('scrollAfterSelect')) {
1127
+ self.highlightFirstItem();
1128
+ }
1118
1129
  });
1119
1130
 
1120
1131
  container.on('unselect', function () {
@@ -1123,7 +1134,10 @@ S2.define('select2/results',[
1123
1134
  }
1124
1135
 
1125
1136
  self.setClasses();
1126
- self.highlightFirstItem();
1137
+
1138
+ if (self.options.get('scrollAfterSelect')) {
1139
+ self.highlightFirstItem();
1140
+ }
1127
1141
  });
1128
1142
 
1129
1143
  container.on('open', function () {
@@ -1177,7 +1191,7 @@ S2.define('select2/results',[
1177
1191
 
1178
1192
  var currentIndex = $options.index($highlighted);
1179
1193
 
1180
- // If we are already at te top, don't move further
1194
+ // If we are already at the top, don't move further
1181
1195
  // If no options, currentIndex will be -1
1182
1196
  if (currentIndex <= 0) {
1183
1197
  return;
@@ -1418,6 +1432,7 @@ S2.define('select2/selection/base',[
1418
1432
 
1419
1433
  $selection.attr('title', this.$element.attr('title'));
1420
1434
  $selection.attr('tabindex', this._tabindex);
1435
+ $selection.attr('aria-disabled', 'false');
1421
1436
 
1422
1437
  this.$selection = $selection;
1423
1438
 
@@ -1427,7 +1442,6 @@ S2.define('select2/selection/base',[
1427
1442
  BaseSelection.prototype.bind = function (container, $container) {
1428
1443
  var self = this;
1429
1444
 
1430
- var id = container.id + '-container';
1431
1445
  var resultsId = container.id + '-results';
1432
1446
 
1433
1447
  this.container = container;
@@ -1470,20 +1484,19 @@ S2.define('select2/selection/base',[
1470
1484
  self.$selection.removeAttr('aria-activedescendant');
1471
1485
  self.$selection.removeAttr('aria-owns');
1472
1486
 
1473
- self.$selection.focus();
1474
- window.setTimeout(function () {
1475
- self.$selection.focus();
1476
- }, 0);
1487
+ self.$selection.trigger('focus');
1477
1488
 
1478
1489
  self._detachCloseHandler(container);
1479
1490
  });
1480
1491
 
1481
1492
  container.on('enable', function () {
1482
1493
  self.$selection.attr('tabindex', self._tabindex);
1494
+ self.$selection.attr('aria-disabled', 'false');
1483
1495
  });
1484
1496
 
1485
1497
  container.on('disable', function () {
1486
1498
  self.$selection.attr('tabindex', '-1');
1499
+ self.$selection.attr('aria-disabled', 'true');
1487
1500
  });
1488
1501
  };
1489
1502
 
@@ -1506,7 +1519,6 @@ S2.define('select2/selection/base',[
1506
1519
  };
1507
1520
 
1508
1521
  BaseSelection.prototype._attachCloseHandler = function (container) {
1509
- var self = this;
1510
1522
 
1511
1523
  $(document.body).on('mousedown.select2.' + container.id, function (e) {
1512
1524
  var $target = $(e.target);
@@ -1516,8 +1528,6 @@ S2.define('select2/selection/base',[
1516
1528
  var $all = $('.select2.select2-container--open');
1517
1529
 
1518
1530
  $all.each(function () {
1519
- var $this = $(this);
1520
-
1521
1531
  if (this == $select[0]) {
1522
1532
  return;
1523
1533
  }
@@ -1546,6 +1556,27 @@ S2.define('select2/selection/base',[
1546
1556
  throw new Error('The `update` method must be defined in child classes.');
1547
1557
  };
1548
1558
 
1559
+ /**
1560
+ * Helper method to abstract the "enabled" (not "disabled") state of this
1561
+ * object.
1562
+ *
1563
+ * @return {true} if the instance is not disabled.
1564
+ * @return {false} if the instance is disabled.
1565
+ */
1566
+ BaseSelection.prototype.isEnabled = function () {
1567
+ return !this.isDisabled();
1568
+ };
1569
+
1570
+ /**
1571
+ * Helper method to abstract the "disabled" state of this object.
1572
+ *
1573
+ * @return {true} if the disabled option is true.
1574
+ * @return {false} if the disabled option is false.
1575
+ */
1576
+ BaseSelection.prototype.isDisabled = function () {
1577
+ return this.options.get('disabled');
1578
+ };
1579
+
1549
1580
  return BaseSelection;
1550
1581
  });
1551
1582
 
@@ -1610,7 +1641,7 @@ S2.define('select2/selection/single',[
1610
1641
 
1611
1642
  container.on('focus', function (evt) {
1612
1643
  if (!container.isOpen()) {
1613
- self.$selection.focus();
1644
+ self.$selection.trigger('focus');
1614
1645
  }
1615
1646
  });
1616
1647
  };
@@ -1644,7 +1675,14 @@ S2.define('select2/selection/single',[
1644
1675
  var formatted = this.display(selection, $rendered);
1645
1676
 
1646
1677
  $rendered.empty().append(formatted);
1647
- $rendered.attr('title', selection.title || selection.text);
1678
+
1679
+ var title = selection.title || selection.text;
1680
+
1681
+ if (title) {
1682
+ $rendered.attr('title', title);
1683
+ } else {
1684
+ $rendered.removeAttr('title');
1685
+ }
1648
1686
  };
1649
1687
 
1650
1688
  return SingleSelection;
@@ -1689,7 +1727,7 @@ S2.define('select2/selection/multiple',[
1689
1727
  '.select2-selection__choice__remove',
1690
1728
  function (evt) {
1691
1729
  // Ignore the event if it is disabled
1692
- if (self.options.get('disabled')) {
1730
+ if (self.isDisabled()) {
1693
1731
  return;
1694
1732
  }
1695
1733
 
@@ -1747,7 +1785,12 @@ S2.define('select2/selection/multiple',[
1747
1785
  var formatted = this.display(selection, $selection);
1748
1786
 
1749
1787
  $selection.append(formatted);
1750
- $selection.attr('title', selection.title || selection.text);
1788
+
1789
+ var title = selection.title || selection.text;
1790
+
1791
+ if (title) {
1792
+ $selection.attr('title', title);
1793
+ }
1751
1794
 
1752
1795
  Utils.StoreData($selection[0], 'data', selection);
1753
1796
 
@@ -1845,7 +1888,7 @@ S2.define('select2/selection/allowClear',[
1845
1888
 
1846
1889
  AllowClear.prototype._handleClear = function (_, evt) {
1847
1890
  // Ignore the event if it is disabled
1848
- if (this.options.get('disabled')) {
1891
+ if (this.isDisabled()) {
1849
1892
  return;
1850
1893
  }
1851
1894
 
@@ -1888,7 +1931,7 @@ S2.define('select2/selection/allowClear',[
1888
1931
  }
1889
1932
  }
1890
1933
 
1891
- this.$element.trigger('change');
1934
+ this.$element.trigger('input').trigger('change');
1892
1935
 
1893
1936
  this.trigger('toggle', {});
1894
1937
  };
@@ -1911,8 +1954,10 @@ S2.define('select2/selection/allowClear',[
1911
1954
  return;
1912
1955
  }
1913
1956
 
1957
+ var removeAll = this.options.get('translations').get('removeAllItems');
1958
+
1914
1959
  var $remove = $(
1915
- '<span class="select2-selection__clear">' +
1960
+ '<span class="select2-selection__clear" title="' + removeAll() +'">' +
1916
1961
  '&times;' +
1917
1962
  '</span>'
1918
1963
  );
@@ -1938,7 +1983,7 @@ S2.define('select2/selection/search',[
1938
1983
  '<li class="select2-search select2-search--inline">' +
1939
1984
  '<input class="select2-search__field" type="search" tabindex="-1"' +
1940
1985
  ' autocomplete="off" autocorrect="off" autocapitalize="none"' +
1941
- ' spellcheck="false" role="textbox" aria-autocomplete="list" />' +
1986
+ ' spellcheck="false" role="searchbox" aria-autocomplete="list" />' +
1942
1987
  '</li>'
1943
1988
  );
1944
1989
 
@@ -1955,14 +2000,18 @@ S2.define('select2/selection/search',[
1955
2000
  Search.prototype.bind = function (decorated, container, $container) {
1956
2001
  var self = this;
1957
2002
 
2003
+ var resultsId = container.id + '-results';
2004
+
1958
2005
  decorated.call(this, container, $container);
1959
2006
 
1960
2007
  container.on('open', function () {
2008
+ self.$search.attr('aria-controls', resultsId);
1961
2009
  self.$search.trigger('focus');
1962
2010
  });
1963
2011
 
1964
2012
  container.on('close', function () {
1965
2013
  self.$search.val('');
2014
+ self.$search.removeAttr('aria-controls');
1966
2015
  self.$search.removeAttr('aria-activedescendant');
1967
2016
  self.$search.trigger('focus');
1968
2017
  });
@@ -1982,7 +2031,11 @@ S2.define('select2/selection/search',[
1982
2031
  });
1983
2032
 
1984
2033
  container.on('results:focus', function (params) {
1985
- self.$search.attr('aria-activedescendant', params.id);
2034
+ if (params.data._resultId) {
2035
+ self.$search.attr('aria-activedescendant', params.data._resultId);
2036
+ } else {
2037
+ self.$search.removeAttr('aria-activedescendant');
2038
+ }
1986
2039
  });
1987
2040
 
1988
2041
  this.$selection.on('focusin', '.select2-search--inline', function (evt) {
@@ -2016,6 +2069,12 @@ S2.define('select2/selection/search',[
2016
2069
  }
2017
2070
  });
2018
2071
 
2072
+ this.$selection.on('click', '.select2-search--inline', function (evt) {
2073
+ if (self.$search.val()) {
2074
+ evt.stopPropagation();
2075
+ }
2076
+ });
2077
+
2019
2078
  // Try to detect the IE version should the `documentMode` property that
2020
2079
  // is stored on the document. This is only implemented in IE and is
2021
2080
  // slightly cleaner than doing a user agent check.
@@ -2101,13 +2160,7 @@ S2.define('select2/selection/search',[
2101
2160
 
2102
2161
  this.resizeSearch();
2103
2162
  if (searchHadFocus) {
2104
- var isTagInput = this.$element.find('[data-select2-tag]').length;
2105
- if (isTagInput) {
2106
- // fix IE11 bug where tag input lost focus
2107
- this.$element.focus();
2108
- } else {
2109
- this.$search.focus();
2110
- }
2163
+ this.$search.trigger('focus');
2111
2164
  }
2112
2165
  };
2113
2166
 
@@ -2140,7 +2193,7 @@ S2.define('select2/selection/search',[
2140
2193
  var width = '';
2141
2194
 
2142
2195
  if (this.$search.attr('placeholder') !== '') {
2143
- width = this.$selection.find('.select2-selection__rendered').innerWidth();
2196
+ width = this.$selection.find('.select2-selection__rendered').width();
2144
2197
  } else {
2145
2198
  var minimumWidth = this.$search.val().length + 1;
2146
2199
 
@@ -2503,6 +2556,7 @@ S2.define('select2/diacritics',[
2503
2556
  '\u019F': 'O',
2504
2557
  '\uA74A': 'O',
2505
2558
  '\uA74C': 'O',
2559
+ '\u0152': 'OE',
2506
2560
  '\u01A2': 'OI',
2507
2561
  '\uA74E': 'OO',
2508
2562
  '\u0222': 'OU',
@@ -2912,6 +2966,7 @@ S2.define('select2/diacritics',[
2912
2966
  '\uA74B': 'o',
2913
2967
  '\uA74D': 'o',
2914
2968
  '\u0275': 'o',
2969
+ '\u0153': 'oe',
2915
2970
  '\u01A3': 'oi',
2916
2971
  '\u0223': 'ou',
2917
2972
  '\uA74F': 'oo',
@@ -3080,8 +3135,9 @@ S2.define('select2/diacritics',[
3080
3135
  '\u03CD': '\u03C5',
3081
3136
  '\u03CB': '\u03C5',
3082
3137
  '\u03B0': '\u03C5',
3083
- '\u03C9': '\u03C9',
3084
- '\u03C2': '\u03C3'
3138
+ '\u03CE': '\u03C9',
3139
+ '\u03C2': '\u03C3',
3140
+ '\u2019': '\''
3085
3141
  };
3086
3142
 
3087
3143
  return diacritics;
@@ -3166,7 +3222,7 @@ S2.define('select2/data/select',[
3166
3222
  if ($(data.element).is('option')) {
3167
3223
  data.element.selected = true;
3168
3224
 
3169
- this.$element.trigger('change');
3225
+ this.$element.trigger('input').trigger('change');
3170
3226
 
3171
3227
  return;
3172
3228
  }
@@ -3187,13 +3243,13 @@ S2.define('select2/data/select',[
3187
3243
  }
3188
3244
 
3189
3245
  self.$element.val(val);
3190
- self.$element.trigger('change');
3246
+ self.$element.trigger('input').trigger('change');
3191
3247
  });
3192
3248
  } else {
3193
3249
  var val = data.id;
3194
3250
 
3195
3251
  this.$element.val(val);
3196
- this.$element.trigger('change');
3252
+ this.$element.trigger('input').trigger('change');
3197
3253
  }
3198
3254
  };
3199
3255
 
@@ -3209,7 +3265,7 @@ S2.define('select2/data/select',[
3209
3265
  if ($(data.element).is('option')) {
3210
3266
  data.element.selected = false;
3211
3267
 
3212
- this.$element.trigger('change');
3268
+ this.$element.trigger('input').trigger('change');
3213
3269
 
3214
3270
  return;
3215
3271
  }
@@ -3227,7 +3283,7 @@ S2.define('select2/data/select',[
3227
3283
 
3228
3284
  self.$element.val(val);
3229
3285
 
3230
- self.$element.trigger('change');
3286
+ self.$element.trigger('input').trigger('change');
3231
3287
  });
3232
3288
  };
3233
3289
 
@@ -3420,15 +3476,19 @@ S2.define('select2/data/array',[
3420
3476
  'jquery'
3421
3477
  ], function (SelectAdapter, Utils, $) {
3422
3478
  function ArrayAdapter ($element, options) {
3423
- var data = options.get('data') || [];
3479
+ this._dataToConvert = options.get('data') || [];
3424
3480
 
3425
3481
  ArrayAdapter.__super__.constructor.call(this, $element, options);
3426
-
3427
- this.addOptions(this.convertToOptions(data));
3428
3482
  }
3429
3483
 
3430
3484
  Utils.Extend(ArrayAdapter, SelectAdapter);
3431
3485
 
3486
+ ArrayAdapter.prototype.bind = function (container, $container) {
3487
+ ArrayAdapter.__super__.bind.call(this, container, $container);
3488
+
3489
+ this.addOptions(this.convertToOptions(this._dataToConvert));
3490
+ };
3491
+
3432
3492
  ArrayAdapter.prototype.select = function (data) {
3433
3493
  var $option = this.$element.find('option').filter(function (i, elm) {
3434
3494
  return elm.value == data.id.toString();
@@ -3718,8 +3778,6 @@ S2.define('select2/data/tags',[
3718
3778
  };
3719
3779
 
3720
3780
  Tags.prototype._removeOldTags = function (_) {
3721
- var tag = this._lastTag;
3722
-
3723
3781
  var $options = this.$element.find('option[data-select2-tag]');
3724
3782
 
3725
3783
  $options.each(function () {
@@ -3794,7 +3852,7 @@ S2.define('select2/data/tokenizer',[
3794
3852
  // Replace the search term if we have the search box
3795
3853
  if (this.$search.length) {
3796
3854
  this.$search.val(tokenData.term);
3797
- this.$search.focus();
3855
+ this.$search.trigger('focus');
3798
3856
  }
3799
3857
 
3800
3858
  params.term = tokenData.term;
@@ -3923,10 +3981,30 @@ S2.define('select2/data/maximumSelectionLength',[
3923
3981
  decorated.call(this, $e, options);
3924
3982
  }
3925
3983
 
3984
+ MaximumSelectionLength.prototype.bind =
3985
+ function (decorated, container, $container) {
3986
+ var self = this;
3987
+
3988
+ decorated.call(this, container, $container);
3989
+
3990
+ container.on('select', function () {
3991
+ self._checkIfMaximumSelected();
3992
+ });
3993
+ };
3994
+
3926
3995
  MaximumSelectionLength.prototype.query =
3927
3996
  function (decorated, params, callback) {
3928
3997
  var self = this;
3929
3998
 
3999
+ this._checkIfMaximumSelected(function () {
4000
+ decorated.call(self, params, callback);
4001
+ });
4002
+ };
4003
+
4004
+ MaximumSelectionLength.prototype._checkIfMaximumSelected =
4005
+ function (_, successCallback) {
4006
+ var self = this;
4007
+
3930
4008
  this.current(function (currentData) {
3931
4009
  var count = currentData != null ? currentData.length : 0;
3932
4010
  if (self.maximumSelectionLength > 0 &&
@@ -3939,7 +4017,10 @@ S2.define('select2/data/maximumSelectionLength',[
3939
4017
  });
3940
4018
  return;
3941
4019
  }
3942
- decorated.call(self, params, callback);
4020
+
4021
+ if (successCallback) {
4022
+ successCallback();
4023
+ }
3943
4024
  });
3944
4025
  };
3945
4026
 
@@ -3978,7 +4059,7 @@ S2.define('select2/dropdown',[
3978
4059
  };
3979
4060
 
3980
4061
  Dropdown.prototype.position = function ($dropdown, $container) {
3981
- // Should be implmented in subclasses
4062
+ // Should be implemented in subclasses
3982
4063
  };
3983
4064
 
3984
4065
  Dropdown.prototype.destroy = function () {
@@ -4002,7 +4083,7 @@ S2.define('select2/dropdown/search',[
4002
4083
  '<span class="select2-search select2-search--dropdown">' +
4003
4084
  '<input class="select2-search__field" type="search" tabindex="-1"' +
4004
4085
  ' autocomplete="off" autocorrect="off" autocapitalize="none"' +
4005
- ' spellcheck="false" role="textbox" />' +
4086
+ ' spellcheck="false" role="searchbox" aria-autocomplete="list" />' +
4006
4087
  '</span>'
4007
4088
  );
4008
4089
 
@@ -4017,6 +4098,8 @@ S2.define('select2/dropdown/search',[
4017
4098
  Search.prototype.bind = function (decorated, container, $container) {
4018
4099
  var self = this;
4019
4100
 
4101
+ var resultsId = container.id + '-results';
4102
+
4020
4103
  decorated.call(this, container, $container);
4021
4104
 
4022
4105
  this.$search.on('keydown', function (evt) {
@@ -4039,24 +4122,27 @@ S2.define('select2/dropdown/search',[
4039
4122
 
4040
4123
  container.on('open', function () {
4041
4124
  self.$search.attr('tabindex', 0);
4125
+ self.$search.attr('aria-controls', resultsId);
4042
4126
 
4043
- self.$search.focus();
4127
+ self.$search.trigger('focus');
4044
4128
 
4045
4129
  window.setTimeout(function () {
4046
- self.$search.focus();
4130
+ self.$search.trigger('focus');
4047
4131
  }, 0);
4048
4132
  });
4049
4133
 
4050
4134
  container.on('close', function () {
4051
4135
  self.$search.attr('tabindex', -1);
4136
+ self.$search.removeAttr('aria-controls');
4137
+ self.$search.removeAttr('aria-activedescendant');
4052
4138
 
4053
4139
  self.$search.val('');
4054
- self.$search.blur();
4140
+ self.$search.trigger('blur');
4055
4141
  });
4056
4142
 
4057
4143
  container.on('focus', function () {
4058
4144
  if (!container.isOpen()) {
4059
- self.$search.focus();
4145
+ self.$search.trigger('focus');
4060
4146
  }
4061
4147
  });
4062
4148
 
@@ -4071,6 +4157,14 @@ S2.define('select2/dropdown/search',[
4071
4157
  }
4072
4158
  }
4073
4159
  });
4160
+
4161
+ container.on('results:focus', function (params) {
4162
+ if (params.data._resultId) {
4163
+ self.$search.attr('aria-activedescendant', params.data._resultId);
4164
+ } else {
4165
+ self.$search.removeAttr('aria-activedescendant');
4166
+ }
4167
+ });
4074
4168
  };
4075
4169
 
4076
4170
  Search.prototype.handleSearch = function (evt) {
@@ -4155,6 +4249,7 @@ S2.define('select2/dropdown/infiniteScroll',[
4155
4249
 
4156
4250
  if (this.showLoadingMore(data)) {
4157
4251
  this.$results.append(this.$loadingMore);
4252
+ this.loadMoreIfNeeded();
4158
4253
  }
4159
4254
  };
4160
4255
 
@@ -4173,25 +4268,27 @@ S2.define('select2/dropdown/infiniteScroll',[
4173
4268
  self.loading = true;
4174
4269
  });
4175
4270
 
4176
- this.$results.on('scroll', function () {
4177
- var isLoadMoreVisible = $.contains(
4178
- document.documentElement,
4179
- self.$loadingMore[0]
4180
- );
4271
+ this.$results.on('scroll', this.loadMoreIfNeeded.bind(this));
4272
+ };
4181
4273
 
4182
- if (self.loading || !isLoadMoreVisible) {
4183
- return;
4184
- }
4274
+ InfiniteScroll.prototype.loadMoreIfNeeded = function () {
4275
+ var isLoadMoreVisible = $.contains(
4276
+ document.documentElement,
4277
+ this.$loadingMore[0]
4278
+ );
4185
4279
 
4186
- var currentOffset = self.$results.offset().top +
4187
- self.$results.outerHeight(false);
4188
- var loadingMoreOffset = self.$loadingMore.offset().top +
4189
- self.$loadingMore.outerHeight(false);
4280
+ if (this.loading || !isLoadMoreVisible) {
4281
+ return;
4282
+ }
4190
4283
 
4191
- if (currentOffset + 50 >= loadingMoreOffset) {
4192
- self.loadMore();
4193
- }
4194
- });
4284
+ var currentOffset = this.$results.offset().top +
4285
+ this.$results.outerHeight(false);
4286
+ var loadingMoreOffset = this.$loadingMore.offset().top +
4287
+ this.$loadingMore.outerHeight(false);
4288
+
4289
+ if (currentOffset + 50 >= loadingMoreOffset) {
4290
+ this.loadMore();
4291
+ }
4195
4292
  };
4196
4293
 
4197
4294
  InfiniteScroll.prototype.loadMore = function () {
@@ -4212,7 +4309,7 @@ S2.define('select2/dropdown/infiniteScroll',[
4212
4309
  var $option = $(
4213
4310
  '<li ' +
4214
4311
  'class="select2-results__option select2-results__option--load-more"' +
4215
- 'role="treeitem" aria-disabled="true"></li>'
4312
+ 'role="option" aria-disabled="true"></li>'
4216
4313
  );
4217
4314
 
4218
4315
  var message = this.options.get('translations').get('loadingMore');
@@ -4230,7 +4327,7 @@ S2.define('select2/dropdown/attachBody',[
4230
4327
  '../utils'
4231
4328
  ], function ($, Utils) {
4232
4329
  function AttachBody (decorated, $element, options) {
4233
- this.$dropdownParent = options.get('dropdownParent') || $(document.body);
4330
+ this.$dropdownParent = $(options.get('dropdownParent') || document.body);
4234
4331
 
4235
4332
  decorated.call(this, $element, options);
4236
4333
  }
@@ -4238,27 +4335,14 @@ S2.define('select2/dropdown/attachBody',[
4238
4335
  AttachBody.prototype.bind = function (decorated, container, $container) {
4239
4336
  var self = this;
4240
4337
 
4241
- var setupResultsEvents = false;
4242
-
4243
4338
  decorated.call(this, container, $container);
4244
4339
 
4245
4340
  container.on('open', function () {
4246
4341
  self._showDropdown();
4247
4342
  self._attachPositioningHandler(container);
4248
4343
 
4249
- if (!setupResultsEvents) {
4250
- setupResultsEvents = true;
4251
-
4252
- container.on('results:all', function () {
4253
- self._positionDropdown();
4254
- self._resizeDropdown();
4255
- });
4256
-
4257
- container.on('results:append', function () {
4258
- self._positionDropdown();
4259
- self._resizeDropdown();
4260
- });
4261
- }
4344
+ // Must bind after the results handlers to ensure correct sizing
4345
+ self._bindContainerResultHandlers(container);
4262
4346
  });
4263
4347
 
4264
4348
  container.on('close', function () {
@@ -4307,6 +4391,44 @@ S2.define('select2/dropdown/attachBody',[
4307
4391
  this.$dropdownContainer.detach();
4308
4392
  };
4309
4393
 
4394
+ AttachBody.prototype._bindContainerResultHandlers =
4395
+ function (decorated, container) {
4396
+
4397
+ // These should only be bound once
4398
+ if (this._containerResultsHandlersBound) {
4399
+ return;
4400
+ }
4401
+
4402
+ var self = this;
4403
+
4404
+ container.on('results:all', function () {
4405
+ self._positionDropdown();
4406
+ self._resizeDropdown();
4407
+ });
4408
+
4409
+ container.on('results:append', function () {
4410
+ self._positionDropdown();
4411
+ self._resizeDropdown();
4412
+ });
4413
+
4414
+ container.on('results:message', function () {
4415
+ self._positionDropdown();
4416
+ self._resizeDropdown();
4417
+ });
4418
+
4419
+ container.on('select', function () {
4420
+ self._positionDropdown();
4421
+ self._resizeDropdown();
4422
+ });
4423
+
4424
+ container.on('unselect', function () {
4425
+ self._positionDropdown();
4426
+ self._resizeDropdown();
4427
+ });
4428
+
4429
+ this._containerResultsHandlersBound = true;
4430
+ };
4431
+
4310
4432
  AttachBody.prototype._attachPositioningHandler =
4311
4433
  function (decorated, container) {
4312
4434
  var self = this;
@@ -4383,16 +4505,26 @@ S2.define('select2/dropdown/attachBody',[
4383
4505
  top: container.bottom
4384
4506
  };
4385
4507
 
4386
- // Determine what the parent element is to use for calciulating the offset
4508
+ // Determine what the parent element is to use for calculating the offset
4387
4509
  var $offsetParent = this.$dropdownParent;
4388
4510
 
4389
- // For statically positoned elements, we need to get the element
4511
+ // For statically positioned elements, we need to get the element
4390
4512
  // that is determining the offset
4391
4513
  if ($offsetParent.css('position') === 'static') {
4392
4514
  $offsetParent = $offsetParent.offsetParent();
4393
4515
  }
4394
4516
 
4395
- var parentOffset = $offsetParent.offset();
4517
+ var parentOffset = {
4518
+ top: 0,
4519
+ left: 0
4520
+ };
4521
+
4522
+ if (
4523
+ $.contains(document.body, $offsetParent[0]) ||
4524
+ $offsetParent[0].isConnected
4525
+ ) {
4526
+ parentOffset = $offsetParent.offset();
4527
+ }
4396
4528
 
4397
4529
  css.top -= parentOffset.top;
4398
4530
  css.left -= parentOffset.left;
@@ -4562,7 +4694,7 @@ S2.define('select2/dropdown/closeOnSelect',[
4562
4694
  var originalEvent = evt.originalEvent;
4563
4695
 
4564
4696
  // Don't close if the control key is being held
4565
- if (originalEvent && originalEvent.ctrlKey) {
4697
+ if (originalEvent && (originalEvent.ctrlKey || originalEvent.metaKey)) {
4566
4698
  return;
4567
4699
  }
4568
4700
 
@@ -4616,6 +4748,9 @@ S2.define('select2/i18n/en',[],function () {
4616
4748
  },
4617
4749
  searching: function () {
4618
4750
  return 'Searching…';
4751
+ },
4752
+ removeAllItems: function () {
4753
+ return 'Remove all items';
4619
4754
  }
4620
4755
  };
4621
4756
  });
@@ -4854,66 +4989,29 @@ S2.define('select2/defaults',[
4854
4989
  );
4855
4990
  }
4856
4991
 
4857
- if (typeof options.language === 'string') {
4858
- // Check if the language is specified with a region
4859
- if (options.language.indexOf('-') > 0) {
4860
- // Extract the region information if it is included
4861
- var languageParts = options.language.split('-');
4862
- var baseLanguage = languageParts[0];
4863
-
4864
- options.language = [options.language, baseLanguage];
4865
- } else {
4866
- options.language = [options.language];
4867
- }
4868
- }
4992
+ // If the defaults were not previously applied from an element, it is
4993
+ // possible for the language option to have not been resolved
4994
+ options.language = this._resolveLanguage(options.language);
4869
4995
 
4870
- if ($.isArray(options.language)) {
4871
- var languages = new Translation();
4872
- options.language.push('en');
4996
+ // Always fall back to English since it will always be complete
4997
+ options.language.push('en');
4873
4998
 
4874
- var languageNames = options.language;
4999
+ var uniqueLanguages = [];
4875
5000
 
4876
- for (var l = 0; l < languageNames.length; l++) {
4877
- var name = languageNames[l];
4878
- var language = {};
5001
+ for (var l = 0; l < options.language.length; l++) {
5002
+ var language = options.language[l];
4879
5003
 
4880
- try {
4881
- // Try to load it with the original name
4882
- language = Translation.loadPath(name);
4883
- } catch (e) {
4884
- try {
4885
- // If we couldn't load it, check if it wasn't the full path
4886
- name = this.defaults.amdLanguageBase + name;
4887
- language = Translation.loadPath(name);
4888
- } catch (ex) {
4889
- // The translation could not be loaded at all. Sometimes this is
4890
- // because of a configuration problem, other times this can be
4891
- // because of how Select2 helps load all possible translation files.
4892
- if (options.debug && window.console && console.warn) {
4893
- console.warn(
4894
- 'Select2: The language file for "' + name + '" could not be ' +
4895
- 'automatically loaded. A fallback will be used instead.'
4896
- );
4897
- }
4898
-
4899
- continue;
4900
- }
4901
- }
4902
-
4903
- languages.extend(language);
5004
+ if (uniqueLanguages.indexOf(language) === -1) {
5005
+ uniqueLanguages.push(language);
4904
5006
  }
5007
+ }
4905
5008
 
4906
- options.translations = languages;
4907
- } else {
4908
- var baseTranslation = Translation.loadPath(
4909
- this.defaults.amdLanguageBase + 'en'
4910
- );
4911
- var customTranslation = new Translation(options.language);
4912
-
4913
- customTranslation.extend(baseTranslation);
5009
+ options.language = uniqueLanguages;
4914
5010
 
4915
- options.translations = customTranslation;
4916
- }
5011
+ options.translations = this._processTranslations(
5012
+ options.language,
5013
+ options.debug
5014
+ );
4917
5015
 
4918
5016
  return options;
4919
5017
  };
@@ -4980,13 +5078,14 @@ S2.define('select2/defaults',[
4980
5078
  debug: false,
4981
5079
  dropdownAutoWidth: false,
4982
5080
  escapeMarkup: Utils.escapeMarkup,
4983
- language: EnglishTranslation,
5081
+ language: {},
4984
5082
  matcher: matcher,
4985
5083
  minimumInputLength: 0,
4986
5084
  maximumInputLength: 0,
4987
5085
  maximumSelectionLength: 0,
4988
5086
  minimumResultsForSearch: 0,
4989
5087
  selectOnClose: false,
5088
+ scrollAfterSelect: false,
4990
5089
  sorter: function (data) {
4991
5090
  return data;
4992
5091
  },
@@ -5001,6 +5100,103 @@ S2.define('select2/defaults',[
5001
5100
  };
5002
5101
  };
5003
5102
 
5103
+ Defaults.prototype.applyFromElement = function (options, $element) {
5104
+ var optionLanguage = options.language;
5105
+ var defaultLanguage = this.defaults.language;
5106
+ var elementLanguage = $element.prop('lang');
5107
+ var parentLanguage = $element.closest('[lang]').prop('lang');
5108
+
5109
+ var languages = Array.prototype.concat.call(
5110
+ this._resolveLanguage(elementLanguage),
5111
+ this._resolveLanguage(optionLanguage),
5112
+ this._resolveLanguage(defaultLanguage),
5113
+ this._resolveLanguage(parentLanguage)
5114
+ );
5115
+
5116
+ options.language = languages;
5117
+
5118
+ return options;
5119
+ };
5120
+
5121
+ Defaults.prototype._resolveLanguage = function (language) {
5122
+ if (!language) {
5123
+ return [];
5124
+ }
5125
+
5126
+ if ($.isEmptyObject(language)) {
5127
+ return [];
5128
+ }
5129
+
5130
+ if ($.isPlainObject(language)) {
5131
+ return [language];
5132
+ }
5133
+
5134
+ var languages;
5135
+
5136
+ if (!$.isArray(language)) {
5137
+ languages = [language];
5138
+ } else {
5139
+ languages = language;
5140
+ }
5141
+
5142
+ var resolvedLanguages = [];
5143
+
5144
+ for (var l = 0; l < languages.length; l++) {
5145
+ resolvedLanguages.push(languages[l]);
5146
+
5147
+ if (typeof languages[l] === 'string' && languages[l].indexOf('-') > 0) {
5148
+ // Extract the region information if it is included
5149
+ var languageParts = languages[l].split('-');
5150
+ var baseLanguage = languageParts[0];
5151
+
5152
+ resolvedLanguages.push(baseLanguage);
5153
+ }
5154
+ }
5155
+
5156
+ return resolvedLanguages;
5157
+ };
5158
+
5159
+ Defaults.prototype._processTranslations = function (languages, debug) {
5160
+ var translations = new Translation();
5161
+
5162
+ for (var l = 0; l < languages.length; l++) {
5163
+ var languageData = new Translation();
5164
+
5165
+ var language = languages[l];
5166
+
5167
+ if (typeof language === 'string') {
5168
+ try {
5169
+ // Try to load it with the original name
5170
+ languageData = Translation.loadPath(language);
5171
+ } catch (e) {
5172
+ try {
5173
+ // If we couldn't load it, check if it wasn't the full path
5174
+ language = this.defaults.amdLanguageBase + language;
5175
+ languageData = Translation.loadPath(language);
5176
+ } catch (ex) {
5177
+ // The translation could not be loaded at all. Sometimes this is
5178
+ // because of a configuration problem, other times this can be
5179
+ // because of how Select2 helps load all possible translation files
5180
+ if (debug && window.console && console.warn) {
5181
+ console.warn(
5182
+ 'Select2: The language file for "' + language + '" could ' +
5183
+ 'not be automatically loaded. A fallback will be used instead.'
5184
+ );
5185
+ }
5186
+ }
5187
+ }
5188
+ } else if ($.isPlainObject(language)) {
5189
+ languageData = new Translation(language);
5190
+ } else {
5191
+ languageData = language;
5192
+ }
5193
+
5194
+ translations.extend(languageData);
5195
+ }
5196
+
5197
+ return translations;
5198
+ };
5199
+
5004
5200
  Defaults.prototype.set = function (key, value) {
5005
5201
  var camelKey = $.camelCase(key);
5006
5202
 
@@ -5030,6 +5226,10 @@ S2.define('select2/options',[
5030
5226
  this.fromElement($element);
5031
5227
  }
5032
5228
 
5229
+ if ($element != null) {
5230
+ this.options = Defaults.applyFromElement(this.options, $element);
5231
+ }
5232
+
5033
5233
  this.options = Defaults.apply(this.options);
5034
5234
 
5035
5235
  if ($element && $element.is('input')) {
@@ -5053,14 +5253,6 @@ S2.define('select2/options',[
5053
5253
  this.options.disabled = $e.prop('disabled');
5054
5254
  }
5055
5255
 
5056
- if (this.options.language == null) {
5057
- if ($e.prop('lang')) {
5058
- this.options.language = $e.prop('lang').toLowerCase();
5059
- } else if ($e.closest('[lang]').prop('lang')) {
5060
- this.options.language = $e.closest('[lang]').prop('lang');
5061
- }
5062
- }
5063
-
5064
5256
  if (this.options.dir == null) {
5065
5257
  if ($e.prop('dir')) {
5066
5258
  this.options.dir = $e.prop('dir');
@@ -5098,20 +5290,43 @@ S2.define('select2/options',[
5098
5290
 
5099
5291
  $e.attr('ajax--url', Utils.GetData($e[0], 'ajaxUrl'));
5100
5292
  Utils.StoreData($e[0], 'ajax-Url', Utils.GetData($e[0], 'ajaxUrl'));
5101
-
5102
5293
  }
5103
5294
 
5104
5295
  var dataset = {};
5105
5296
 
5297
+ function upperCaseLetter(_, letter) {
5298
+ return letter.toUpperCase();
5299
+ }
5300
+
5301
+ // Pre-load all of the attributes which are prefixed with `data-`
5302
+ for (var attr = 0; attr < $e[0].attributes.length; attr++) {
5303
+ var attributeName = $e[0].attributes[attr].name;
5304
+ var prefix = 'data-';
5305
+
5306
+ if (attributeName.substr(0, prefix.length) == prefix) {
5307
+ // Get the contents of the attribute after `data-`
5308
+ var dataName = attributeName.substring(prefix.length);
5309
+
5310
+ // Get the data contents from the consistent source
5311
+ // This is more than likely the jQuery data helper
5312
+ var dataValue = Utils.GetData($e[0], dataName);
5313
+
5314
+ // camelCase the attribute name to match the spec
5315
+ var camelDataName = dataName.replace(/-([a-z])/g, upperCaseLetter);
5316
+
5317
+ // Store the data attribute contents into the dataset since
5318
+ dataset[camelDataName] = dataValue;
5319
+ }
5320
+ }
5321
+
5106
5322
  // Prefer the element's `dataset` attribute if it exists
5107
5323
  // jQuery 1.x does not correctly handle data attributes with multiple dashes
5108
5324
  if ($.fn.jquery && $.fn.jquery.substr(0, 2) == '1.' && $e[0].dataset) {
5109
- dataset = $.extend(true, {}, $e[0].dataset, Utils.GetData($e[0]));
5110
- } else {
5111
- dataset = Utils.GetData($e[0]);
5325
+ dataset = $.extend(true, {}, $e[0].dataset, dataset);
5112
5326
  }
5113
5327
 
5114
- var data = $.extend(true, {}, dataset);
5328
+ // Prefer our internal data cache if it exists
5329
+ var data = $.extend(true, {}, Utils.GetData($e[0]), dataset);
5115
5330
 
5116
5331
  data = Utils._convertData(data);
5117
5332
 
@@ -5305,6 +5520,12 @@ S2.define('select2/core',[
5305
5520
  return null;
5306
5521
  }
5307
5522
 
5523
+ if (method == 'computedstyle') {
5524
+ var computedStyle = window.getComputedStyle($element[0]);
5525
+
5526
+ return computedStyle.width;
5527
+ }
5528
+
5308
5529
  return method;
5309
5530
  };
5310
5531
 
@@ -5345,8 +5566,8 @@ S2.define('select2/core',[
5345
5566
 
5346
5567
  if (observer != null) {
5347
5568
  this._observer = new observer(function (mutations) {
5348
- $.each(mutations, self._syncA);
5349
- $.each(mutations, self._syncS);
5569
+ self._syncA();
5570
+ self._syncS(null, mutations);
5350
5571
  });
5351
5572
  this._observer.observe(this.$element[0], {
5352
5573
  attributes: true,
@@ -5468,7 +5689,7 @@ S2.define('select2/core',[
5468
5689
  if (self.isOpen()) {
5469
5690
  if (key === KEYS.ESC || key === KEYS.TAB ||
5470
5691
  (key === KEYS.UP && evt.altKey)) {
5471
- self.close();
5692
+ self.close(evt);
5472
5693
 
5473
5694
  evt.preventDefault();
5474
5695
  } else if (key === KEYS.ENTER) {
@@ -5502,7 +5723,7 @@ S2.define('select2/core',[
5502
5723
  Select2.prototype._syncAttributes = function () {
5503
5724
  this.options.set('disabled', this.$element.prop('disabled'));
5504
5725
 
5505
- if (this.options.get('disabled')) {
5726
+ if (this.isDisabled()) {
5506
5727
  if (this.isOpen()) {
5507
5728
  this.close();
5508
5729
  }
@@ -5513,7 +5734,7 @@ S2.define('select2/core',[
5513
5734
  }
5514
5735
  };
5515
5736
 
5516
- Select2.prototype._syncSubtree = function (evt, mutations) {
5737
+ Select2.prototype._isChangeMutation = function (evt, mutations) {
5517
5738
  var changed = false;
5518
5739
  var self = this;
5519
5740
 
@@ -5541,7 +5762,22 @@ S2.define('select2/core',[
5541
5762
  }
5542
5763
  } else if (mutations.removedNodes && mutations.removedNodes.length > 0) {
5543
5764
  changed = true;
5765
+ } else if ($.isArray(mutations)) {
5766
+ $.each(mutations, function(evt, mutation) {
5767
+ if (self._isChangeMutation(evt, mutation)) {
5768
+ // We've found a change mutation.
5769
+ // Let's escape from the loop and continue
5770
+ changed = true;
5771
+ return false;
5772
+ }
5773
+ });
5544
5774
  }
5775
+ return changed;
5776
+ };
5777
+
5778
+ Select2.prototype._syncSubtree = function (evt, mutations) {
5779
+ var changed = this._isChangeMutation(evt, mutations);
5780
+ var self = this;
5545
5781
 
5546
5782
  // Only re-pull the data if we think there is a change
5547
5783
  if (changed) {
@@ -5592,7 +5828,7 @@ S2.define('select2/core',[
5592
5828
  };
5593
5829
 
5594
5830
  Select2.prototype.toggleDropdown = function () {
5595
- if (this.options.get('disabled')) {
5831
+ if (this.isDisabled()) {
5596
5832
  return;
5597
5833
  }
5598
5834
 
@@ -5608,15 +5844,40 @@ S2.define('select2/core',[
5608
5844
  return;
5609
5845
  }
5610
5846
 
5847
+ if (this.isDisabled()) {
5848
+ return;
5849
+ }
5850
+
5611
5851
  this.trigger('query', {});
5612
5852
  };
5613
5853
 
5614
- Select2.prototype.close = function () {
5854
+ Select2.prototype.close = function (evt) {
5615
5855
  if (!this.isOpen()) {
5616
5856
  return;
5617
5857
  }
5618
5858
 
5619
- this.trigger('close', {});
5859
+ this.trigger('close', { originalEvent : evt });
5860
+ };
5861
+
5862
+ /**
5863
+ * Helper method to abstract the "enabled" (not "disabled") state of this
5864
+ * object.
5865
+ *
5866
+ * @return {true} if the instance is not disabled.
5867
+ * @return {false} if the instance is disabled.
5868
+ */
5869
+ Select2.prototype.isEnabled = function () {
5870
+ return !this.isDisabled();
5871
+ };
5872
+
5873
+ /**
5874
+ * Helper method to abstract the "disabled" state of this object.
5875
+ *
5876
+ * @return {true} if the disabled option is true.
5877
+ * @return {false} if the disabled option is false.
5878
+ */
5879
+ Select2.prototype.isDisabled = function () {
5880
+ return this.options.get('disabled');
5620
5881
  };
5621
5882
 
5622
5883
  Select2.prototype.isOpen = function () {
@@ -5693,7 +5954,7 @@ S2.define('select2/core',[
5693
5954
  });
5694
5955
  }
5695
5956
 
5696
- this.$element.val(newVal).trigger('change');
5957
+ this.$element.val(newVal).trigger('input').trigger('change');
5697
5958
  };
5698
5959
 
5699
5960
  Select2.prototype.destroy = function () {