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,3 +1,7 @@
1
+ u = up.util
2
+ e = up.element
3
+ $ = jQuery
4
+
1
5
  describe 'up.motion', ->
2
6
 
3
7
  u = up.util
@@ -7,32 +11,32 @@ describe 'up.motion', ->
7
11
  describe 'up.animate', ->
8
12
 
9
13
  it 'animates the given element', (done) ->
10
- $element = affix('.element').text('content')
14
+ $element = $fixture('.element').text('content')
11
15
  up.animate($element, 'fade-in', duration: 200, easing: 'linear')
12
16
 
13
- u.setTimer 1, ->
17
+ u.timer 1, ->
14
18
  expect($element).toHaveOpacity(0.0, 0.15)
15
- u.setTimer 100, ->
19
+ u.timer 100, ->
16
20
  expect($element).toHaveOpacity(0.5, 0.3)
17
- u.setTimer 260, ->
21
+ u.timer 260, ->
18
22
  expect($element).toHaveOpacity(1.0, 0.15)
19
23
  done()
20
24
 
21
25
  it 'returns a promise that is fulfilled when the animation has completed', (done) ->
22
- $element = affix('.element').text('content')
26
+ $element = $fixture('.element').text('content')
23
27
  resolveSpy = jasmine.createSpy('resolve')
24
28
 
25
29
  promise = up.animate($element, 'fade-in', duration: 100, easing: 'linear')
26
30
  promise.then(resolveSpy)
27
31
 
28
- u.setTimer 50, ->
32
+ u.timer 50, ->
29
33
  expect(resolveSpy).not.toHaveBeenCalled()
30
- u.setTimer 50 + (timingTolerance = 120), ->
34
+ u.timer 50 + (timingTolerance = 120), ->
31
35
  expect(resolveSpy).toHaveBeenCalled()
32
36
  done()
33
37
 
34
38
  it 'cancels an existing animation on the element by instantly jumping to the last frame', asyncSpec (next) ->
35
- $element = affix('.element').text('content')
39
+ $element = $fixture('.element').text('content')
36
40
  up.animate($element, { 'font-size': '40px' }, duration: 10000, easing: 'linear')
37
41
 
38
42
  next =>
@@ -42,7 +46,7 @@ describe 'up.motion', ->
42
46
  expect($element.css('font-size')).toEqual('40px')
43
47
 
44
48
  it 'pauses an existing CSS transitions and restores it once the Unpoly animation is done', asyncSpec (next) ->
45
- $element = affix('.element').text('content').css
49
+ $element = $fixture('.element').text('content').css
46
50
  backgroundColor: 'yellow'
47
51
  fontSize: '10px'
48
52
  height: '20px'
@@ -87,32 +91,32 @@ describe 'up.motion', ->
87
91
  describe 'when up.animate() is called from inside an animation function', ->
88
92
 
89
93
  it 'animates', (done) ->
90
- $element = affix('.element').text('content')
94
+ $element = $fixture('.element').text('content')
91
95
 
92
96
  animation = ($element, options) ->
93
- u.writeInlineStyle($element, opacity: 0)
97
+ e.setStyle($element, opacity: 0)
94
98
  up.animate($element, { opacity: 1 }, options)
95
99
 
96
100
  up.animate($element, animation, duration: 300, easing: 'linear')
97
101
 
98
- u.setTimer 5, ->
102
+ u.timer 5, ->
99
103
  expect($element).toHaveOpacity(0.0, 0.25)
100
- u.setTimer 150, ->
104
+ u.timer 150, ->
101
105
  expect($element).toHaveOpacity(0.5, 0.25)
102
- u.setTimer 300, ->
106
+ u.timer 300, ->
103
107
  expect($element).toHaveOpacity(1.0, 0.25)
104
108
  done()
105
109
 
106
110
  it "finishes animations only once", (done) ->
107
- $element = affix('.element').text('content')
111
+ $element = $fixture('.element').text('content')
108
112
 
