Skip to content

Instantly share code, notes, and snippets.

View mattborn's full-sized avatar
🥃
Slow and steady…

Matt Born mattborn

🥃
Slow and steady…
View GitHub Profile
// Simple Input Focus Clear Value
$(document).ready(function() {
$('input#name').focus(function() {
if ($(this).val() == 'Have an account?') {
$(this).val('').addClass('change-style');
}
});
/* Clear 'dem Fields by Matthew Born */
$('input[type=text]').focus(function(){
if(!$(this).attr('placeholder')){
if(!$(this).val()){
$(this).attr('placeholder', ' ');
$(this).val('').addClass('active');
} else {
$(this).attr('placeholder', $(this).val());
$(this).val('').addClass('active');
}
/* Anchor Slide by Matthew Born */
$('.slide a').click(function(){
var anchor = $(this).attr('href');
$('html,body').animate({scrollTop: $(anchor).offset().top},'slow');
});
/* Tooltips */
$('h3 a').hover(function(){
if($(this).attr('title')){
$(this).append($('<div class="tooltip">'+$(this).attr('title')+'</div>'));
}
}, function(){
$(this).find('div').remove();
});
(function($){
// Extend easing options.
$.extend( $.easing, { def: 'easeOutExpo',
easeOutExpo: function (x, t, b, c, d) {
return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
},
easeInOutExpo: function (x, t, b, c, d) {
if (t==0) return b;
if (t==d) return b+c;
@mattborn
mattborn / gist:1374533
Created November 17, 2011 21:08
Slim NextGen Gallery Template
<?php if ( ! defined ('ABSPATH') ) die ('No direct access allowed'); ?><?php if ( ! empty ( $gallery ) ) : ?>
<div id="gallery">
<?php foreach ( $images as $image ) : if ( ! $image->hidden ) : ?>
<a href="<?php echo $image->description ?>"><img alt="<?php echo $image->alttext ?>" src="<?php echo $image->imageURL ?>" /></a>
<?php endif; if ( $image->hidden ) continue; endforeach; ?>
</div><!-- #gallery -->
<?php endif; ?>
@mattborn
mattborn / gist:3099421
Created July 12, 2012 17:12
My preferred easing function
// Add easeOutExpo easing
$.extend($.easing, { def: 'easeOutExpo',
easeOutExpo: function(x, t, b, c, d){
return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
}
});
@mattborn
mattborn / gist:5068555
Last active December 14, 2015 09:59
dotjs page navigation via arrow keys on thecodinglove.com save as ~/.js/thecodinglove.com.js + make sure your using the dotjs chrome extension
$(window).keydown(function(e){
var next = parseInt(location.pathname.split('/')[2])+1 || 2;
var prev = parseInt(location.pathname.split('/')[2])-1;
if (e.which === 39) {
document.location.href = ('/page/'+next);
} else if (e.which === 37) {
document.location.href = ('/page/'+prev);
}
});
@mattborn
mattborn / gist:5311578
Created April 4, 2013 15:48
Recent concept of Backbone router for Redemption.
define(['jquery', 'lodash', 'backbone', 'moment'],
function($, _, Backbone) {
var Router = Backbone.Router.extend({
routes: {
'visit': 'visit',
'connect': 'connect',
'events': 'events',
'sermons': 'sermons',
'*actions': 'default'
}
@mattborn
mattborn / work
Created February 25, 2014 22:27
Automating opening apps for work
#!/bin/bash
apps=( Tunnelblick Calendar Evernote Hall Messages SourceTree Spotify Sublime\ Text\ 2 )
for app in "${apps[@]}"
do
echo Opening "$app".
open /Applications/"$app".app
done