Skip to content

Instantly share code, notes, and snippets.

View danielhaim1's full-sized avatar

Daniel Haim danielhaim1

View GitHub Profile
@danielhaim1
danielhaim1 / scrollfade.js
Created June 7, 2013 18:08
Change opacity of element based on window scroll
$(document).ready(function() {
var fadeStart=1 // 100px scroll or less will equiv to 1 opacity
,fadeUntil=500 // 200px scroll or more will equiv to 0 opacity
,fading = $('#fading')
;
$(window).bind('scroll', function(){
var offset = $(document).scrollTop()
@danielhaim1
danielhaim1 / data-pullquote.js
Created June 7, 2013 18:52
If paragraph has data-pullquote="span", quote will pull the <span></span> from the paragraph and data-pullquote that span. the data-pullquote="attribute" can change to anything really, e.g. "strong", "em", "blockquote" etc.
(function( $ ){
var PULLQUOTE = 'data-pullquote';
$('[' + PULLQUOTE + ']').each(function(){
var $parent = $(this),
$quote = $parent.find( $parent.data('pullquote') );
if ( $quote.length > 0 )
@danielhaim1
danielhaim1 / relative-dates.php
Created June 7, 2013 19:07
Relative dates: - a moment ago - 1 min - 59 mins - 1 hour - 23 hours - 1 day - 7 days - 1 week - 5 weeks - 1 month - 11 months - 1 year - infinity years
<?php
if(!function_exists('how_long_ago')){
function how_long_ago($timestamp){
$difference = current_time('timestamp') - $timestamp;
if($difference >= 60*60*24*365){ // if more than a year ago
$int = intval($difference / (60*60*24*365));
$s = ($int > 1) ? 's' : '';
@danielhaim1
danielhaim1 / base.css
Created June 7, 2013 19:28
my base.css.
/***************************
notice how the puke cascades.
%%%%%%
%%%% = =
%%C >
_)' _( .'
__/ |_/\ " *. o
/` \_\ \/ %`= '_ .
/ ) \/| .^',*. ,
@danielhaim1
danielhaim1 / change-theme.js
Created June 7, 2013 19:35
Change Theme Color (.js button)
$(document).ready(function () {
swap();
});
var swap = function () {
$('.light').click(function () {
$(this).removeClass('light').addClass('dark').find('div').text('Darker');
$('body').removeClass('darker').addClass('lighter');
swap();
});
$('.dark').click(function () {
@danielhaim1
danielhaim1 / blockquote.css
Created June 7, 2013 22:17
blockquote.css
blockquote { background: #f9f9f9;
border-left: 10px solid #ccc;
margin: 1.5em 10px;
padding: .5em 10px;
quotes: "\201C""\201D""\2018""\2019";
}
blockquote:before { color: #ccc;
content: open-quote;
font-size: 4em;
@danielhaim1
danielhaim1 / css-tabs.html
Created June 7, 2013 22:22
Pure CSS functional tabbed area
<style>
.tabs { position: relative;
clear: both;
margin: 25px 0;
min-height: 200px;
width: 300px;
font: 700 15px Arial;
}
.singleTab { float: left }
@danielhaim1
danielhaim1 / hoverclass.js
Created January 28, 2014 23:04
Toggle class on :hover
$('.class').hover(function(){
$(this).addClass('hover');
}, function(){
$(this).removeClass('hover');
});
@danielhaim1
danielhaim1 / disableinput.js
Last active February 24, 2017 03:17
Disable input fields
$('input[type="submit"]').attr("disabled", true);
@danielhaim1
danielhaim1 / color-harmony.scss
Last active March 16, 2017 16:17
Establish color harmony by finding high value, and cool color
//Pick a color
$first-color: hsl(10, 100%, 50%);
// Find the complement
$second-color: complement($first-color);
//Check if you have a cool color on your hands. Cool colors will overpower warm colors when mixing.