upjs-rails 0.14.0 → 0.14.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +8 -16
  3. data/.yardopts +1 -0
  4. data/README.md +36 -17
  5. data/README_RAILS.md +116 -0
  6. data/lib/assets/javascripts/up/bus.js.coffee +9 -2
  7. data/lib/assets/javascripts/up/flow.js.coffee +6 -5
  8. data/lib/assets/javascripts/up/form.js.coffee +3 -2
  9. data/lib/assets/javascripts/up/history.js.coffee +1 -0
  10. data/lib/assets/javascripts/up/layout.js.coffee +6 -3
  11. data/lib/assets/javascripts/up/link.js.coffee +13 -8
  12. data/lib/assets/javascripts/up/modal.js.coffee +2 -0
  13. data/lib/assets/javascripts/up/motion.js.coffee +9 -4
  14. data/lib/assets/javascripts/up/navigation.js.coffee +3 -2
  15. data/lib/assets/javascripts/up/popup.js.coffee +10 -2
  16. data/lib/assets/javascripts/up/proxy.js.coffee +2 -1
  17. data/lib/assets/javascripts/up/tooltip.js.coffee +1 -0
  18. data/lib/upjs/rails/engine.rb +1 -1
  19. data/lib/upjs/rails/inspector.rb +14 -1
  20. data/lib/upjs/rails/inspector_accessor.rb +1 -1
  21. data/lib/upjs/rails/request_echo_headers.rb +1 -1
  22. data/lib/upjs/rails/request_method_cookie.rb +1 -1
  23. data/lib/upjs/rails/version.rb +1 -1
  24. data/spec_app/Gemfile +0 -4
  25. data/spec_app/Gemfile.lock +1 -42
  26. data/spec_app/app/controllers/application_controller.rb +0 -8
  27. data/spec_app/app/controllers/test_controller.rb +5 -0
  28. data/spec_app/spec/controllers/test_controller_spec.rb +9 -0
  29. metadata +3 -21
  30. data/.rdoc_options +0 -23
  31. data/spec_app/app/controllers/cards_controller.rb +0 -51
  32. data/spec_app/app/controllers/pages_controller.rb +0 -6
  33. data/spec_app/app/models/card.rb +0 -6
  34. data/spec_app/app/models/tests.rb +0 -27
  35. data/spec_app/app/views/cards/_side.html.haml +0 -4
  36. data/spec_app/app/views/cards/index.html.haml +0 -10
  37. data/spec_app/app/views/cards/new.html.haml +0 -15
  38. data/spec_app/app/views/cards/show.html.haml +0 -11
  39. data/spec_app/app/views/pages/home.html.haml +0 -12
  40. data/spec_app/config/cucumber.yml +0 -8
  41. data/spec_app/db/migrate/20141225125143_create_card.rb +0 -9
  42. data/spec_app/features/history.feature +0 -30
  43. data/spec_app/features/navigation.feature +0 -9
  44. data/spec_app/features/step_definitions/factory_steps.rb +0 -5
  45. data/spec_app/features/step_definitions/navigation_steps.rb +0 -29
  46. data/spec_app/features/step_definitions/utility_steps.rb +0 -15
  47. data/spec_app/features/support/env.rb +0 -73
  48. data/spec_app/features/support/find_by_anything.rb +0 -19
  49. data/spec_app/features/support/paths.rb +0 -51
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fd47220f987d9bf4997383808d2242fc8a8fc316
4
- data.tar.gz: b71ce97484ee052743ea7d876cf606f5dbed3928
3
+ metadata.gz: 8d8056ae5ab5354aaa8ca90558101abf08462bc3
4
+ data.tar.gz: 40f40019a92d36bbf9b633806f37370d4267c159
5
5
  SHA512:
