GithubHelp home page GithubHelp logo

patsanch / pretty_flash Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rpheath/pretty_flash

1.0 1.0 0.0 137 KB

Rails plugin: provides reusable (and pretty) flash messages.

Home Page: http://rpheath.com/posts/379-rails-plugin-for-pretty-flash-messages

License: MIT License

Ruby 100.00%

pretty_flash's Introduction

PrettyFlash

Rails plugin that provides “pretty” flash messages.

In the controller…

This plugin gives a couple of convenience methods for setting flash messages.

notice "Hooray! You did something good."
warning "Uhm, You're not allowed to do that yet."
error "Ooooops! Something went wrong."

Use those instead of the typical flash[:notice] = "Some String" (all it does is set that for you).

In the view…

Then all you have to do to display them is:

<%= display_flash_messages %>

Easy enough?

Get Started

There’s an assets folder with this plugin, that contains the images, CSS, and javascript (optional). There’s
a rake task that installs this stuff where it needs to be (inside the public/ directory).

$ rake pretty_flash:install

WARNING: this will overwrite any of the files that have the same name. So double check if you don’t want that to happen.

Also, the flash.js file located in the assets/javascripts folder is only used to fade the flash messages after so many
seconds (defaults to 25 seconds). If you want that, I’ve provide support for prototype and jquery, so just copy whichever
one you’re using into application.js and you’re all set. If you’re not using either, sorry :-)

Enjoy!

In case of multiple flashes in one page


  /* FIX FOR MULTPLE FLASHES */
	
	if($('.warning').length > 0) {
	  if($('.notice').length > 0) {
	    $(".warning").css('margin-bottom', '60px');
	  }
	}

Licensing

Copyright © 2008 Ryan Heath, released under the MIT license

pretty_flash's People

Contributors

rpheath avatar

Stargazers

Patrick Sanchez avatar

Watchers

Patrick Sanchez avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.