upjs-rails 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -45
  3. data/Rakefile +3 -0
  4. data/bower.json +6 -1
  5. data/dist/up.css +27 -4
  6. data/dist/up.js +197 -60
  7. data/dist/up.min.css +1 -1
  8. data/dist/up.min.js +1 -1
  9. data/lib/assets/javascripts/up/bus.js.coffee +16 -6
  10. data/lib/assets/javascripts/up/flow.js.coffee +30 -13
  11. data/lib/assets/javascripts/up/form.js.coffee +40 -10
  12. data/lib/assets/javascripts/up/history.js.coffee +8 -1
  13. data/lib/assets/javascripts/up/magic.js.coffee +17 -5
  14. data/lib/assets/javascripts/up/modal.js.coffee +16 -2
  15. data/lib/assets/javascripts/up/motion.js.coffee +14 -1
  16. data/lib/assets/javascripts/up/navigation.js.coffee +15 -6
  17. data/lib/assets/javascripts/up/popup.js.coffee +21 -3
  18. data/lib/assets/javascripts/up/tooltip.js.coffee +15 -1
  19. data/lib/assets/javascripts/up/util.js.coffee +24 -8
  20. data/lib/assets/stylesheets/up/tooltip.css.sass +30 -5
  21. data/lib/upjs/rails/current_location.rb +19 -0
  22. data/lib/upjs/rails/version.rb +1 -1
  23. data/lib/upjs-rails.rb +1 -4
  24. data/spec_app/Gemfile.lock +11 -11
  25. data/spec_app/app/assets/stylesheets/application.css +2 -0
  26. data/spec_app/app/assets/stylesheets/jasmine_specs.css +5 -0
  27. data/spec_app/app/views/pages/home.html.haml +8 -1
  28. data/spec_app/spec/javascripts/support/jasmine.yml +1 -0
  29. data/spec_app/spec/javascripts/up/bus_spec.js.coffee +12 -0
  30. data/spec_app/spec/javascripts/up/flow_spec.js.coffee +92 -68
  31. data/spec_app/spec/javascripts/up/form_spec.js.coffee +100 -0
  32. data/spec_app/spec/javascripts/up/history_spec.js.coffee +12 -0
  33. data/spec_app/spec/javascripts/up/link_spec.js.coffee +47 -0
  34. data/spec_app/spec/javascripts/up/magic_spec.js.coffee +49 -0
  35. data/spec_app/spec/javascripts/up/marker_spec.js.coffee +14 -12
  36. data/spec_app/spec/javascripts/up/modal_spec.js.coffee +30 -0
  37. data/spec_app/spec/javascripts/up/motion_spec.js.coffee +25 -0
  38. data/spec_app/spec/javascripts/up/navigation_spec.js.coffee +60 -24
  39. data/spec_app/spec/javascripts/up/popup_spec.js.coffee +30 -0
  40. data/spec_app/spec/javascripts/up/tooltip_spec.js.coffee +46 -0
  41. data/spec_app/spec/javascripts/up/util_spec.js.coffee +27 -25
  42. metadata +13 -3
  43. data/lib/upjs/rails/redirection.rb +0 -26
@@ -1,27 +1,63 @@
1
1
  describe 'up.navigation', ->
2
+
3
+ describe 'unobtrusive behavior', ->
2
4
 
3
- it 'marks links as .up-current iff they link to the current URL', ->
4
- spyOn(up.browser, 'url').and.returnValue('/foo')
5
- $currentLink = up.ready(affix('a[href="/foo"]'))
6
- $otherLink = up.ready(affix('a[href="/bar"]'))
7
- expect($currentLink).toHaveClass('up-current')
8
- expect($otherLink).not.toHaveClass('up-current')
5
+ it 'marks a link as .up-current iff it links to the current URL', ->
6
+ spyOn(up.browser, 'url').and.returnValue('/foo')
7
+ $currentLink = up.ready(affix('a[href="/foo"]'))
8
+ $otherLink = up.ready(affix('a[href="/bar"]'))
9
+ expect($currentLink).toHaveClass('up-current')
10
+ expect($otherLink).not.toHaveClass('up-current')
11
+
12
+ it 'marks a link as .up-current if it links to the current URL, but is missing a trailing slash', ->
13
+ $link = affix('a[href="/foo"][up-target=".main"]')
14
+ affix('.main')
15
+ jasmine.Ajax.install()
16
+ $link.click()
17
+ jasmine.Ajax.requests.mostRecent().respondWith
18
+ status: 200
19
+ contentType: 'text/html'
20
+ responseHeaders: { 'X-Up-Current-Location': '/foo/' }
21
+ responseText: '<div class="main">new-text</div>'
22
+ expect($link).toHaveClass('up-current')
9
23
 