109
113
  animation = ($element, options) ->
110
- u.writeInlineStyle($element, opacity: 0)
114
+ e.setStyle($element, opacity: 0)
111
115
  up.animate($element, { opacity: 1 }, options)
112
116
 
113
117
  up.animate($element, animation, duration: 200, easing: 'linear')
114
118
 
115
- u.nextFrame =>
119
+ u.task =>
116
120
  expect(up.motion.finishCount()).toEqual(1)
117
121
  done()
118
122
 
@@ -123,12 +127,12 @@ describe 'up.motion', ->
123
127
  up.motion.config.enabled = false
124
128
 
125
129
  it "doesn't animate and directly sets the last frame instead", (done) ->
126
- $element = affix('.element').text('content')
130
+ $element = $fixture('.element').text('content')
127
131
  callback = jasmine.createSpy('animation done callback')
128
132
  animateDone = up.animate($element, { 'font-size': '40px' }, duration: 10000, easing: 'linear')
129
133
  animateDone.then(callback)
130
134
 
131
- u.setTimer 5, =>
135
+ u.timer 5, =>
132
136
  expect($element.css('font-size')).toEqual('40px')
133
137
  expect(callback).toHaveBeenCalled()
134
138
  done()
@@ -138,7 +142,7 @@ describe 'up.motion', ->
138
142
  describe "when called with a `#{noneAnimation}` animation", ->
139
143
 
140
144
  it "doesn't animate and resolves instantly", asyncSpec (next) ->
141
- $element = affix('.element').text('content')
145
+ $element = $fixture('.element').text('content')
142
146
  callback = jasmine.createSpy('animation done callback')
143
147
  animateDone = up.animate($element, noneAnimation, duration: 10000, easing: 'linear')
144
148
  animateDone.then(callback)
@@ -150,7 +154,7 @@ describe 'up.motion', ->
150
154
  describe 'when called with an element or selector', ->
151
155
 
152
156
  it 'cancels an existing animation on the given element by instantly jumping to the last frame', asyncSpec (next) ->
153
- $element = affix('.element').text('content')
157
+ $element = $fixture('.element').text('content')
154
158
  up.animate($element, { 'font-size': '40px', 'opacity': '0.5' }, duration: 30000)
155
159
 
156
160
  next =>
@@ -158,10 +162,10 @@ describe 'up.motion', ->
158
162
 
159
163
  next =>
160
164
  expect($element.css('font-size')).toEqual('40px')
161
- expect(u.opacity($element, 'opacity')).toBeAround(0.5, 0.01) # Safari sometimes has rounding errors
165
+ expect($element).toHaveOpacity(0.5, 0.01) # Safari sometimes has rounding errors
162
166
 
163
167
  it 'cancels animations on children of the given element', asyncSpec (next) ->
164
- $parent = affix('.element')
168
+ $parent = $fixture('.element')
165
169
  $child = $parent.affix('.child')
166
170
  up.animate($child, { 'font-size': '40px' }, duration: 10000)
167
171
 
@@ -172,8 +176,8 @@ describe 'up.motion', ->
172
176
  expect($child.css('font-size')).toEqual('40px')
173
177
 
174
178
  it 'does not cancel animations on other elements', asyncSpec (next) ->
175
- $element1 = affix('.element1').text('content1')
176
- $element2 = affix('.element2').text('content2')
179
+ $element1 = $fixture('.element1').text('content1')
180
+ $element2 = $fixture('.element2').text('content2')
177
181
  up.animate($element1, 'fade-in', duration: 10000)
178
182
  up.animate($element2, 'fade-in', duration: 10000)
179
183
 
@@ -185,7 +189,7 @@ describe 'up.motion', ->
185
189
  expect(Number($element2.css('opacity'))).toBeAround(0, 0.1)
186
190
 
187
191
  it 'restores CSS transitions from before the Unpoly animation', asyncSpec (next) ->
