unpoly-rails 0.61.1 → 2.0.0.pre.rc4

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of unpoly-rails might be problematic. Click here for more details.

Files changed (340) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +1 -1
  3. data/CHANGELOG.md +85 -2
  4. data/README.md +3 -11
  5. data/README_RAILS.md +295 -14
  6. data/dist/unpoly-bootstrap3.css +9 -14
  7. data/dist/unpoly-bootstrap3.js +4 -18
  8. data/dist/unpoly-bootstrap3.min.css +1 -1
  9. data/dist/unpoly-bootstrap3.min.js +1 -1
  10. data/dist/unpoly-bootstrap4.css +9 -0
  11. data/dist/unpoly-bootstrap4.js +16 -0
  12. data/dist/unpoly-bootstrap4.min.css +1 -0
  13. data/dist/unpoly-bootstrap4.min.js +1 -0
  14. data/dist/unpoly-bootstrap5.css +9 -0
  15. data/dist/unpoly-bootstrap5.js +14 -0
  16. data/dist/unpoly-bootstrap5.min.css +1 -0
  17. data/dist/unpoly-bootstrap5.min.js +1 -0
  18. data/dist/unpoly-migrate.js +1213 -0
  19. data/dist/unpoly-migrate.min.js +1 -0
  20. data/dist/unpoly.css +109 -140
  21. data/dist/unpoly.js +15368 -10444
  22. data/dist/unpoly.min.css +1 -1
  23. data/dist/unpoly.min.js +6 -4
  24. data/lib/unpoly-rails.rb +9 -3
  25. data/lib/unpoly/rails/change.rb +372 -0
  26. data/lib/unpoly/rails/change/cache.rb +26 -0
  27. data/lib/unpoly/rails/change/context.rb +80 -0
  28. data/lib/unpoly/rails/change/field.rb +117 -0
  29. data/lib/unpoly/rails/change/field_definition.rb +74 -0
  30. data/lib/unpoly/rails/change/layer.rb +60 -0
  31. data/lib/unpoly/rails/controller.rb +47 -0
  32. data/lib/unpoly/rails/error.rb +5 -0
  33. data/lib/unpoly/rails/request_echo_headers.rb +2 -2
  34. data/lib/unpoly/rails/version.rb +1 -1
  35. data/lib/unpoly/tasks.rb +45 -0
  36. metadata +43 -313
  37. data/.gitignore +0 -10
  38. data/.ruby-version +0 -1
  39. data/Gemfile +0 -8
  40. data/Gemfile.lock +0 -45
  41. data/Rakefile +0 -145
  42. data/bower.json +0 -27
  43. data/design/animation-ghosting.txt +0 -72
  44. data/design/design.txt +0 -34
  45. data/design/draft.html.erb +0 -48
  46. data/design/draft.rb +0 -9
  47. data/design/es6.js +0 -32
  48. data/design/ghost-debugging.txt +0 -118
  49. data/design/homepage.txt +0 -236
  50. data/design/ie11.txt +0 -9
  51. data/design/measure_import_node.js +0 -330
  52. data/design/measure_jquery/element_list.js +0 -41
  53. data/design/measure_jquery/up.on_vs_addEventListener.js +0 -56
  54. data/design/positioning.txt +0 -28
  55. data/design/query-params-in-form-actions/cases.html +0 -125
  56. data/design/rename.txt +0 -0
  57. data/design/test_rejected_promise.txt +0 -5
  58. data/design/unpoly errors.txt +0 -19
  59. data/lib/assets/javascripts/unpoly-bootstrap3.coffee +0 -2
  60. data/lib/assets/javascripts/unpoly-bootstrap3/feedback-ext.coffee +0 -5
  61. data/lib/assets/javascripts/unpoly-bootstrap3/form-ext.coffee +0 -1
  62. data/lib/assets/javascripts/unpoly-bootstrap3/modal-ext.coffee +0 -14
  63. data/lib/assets/javascripts/unpoly-bootstrap3/viewport-ext.coffee +0 -5
  64. data/lib/assets/javascripts/unpoly.coffee +0 -28
  65. data/lib/assets/javascripts/unpoly/browser.coffee.erb +0 -240
  66. data/lib/assets/javascripts/unpoly/classes/body_shifter.coffee +0 -36
  67. data/lib/assets/javascripts/unpoly/classes/cache.coffee +0 -127
  68. data/lib/assets/javascripts/unpoly/classes/compile_pass.coffee +0 -93
  69. data/lib/assets/javascripts/unpoly/classes/config.coffee +0 -9
  70. data/lib/assets/javascripts/unpoly/classes/css_transition.coffee +0 -118
  71. data/lib/assets/javascripts/unpoly/classes/divertible_chain.coffee +0 -39
  72. data/lib/assets/javascripts/unpoly/classes/event_listener.coffee +0 -116
  73. data/lib/assets/javascripts/unpoly/classes/extract_cascade.coffee +0 -86
  74. data/lib/assets/javascripts/unpoly/classes/extract_plan.coffee +0 -111
  75. data/lib/assets/javascripts/unpoly/classes/field_observer.coffee +0 -80
  76. data/lib/assets/javascripts/unpoly/classes/focus_follower.coffee +0 -29
  77. data/lib/assets/javascripts/unpoly/classes/follow_variant.coffee +0 -56
  78. data/lib/assets/javascripts/unpoly/classes/html_parser.coffee +0 -46
  79. data/lib/assets/javascripts/unpoly/classes/motion_controller.coffee +0 -157
  80. data/lib/assets/javascripts/unpoly/classes/params.coffee.erb +0 -543
  81. data/lib/assets/javascripts/unpoly/classes/record.coffee +0 -22
  82. data/lib/assets/javascripts/unpoly/classes/rect.js +0 -21
  83. data/lib/assets/javascripts/unpoly/classes/request.coffee +0 -246
  84. data/lib/assets/javascripts/unpoly/classes/response.coffee +0 -157
  85. data/lib/assets/javascripts/unpoly/classes/reveal_motion.coffee +0 -102
  86. data/lib/assets/javascripts/unpoly/classes/scroll_motion.coffee +0 -67
  87. data/lib/assets/javascripts/unpoly/classes/selector.coffee +0 -60
  88. data/lib/assets/javascripts/unpoly/classes/store/memory.coffee +0 -26
  89. data/lib/assets/javascripts/unpoly/classes/store/session.coffee +0 -59
  90. data/lib/assets/javascripts/unpoly/classes/tether.coffee +0 -105
  91. data/lib/assets/javascripts/unpoly/classes/url_set.coffee +0 -32
  92. data/lib/assets/javascripts/unpoly/cookie.coffee +0 -56
  93. data/lib/assets/javascripts/unpoly/element.coffee.erb +0 -1126
  94. data/lib/assets/javascripts/unpoly/event.coffee.erb +0 -445
  95. data/lib/assets/javascripts/unpoly/feedback.coffee +0 -353
  96. data/lib/assets/javascripts/unpoly/form.coffee.erb +0 -1069
  97. data/lib/assets/javascripts/unpoly/fragment.coffee.erb +0 -927
  98. data/lib/assets/javascripts/unpoly/framework.coffee +0 -67
  99. data/lib/assets/javascripts/unpoly/history.coffee +0 -268
  100. data/lib/assets/javascripts/unpoly/legacy.coffee +0 -60
  101. data/lib/assets/javascripts/unpoly/link.coffee.erb +0 -622
  102. data/lib/assets/javascripts/unpoly/log.coffee +0 -248
  103. data/lib/assets/javascripts/unpoly/modal.coffee.erb +0 -825
  104. data/lib/assets/javascripts/unpoly/motion.coffee.erb +0 -668
  105. data/lib/assets/javascripts/unpoly/namespace.coffee.erb +0 -5
  106. data/lib/assets/javascripts/unpoly/popup.coffee.erb +0 -515
  107. data/lib/assets/javascripts/unpoly/protocol.coffee +0 -298
  108. data/lib/assets/javascripts/unpoly/proxy.coffee +0 -672
  109. data/lib/assets/javascripts/unpoly/radio.coffee +0 -60
  110. data/lib/assets/javascripts/unpoly/rails.coffee +0 -24
  111. data/lib/assets/javascripts/unpoly/syntax.coffee.erb +0 -477
  112. data/lib/assets/javascripts/unpoly/toast.coffee +0 -67
  113. data/lib/assets/javascripts/unpoly/tooltip.coffee +0 -276
  114. data/lib/assets/javascripts/unpoly/util.coffee.erb +0 -1676
  115. data/lib/assets/javascripts/unpoly/viewport.coffee.erb +0 -830
  116. data/lib/assets/stylesheets/unpoly-bootstrap3.sass +0 -1
  117. data/lib/assets/stylesheets/unpoly-bootstrap3/modal-ext.sass +0 -27
  118. data/lib/assets/stylesheets/unpoly.sass +0 -1
  119. data/lib/assets/stylesheets/unpoly/close.sass +0 -2
  120. data/lib/assets/stylesheets/unpoly/dom.sass +0 -5
  121. data/lib/assets/stylesheets/unpoly/layout.sass +0 -2
  122. data/lib/assets/stylesheets/unpoly/link.sass +0 -2
  123. data/lib/assets/stylesheets/unpoly/modal.sass +0 -116
  124. data/lib/assets/stylesheets/unpoly/popup.sass +0 -7
  125. data/lib/assets/stylesheets/unpoly/toast.sass +0 -33
  126. data/lib/assets/stylesheets/unpoly/tooltip.sass +0 -62
  127. data/lib/unpoly/rails/inspector.rb +0 -149
  128. data/lib/unpoly/rails/inspector_accessor.rb +0 -30
  129. data/package.json +0 -38
  130. data/spec_app/.firefox-version +0 -1
  131. data/spec_app/.gitignore +0 -17
  132. data/spec_app/.rspec +0 -2
  133. data/spec_app/Gemfile +0 -30
  134. data/spec_app/Gemfile.lock +0 -229
  135. data/spec_app/README.rdoc +0 -28
  136. data/spec_app/Rakefile +0 -6
  137. data/spec_app/app/assets/images/.keep +0 -0
  138. data/spec_app/app/assets/images/favicon.png +0 -0
  139. data/spec_app/app/assets/images/grid.png +0 -0
  140. data/spec_app/app/assets/javascripts/bootstrap_manifest.coffee +0 -6
  141. data/spec_app/app/assets/javascripts/integration_test.coffee +0 -6
  142. data/spec_app/app/assets/javascripts/jasmine_specs.coffee +0 -6
  143. data/spec_app/app/assets/stylesheets/_helpers.sass +0 -5
  144. data/spec_app/app/assets/stylesheets/bootstrap_manifest.sass +0 -2
  145. data/spec_app/app/assets/stylesheets/integration_test.sass +0 -88
  146. data/spec_app/app/assets/stylesheets/jasmine_specs.sass +0 -20
  147. data/spec_app/app/controllers/application_controller.rb +0 -14
  148. data/spec_app/app/controllers/binding_test_controller.rb +0 -51
  149. data/spec_app/app/controllers/compiler_test_controller.rb +0 -5
  150. data/spec_app/app/controllers/css_test_controller.rb +0 -5
  151. data/spec_app/app/controllers/error_test_controller.rb +0 -5
  152. data/spec_app/app/controllers/form_test/basics_controller.rb +0 -14
  153. data/spec_app/app/controllers/form_test/redirects_controller.rb +0 -17
  154. data/spec_app/app/controllers/form_test/uploads_controller.rb +0 -15
  155. data/spec_app/app/controllers/hash_test_controller.rb +0 -5
  156. data/spec_app/app/controllers/method_test_controller.rb +0 -16
  157. data/spec_app/app/controllers/motion_test_controller.rb +0 -5
  158. data/spec_app/app/controllers/pages_controller.rb +0 -9
  159. data/spec_app/app/controllers/replace_test_controller.rb +0 -5
  160. data/spec_app/app/controllers/reveal_test_controller.rb +0 -5
  161. data/spec_app/app/controllers/scroll_test_controller.rb +0 -5
  162. data/spec_app/app/helpers/application_helper.rb +0 -2
  163. data/spec_app/app/mailers/.keep +0 -0
  164. data/spec_app/app/models/concerns/.keep +0 -0
  165. data/spec_app/app/views/compiler_test/timestamp.erb +0 -9
  166. data/spec_app/app/views/css_test/modal.erb +0 -47
  167. data/spec_app/app/views/css_test/modal_contents.erb +0 -5
  168. data/spec_app/app/views/css_test/modal_contents_wide.erb +0 -5
  169. data/spec_app/app/views/css_test/popup.erb +0 -81
  170. data/spec_app/app/views/css_test/popup_contents.erb +0 -5
  171. data/spec_app/app/views/css_test/tooltip.erb +0 -48
  172. data/spec_app/app/views/error_test/trigger.erb +0 -80
  173. data/spec_app/app/views/error_test/unexpected_response.erb +0 -3
  174. data/spec_app/app/views/form_test/basics/new.erb +0 -60
  175. data/spec_app/app/views/form_test/redirects/new.erb +0 -27
  176. data/spec_app/app/views/form_test/redirects/target.erb +0 -4
  177. data/spec_app/app/views/form_test/submission_result.erb +0 -30
  178. data/spec_app/app/views/form_test/uploads/new.erb +0 -44
  179. data/spec_app/app/views/hash_test/unpoly.erb +0 -30
  180. data/spec_app/app/views/hash_test/vanilla.erb +0 -13
  181. data/spec_app/app/views/layouts/integration_test.erb +0 -22
  182. data/spec_app/app/views/layouts/jasmine_rails/spec_runner.html.erb +0 -20
  183. data/spec_app/app/views/method_test/form_target.erb +0 -17
  184. data/spec_app/app/views/method_test/page1.erb +0 -11
  185. data/spec_app/app/views/method_test/page2.erb +0 -6
  186. data/spec_app/app/views/motion_test/animations.erb +0 -16
  187. data/spec_app/app/views/motion_test/transitions.erb +0 -13
  188. data/spec_app/app/views/pages/start.erb +0 -79
  189. data/spec_app/app/views/replace_test/_nav.erb +0 -6
  190. data/spec_app/app/views/replace_test/page1.erb +0 -14
  191. data/spec_app/app/views/replace_test/page2.erb +0 -14
  192. data/spec_app/app/views/replace_test/table.erb +0 -16
  193. data/spec_app/app/views/reveal_test/long1.erb +0 -17
  194. data/spec_app/app/views/reveal_test/long2.erb +0 -17
  195. data/spec_app/app/views/reveal_test/within_document_viewport.erb +0 -24
  196. data/spec_app/app/views/reveal_test/within_overflowing_div_viewport.erb +0 -28
  197. data/spec_app/app/views/scroll_test/long1.erb +0 -30
  198. data/spec_app/bin/bundle +0 -3
  199. data/spec_app/bin/rails +0 -8
  200. data/spec_app/bin/rake +0 -8
  201. data/spec_app/bin/setup +0 -29
  202. data/spec_app/bin/spring +0 -18
  203. data/spec_app/config.ru +0 -4
  204. data/spec_app/config/application.rb +0 -28
  205. data/spec_app/config/boot.rb +0 -3
  206. data/spec_app/config/database.yml +0 -25
  207. data/spec_app/config/environment.rb +0 -5
  208. data/spec_app/config/environments/development.rb +0 -41
  209. data/spec_app/config/environments/production.rb +0 -79
  210. data/spec_app/config/environments/test.rb +0 -42
  211. data/spec_app/config/initializers/assets.rb +0 -19
  212. data/spec_app/config/initializers/backtrace_silencers.rb +0 -7
  213. data/spec_app/config/initializers/bower_rails.rb +0 -16
  214. data/spec_app/config/initializers/cookies_serializer.rb +0 -3
  215. data/spec_app/config/initializers/filter_parameter_logging.rb +0 -4
  216. data/spec_app/config/initializers/inflections.rb +0 -16
  217. data/spec_app/config/initializers/mime_types.rb +0 -4
  218. data/spec_app/config/initializers/session_store.rb +0 -3
  219. data/spec_app/config/initializers/wrap_parameters.rb +0 -14
  220. data/spec_app/config/locales/en.yml +0 -23
  221. data/spec_app/config/routes.rb +0 -30
  222. data/spec_app/config/secrets.yml +0 -22
  223. data/spec_app/db/schema.rb +0 -23
  224. data/spec_app/db/seeds.rb +0 -7
  225. data/spec_app/lib/assets/.keep +0 -0
  226. data/spec_app/lib/tasks/.keep +0 -0
  227. data/spec_app/lib/tasks/cucumber.rake +0 -65
  228. data/spec_app/log/.keep +0 -0
  229. data/spec_app/public/404.html +0 -67
  230. data/spec_app/public/422.html +0 -67
  231. data/spec_app/public/500.html +0 -66
  232. data/spec_app/public/favicon.ico +0 -0
  233. data/spec_app/public/robots.txt +0 -5
  234. data/spec_app/script/cucumber +0 -10
  235. data/spec_app/spec/controllers/binding_test_controller_spec.rb +0 -248
  236. data/spec_app/spec/javascripts/helpers/agent_detector.coffee +0 -20
  237. data/spec_app/spec/javascripts/helpers/async_sequence.js.coffee +0 -103
  238. data/spec_app/spec/javascripts/helpers/browser_switches.js.coffee +0 -21
  239. data/spec_app/spec/javascripts/helpers/enable_logging.js.coffee +0 -2
  240. data/spec_app/spec/javascripts/helpers/fixture.js.coffee +0 -25
  241. data/spec_app/spec/javascripts/helpers/index.js.coffee +0 -1
  242. data/spec_app/spec/javascripts/helpers/jquery_no_conflict.js +0 -1
  243. data/spec_app/spec/javascripts/helpers/knife.js.coffee +0 -69
  244. data/spec_app/spec/javascripts/helpers/last_request.js.coffee +0 -25
  245. data/spec_app/spec/javascripts/helpers/mock_ajax.js.coffee +0 -8
  246. data/spec_app/spec/javascripts/helpers/mock_clock.js.coffee +0 -2
  247. data/spec_app/spec/javascripts/helpers/parse_form_data.js.coffee +0 -24
  248. data/spec_app/spec/javascripts/helpers/promise_state.js +0 -18
  249. data/spec_app/spec/javascripts/helpers/protect_jasmine_runner.coffee +0 -12
  250. data/spec_app/spec/javascripts/helpers/remove_body_margin.js.coffee +0 -8
  251. data/spec_app/spec/javascripts/helpers/reset_history.js.coffee +0 -23
  252. data/spec_app/spec/javascripts/helpers/reset_knife.js.coffee +0 -2
  253. data/spec_app/spec/javascripts/helpers/reset_up.js.coffee +0 -25
  254. data/spec_app/spec/javascripts/helpers/restore_body_scroll.js.coffee +0 -5
  255. data/spec_app/spec/javascripts/helpers/show_lib_versions.coffee +0 -12
  256. data/spec_app/spec/javascripts/helpers/spec_util.coffee +0 -47
  257. data/spec_app/spec/javascripts/helpers/to_be_around.js.coffee +0 -8
  258. data/spec_app/spec/javascripts/helpers/to_be_array.coffee +0 -5
  259. data/spec_app/spec/javascripts/helpers/to_be_attached.coffee +0 -9
  260. data/spec_app/spec/javascripts/helpers/to_be_blank.js.coffee +0 -8
  261. data/spec_app/spec/javascripts/helpers/to_be_detached.coffee +0 -9
  262. data/spec_app/spec/javascripts/helpers/to_be_element.js.coffee +0 -8
  263. data/spec_app/spec/javascripts/helpers/to_be_error.coffee +0 -8
  264. data/spec_app/spec/javascripts/helpers/to_be_given.js.coffee +0 -8
  265. data/spec_app/spec/javascripts/helpers/to_be_hidden.js.coffee +0 -8
  266. data/spec_app/spec/javascripts/helpers/to_be_jquery.js.coffee +0 -5
  267. data/spec_app/spec/javascripts/helpers/to_be_missing.js.coffee +0 -8
  268. data/spec_app/spec/javascripts/helpers/to_be_present.js.coffee +0 -8
  269. data/spec_app/spec/javascripts/helpers/to_be_scrolled_to.coffee +0 -11
  270. data/spec_app/spec/javascripts/helpers/to_be_visible.js.coffee +0 -9
  271. data/spec_app/spec/javascripts/helpers/to_contain.js.coffee +0 -8
  272. data/spec_app/spec/javascripts/helpers/to_end_with.js.coffee +0 -11
  273. data/spec_app/spec/javascripts/helpers/to_equal_jquery.js.coffee +0 -8
  274. data/spec_app/spec/javascripts/helpers/to_equal_node_list.coffee +0 -7
  275. data/spec_app/spec/javascripts/helpers/to_equal_via_is_equal.js.coffee +0 -7
  276. data/spec_app/spec/javascripts/helpers/to_have_class.js.coffee +0 -10
  277. data/spec_app/spec/javascripts/helpers/to_have_descendant.js.coffee +0 -10
  278. data/spec_app/spec/javascripts/helpers/to_have_length.js.coffee +0 -8
  279. data/spec_app/spec/javascripts/helpers/to_have_opacity.coffee +0 -15
  280. data/spec_app/spec/javascripts/helpers/to_have_own_property.js.coffee +0 -8
  281. data/spec_app/spec/javascripts/helpers/to_have_request_method.js.coffee +0 -16
  282. data/spec_app/spec/javascripts/helpers/to_have_text.js.coffee +0 -9
  283. data/spec_app/spec/javascripts/helpers/to_have_unhandled_rejections.coffee +0 -18
  284. data/spec_app/spec/javascripts/helpers/to_match_list.coffee +0 -14
  285. data/spec_app/spec/javascripts/helpers/to_match_selector.coffee +0 -8
  286. data/spec_app/spec/javascripts/helpers/to_match_text.js.coffee +0 -13
  287. data/spec_app/spec/javascripts/helpers/to_match_url.coffee +0 -14
  288. data/spec_app/spec/javascripts/helpers/trigger.js.coffee +0 -200
  289. data/spec_app/spec/javascripts/helpers/wait_until_dom_ready.js.coffee +0 -5
  290. data/spec_app/spec/javascripts/support/jasmine.yml +0 -51
  291. data/spec_app/spec/javascripts/up/browser_spec.js.coffee +0 -150
  292. data/spec_app/spec/javascripts/up/classes/cache_spec.js.coffee +0 -82
  293. data/spec_app/spec/javascripts/up/classes/config_spec.coffee +0 -24
  294. data/spec_app/spec/javascripts/up/classes/divertible_chain_spec.coffee +0 -45
  295. data/spec_app/spec/javascripts/up/classes/focus_tracker_spec.coffee +0 -34
  296. data/spec_app/spec/javascripts/up/classes/params_spec.coffee +0 -557
  297. data/spec_app/spec/javascripts/up/classes/request_spec.coffee +0 -50
  298. data/spec_app/spec/javascripts/up/classes/scroll_motion_spec.js.coffee +0 -51
  299. data/spec_app/spec/javascripts/up/classes/store/memory_spec.js.coffee +0 -70
  300. data/spec_app/spec/javascripts/up/classes/store/session_spec.js.coffee +0 -114
  301. data/spec_app/spec/javascripts/up/element_spec.coffee +0 -897
  302. data/spec_app/spec/javascripts/up/event_spec.js.coffee +0 -530
  303. data/spec_app/spec/javascripts/up/feedback_spec.js.coffee +0 -401
  304. data/spec_app/spec/javascripts/up/form_spec.js.coffee +0 -1527
  305. data/spec_app/spec/javascripts/up/fragment_spec.js.coffee +0 -2598
  306. data/spec_app/spec/javascripts/up/history_spec.js.coffee +0 -340
  307. data/spec_app/spec/javascripts/up/jquery_spec.js.coffee +0 -4
  308. data/spec_app/spec/javascripts/up/legacy_spec.js.coffee +0 -27
  309. data/spec_app/spec/javascripts/up/link_spec.js.coffee +0 -1093
  310. data/spec_app/spec/javascripts/up/log_spec.js.coffee +0 -119
  311. data/spec_app/spec/javascripts/up/modal_spec.js.coffee +0 -917
  312. data/spec_app/spec/javascripts/up/motion_spec.js.coffee +0 -582
  313. data/spec_app/spec/javascripts/up/popup_spec.js.coffee +0 -507
  314. data/spec_app/spec/javascripts/up/protocol_spec.js.coffee +0 -39
  315. data/spec_app/spec/javascripts/up/proxy_spec.js.coffee +0 -1137
  316. data/spec_app/spec/javascripts/up/radio_spec.js.coffee +0 -212
  317. data/spec_app/spec/javascripts/up/rails_spec.js.coffee +0 -118
  318. data/spec_app/spec/javascripts/up/spec_spec.js.coffee +0 -9
  319. data/spec_app/spec/javascripts/up/syntax_spec.js.coffee +0 -304
  320. data/spec_app/spec/javascripts/up/toast_spec.js.coffee +0 -37
  321. data/spec_app/spec/javascripts/up/tooltip_spec.js.coffee +0 -163
  322. data/spec_app/spec/javascripts/up/util_spec.js.coffee +0 -1420
  323. data/spec_app/spec/javascripts/up/viewport_spec.js.coffee +0 -655
  324. data/spec_app/spec/spec_helper.rb +0 -62
  325. data/spec_app/test/controllers/.keep +0 -0
  326. data/spec_app/test/fixtures/.keep +0 -0
  327. data/spec_app/test/helpers/.keep +0 -0
  328. data/spec_app/test/integration/.keep +0 -0
  329. data/spec_app/test/mailers/.keep +0 -0
  330. data/spec_app/test/models/.keep +0 -0
  331. data/spec_app/test/test_helper.rb +0 -10
  332. data/spec_app/vendor/asset-libs/es6-promise-4.1.6/es6-promise.auto.js +0 -1159
  333. data/spec_app/vendor/asset-libs/jasmine-ajax-3.3.1/.bower.json +0 -43
  334. data/spec_app/vendor/asset-libs/jasmine-ajax-3.3.1/.gitignore +0 -6
  335. data/spec_app/vendor/asset-libs/jasmine-ajax-3.3.1/.npmignore +0 -10
  336. data/spec_app/vendor/asset-libs/jasmine-ajax-3.3.1/.pairs +0 -6
  337. data/spec_app/vendor/asset-libs/jasmine-ajax-3.3.1/.travis.yml +0 -56
  338. data/spec_app/vendor/asset-libs/jasmine-ajax-3.3.1/jasmine-ajax.js +0 -790
  339. data/spec_app/vendor/assets/.keep +0 -0
  340. data/unpoly-rails.gemspec +0 -24
