GithubHelp home page GithubHelp logo

css-indicators's Introduction

css-indicators

Pure CSS3 work indicators (a.k.a. Ajax loaders).

Usage

Download either the minified or the regular version of the CSS file and include it in your page:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <!-- This is the important bit -->
    <link rel="stylesheet" media="screen" href="css/css-indicators.min.css" />
</head>
<body>
</body>
</html>

And then you can use the provided JS helper (in the form of a jQuery plugin) or add the needed markup for the themed indicator (see below).

jQuery plugin

css-indicators comes bundled with a tiny but handy jQuery plugin.

By using it, you won't have to go through the hassle of dealing with the correct markup for each indicator theme. You'll just have to do a $('#my-indicator').indicator() optionally specified with a couple of options.

Usage

After you've included the CSS file for the indicators, you will need to add the JS file or its minified version to your jQuery-enabled page. Remember to add it after your jQuery <script> tag!

Once you have included the JS file, you can then use it with any existing element on the page:

jQuery(function($) {
    // With the default options
    $('#default-indicator').indicator();
    //  -> Will produce a 'spinner', 'normal', with 9 bars.

    // Only specifying the theme
    $('#themed-indicator').indicator('bouncer');

    // Providing a hash of options
    $('#customized-indicator').indicator({ theme: 'pulsar', size: 'x-large' });
});

Available options

The available options for the plugin are:

  • theme: The theme to use - 'spinner' by default, but could be any of the themes listed below.
  • size: The size: 'small', 'medium', 'normal' (default), 'large', 'x-large'.
  • extra: Extra classes to define on the container. Defaults to '' (an empty string).
  • bars: Number of child bars to add to the spinner theme. Only valid for that theme. Defaults to 9.

Indicator themes

Global CSS class names

First of all, you should know that every indicator must have the .indicator class name.

For every indicator theme you can specify its size via a class name. This is optional, and will default to a sensible value. Available sizes are: .small, .medium, .normal (the default size), .large and .x-large.

Spinner

This theme displays an animated spinner with bars.

The markup

This indicator requires the following markup (please note that the specific classes described in the next section might change for your particular use case):

<!-- The spinner needs a container element -->
<span class="indicator spinner normal bars-9">
    <!-- And a set of bars to draw, in this case 9 as .bars-9 requires -->
    <span class="bar"></span>
    <span class="bar"></span>
    <span class="bar"></span>
    <span class="bar"></span>
    <span class="bar"></span>
    <span class="bar"></span>
    <span class="bar"></span>
    <span class="bar"></span>
    <span class="bar"></span>
</span>

The CSS

This indicator uses the .spinner class name, and relies on a class that states the number of bars it should show.

For the number of bars you must use a class that indicates how many bar elements the spinner has in the form .bars-X, where X is a number between 3 and 36.

Bouncer

This theme displays a nice little ball bouncing up and down in a neverending loop.

The markup

This indicator requires the following markup (please note that the specific classes described in the next section might change for your particular use case):

<!-- The bouncer needs a container element -->
<span class="indicator bouncer normal with-floor">
    <!-- And the ball that will be bouncing inside the container -->
    <span class="ball"></span>
</span>

Pulsar

This theme displays a nice little ball pulsing in a neverending loop.

The markup

This indicator requires the following markup (please note that the specific classes described in the next section might change for your particular use case):

<!-- The pulsar needs a container element -->
<span class="indicator pulsar normal">
    <!-- And the ball that will be pulsing inside the container -->
    <span class="ball"></span>
</span>

The CSS

This indicator uses the .pulsar class and has no further configuration through classes.

Squared

This theme displays a square moving in the shape of a bigger square.

The markup

This indicator requires the following markup (please note that the specific classes described in the next section might change for your particular use case):

<!-- Squared needs a container element -->
<span class="indicator squared normal">
    <!-- And the square that will be moving inside -->
    <span class="square"></span>
</span>

The CSS

This indicator uses the .squared class and has no further configuration through classes.

Loopy

This theme displays a square in a loopy rotation.

The markup

This indicator requires the following markup (please note that the specific classes described in the next section might change for your particular use case):

<!-- Loopy only uses a container element -->
<span class="indicator loopy normal">
    <!-- So no children allowed in here, old sport! -->
</span>

The CSS

This indicator uses the .loopy class and can optionally have slightly rounded corners if you use the .rounded class.

FBlocks

This theme displays a facebook-like blocks animation.

The markup

This indicator requires the following markup (please note that the specific classes described in the next section might change for your particular use case):

<!-- FBlocks uses a container element -->
<span class="indicator fblocks normal">
    <!-- And  three inner blocks -->
    <span class="block"></span>
    <span class="block"></span>
    <span class="block"></span>
</span>

The CSS

This indicator uses only the .fblocks class.

License

css-indicators is licensed under the MIT License. Here you have the boring legal stuff:

Copyright (c) 2012 José Nahuel Cuesta Luengo

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

css-indicators's People

Contributors

ncuesta avatar

Watchers

 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.