10
- it 'changes .up-current marks as the URL changes'
11
-
12
- it 'marks clicked linked as .up-active until the request finishes', ->
13
- $link = affix('a[href="/foo"][up-target=".main"]')
14
- affix('.main')
15
- jasmine.Ajax.install()
16
- $link.click()
17
- expect($link).toHaveClass('up-active')
18
- jasmine.Ajax.requests.mostRecent().respondWith
19
- status: 200
20
- contentType: '/text/html'
21
- responseText: '<div class="main">new-text</div>'
22
- expect($link).not.toHaveClass('up-active')
23
- expect($link).toHaveClass('up-current')
24
-
25
-
26
- it 'prefers to mark an enclosing [up-follow] click area'
27
-
24
+ it 'marks a link as .up-current if it links to the current URL, but has an extra trailing slash', ->
25
+ $link = affix('a[href="/foo/"][up-target=".main"]')
26
+ affix('.main')
27
+ jasmine.Ajax.install()
28
+ $link.click()
29
+ jasmine.Ajax.requests.mostRecent().respondWith
30
+ status: 200
31
+ contentType: 'text/html'
32
+ responseHeaders: { 'X-Up-Current-Location': '/foo' }
33
+ responseText: '<div class="main">new-text</div>'
34
+ expect($link).toHaveClass('up-current')
35
+
36
+ it 'changes .up-current marks as the URL changes'
37
+
38
+ it 'marks clicked linked as .up-active until the request finishes', ->
39
+ $link = affix('a[href="/foo"][up-target=".main"]')
40
+ affix('.main')
41
+ jasmine.Ajax.install()
42
+ $link.click()
43
+ expect($link).toHaveClass('up-active')
44
+ jasmine.Ajax.requests.mostRecent().respondWith
45
+ status: 200
46
+ contentType: 'text/html'
47
+ responseText: '<div class="main">new-text</div>'
48
+ expect($link).not.toHaveClass('up-active')
49
+ expect($link).toHaveClass('up-current')
50
+
51
+ it 'prefers to mark an enclosing [up-follow] click area', ->
52
+ $area = affix('div[up-follow] a[href="/foo"][up-target=".main"]')
53
+ $link = $area.find('a')
54
+ affix('.main')
55
+ jasmine.Ajax.install()
56
+ $link.click()
57
+ expect($area).toHaveClass('up-active')
58
+ jasmine.Ajax.requests.mostRecent().respondWith
59
+ status: 200
60
+ contentType: 'text/html'
61
+ responseText: '<div class="main">new-text</div>'
62
+ expect($area).toHaveClass('up-current')
63
+
@@ -0,0 +1,30 @@
1
+ describe 'up.popup', ->
2
+
3
+ describe 'Javascript functions', ->
4
+
5
+ describe 'up.popup.defaults', ->
6
+
7
+ it 'should have tests'
8
+
9
+ describe 'up.popup.open', ->
10
+
11
+ it 'should have tests'
12
+
13
+ describe 'up.popup.close', ->
14
+
15
+ it 'should have tests'
16
+
17
+ describe 'up.popup.source', ->
18
+
19
+ it 'should have tests'
20
+
21
+ describe 'unobtrusive behavior', ->
22
+
23
+ describe 'a[up-popup]', ->
24
+
25
+ it 'should have tests'
26
+
27
+ describe '[up-close]', ->
28
+
29
+ it 'should have tests'
30
+
@@ -0,0 +1,46 @@
1
+ describe 'up.tooltip', ->
2
+
3
+ describe 'Javascript functions', ->
4
+
5
+ describe 'up.tooltip.open', ->
6
+
7
+ it 'opens a tooltop above the center of the given element', ->
8
+ $link = affix('span').text('button label')
9
+ $link.css(
10
+ position: 'absolute'
11
+ left: '200px'
12
+ top: '200px'
13
+ width: '50px'
14
+ height: '50px'
15
+ )
16
+ up.tooltip.open($link, html: 'tooltip text')
17
+ $tooltip = $('.up-tooltip')
18
+ expect($tooltip).toBeInDOM()
19
+ expect($tooltip).toHaveText('tooltip text')
20
+ tooltipBox = up.util.measure($tooltip, relative: true)
21
+ linkBox = up.util.measure($link, relative: true)
22
+ expect(tooltipBox.top).toBeCloseTo(linkBox.top - tooltipBox.height, 15)
23
+ expect(tooltipBox.left).toBeCloseTo(linkBox.left + 0.5 * (linkBox.width - tooltipBox.width), 15)
24
+
25
+ it 'allows HTML for the tooltip text'
26
+
27
+ it 'closes an existing tooltip'
28
+
29
+ describe 'with origin option', ->
30
+
31
+ it 'anchors the tooltip at a different edge of the element'
32
+
33
+ describe 'up.tooltip.close', ->
34
+
35
+ it 'should have tests'
36
+
37
+ describe 'unobtrusive behavior', ->
38
+
39
+ describe '[up-tooltip]', ->
40
+
41
+ it 'should have tests'
42
+
43
+ describe 'body', ->
44
+
45
+ it 'closes a tooltip when clicked'
46
+
@@ -1,27 +1,29 @@
1
1
  describe 'up.util', ->
2
+
3
+ describe 'Javascript functions', ->
2
4
 
