unpoly-rails 0.54.0 → 0.54.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of unpoly-rails might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/Rakefile +19 -0
- data/dist/unpoly.js +380 -390
- data/dist/unpoly.min.js +3 -4
- data/lib/assets/javascripts/unpoly/{browser.coffee → browser.coffee.erb} +20 -20
- data/lib/assets/javascripts/unpoly/{bus.coffee → bus.coffee.erb} +17 -17
- data/lib/assets/javascripts/unpoly/classes/cache.coffee +2 -2
- data/lib/assets/javascripts/unpoly/classes/extract_plan.coffee +1 -1
- data/lib/assets/javascripts/unpoly/classes/motion_tracker.coffee +3 -3
- data/lib/assets/javascripts/unpoly/classes/request.coffee +9 -9
- data/lib/assets/javascripts/unpoly/classes/response.coffee +11 -11
- data/lib/assets/javascripts/unpoly/{dom.coffee → dom.coffee.erb} +18 -18
- data/lib/assets/javascripts/unpoly/feedback.coffee +8 -8
- data/lib/assets/javascripts/unpoly/{form.coffee → form.coffee.erb} +20 -20
- data/lib/assets/javascripts/unpoly/history.coffee +12 -12
- data/lib/assets/javascripts/unpoly/{layout.coffee → layout.coffee.erb} +23 -23
- data/lib/assets/javascripts/unpoly/{link.coffee → link.coffee.erb} +18 -18
- data/lib/assets/javascripts/unpoly/log.coffee +9 -9
- data/lib/assets/javascripts/unpoly/{modal.coffee → modal.coffee.erb} +22 -22
- data/lib/assets/javascripts/unpoly/motion.coffee +14 -14
- data/lib/assets/javascripts/unpoly/namespace.coffee.erb +1 -1
- data/lib/assets/javascripts/unpoly/{popup.coffee → popup.coffee.erb} +15 -15
- data/lib/assets/javascripts/unpoly/protocol.coffee +6 -6
- data/lib/assets/javascripts/unpoly/proxy.coffee +20 -20
- data/lib/assets/javascripts/unpoly/radio.coffee +4 -4
- data/lib/assets/javascripts/unpoly/rails.coffee +1 -1
- data/lib/assets/javascripts/unpoly/syntax.coffee +10 -10
- data/lib/assets/javascripts/unpoly/toast.coffee +1 -1
- data/lib/assets/javascripts/unpoly/tooltip.coffee +7 -7
- data/lib/assets/javascripts/unpoly/util.coffee +107 -107
- data/lib/unpoly/rails/version.rb +1 -1
- data/package.json +1 -1
- data/spec_app/Gemfile.lock +1 -1
- data/spec_app/config/application.rb +2 -0
- data/spec_app/spec/javascripts/helpers/to_have_unhandled_rejections.coffee +3 -0
- data/spec_app/spec/javascripts/up/form_spec.js.coffee +4 -3
- data/spec_app/spec/javascripts/up/link_spec.js.coffee +1 -1
- data/spec_app/spec/javascripts/up/proxy_spec.js.coffee +1 -1
- metadata +10 -10
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
###**
|
2
2
|
Animation
|
3
3
|
=========
|
4
4
|
|
@@ -42,7 +42,7 @@ up.motion = (($) ->
|
|
42
42
|
|
43
43
|
motionTracker = new up.MotionTracker('motion')
|
44
44
|
|
45
|
-
|
45
|
+
###**
|
46
46
|
Sets default options for animations and transitions.
|
47
47
|
|
48
48
|
@property up.motion.config
|
@@ -77,7 +77,7 @@ up.motion = (($) ->
|
|
77
77
|
namedTransitions = u.copy(defaultNamedTransitions)
|
78
78
|
config.reset()
|
79
79
|
|
80
|
-
|
80
|
+
###**
|
81
81
|
Returns whether Unpoly will perform animations.
|
82
82
|
|
83
83
|
Set [`up.motion.config.enabled`](/up.motion.config) `false` in order to disable animations globally.
|
@@ -89,7 +89,7 @@ up.motion = (($) ->
|
|
89
89
|
isEnabled = ->
|
90
90
|
config.enabled
|
91
91
|
|
92
|
-
|
92
|
+
###**
|
93
93
|
Applies the given animation to the given element.
|
94
94
|
|
95
95
|
\#\#\# Example
|
@@ -190,7 +190,7 @@ up.motion = (($) ->
|
|
190
190
|
# Signal that the animation is already done.
|
191
191
|
Promise.resolve()
|
192
192
|
|
193
|
-
|
193
|
+
###**
|
194
194
|
Animates the given element's CSS properties using CSS transitions.
|
195
195
|
|
196
196
|
If the element is already being animated, the previous animation
|
@@ -295,7 +295,7 @@ up.motion = (($) ->
|
|
295
295
|
|
296
296
|
motionTracker.start($element, startCssTransition)
|
297
297
|
|
298
|
-
|
298
|
+
###**
|
299
299
|
Extracts animation-related options from the given options hash.
|
300
300
|
If `$element` is given, also inspects the element for animation-related
|
301
301
|
attributes like `up-easing` or `up-duration`.
|
@@ -317,7 +317,7 @@ up.motion = (($) ->
|
|
317
317
|
findNamedAnimation = (name) ->
|
318
318
|
namedAnimations[name] or up.fail("Unknown animation %o", name)
|
319
319
|
|
320
|
-
|
320
|
+
###**
|
321
321
|
@function withGhosts
|
322
322
|
@return {Promise}
|
323
323
|
@internal
|
@@ -381,7 +381,7 @@ up.motion = (($) ->
|
|
381
381
|
oldCopy.$bounds.remove()
|
382
382
|
newCopy.$bounds.remove()
|
383
383
|
|
384
|
-
|
384
|
+
###**
|
385
385
|
Completes [animations](/up.animate) and [transitions](/up.morph).
|
386
386
|
|
387
387
|
If called without arguments, all animations on the screen are completed.
|
@@ -401,7 +401,7 @@ up.motion = (($) ->
|
|
401
401
|
finish = (elementOrSelector) ->
|
402
402
|
motionTracker.finish(elementOrSelector)
|
403
403
|
|
404
|
-
|
404
|
+
###**
|
405
405
|
Performs an animated transition between two elements.
|
406
406
|
Transitions are implement by performing two animations in parallel,
|
407
407
|
causing one element to disappear and the other to appear.
|
@@ -515,7 +515,7 @@ up.motion = (($) ->
|
|
515
515
|
else if namedTransition = namedTransitions[object]
|
516
516
|
findTransitionFn(namedTransition)
|
517
517
|
|
518
|
-
|
518
|
+
###**
|
519
519
|
This instantly causes the side effects of a successful transition.
|
520
520
|
We use this to skip morphing for old browsers, or when the developer
|
521
521
|
decides to only animate the new element (i.e. no real ghosting or transition).
|
@@ -535,7 +535,7 @@ up.motion = (($) ->
|
|
535
535
|
# in this branch, we need to do it ourselves.
|
536
536
|
up.layout.revealOrRestoreScroll($new, scrollOptions)
|
537
537
|
|
538
|
-
|
538
|
+
###**
|
539
539
|
@internal
|
540
540
|
###
|
541
541
|
prependCopy = ($element, $viewport) ->
|
@@ -586,7 +586,7 @@ up.motion = (($) ->
|
|
586
586
|
$bounds: $bounds
|
587
587
|
moveTop: moveTop
|
588
588
|
|
589
|
-
|
589
|
+
###**
|
590
590
|
Defines a named transition.
|
591
591
|
|
592
592
|
Here is the definition of the pre-defined `cross-fade` animation:
|
@@ -622,7 +622,7 @@ up.motion = (($) ->
|
|
622
622
|
registerTransition = (name, transition) ->
|
623
623
|
namedTransitions[name] = transition
|
624
624
|
|
625
|
-
|
625
|
+
###**
|
626
626
|
Defines a named animation.
|
627
627
|
|
628
628
|
Here is the definition of the pre-defined `fade-in` animation:
|
@@ -661,7 +661,7 @@ up.motion = (($) ->
|
|
661
661
|
defaultNamedAnimations = u.copy(namedAnimations)
|
662
662
|
defaultNamedTransitions = u.copy(namedTransitions)
|
663
663
|
|
664
|
-
|
664
|
+
###**
|
665
665
|
Returns whether the given animation option will cause the animation
|
666
666
|
to be skipped.
|
667
667
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
###**
|
2
2
|
Pop-up overlays
|
3
3
|
===============
|
4
4
|
|
@@ -49,7 +49,7 @@ up.popup = (($) ->
|
|
49
49
|
|
50
50
|
u = up.util
|
51
51
|
|
52
|
-
|
52
|
+
###**
|
53
53
|
Sets default options for future popups.
|
54
54
|
|
55
55
|
@property up.popup.config
|
@@ -86,7 +86,7 @@ up.popup = (($) ->
|
|
86
86
|
position: 'bottom-right'
|
87
87
|
history: false
|
88
88
|
|
89
|
-
|
89
|
+
###**
|
90
90
|
Returns the URL from which the current popup's contents were loaded.
|
91
91
|
|
92
92
|
Returns `undefined` if no popup is open.
|
@@ -97,7 +97,7 @@ up.popup = (($) ->
|
|
97
97
|
@stable
|
98
98
|
###
|
99
99
|
|
100
|
-
|
100
|
+
###**
|
101
101
|
Returns the URL of the page or modal behind the popup.
|
102
102
|
|
103
103
|
@function up.popup.coveredUrl
|
@@ -169,7 +169,7 @@ up.popup = (($) ->
|
|
169
169
|
unveilFrame = ->
|
170
170
|
state.$popup.show()
|
171
171
|
|
172
|
-
|
172
|
+
###**
|
173
173
|
Returns whether popup modal is currently open.
|
174
174
|
|
175
175
|
@function up.popup.isOpen
|
@@ -179,7 +179,7 @@ up.popup = (($) ->
|
|
179
179
|
isOpen = ->
|
180
180
|
state.phase == 'opened' || state.phase == 'opening'
|
181
181
|
|
182
|
-
|
182
|
+
###**
|
183
183
|
Attaches a popup overlay to the given element or selector.
|
184
184
|
|
185
185
|
Emits events [`up:popup:open`](/up:popup:open) and [`up:popup:opened`](/up:popup:opened).
|
@@ -277,7 +277,7 @@ up.popup = (($) ->
|
|
277
277
|
up.emit('up:popup:opened', message: 'Popup opened')#
|
278
278
|
promise
|
279
279
|
|
280
|
-
|
280
|
+
###**
|
281
281
|
This event is [emitted](/up.emit) when a popup is starting to open.
|
282
282
|
|
283
283
|
@event up:popup:open
|
@@ -286,14 +286,14 @@ up.popup = (($) ->
|
|
286
286
|
@stable
|
287
287
|
###
|
288
288
|
|
289
|
-
|
289
|
+
###**
|
290
290
|
This event is [emitted](/up.emit) when a popup has finished opening.
|
291
291
|
|
292
292
|
@event up:popup:opened
|
293
293
|
@stable
|
294
294
|
###
|
295
295
|
|
296
|
-
|
296
|
+
###**
|
297
297
|
Closes a currently opened popup overlay.
|
298
298
|
|
299
299
|
Does nothing if no popup is currently open.
|
@@ -349,7 +349,7 @@ up.popup = (($) ->
|
|
349
349
|
else
|
350
350
|
attachAsap($link, options)
|
351
351
|
|
352
|
-
|
352
|
+
###**
|
353
353
|
This event is [emitted](/up.emit) when a popup dialog
|
354
354
|
is starting to [close](/up.popup.close).
|
355
355
|
|
@@ -359,7 +359,7 @@ up.popup = (($) ->
|
|
359
359
|
@stable
|
360
360
|
###
|
361
361
|
|
362
|
-
|
362
|
+
###**
|
363
363
|
This event is [emitted](/up.emit) when a popup dialog
|
364
364
|
is done [closing](/up.popup.close).
|
365
365
|
|
@@ -372,7 +372,7 @@ up.popup = (($) ->
|
|
372
372
|
discardHistory()
|
373
373
|
closeAsap()
|
374
374
|
|
375
|
-
|
375
|
+
###**
|
376
376
|
Returns whether the given element or selector is contained
|
377
377
|
within the current popup.
|
378
378
|
|
@@ -386,7 +386,7 @@ up.popup = (($) ->
|
|
386
386
|
$element = $(elementOrSelector)
|
387
387
|
$element.closest('.up-popup').length > 0
|
388
388
|
|
389
|
-
|
389
|
+
###**
|
390
390
|
Opens this link's destination of in a popup overlay:
|
391
391
|
|
392
392
|
<a href="/decks" up-popup=".deck_list">Switch deck</a>
|
@@ -447,7 +447,7 @@ up.popup = (($) ->
|
|
447
447
|
# Close the pop-up overlay when the user presses ESC.
|
448
448
|
up.bus.onEscape(closeAsap)
|
449
449
|
|
450
|
-
|
450
|
+
###**
|
451
451
|
When this element is clicked, a currently open [popup](/up.popup) is closed.
|
452
452
|
|
453
453
|
Does nothing if no popup is currently open.
|
@@ -483,7 +483,7 @@ up.popup = (($) ->
|
|
483
483
|
# The framework is reset between tests
|
484
484
|
up.on 'up:framework:reset', reset
|
485
485
|
|
486
|
-
knife: eval(Knife
|
486
|
+
<% if ENV['JS_KNIFE'] %>knife: eval(Knife.point)<% end %>
|
487
487
|
attach: attachAsap
|
488
488
|
close: closeAsap
|
489
489
|
url: -> state.url
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
###**
|
2
2
|
Server protocol
|
3
3
|
===============
|
4
4
|
|
@@ -178,21 +178,21 @@ up.protocol = (($) ->
|
|
178
178
|
|
179
179
|
u = up.util
|
180
180
|
|
181
|
-
|
181
|
+
###**
|
182
182
|
@function up.protocol.locationFromXhr
|
183
183
|
@internal
|
184
184
|
###
|
185
185
|
locationFromXhr = (xhr) ->
|
186
186
|
xhr.getResponseHeader(config.locationHeader) || xhr.responseURL
|
187
187
|
|
188
|
-
|
188
|
+
###**
|
189
189
|
@function up.protocol.titleFromXhr
|
190
190
|
@internal
|
191
191
|
###
|
192
192
|
titleFromXhr = (xhr) ->
|
193
193
|
xhr.getResponseHeader(config.titleHeader)
|
194
194
|
|
195
|
-
|
195
|
+
###**
|
196
196
|
@function up.protocol.methodFromXhr
|
197
197
|
@internal
|
198
198
|
###
|
@@ -200,7 +200,7 @@ up.protocol = (($) ->
|
|
200
200
|
if method = xhr.getResponseHeader(config.methodHeader)
|
201
201
|
u.normalizeMethod(method)
|
202
202
|
|
203
|
-
|
203
|
+
###**
|
204
204
|
Server-side companion libraries like unpoly-rails set this cookie so we
|
205
205
|
have a way to detect the request method of the initial page load.
|
206
206
|
There is no JavaScript API for this.
|
@@ -217,7 +217,7 @@ up.protocol = (($) ->
|
|
217
217
|
# which might be much later.
|
218
218
|
up.bus.on('up:framework:booted', initialRequestMethod)
|
219
219
|
|
220
|
-
|
220
|
+
###**
|
221
221
|
Configures strings used in the optional [server protocol](/up.protocol).
|
222
222
|
|
223
223
|
@property up.protocol.config
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
###**
|
2
2
|
AJAX acceleration
|
3
3
|
=================
|
4
4
|
|
@@ -52,7 +52,7 @@ up.proxy = (($) ->
|
|
52
52
|
|
53
53
|
queuedLoaders = []
|
54
54
|
|
55
|
-
|
55
|
+
###**
|
56
56
|
@property up.proxy.config
|
57
57
|
@param {number} [config.preloadDelay=75]
|
58
58
|
The number of milliseconds to wait before [`[up-preload]`](/a-up-preload)
|
@@ -101,7 +101,7 @@ up.proxy = (($) ->
|
|
101
101
|
cachable: (request) -> up.Request.wrap(request).isCachable()
|
102
102
|
# logPrefix: 'up.proxy'
|
103
103
|
|
104
|
-
|
104
|
+
###**
|
105
105
|
Returns a cached response for the given request.
|
106
106
|
|
107
107
|
Returns `undefined` if the given request is not currently cached.
|
@@ -152,7 +152,7 @@ up.proxy = (($) ->
|
|
152
152
|
|
153
153
|
reset()
|
154
154
|
|
155
|
-
|
155
|
+
###**
|
156
156
|
Makes an AJAX request to the given URL.
|
157
157
|
|
158
158
|
\#\#\# Example
|
@@ -257,7 +257,7 @@ up.proxy = (($) ->
|
|
257
257
|
|
258
258
|
promise
|
259
259
|
|
260
|
-
|
260
|
+
###**
|
261
261
|
Makes an AJAX request to the given URL and caches the response.
|
262
262
|
|
263
263
|
The function returns a promise that fulfills with the response text.
|
@@ -310,7 +310,7 @@ up.proxy = (($) ->
|
|
310
310
|
pickResponseText = (response) -> resolve(response.text)
|
311
311
|
makeRequest(args...).then(pickResponseText, reject)
|
312
312
|
|
313
|
-
|
313
|
+
###**
|
314
314
|
Returns `true` if the proxy is not currently waiting
|
315
315
|
for a request to finish. Returns `false` otherwise.
|
316
316
|
|
@@ -322,7 +322,7 @@ up.proxy = (($) ->
|
|
322
322
|
isIdle = ->
|
323
323
|
pendingCount == 0
|
324
324
|
|
325
|
-
|
325
|
+
###**
|
326
326
|
Returns `true` if the proxy is currently waiting
|
327
327
|
for a request to finish. Returns `false` otherwise.
|
328
328
|
|
@@ -346,7 +346,7 @@ up.proxy = (($) ->
|
|
346
346
|
slowDelayTimer = u.setTimer(config.slowDelay, emission)
|
347
347
|
|
348
348
|
|
349
|
-
|
349
|
+
###**
|
350
350
|
This event is [emitted](/up.emit) when [AJAX requests](/up.request)
|
351
351
|
are taking long to finish.
|
352
352
|
|
@@ -407,7 +407,7 @@ up.proxy = (($) ->
|
|
407
407
|
up.emit('up:proxy:recover', message: 'Proxy has recovered from slow response')
|
408
408
|
slowEventEmitted = false
|
409
409
|
|
410
|
-
|
410
|
+
###**
|
411
411
|
This event is [emitted](/up.emit) when [AJAX requests](/up.request)
|
412
412
|
have [taken long to finish](/up:proxy:slow), but have finished now.
|
413
413
|
|
@@ -446,7 +446,7 @@ up.proxy = (($) ->
|
|
446
446
|
u.microtask(pokeQueue)
|
447
447
|
Promise.reject(new Error('Event up:proxy:load was prevented'))
|
448
448
|
|
449
|
-
|
449
|
+
###**
|
450
450
|
This event is [emitted](/up.emit) before an [AJAX request](/up.request)
|
451
451
|
is sent over the network.
|
452
452
|
|
@@ -479,7 +479,7 @@ up.proxy = (($) ->
|
|
479
479
|
request: response.request
|
480
480
|
response: response
|
481
481
|
|
482
|
-
|
482
|
+
###**
|
483
483
|
This event is [emitted](/up.emit) when the response to an
|
484
484
|
[AJAX request](/up.request) has been received.
|
485
485
|
|
@@ -494,7 +494,7 @@ up.proxy = (($) ->
|
|
494
494
|
@experimental
|
495
495
|
###
|
496
496
|
|
497
|
-
|
497
|
+
###**
|
498
498
|
This event is [emitted](/up.emit) when an [AJAX request](/up.request)
|
499
499
|
encounters fatal error like a timeout or loss of network connectivity.
|
500
500
|
|
@@ -510,7 +510,7 @@ up.proxy = (($) ->
|
|
510
510
|
# Don't return the promise from the loader above
|
511
511
|
return undefined
|
512
512
|
|
513
|
-
|
513
|
+
###**
|
514
514
|
Makes the proxy assume that `newRequest` has the same response as the
|
515
515
|
already cached `oldRequest`.
|
516
516
|
|
@@ -524,7 +524,7 @@ up.proxy = (($) ->
|
|
524
524
|
###
|
525
525
|
alias = cache.alias
|
526
526
|
|
527
|
-
|
527
|
+
###**
|
528
528
|
Manually stores a promise for the response to the given request.
|
529
529
|
|
530
530
|
@function up.proxy.set
|
@@ -537,7 +537,7 @@ up.proxy = (($) ->
|
|
537
537
|
###
|
538
538
|
set = cache.set
|
539
539
|
|
540
|
-
|
540
|
+
###**
|
541
541
|
Manually removes the given request from the cache.
|
542
542
|
|
543
543
|
You can also [configure](/up.proxy.config) when the proxy
|
@@ -551,7 +551,7 @@ up.proxy = (($) ->
|
|
551
551
|
###
|
552
552
|
remove = cache.remove
|
553
553
|
|
554
|
-
|
554
|
+
###**
|
555
555
|
Removes all cache entries.
|
556
556
|
|
557
557
|
Unpoly also automatically clears the cache whenever it processes
|
@@ -583,7 +583,7 @@ up.proxy = (($) ->
|
|
583
583
|
$waitingLink = undefined
|
584
584
|
cancelPreloadDelay()
|
585
585
|
|
586
|
-
|
586
|
+
###**
|
587
587
|
Preloads the given link.
|
588
588
|
|
589
589
|
When the link is clicked later, the response will already be cached,
|
@@ -606,13 +606,13 @@ up.proxy = (($) ->
|
|
606
606
|
else
|
607
607
|
Promise.reject(new Error("Won't preload unsafe link"))
|
608
608
|
|
609
|
-
|
609
|
+
###**
|
610
610
|
@internal
|
611
611
|
###
|
612
612
|
isSafeMethod = (method) ->
|
613
613
|
u.contains(config.safeMethods, method)
|
614
614
|
|
615
|
-
|
615
|
+
###**
|
616
616
|
@internal
|
617
617
|
###
|
618
618
|
wrapMethod = (method, data, appendOpts) ->
|
@@ -621,7 +621,7 @@ up.proxy = (($) ->
|
|
621
621
|
method = 'POST'
|
622
622
|
[method, data]
|
623
623
|
|
624
|
-
|
624
|
+
###**
|
625
625
|
Links with an `up-preload` attribute will silently fetch their target
|
626
626
|
when the user hovers over the click area, or when the user puts her
|
627
627
|
mouse/finger down (before releasing).
|