Skip to content

Instantly share code, notes, and snippets.

@jdcauley
jdcauley / email-sign-up.js
Created July 10, 2014 13:35
Email Sign Up with Parse
$('#submit').click(function(){
var emailAddress = $('#email').val();
var NewSignUp = Parse.Object.extend("NewSignUp");
var newSignUp = new NewSignUp();
newSignUp.save({email: emailAddress}).then(function(success) {
if(success){
$('#signup').addClass('done');
$('#form-success').addClass('show');
} else {
$('#signup').addClass('done');
@jdcauley
jdcauley / boxer.js
Last active August 29, 2015 14:03
Boxer - Make Height = Width
window.onload = boxer;
window.onresize = boxer;
function boxer(){
var cols = document.getElementsByClassName('col');
for (var i = 0; i < cols.length; i++){
var style = window.getComputedStyle(cols[i], null).getPropertyValue('width');
cols[i].style.height=style;
}
@jdcauley
jdcauley / scripts.js
Created July 15, 2014 16:00
Placeholder for Gravity Forms
function placeholder(){
var target = '#gform_1 input[type=text]';
var inputs = document.querySelectorAll(target);
if(inputs){
for (var i = 0; i < inputs.length; i++){
var value = inputs[i].value;
console.log(value);
@jdcauley
jdcauley / single.php
Last active August 29, 2015 14:04
Image Empty State
<div class="blog-img">
<?php if (has_post_thumbnail()): ?>
<?php $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), array( 5600,1000 ), false, '' ); ?>
<div class="blog-feature" style="background-image: url(<?php echo $src[0]; ?>);"></div>
<?php else: ?>
<div class="blog-feature-empty"></div>
<?php endif; ?>
</div>
@jdcauley
jdcauley / empty-thumb.php
Created July 16, 2014 18:51
Featured Image with Empty State
<div class="blog-img">
<?php if (has_post_thumbnail()): ?>
<?php $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), array( 5600,1000 ), false, '' ); ?>
<div class="blog-feature" style="background-image: url(<?php echo $src[0]; ?>);"></div>
<?php else: ?>
<div class="blog-feature-empty"></div>
<?php endif; ?>
</div>
@jdcauley
jdcauley / equalheight.js
Last active August 29, 2015 14:04
Box Height
function boxHeight(target){
var pricingBox = document.getElementsByClassName(target);
var boxHeights = []
for (var i = 0; i < pricingBox.length; i++){
var heights = window.getComputedStyle(pricingBox[i], null).getPropertyValue('height').replace("px", "");
boxHeights.push(heights);
}
var tallest = Math.max.apply( null, boxHeights );
for (var i = 0; i < pricingBox.length; i++){
pricingBox[i].style.height=tallest+'px' ;
@jdcauley
jdcauley / grayscale-img.scss
Created July 23, 2014 14:03
Quick Gray Scale
&.grayscale img {
filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale"); /* Firefox 10+, Firefox on Android */
filter: gray; /* IE6-9 */
-webkit-filter: grayscale(100%); /* Chrome 19+, Safari 6+, Safari 6+ iOS */
}
&.grayscale:hover img {
filter: none;
-webkit-filter: none;
}
<?php $args = array(
'echo' => true,
'redirect' => get_permalink(90),
'form_id' => 'loginform',
'label_username' => __( 'Username' ),
'label_password' => __( 'Password' ),
'label_remember' => __( 'Remember Me' ),
'label_log_in' => __( 'Log In' ),
'id_username' => 'user_login',
'id_password' => 'user_pass',
@jdcauley
jdcauley / scripts.js
Created August 7, 2014 11:34
style-to-head
function dribbleVideoPosition(){
if($('body').hasClass('home') ){
var currentWindow = $(window).width();
if (currentWindow < 1628){
var difference = 1628 - currentWindow;
var half = Math.round(difference/2);
var newMarginLeft = half;
var css = '.dribble{margin-left: -'+ newMarginLeft + 'px !important;}',
head = document.head || document.getElementsByTagName('head')[0],
@jdcauley
jdcauley / getParams.js
Last active August 29, 2015 14:05
getParams from URL and turn into object
function getParams(){
var params = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++){
hash = hashes[i].split('=');
params[hash[0]] = hash[1];
}
return params;
}