jQuery autocomplete with multiple values

This will eventually be integrated into jQuery UI with the multiple: true option, but right now this is the way. Credits go to jqueryui.com.

Unobtrusive jQuery to toggle visibility with selects and checkboxes

Use this if you want to show or hide part of a form if certain options are selected or boxes are checked.

The triggering input gets an data-selects-visibility attribute with a selector for the elements to show or hide, like

<%= form.select :advancedness, [['basic', 'basic'], ['advanced', 'advanced'], ['very advanced', 'very_advanced]], {}, :"data-selects-visibility" => ".sub_form" %>

The elements that are shown/hidden look like

<div class="sub_form" data-show-for="basic"> 
  only shown for advancedness = basic 
</div>

...

Regular Expressions - Cheat Sheet

You can write regular expressions some different ways, e.g. /regex/ and %r{regex}. For examples, look here.

Remember that it is always a good idea to match a regex visually first.

Characters

Literal Characters

[ ] \ ^ $ . | ? * + ( )

Character Classes

[ae]            matches a and e, e.g. gr[ae]y => grey or gray => but NOT graay or graey
[0-9]  ...

traits.js - Traits for Javascript

traits.js is a minimal, standards-compliant trait composition library for Javascript.

mezzoblue's PaintbrushJS at master - GitHub

PaintbrushJS is a lightweight, browser-based image processing library that can apply various visual filters to images within a web page.

epeli / Underscore.strings / source — bitbucket.org

String manipulation extensions for the Underscore.js javascript library.

Using CSS3PIE cross-domain

Currently not possible as the linked .htc file contains JavaScript which is not explicitly called.

The developers are working on a pure JavaScript solution which will have some downsides but work across different domains.

Javascript Compressor - compress code online for free

Compress and obfuscate Javascript code online completely free using this compressor.

Autofocus a form field with HTML5 or jQuery

In Webkit you can use the HTML5-attribute autofocus:

= form.text_field :title, :autofocus => 'autofocus'

Here is a jQuery fallback for browsers that don't speak HTML5:

var Autofocus = {

  supported: function() {
    return 'autofocus' in document.createElement('input');
  },

  fake: function() {
    $('[autofocus]').focus();
  },

  extend: function() {
    Autofocus.supported() || Autofocus.fake();
  }

};

$(Autofocus.extend);

Test if a checkbox is checked in jQuery

jqueryElement.is(':checked')

Why your all.js is empty on staging or production

When you include a non-existing Javascript file, you probably won't notice it during development. But with caching active (on production or staging) Rails will write an empty all.js file without complaining.

jsviz - Google Code

JSViz makes it easy to create dynamic 2D views of information. Practical applications include network graphs, navigation, and other dynamic layouts.

The Sexy Curls jQuery Plugin by Elliott Kember

The Sexy Curls jQuery Plugin is an open-source jQuery plugin by Elliott Kember which lets you share in the beauty of the page fold.

JSMIN, The JavaScript Minifier

JSMin is a filter which removes comments and unnecessary whitespace from JavaScript files. It typically reduces filesize by half, resulting in faster downloads. It also encourages a more expressive programming style because it eliminates the download cost of clean, literate self-documentation.

leethal's live-validations at master - GitHub

Reads Active Record's validations and makes them available to live client side javascript

flot - Google Code

Flot is a pure Javascript plotting library for jQuery. It produces graphical plots of arbitrary datasets on-the-fly client-side.

Solutoire.com › Flotr Javascript Plotting Library

Flotr is a javascript plotting library based on the Prototype Javascript Framework (version 1.6.0.2 at the moment) and inspired by Flot (written by Ole Laursen).

JavaScript dependency management and concatenation: Sprockets

Sprockets is a Ruby library that preprocesses and concatenates JavaScript source files. It takes any number of source files and preprocesses them line-by-line in order to build a single concatenation. Specially formatted lines act as directives to the Sprockets preprocessor, telling it to require the contents of another file or library first or to provide a set of asset files (such as images or stylesheets) to the document root.

MooEditable

A simple web-based WYSIWYG editor, written in MooTools.

sandofsky's acts_against_douchebar at master - GitHub

A Rails plugin that delivers a special message to DiggBar users, or runs frame-killer javascript.

Introducing Typekit « The Typekit Blog

As a Typekit user, you’ll have access to our library of high-quality fonts. Just add a line of JavaScript to your markup, tell us what fonts you want to use, and then craft your pages the way you always have. Except now you’ll be able to use real fonts.

Cross-Domain Data with Rack and Rails | Union Station

Asynchronous JavaScript and CSS, also known as CSSHttpRequest, is a method of URI-encoding data in 2KB chunks split over several CSS rules with a modified data URI scheme. Because CSS is not subject to the same-origin policy, no service proxy is required.