unpoly-rails 0.57.0 → 0.60.0

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 (186) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +393 -1
  3. data/Gemfile.lock +5 -2
  4. data/README.md +1 -1
  5. data/README_RAILS.md +1 -1
  6. data/Rakefile +10 -1
  7. data/design/es6.js +32 -0
  8. data/design/ie11.txt +9 -0
  9. data/design/measure_jquery/element_list.js +41 -0
  10. data/design/measure_jquery/up.on_vs_addEventListener.js +56 -0
  11. data/design/todo_jquery.txt +13 -0
  12. data/dist/unpoly-bootstrap3.js +8 -8
  13. data/dist/unpoly-bootstrap3.min.js +1 -1
  14. data/dist/unpoly.css +22 -20
  15. data/dist/unpoly.js +6990 -5336
  16. data/dist/unpoly.min.css +1 -1
  17. data/dist/unpoly.min.js +4 -4
  18. data/lib/assets/javascripts/unpoly-bootstrap3/viewport-ext.coffee +5 -0
  19. data/lib/assets/javascripts/unpoly.coffee +8 -6
  20. data/lib/assets/javascripts/unpoly/browser.coffee.erb +23 -118
  21. data/lib/assets/javascripts/unpoly/classes/body_shifter.coffee +36 -0
  22. data/lib/assets/javascripts/unpoly/classes/cache.coffee +4 -4
  23. data/lib/assets/javascripts/unpoly/classes/compile_pass.coffee +45 -39
  24. data/lib/assets/javascripts/unpoly/classes/config.coffee +9 -0
  25. data/lib/assets/javascripts/unpoly/classes/css_transition.coffee +18 -27
  26. data/lib/assets/javascripts/unpoly/classes/divertible_chain.coffee +39 -0
  27. data/lib/assets/javascripts/unpoly/classes/event_listener.coffee +116 -0
  28. data/lib/assets/javascripts/unpoly/classes/extract_cascade.coffee +8 -8
  29. data/lib/assets/javascripts/unpoly/classes/extract_plan.coffee +19 -19
  30. data/lib/assets/javascripts/unpoly/classes/field_observer.coffee +54 -31
  31. data/lib/assets/javascripts/unpoly/classes/{focus_tracker.coffee → focus_follower.coffee} +2 -2
  32. data/lib/assets/javascripts/unpoly/classes/follow_variant.coffee +25 -25
  33. data/lib/assets/javascripts/unpoly/classes/html_parser.coffee +4 -11
  34. data/lib/assets/javascripts/unpoly/classes/motion_controller.coffee +157 -0
  35. data/lib/assets/javascripts/unpoly/classes/params.coffee.erb +525 -0
  36. data/lib/assets/javascripts/unpoly/classes/record.coffee +8 -2
  37. data/lib/assets/javascripts/unpoly/classes/rect.js +21 -0
  38. data/lib/assets/javascripts/unpoly/classes/request.coffee +41 -35
  39. data/lib/assets/javascripts/unpoly/classes/response.coffee +7 -3
  40. data/lib/assets/javascripts/unpoly/classes/reveal_motion.coffee +102 -0
  41. data/lib/assets/javascripts/unpoly/classes/scroll_motion.coffee +67 -0
  42. data/lib/assets/javascripts/unpoly/classes/selector.coffee +60 -0
  43. data/lib/assets/javascripts/unpoly/classes/tether.coffee +105 -0
  44. data/lib/assets/javascripts/unpoly/classes/url_set.coffee +12 -7
  45. data/lib/assets/javascripts/unpoly/element.coffee.erb +1126 -0
  46. data/lib/assets/javascripts/unpoly/event.coffee.erb +437 -0
  47. data/lib/assets/javascripts/unpoly/feedback.coffee +73 -94
  48. data/lib/assets/javascripts/unpoly/form.coffee.erb +188 -181
  49. data/lib/assets/javascripts/unpoly/{dom.coffee.erb → fragment.coffee.erb} +250 -283
  50. data/lib/assets/javascripts/unpoly/framework.coffee +67 -0
  51. data/lib/assets/javascripts/unpoly/history.coffee +29 -28
  52. data/lib/assets/javascripts/unpoly/legacy.coffee +60 -0
  53. data/lib/assets/javascripts/unpoly/link.coffee.erb +127 -119
  54. data/lib/assets/javascripts/unpoly/log.coffee +99 -19
  55. data/lib/assets/javascripts/unpoly/modal.coffee.erb +95 -118
  56. data/lib/assets/javascripts/unpoly/motion.coffee.erb +158 -138
  57. data/lib/assets/javascripts/unpoly/namespace.coffee.erb +0 -5
  58. data/lib/assets/javascripts/unpoly/popup.coffee.erb +119 -102
  59. data/lib/assets/javascripts/unpoly/protocol.coffee +11 -15
  60. data/lib/assets/javascripts/unpoly/proxy.coffee +62 -65
  61. data/lib/assets/javascripts/unpoly/radio.coffee +3 -5
  62. data/lib/assets/javascripts/unpoly/rails.coffee +8 -9
  63. data/lib/assets/javascripts/unpoly/syntax.coffee.erb +173 -125
  64. data/lib/assets/javascripts/unpoly/toast.coffee +25 -24
  65. data/lib/assets/javascripts/unpoly/tooltip.coffee +89 -79
  66. data/lib/assets/javascripts/unpoly/util.coffee.erb +579 -1074
  67. data/lib/assets/javascripts/unpoly/{layout.coffee.erb → viewport.coffee.erb} +334 -264
  68. data/lib/assets/stylesheets/unpoly/dom.sass +1 -1
  69. data/lib/assets/stylesheets/unpoly/layout.sass +2 -0
  70. data/lib/assets/stylesheets/unpoly/popup.sass +0 -1
  71. data/lib/assets/stylesheets/unpoly/tooltip.sass +17 -12
  72. data/lib/unpoly/rails/version.rb +1 -1
  73. data/package.json +1 -2
  74. data/spec_app/Gemfile +2 -1
  75. data/spec_app/Gemfile.lock +38 -27
  76. data/spec_app/app/assets/javascripts/integration_test.coffee +1 -0
  77. data/spec_app/app/assets/javascripts/jasmine_specs.coffee +1 -2
  78. data/spec_app/app/assets/stylesheets/integration_test.sass +14 -1
  79. data/spec_app/app/controllers/scroll_test_controller.rb +5 -0
  80. data/spec_app/app/views/css_test/modal.erb +6 -6
  81. data/spec_app/app/views/css_test/popup.erb +44 -18
  82. data/spec_app/app/views/css_test/tooltip.erb +23 -4
  83. data/spec_app/app/views/error_test/trigger.erb +1 -1
  84. data/spec_app/app/views/form_test/basics/new.erb +1 -3
  85. data/spec_app/app/views/pages/start.erb +9 -2
  86. data/spec_app/app/views/reveal_test/long1.erb +1 -1
  87. data/spec_app/app/views/reveal_test/long2.erb +1 -1
  88. data/spec_app/app/views/reveal_test/within_document_viewport.erb +24 -0
  89. data/spec_app/app/views/reveal_test/within_overflowing_div_viewport.erb +28 -0
  90. data/spec_app/app/views/scroll_test/long1.erb +30 -0
  91. data/spec_app/config/routes.rb +1 -0
  92. data/spec_app/spec/javascripts/helpers/agent_detector.coffee +3 -0
  93. data/spec_app/spec/javascripts/helpers/async_sequence.js.coffee +1 -0
  94. data/spec_app/spec/javascripts/helpers/browser_switches.js.coffee +17 -5
  95. data/spec_app/spec/javascripts/helpers/enable_logging.js.coffee +1 -1
  96. data/spec_app/spec/javascripts/helpers/fixture.js.coffee +25 -0
  97. data/spec_app/spec/javascripts/helpers/jquery_no_conflict.js +1 -0
  98. data/spec_app/spec/javascripts/helpers/last_request.js.coffee +1 -0
  99. data/spec_app/spec/javascripts/helpers/mock_ajax.js.coffee +1 -1
  100. data/spec_app/spec/javascripts/helpers/parse_form_data.js.coffee +2 -2
  101. data/spec_app/spec/javascripts/helpers/protect_jasmine_runner.coffee +4 -1
  102. data/spec_app/spec/javascripts/helpers/remove_body_margin.js.coffee +3 -0
  103. data/spec_app/spec/javascripts/helpers/reset_history.js.coffee +2 -1
  104. data/spec_app/spec/javascripts/helpers/reset_knife.js.coffee +2 -2
  105. data/spec_app/spec/javascripts/helpers/reset_up.js.coffee +18 -11
  106. data/spec_app/spec/javascripts/helpers/restore_body_scroll.js.coffee +3 -0
  107. data/spec_app/spec/javascripts/helpers/show_lib_versions.coffee +3 -0
  108. data/spec_app/spec/javascripts/helpers/spec_util.coffee +47 -0
  109. data/spec_app/spec/javascripts/helpers/to_be_around.js.coffee +3 -0
  110. data/spec_app/spec/javascripts/helpers/to_be_array.coffee +5 -0
  111. data/spec_app/spec/javascripts/helpers/to_be_attached.coffee +6 -2
  112. data/spec_app/spec/javascripts/helpers/to_be_blank.js.coffee +3 -0
  113. data/spec_app/spec/javascripts/helpers/to_be_detached.coffee +6 -2
  114. data/spec_app/spec/javascripts/helpers/to_be_element.js.coffee +8 -0
  115. data/spec_app/spec/javascripts/helpers/to_be_error.coffee +3 -0
  116. data/spec_app/spec/javascripts/helpers/to_be_given.js.coffee +3 -0
  117. data/spec_app/spec/javascripts/helpers/to_be_hidden.js.coffee +8 -0
  118. data/spec_app/spec/javascripts/helpers/to_be_missing.js.coffee +3 -0
  119. data/spec_app/spec/javascripts/helpers/to_be_present.js.coffee +3 -0
  120. data/spec_app/spec/javascripts/helpers/to_be_scrolled_to.coffee +3 -0
  121. data/spec_app/spec/javascripts/helpers/to_be_visible.js.coffee +9 -0
  122. data/spec_app/spec/javascripts/helpers/to_contain.js.coffee +3 -0
  123. data/spec_app/spec/javascripts/helpers/to_end_with.js.coffee +3 -0
  124. data/spec_app/spec/javascripts/helpers/to_equal_jquery.js.coffee +1 -2
  125. data/spec_app/spec/javascripts/helpers/to_equal_node_list.coffee +7 -0
  126. data/spec_app/spec/javascripts/helpers/to_equal_via_is_equal.js.coffee +7 -0
  127. data/spec_app/spec/javascripts/helpers/to_have_class.js.coffee +10 -0
  128. data/spec_app/spec/javascripts/helpers/to_have_descendant.js.coffee +10 -0
  129. data/spec_app/spec/javascripts/helpers/to_have_length.js.coffee +8 -0
  130. data/spec_app/spec/javascripts/helpers/to_have_opacity.coffee +7 -3
  131. data/spec_app/spec/javascripts/helpers/to_have_own_property.js.coffee +3 -0
  132. data/spec_app/spec/javascripts/helpers/to_have_request_method.js.coffee +1 -0
  133. data/spec_app/spec/javascripts/helpers/to_have_text.js.coffee +9 -0
  134. data/spec_app/spec/javascripts/helpers/to_have_unhandled_rejections.coffee +0 -21
  135. data/spec_app/spec/javascripts/helpers/to_match_list.coffee +14 -0
  136. data/spec_app/spec/javascripts/helpers/to_match_selector.coffee +3 -0
  137. data/spec_app/spec/javascripts/helpers/to_match_text.js.coffee +4 -1
  138. data/spec_app/spec/javascripts/helpers/to_match_url.coffee +1 -0
  139. data/spec_app/spec/javascripts/helpers/trigger.js.coffee +91 -7
  140. data/spec_app/spec/javascripts/helpers/wait_until_dom_ready.js.coffee +3 -0
  141. data/spec_app/spec/javascripts/up/browser_spec.js.coffee +23 -90
  142. data/spec_app/spec/javascripts/up/classes/cache_spec.js.coffee +3 -0
  143. data/spec_app/spec/javascripts/up/classes/config_spec.coffee +24 -0
  144. data/spec_app/spec/javascripts/up/classes/divertible_chain_spec.coffee +45 -0
  145. data/spec_app/spec/javascripts/up/classes/focus_tracker_spec.coffee +5 -2
  146. data/spec_app/spec/javascripts/up/classes/params_spec.coffee +557 -0
  147. data/spec_app/spec/javascripts/up/classes/request_spec.coffee +7 -4
  148. data/spec_app/spec/javascripts/up/classes/scroll_motion_spec.js.coffee +51 -0
  149. data/spec_app/spec/javascripts/up/classes/store/memory_spec.js.coffee +3 -0
  150. data/spec_app/spec/javascripts/up/classes/store/session_spec.js.coffee +3 -2
  151. data/spec_app/spec/javascripts/up/element_spec.coffee +897 -0
  152. data/spec_app/spec/javascripts/up/event_spec.js.coffee +496 -0
  153. data/spec_app/spec/javascripts/up/feedback_spec.js.coffee +69 -48
  154. data/spec_app/spec/javascripts/up/form_spec.js.coffee +252 -194
  155. data/spec_app/spec/javascripts/up/{dom_spec.js.coffee → fragment_spec.js.coffee} +381 -388
  156. data/spec_app/spec/javascripts/up/history_spec.js.coffee +21 -19
  157. data/spec_app/spec/javascripts/up/jquery_spec.js.coffee +4 -0
  158. data/spec_app/spec/javascripts/up/legacy_spec.js.coffee +27 -0
  159. data/spec_app/spec/javascripts/up/link_spec.js.coffee +163 -160
  160. data/spec_app/spec/javascripts/up/log_spec.js.coffee +85 -12
  161. data/spec_app/spec/javascripts/up/modal_spec.js.coffee +141 -123
  162. data/spec_app/spec/javascripts/up/motion_spec.js.coffee +117 -113
  163. data/spec_app/spec/javascripts/up/popup_spec.js.coffee +60 -77
  164. data/spec_app/spec/javascripts/up/protocol_spec.js.coffee +1 -0
  165. data/spec_app/spec/javascripts/up/proxy_spec.js.coffee +85 -78
  166. data/spec_app/spec/javascripts/up/radio_spec.js.coffee +29 -22
  167. data/spec_app/spec/javascripts/up/rails_spec.js.coffee +14 -13
  168. data/spec_app/spec/javascripts/up/spec_spec.js.coffee +9 -0
  169. data/spec_app/spec/javascripts/up/syntax_spec.js.coffee +96 -66
  170. data/spec_app/spec/javascripts/up/toast_spec.js.coffee +37 -0
  171. data/spec_app/spec/javascripts/up/tooltip_spec.js.coffee +31 -47
  172. data/spec_app/spec/javascripts/up/util_spec.js.coffee +725 -562
  173. data/spec_app/spec/javascripts/up/{layout_spec.js.coffee → viewport_spec.js.coffee} +175 -149
  174. metadata +57 -19
  175. data/lib/assets/javascripts/unpoly-bootstrap3/layout-ext.coffee +0 -5
  176. data/lib/assets/javascripts/unpoly/bus.coffee.erb +0 -518
  177. data/lib/assets/javascripts/unpoly/classes/extract_step.coffee +0 -4
  178. data/lib/assets/javascripts/unpoly/classes/motion_tracker.coffee +0 -125
  179. data/lib/assets/javascripts/unpoly/params.coffee.erb +0 -522
  180. data/spec_app/spec/javascripts/helpers/append_fixture.js.coffee +0 -8
  181. data/spec_app/spec/javascripts/up/bus_spec.js.coffee +0 -210
  182. data/spec_app/spec/javascripts/up/namespace_spec.js.coffee +0 -9
  183. data/spec_app/spec/javascripts/up/params_spec.coffee +0 -768
  184. data/spec_app/vendor/asset-libs/jasmine-fixture-1.3.4/jasmine-fixture.js +0 -433
  185. data/spec_app/vendor/asset-libs/jasmine-jquery-2.1.1/.bower.json +0 -26
  186. data/spec_app/vendor/asset-libs/jasmine-jquery-2.1.1/jasmine-jquery.js +0 -838