6
- metadata.gz: a6dac91f27712ab12d1b9720e024ac37e58cdaed57378a97d9c7a1bee9382d90c699f8156aea44e976cd9c5b0ad309d5df15a0a0fcc00c3199605f75cf82c541
7
- data.tar.gz: b9ea728672ad5dcfb5691d5f46d0b00c801724a3dd1dd0ed5e5912c00f62f3f493da867b8a05e6c413f14430a26952a2b40db69391079fd90ed1df5c3eac5838
6
+ metadata.gz: 56ccd0b74346251a971b60379c7c66b7d00beee8ed4a4e2f095f8f2ba21a2a0aeea83b402ed11d384a7d1db0ba52fc8a9f46f041e89898a381e16db264eac15a
7
+ data.tar.gz: c3a053fde7dcc0d5ef169ba786de35dcdb36fbda86918ccce04b165453a2ff0a11f32950c6d2e96ffdaadc959dc41116bbaded285ee12864b61b5924e4f65782
data/.gitignore CHANGED
@@ -1,17 +1,9 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- .idea
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- lib/bundler/man
11
- pkg
12
- rdoc
13
- spec/reports
14
- test/tmp
15
- test/version_tmp
1
+ /pkg
2
+ /.bundle
3
+ /.yardoc
4
+ /.idea
5
+ /coverage
6
+ /rdoc
16
7
  tmp
17
- dist/manifest.json
8
+ /dist/manifest.json
9
+ /doc
data/.yardopts ADDED
@@ -0,0 +1 @@
1
+ --markup=markdown --main=README_RAILS.md
data/README.md CHANGED
@@ -1,47 +1,66 @@
1
- # Up.js: Snappy UI for server-side web applications
1
+ Up.js + Rails bindings
2
+ ======================
2
3
 
3
- Up.js gives your traditional web application fast-responding views with minimal changes to your code and development style. If you require modern UX but don't want to pay the Javascript MVC complexity tax, Up.js can be a solution for you.
4
+ Up.js gives your traditional web application fast-responding views with minimal changes to your code and development style. If you require modern UX but don't want to pay the Javascript complexity tax, Up.js can be a solution for you.
4
5
 
