Skip to content

Instantly share code, notes, and snippets.

View willbroderick's full-sized avatar

Will Broderick willbroderick

  • Clean Canvas Ltd
  • Nottingham, UK
View GitHub Profile
@willbroderick
willbroderick / normheights.js
Last active November 17, 2015 09:29
Help normalise the heights of items laid out in responsive rows - relies on presence of an inner div that will keep natural height of objects inside. Useful for keeping prices aligned under product images.
$(window).on('debouncedresize load', function(){
$('[data-normheights]').each(function(){
var $items = $(this).find($(this).data('normheights')),
childFilter = $(this).data('normheights-inner'),
tallest = 0,
lastYOffset = 0,
row = [];
$items.each(function(index){
var $img = $(this).find(childFilter);
var yOffset = $(this).offset().top;
@willbroderick
willbroderick / willFillParent.js
Last active January 10, 2017 10:30
Set an image or iframe to fill its parent (like a desktop wallpaper)
/* Take an image, or any other element with height/width attrs (e.g. iframe) and stretch it to fill parent
* MIT license
*
* Dependencies:
* imagesLoaded: https://github.com/desandro/imagesloaded
*
* Usage examples:
* $('.fillcontainer img.main').willFillParent({ closest: '.fillcontainer', windowEvent: 'debouncedresize load' });
* $('.video-bg > .video').willFillParent({ windowEvent: 'resize' });
*
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')