Giter VIP home page Giter VIP logo

growlyflash's Introduction

Growlyflash

The growlyflash gem turns boring ActionDispatch::Flash messages in your Rails 3 app to asynchronous Growl-like notifications with Bootstrap Alert markup.

With XHR requests it places flash hash to the X-Messages HTTP header or inline in javascript.

Based on rewritten in coffeescript Bootstrap Growl plugin� and inspired by Bootstrap Flash Messages

Installation

Add this line to your application's Gemfile:

gem 'growlyflash'

And then execute:

$ bundle

For non-XHR requests append the following before other javascripts inside <head>:

<%= growlyflash_static_notices %>

And require glowlyflash in app/assets/javascripts/application.js

//= require growlyflash/growlyflash

Customize

If you want to change default options, you can override them somewhere in your coffee/js:

$.bootstrapGrowl.defaults = $.extend on, $.bootstrapGrowl.defaults,
  # Box width (number or css-like string, etc. "auto")
  width:       250
  
  # Auto-dismiss timeout. Set it to 0 if you want to disable auto-dismiss
  delay:       4000
  
  # Spacing between boxes in stack
  spacing:     10
  
  # Appends boxes to a specific container
  target:      'body'
  
  # Show close button
  dismiss:     true
  
  # Default class suffix for alert boxes. 
  # Use the following mapping (Flash key => Bootstrap Alert)
  #   warning: null
  #   error:   "error"
  #   notice:  "info"
  #   success: "success"
  type:        null
  
  # Horizontal aligning (left, right or center)
  align:       'right'
  
  # Margin from the closest side
  alignAmount: 20
  
  # Offset from window bounds
  offset:      
    from:      'top'
    amount:    20

Insert the following if you want to close alert boxes by clicking on themselves. Also it doesn't steel focus from toggled elements like dropdowns and works fine with touch devices, so I advise to use it:

jQuery ->
  # ...
  $(document).on 'click.alert.data-api', '[data-dismiss="alert"]', (e) -> 
    e.stopPropagation()
  
  $(document).on 'touchstart click', ".bootstrap-growl", (e) -> 
    e.stopPropagation()
    $('[data-dismiss="alert"]', @).click()
    off

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

growlyflash's People

Contributors

coxy avatar estum avatar

Watchers

 avatar  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.