@@ -1,5 +1,5 @@
1
1
  <script>
2
- up.dom.config.fallbacks = [];
2
+ up.fragment.config.fallbacks = [];
3
3
  </script>
4
4
 
5
5
  <div class="example">
@@ -21,9 +21,7 @@
21
21
  <p>
22
22
  <label>
23
23
  input[type=checkbox]
24
- <select name="checkbox-param">
25
- <option value="checkbox-value">checkbox-label</option>
26
- </select>
24
+ <input type="checkbox" name="checkbox-param" value="checkbox-value">
27
25
  </label>
28
26
  </p>
29
27
 
@@ -9,11 +9,14 @@
9
9
  <%= link_to 'Jasmine specs with jQuery 3', '/specs?jquery=3' %>
10
10
  <ul>
11
11
  <% %w[
12
- up.dom
12
+ up.browser
13
+ up.element
14
+ up.event
13
15
  up.feedback
14
16
  up.form
17
+ up.fragment
15
18
  up.history
16
- up.layout
19
+ up.legacy
17
20
  up.link
18
21
  up.log
19
22
  up.modal
@@ -26,6 +29,7 @@
26
29
  up.toast
27
30
  up.tooltip
28
31
  up.util
32
+ up.viewport
29
33
  ].each do |mod| %>
