Skip to content

Instantly share code, notes, and snippets.

@boazsender
boazsender / modified-x-axis-intervals-and-labels.js
Created June 21, 2010 19:49
Raphael line chart with custom x-axis labels demo
//based on the source of http://g.raphaeljs.com/linechart.html
var options = {
axis: "0 0 1 1", // Where to put the labels (trbl)
axisxstep: 16 // How many x interval labels to render (axisystep does the same for the y axis)
};
document.addEventListener('DOMContentLoaded', function () {
// Make the raphael object
@boazsender
boazsender / jQuery.classList.js
Created July 16, 2010 05:28
classList() method which provides the behaviour you would expect from a method implementation of the HTML5 classList property which is supported currently in FF 3.6
/*
Usages:
$(selector).classList() //returns an array of classnames
$(selector).classList('newclass') //replaces the current element's classes
$(selector).classList('new', 'class', 'names') //replaces the current element's classes
$(selector).classList(['new', 'class', 'names']) //replaces the current element's classes
*/
jQuery.fn.extend({
classList: function( value ) {
@boazsender
boazsender / index.html
Created August 10, 2010 07:38
Dead Simple Twitter Search API implementation with jQuery
<!DOCTYPE html>
<html>
<head>
<title>Dead Simple Twitter Search API jQuery Feed</title>
<script src="http://code.jquery.com/jquery.js"></script>
<script src="jQuery.twitterFeed.js"></script>
<link href="jQuery.twitterFeed.css" media="screen" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Twitter Posts:</h1>
<!DOCTYPE html>
<html>
<head>
<title>Twitter Search Plugin</title>
<script src="http://code.jquery.com/jquery.js"></script>
<script src="jquery.twitter.js"></script>
<style type="text/css">
.twitter-posts li {margin-bottom: 10px; font-size: 12px; clear: both; list-style-type:none;}
.twitter-posts li img {float:left; width: 48px; margin:0px 10px 10px 0px;border:1px solid #c2c2c2; -moz-box-shadow: 0px 0px 4px #c2c2c2; -webkit-box-shadow: 0px 0px 4px #c2c2c2; box-shadow: 0px 0px 4px #c2c2c2;}
.twitter-posts li a {text-decoration:none; color: #009;}
$('selector').twitter('search terms');
@boazsender
boazsender / twitter-api-boilerplate-with-comments.js
Created November 26, 2010 05:06
Twitter API implementations for lists, search.
$(function(){
// Twitter REST API list method
$.getJSON('http://twitter.com/F1LT3R/lists/bocoup/statuses.json?callback=?', function(tweets){
console.log('Twitter REST API results:', tweets);
// This will log an array of objects each representing one twitter post.
// Each object in the array will contain on tweet that looks like this.
/*
[
Object,
Object : {
@boazsender
boazsender / popcorn-api.js
Created December 5, 2010 16:24
Popcorn API, Three Popcorn.js plugin patterns, and the plugin manifes
// Popcorn Instance Methods
var p = Popcorn( "#video" )
p.play()
// Play the video (Native "pass through" method)
// Returns the Popcorn instance object
p.load()
// Load the video (Native "pass through" method)
// Returns the Popcorn instance object
@boazsender
boazsender / enhanced-singleton-api-pattern.js
Created December 5, 2010 16:44
Enhanced Singleton pattern borrowed by @rwaldron from jQuery for Popcornjs
/*
* Outline code for the popcornjs enhanced singleton pattern
*/
// Immediately invoked function expression is used to
// create a pseudo-private scope for our api definition
// a reference to the `window` object is passed into the
// closure and referenced as `global`. This is both
// beneficial for compressors and provides a fast
// reference to the window context
Popcorn('#video')
.play()
.currentTime(30)
.pause()
.listen('timeupdate', function(event){
console.log( this ) // the current popcorn object
this.currentTime() // the currentTime
})
.play()
.currentTime(20)
// Originally solved by Tim Branyen in his drop file plugin
// http://dev.aboutnerd.com/jQuery.dropFile/jquery.dropFile.js
jQuery.event.props.push('dataTransfer');