GithubHelp home page GithubHelp logo

jlsfernandez / angular-progress-button-styles Goto Github PK

View Code? Open in Web Editor NEW

This project forked from akveo/angular-progress-button-styles

0.0 2.0 0.0 41 KB

AngularJS version of codrops progress buttons for the use with promises

License: MIT License

JavaScript 4.82% CSS 95.18%

angular-progress-button-styles's Introduction

angular-progress-button-styles

AngularJS version of Codrops progress buttons. I've also made less and sass versions of it besides css.

Check out Live demo!

Basic usage

Install bower package:

bower install --save angular-progress-button-styles

Include scripts and styles (I use FontAwesome for success and error icons, but you can override it):

<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="bower_components/angular-progress-button-styles/dist/angular-progress-button-styles.min.css">
<script type="text/javascript" src="bower_components/angular-progress-button-styles/dist/angular-progress-button-styles.min.js"></script>

Add angular module dependency:

var app = angular.module('app', ['angular-progress-button-styles']);

Add directive to the button element!

<button progress-button="someFunctionThatReturnsPromise()">Submit</button>

That's it! Enjoy the plugin!

Configuration

The directive itself takes as a parameter callback function, that returns promise after execution. If function returns value progress completes instantly. You can configure plugin using two different ways:

  • Using html attributes
  • Using javascript
HTML configuration

Here is a list of supported HTML attributes and their meaning:

Attribute Available values Meaning
pb-style
  • fill
  • shrink
  • rotate-angle-bottom
  • rotate-angle-top
  • rotate-angle-left
  • rotate-angle-right
  • rotate-side-down
  • rotate-side-up
  • rotate-side-left
  • rotate-side-right
  • rotate-back
  • slide-down
  • top-line
  • move-up
  • lateral-lines
  • flip-open
Defines button appearance. Default value is fill.
pb-direction
  • horizontal
  • vertical
To be used with pb-style=(fill or shrink). Defines the direction of the progress bar.
Default value is horizontal.
pb-random-progress
  • true
  • false
Runs random fill function from the moment button is clicked till promise is resolved.
Default value is true.
pb-profile String value The profile from which to fetch configuration during the button initialization.
For more information look JS configuration section
Javascript configuration

For those ones, who don't like to have a lot of configuration in HTML as well to prevent the copy-paste there also is possibility to define configuration in Javascript using profiles. To do this, you need to inject progressButtonConfigProvider during the app configuration:

mdl.config(function(progressButtonConfigProvider) {
  progressButtonConfigProvider.profile('testProfile', {
    style: 'shrink',
    direction: 'vertical'
  });
});

In this example new profile called 'testProfile' created. You can then apply it to you button like this:

<button progress-button="someFunctionThatReturnsPromise()" pb-profile="testProfile">Submit</button>

This would create new button with style shrink and vertical direction.

You can as well define default profile, that will be applied to all the buttons across your application:

progressButtonConfigProvider.profile({
  style: 'shrink',
  direction: 'vertical'
});

License

MIT license.

Contribution

You are welcome to contribute. Feel free to contact me.

Special thanks for contribution:

angular-progress-button-styles's People

Contributors

danielgranat avatar digitalgears avatar kostyadanovsky avatar lugovsky avatar smartapant 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.