30
34
  <li><%= link_to mod, "/specs?spec=#{mod}" %></li>
31
35
  <% end %>
@@ -62,7 +66,10 @@
62
66
  <li><%= link_to 'Fragment update', '/replace_test/page1' %></li>
63
67
  <li><%= link_to 'Hash links (without Unpoly)', '/hash_test/vanilla#one' %></li>
64
68
  <li><%= link_to 'Hash links (with Unpoly)', '/hash_test/unpoly#one' %></li>
69
+ <li><%= link_to 'Revealing content in an overflowing <div> ', '/reveal_test/within_overflowing_div_viewport' %></li>
70
+ <li><%= link_to 'Revealing content in the document viewport ', '/reveal_test/within_document_viewport' %></li>
65
71
  <li><%= link_to 'Revealing long pages', '/reveal_test/long1' %></li>
72
+ <li><%= link_to 'Scrolling behavior', '/scroll_test/long1' %></li>
66
73
  <li><%= link_to 'Animations', '/motion_test/animations' %></li>
67
74
  <li><%= link_to 'Transitions', '/motion_test/transitions' %></li>
68
75
  </ul>
@@ -1,6 +1,6 @@
1
1
  <script>
2
2
  up.motion.config.duration = 2000
3
- up.layout.config.duration = 2000
3
+ up.viewport.config.duration = 2000
4
4
  </script>
