Skip to content

Commit

Permalink
Updated changelog and readme for v3 release
Browse files Browse the repository at this point in the history
  • Loading branch information
leonid-shevtsov committed Mar 7, 2014
1 parent 2c7a181 commit 7642de4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## 2014-03-07 3.0.0

* Moved Javascript methods to an `UnobtrusiveFlash` module. This breaks calling `$.showFlashMessage`, hence another major release [#11]
* Make sure that the flash events are invoked after a handler had a chance to bind [#10]
* Changed default alerts to never autohide [#6]
* Bootstrap handler: All conventional Rails notices are correctly styled by @conzett [#12]
* Turbolinks are supported thanks to @yoyos [#13]
* Fixes to cookie nuking by @asaletnik [#7]

## 2013-12-21 2.1.0

* Changed message escaping logic to use the Rails html_safe conventions (Possibly breaking change)
Expand Down
16 changes: 10 additions & 6 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Ever got tired of writing custom code to handle flash messages passed in AJAX re
Here comes the solution.

`unobtrusive_flash` takes your flash messages for the backend and automagically passes them to the frontend via
HTTP cookies. This works with both regular page loads and AJAX requests, does not tamper with the page body and requires
HTTP cookies. This works with both **regular page loads**, **jQuery AJAX requests**, and **turbolinks** (from v3), does not tamper with the page body and requires
about 3 extra lines of code in your app - how's that for unobtrusive?

You can pass up to 4K of text into flash this way, and you don't need to worry about cookie size since they are
Expand All @@ -25,14 +25,14 @@ Tested in:

## Requirements

* Rails 3
* Rails >=3
* jQuery (tested with v1.10)

## Usage

1. Add the `unobtrusive_flash` gem to your Gemfile.

gem 'unobtrusive_flash', '~>2'
gem 'unobtrusive_flash', '>=3'

2. Add the following to the controllers that generate flash messages (or better, to the `ApplicationController`):

Expand Down Expand Up @@ -66,16 +66,20 @@ Unobtrusive Flash triggers jQuery events when flash is received. If you want to

$(window).bind('rails:flash', flashHandler);


## Using UnobtrusiveFlash with a frontend framework that doesn't use jQuery for AJAX

Call `UnobtrusiveFlash.showFlashFromCookies()` in your Javascript after a completed request.

## Bonus: show 'flash messages' from the front-end

Both Bootstrap and non-Bootstrap versions contain a function to display flash messages:

// Shown for 5 seconds (default)
$.showFlashMessage('Hello World', {type: 'notice'})
UnobtrusiveFlash.showFlashMessage('Hello World', {type: 'notice'})
// Shown forever
$.showFlashMessage('Error', {type: 'error', timeout: 0})
UnobtrusiveFlash.showFlashMessage('Error', {type: 'error', timeout: 0})

* * *

© 2010-2013 Leonid Shevtsov, released under the MIT license
© 2010-2014 Leonid Shevtsov, released under the MIT license
2 changes: 1 addition & 1 deletion lib/unobtrusive_flash/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module UnobtrusiveFlash
VERSION = "2.1.0"
VERSION = "3.0.0"
end

0 comments on commit 7642de4

Please sign in to comment.