From 7642de4e424d7a1d1e5d4b93fcdf2f15ff0e8a9c Mon Sep 17 00:00:00 2001 From: Leonid Shevtsov Date: Fri, 7 Mar 2014 18:31:28 +0200 Subject: [PATCH] Updated changelog and readme for v3 release --- CHANGELOG.md | 9 +++++++++ README.markdown | 16 ++++++++++------ lib/unobtrusive_flash/version.rb | 2 +- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 38d4213..82e55b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/README.markdown b/README.markdown index 63484b3..60f9739 100644 --- a/README.markdown +++ b/README.markdown @@ -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 @@ -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`): @@ -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 diff --git a/lib/unobtrusive_flash/version.rb b/lib/unobtrusive_flash/version.rb index 8e7f31b..c3bd146 100644 --- a/lib/unobtrusive_flash/version.rb +++ b/lib/unobtrusive_flash/version.rb @@ -1,3 +1,3 @@ module UnobtrusiveFlash - VERSION = "2.1.0" + VERSION = "3.0.0" end