Skip to content

Instantly share code, notes, and snippets.

Looking for work

Barney Carroll barneycarroll

Looking for work
Block or report user

Report or block barneycarroll

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
barneycarroll / $.hasLayout.js
Created Sep 30, 2011
Force hasLayout toggle
View $.hasLayout.js
// Force hasLayout: wait til after page load, toggle zoom moments later
$.fn.hasLayout = function(){
$el = $(this),
zoom = function(){
delay = function(x){
barneycarroll / aspect.htm
Created Oct 11, 2011
Keep a given aspect ratio for any content
View aspect.htm
.aspectWrapper {
position: relative;
.aspectImg {
display: block;
height: auto;
position: relative;
width: 100%;
barneycarroll / jquery.scope.js
Created Nov 21, 2011
Create a quick reference to a $ context, useful for concise and readable $('thing').find() shortcuts
View jquery.scope.js
Return $ function limited to current context.
var $widget = $('widget').scope()
$widget() == $('widget')
$widget('a') == $('widget').find('a')
barneycarroll / jquery.loadAll.js
Created Dec 15, 2011
Wait for all elements with external resources (imgs, iframes) in current $ scope to have loaded before firing passed function
View jquery.loadAll.js
Wait for all elements with external resources (imgs, iframes)
in current $ scope to have loaded before firing passed event.
$('.plugin img').loadAll(function(){...})
For a version of $().load that forces a reload (if load has already
fired before event binding), use
barneycarroll / webkitMobileGPU-CSS.css
Created Jan 19, 2012
Force hardware acceleration on dynamically styled elements for Webkit mobile.
View webkitMobileGPU-CSS.css
/* Media query restricts to mobile: avoid Chrome purple scroll bars */
[style] {
-webkit-transform: translateZ(0);
barneycarroll / jquery.dataExtend.js
Created Mar 7, 2012
Make editing/extending objects slightly less verbose
View jquery.dataExtend.js
$(el).data() is fine if you're using it for simple key/value pairs, but if there's any depth (objects), adding to or modifying said objects becomes a verbose pain in the ass.
This extension method uses $.extend() to add or modify any object with the given key:
barneycarroll / fizzleSizzle.js
Last active Oct 1, 2015
Get rid of Sizzle's IE custom attributes
View fizzleSizzle.js
In IE, Sizzle has to create custom attributes to be able to travel the DOM intelligently. The custom attributes are lengthy and nasty, and can often screw up your code if you rely on parsing markup. fizzleSizzle wipes all that stuff out.
// Pass in a string of markup and get it back without Sizzle's shizzle
var fizzleShizzle = function(x){
return x.replace(/(nodeIndex|sizcache|sizset)[\w\d]*(="[^"]*")*/gi,'');
barneycarroll / console.log.js
Created Apr 20, 2012
Stop breakage on environments without console.log
View console.log.js
if(!window.console) console = {log:function(){}};
barneycarroll / browse.js
Created Aug 7, 2012
Browser feature inference
View browse.js
browser = {
ieVersion: function () {
var undef;
var v = 3;
var div = document.createElement('div');
var all = div.getElementsByTagName('i');
while (
div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->', all[0]);
return v > 4 ? v : undef;
barneycarroll / grids.reduced.css
Last active Oct 11, 2015
OOCSS grids without classitis for IE9 and above
View grids.reduced.css
.line > :nth-child(n+2):last-child{
overflow: hidden;
.line > *{
.line > :nth-child(1):nth-last-child(2){
You can’t perform that action at this time.