Skip to content

Instantly share code, notes, and snippets.

View harmstyler's full-sized avatar

Tyler Harms harmstyler

View GitHub Profile
@harmstyler
harmstyler / rwdTables.coffee
Last active December 16, 2015 20:19
A Responsive Design Approach for Complex, Multicolumn Data Tables by filament group, moved to coffeescript.
rwdTables = ->
container = $('<div class="table-menu table-menu-hidden"><ul /></div>')
$( "thead th" ).each (i) ->
th = $(this)
id = th.attr("id")
classes = th.attr("class"); # essential, optional (or other content identifiers)
# assign an ID to each header, if none is in the markup
if id is undefined
id = ( "col-" ) + i;
@harmstyler
harmstyler / caret.scss
Created June 26, 2013 19:02
Simple hack to give more caret options to bootstrap's caret class
/* ***** Carets and other CSS icons ***** */
.caret {
&.up {
border-bottom: 4px solid #000000;
border-top: none;
}
&.left {
border-top: 4px solid transparent;
border-right: 5px solid #000000;
border-bottom: 4px solid transparent;
enableScrollMenu = ->
$(".bottomscrollbar").hover (->
$this = $(this)
windowHeight = $this.prev().children().length * $this.prev().children().height()
$this.prev().animate(
scrollTop:windowHeight
,600)
), ->
# stop on unhover
$(this).prev().stop()
@harmstyler
harmstyler / accessibleDropdown.coffee
Created August 2, 2013 16:13
Keyboard accessible dropdown menu.
$.fn.accessibleDropDown = ->
el = $(this);
enter = -> $(this).addClass('hover')
leave = -> $(this).removeClass('hover')
# Hover dropdown
$("li", el).hoverIntent(enter,leave)
# Make dropdown menus keyboard accessible
$("a", el).focus( ->
$(this).parents("li").addClass("hover");
@harmstyler
harmstyler / affixEvents.js
Created November 8, 2013 15:16
Code taken from comment by @gregjopa on how to add affix events to bootstrap.
$alert.on('unaffixed.bs.affix', function () {
// ... Code Here
});
$alert.on('affixed.bs.affix', function () {
// ... Code Here
});

Moving from jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})
@harmstyler
harmstyler / statics.py
Created November 14, 2013 18:37
django 1.5 Project and Base Directory variables
import os
PROJECT_DIR = os.path.dirname(os.path.abspath(__file__))
BASE_DIR = os.path.abspath(os.path.join(PROJECT_DIR, '../../'))
# URL prefix for static files.
# Example: "http://example.com/static/", "http://static.example.com/"
STATIC_URL = '/static/'
# Additional locations of static files
@harmstyler
harmstyler / one-liners.md
Last active December 30, 2015 06:29
Command One Liners
@harmstyler
harmstyler / gist:7896595
Last active December 30, 2015 22:49
Compares two arrays and returns boolean value. Coffeescript and Javascript versions provided
Array::equals = (array) ->
return false unless array
return false unless @length is array.length
i = 0
while i < @length
if this[i] instanceof Array and array[i] instanceof Array
# Check and recurse into the nested arrays
return false unless this[i].equals(array[i])
else if this[i] instanceof Object and array[i] instanceof Object
# Stringify objects for comparison

Div full Width/Height of viewport with jQuery

This handy piece of code allows you to create a full width/height div according to the viewport. The code also handles window resizing. Great for modal dialogs or popups.

// global vars
var winWidth = $(window).width();
var winHeight = $(window).height();

// set initial div height / width
$('div').css({