Skip to content

Instantly share code, notes, and snippets.

View KruegerDesigns's full-sized avatar

Adam Krueger KruegerDesigns

View GitHub Profile
@KruegerDesigns
KruegerDesigns / sameHeight.js
Created January 11, 2013 16:53
Elements that need to match height can use this jQuery. Based on Chris Coyer's same height code, but modified for layouts using "box-sizing: border-box;".
// jQuery same height HTML elements, per a row.
$(window).load(function() {
var currentTallest = 0,
currentRowStart = 0,
rowDivs = new Array(),
$el,
topPosition = 0;
$('.blocks').each(function() {
@KruegerDesigns
KruegerDesigns / image_captions.html
Created August 7, 2013 16:19
Reference for image captions.
<!-- Pre HTML5 -->
<div class="img-caption" itemscope itemtype="http://schema.org/ImageObject">
<img src="" alt="" itemprop="contentURL">
<span itemprop="description">
Some image caption text.
</span>
</div>
<!-- Post HTML5 -->
<figure class="img-caption" itemscope itemtype="http://schema.org/ImageObject">
<?php
// Referrence: http://stackoverflow.com/questions/3161816/php-cut-a-string-after-x-characters
// Max allowed characters
$limit_max = 160;
// If limit exeeded, remove 3 characters to make room for trail
$limit_trail = $limit_max - 3;
@KruegerDesigns
KruegerDesigns / Placeholder-Polyfil
Created March 4, 2014 21:05
Placeholder jQuery Polyfil
<script type="text/javascript">
$(document).ready(function() {
//$('input').placeholder();
$('[placeholder]').focus(function() {
var input = $(this);
if (input.val() === input.attr('placeholder')) {
input.val('');
input.removeClass('placeholder');
}
}).blur(function() {
@KruegerDesigns
KruegerDesigns / typography.css
Created April 15, 2014 21:20
Basic Content Spacing, Typography, Baseline Grid
.global-inline-styles {
h2 {
padding-bottom: .35em;
margin-top:0;
margin-bottom:0;
}
h3 {
padding-top: .25em;
padding-bottom: .25em;
margin-top:0;
@KruegerDesigns
KruegerDesigns / play-pause.js
Created June 4, 2014 22:44
Pause all other HTML5 videos when a video is played
// Pause all other HTML5 videos when a video is played
$('video').click(function() {
$("video").each(function () { this.pause() });
});
@KruegerDesigns
KruegerDesigns / toggle-menu.js
Last active August 29, 2015 14:05
Toggle Menu for jQuery
// Hides the menu
$(".menu").hide;
// This toggles the menu's visibility on/off, with a fade feature
$( ".toggle-button" ).on( "click", function() {
event.stopPropagation();
$(".menu").fadeToggle( "fast" );
});
// This fades out the menu when the user clicks outside of the menu area
@KruegerDesigns
KruegerDesigns / image-resolutions.js
Last active August 29, 2015 14:10
See which images were resized. Great for CMS sites where the client uses a full resolution image.
window.onload = function() {
// All images on page as an array
var image = document.images;
// Loop trough each image and return its height/width values
for (var i = image.length - 1; i >= 0; i--) {
image[i].style.outline = "3px solid orange";
image[i].scrollIntoView();
alert("Image height: " + image[i].height + "px \n" + "Image width: " + image[i].width + "px \n" + "Original height: " + image[i].naturalHeight + "px \n" + "Original width: " + image[i].naturalWidth + "px \n");
@KruegerDesigns
KruegerDesigns / gulpfile.js
Last active August 29, 2015 14:15
Start processing less files with this Gulp file! Also supports minified CSS and LiveReload watching.
// Run "npm init" and fill out the wizard
// Then run the following to install all dependancies:
// npm install gulp gulp-util gulp-plumber gulp-less gulp-cssmin gulp-concat gulp-rename gulp-livereload
// Include gulp
var gulp = require('gulp');
// Include Our Plugins
var gutil = require('gulp-util');
var plumber = require('gulp-plumber');
@KruegerDesigns
KruegerDesigns / email_validation
Created March 23, 2015 23:04
Simple and lightweight jQuery email validation.
<!-- Add the styles below to your CSS file -->
<style>
input.email-error {
color: #C24C4C;
}
</style>
<!-- Add the jQuery below to your Javacript file -->
<script>
$(document).ready( function(){