188
- $element = affix('.element').text('content')
192
+ $element = $fixture('.element').text('content')
189
193
  $element.css('transition': 'font-size 3s ease')
190
194
  oldTransitionProperty = $element.css('transition-property')
191
195
  expect(oldTransitionProperty).toBeDefined()
@@ -196,15 +200,15 @@ describe 'up.motion', ->
196
200
  up.motion.finish($element)
197
201
 
198
202
  next =>
199
- expect(u.opacity($element)).toEqual(1)
203
+ expect($element).toHaveOpacity(1)
200
204
  currentTransitionProperty = $element.css('transition-property')
201
205
  expect(currentTransitionProperty).toEqual(oldTransitionProperty)
202
206
  expect(currentTransitionProperty).toContain('font-size')
203
207
  expect(currentTransitionProperty).not.toContain('opacity')
204
208
 
205
209
  it 'cancels an existing transition on the old element by instantly jumping to the last frame', asyncSpec (next) ->
206
- $v1 = affix('.element').text('v1')
207
- $v2 = affix('.element').text('v2')
210
+ $v1 = $fixture('.element').text('v1')
211
+ $v2 = $fixture('.element').text('v2')
208
212
 
209
213
  up.morph($v1, $v2, 'cross-fade', duration: 200)
210
214
 
@@ -219,8 +223,8 @@ describe 'up.motion', ->
219
223
  expect($v2).toHaveOpacity(1.0, 0.2)
220
224
 
221
225
  it 'cancels an existing transition on the new element by instantly jumping to the last frame', asyncSpec (next) ->
222
- $v1 = affix('.element').text('v1')
223
- $v2 = affix('.element').text('v2')
226
+ $v1 = $fixture('.element').text('v1')
227
+ $v2 = $fixture('.element').text('v2')
224
228
 
225
229
  up.morph($v1, $v2, 'cross-fade', duration: 200)
226
230
 
@@ -236,7 +240,7 @@ describe 'up.motion', ->
236
240
 
237
241
 
238
242
  it 'cancels transitions on children of the given element', asyncSpec (next) ->
239
- $parent = affix('.parent')
243
+ $parent = $fixture('.parent')
240
244
  $old = $parent.affix('.old').text('old content')
241
245
  $new = $parent.affix('.new').text('new content')
242
246
 
@@ -254,8 +258,8 @@ describe 'up.motion', ->
254
258
 
255
259
 
256
260
  it 'does not leave .up-bounds elements in the DOM', asyncSpec (next) ->
257
- $old = affix('.old').text('old content')
258
- $new = affix('.new').text('new content')
261
+ $old = $fixture('.old').text('old content')
262
+ $new = $fixture('.new').text('new content')
259
263
 
260
264
  up.morph($old, $new, 'cross-fade', duration: 2000)
261
265
 
@@ -268,7 +272,7 @@ describe 'up.motion', ->
268
272
 
269
273
 
270
274
  it 'emits an up:motion:finish event on the given animating element, so custom animation functions can react to the finish request', asyncSpec (next) ->
271
- $element = affix('.element').text('element text')
275
+ $element = $fixture('.element').text('element text')
272
276
  listener = jasmine.createSpy('finish event listener')
273
277
  $element.on('up:motion:finish', listener)
274
278
 
@@ -294,69 +298,69 @@ describe 'up.motion', ->
294
298
  describe 'when called without arguments', ->
295
299
 
296
300
  it 'cancels all animations on the screen', asyncSpec (next) ->
297
- $element1 = affix('.element1').text('content1')
298
- $element2 = affix('.element2').text('content2')
301
+ $element1 = $fixture('.element1').text('content1')
302
+ $element2 = $fixture('.element2').text('content2')
299
303
 
300
304
  up.animate($element1, 'fade-in', duration: 3000)
301
305
  up.animate($element2, 'fade-in', duration: 3000)
302
306
 
303
307
  next =>
