Coder Social home page Coder Social logo

fa-multi-button's Introduction

fa-multi-button

Modern toggle, push button or just a signal indicator

Features

  • Create toggle buttons with font awesome icons
  • Create push buttons with glow off effect
  • Create read only buttons as an indicator control

Usage

$(selector).famultibutton(options);

Examples

<div id="btn1"></div>

<script>
    $(function() {
        btn = $('#btn1').famultibutton();
		btn.setOn();
    });
</script>

More examples with fa-multi-button

Options

  • icon: The foreground font awesome icon name (default: 'fa-power-off')
  • backgroundIcon: The background font awesome icon name (default: 'fa-circle')
  • offColor: Color of the foreground in state off (default: '#2A2A2A')
  • offBackgroundColor: Color of the foreground in state off (default: '#505050')
  • onColor: Color of the foreground in state on (default: '#2A2A2A')
  • onBackgroundColor: Color of the background in state on (default: '#aa6900')
  • classes: Array of optional font awesome classes to add to selector (default: 'fa-3x')
  • mode: Sets the kind of button: 'toggle', 'push' or 'signal' (default='toggle')
  • toggleOn: Function called in state on
  • toggleOff: Function called in state off

See the list for all available icons

Dont forget the 'fa-' suffix in icon and backgroundIcon name.

Hooks

<script>
	$('.button').famultibutton({
		icon: 'fa-lock',
		onColor: '#ffffff',
		offColor: '#ffffff',
		onBackgroundColor: '#33dd00',
		toggleOn: function( ) { /*make something*/ },
		toggleOff: function( ) { /*make something*/ }
	});
</script>

Update call for multi instances

<div class="button" device="mylamp"></div>
<div class="button" device="otherlamp"></div>

<script>

// init buttons
 $('.button').each(function(index) {
 	
 	var device = $(this).attr('device');
 	var elem = $(this).famultibutton({
		icon: 'fa-lightbulb-o',
		backgroundIcon: 'fa-circle',
		offColor: '#2A2A2A',
		onColor: '#2A2A2A',
		// Called in toggle on state.
		toggleOn: function( ) { setSomething( device,"on" ); },
	   	toggleOff: function( ) { setSomething( device,"off" ); },
	});
	// store instance into data
	elem.data('famultibutton',elem);
 });
 
 // update buttons
 function doUpdate() {
 	$('.button').each(function(index) {
 	  var state = getSomething( $(this).attr('device') );
	  if ( state == 'on' )
		$(this).data('famultibutton').setOn();
	  else
		$(this).data('famultibutton').setOff();
 	});
 }
</script>

License

This project is licensed under MIT.

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.