5
5
 
6
6
  <div class="long-page" style="height: 2000px; background-color: rgba(0, 0, 255, 0.3)">
@@ -1,6 +1,6 @@
1
1
  <script>
2
2
  up.motion.config.duration = 2000
3
- up.layout.config.duration = 2000
3
+ up.viewport.config.duration = 2000
4
4
  </script>
5
5
 
6
6
  <div class="long-page" style="height: 2000px; background-color: rgba(255, 0, 0, 0.3)">
@@ -0,0 +1,24 @@
1
+ <div class="fixed-top-bar" up-fixed="top" style="margin: 25px">
2
+ <span class="button" onclick="up.reveal('.small', { behavior: 'smooth' })">Reveal .small</span>
3
+ <span class="button" onclick="up.reveal('.large', { behavior: 'smooth' })">Reveal .large</span>
4
+ <span class="button" onclick="up.viewport.config.revealPadding += 25">Increase padding</span>
5
+ </div>
6
+
7
+ <div class="fixed-bottom-bar" up-fixed="bottom" style="margin: 25px">
8
+ </div>
9
+
10
+ <div style="height: 1000px; background-color: rgba(0, 0, 255, 0.2)">
11
+ above
12
+ </div>
13
+
14
+ <div class="example small" style="background-color: rgba(255, 0, 0, 0.4); height: 50px">
15
+ .small
16
+ </div>
17
+
18
+ <div class="example large" style="background-color: rgba(0, 255, 0, 0.4); height: 2000px">
19
+ .large
20
+ </div>
21
+
22
+ <div style="height: 1000px; background-color: rgba(0, 0, 255, 0.2)">
23
+ below
24
+ </div>
@@ -0,0 +1,28 @@
1
+ <div class="fixed-top-bar" up-fixed="top" style="margin: 25px">
2
+ <span class="button" onclick="up.reveal('.small', { behavior: 'smooth' })">Reveal .small</span>
3
+ <span class="button" onclick="up.reveal('.large', { behavior: 'smooth' })">Reveal .large</span>
4
+ <span class="button" onclick="up.viewport.config.revealPadding += 25">Increase padding</span>
5
+ </div>
6
+
7
+ <div class="fixed-bottom-bar" up-fixed="bottom" style="margin: 25px">
8
+ </div>
9
+
10
+ <div up-viewport style="overflow-y: scroll; width: 300px; height: 100vh">
11
+
12
+ <div style="height: 1000px; background-color: rgba(0, 0, 255, 0.2)">
13
+ above
14
+ </div>
15
+
16
+ <div class="example small" style="background-color: rgba(255, 0, 0, 0.4); height: 50px">
17
+ .small
18
+ </div>
19
+
20
+ <div class="example large" style="background-color: rgba(0, 255, 0, 0.4); height: 2000px">
21
+ .large
22
+ </div>
23
+
24
+ <div style="height: 1000px; background-color: rgba(0, 0, 255, 0.2)">
25
+ below
26
+ </div>
27
+
28
+ </div>
@@ -0,0 +1,30 @@
1
+ <div class="example">
2
+
3
+ <p>
4
+ <a class="button" href="#" onclick="up.scroll(document.scrollingElement, document.getElementById('bottom').offsetTop, { behavior: 'smooth' }); return false">Scroll down with Unpoly</a>
5
+ <a class="button" href="#" onclick="document.scrollingElement.scrollTo({ top: document.getElementById('bottom').offsetTop, behavior: 'smooth' }); return false">Scroll down with native</a>
6
+ </p>
7
+
8
+ <h2>Long page</h2>
9
+
10
+ <div style="height: 2000px" id="content">
11
+ Content height:
12
+ <a href="#" onclick="document.getElementById('content').style.height = '100px'; return false">100px</a>
13
+ <a href="#" onclick="document.getElementById('content').style.height = '300px'; return false">300px</a>
14
+ <a href="#" onclick="document.getElementById('content').style.height = '600px'; return false">600px</a>
15
+ <a href="#" onclick="document.getElementById('content').style.height = '1000px'; return false">1000px</a>
16
+ <a href="#" onclick="document.getElementById('content').style.height = '3000px'; return false">3000px</a>
17
+ <a href="#" onclick="document.getElementById('content').style.height = '10000px'; return false">10000px</a>
18
+ <a href="#" onclick="document.getElementById('content').style.height = '90000px'; return false">90000px</a>
19
+ </div>
20
+
21
+ <p id="bottom">
22
+ <a class="button" href="#" onclick="up.scroll(document.scrollingElement, 0, { behavior: 'smooth' }); return false">Scroll up with Unpoly</a>
23
+ <a class="button" href="#" onclick="document.scrollingElement.scrollTo({ top: 0, behavior: 'smooth' }); return false">Scroll up with native</a>
24
+ </p>
25
+
26
+ <div style="height: 3000px">
27
+ <!-- rest -->
28
+ </div>
29
+
30
+ </div>
@@ -13,6 +13,7 @@ Rails.application.routes.draw do
13
13
  get 'replace_test/:action', controller: 'replace_test'
