unpoly-rails 0.54.0 → 0.54.1

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 (40) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -0
  3. data/Rakefile +19 -0
  4. data/dist/unpoly.js +380 -390
  5. data/dist/unpoly.min.js +3 -4
  6. data/lib/assets/javascripts/unpoly/{browser.coffee → browser.coffee.erb} +20 -20
  7. data/lib/assets/javascripts/unpoly/{bus.coffee → bus.coffee.erb} +17 -17
  8. data/lib/assets/javascripts/unpoly/classes/cache.coffee +2 -2
  9. data/lib/assets/javascripts/unpoly/classes/extract_plan.coffee +1 -1
  10. data/lib/assets/javascripts/unpoly/classes/motion_tracker.coffee +3 -3
  11. data/lib/assets/javascripts/unpoly/classes/request.coffee +9 -9
  12. data/lib/assets/javascripts/unpoly/classes/response.coffee +11 -11
  13. data/lib/assets/javascripts/unpoly/{dom.coffee → dom.coffee.erb} +18 -18
  14. data/lib/assets/javascripts/unpoly/feedback.coffee +8 -8
  15. data/lib/assets/javascripts/unpoly/{form.coffee → form.coffee.erb} +20 -20
  16. data/lib/assets/javascripts/unpoly/history.coffee +12 -12
  17. data/lib/assets/javascripts/unpoly/{layout.coffee → layout.coffee.erb} +23 -23
  18. data/lib/assets/javascripts/unpoly/{link.coffee → link.coffee.erb} +18 -18
  19. data/lib/assets/javascripts/unpoly/log.coffee +9 -9
  20. data/lib/assets/javascripts/unpoly/{modal.coffee → modal.coffee.erb} +22 -22
  21. data/lib/assets/javascripts/unpoly/motion.coffee +14 -14
  22. data/lib/assets/javascripts/unpoly/namespace.coffee.erb +1 -1
  23. data/lib/assets/javascripts/unpoly/{popup.coffee → popup.coffee.erb} +15 -15
  24. data/lib/assets/javascripts/unpoly/protocol.coffee +6 -6
  25. data/lib/assets/javascripts/unpoly/proxy.coffee +20 -20
  26. data/lib/assets/javascripts/unpoly/radio.coffee +4 -4
  27. data/lib/assets/javascripts/unpoly/rails.coffee +1 -1
  28. data/lib/assets/javascripts/unpoly/syntax.coffee +10 -10
  29. data/lib/assets/javascripts/unpoly/toast.coffee +1 -1
  30. data/lib/assets/javascripts/unpoly/tooltip.coffee +7 -7
  31. data/lib/assets/javascripts/unpoly/util.coffee +107 -107
  32. data/lib/unpoly/rails/version.rb +1 -1
  33. data/package.json +1 -1
  34. data/spec_app/Gemfile.lock +1 -1
  35. data/spec_app/config/application.rb +2 -0
  36. data/spec_app/spec/javascripts/helpers/to_have_unhandled_rejections.coffee +3 -0
  37. data/spec_app/spec/javascripts/up/form_spec.js.coffee +4 -3
  38. data/spec_app/spec/javascripts/up/link_spec.js.coffee +1 -1
  39. data/spec_app/spec/javascripts/up/proxy_spec.js.coffee +1 -1
  40. metadata +10 -10
@@ -1,4 +1,4 @@
1
- ###*
1
+ ###**
2
2
  Fragment update API
3
3
  ===================
4
4
 