5
- See [upjs.io](http://upjs.io) for more information and API documentation.
6
+ This repository is home both to the Up.js javascript code and its (optional) bindings for Ruby on Rails (`upjs-rails` gem).
6
7
 
7
- See [`CHANGELOG.md`](https://github.com/makandra/upjs/blob/master/CHANGELOG.md) for notable changes.
8
8
 
9
+ Getting started
10
+ ---------------
9
11
 
10
- ## Running tests
12
+ - See [upjs.io](http://upjs.io) for more information and Javascript API documentation.
13
+ - See [`CHANGELOG.md`](https://github.com/makandra/upjs/blob/master/CHANGELOG.md) for notable changes.
14
+ - See [`README_RAILS.md`](https://github.com/makandra/upjs/blob/master/README_RAILS.md) documentation of the Rails bindings.
15
+
16
+
17
+ Running tests
18
+ -------------
11
19
 
12
20
  Overview:
13
21
 
14
22
  - This currently requires Ruby
15
23
  - There's a Rails app in `spec_app`
16
- - Jasmine tests live in `spec_app/spec/javascripts`
17
- - There are also some Cucumber integration tests left in `spec_app/features`, but this is legacy code.
18
- Testing with Jasmine works so well that we want the entire test suite to become pure-JS Jasmine specs.
19
-
20
- To run Jasmine tests:
21
-
24
+ - Jasmine tests for Up.js live in `spec_app/spec/javascripts`
25
+ - RSpec tests for the `upjs-rails` gem live in `spec_app/spec/controllers`
26
+
27
+ Install dependencies for tests:
28
+
22
29
  - Install Ruby 2.1.2
30
+ - Install Bundler by running `gem install bundler`
23
31
  - `cd` into `spec_app`
24
32
  - Install dependencies by running `bundle install`
25
- - Migrate
26
- - Start the Rails server
27
- - Access `http://localhost:3000/specs`
28
33
 
34
+ To run Jasmine tests for Up.js:
35
+
36
+ - `cd` into `spec_app`
37
+ - Start the Rails server by running `rails server`
38
+ - Access `http://localhost:3000/specs` to see the Jasmine test runner
29
39
 
30
- ## Making a new release
40
+ To run RSpec tests for the `upjs-rails` gem:
41
+
42
+ - `cd` into `spec_app`
43
+ - Run `rspec`
44
+
45
+
46
+ Making a new release
47
+ --------------------
31
48
 
32
49
  We are currently feeding three release channels:
33
50
 
34
51
  - Manual download from Github
35
- - Bower
52
+ - Bower (this also fetches from Github)
36
53
  - Rubygems (as the `upjs-rails` gem)
37
54
 
55
+ We always release to all channel simultaneously.
56
+
38
57
  To make a new release:
39
58
 
40
59
  - Edit `lib/upjs/rails/version.rb` and bump the version number. Use [semantic versioning](http://semver.org/).
41
60
  - Add an entry to `CHANGELOG.md`
42
61
  - Commit and push the version bump and `CHANGELOG.md`
43
62
  - From the project root, type `rake assets:compile`. This will output minified JS and CSS files to the `dist` folder.
44
- - Commit and push the generated files
63
+ - Commit and push the generated files in `dist`
45
64
  - From the project root, type `rake release`. This will publish a new gem version to Rubygems.org.
46
65
  It will also push a tag for this version, which Bower requires for its own versioning scheme.
47
66
 
data/README_RAILS.md ADDED
@@ -0,0 +1,116 @@
1
+ upjs-rails: Ruby on Rails bindings for Up.js
2
+ ============================================
3
+
4
+ [Up.js](http://upjs.io) is a backend-agnostic progressive enhancement framework. `upjs-rails` gives your [Ruby on Rails](http://rubyonrails.org/) application some convenience candy when you are using Up.js in your frontend.
5
+
6
+
7
+ Features
8
+ --------
9
+
10
+ The methods documented below are available in all controllers, views and helpers.
11
+
12
+ ### Detecting a fragment update
13
+
14
+ To test whether the current request is a [fragment update](http://upjs.io/up.replace):
15
+
16
+ up?
17
+
18
+ To retrieve the CSS selector that is being [updated](http://upjs.io/up.replace):
19
+
20
+ up.selector
21
+
22
+ The Up.js frontend will expect an HTML response containing an element that matches this selector. If no such element is found, an error is shown to the user. Server-side code is free to optimize its response by only returning HTML that matches this selector.
23
+
24
+ ### Pushing a document title to the client
25
+
26
+ To force Up.js to set a document title when processing the response:
27
+
28
+ up.title = 'Title from server'
29
+
30
+ This is useful when you skip rendering the `<head>` in an Up.js request.
31
+
32
+ ### Detecting an Up.js form validation
33
+
34
+ To test whether the current request is a [form validation](http://upjs.io/up-validate):
35
+
36
+ up.validate?
37
+
38
+ When detecting a validation request, the server is expected to validate (but not save) the form submission and render a new copy of the form with validation errors. A typical saving action should behave like this:
39
+
40
+ class UsersController < ApplicationController
41
+
42
+ def create
43
+ user_params = params[:user].permit(:email, :password)
44
+ @user = User.new(user_params)
45
+ if up.validate?
46
+ @user.valid? # run validations, but don't save to the database
47
+ render 'form' # render form with error messages
48
+ elsif @user.save?
49
+ sign_in @user
50
+ else
51
+ render 'form', status: :bad_request
52
+ end
53
+ end
54
+
55
+ end
56
+
57
+ ### Automatic redirect detection
58
+
59
+ `upjs-rails` installs a `before_filter` into all controllers which echoes the request's URL as a response header `X-Up-Location` and the request's
60
+ HTTP method as `X-Up-Method`.
61
+
62
+ The Up.js frontend [requires these headers to detect redirects](http://upjs.io/form-up-target#redirects), which are otherwise undetectable for an AJAX client.
63
+
64
+ ### Automatic method detection for initial page load
65
+
66
+ `upjs-rails` sets an `_up_request_method` cookie that Up.js needs to detect the request method for the initial page load.
67
+
68
+ If the initial page was loaded with a non-`GET` HTTP method, Up.js will fall back to full page loads for all actions that require `pushState`.
69
+
70
+ The reason for this is that some browsers remember the method of the initial page load and don't let the application change it, even with `pushState`. Thus, when the user reloads the page much later, an affected browser might request a `POST`, `PUT`, etc. instead of the correct method.
71
+
72
+
73
+ What you still need to do manually
74
+ ----------------------------------
75
+
76
+ ### Failed form submissions must return a non-200 status code
77
+
78
+ Up.js lets you submit forms via AJAX by using the [`form[up-target]`](http://upjs.io/form-up-target) selector or [`up.submit`](http://upjs.io/up.submit) function.
79
+
80
+ For Up.js to be able to detect a failed form submission, the form must be re-rendered with a non-200 HTTP status code. We recommend to use either 400 (bad request) or 422 (unprocessable entity).
81
+
82
+ To do so in Rails, pass a [`:status` option to `render`](http://guides.rubyonrails.org/layouts_and_rendering.html#the-status-option):
83
+
84
+ class UsersController < ApplicationController
85
+
86
+ def create
87
+ user_params = params[:user].permit(:email, :password)
88
+ @user = User.new(user_params)
89
+ if @user.save?
90
+ sign_in @user
91
+ else
92
+ render 'form', status: :bad_request
93
+ end
94
+ end
95
+
96
+ end
97
+
98
+
99
+ Development
100
+ -----------
101
+
102
+ ### Before you make a PR
103
+
104
+ Before you make a PR, please have some discussion about the proposed change by [opening an issue on Github](https://github.com/makandra/upjs/issues/new).
105
+
106
+ ### Running tests
107
+
108
+ - Install Ruby 2.1.2
109
+ - Install Bundler by running `gem install bundler`
110
+ - `cd` into `spec_app`
111
+ - Install dependencies by running `bundle install`
112
+ - Run `rspec`
113
+
114
+ ### Making a new release
115
+
116
+ New versions of `upjs-rails` are released as part of the [Up.js release process](https://github.com/makandra/upjs/blob/master/README.md#making-a-new-release).
@@ -145,7 +145,12 @@ up.bus = (($) ->
145
145
 
146
146
 
147
147
  ###*
148
- Emits an event with the given name and properties.
148
+ Emits a event with the given name and properties.
149
+
150
+ The event will be triggered as a jQuery event on `document`.
151
+
152
+ Other code can subscribe to events with that name using
153
+ [`up.on`](/up.on) or by [binding a jQuery event listener](http://api.jquery.com/on/) to `document`.
149
154
 
150
155
  \#\#\#\# Example
151
156
 
@@ -249,9 +254,11 @@ up.bus = (($) ->
249
254
 
250
255
  ###*
251
256
  Boots the Up.js framework.
257
+
252
258
  This is done automatically by including the Up.js Javascript.
253
259
 
254
- Does nothing if the current browser is [not supported](/up.browser.isSupported).
260
+ Up.js will not boot if the current browser is [not supported](/up.browser.isSupported).
261
+ This leaves you with a classic server-side application on legacy browsers.
255
262
 
256
263
  Emits the [`up:framework:boot`](/up:framework:boot) event.
257
264
 
@@ -106,6 +106,9 @@ up.flow = (($) ->
106
106
  that is being updated. The request's `X-Up-Selector` header will contain
107
107
  the CSS selector for the updating fragment.
108
108
 
109
+ If you are using the `upjs-rails` gem you can also access the selector via
110
+ `up.selector` in all controllers, views and helpers.
111
+
109
112
  \#\#\#\# Events
110
113
 
111
114
  Up.js will emit [`up:fragment:destroyed`](/up:fragment:destroyed) on the element
@@ -360,13 +363,11 @@ up.flow = (($) ->
360
363
  $element.closest(unreal).length == 0
361
364
 
362
365
  ###*
363
- Returns the first element matching the given selector.
364
-
365
- Excludes elements that also match `.up-ghost` or `.up-destroying`
366
- or that are children of elements with these selectors.
366
+ Returns the first element matching the given selector, but
367
+ ignores elements that are being [destroyed](/up.destroy) or [transitioned](/up.morph).
367
368
 
368
369
  If the given argument is already a jQuery collection (or an array
369
- of DOM elements), the first element matching these conditions
370
+ of DOM elements), the first element matching these conditions
370
371
  is returned.
371
372
 
372
373
  Returns `undefined` if no element matches these conditions.
@@ -24,6 +24,7 @@ up.form = (($) ->
24
24
  By default this looks for a `<fieldset>`, `<label>` or `<form>`
25
25
  around the validating input field, or any element with an
26
26
  `up-fieldset` attribute.
27
+ @stable
27
28
  ###
28
29
  config = u.config
29
30
  validateTargets: ['[up-fieldset]:has(&)', 'fieldset:has(&)', 'label:has(&)', 'form:has(&)']
@@ -363,13 +364,13 @@ up.form = (($) ->
363
364
 
364
365
  The programmatic variant of this is the [`up.submit`](/up.submit) function.
365
366
 
366
- \#\#\#\# Validation errors
367
+ \#\#\#\# Failed submission
367
368
 
368
369
  When the server was unable to save the form due to invalid data,
369
370
  it will usually re-render an updated copy of the form with
370
371
  validation messages.
371
372
 
372
- For Up.js to be able to pick up a validation failure,
373
+ For Up.js to be able to detect a failed form submission,,
373
374
  the form must be re-rendered with a non-200 HTTP status code.
374
375
  We recommend to use either 400 (bad request) or
375
376
  422 (unprocessable entity).
@@ -24,6 +24,7 @@ up.history = (($) ->
24
24
  @param {Boolean} [config.restoreScroll=true]
25
25
  Whether to restore the known scroll positions
26
26
  when the user goes back or forward in history.
27
+ @stable
27
28
  ###
28
29
  config = u.config
29
30
  popTargets: ['body']
@@ -38,6 +38,7 @@ up.layout = (($) ->
38
38
  to the top when the revealed element is closer to the top than `config.snap`.
39
39
  @param {Number} [config.substance]
40
40
  A number indicating how many top pixel rows of an element to [reveal](/up.reveal).
41
+ @stable
41
42
  ###
42
43
  config = u.config
43
44
  duration: 0
@@ -191,7 +192,9 @@ up.layout = (($) ->
191
192
  Many applications have a navigation bar fixed to the top or bottom,
192
193
  obstructing the view on an element.
193
194
 
194
- To make `up.aware` of these fixed elements you can either:
195
+ You can make `up.reveal` aware of these fixed elements
196
+ so it can scroll the viewport far enough so the revealed element is fully visible.
197
+ To make `up.reveal` aware fixed elements you can either:
195
198
 
196
199
  - give the element an attribute [`up-fixed="top"`](/up-fixed-top) or [`up-fixed="bottom"`](up-fixed-bottom)
197
200
  - [configure default options](/up.layout.config) for `fixedTop` or `fixedBottom`
@@ -480,7 +483,7 @@ up.layout = (($) ->
480
483
  [`up.reveal`](/up.reveal) is aware of fixed elements and will scroll
481
484
  the viewport far enough so the revealed element is fully visible.
482
485
 
483
- Example:
486
+ \#\#\#\# Example
484
487
 
485
488
  <div class="top-nav" up-fixed="top">...</div>
486
489
 
@@ -495,7 +498,7 @@ up.layout = (($) ->
495
498
  [`up.reveal`](/up.reveal) is aware of fixed elements and will scroll
496
499
  the viewport far enough so the revealed element is fully visible.
497
500
 
498
- Example:
501
+ \#\#\#\# Example
499
502
 
500
503
  <div class="bottom-nav" up-fixed="bottom">...</div>
501
504
 
@@ -100,7 +100,7 @@ up.link = (($) ->
100
100
  The URL to visit.
101
101
  @param {String} [options.target='body']
102
102
  The selector to replace.
103
- @param {Object} options
103
+ @param {Object} [options]
104
104
  See options for [`up.replace`](/up.replace)
105
105
  @stable
106
106
  ###
@@ -122,6 +122,8 @@ up.link = (($) ->
122
122
  var $link = $('a:first'); // select link with jQuery
123
123
  up.follow($link);
124
124
 
125
+ The UJS variant of this are the [`a[up-target]`](/a-up-target) and [`a[up-follow]`](/a-up-follow) selectors.
126
+
125
127
  @function up.follow
126
128
  @param {Element|jQuery|String} linkOrSelector
127
129
  An element or selector which resolves to an `<a>` tag
@@ -316,11 +318,12 @@ up.link = (($) ->
316
318
  If applied on a link, Follows this link via AJAX and replaces the
317
319
  current `<body>` element with the response's `<body>` element.
318
320
 
319
- Example:
321
+ To only update a fragment instead of the entire page, see
322
+ [`a[up-target]`](/a-up-target).
320
323
 
321
- <a href="/users" up-follow>User list</a>
324
+ \#\#\#\# Example
322
325
 
323
- To only update a fragment instead of the entire page, see [`up-target`](/up-target).
326
+ <a href="/users" up-follow>User list</a>
324
327
 
325
328
  \#\#\#\# Turn any element into a link
326
329
 
@@ -353,7 +356,12 @@ up.link = (($) ->
353
356
 
354
357
  ###*
355
358
  Add an `up-expand` class to any element that contains a link
356
- in order to enlarge the link's click area:
359
+ in order to enlarge the link's click area.
360
+
361
+ `up-expand` honors all the UJS behavior in expanded links
362
+ ([`up-target`](/up-target), [`up-instant`](/up-instant), [`up-preload`](/up-preload), etc.).
363
+
364
+ \#\#\#\# Example
357
365
 
358
366
  <div class="notification" up-expand>
359
367
  Record was saved!
@@ -363,9 +371,6 @@ up.link = (($) ->
363
371
  In the example above, clicking anywhere within `.notification` element
364
372
  would [follow](/up.follow) the *Close* link.
365
373
 
366
- `up-expand` honors all the UJS behavior in expanded links
367
- (`up-target`, `up-instant`, `up-preload`, etc.).
368
-
369
374
  @selector [up-expand]
370
375
  @stable
371
376
  ###
@@ -93,6 +93,7 @@ up.modal = (($) ->
93
93
  @param {String} [config.closeAnimation='fade-out']
94
94
  The animation used to close the modal. The animation will be applied
95
95
  to both the dialog box and the overlay dimming the page.
96
+ @stable
96
97
  ###
97
98
  config = u.config
98
99
  maxWidth: null
@@ -331,6 +332,7 @@ up.modal = (($) ->
331
332
 
332
333
  ###*
333
334
  Closes a currently opened modal overlay.
335
+
334
336
  Does nothing if no modal is currently open.
335
337
 
336
338
  Emits events [`up:modal:close`](/up:modal:close) and [`up:modal:closed`](/up:modal:closed).
@@ -45,6 +45,7 @@ up.motion = (($) ->
45
45
  @param {Number} [config.duration=300]
46
46
  @param {Number} [config.delay=0]
47
47
  @param {String} [config.easing='ease']
48
+ @stable
48
49
  ###
49
50
  config = u.config
50
51
  duration: 300
@@ -57,7 +58,9 @@ up.motion = (($) ->
57
58
  config.reset()
58
59
 
59
60
  ###*
60
- Applies the given animation to the given element:
61
+ Applies the given animation to the given element.
62
+
63
+ \#\#\#\# Example
61
64
 
62
65
  up.animate('.warning', 'fade-in');
63
66
 
@@ -109,6 +112,7 @@ up.motion = (($) ->
109
112
  The element to animate.
110
113
  @param {String|Function|Object} animation
111
114
  Can either be:
115
+
112
116
  - The animation's name
113
117
  - A function performing the animation
114
118
  - An object of CSS attributes describing the last frame of the animation
@@ -220,9 +224,10 @@ up.motion = (($) ->
220
224
  promise
221
225
 
222
226
  ###*
223
- Completes all animations and transitions for the given element
224
- by jumping to the last animation frame instantly. All callbacks chained to
225
- the original animation's promise will be called.
227
+ Completes all [animations](/up.animate) and [transitions](/up.morph)
228
+ for the given element by jumping to the last animation frame instantly.
229
+
230
+ All callbacks chained to the original animation's promise will be called.
226
231
 
227
232
  Does nothing if the given element is not currently animating.
228
233
 
@@ -21,6 +21,7 @@ up.navigation = (($) ->
21
21
  @property up.navigation.config
22
22
  @param {Number} [config.currentClasses]
23
23
  An array of classes to set on [links that point the current location](/up-current).
24
+ @stable
24
25
  ###
25
26
  config = u.config
26
27
  currentClasses: ['up-current']
@@ -120,8 +121,8 @@ up.navigation = (($) ->
120
121
 
121
122
  <a href="/foo" up-follow up-active>Foo</a>
122
123
 
123
- Once the fragment is loaded the browser's location bar is updated
124
- to `http://yourhost/foo` via [`history.pushState`](https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Manipulating_the_browser_history#Adding_and_modifying_history_entries):
124
+ Once the link destination has loaded and rendered, the `up-active` class
125
+ is removed and the [`up-current`](/up-current) class is added:
125
126
 
126
127
  <a href="/foo" up-follow up-current>Foo</a>
127
128
 
@@ -83,6 +83,7 @@ up.popup = (($) ->
83
83
  Defines where the popup is attached to the opening element.
84
84
 
85
85
  Valid values are `bottom-right`, `bottom-left`, `top-right` and `top-left`.
86
+ @stable
86
87
  ###
87
88
  config = u.config
88
89
  openAnimation: 'fade-in'
@@ -292,8 +293,15 @@ up.popup = (($) ->
292
293
 
293
294
  ###*
294
295
  When an element with this attribute is clicked,
295
- a currently open popup is closed.
296
-
296
+ a currently open popup is closed.
297
+
298
+ Does nothing if no popup is currently open.
299
+
300
+ To make a link that closes the current popup, but follows to
301
+ a fallback destination if no popup is open:
302
+
303
+ <a href="/fallback" up-close>Okay</a>
304
+
297
305
  @selector [up-close]
298
306
  @stable
299
307
  ###
@@ -77,6 +77,7 @@ up.proxy = (($) ->
77
77
  @param {Number} [config.busyDelay=300]
78
78
  How long the proxy waits until emitting the [`up:proxy:busy` event](/up:proxy:busy).
79
79
  Use this to prevent flickering of spinners.
80
+ @stable
80
81
  ###
81
82
  config = u.config
82
83
  busyDelay: 300
@@ -392,7 +393,7 @@ up.proxy = (($) ->
392
393
  The element whose destination should be preloaded.
393
394
  @return
394
395
  A promise that will be resolved when the request was loaded and cached
395
- @stable
396
+ @experimental
396
397
  ###
397
398
  preload = (linkOrSelector, options) ->
398
399
  $link = $(linkOrSelector)
@@ -44,6 +44,7 @@ up.tooltip = (($) ->
44
44
  The animation used to open a tooltip.
45
45
  @param {String} [config.closeAnimation='fade-out']
46
46
  The animation used to close a tooltip.
47
+ @stable
47
48
  ###
48
49
  config = u.config
49
50
  position: 'top'
@@ -1,6 +1,6 @@
1
1
  module Upjs
2
2
  module Rails
3
- class Engine < ::Rails::Engine # :nodoc:
3
+ class Engine < ::Rails::Engine
4
4
  end
5
5
  end
6
6
  end
@@ -40,7 +40,7 @@ module Upjs
40
40
  validate_name.present?
41
41
  end
42
42
 
43
- ###
43
+ ##
44
44
  # If the current form submission is a [validation](http://upjs.io/up-validate),
45
45
  # this returns the name attribute of the form field that has triggered
46
46
  # the validation.
@@ -48,6 +48,15 @@ module Upjs
48
48
  request.headers['X-Up-Validate']
49
49
  end
50
50
 
51
+ ##
52
+ # Forces Up.js to use the given string as the document title when processing
53
+ # this response.
54
+ #
55
+ # This is useful when you skip rendering the `<head>` in an Up.js request.
56
+ def title=(new_title)
57
+ response.headers['X-Up-Title'] = new_title
58
+ end
59
+
51
60
  private
52
61
 
53
62
  def request
@@ -58,6 +67,10 @@ module Upjs
58
67
  @controller.params
59
68
  end
60
69
 
70
+ def response
71
+ @controller.response
72
+ end
73
+
61
74
  end
62
75
  end
63
76
  end
@@ -6,7 +6,7 @@ module Upjs
6
6
  # for Up.js-related concerns such as "is this a page fragment update?".
7
7
  module InspectorAccessor
8
8
 
9
- def self.included(base) # :nodoc:
9
+ def self.included(base)
10
10
  base.helper_method :up, :up?
11
11
  end
12
12
 
@@ -1,7 +1,7 @@
1
1
  module Upjs
2
2
  module Rails
3
3
  ##
4
- # Installs a before_filter into all controllers which echoes the
4
+ # Installs a `before_filter` into all controllers which echoes the
5
5
  # request's URL as a response header `X-Up-Location` and the request's
6
6
  # HTTP method as `X-Up-Method`.
7
7
  #
@@ -15,7 +15,7 @@ module Upjs
15
15
 
16
16
  COOKIE_NAME = '_up_request_method'
17
17
 
18
- def self.included(base) # :nodoc:
18
+ def self.included(base)
19
19
  base.before_filter :set_up_request_method_cookie
20
20
  end
21
21
 
@@ -4,6 +4,6 @@ module Upjs
4
4
  # The current version of the upjs-rails gem.
5
5
  # This version number is also used for releases of the Up.js
6
6
  # frontend code.
7
- VERSION = '0.14.0'
7
+ VERSION = '0.14.1'
8
8
  end
9
9
  end
data/spec_app/Gemfile CHANGED
@@ -26,8 +26,4 @@ end
26
26
 
27
27
  group :test do
28
28
  gem 'rspec-rails'
29
- gem 'cucumber-rails', require: false
30
- gem 'database_cleaner'
31
- gem 'selenium-webdriver'
32
- gem 'spreewald'
33
29
  end