14
14
  get 'hash_test/:action', controller: 'hash_test'
15
15
  get 'reveal_test/:action', controller: 'reveal_test'
16
+ get 'scroll_test/:action', controller: 'scroll_test'
16
17
  get 'motion_test/:action', controller: 'motion_test'
17
18
 
18
19
  namespace :form_test do
@@ -1,3 +1,6 @@
1
+ u = up.util
2
+ $ = jQuery
3
+
1
4
  @AgentDetector = do ->
2
5
 
3
6
  match = (regexp) ->
@@ -1,4 +1,5 @@
1
1
  u = up.util
2
+ $ = jQuery
2
3
 
3
4
  LOG_ENABLED = false
4
5
 
@@ -1,9 +1,21 @@
1
- window.describeCapability = (capability, examples) ->
2
- if up.browser[capability]()
1
+ u = up.util
2
+ $ = jQuery
3
+
4
+ window.describeCapability = (capabilities, examples) ->
5
+ capabilities = u.wrapList(capabilities)
6
+ allSupported = u.every capabilities, (c) ->
7
+ if fn = up.browser[c]
8
+ fn()
9
+ else
10
+ u.fail("Unknown capability: up.browser.#{c}()")
11
+ up.browser[c]()
12
+ if allSupported
3
13
  examples()
