Giter Site home page Giter Site logo

jquery-facebook-photo-selector's Introduction

jQuery Facebook Photo Selector

This is an interface component that allows you to select a photo from your albums as if you were inside of Facebook. It mimics the 'Change your profile picture' dialogue, but allows you to customize it as you like.

This is what it looks like.

This is based on the Friend Selector plugin created by These Days. Their plugin can be found on GitHub.

Viewing the example

You can view the example at labs.carsonshold.com/fb-photo-selector, or you can check out this repository and run it yourself.

You'll need to put the files on a web server or virtual host - Facebook apps won't run off the local file system.

Just edit example.js and set your Facebook appId, then set the 'Website' field in your app settings accordingly.

Using the plugin

Include required HTML

  • Copy the div element with the ID CSPhotoSelector (and all of its children) from index.html.

Include required CSS

  • Include the csphotoselector.css stylesheet in your document.
  • Ensure the csphotoselector folder is located in the same directory as csphotoselector.css. It holds required images.

Include required JavaScript

  • Include jQuery in your document.
  • Include the Facebook JavaScript SDK.
  • Include csphotoselector.js.

The fun stuff (using the plugin)

1 - Make sure your user has authenticated your Facebook app. user_photos is required. friends_photos is required if you would like to browse a friend's photos. These are set in example.js.

2 - Initialise the plugin. Here you can set options like toggling debug messages, your preferred classnames, etc.

CSPhotoSelector.init({debug: true});

3 - Create an instance of the plugin.

selector = CSPhotoSelector.newInstance({
	callbackAlbumSelected	: callbackAlbumSelected,
	callbackAlbumUnselected	: callbackAlbumUnselected,
	callbackPhotoSelected	: callbackPhotoSelected,
	callbackPhotoUnselected	: callbackPhotoUnselected,
	callbackSubmit			: callbackSubmit,
	maxSelection			: 1,
	albumsPerPage			: 6,
	photosPerPage			: 200,
	autoDeselection			: true
});

4 - Display the plugin instance when you need it. The plugin will automatically load the Facebook photos of the logged in user, or attempt to load the photos of the friend ID passed to the function.

$(".photoSelect").click(function (e) {
	e.preventDefault();
	id = null;
	if ( $(this).attr('data-id') ) id = $(this).attr('data-id');
	fbphotoSelect(id);
});

License

MIT Licensed

jquery-facebook-photo-selector's People

Contributors

cshold avatar iamcal avatar shaunagordon 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.