304
- expect(u.opacity($element1)).toBeAround(0.0, 0.1)
305
- expect(u.opacity($element2)).toBeAround(0.0, 0.1)
308
+ expect($element1).toHaveOpacity(0.0, 0.1)
309
+ expect($element2).toHaveOpacity(0.0, 0.1)
306
310
 
307
311
  up.motion.finish()
308
312
 
309
313
  next =>
310
314
  $element1 = $('.element1')
311
315
  $element2 = $('.element2')
312
- expect(u.opacity($element1)).toBe(1.0)
313
- expect(u.opacity($element2)).toBe(1.0)
316
+ expect($element1).toHaveOpacity(1.0)
317
+ expect($element2).toHaveOpacity(1.0)
314
318
 
315
319
  describe 'up.morph', ->
316
320
 
317
321
  it 'transitions between two element by absolutely positioning one element above the other', asyncSpec (next) ->
318
- $old = affix('.old').text('old content').css(width: '200px', width: '200px')
319
- $new = affix('.new').text('new content').css(width: '200px', width: '200px').detach()
322
+ $old = $fixture('.old').text('old content').css(width: '200px', width: '200px')
323
+ $new = $fixture('.new').text('new content').css(width: '200px', width: '200px').detach()
320
324
 
321
- oldDims = u.measure($old)
325
+ oldDims = $old[0].getBoundingClientRect()
322
326
 
323
327
  up.morph($old, $new, 'cross-fade', duration: 200, easing: 'linear')
324
328
 
325
329
  next =>
326
- expect(u.measure($old)).toEqual(oldDims)
327
- expect(u.measure($new)).toEqual(oldDims)
330
+ expect($old[0].getBoundingClientRect()).toEqual(oldDims)
331
+ expect($new[0].getBoundingClientRect()).toEqual(oldDims)
328
332
 
329
- expect(u.opacity($old)).toBeAround(1.0, 0.25)
330
- expect(u.opacity($new)).toBeAround(0.0, 0.25)
333
+ expect($old).toHaveOpacity(1.0, 0.25)
334
+ expect($new).toHaveOpacity(0.0, 0.25)
331
335
 
332
336
  next.after 100, =>
333
- expect(u.opacity($old)).toBeAround(0.5, 0.25)
334
- expect(u.opacity($new)).toBeAround(0.5, 0.25)
337
+ expect($old).toHaveOpacity(0.5, 0.25)
338
+ expect($new).toHaveOpacity(0.5, 0.25)
335
339
 
336
340
  next.after (100 + (tolerance = 110)), =>
337
- expect(u.opacity($new)).toBeAround(1.0, 0.25)
341
+ expect($new).toHaveOpacity(1.0, 0.25)
338
342
  expect($old).toBeDetached()
339
343
 
340
344
  it 'does not change the position of sibling elements (as long as the old and new elements are of equal size)', asyncSpec (next) ->
341
- $container = affix('.container')
345
+ $container = $fixture('.container')
342
346
 
343
347
  $before = $container.affix('.before').css(margin: '20px')
344
348
  $old = $container.affix('.old').text('old content').css(width: '200px', width: '200px', margin: '20px')
345
349
  $new = $container.affix('.new').text('new content').css(width: '200px', width: '200px', margin: '20px').detach()
346
350
  $after = $container.affix('.before').css(margin: '20px')
347
351
 
348
- beforeDims = u.measure($before)
349
- afterDims = u.measure($after)
352
+ beforeDims = $before[0].getBoundingClientRect()
353
+ afterDims = $after[0].getBoundingClientRect()
350
354
 
351
355
  up.morph($old, $new, 'cross-fade', duration: 30, easing: 'linear')
352
356
 
353
357
  next =>
354
- expect(u.measure($before)).toEqual(beforeDims)
355
- expect(u.measure($after)).toEqual(afterDims)
358
+ expect($before[0].getBoundingClientRect()).toEqual(beforeDims)
359
+ expect($after[0].getBoundingClientRect()).toEqual(afterDims)
356
360
 