4
14
 
5
- window.describeFallback = (capability, examples) ->
6
- describe "in a browser without #{capability}", ->
15
+ window.describeFallback = (capabilities, examples) ->
16
+ capabilities = u.wrapList(capabilities)
17
+ describe "(in a browser without #{capabilities.join(', ')})", ->
7
18
  beforeEach ->
8
- spyOn(up.browser, capability).and.returnValue(false)
19
+ u.each capabilities, (c) ->
20
+ spyOn(up.browser, c).and.returnValue(false)
9
21
  examples()
@@ -1,2 +1,2 @@
1
1
  beforeEach ->
2
- up.log.enable()
2
+ up.log.disable()
@@ -0,0 +1,25 @@
1
+ e = up.element
2
+ $ = jQuery
3
+
4
+ fixturesContainer = undefined
5
+
6
+ ensureContainerExists = ->
7
+ fixturesContainer ||= e.affix(document.body, '.fixtures')
8
+
9
+ afterEach ->
10
+ if fixturesContainer
11
+ e.remove(fixturesContainer)
12
+ fixturesContainer = undefined
13
+
14
+ appendFixture = (args...) ->
15
+ container = ensureContainerExists()
16
+ e.affix(container, args...)
17
+
18
+ $appendFixture = (args...) ->
19
+ $(appendFixture(args...))
20
+
21
+ window.fixture = appendFixture
22
+ window.$fixture = $appendFixture
23
+
24
+ # A lot of legacy tests require this jQuery function
25
+ $.fn.affix = (args...) -> $(e.affix(this[0], args...))
@@ -0,0 +1 @@
1
+ jQuery.noConflict();
@@ -1,4 +1,5 @@
1
1
  u = up.util
