• Stars
    star
    268
  • Rank 153,144 (Top 4 %)
  • Language
    JavaScript
  • License
    Other
  • Created over 14 years ago
  • Updated over 11 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A jQuery based Alternative Facebook Multi-Friend Selector that uses the Graph API

ISO New Maintainer

I'm sorry. I haven't had any time to maintain this library (sadpanda). I'm looking for a volunteer to help maintain and progress the library... because everyone's friends deserve to be selected sometimes.

Overview

This is an client side alternative to the Facebook Multi-Friend Selector that relies on jQuery. No server side component necessary which makes it really easy to adapt and use. Check out this blog post with more details and screencast. To see a demo go here. Click login and login to your facebook account and you should see the friend selector.

Much can be customized by CSS, for example if you want a stacked list type selector that's more stripped down

How to use it

This plugin is depends on the Facebook Javascript API so you have to include it:

	<script src="http://connect.facebook.net/en_US/all.js"></script>

Include the plugin javascript file and CSS

Assuming you have a container like:

	<div id="jfmfs-container"></div>

And you have included the Facebook Javascript API And you have already logged the user in. (FB.init and FB.login) You can load the friend selector in a container like this:

	$("#jfmfs-container").jfmfs();

This should fetch the current users friends and give you the interface to select friends. Then when you're ready to move on, there's a function to call that returns an array of the Facebook Ids of the selected friends.

	var friendSelector  = $("#jfmfs-container").data('jfmfs');
	var selectedFriends = friendSelector.getSelectedIds();

Options

These options can be passed into the jfmfs function with a map of options like jfmfs({key1: val, key2: val})

  • max_selected: int (optional)- max number of items that can be selected

  • labels: object with i18n labels for translations. If you pass this, you need to define all of the labels.

      labels: {
      	selected: "Selected",
      	filter_default: "Start typing a name",
      	filter_title: "Find Friends:",
      	all: "All",
      	max_selected_message: "{0} of {1} selected"
      	// message to display showing how many items are already selected like: "{0} of {1} chosen"
      }
    
  • friend_fields: a comma separated list of fields to return in case you need additional fields for sorting. However you should always at least specify: "id,name",

  • sorter: a function reference that will be called to do the sorting. It takes two arguments which are the two friend objects to be compared and returns "truthy if the first should come before the second. The default is:

      function(a, b) {
      	var x = a.name.toLowerCase();
      	var y = b.name.toLowerCase();
      	return ((x < y) ? -1 : ((x > y) ? 1 : 0));
      }
    
  • pre_selected_friends: an array of ids of friends to preselect once loaded like: pre_selected_friends: [1014025367]

  • exclude_friends: an array of ids of friends to exclude from the list like: exclude_friends: [33333333]

For example your options might look like this if you want a max of 3 friends selected, friends 11111111 and 22222222 preselected, friend 33333333 excluded from the list and to sort by friends' last name:

	{
	    max_selected: 3,
	    max_selected_message: "{0} of {1} sucker selected",
		friend_fields: "id,name,last_name",
		pre_selected_friends: [11111111, 22222222],
		exclude_friends: [33333333],
		sorter: function(a, b) {
	        var x = a.last_name.toLowerCase();
	        var y = b.last_name.toLowerCase();
	        return ((x < y) ? -1 : ((x > y) ? 1 : 0));
	    }
	}

Events

jfmfs.friendload.finished - triggered on the container when the list of friends is finished loading

	$("#jfmfs-container").bind("jfmfs.friendload.finished", function() { 
	    alert("finished loaded!"); 
	});

jfmfs.selection.changed - triggered on the container when a selection has changed with an array of selected friends each like { id: "123", name: "John Doe"}

	$("#jfmfs-container").bind("jfmfs.selection.changed", function(e, data) { 
	    console.log("changed", data);
	});                     

Changelog

Version v4

2/5/2011:

  • Fixed issue with images not loading when list is filtered

  • Added i18n label object option to override default text

  • Fixed bug when there was only one row of friends

  • Added minified version [5.37KB (2.06KB gzipped)]

Version v3

1/28/2011:

  • Added customizable sorter option (see details in options section)

  • Added pre_selected_friends option (see details in options section)

  • Added exclude_friends option (see details in options section)

Version v2 (yeah, not 0.0.0.2)

1/21/2011:

  • Added some performance optimizations especially with a large number of friends

  • Custom events for notification when friends are loaded or selections change

  • Progressive image loading when scrolling including the usage of Ben Alman's awesome throttle/debounce library for smoother scrolling

More Repositories

1

node-reggie

An experimental light weight alternative to a full blown npm registry
JavaScript
416
star
2

docco-husky

A fork of docco for generating documentation for a whole project
CoffeeScript
124
star
3

grails-solr-plugin

Provides search capabilities for Grails domain model and more using the excellent Solr open source search server through the SolrJ library.
Groovy
42
star
4

probe.io

JavaScript
30
star
5

framer

Project Abandoned: donated the name to https://framer.com/ โ˜ ๏ธ!
JavaScript
13
star
6

node-haproxy-stat

Simplify getting info an stats from a local haproxy stat file socket
JavaScript
7
star
7

witbot-sample

JavaScript
6
star
8

Confluence-Socialcast-Plugin

Java
4
star
9

grails-solr-demo

A demo project for some of the features of the Grails Solr plugin
Groovy
4
star
10

node-license-spelunker

Find the licenses of all of you node.js dependencies recursively and create a simple report that includes the license details
JavaScript
4
star
11

node-metrics-collector

JavaScript
3
star
12

marklogic-xquery-oauth2

An Oauth2 library/sample for MarkLogic
3
star
13

docker-minecraft-bukkit

Shell
3
star
14

SonicJot

Swift
2
star
15

node.js-presentation

Code samples from my node.js presentation
JavaScript
2
star
16

tailable-capped-array

A simple fixed length list that supports tailable readable streams for node.js
JavaScript
2
star
17

grails-gorm-jpa-fork

Forking Gorm JPA to try and fix a few problems
Java
1
star
18

sigint-metrics-reckoner

JavaScript
1
star
19

trump-bot

JavaScript
1
star
20

witty-weather-bot

JavaScript
1
star
21

Evented-Web-Demo

Code used in my Event Web presentation demo
JavaScript
1
star
22

sigint-emitter-node

JavaScript
1
star
23

go-httpinfo

Simple http.Handler middleware that records HTTP status code, response size, and duration
Go
1
star
24

sigint-emitter-java

Java
1
star
25

reverse-string-template

Extract values from structured strings
JavaScript
1
star
26

mikebrevoort.site

A repo to support my public blog
CSS
1
star