@@ -15,7 +15,7 @@ up.dom = (($) ->
15
15
 
16
16
  u = up.util
17
17
 
18
- ###*
18
+ ###**
19
19
  Configures defaults for fragment insertion.
20
20
 
21
21
  @property up.dom.config
@@ -46,7 +46,7 @@ up.dom = (($) ->
46
46
  sourceUrl = u.normalizeUrl(sourceUrl) if u.isPresent(sourceUrl)
47
47
  $element.attr("up-source", sourceUrl)
48
48
 
49
- ###*
49
+ ###**
50
50
  Returns the URL the given element was retrieved from.
51
51
 
52
52
  @method up.dom.source
@@ -57,7 +57,7 @@ up.dom = (($) ->
57
57
  $element = $(selectorOrElement).closest('[up-source]')
58
58
  u.presence($element.attr("up-source")) || up.browser.url()
59
59
 
60
- ###*
60
+ ###**
61
61
  Resolves the given CSS selector (which might contain `&` references)
62
62
  to a full CSS selector without ampersands.
63
63
 
@@ -84,7 +84,7 @@ up.dom = (($) ->
84
84
  selector = u.selectorForElement(selectorOrElement)
85
85
  selector
86
86
 
87
- ###*
87
+ ###**
88
88
  Replaces elements on the current page with corresponding elements
89
89
  from a new page fetched from the server.
90
90
 
@@ -293,7 +293,7 @@ up.dom = (($) ->
293
293
  promise = promise.then(onSuccess, onFailure) unless options.preload
294
294
  promise
295
295
 
296
- ###*
296
+ ###**
297
297
  @internal
298
298
  ###
299
299
  processResponse = (isSuccess, selector, response, options) ->
@@ -333,7 +333,7 @@ up.dom = (($) ->
333
333
  shouldExtractTitle = (options) ->
334
334
  not (options.title is false || u.isString(options.title) || (options.history is false && options.title isnt true))
335
335
 
336
- ###*
336
+ ###**
337
337
  Updates a selector on the current page with the
338
338
  same selector from the given HTML string.
339
339
 
@@ -603,7 +603,7 @@ up.dom = (($) ->
603
603
  if up.bus.nobodyPrevents('up:fragment:keep', keepEventArgs)
604
604
  plan
605
605
 
606
- ###*
606
+ ###**
607
607
  Elements with an `up-keep` attribute will be persisted during
608
608
  [fragment updates](/a-up-target).
609
609
 
@@ -653,7 +653,7 @@ up.dom = (($) ->
653
653
  @stable
654
654
  ###
655
655
 
656
- ###*
656
+ ###**
657
657
  This event is [emitted](/up.emit) before an existing element is [kept](/up-keep) during
658
658
  a page update.
659
659
 
@@ -674,7 +674,7 @@ up.dom = (($) ->
674
674
  @stable
675
675
  ###
676
676
 
677
- ###*
677
+ ###**
678
678
  This event is [emitted](/up.emit) when an existing element has been [kept](/up-keep)
679
679
  during a page update.
680
680
 
@@ -692,7 +692,7 @@ up.dom = (($) ->
692
692
  @stable
693
693
  ###
694
694
 
695
- ###*
695
+ ###**
696
696
  Compiles a page fragment that has been inserted into the DOM
697
697
  by external code.
698
698
 
@@ -728,7 +728,7 @@ up.dom = (($) ->
728
728
  emitFragmentInserted($element, options)
729
729
  $element
730
730
 
731
- ###*
731
+ ###**
732
732
  When a page fragment has been [inserted or updated](/up.replace),
733
733
  this event is [emitted](/up.emit) on the fragment.
734
734
 
@@ -766,7 +766,7 @@ up.dom = (($) ->
766
766
  # as well as its ancestors
767
767
  $element.closest(unreal).length == 0
768
768
 
769
- ###*
769
+ ###**
770
770
  Returns the first element matching the given selector, but
771
771
  ignores elements that are being [destroyed](/up.destroy) or [transitioned](/up.morph).
772
772
 
@@ -834,7 +834,7 @@ up.dom = (($) ->
834
834
  matchesLayer = (selectorOrElement, layer) ->
835
835
  layerOf(selectorOrElement) == layer
836
836
 
837
- ###*
837
+ ###**
838
838
  Destroys the given element or selector.
839
839
 
840
840
  Takes care that all [`up.compiler()`](/up.compiler) destructors, if any, are called.
@@ -902,7 +902,7 @@ up.dom = (($) ->
902
902
  # Don't log destruction for elements that are either Unpoly internals or frequently destroyed
903
903
  options.log != false && !$element.is('.up-placeholder, .up-tooltip, .up-modal, .up-popup')
904
904
 
905
- ###*
905
+ ###**
906
906
  Before a page fragment is being [destroyed](/up.destroy), this
907
907
  event is [emitted](/up.emit) on the fragment.
908
908
 
@@ -915,7 +915,7 @@ up.dom = (($) ->
915
915
  @stable
916
916
  ###
917
917
 
918
- ###*
918
+ ###**
919
919
  This event is [emitted](/up.emit) right before a [destroyed](/up.destroy)
920
920
  page fragment is removed from the DOM.
921
921
 
@@ -928,7 +928,7 @@ up.dom = (($) ->
928
928
  @stable
929
929
  ###
930
930
 
931
- ###*
931
+ ###**
932
932
  Replaces the given element with a fresh copy fetched from the server.
933
933
 
934
934
  \#\#\# Example
@@ -961,7 +961,7 @@ up.dom = (($) ->
961
961
 
962
962
  up.on 'up:framework:reset', reset
963
963
 
964
- knife: eval(Knife?.point)
964
+ <% if ENV['JS_KNIFE'] %>knife: eval(Knife.point)<% end %>
965
965
  replace: replace
966
966
  reload: reload
967
967
  destroy: destroy
@@ -1,4 +1,4 @@
1
- ###*
1
+ ###**
2
2
  Navigation feedback
3
3
  ===================
4
4
 
@@ -39,7 +39,7 @@ up.feedback = (($) ->
39
39
 
40
40
  u = up.util
41
41
 
42
- ###*
42
+ ###**
43
43
  Sets default options for this module.
44
44
 
45
45
  @property up.feedback.config
@@ -121,7 +121,7 @@ up.feedback = (($) ->
121
121
  else if $section.hasClass(klass) && $section.closest('.up-destroying').length == 0
122
122
  $section.removeClass(klass)
123
123
 
124
- ###*
124
+ ###**
125
125
  @function findActionableArea
126
126
  @param {string|Element|jQuery} elementOrSelector
127
127
  @internal
@@ -133,7 +133,7 @@ up.feedback = (($) ->
133
133
  $area = u.presence($area.parent(SELECTOR_SECTION)) || $area
134
134
  $area
135
135
 
136
- ###*
136
+ ###**
137
137
  Marks the given element as currently loading, by assigning the CSS class [`up-active`](/a.up-active).
138
138
 
139
139
  This happens automatically when following links or submitting forms through the Unpoly API.
@@ -178,7 +178,7 @@ up.feedback = (($) ->
178
178
  up.warn('Expected block to return a promise, but got %o', promise)
179
179
  promise
180
180
 
181
- ###*
181
+ ###**
182
182
  Links that are currently [loading through Unpoly](/form-up-target)
183
183
  are assigned the `up-active` class automatically.
184
184
  Style `.up-active` in your CSS to improve the perceived responsiveness
@@ -206,7 +206,7 @@ up.feedback = (($) ->
206
206
  @stable
207
207
  ###
208
208
 
209
- ###*
209
+ ###**
210
210
  Forms that are currently [loading through Unpoly](/a-up-target)
211
211
  are assigned the `up-active` class automatically.
212
212
  Style `.up-active` in your CSS to improve the perceived responsiveness
@@ -237,7 +237,7 @@ up.feedback = (($) ->
237
237
  @stable
238
238
  ###
239
239
 
240
- ###*
240
+ ###**
241
241
  Marks the given element as no longer loading, by removing the CSS class [`up-active`](/a.up-active).
242
242
 
243
243
  This happens automatically when network requests initiated by the Unpoly API have completed.
@@ -252,7 +252,7 @@ up.feedback = (($) ->
252
252
  $element = findActionableArea(elementOrSelector)
253
253
  $element.removeClass(CLASS_ACTIVE)
254
254
 
255
- ###*
255
+ ###**
256
256
  Links that point to the current location are assigned
257
257
  the `up-current` class automatically.
258
258
 
@@ -1,4 +1,4 @@
1
- ###*
1
+ ###**
2
2
  Forms
3
3
  =====
4
4
 
@@ -12,7 +12,7 @@ up.form = (($) ->
12
12
 
13
13
  u = up.util
14
14
 
15
- ###*
15
+ ###**
16
16
  Sets default options for form submission and validation.
17
17
 
18
18
  @property up.form.config
@@ -40,14 +40,14 @@ up.form = (($) ->
40
40
  reset = ->
41
41
  config.reset()
42
42
 
43
- ###*
43
+ ###**
44
44
  @function up.form.fieldSelector
45
45
  @internal
46
46
  ###
47
47
  fieldSelector = ->
48
48
  u.multiSelector(config.fields)
49
49
 
50
- ###*
50
+ ###**
51
51
  Submits a form via AJAX and updates a page fragment with the response.
52
52
 
53
53
  up.submit('form.new-user', { target: '.main' })
@@ -180,7 +180,7 @@ up.form = (($) ->
180
180
  u.always promise, -> up.feedback.stop($form)
181
181
  promise
182
182
 
183
- ###*
183
+ ###**
184
184
  This event is [emitted](/up.emit) when a form is [submitted](/up.submit) through Unpoly.
185
185
 
186
186
  @event up:form:submit
@@ -191,7 +191,7 @@ up.form = (($) ->
191
191
  @stable
192
192
  ###
193
193
 
194
- ###*
194
+ ###**
195
195
  Observes form fields and runs a callback when a value changes.
196
196
 
197
197
  This is useful for observing text fields while the user is typing.
@@ -276,7 +276,7 @@ up.form = (($) ->
276
276
  callback = null
277
277
  rawCallback = u.option(callbackArg, u.presentAttr($element, 'up-observe'))
278
278
  if u.isString(rawCallback)
279
- callback = (value, $field) -> eval(rawCallback)
279
+ callback = new Function('value', '$field', rawCallback)
280
280
  else
281
281
  callback = rawCallback or up.fail('up.observe: No change callback given')
282
282
 
@@ -295,7 +295,7 @@ up.form = (($) ->
295
295
  observer.start()
296
296
  return observer.stop
297
297
 
298
- ###*
298
+ ###**
299
299
  [Observes](/up.observe) a field or form and submits the form when a value changes.
300
300
 
301
301
  Both the form and the changed field will be assigned a CSS class [`form-up-active`](/form-up-active)
@@ -331,7 +331,7 @@ up.form = (($) ->
331
331
  target = u.selectorForElement(target)
332
332
  target
333
333
 
334
- ###*
334
+ ###**
335
335
  Performs a server-side validation of a form field.
336
336
 
337
337
  `up.validate()` submits the given field's form with an additional `X-Up-Validate`
@@ -398,7 +398,7 @@ up.form = (($) ->
398
398
  values.push(meta)
399
399
  values
400
400
 
401
- ###*
401
+ ###**
402
402
  Shows or hides a target selector depending on the value.
403
403
 
404
404
  See [`input[up-switch]`](/input-up-switch) for more documentation and examples.
@@ -423,7 +423,7 @@ up.form = (($) ->
423
423
  $(targetSelector).each ->
424
424
  switchTarget($(this), fieldValues)
425
425
 
426
- ###*
426
+ ###**
427
427
  @internal
428
428
  ###
429
429
  switchTarget = (target, fieldValues) ->
@@ -444,7 +444,7 @@ up.form = (($) ->
444
444
  $target.toggle(show)
445
445
  $target.addClass('up-switched')
446
446
 
447
- ###*
447
+ ###**
448
448
  @internal
449
449
  ###
450
450
  findSwitcherForTarget = ($target) ->
@@ -457,7 +457,7 @@ up.form = (($) ->
457
457
  else
458
458
  u.fail('Could not find [up-switch] field for %o', $target.get(0))
459
459
 
460
- ###*
460
+ ###**
461
461
  Forms with an `up-target` attribute are [submitted via AJAX](/up.submit)
462
462
  instead of triggering a full page reload.
463
463
 
@@ -594,7 +594,7 @@ up.form = (($) ->
594
594
  up.bus.consumeAction(event)
595
595
  u.muteRejection submit($form)
596
596
 
597
- ###*
597
+ ###**
598
598
  When a form field with this attribute is changed, the form is validated on the server
599
599
  and is updated with validation messages.
600
600
 
@@ -742,7 +742,7 @@ up.form = (($) ->
742
742
  up.on 'change', '[up-validate]', (event, $field) ->
743
743
  u.muteRejection validate($field)
744
744
 
745
- ###*
745
+ ###**
746
746
  Show or hide elements when a `<select>` or `<input>` has a given value.
747
747
 
748
748
  \#\#\# Example: Select options
@@ -825,7 +825,7 @@ up.form = (($) ->
825
825
  up.compiler '[up-show-for]:not(.up-switched), [up-hide-for]:not(.up-switched)', ($element) ->
826
826
  switchTarget($element)
827
827
 
828
- ###*
828
+ ###**
829
829
  Observes this field and runs a callback when a value changes.
830
830
 
831
831
  This is useful for observing text fields while the user is typing.
@@ -860,7 +860,7 @@ up.form = (($) ->
860
860
  @stable
861
861
  ###
862
862
 
863
- ###*
863
+ ###**
864
864
  Observes this form and runs a callback when any field changes.
865
865
 
866
866
  This is useful for observing text fields while the user is typing.
@@ -897,7 +897,7 @@ up.form = (($) ->
897
897
  ###
898
898
  up.compiler '[up-observe]', ($formOrField) -> observe($formOrField)
899
899
 
900
- ###*
900
+ ###**
901
901
  [Observes](/up.observe) this form field and submits the form when its value changes.
902
902
 
903
903
  Both the form and the changed field will be assigned a CSS class [`up-active`](/form-up-active)
@@ -920,7 +920,7 @@ up.form = (($) ->
920
920
  @stable
921
921
  ###
922
922
 
923
- ###*
923
+ ###**
924
924
  [Observes](/up.observe) this form and submits the form when *any* field changes.
925
925
 
926
926
  Both the form and the field will be assigned a CSS class [`up-active`](/form-up-active)
@@ -946,7 +946,7 @@ up.form = (($) ->
946
946
 
947
947
  up.on 'up:framework:reset', reset
948
948
 
949
- knife: eval(Knife?.point)
949
+ <% if ENV['JS_KNIFE'] %>knife: eval(Knife.point)<% end %>
950
950
  config: config
951
951
  submit: submit
952
952
  observe: observe
@@ -1,4 +1,4 @@
1
- ###*
1
+ ###**
2
2
  History
3
3
  ========
4
4
 
@@ -12,7 +12,7 @@ up.history = (($) ->
12
12
 
13
13
  u = up.util
14
14
 
15
- ###*
15
+ ###**
16
16
  Configures behavior when the user goes back or forward in browser history.
17
17
 
18
18
  @property up.history.config
@@ -29,7 +29,7 @@ up.history = (($) ->
29
29
  popTargets: ['body']
30
30
  restoreScroll: true
31
31
 
32
- ###*
32
+ ###**
33
33
  Returns the previous URL in the browser history.
34
34
 
35
35
  Note that this will only work reliably for history changes that
@@ -52,7 +52,7 @@ up.history = (($) ->
52
52
  normalizeOptions.hash = true
53
53
  u.normalizeUrl(url, normalizeOptions)
54
54
 
55
- ###*
55
+ ###**
56
56
  Returns a normalized URL for the current history entry.
57
57
 
58
58
  @function up.history.url
@@ -65,7 +65,7 @@ up.history = (($) ->
65
65
  normalizeOptions = { stripTrailingSlash: true }
66
66
  normalizeUrl(url, normalizeOptions) == currentUrl(normalizeOptions)
67
67
 
68
- ###*
68
+ ###**
69
69
  Remembers the given URL so we can offer `up.history.previousUrl()`.
70
70
 
71
71
  @function observeNewUrl
@@ -77,7 +77,7 @@ up.history = (($) ->
77
77
  nextPreviousUrl = undefined
78
78
  nextPreviousUrl = url
79
79
 
80
- ###*
80
+ ###**
81
81
  Replaces the current history entry and updates the
82
82
  browser's location bar with the given URL.
83
83
 
@@ -96,7 +96,7 @@ up.history = (($) ->
96
96
  replace = (url) ->
97
97
  manipulate('replaceState', url)
98
98
 
99
- ###*
99
+ ###**
100
100
  Adds a new history entry and updates the browser's
101
101
  address bar with the given URL.
102
102
 
@@ -124,7 +124,7 @@ up.history = (($) ->
124
124
  else
125
125
  up.emit('up:history:muted', url: url, message: "Did not advance to #{url} (history is unavailable)")
126
126
 
127
- ###*
127
+ ###**
128
128
  This event is [emitted](/up.emit) before a new history entry is added.
129
129
 
130
130
  @event up:history:push
@@ -135,7 +135,7 @@ up.history = (($) ->
135
135
  @experimental
136
136
  ###
137
137
 
138
- ###*
138
+ ###**
139
139
  This event is [emitted](/up.emit) after a new history entry has been added.
140
140
 
141
141
  @event up:history:pushed
@@ -184,7 +184,7 @@ up.history = (($) ->
184
184
  state = event.originalEvent.state
185
185
  restoreStateOnPop(state)
186
186
 
187
- ###*
187
+ ###**
188
188
  This event is [emitted](/up.emit) before a history entry will be restored.
189
189
 
190
190
  History entries are restored when the user uses the *Back* or *Forward* button.
@@ -195,7 +195,7 @@ up.history = (($) ->
195
195
  @internal
196
196
  ###
197
197
 
198
- ###*
198
+ ###**
199
199
  This event is [emitted](/up.emit) after a history entry has been restored.
200
200
 
201
201
  History entries are restored when the user uses the *Back* or *Forward* button.
@@ -220,7 +220,7 @@ up.history = (($) ->
220
220
  # We should check in 2023 if we can remove this.
221
221
  setTimeout register, 100
222
222
 
223
- ###*
223
+ ###**
224
224
  Changes the link's destination so it points to the previous URL.
225
225
 
226
226
  Note that this will *not* call `location.back()`, but will set