2
+ $ = jQuery
2
3
 
3
4
  beforeEach ->
4
5
  @lastRequest = ->
@@ -2,7 +2,7 @@ beforeEach ->
2
2
  jasmine.Ajax.install()
3
3
 
4
4
  afterEach (done) ->
5
- up.util.nextFrame ->
5
+ up.util.task ->
6
6
  jasmine.Ajax.uninstall()
7
7
  done()
8
8
 
@@ -6,10 +6,10 @@ beforeEach ->
6
6
 
7
7
  parse: (params) ->
8
8
  if up.browser.canInspectFormData()
9
- array = up.params.toArray(params)
9
+ array = new up.Params(params).toArray()
10
10
  else if params.originalArray
11
11
  # In browser that don't support FormData#entries(),
12
- # up.params.toArray() stores the original array with the generated
12
+ # up.Params#toArray() stores the original array with the generated
13
13
  # FormData object.
14
14
  array = params.originalArray
15
15
  else
@@ -1,5 +1,8 @@
1
+ u = up.util
2
+ $ = jQuery
3
+
1
4
  beforeEach ->
2
- up.dom.config.fallbacks = ['.default-fallback']
5
+ up.fragment.config.fallbacks = ['.default-fallback']
3
6
  up.history.config.popTargets = ['.default-fallback']
4
7
  $element = $('<div class="default-fallback"></div>')
5
8
  $element.appendTo(document.body)
@@ -1,3 +1,6 @@
1
+ u = up.util
2
+ $ = jQuery
3
+
1
4
  # We have a lot of specs that measure the distance of elements
2
5
  # from the screen edge, so we can't have the Jasmine runner to have
3
6
  # any margins on the body.
@@ -1,4 +1,5 @@
1
1
  u = up.util
2
+ $ = jQuery
2
3
 
3
4
  replaceStateHelperCount = 0
4
5
 
@@ -7,7 +8,7 @@ beforeAll ->
7
8
  @titleBeforeSuite = document.title
8
9
 
9
10
  afterAll (done) ->
10
- up.util.nextFrame =>
11
+ up.util.task =>
11
12
  history.replaceState?({ fromResetPathHelper: true }, '', @hrefBeforeSuite)
12
13
  document.title = @titleBeforeSuite
13
14
  done()
@@ -1,2 +1,2 @@
1
- #afterEach ->
2
- # Knife.reset()
1
+ afterEach ->
2
+ Knife.reset()
@@ -1,18 +1,25 @@
1
+ u = up.util
2
+ $ = jQuery
3
+
1
4
  afterEach (done) ->
