Skip to content

Instantly share code, notes, and snippets.

View joecritch's full-sized avatar

Joe Critchley joecritch

View GitHub Profile
.class {
background: rgba(255,255,255,0.8);
html.no-rgba & {
background: #eee;
}
}
/** Which would output as: **/
.class { background: rgba(255,255,255,0.8);
@joecritch
joecritch / gist:1723442
Created February 2, 2012 13:21
Git add & commit shortcut
git config --global alias.ac '! git add -A && git commit -m'
<!DOCTYPE html "⌘">
<html>
<meta charset=utf-8>
<title>Brap.</title>
<style>
* { margin: 0; padding: 0; }
/** etc **/
</style>
<body>
$('.toggler').bind('change', function() {
var showIt = !$(this).is(':checked');
var panel = $(this).closest('.field').nextAll('.hide');
panel.changeVisibility(showIt)
.closest('fieldset').changeClass('featured', showIt);
});
// Helper classes
$.fn.changeClass = function(className, add) {
add = add || false;
return this.each(function() {
if(add) {
$(this).addClass(className);
}
else {
$(this).removeClass(className);
$('.toggler').change(function() {
var showIt = !$(this).is(':checked');
var panel = $(this).closest('.field').nextAll('.hide');
if(showIt) {
panel.show().closest('fieldset').addClass('featured');
}
else {
panel.hide().closest('fieldset').removeClass('featured');
}
});
@joecritch
joecritch / gist:929535
Created April 19, 2011 20:22
All of the plugin
(function($) {
// Static constructs
$.motionlab = $.motionlab || {};
$.motionlab.simpleScroll = {
conf: {
auto_slide: 0,
hover_pause: 0,
auto_slide_seconds: 1000
}
@joecritch
joecritch / gist:929505
Created April 19, 2011 20:13
Callbacks
// add a "fire" variable, below the self variable, that will cover both the current instance and the root variable.
var self = this,
fire = root.add(self);
/////////////////////////
// then insert calls to the custom functions in all the necessary places, e.g. in the slide function --
$.extend(self, {
@joecritch
joecritch / gist:929361
Created April 19, 2011 19:25
Souped-up call!
$('.carousel ul').each(function() {
var ul = $(this);
ul.simpleScroll({
auto_slide: 1,
hover_pause: 1
});
// Aha! There's our data object we created inside the plugin. Luckily, this gives us access to everything that SimpleScroll had to offer.
var api = ul.data('simpleScroll');
$.fn.simpleScroll = function(conf) {
// already constructed --> return API (it shouldn't really be called for a second time.)
var el = this.data("simpleScroll");
if (el) { return el; }
var conf = $.extend({}, $.motionlab.simpleScroll.conf, conf);
return this.each(function() {