Giter Club home page Giter Club logo

messagebar's Introduction

jQuery MessageBar Build Status devDependencies

A top bar for notification messages. Dismiss it by clicking the x. Works with Django, but that's optional.

Screenshot and Demo

Here is a screenshot of MessageBar being used on https://www.djangopackages.com:

Screenshot of MessageBar

To see a live demo of several MessageBars in action, see http://audreyr.github.io/messagebar/demo/.

  • They correspond to Bootstrap's default, primary, success, info, warning, and danger styles.
  • The default MessageBars are purposely plain. It's your job to change the CSS colors and font to match your site, of course.

To run the demo locally:

npm install
grunt

Usage

  1. Copy the appropriate files from dist/ into your project. For example, if you want the minified jQuery plugin version of this, copy:
  • dist/jquery.messagebar.min.css
  • dist/jquery.messagebar.min.js
  1. Include jQuery (any version will do):
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
  1. Include plugin's code:
<link href="dist/jquery.messagebar.min.css" rel="stylesheet">
<script src="dist/jquery.messagebar.min.js"></script>
  1. Put your plugin HTML on your web page:
<div class="messagebar">
    <div class="container">
      This is a notification. You can click it away if you want.
      <button type="button" class="close" data-dismiss="message">&times;</button>
    </div>
</div>
  1. Call the plugin:
$(".messagebar").messageBar({
  slide: false
});

(Note: slide: true hasn't been implemented yet. See #1 for more info. If you feel like implementing that feature, go for it and send a pull request!)

Setting Up jQuery MessageBar with Django Messages

jQuery MessageBar can easily be connected to Django's messages framework, allowing your web application to display notifications as top bars that can be clicked away.

This is similar to the notification bars used in many popular web applications, such as StackOverflow.

  1. Add this to your base template:
{% for message in messages %}
  <div class="messagebar messagebar-{% if message.tags %}{{ message.tags }}{% endif %}" id="message_{{ forloop.counter }}">
    <div class="container">
      {{ message }}
      <button type="button" class="close" data-dismiss="message">&times;</button>
    </div>
  </div>
{% endfor %}
  1. Change the names of the classes in messagebar.css to match Django's built-in message levels of:
  • debug
  • info
  • success
  • warning
  • error

See https://docs.djangoproject.com/en/dev/ref/contrib/messages/#message-tags for more info.

Once you've done this, your styles should look something like:

/* messagebar by audreyr ~ https://github.com/audreyr/messagebar */
/*! jquery.messagebar.min.css */.messagebar{font-family:Helvetica,Arial,sans-serif;font-size:14px;font-weight:700;color:#000;text-shadow:.3px .3px .3px #FFF;padding:10px 0}.messagebar-default{background-color:#c4c4c4;border-bottom:1px solid #999}.messagebar-debug{background-color:#84b3dc;border-bottom:1px solid #428BCA}.messagebar-success{background-color:#a3d7a3;border-bottom:1px solid #5CB85C}.messagebar-info{background-color:#9ed9eb;border-bottom:1px solid #5BC0DE}.messagebar-warning{background-color:#f6cd93;border-bottom:1px solid #F0AD4E}.messagebar-error{background-color:#e89996;border-bottom:1px solid #D9534F}button.close{padding:0;cursor:pointer;background:rgba(0,0,0,0);border:0;-webkit-appearance:none}.close{float:right;font-size:18px;font-weight:700;line-height:.8em;color:#000;text-shadow:0 1px 0 #FFF;opacity:.2;filter:alpha(opacity=20)}

messagebar's People

Contributors

audreyfeldroy avatar frost-nzcr4 avatar fqdn avatar

Stargazers

Casey Strouse avatar Felipe Kellermann avatar  avatar Mac Alnakari avatar Attila Bakos avatar Emil George James avatar Brian Faust avatar Omachonu Ogali avatar Subhash Ramesh avatar  avatar Mustafa Abualsaud avatar  avatar Rogerio Marques avatar Kyle Lawlor-Bagcal avatar  avatar Felix Hanspach avatar Geoff Taylor avatar Rezha Julio avatar  avatar Taylor D. Edmiston avatar Markus Zapke-Gründemann avatar Alessio Di Stasio avatar Ulrich Petri avatar Keryn Knight avatar Rolf Erik Lekang avatar Frank Wiles avatar Carol Willing avatar Trey Hunner avatar somi avatar donnie-darko avatar Konrad Rymczak avatar  avatar Silvio René avatar Douglas Soares de Andrade avatar Patrick Taylor avatar Pedro Kiefer avatar  avatar Rezha Julio avatar Christopher Semmler avatar Gilson Filho avatar Gladson avatar Jonathan Barratt avatar Tarun Chaudhry avatar Stéphane "Twidi" Angel avatar Jb avatar Stephen Marie-Rhodes avatar Masroor Naved avatar Bruno Rocha avatar Leonardo Borges Avelino avatar Daniel Roy Greenfeld avatar  avatar Pedro Coutinho avatar

Watchers

 avatar Michael R. Bernstein avatar pyzen avatar  avatar James Cloos avatar  avatar  avatar  avatar

messagebar's Issues

Implement slide in/out

When the page loads, the topbar should slide down, pushing the page down.

When the user clicks x, the topbar should slide up, pushing the page back up into its normal position.

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.