2
5
  # If the spec has installed the Jasmine clock, uninstall it so
3
6
  # the timeout below will actually happen.
4
7
  jasmine.clock().uninstall()
5
8
 
6
- # Wait one more frame so pending callbacks have a chance to run.
7
- # Pending callbacks might change the URL or cause errors that bleed into
8
- # the next example.
9
+ # Most pending promises will wait for an animation to finish.
10
+ promise = up.motion.finish()
11
+
12
+ u.always promise, ->
9
13
 
10
- up.util.nextFrame =>
11
- up.reset()
12
- up.browser.popCookie(up.protocol.config.methodCookie)
14
+ # Wait one more frame so pending callbacks have a chance to run.
15
+ # Pending callbacks might change the URL or cause errors that bleed into
16
+ # the next example.
17
+ up.util.task =>
18
+ up.framework.reset()
19
+ up.browser.popCookie(up.protocol.config.methodCookie)
13
20
 
14
- # Give async reset behavior another frame to play out,
15
- # then start the next example.
16
- up.util.nextFrame ->
17
- $('.up-toast').remove()
18
- done()
21
+ # Give async reset behavior another frame to play out,
22
+ # then start the next example.
23
+ up.util.task ->
24
+ $('.up-toast').remove()
25
+ done()
@@ -1,2 +1,5 @@
1
+ u = up.util
2
+ $ = jQuery
3
+
1
4
  afterEach ->
2
5
  $('body').scrollTop(0)
@@ -1,3 +1,6 @@
1
+ u = up.util
2
+ $ = jQuery
3
+
1
4
  showVersions = ->
2
5
  $('.jasmine-version').text """
3
6
  jQuery #{$.fn.jquery}
@@ -0,0 +1,47 @@
1
+ u = up.util
2
+ e = up.element
3
+ $ = jQuery
4
+
5
+ up.specUtil = do ->
6
+
7
+ ###**
8
+ Returns whether the given element has been detached from the DOM
9
+ (or whether it was never attached).
10
+
11
+ @function up.util.isDetached
12
+ @internal
13
+ ###
14
+ isDetached = (element) ->
15
+ element = e.get(element)
16
+ # This is by far the fastest way to do this
17
+ not $.contains(document.documentElement, element)
18
+
19
+ isAttached = (element) ->
20
+ !isDetached(element)
21
+
22
+ isVisible = (element) ->
23
+ $(element).is(':visible')
24
+
25
+ isHidden = (element) ->
26
+ $(element).is(':hidden')
27
+
28
+ ###**
29
+ @function up.util.promiseTimer
30
+ @internal
31
+ ###
32
+ promiseTimer = (ms) ->
33
+ timeout = undefined
34
+ promise = new Promise (resolve, reject) ->
35
+ timeout = u.timer(ms, resolve)
36
+ promise.cancel = -> clearTimeout(timeout)
37
+ promise
38
+
39
+
40
+ isDetached: isDetached
41
+ isAttached: isAttached
42
+ isVisible: isVisible
43
+ isHidden: isHidden
44
+ promiseTimer: promiseTimer
45
+
46
+
47
+
@@ -1,3 +1,6 @@
1
+ u = up.util
2
+ $ = jQuery
3
+
1
4
  beforeEach ->
2
5
  jasmine.addMatchers
3
6
  toBeAround: (util, customEqualityTesters) ->
@@ -0,0 +1,5 @@
1
+ beforeEach ->
2
+ jasmine.addMatchers
3
+ toBeArray: (util, customEqualityTesters) ->
4
+ compare: (actual) ->
5
+ pass: up.util.isArray(actual)
@@ -1,5 +1,9 @@
1
+ u = up.util
2
+ $ = jQuery
3
+
1
4
  beforeEach ->
2
5
  jasmine.addMatchers
3
6
  toBeAttached: (util, customEqualityTesters) ->
4
- compare: (actual) ->
5
- pass: !up.util.isDetached(actual)
7
+ compare: (element) ->
8
+ element = up.element.get(element)
9
+ pass: element && up.specUtil.isAttached(element)
@@ -1,3 +1,6 @@
1
+ u = up.util
2
+ $ = jQuery
3
+
1
4
  beforeEach ->
2
5
  jasmine.addMatchers
3
6
  toBeBlank: (util, customEqualityTesters) ->