3
- describe '.isBlank', ->
4
-
5
- it 'returns false for false', ->
6
- expect(up.util.isBlank(false)).toBe(false)
7
-
8
- it 'returns false for true', ->
9
- expect(up.util.isBlank(true)).toBe(false)
10
-
11
- it 'returns true for null', ->
12
- expect(up.util.isBlank(null)).toBe(true)
13
-
14
- it 'returns true for undefined', ->
15
- expect(up.util.isBlank(undefined)).toBe(true)
16
-
17
- it 'returns true for an empty String', ->
18
- expect(up.util.isBlank('')).toBe(true)
19
-
20
- it 'returns false for a String with at least one character', ->
21
- expect(up.util.isBlank('string')).toBe(false)
22
-
23
- it 'returns true for an empty array', ->
24
- expect(up.util.isBlank([])).toBe(true)
25
-
26
- it 'returns false for an array with at least one element', ->
27
- expect(up.util.isBlank(['element'])).toBe(false)
5
+ describe '.isBlank', ->
6
+
7
+ it 'returns false for false', ->
8
+ expect(up.util.isBlank(false)).toBe(false)
9
+
10
+ it 'returns false for true', ->
11
+ expect(up.util.isBlank(true)).toBe(false)
12
+
13
+ it 'returns true for null', ->
14
+ expect(up.util.isBlank(null)).toBe(true)
15
+
16
+ it 'returns true for undefined', ->
17
+ expect(up.util.isBlank(undefined)).toBe(true)
18
+
19
+ it 'returns true for an empty String', ->
20
+ expect(up.util.isBlank('')).toBe(true)
21
+
22
+ it 'returns false for a String with at least one character', ->
23
+ expect(up.util.isBlank('string')).toBe(false)
24
+
25
+ it 'returns true for an empty array', ->
26
+ expect(up.util.isBlank([])).toBe(true)
27
+
28
+ it 'returns false for an array with at least one element', ->
29
+ expect(up.util.isBlank(['element'])).toBe(false)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: upjs-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henning Koch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-05 00:00:00.000000000 Z
11
+ date: 2015-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -140,8 +140,8 @@ files:
140
140
  - lib/assets/stylesheets/up/popup.css.sass
141
141
  - lib/assets/stylesheets/up/tooltip.css.sass
142
142
  - lib/upjs-rails.rb
143
+ - lib/upjs/rails/current_location.rb
143
144
  - lib/upjs/rails/engine.rb
144
- - lib/upjs/rails/redirection.rb
145
145
  - lib/upjs/rails/request.rb
146
146
  - lib/upjs/rails/version.rb
147
147
  - spec_app/.firefox-version
@@ -158,6 +158,7 @@ files:
158
158
  - spec_app/app/assets/stylesheets/blocks/controls.css.sass
159
159
  - spec_app/app/assets/stylesheets/blocks/menu.css.sass
160
160
  - spec_app/app/assets/stylesheets/blocks/panel.css.sass
161
+ - spec_app/app/assets/stylesheets/jasmine_specs.css
161
162
  - spec_app/app/controllers/application_controller.rb
162
163
  - spec_app/app/controllers/cards_controller.rb
163
164
  - spec_app/app/controllers/concerns/.keep
@@ -224,9 +225,18 @@ files:
224
225
  - spec_app/spec/javascripts/helpers/reset_path.js.coffee
225
226
  - spec_app/spec/javascripts/helpers/reset_up.js.coffee
226
227
  - spec_app/spec/javascripts/support/jasmine.yml
228
+ - spec_app/spec/javascripts/up/bus_spec.js.coffee
227
229
  - spec_app/spec/javascripts/up/flow_spec.js.coffee
230
+ - spec_app/spec/javascripts/up/form_spec.js.coffee
231
+ - spec_app/spec/javascripts/up/history_spec.js.coffee
232
+ - spec_app/spec/javascripts/up/link_spec.js.coffee
233
+ - spec_app/spec/javascripts/up/magic_spec.js.coffee
228
234
  - spec_app/spec/javascripts/up/marker_spec.js.coffee
235
+ - spec_app/spec/javascripts/up/modal_spec.js.coffee
236
+ - spec_app/spec/javascripts/up/motion_spec.js.coffee
229
237
  - spec_app/spec/javascripts/up/navigation_spec.js.coffee
238
+ - spec_app/spec/javascripts/up/popup_spec.js.coffee
239
+ - spec_app/spec/javascripts/up/tooltip_spec.js.coffee
230
240
  - spec_app/spec/javascripts/up/util_spec.js.coffee
231
241
  - spec_app/test/controllers/.keep
232
242
  - spec_app/test/fixtures/.keep
@@ -1,26 +0,0 @@
1
- module Upjs
2
- module Rails
3
- module Redirection
4
-
5
- def redirect_to(*args)
6
- super
7
- flash[:redirected_to] = self.location if request.up?
8
- end
9
-
10
- def self.included(base)
11
- base.before_filter :extract_redirect_location
12
- end
13
-
14
- private
15
-
16
- def extract_redirect_location
17
- if location = flash[:redirected_to]
18
- headers['X-Up-Previous-Redirect-Location'] = location
19
- end
20
- end
21
-
22
- ActionController::Base.include(self)
23
-
24
- end
25
- end
26
- end