GithubHelp home page GithubHelp logo

tintjs's Introduction

Tint.js

Tint.js is Tint's SDK that allows developers to quickly build dynamic social content. Tint.js handles all of the social aggregation and data delivery / pagination / templating.

Getting Started

Below, you will learn how to use Tint.js to build a basic custom widget.

Dependencies

Include the Tint script along with the other JavaScript on your page.

<script async type="text/javascript" src="somelongurl/tint.js"></script>

Then, to run your code after all of the Tint components are loaded, add the following:

<script>
	Tint.ready(function(){
		// View and API components are loaded
	});
</script>

The Model

Tint.js models are extensions of Backbone.js modules. Use them to pull in data from our API. These models are used to create views which can be rendered

var collection = new Tint.PostCollection();
collection.username = 'your_username_here'; // required
collection.fetch(); // calls the API for collection data

The model comes with a number of properties that can be modified to change what data is returned

var collection = new Tint.PostCollection({
	username: '', // required username of your Tint
	network: 'facebook', // optional network - all, twitter, instagram, etc.
	from : 1382485719887 // optional timestamp indicating when to start pulling in data
});

The View

Views can use custom templates to render the data. Our templating system makes this easy. Just do the following:

  1. Define a template using mustache.js syntax, and either put it on the page in a script tag, or host it somewhere with jsonp enabled
  2. Associate it with a view using the CSS identifier or the URL to your template
  3. Optionally, add a CSS file to style the template and store it as "template_css"
<!-- 1. defining a custom template -->
<script class="my_template_name" type="application/x-template">
	<div>
		<h2>{{ title }}</h2>
	</div>
</script>
<!-- 2. setting up model and view with custom template -->
<script>
	Tint.ready(function(){
		// View and API components are loaded
		// create a new collection of posts
		var collection = new Tint.PostCollection();
		collection.username = 'your_username_here'; // required
		// create a new view, associating them with this collection
		var postHolderView = new Tint.PostHolderView({
			model: collection,
			// optional template for a single post (see http://dev.tintup.com/template/postTemplate_basic?callback=example for an example)
			template: 'http://www.example.com/url/to/your/jsonp/template',
			// optional css file to go with your template
			template_css: 'http://www.example.com/url/to/your/css.css',
			// optional function to be called after all of the posts have rendered
			afterRender: function(){
				console.log('render finished');
			}
		});
		// pull data from server
		collection.fetch();
	});
</script>

tintjs's People

Contributors

rchiba avatar

Stargazers

Chris Soriano avatar

Watchers

James Cloos avatar Shreyas avatar TINT avatar Ketan Deshmukh avatar John Niedzwiecki avatar Joey Rideout avatar Andrew Pennington avatar Rocco Balsamo avatar

Forkers

seekshreyas

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.