357
361
  next.after 50, =>
358
- expect(u.measure($before)).toEqual(beforeDims)
359
- expect(u.measure($after)).toEqual(afterDims)
362
+ expect($before[0].getBoundingClientRect()).toEqual(beforeDims)
363
+ expect($after[0].getBoundingClientRect()).toEqual(afterDims)
360
364
 
361
365
  it 'transitions between two elements that are already positioned absolutely', asyncSpec (next) ->
362
366
  elementStyles =
@@ -365,25 +369,25 @@ describe 'up.motion', ->
365
369
  top: '30px'
366
370
  width: '200px'
367
371
  width: '200px'
368
- $old = affix('.old').text('old content').css(elementStyles)
369
- $new = affix('.new').text('new content').css(elementStyles).detach()
372
+ $old = $fixture('.old').text('old content').css(elementStyles)
373
+ $new = $fixture('.new').text('new content').css(elementStyles).detach()
370
374
 
371
- oldDims = u.measure($old)
375
+ oldDims = $old[0].getBoundingClientRect()
372
376
 
373
377
  up.morph($old, $new, 'cross-fade', duration: 100, easing: 'linear')
374
378
 
375
379
  next =>
376
- expect(u.measure($old)).toEqual(oldDims)
377
- expect(u.measure($new)).toEqual(oldDims)
380
+ expect($old[0].getBoundingClientRect()).toEqual(oldDims)
381
+ expect($new[0].getBoundingClientRect()).toEqual(oldDims)
378
382
 
379
383
  next.after (100 + (timingTolerance = 120)), =>
380
384
  expect($old).toBeDetached()
381
- expect(u.measure($new)).toEqual(oldDims)
385
+ expect($new[0].getBoundingClientRect()).toEqual(oldDims)
382
386
 
383
387
  it 'cancels an existing transition on the new element by instantly jumping to the last frame', asyncSpec (next) ->
384
- $v1 = affix('.element').text('v1')
385
- $v2 = affix('.element').text('v2')
386
- $v3 = affix('.element').text('v3')
388
+ $v1 = $fixture('.element').text('v1')
389
+ $v2 = $fixture('.element').text('v2')
390
+ $v3 = $fixture('.element').text('v3')
387
391
 
388
392
  up.morph($v1, $v2, 'cross-fade', duration: 200)
389
393
 
@@ -399,8 +403,8 @@ describe 'up.motion', ->
399
403
  expect($v3).toHaveOpacity(0.0, 0.2)
400
404
 
401
405
  it 'detaches the old element in the DOM', (done) ->
402
- $v1 = affix('.element').text('v1')
403
- $v2 = affix('.element').text('v2')
406
+ $v1 = $fixture('.element').text('v1')
407
+ $v2 = $fixture('.element').text('v2')
404
408
 
405
409
  morphDone = up.morph($v1, $v2, 'cross-fade', duration: 5)
406
410
 
@@ -410,53 +414,53 @@ describe 'up.motion', ->
410
414
  done()
411
415
 
412
416
  it 'does not leave .up-bounds elements in the DOM', (done) ->
413
- $v1 = affix('.element').text('v1')
414
- $v2 = affix('.element').text('v2')
417
+ $v1 = $fixture('.element').text('v1')
418
+ $v2 = $fixture('.element').text('v2')
415
419
 
416
420
  morphDone = up.morph($v1, $v2, 'cross-fade', duration: 5)
417
421
 
418
422
  morphDone.then ->
419
- expect('.up-bounds').not.toExist()
423
+ expect('.up-bounds').not.toBeAttached()
420
424
  done()
421
425
 
422
426
 
423
427
  describe 'when up.animate() is called from inside a transition function', ->
424
428
 
425
429
  it 'animates', asyncSpec (next) ->
