Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View cullenjohnson's full-sized avatar

Cullen Johnson cullenjohnson

View GitHub Profile
@cullenjohnson
cullenjohnson / JQuery flash.js
Last active August 29, 2015 14:10
Flashes the selected element a certain color or style for a configurable number of seconds (without needing jQuery UI).
jQuery.fn.extend({
/** $().flash(options)
*
* Author: Cullen Johnson
* URL: https://gist.github.com/cullenjohnson/3d529bbfc7a555d1e640
*
* Description:
* Flashes an element's background-color, then fades back to the element's original background-color
*
* REQUIRES jQuery 1.4+ (jQuery UI is NOT needed)
@cullenjohnson
cullenjohnson / GetSearchTermRelevanceComparator.js
Last active August 29, 2015 14:27
Returns a compare function to be used in JavaScript's `Array.prototype.sort()` function that finds the string match of a search term nearest to the start of the word.
/** GetSearchTermRelevanceComparator
* Author: Cullen Johnson
* Github: https://github.com/cullenjohnson
* Website: cullenjohnson.ca
*
* Return an underscore sort comparator that can sort a list of strings based on the relevancy of the search term.
* Can be used to sort strings, objects with string properties, or Backbone objects with string properties.
*
* Search Priority: (Example search term: "FOO")
* 1. Exact match of search term ("FOO" > "super FOObar")
@cullenjohnson
cullenjohnson / FilterSelectView.js
Created October 1, 2015 23:31
Backbone <select> tag replacement inspired by the "Burn your select tags" talk by Alice Bartlett at EpicFEL 2014: https://www.youtube.com/watch?v=CUkMCQR4TpY
/**
* FilterSelectView
* Creator: Cullen
*/
FilterSelectView = Backbone.View.extend({
/** -----------------------------------
* DESCRIPTION
* ------------------------------------
*