@@ -1,119 +0,0 @@
1
- u = up.util
2
- $ = jQuery
3
-
4
- describe 'up.log', ->
5
-
6
- describe 'JavaScript functions', ->
7
-
8
- describe 'up.log.puts', ->
9
-
10
- it 'sends a log message to the developer console iff the log is enabled', ->
11
- spyOn(console, 'log')
12
-
13
- up.log.disable()
14
- up.log.puts('message')
15
- expect(console.log).not.toHaveBeenCalled()
16
-
17
- up.log.enable()
18
- up.log.puts('message')
19
- expect(console.log).toHaveBeenCalledWith('[UP] message')
20
-
21
- describe 'up.log.debug', ->
22
-
23
- it 'sends a debug message to the developer console iff the log is enabled', ->
24
- spyOn(console, 'debug')
25
-
26
- up.log.disable()
27
- up.log.debug('message')
28
- expect(console.debug).not.toHaveBeenCalled()
29
-
30
- up.log.enable()
31
- up.log.debug('message')
32
- expect(console.debug).toHaveBeenCalledWith('[UP] message')
33
-
34
- describe 'up.log.error', ->
35
-
36
- it 'sends an error message to the developer console regardless whether the log is enabled or not', ->
37
- spyOn(console, 'error')
38
-
39
- up.log.disable()
40
- up.log.error('message1')
41
- expect(console.error).toHaveBeenCalledWith('[UP] message1')
42
-
43
- up.log.enable()
44
- up.log.error('message2')
45
- expect(console.error.calls.allArgs()).toEqual [
46
- ['[UP] message1'],
47
- ['[UP] message2']
48
- ]
49
-
50
- describe 'up.log.sprintf', ->
51
-
52
- describe 'with string argument', ->
53
-
54
- it 'serializes with surrounding quotes', ->
55
- formatted = up.log.sprintf('before %o after', 'argument')
56
- expect(formatted).toEqual('before "argument" after')
57
-
58
- describe 'with undefined argument', ->
59
-
60
- it 'serializes to the word "undefined"', ->
61
- formatted = up.log.sprintf('before %o after', undefined)
62
- expect(formatted).toEqual('before undefined after')
63
-
64
- describe 'with null argument', ->
65
-
66
- it 'serializes to the word "null"', ->
67
- formatted = up.log.sprintf('before %o after', null)
68
- expect(formatted).toEqual('before null after')
69
-
70
- describe 'with number argument', ->
71
-
72
- it 'serializes the number as string', ->
73
- formatted = up.log.sprintf('before %o after', 5)
74
- expect(formatted).toEqual('before 5 after')
75
-
76
- describe 'with function argument', ->
77
-
78
- it 'serializes the function code', ->
79
- formatted = up.log.sprintf('before %o after', `function foo() {}`)
80
- expect(formatted).toEqual('before function foo() {} after')
81
-
82
- describe 'with array argument', ->
83
-
84
- it 'recursively serializes the elements', ->
85
- formatted = up.log.sprintf('before %o after', [1, "foo"])
86
- expect(formatted).toEqual('before [1, "foo"] after')
87
-
88
- describe 'with element argument', ->
89
-
90
- it 'serializes the tag name with id, name and class attributes, but ignores other attributes', ->
91
- $element = $('<table id="id-value" name="name-value" class="class-value" title="title-value">')
92
- element = $element.get(0)
93
- formatted = up.log.sprintf('before %o after', element)
94
- expect(formatted).toEqual('before <table id="id-value" name="name-value" class="class-value"> after')
95
-
96
- describe 'with jQuery argument', ->
97
-
98
- it 'serializes the tag name with id, name and class attributes, but ignores other attributes', ->
99
- $element1 = $('<table id="table-id">')
100
- $element2 = $('<ul id="ul-id">')
101
- formatted = up.log.sprintf('before %o after', $element1.add($element2))
102
- expect(formatted).toEqual('before $(<table id="table-id">, <ul id="ul-id">) after')
103
-
104
- describe 'with object argument', ->
105
-
106
- it 'serializes to JSON', ->
107
- object = { foo: 'foo-value', bar: 'bar-value' }
108
- formatted = up.log.sprintf('before %o after', object)
109
- expect(formatted).toEqual('before {"foo":"foo-value","bar":"bar-value"} after')
110
-
111
- it "skips a key if a getter crashes", ->
112
- object = {}
113
- Object.defineProperty(object, 'foo', get: (-> throw "error"))
114
- formatted = up.log.sprintf('before %o after', object)
115
- expect(formatted).toEqual('before {} after')
116
-
117
- object.bar = 'bar'
118
- formatted = up.log.sprintf('before %o after', object)
119
- expect(formatted).toEqual('before {"bar":"bar"} after')
@@ -1,917 +0,0 @@
1
- u = up.util
2
- e = up.element
3
- $ = jQuery
4
-
5
- describe 'up.modal', ->
6
-
7
- beforeEach ->
8
- up.modal.config.openDuration = 5
9
- up.modal.config.closeDuration = 5
10
-
11
- describe 'JavaScript functions', ->
12
-
13
- describe 'up.modal.follow', ->
14
-
15
- it "loads the given link's destination in a dialog window", (done) ->
16
- $link = $fixture('a[href="/path/to"][up-modal=".middle"]').text('link')
17
- promise = up.modal.follow($link)
18
-
19
- u.task =>
20
- expect(@lastRequest().url).toMatch /\/path\/to$/
21
- @respondWith """
22
- <div class="before">new-before</div>
23
- <div class="middle">new-middle</div>
24
- <div class="after">new-after</div>
25
- """
26
-
27
- promise.then =>
28
- expect($('.up-modal')).toBeAttached()
29
- expect($('.up-modal-dialog')).toBeAttached()
30
- expect($('.up-modal-dialog .middle')).toBeAttached()
31
- expect($('.up-modal-dialog .middle')).toHaveText('new-middle')
32
- expect($('.up-modal-dialog .before')).not.toBeAttached()
33
- expect($('.up-modal-dialog .after')).not.toBeAttached()
34
- done()
35
-
36
- describe 'up.modal.extract', ->
37
-
38
- it 'opens a modal by extracting the given selector from the given HTML string', (done) ->
39
- up.history.config.enabled = true
40
-
41
- oldHref = location.href
42
- promise = up.modal.extract '.middle', """
43
- <div class="before">new-before</div>
44
- <div class="middle">new-middle</div>
45
- <div class="after">new-after</div>
46
- """
47
-
48
- promise.then =>
49
- expect($('.up-modal')).toBeAttached()
50
- expect($('.up-modal-dialog')).toBeAttached()
51
- expect($('.up-modal-dialog .middle')).toBeAttached()
52
- expect($('.up-modal-dialog .middle')).toHaveText('new-middle')
53
- expect($('.up-modal-dialog .before')).not.toBeAttached()
54
- expect($('.up-modal-dialog .after')).not.toBeAttached()
55
-
56
- # Can't change URLs
57
- expect(location.href).toEqual(oldHref)
58
- done()
59
-
60
- describe 'up.modal.visit', ->
61
-
62
- it "requests the given URL and places the given selector into a modal", (done) ->
63
- up.history.config.enabled = true
64
-
65
- promise = up.modal.visit('/foo', target: '.middle')
66
-
67
- u.task =>
68
- @respondWith """
69
- <div class="before">new-before</div>
70
- <div class="middle">new-middle</div>
71
- <div class="after">new-after</div>
72
- """
73
-
74
- promise.then =>
75
- expect('.up-modal').toBeAttached()
76
- expect('.up-modal-dialog').toBeAttached()
77
- expect('.up-modal-dialog .middle').toBeAttached()
78
- expect('.up-modal-dialog .middle').toHaveText('new-middle')
79
- expect('.up-modal-dialog .before').not.toBeAttached()
80
- expect('.up-modal-dialog .after').not.toBeAttached()
81
- expect(location.pathname).toMatchUrl('/foo')
82
- done()
83
-
84
- it "doesn't create an .up-modal frame and replaces { failTarget } if the server returns a non-200 response", (done) ->
85
- $fixture('.error').text('old error')
86
-
87
- promise = up.modal.visit('/foo', target: '.target', failTarget: '.error')
88
-
89
- u.task =>
90
- @respondWith
91
- status: 500
92
- responseText: """
93
- <div class="target">new target</div>
94
- <div class="error">new error</div>
95
- """
96
-
97
- promise.catch =>
98
- expect('.up-modal').not.toBeAttached()
99
- expect('.error').toHaveText('new error')
100
- done()
101
-
102
- it 'always makes a request for the given selector, and does not "improve" the selector with a fallback', asyncSpec (next) ->
103
- up.modal.visit('/foo', target: '.target', failTarget: '.error')
104
- next =>
105
- expect(jasmine.Ajax.requests.count()).toEqual(1)
106
- headers = @lastRequest().requestHeaders
107
- expect(headers['X-Up-Target']).toEqual('.target')
108
-
109
- describe 'preventing elements from jumping as scrollbars change', ->
110
-
111
- it "brings its own scrollbar, padding the body on the right", (done) ->
112
- $body = $(document.body)
113
-
114
- $fixture('.spacer').css(height: '9000px')
115
- # Safari 11 has no vertical scrollbar that takes away space from the document,
116
- # so the entire shifting logic is skipped.
117
- if up.viewport.rootHasVerticalScrollbar()
118
-
119
- $rootOverflowElement = $(up.viewport.rootOverflowElement())
120
-
121
- promise = up.modal.visit('/foo', target: '.container')
122
-
123
- u.task =>
124
- @respondWith('<div class="container">text</div>')
125
-
126
- promise.then ->
127
- $modal = $('.up-modal')
128
- $viewport = $modal.find('.up-modal-viewport')
129
- scrollbarWidth = up.viewport.scrollbarWidth()
130
-
131
- expect($modal).toBeAttached()
132
- expect($viewport.css('overflow-y')).toEqual('scroll')
133
- expect($rootOverflowElement.css('overflow-y')).toEqual('hidden')
134
- expect(parseInt($body.css('padding-right'))).toBeAround(scrollbarWidth, 5)
135
-
136
- up.modal.close().then ->
137
- expect($rootOverflowElement.css('overflow-y')).toEqual('scroll')
138
- expect(parseInt($body.css('padding-right'))).toBe(0)
139
- done()
140
- else
141
- expect(true).toBe(true)
142
- done()
143
-
144
- it "gives the scrollbar to .up-modal instead of .up-modal-viewport while animating, so we don't see scaled scrollbars in a zoom-in animation", (done) ->
145
- openPromise = up.modal.extract('.container', '<div class="container">text</div>', animation: 'fade-in', duration: 100)
146
-
147
- u.timer 50, ->
148
- $modal = $('.up-modal')
149
- $viewport = $modal.find('.up-modal-viewport')
150
- expect($modal).toHaveClass('up-modal-animating')
151
- expect($modal.css('overflow-y')).toEqual('scroll')
152
- expect($viewport.css('overflow-y')).toEqual('hidden')
153
-
154
- openPromise.then ->
155
- expect($modal).not.toHaveClass('up-modal-animating')
156
- expect($modal.css('overflow-y')).not.toEqual('scroll')
157
- expect($viewport.css('overflow-y')).toEqual('scroll')
158
- closePromise = up.modal.close(animation: 'fade-out', duration: 400)
159
-
160
- u.timer 50, ->
161
- expect($modal).toHaveClass('up-modal-animating')
162
- expect($modal.css('overflow-y')).toEqual('scroll')
163
- expect($viewport.css('overflow-y')).toEqual('hidden')
164
- done()
165
-
166
- it "does not add right padding to the body if the document's overflow element has overflow-y: hidden", (done) ->
167
- restoreBody = e.setTemporaryStyle(up.viewport.rootOverflowElement(), overflowY: 'hidden')
168
- $fixture('.spacer').css(height: '9000px')
169
-
170
- up.modal.extract('.container', '<div class="container">text</div>').then ->
171
- $body = $('body')
172
- expect($('.up-modal')).toBeAttached()
173
- expect(parseInt($body.css('padding-right'))).toBe(0)
174
-
175
- up.modal.close().then ->
176
- expect(parseInt($body.css('padding-right'))).toBe(0)
177
- restoreBody()
178
- done()
179
-
180
- it "does not add right padding to the body if the document's overflow element has overflow-y: auto, but does not currently have scrollbars", (done) ->
181
- restoreBody = e.setTemporaryStyle(up.viewport.rootOverflowElement(), overflowY: 'auto')
182
- restoreReporter = e.setTemporaryStyle($('.jasmine_html-reporter')[0], height: '100px', overflowY: 'hidden')
183
-
184
- up.modal.extract('.container', '<div class="container">text</div>').then ->
185
- $body = $('body')
186
- expect($('.up-modal')).toBeAttached()
187
- expect(parseInt($body.css('padding-right'))).toBe(0)
188
-
189
- up.modal.close().then ->
190
- expect(parseInt($body.css('padding-right'))).toBe(0)
191
- restoreReporter()
192
- restoreBody()
193
- done()
194
-
195
- it 'pushes right-anchored elements away from the edge of the screen', (done) ->
196
- $fixture('.spacer').css(height: '9000px')
197
- # Safari 11 has no vertical scrollbar that takes away space from the document,
198
- # so the entire shifting logic is skipped.
199
- if up.viewport.rootHasVerticalScrollbar()
200
- scrollbarWidth = up.viewport.scrollbarWidth()
201
- $anchoredElement = $fixture('div[up-anchored=right]').css
202
- position: 'absolute'
203
- top: '0'
204
- right: '30px'
205
-
206
- promise = up.modal.visit('/foo', target: '.container')
207
-
208
- u.task =>
209
- @respondWith('<div class="container">text</div>')
210
-
211
- promise.then ->
212
- expect(parseInt($anchoredElement.css('right'))).toBeAround(30 + scrollbarWidth, 10)
213
-
214
- up.modal.close().then ->
215
- expect(parseInt($anchoredElement.css('right'))).toBeAround(30 , 10)
216
- done()
217
- else
218
- expect(true).toBe(true)
219
- done()
220
-
221
- describe 'opening a modal while another modal is open', ->
222
-
223
- it 'does not open multiple modals or pad the body twice if the user starts loading a second modal before the first was done loading', (done) ->
224
- up.modal.config.closeDuration = 10
225
- scrollbarWidth = up.viewport.scrollbarWidth()
226
-
227
- # Load a first modal
228
- up.modal.visit('/path1', target: '.container', animation: 'fade-in', duration: 50)
229
-
230
- # Immediately load a second modal in the same frame.
231
- # This will discard the first request immediately.
232
- up.modal.visit('/path2', target: '.container', animation: 'fade-in', duration: 50)
233
-
234
- u.task =>
235
- # The second modal has survived
236
- expect(jasmine.Ajax.requests.count()).toEqual(1)
237
- expect(@lastRequest().url).toMatchUrl('/path2')
238
-
239
- # We send the response for 2
240
- @respondWith('<div class="container">response2</div>')
241
-
242
- u.timer 10, =>
243
- # The second modal is now opening
244
- up.modal.visit('/path3', target: '.container', animation: 'fade-in', duration: 50)
245
-
246
- # Load a third modal before the second was done opening
247
- u.task =>
248
- # Since we're still opening the second modal, no request has been made.
249
- expect(jasmine.Ajax.requests.count()).toEqual(1)
250
-
251
- u.timer 180, =>
252
- # Now that the second modal has opened, we make the request to /path3
253
- expect(jasmine.Ajax.requests.count()).toEqual(2)
254
- expect(@lastRequest().url).toMatchUrl('/path3')
255
-
256
- @respondWith('<div class="container">response3</div>')
257
-
258
- u.timer 180, =>
259
- expect(jasmine.Ajax.requests.count()).toEqual(2)
260
- expect($('.up-modal').length).toBe(1)
261
- expect($('.up-modal-dialog').length).toBe(1)
262
- expect($('.container')).toHaveText('response3')
263
- bodyPadding = parseInt($('body').css('padding-right'))
264
- expect(bodyPadding).toBeAround(scrollbarWidth, 10)
265
- if scrollbarWidth > 0 # this test does not make sense on old Safaris
266
- expect(bodyPadding).not.toBeAround(2 * scrollbarWidth, 2 * 5)
267
- done()
268
-
269
- it 'closes the current modal and wait for its close animation to finish before starting the open animation of a second modal', asyncSpec (next) ->
270
- up.modal.config.openAnimation = 'fade-in'
271
- up.modal.config.openDuration = 100
272
- up.modal.config.closeAnimation = 'fade-out'
273
- up.modal.config.closeDuration = 100
274
-
275
- events = []
276
- u.each ['up:modal:open', 'up:modal:opened', 'up:modal:close', 'up:modal:closed'], (event) ->
277
- up.on event, ->
278
- events.push(event)
279
-
280
- up.modal.extract('.target', '<div class="target">response1</div>')
281
-
282
- next =>
283
- # First modal is starting opening animation (will take 100 ms)
284
- expect(events).toEqual ['up:modal:open']
285
- expect($('.target')).toHaveText('response1')
286
-
287
- next.after (100 + (timingTolerance = 100)), =>
288
- # First modal has completed opening animation after 100 ms
289
- expect(events).toEqual ['up:modal:open', 'up:modal:opened']
290
- expect($('.target')).toHaveText('response1')
291
-
292
- # We open another modal, which will cause the first modal to start closing (will take 100 ms)
293
- up.modal.extract('.target', '<div class="target">response2</div>')
294
-
295
- next.after 50, =>
296
- # Second modal is still waiting for first modal's closing animaton to finish.
297
- expect(events).toEqual ['up:modal:open', 'up:modal:opened', 'up:modal:close']
298
- expect($('.target')).toHaveText('response1')
299
-
300
- next.after (50 + 100 + (timingTolerance = 200)), =>
301
- # First modal has finished closing, second modal has finished opening.
302
- expect(events).toEqual ['up:modal:open', 'up:modal:opened', 'up:modal:close', 'up:modal:closed', 'up:modal:open', 'up:modal:opened']
303
- expect($('.target')).toHaveText('response2')
304
-
305
- it 'closes an opening modal if a second modal starts opening before the first modal has finished its open animation', asyncSpec (next) ->
306
- up.modal.config.openAnimation = 'fade-in'
307
- up.modal.config.openDuration = 100
308
- up.modal.config.closeAnimation = 'fade-out'
309
- up.modal.config.closeDuration = 100
310
-
311
- # Open the first modal
312
- up.modal.extract('.target', '<div class="target">response1</div>')
313
-
314
- next.after 50, =>
315
- # First modal is still in its opening animation
316
- expect($('.target')).toHaveText('response1')
317
-
318
- # Open a second modal
319
- up.modal.extract('.target', '<div class="target">response2</div>')
320
-
321
- next =>
322
- # First modal is starting close animation. Second modal waits for that.
323
- expect($('.target')).toHaveText('response1')
324
-
325
- next.after 10, =>
326
- # Second modal is still waiting for first modal's closing animaton to finish.
327
- expect($('.target')).toHaveText('response1')
328
-
329
- next.after (140 + (timingTolerance = 220)), =>
330
- # First modal has finished closing, second modal has finished opening.
331
- expect($('.target')).toHaveText('response2')
332
-
333
- it 'uses the correct flavor config for the first and second modal', asyncSpec (next) ->
334
- up.modal.config.openAnimation = 'fade-in'
335
- up.modal.config.openDuration = 20
336
- up.modal.config.closeAnimation = 'fade-out'
337
- up.modal.config.closeDuration = 20
338
- up.modal.flavor 'custom-drawer',
339
- openAnimation: 'move-from-right'
340
- closeAnimation: 'move-to-right'
341
-
342
- animations = []
343
- spyOn(up, 'animate').and.callFake (element, animation, options) ->
344
- if e.matches(element, '.up-modal-viewport')
345
- animations.push
346
- text: element.querySelector('.target').innerText.trim()
347
- animation: animation
348
- deferred = u.newDeferred()
349
- u.timer options.duration, -> deferred.resolve()
350
- deferred.promise()
351
-
352
- up.modal.extract('.target', '<div class="target">response1</div>')
353
-
354
- next =>
355
- expect(animations).toEqual [
356
- { animation: 'fade-in', text: 'response1' }
357
- ]
358
-
359
- next.after 30, =>
360
- # first modal is now done animating
361
- expect(animations).toEqual [
362
- { animation: 'fade-in', text: 'response1' }
363
- ]
364
-
365
- up.modal.extract('.target', '<div class="target">response2</div>', flavor: 'custom-drawer')
366
-
367
- next =>
368
- expect(animations).toEqual [
369
- { animation: 'fade-in', text: 'response1' },
370
- { animation: 'fade-out', text: 'response1' },
371
- ]
372
-
373
- next.after 30, =>
374
- expect(animations).toEqual [
375
- { animation: 'fade-in', text: 'response1' },
376
- { animation: 'fade-out', text: 'response1' },
377
- { animation: 'move-from-right', text: 'response2' }
378
- ]
379
-
380
- expect($('.up-modal').attr('up-flavor')).toEqual('custom-drawer')
381
-
382
-
383
- it 'never resolves the open() promise and shows no error if close() was called before the response was received', asyncSpec (next) ->
384
- openPromise = up.modal.visit('/foo', target: '.container')
385
-
386
- next =>
387
- up.modal.close()
388
-
389
- next =>
390
- respond = => @respondWith('<div class="container">text</div>')
391
- expect(respond).not.toThrowError()
392
-
393
- next.await =>
394
- expect($('.up-toast')).not.toBeAttached()
395
- promise = promiseState(openPromise)
396
- promise.then (result) => expect(result.state).toEqual('pending')
397
-
398
- describe 'up.modal.coveredUrl', ->
399
-
400
- describeCapability 'canPushState', ->
401
-
402
- it 'returns the URL behind the modal overlay', (done) ->
403
- up.history.config.enabled = true
404
- up.history.replace('/foo')
405
-
406
- expect(up.modal.coveredUrl()).toBeMissing()
407
- visitPromise = up.modal.visit('/bar', target: '.container')
408
- u.task =>
409
- @respondWith('<div class="container">text</div>')
410
- visitPromise.then ->
411
- expect(up.modal.coveredUrl()).toMatchUrl('/foo')
412
- up.modal.close().then ->
413
- expect(up.modal.coveredUrl()).toBeMissing()
414
- done()
415
-
416
- describe 'up.modal.flavors', ->
417
-
418
- it 'allows to register new modal variants with its own default configuration', asyncSpec (next) ->
419
- up.modal.flavors.variant = { maxWidth: 200 }
420
- $link = $fixture('a[href="/path"][up-modal=".target"][up-flavor="variant"]')
421
- Trigger.click($link)
422
-
423
- next =>
424
- @respondWith('<div class="target">new text</div>')
425
-
426
- next =>
427
- $modal = $('.up-modal')
428
- $dialog = $modal.find('.up-modal-dialog')
429
- expect($modal).toBeAttached()
430
- expect($modal.attr('up-flavor')).toEqual('variant')
431
- expect($dialog.attr('style')).toContain('max-width: 200px')
432
-
433
- it 'does not change the configuration of non-flavored modals', asyncSpec (next) ->
434
- up.modal.flavors.variant = { maxWidth: 200 }
435
- $link = $fixture('a[href="/path"][up-modal=".target"]')
436
- Trigger.click($link)
437
-
438
- next =>
439
- @respondWith('<div class="target">new text</div>')
440
-
441
- next =>
442
- $modal = $('.up-modal')
443
- $dialog = $modal.find('.up-modal-dialog')
444
- expect($modal).toBeAttached()
445
- expect($dialog.attr('style')).toBeBlank()
446
-
447
- describe 'up.modal.close', ->
448
-
449
- it 'closes a currently open modal', (done) ->
450
- up.modal.extract('.content', '<div class="content">Modal content</div>')
451
-
452
- u.task =>
453
- expect('.up-modal .content').toBeAttached()
454
-
455
- up.modal.close().then ->
456
- expect('.up-modal .content').not.toBeAttached()
457
- done()
458
-
459
- it 'does nothing if no modal is open', (done) ->
460
- wasClosed = false
461
- up.on 'up:modal:close', ->
462
- wasClosed = true
463
-
464
- up.modal.close().then ->
465
- expect(wasClosed).toBe(false)
466
- done()
467
-
468
- describe 'unobtrusive behavior', ->
469
-
470
- describe 'a[up-modal]', ->
471
-
472
- beforeEach ->
473
- up.motion.config.enabled = false
474
-
475
- # Some examples only want to check if follow() has been called, without
476
- # actually making a request.
477
- @stubFollow = =>
478
- @$link = $fixture('a[href="/path"][up-modal=".target"]')
479
- @followSpy = up.modal.knife.mock('followAsap').and.returnValue(Promise.resolve())
480
- @defaultSpy = spyOn(up.link, 'allowDefault').and.callFake((event) -> event.preventDefault())
481
-
482
- it 'opens the clicked link in a modal', asyncSpec (next) ->
483
- @$link = $fixture('a[href="/path"][up-modal=".target"]')
484
- Trigger.click(@$link)
485
-
486
- next =>
487
- lastRequest = @lastRequest()
488
- expect(lastRequest.url).toMatchUrl('/path')
489
- @respondWith '<div class="target">new content</div>'
490
-
491
- next =>
492
- expect('.up-modal').toBeAttached()
493
- expect('.up-modal-content').toHaveText('new content')
494
-
495
- describe 'when modifier keys are held', ->
496
-
497
- # IE does not call JavaScript and always performs the default action on right clicks
498
- unless AgentDetector.isIE() || AgentDetector.isEdge()
499
- it 'does nothing if the right mouse button is used', asyncSpec (next) ->
500
- @stubFollow()
501
- Trigger.click(@$link, button: 2)
502
- next => expect(@followSpy).not.toHaveBeenCalled()
503
-
504
- it 'does nothing if shift is pressed during the click', asyncSpec (next) ->
505
- @stubFollow()
506
- Trigger.click(@$link, shiftKey: true)
507
- next => expect(@followSpy).not.toHaveBeenCalled()
508
-
509
- it 'does nothing if ctrl is pressed during the click', asyncSpec (next) ->
510
- @stubFollow()
511
- Trigger.click(@$link, ctrlKey: true)
512
- next => expect(@followSpy).not.toHaveBeenCalled()
513
-
514
- it 'does nothing if meta is pressed during the click', asyncSpec (next) ->
515
- @stubFollow()
516
- Trigger.click(@$link, metaKey: true)
517
- next => expect(@followSpy).not.toHaveBeenCalled()
518
-
519
- describe 'with [up-instant] modifier', ->
520
-
521
- beforeEach ->
522
- @stubFollow()
523
- @$link.attr('up-instant', '')
524
-
525
- it 'opens the modal on mousedown (instead of on click)', asyncSpec (next) ->
526
- Trigger.mousedown(@$link)
527
- next =>
528
- expect(@followSpy).toHaveBeenCalledWith(@$link[0], {})
529
-
530
- it 'does nothing on mouseup', asyncSpec (next) ->
531
- Trigger.mouseup(@$link)
532
- next => expect(@followSpy).not.toHaveBeenCalled()
533
-
534
- it 'does nothing on click', asyncSpec (next) ->
535
- Trigger.click(@$link)
536
- next => expect(@followSpy).not.toHaveBeenCalled()
537
-
538
- # IE does not call JavaScript and always performs the default action on right clicks
539
- unless AgentDetector.isIE() || AgentDetector.isEdge()
540
- it 'does nothing if the right mouse button is pressed down', asyncSpec (next) ->
541
- Trigger.mousedown(@$link, button: 2)
542
- next => expect(@followSpy).not.toHaveBeenCalled()
543
-
544
- it 'does nothing if shift is pressed during mousedown', asyncSpec (next) ->
545
- Trigger.mousedown(@$link, shiftKey: true)
546
- next => expect(@followSpy).not.toHaveBeenCalled()
547
-
548
- it 'does nothing if ctrl is pressed during mousedown', asyncSpec (next) ->
549
- Trigger.mousedown(@$link, ctrlKey: true)
550
- next => expect(@followSpy).not.toHaveBeenCalled()
551
-
552
- it 'does nothing if meta is pressed during mousedown', asyncSpec (next) ->
553
- Trigger.mousedown(@$link, metaKey: true)
554
- next => expect(@followSpy).not.toHaveBeenCalled()
555
-
556
- describe 'with [up-method] modifier', ->
557
-
558
- it 'honours the given method', asyncSpec (next) ->
559
- $link = $fixture('a[href="/path"][up-modal=".target"][up-method="post"]')
560
- Trigger.click($link)
561
-
562
- next =>
563
- expect(@lastRequest().method).toEqual 'POST'
564
-
565
- it 'adds a history entry and allows the user to use the back button', asyncSpec (next) ->
566
- up.motion.config.enabled = false
567
- up.history.config.enabled = true
568
- up.history.config.popTargets = ['.container']
569
-
570
- up.history.push('/original-path')
571
-
572
- $container = $fixture('.container').text('old container content')
573
- $link = $container.affix('a[href="/new-path"][up-modal=".target"]')
574
-
575
- expect(location.pathname).toEqual('/original-path')
576
-
577
- Trigger.clickSequence($link)
578
-
579
- next =>
580
- @respondWith('<div class="target">modal content</div>')
581
-
582
- next =>
583
- expect(location.pathname).toEqual('/new-path')
584
- expect('.up-modal .target').toHaveText('modal content')
585
-
586
- history.back()
587
-
588
- next.after (waitForBrowser = 70), =>
589
- @respondWith('<div class="container">restored container content</div>')
590
-
591
- next =>
592
- expect(location.pathname).toEqual('/original-path')
593
- expect('.container').toHaveText('restored container content')
594
- expect('.up-modal').not.toBeAttached()
595
-
596
- it 'allows to open a modal after closing a previous modal with the escape key (bugfix)', asyncSpec (next) ->
597
- up.motion.config.enabled = false
598
-
599
- $link1 = $fixture('a[href="/path1"][up-modal=".target"]')
600
- $link2 = $fixture('a[href="/path2"][up-modal=".target"]')
601
- Trigger.clickSequence($link1)
602
-
603
- next =>
604
- @respondWith('<div class="target">content 1</div>')
605
-
606
- next =>
607
- expect(up.modal.isOpen()).toBe(true)
608
-
609
- Trigger.escapeSequence(document.body)
610
-
611
- next =>
612
- expect(up.modal.isOpen()).toBe(false)
613
-
614
- Trigger.clickSequence($link2)
615
-
616
- next =>
617
- @respondWith('<div class="target">content 1</div>')
618
-
619
- next =>
620
- expect(up.modal.isOpen()).toBe(true)
621
-
622
-
623
- describe '[up-drawer]', ->
624
-
625
- beforeEach ->
626
- up.motion.config.enabled = false
627
-
628
- it 'slides in a drawer that covers the full height of the screen', asyncSpec (next) ->
629
- $link = $fixture('a[href="/qux"][up-drawer=".target"]').text('label')
630
- up.hello($link)
631
- Trigger.clickSequence($link)
632
-
633
- next =>
634
- @respondWith '<div class="target">new text</div>'
635
-
636
- next =>
637
- expect(up.modal.isOpen()).toBe(true)
638
- expect($('.up-modal').attr('up-flavor')).toEqual('drawer')
639
- windowHeight = up.viewport.rootHeight()
640
- modalHeight = $('.up-modal-content').outerHeight()
641
- expect(modalHeight).toEqual(windowHeight)
642
- expect($('.up-modal-content').offset()).toEqual(top: 0, left: 0)
643
-
644
- it 'puts the drawer on the right if the opening link sits in the right 50% of the screen', asyncSpec (next) ->
645
- $link = $fixture('a[href="/foo"][up-drawer=".target"]').text('label')
646
- $link.css
647
- position: 'absolute'
648
- right: '0'
649
- up.hello($link)
650
- Trigger.clickSequence($link)
651
-
652
- next =>
653
- @respondWith '<div class="target">new text</div>'
654
-
655
- next =>
656
- expect(up.modal.isOpen()).toBe(true)
657
- windowWidth = up.viewport.rootWidth()
658
- modalWidth = $('.up-modal-content').outerWidth()
659
- scrollbarWidth = up.viewport.scrollbarWidth()
660
- expect($('.up-modal-content').offset().left).toBeAround(windowWidth - modalWidth - scrollbarWidth, 1.0)
661
-
662
- describe '[up-close]', ->
663
-
664
- backgroundClicked = undefined
665
-
666
- beforeEach ->
667
- up.motion.config.enabled = false
668
- backgroundClicked = jasmine.createSpy('background clicked')
669
- up.on 'click', backgroundClicked
670
-
671
- describe 'when clicked inside a modal', ->
672
-
673
- it 'closes the open modal and halts the event chain', asyncSpec (next) ->
674
- up.modal.extract('.target', '<div class="target"><a up-close>text</a></div>', animation: false)
675
-
676
- next =>
677
- $link = $('.up-modal a[up-close]') # link is within the modal
678
- Trigger.clickSequence($link)
679
-
680
- next =>
681
- expect(up.modal.isOpen()).toBe(false)
682
- expect(backgroundClicked).not.toHaveBeenCalled()
683
-
684
-
685
- describe 'when no modal is open', ->
686
-
687
- it 'does nothing and allows the event chain to continue', asyncSpec (next) ->
688
- $link = $fixture('a[up-close]') # link is outside the modal
689
- up.hello($link)
690
- Trigger.clickSequence($link)
691
-
692
- next =>
693
- expect(backgroundClicked).toHaveBeenCalled()
694
-
695
- describe 'closing', ->
696
-
697
- it 'closes the modal on close icon click', asyncSpec (next) ->
698
- up.modal.extract('.modal', '<div class="modal">Modal content</div>', animation: false)
699
-
700
- next =>
701
- $closeIcon = $('.up-modal-close')
702
- Trigger.clickSequence($closeIcon)
703
-
704
- next =>
705
- expect(up.modal.isOpen()).toBe(false)
706
-
707
- it 'closes the modal on backdrop click', asyncSpec (next) ->
708
- up.modal.extract('.modal', '<div class="modal">Modal content</div>', animation: false)
709
-
710
- next =>
711
- $backdrop = $('.up-modal-backdrop')
712
- Trigger.clickSequence($backdrop)
713
-
714
- next =>
715
- expect(up.modal.isOpen()).toBe(false)
716
-
717
- it "does not close the modal when clicking on an element outside the modal's DOM hierarchy", asyncSpec (next) ->
718
- $container = $fixture('.container')
719
- up.modal.extract('.modal', '<div class="modal">Modal content</div>', animation: false)
720
-
721
- next =>
722
- Trigger.clickSequence($container)
723
-
724
- next =>
725
- expect(up.modal.isOpen()).toBe(true)
726
-
727
- it 'closes the modal when the user presses the escape key', asyncSpec (next) ->
728
- wasClosed = false
729
- up.on 'up:modal:close', ->
730
- wasClosed = true
731
-
732
- up.modal.extract('.modal', '<div class="modal">Modal content</div>', animation: false)
733
-
734
- next =>
735
- Trigger.escapeSequence(document.body)
736
-
737
- next =>
738
- expect(wasClosed).toBe(true)
739
-
740
- it 'stays open if #preventDefault() is called on up:modal:close event', asyncSpec (next) ->
741
- up.modal.extract('.target', '<div class="target"><a up-close>text</a></div>', animation: false)
742
- up.on 'up:modal:close', (e) -> e.preventDefault()
743
-
744
- next =>
745
- $backdrop = $('.up-modal-backdrop')
746
- Trigger.clickSequence($backdrop)
747
-
748
- next =>
749
- expect(up.modal.isOpen()).toBe(true)
750
-
751
- # Since there isn't anyone who could handle the rejection inside
752
- # the event handler, our handler mutes the rejection.
753
- expect(window).not.toHaveUnhandledRejections()
754
-
755
- describe 'when opened with { closable: false }', ->
756
-
757
- it 'does not render a close icon', asyncSpec (next) ->
758
- up.modal.extract('.modal', '<div class="modal">Modal content</div>', animation: false, closable: false)
759
-
760
- next =>
761
- expect('.up-modal').not.toHaveDescendant('.up-modal-close')
762
-
763
- it 'does not close the modal on backdrop click', asyncSpec (next) ->
764
- up.modal.extract('.modal', '<div class="modal">Modal content</div>', animation: false, closable: false)
765
-
766
- next =>
767
- $backdrop = $('.up-modal-backdrop')
768
- Trigger.clickSequence($backdrop)
769
-
770
- next =>
771
- expect(up.modal.isOpen()).toBe(true)
772
-
773
- it 'does not close the modal when the user presses the escape key', asyncSpec (next) ->
774
- up.modal.extract('.modal', '<div class="modal">Modal content</div>', animation: false, closable: false)
775
-
776
- next =>
777
- Trigger.escapeSequence(document.body)
778
-
779
- next =>
780
- expect(up.modal.isOpen()).toBe(true)
781
-
782
- describe 'when replacing content', ->
783
-
784
- beforeEach ->
785
- up.motion.config.enabled = false
786
-
787
- it 'prefers to replace a selector within the modal', asyncSpec (next) ->
788
- $outside = $fixture('.foo').text('old outside')
789
- up.modal.visit('/path', target: '.foo')
790
-
791
- next =>
792
- @respondWith("<div class='foo'>old inside</div>")
793
-
794
- next =>
795
- up.extract('.foo', "<div class='foo'>new text</div>")
796
-
797
- next =>
798
- expect($outside).toBeAttached()
799
- expect($outside).toHaveText('old outside')
800
- expect($('.up-modal-content')).toHaveText('new text')
801
-
802
- it 'auto-closes the modal when a replacement from inside the modal affects a selector behind the modal', asyncSpec (next) ->
803
- $fixture('.outside').text('old outside')
804
- up.modal.visit('/path', target: '.inside')
805
-
806
- next =>
807
- @respondWith("<div class='inside'>old inside</div>")
808
-
809
- next =>
810
- up.extract('.outside', "<div class='outside'>new outside</div>", origin: $('.inside'))
811
-
812
- next =>
813
- expect($('.outside')).toHaveText('new outside')
814
- expect($('.up-modal')).not.toBeAttached()
815
-
816
- it 'does not restore the covered URL when auto-closing (since it would override the URL from the triggering update)', asyncSpec (next) ->
817
- up.history.config.enabled = true
818
- up.motion.config.enabled = true
819
- up.modal.config.openDuration = 0
820
- up.modal.config.closeDuration = 20
821
-
822
- $fixture('.outside').text('old outside')
823
- up.modal.visit('/path', target: '.inside')
824
-
825
- next =>
826
- @respondWith("<div class='inside'>old inside</div>") # Populate modal
827
-
828
- next =>
829
- up.extract('.outside', "<div class='outside'>new outside</div>",
830
- origin: $('.inside'), history: '/new-location') # Provoke auto-close
831
-
832
- next =>
833
- expect(location.href).toMatchUrl '/new-location'
834
-
835
- it 'does not auto-close the modal when a replacement from inside the modal affects a selector inside the modal', asyncSpec (next) ->
836
- $fixture('.outside').text('old outside')
837
- up.modal.visit('/path', target: '.inside')
838
-
839
- next =>
840
- @respondWith("<div class='inside'>old inside</div>")
841
-
842
- next =>
843
- up.extract('.inside', "<div class='inside'>new inside</div>", origin: $('.inside'))
844
-
845
- next =>
846
- expect($('.inside')).toHaveText('new inside')
847
- expect($('.up-modal')).toBeAttached()
848
-
849
- it 'does not auto-close the modal when a replacement from outside the modal affects a selector outside the modal', asyncSpec (next) ->
850
- $fixture('.outside').text('old outside')
851
- up.modal.visit('/path', target: '.inside')
852
-
853
- next =>
854
- @respondWith("<div class='inside'>old inside</div>")
855
-
856
- next =>
857
- up.extract('.outside', "<div class='outside'>new outside</div>", origin: $('.outside'))
858
-
859
- next =>
860
- expect($('.outside')).toHaveText('new outside')
861
- expect($('.up-modal')).toBeAttached()
862
-
863
- it 'does not auto-close the modal when a replacement from outside the modal affects a selector inside the modal', asyncSpec (next) ->
864
- $fixture('.outside').text('old outside')
865
- up.modal.visit('/path', target: '.inside')
866
-
867
- next =>
868
- @respondWith("<div class='inside'>old inside</div>")
869
-
870
- next =>
871
- up.extract('.inside', "<div class='inside'>new inside</div>", origin: $('.outside'))
872
-
873
- next =>
874
- expect($('.inside')).toHaveText('new inside')
875
- expect($('.up-modal')).toBeAttached()
876
-
877
- it 'does not auto-close the modal when the new fragment is within a popup', asyncSpec (next) ->
878
- up.modal.visit('/modal', target: '.modal-content')
879
-
880
- next =>
881
- @respondWith("<div class='modal-content'></div>")
882
-
883
- next =>
884
- up.popup.attach('.modal-content', url: '/popup', target: '.popup-content')
885
-
886
- next =>
887
- @respondWith("<div class='popup-content'></div>")
888
-
889
- next =>
890
- expect($('.up-modal')).toBeAttached()
891
- expect($('.up-popup')).toBeAttached()
892
-
893
- it 'does not close the modal when a clicked [up-target] link within the modal links to cached content (bugfix)', asyncSpec (next) ->
894
- up.modal.extract '.content', """
895
- <div class="content">
896
- <a href="/foo" up-target=".content">link</a>
897
- </div>
898
- """
899
-
900
- next =>
901
- $link = $('.up-modal .content a')
902
- expect($link).toBeAttached()
903
- up.proxy.preload($link)
904
-
905
- next =>
906
- @respondWith """
907
- <div class="content">
908
- new text
909
- </div>
910
- """
911
-
912
- next =>
913
- Trigger.clickSequence('.up-modal .content a')
914
-
915
- next =>
916
- expect($('.up-modal')).toBeAttached()
917
- expect($('.up-modal .content')).toHaveText('new text')