426
- $old = affix('.old').text('old content')
427
- $new = affix('.new').text('new content').detach()
430
+ $old = $fixture('.old').text('old content')
431
+ $new = $fixture('.new').text('new content').detach()
428
432
 
429
- oldDims = u.measure($old)
433
+ oldDims = $old[0].getBoundingClientRect()
430
434
 
431
- transition = ($old, $new, options) ->
432
- up.animate($old, 'fade-out', options)
433
- up.animate($new, 'fade-in', options)
435
+ transition = (oldElement, newElement, options) ->
436
+ up.animate(oldElement, 'fade-out', options)
437
+ up.animate(newElement, 'fade-in', options)
434
438
 
435
439
  up.morph($old, $new, transition, duration: 200, easing: 'linear')
436
440
 
437
441
  next =>
438
- expect(u.measure($old)).toEqual(oldDims)
439
- expect(u.measure($new)).toEqual(oldDims)
442
+ expect($old[0].getBoundingClientRect()).toEqual(oldDims)
443
+ expect($new[0].getBoundingClientRect()).toEqual(oldDims)
440
444
 
441
- expect(u.opacity($old)).toBeAround(1.0, 0.25)
442
- expect(u.opacity($new)).toBeAround(0.0, 0.25)
445
+ expect($old).toHaveOpacity(1.0, 0.25)
446
+ expect($new).toHaveOpacity(0.0, 0.25)
443
447
 
444
448
  next.after 100, =>
445
- expect(u.opacity($old)).toBeAround(0.5, 0.25)
446
- expect(u.opacity($new)).toBeAround(0.5, 0.25)
449
+ expect($old).toHaveOpacity(0.5, 0.25)
450
+ expect($new).toHaveOpacity(0.5, 0.25)
447
451
 
448
452
  next.after (100 + (tolerance = 110)), =>
449
- expect(u.opacity($new)).toBeAround(1.0, 0.1)
453
+ expect($new).toHaveOpacity(1.0, 0.1)
450
454
  expect($old).toBeDetached()
451
455
  expect($new).toBeAttached()
452
456
 
453
457
  it 'finishes animations only once', asyncSpec (next) ->
454
- $old = affix('.old').text('old content')
455
- $new = affix('.new').text('new content').detach()
458
+ $old = $fixture('.old').text('old content')
459
+ $new = $fixture('.new').text('new content').detach()
456
460
 
457
- transition = ($old, $new, options) ->
458
- up.animate($old, 'fade-out', options)
459
- up.animate($new, 'fade-in', options)
461
+ transition = (oldElement, newElement, options) ->
462
+ up.animate(oldElement, 'fade-out', options)
463
+ up.animate(newElement, 'fade-in', options)
460
464
 
461
465
  up.morph($old, $new, transition, duration: 200, easing: 'linear')
462
466
 
@@ -466,38 +470,38 @@ describe 'up.motion', ->
466
470
  describe 'when up.morph() is called from inside a transition function', ->
467
471
 
468
472
  it 'morphs', asyncSpec (next) ->
469
- $old = affix('.old').text('old content')
470
- $new = affix('.new').text('new content').detach()
473
+ $old = $fixture('.old').text('old content')
474
+ $new = $fixture('.new').text('new content').detach()
471
475
 
472
- oldDims = u.measure($old)
476
+ oldDims = $old[0].getBoundingClientRect()
473
477
 
474
- transition = ($old, $new, options) ->
475
- up.morph($old, $new, 'cross-fade', options)
478
+ transition = (oldElement, newElement, options) ->
479
+ up.morph(oldElement, newElement, 'cross-fade', options)
476
480
 
477
481
  up.morph($old, $new, transition, duration: 400, easing: 'linear')
478
482
 
479
483
  next =>
480
- expect(u.measure($old)).toEqual(oldDims)
481
- expect(u.measure($new)).toEqual(oldDims)
484
+ expect($old[0].getBoundingClientRect()).toEqual(oldDims)
485
+ expect($new[0].getBoundingClientRect()).toEqual(oldDims)
482
486
 
