unpoly-rails 0.34.0 → 0.34.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 +12 -1
- data/Rakefile +1 -1
- data/dist/unpoly.js +88 -69
- data/dist/unpoly.min.js +3 -3
- data/lib/assets/javascripts/unpoly/dom.coffee +1 -1
- data/lib/assets/javascripts/unpoly/feedback.coffee +2 -1
- data/lib/assets/javascripts/unpoly/form.coffee +48 -46
- data/lib/assets/javascripts/unpoly/history.coffee +9 -5
- data/lib/assets/javascripts/unpoly/link.coffee +3 -3
- data/lib/assets/javascripts/unpoly/tooltip.coffee +13 -4
- data/lib/assets/javascripts/unpoly/util.coffee +1 -1
- data/lib/unpoly/rails/version.rb +1 -1
- data/package.json +1 -1
- data/spec_app/Gemfile.lock +1 -1
- data/spec_app/spec/javascripts/helpers/knife.js.coffee +1 -1
- data/spec_app/spec/javascripts/up/dom_spec.js.coffee +1 -1
- data/spec_app/spec/javascripts/up/form_spec.js.coffee +40 -0
- data/spec_app/spec/javascripts/up/history_spec.js.coffee +31 -3
- metadata +2 -2
@@ -49,8 +49,10 @@ up.history = (($) ->
|
|
49
49
|
previousUrl = undefined
|
50
50
|
nextPreviousUrl = undefined
|
51
51
|
|
52
|
-
normalizeUrl = (url) ->
|
53
|
-
|
52
|
+
normalizeUrl = (url, normalizeOptions) ->
|
53
|
+
normalizeOptions ||= {}
|
54
|
+
normalizeOptions.hash = true
|
55
|
+
u.normalizeUrl(url, normalizeOptions)
|
54
56
|
|
55
57
|
###*
|
56
58
|
Returns a normalized URL for the current history entry.
|
@@ -58,11 +60,12 @@ up.history = (($) ->
|
|
58
60
|
@function up.history.url
|
59
61
|
@experimental
|
60
62
|
###
|
61
|
-
currentUrl = ->
|
62
|
-
normalizeUrl(up.browser.url())
|
63
|
+
currentUrl = (normalizeOptions) ->
|
64
|
+
normalizeUrl(up.browser.url(), normalizeOptions)
|
63
65
|
|
64
66
|
isCurrentUrl = (url) ->
|
65
|
-
|
67
|
+
normalizeOptions = { stripTrailingSlash: true }
|
68
|
+
normalizeUrl(url, normalizeOptions) == currentUrl(normalizeOptions)
|
66
69
|
|
67
70
|
###*
|
68
71
|
Remembers the given URL so we can offer `up.history.previousUrl()`.
|
@@ -238,6 +241,7 @@ up.history = (($) ->
|
|
238
241
|
push: push
|
239
242
|
replace: replace
|
240
243
|
url: currentUrl
|
244
|
+
isUrl: isCurrentUrl
|
241
245
|
previousUrl: -> previousUrl
|
242
246
|
normalizeUrl: normalizeUrl
|
243
247
|
|
@@ -5,7 +5,7 @@ Linking to fragments
|
|
5
5
|
In a traditional web application, the entire page is destroyed and re-created when the
|
6
6
|
user follows a link:
|
7
7
|
|
8
|
-
{:width="
|
8
|
+
{:width="620" class="picture has_border is_sepia has_padding"}
|
9
9
|
|
10
10
|
This makes for an unfriendly experience:
|
11
11
|
|
@@ -22,7 +22,7 @@ attribute. The value of this attribute is a CSS selector that indicates which pa
|
|
22
22
|
fragment to update. The server **still renders full HTML pages**, but we only use
|
23
23
|
the targeted ragments and discard the rest:
|
24
24
|
|
25
|
-
{:width="
|
25
|
+
{:width="620" class="picture has_border is_sepia has_padding"}
|
26
26
|
|
27
27
|
With this model, following links feel smooth. All transient DOM changes outside the updated fragment are preserved.
|
28
28
|
Pages also load much faster since the DOM, CSS and Javascript environments do not need to be
|
@@ -107,7 +107,7 @@ up.link = (($) ->
|
|
107
107
|
var $link = $('a:first'); // select link with jQuery
|
108
108
|
up.follow($link);
|
109
109
|
|
110
|
-
The
|
110
|
+
The unobtrusive variant of this are the [`a[up-target]`](/a-up-target) and [`a[up-follow]`](/a-up-follow) selectors.
|
111
111
|
|
112
112
|
@function up.follow
|
113
113
|
@param {Element|jQuery|String} linkOrSelector
|
@@ -34,7 +34,7 @@ up.tooltip = (($) ->
|
|
34
34
|
u = up.util
|
35
35
|
|
36
36
|
###*
|
37
|
-
|
37
|
+
Configures defaults for future tooltips.
|
38
38
|
|
39
39
|
@property up.tooltip.config
|
40
40
|
@param {String} [config.position]
|
@@ -119,8 +119,14 @@ up.tooltip = (($) ->
|
|
119
119
|
###*
|
120
120
|
Opens a tooltip over the given element.
|
121
121
|
|
122
|
+
The unobtrusive variant of this is the [`[up-tooltip]`](/up-tooltip) selector.
|
123
|
+
|
124
|
+
\#\#\# Examples
|
125
|
+
|
126
|
+
In order to attach a tooltip to a `<span class="help">?</span>`:
|
127
|
+
|
122
128
|
up.tooltip.attach('.help', {
|
123
|
-
|
129
|
+
text: 'Enter multiple words or phrases'
|
124
130
|
});
|
125
131
|
|
126
132
|
@function up.tooltip.attach
|
@@ -139,7 +145,7 @@ up.tooltip = (($) ->
|
|
139
145
|
The position of the tooltip.
|
140
146
|
Can be `'top'`, `'right'`, `'bottom'` or `'left'`.
|
141
147
|
@param {String} [options.animation]
|
142
|
-
The animation to use when opening the tooltip.
|
148
|
+
The [animation](/up.motion) to use when opening the tooltip.
|
143
149
|
@return {Promise}
|
144
150
|
A promise that will be resolved when the tooltip's opening animation has finished.
|
145
151
|
@stable
|
@@ -171,6 +177,7 @@ up.tooltip = (($) ->
|
|
171
177
|
|
172
178
|
###*
|
173
179
|
Closes a currently shown tooltip.
|
180
|
+
|
174
181
|
Does nothing if no tooltip is currently shown.
|
175
182
|
|
176
183
|
@function up.tooltip.close
|
@@ -208,7 +215,9 @@ up.tooltip = (($) ->
|
|
208
215
|
state.phase == 'opening' || state.phase == 'opened'
|
209
216
|
|
210
217
|
###*
|
211
|
-
Displays a tooltip with text content when hovering the mouse over this element
|
218
|
+
Displays a tooltip with text content when hovering the mouse over this element.
|
219
|
+
|
220
|
+
\#\#\# Example
|
212
221
|
|
213
222
|
<a href="/decks" up-tooltip="Show all decks">Decks</a>
|
214
223
|
|
@@ -71,7 +71,7 @@ up.util = (($) ->
|
|
71
71
|
# We have seen this in IE11 and W3Schools claims it happens in IE9 or earlier
|
72
72
|
# http://www.w3schools.com/jsref/prop_anchor_pathname.asp
|
73
73
|
pathname = "/#{pathname}" unless pathname[0] == '/'
|
74
|
-
pathname = pathname.replace(/\/$/, '')
|
74
|
+
pathname = pathname.replace(/\/$/, '') if options?.stripTrailingSlash == true
|
75
75
|
normalized += pathname
|
76
76
|
normalized += anchor.hash if options?.hash == true
|
77
77
|
normalized += anchor.search unless options?.search == false
|
data/lib/unpoly/rails/version.rb
CHANGED
data/package.json
CHANGED
data/spec_app/Gemfile.lock
CHANGED
@@ -971,7 +971,7 @@ describe 'up.dom', ->
|
|
971
971
|
promise = up.extract('.element', '<div class="element">version 2</div>', transition: 'cross-fade', duration: 30)
|
972
972
|
promise.then(resolution)
|
973
973
|
expect(resolution).not.toHaveBeenCalled()
|
974
|
-
u.setTimer
|
974
|
+
u.setTimer 80, ->
|
975
975
|
expect(resolution).toHaveBeenCalled()
|
976
976
|
done()
|
977
977
|
|
@@ -703,3 +703,43 @@ describe 'up.form', ->
|
|
703
703
|
expect($target).toBeVisible()
|
704
704
|
@$textInput.val('bar').change()
|
705
705
|
expect($target).toBeHidden()
|
706
|
+
|
707
|
+
describe 'when an [up-show-for] element is dynamically inserted later', ->
|
708
|
+
|
709
|
+
it "shows the element iff it matches the [up-switch] control's value", ->
|
710
|
+
$select = affix('select[up-switch=".target"]')
|
711
|
+
$select.affix('option[value="foo"]').text('Foo')
|
712
|
+
$select.affix('option[value="bar"]').text('Bar')
|
713
|
+
$select.val('foo')
|
714
|
+
up.hello($select)
|
715
|
+
|
716
|
+
# New target enters the DOM after [up-switch] has been compiled
|
717
|
+
$target = affix('.target[up-show-for="bar"]')
|
718
|
+
up.hello($target)
|
719
|
+
|
720
|
+
expect($target).toBeHidden()
|
721
|
+
|
722
|
+
# Check that the new element will notify subsequent changes
|
723
|
+
$select.val('bar').change()
|
724
|
+
expect($target).toBeVisible()
|
725
|
+
|
726
|
+
it "doesn't re-switch targets that were part of the original compile run", ->
|
727
|
+
$container = affix('.container')
|
728
|
+
|
729
|
+
$select = $container.affix('select[up-switch=".target"]')
|
730
|
+
$select.affix('option[value="foo"]').text('Foo')
|
731
|
+
$select.affix('option[value="bar"]').text('Bar')
|
732
|
+
$select.val('foo')
|
733
|
+
$existingTarget = $container.affix('.target.existing[up-show-for="bar"]')
|
734
|
+
|
735
|
+
switchTargetSpy = up.form.knife.mock('switchTarget').and.callThrough()
|
736
|
+
|
737
|
+
up.hello($container)
|
738
|
+
|
739
|
+
# New target enters the DOM after [up-switch] has been compiled
|
740
|
+
$lateTarget = $container.affix('.target.late[up-show-for="bar"]')
|
741
|
+
up.hello($lateTarget)
|
742
|
+
|
743
|
+
expect(switchTargetSpy.calls.count()).toBe(2)
|
744
|
+
expect(switchTargetSpy.calls.argsFor(0)[0]).toEqual($existingTarget)
|
745
|
+
expect(switchTargetSpy.calls.argsFor(1)[0]).toEqual($lateTarget)
|
@@ -7,10 +7,38 @@ describe 'up.history', ->
|
|
7
7
|
describe 'up.history.replace', ->
|
8
8
|
|
9
9
|
it 'should have tests'
|
10
|
-
|
11
|
-
describe 'up.history.push', ->
|
12
10
|
|
13
|
-
|
11
|
+
describe 'up.history.url', ->
|
12
|
+
|
13
|
+
describeCapability 'canPushState', ->
|
14
|
+
|
15
|
+
it 'does not strip a trailing slash from the current URL', ->
|
16
|
+
history.replaceState?({}, 'title', '/host/path/')
|
17
|
+
expect(up.history.url()).toEndWith('/host/path/')
|
18
|
+
|
19
|
+
describe 'up.history.isUrl', ->
|
20
|
+
|
21
|
+
describeCapability 'canPushState', ->
|
22
|
+
|
23
|
+
it 'returns true if the given path is the current URL', ->
|
24
|
+
history.replaceState?({}, 'title', '/host/path/')
|
25
|
+
expect(up.history.isUrl('/host/path/')).toBe(true)
|
26
|
+
|
27
|
+
it 'returns false if the given path is not the current URL', ->
|
28
|
+
history.replaceState?({}, 'title', '/host/path/')
|
29
|
+
expect(up.history.isUrl('/host/other-path/')).toBe(false)
|
30
|
+
|
31
|
+
it 'returns true if the given full URL is the current URL', ->
|
32
|
+
history.replaceState?({}, 'title', '/host/path/')
|
33
|
+
expect(up.history.isUrl("http://#{location.host}/host/path/")).toBe(true)
|
34
|
+
|
35
|
+
it 'returns true if the given path is the current URL, but without a trailing slash', ->
|
36
|
+
history.replaceState?({}, 'title', '/host/path/')
|
37
|
+
expect(up.history.isUrl('/host/path')).toBe(true)
|
38
|
+
|
39
|
+
it 'returns true if the given path is the current URL, but with a trailing slash', ->
|
40
|
+
history.replaceState?({}, 'title', '/host/path')
|
41
|
+
expect(up.history.isUrl('/host/path/')).toBe(true)
|
14
42
|
|
15
43
|
describe 'unobtrusive behavior', ->
|
16
44
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unpoly-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.34.
|
4
|
+
version: 0.34.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henning Koch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|