Coder Social home page Coder Social logo

jquery-facebook-alert's Introduction

This is very simple jQuery based alert() alternative that looks like generic Facebook dialog. It works fine in all major browsers but lacks border-radius and transparency in IE8 and have wrong size in IE7. These browsers weren't the main concern.

To see a demo go here and here

How to use it

This plugin is depends on jQuery so you have to include it (1.7.1 is the minimum tested version):

	<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>

Include the plugin javascript file and CSS:

	<script src="jquery.facebook.alert.js"></script>
	<link rel="stylesheet" href="jquery.facebook.alert.css">

The fbalert function have 4 params that changes its behavior:

  • content - text or jQuery object
  • callback - custom callback, used on all buttons, that don't override it
  • title - custom title, by default is used the document's title
  • buttons - custom set of buttons

Any custom callback is called with two values - button's identifier and jQuery object with whole #fbalert object (can be used as scope for selectors if you use custom HTML content).

Examples (fbalert.html):

	fbalert('Simple alert with default callback.');

Simple example of FBAlert

	fbalert('Alert with custom callback', function() { alert('Custom callback called.'); fbalert_close(); });

	fbalert(
		// content
		'<strong>FBAlert</strong> test',
		// default callback
		function(button, fbalertObject) {
			alert('Button "' + button + '" clicked.');
			fbalert_close();
		},
		// custom title
		'Custom title',
		// custom buttons
		{
			'normal': {
				'name': 'Normal',
				'type': 'normal'
			},
			'primary': {
				'name': 'Primary',
				'type': 'primary'
			},
			'success': {
				'name': 'Success',
				'type': 'success'
			},
			'danger': {
				'name': 'Danger',
				'type': 'danger',
				callback: function(button, fbalertObject) {
					alert('Another callback with button "' + button + '".');
				}
			}
		}
	);

Advanced example of FBAlert

You can use this function together with the Friend selector (fbalert-fs.html).

	fbalert($('<div id="jfmfs-container" />'), function() {
		alert('Selected friends: ' + $("#jfmfs-container").data('jfmfs').getSelectedIds().join(', '));
		fbalert_close();
	});
	$("#jfmfs-container").jfmfs({ max_selected: 3 });

FBAlert with Friend selector

jquery-facebook-alert's People

Contributors

marekjalovec avatar

Stargazers

Hani Gamal avatar

Watchers

James Cloos avatar  avatar

Forkers

tianyingchun

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.