483
- expect(u.opacity($old)).toBeAround(1.0, 0.25)
484
- expect(u.opacity($new)).toBeAround(0.0, 0.25)
487
+ expect($old).toHaveOpacity(1.0, 0.25)
488
+ expect($new).toHaveOpacity(0.0, 0.25)
485
489
 
486
490
  next.after 200, =>
487
- expect(u.opacity($old)).toBeAround(0.5, 0.25)
488
- expect(u.opacity($new)).toBeAround(0.5, 0.25)
491
+ expect($old).toHaveOpacity(0.5, 0.25)
492
+ expect($new).toHaveOpacity(0.5, 0.25)
489
493
 
490
494
  next.after (200 + (tolerance = 110)), =>
491
- expect(u.opacity($new)).toBeAround(1.0, 0.25)
495
+ expect($new).toHaveOpacity(1.0, 0.25)
492
496
  expect($old).toBeDetached()
493
497
  expect($new).toBeAttached()
494
498
 
495
499
  it "finishes animations only once", asyncSpec (next) ->
496
- $old = affix('.old').text('old content')
497
- $new = affix('.new').text('new content').detach()
500
+ $old = $fixture('.old').text('old content')
501
+ $new = $fixture('.new').text('new content').detach()
498
502
 
499
- transition = ($old, $new, options) ->
500
- up.morph($old, $new, 'cross-fade', options)
503
+ transition = (oldElement, newElement, options) ->
504
+ up.morph(oldElement, newElement, 'cross-fade', options)
501
505
 
502
506
  up.morph($old, $new, transition, duration: 50, easing: 'linear')
503
507
 
@@ -508,19 +512,19 @@ describe 'up.motion', ->
508
512
  describe 'with { reveal: true } option', ->
509
513
 
510
514
  it 'reveals the new element while making the old element within the same viewport appear as if it would keep its scroll position', asyncSpec (next) ->
511
- $container = affix('.container[up-viewport]').css
515
+ $container = $fixture('.container[up-viewport]').css
512
516
  'width': '200px'
513
517
  'height': '200px'
514
518
  'overflow-y': 'scroll'
515
519
  'position': 'fixed'
516
520
  'left': 0,
517
521
  'top': 0
518
- $old = affix('.old').appendTo($container).css(height: '600px')
522
+ $old = $fixture('.old').appendTo($container).css(height: '600px')
519
523
  $container.scrollTop(300)
520
524
 
521
525
  expect($container.scrollTop()).toEqual(300)
522
526
 
523
- $new = affix('.new').css(height: '600px').detach()
527
+ $new = $fixture('.new').css(height: '600px').detach()
524
528
 
525
529
  up.morph($old, $new, 'cross-fade', duration: 50, reveal: true)
526
530
 
@@ -544,8 +548,8 @@ describe 'up.motion', ->
544
548
  up.motion.config.enabled = false
545
549
 
546
550
  it "doesn't animate and detaches the old element instead", asyncSpec (next) ->
547
- $old = affix('.old').text('old content')
548
- $new = affix('.new').text('new content')
551
+ $old = $fixture('.old').text('old content')
552
+ $new = $fixture('.new').text('new content')
549
553
  up.morph($old, $new, 'cross-fade', duration: 1000)
550
554
 
551
555
  next =>
@@ -559,8 +563,8 @@ describe 'up.motion', ->
559
563
  describe "when called with a `#{JSON.stringify(noneTransition)}` transition", ->
560
564
 
561
565
  it "doesn't animate and detaches the old element instead", asyncSpec (next) ->
562
- $old = affix('.old').text('old content')
563
- $new = affix('.new').text('new content')
566
+ $old = $fixture('.old').text('old content')
567
+ $new = $fixture('.new').text('new content')
564
568
  up.morph($old, $new, noneTransition, duration: 1000)
565
569
 
566
570
  next =>