Skip to content

Instantly share code, notes, and snippets.

@mbjordan
mbjordan / sticky-on-scroll.css
Created February 14, 2012 13:07
Simple jQuery Sticky-on-Scroll Navigation
#wrapper { position: relative; }
/* Aside in non-scroll mode */
aside {
float: left; /* Keeps the aside to the left and on top */
margin-top: 5px;
padding: 15px 0 15px 8px;
width: 267px;
}
@mbjordan
mbjordan / mobileNav.js
Created November 19, 2012 15:01
mobileNav.js, an alternative to tinyNav.js without markup assumption
/*
mobileNav.js by Matt Jordan.
*/
(function ($) {
$.fn.mobileNav = function (mobileWidth) {
// Create the <select> element
var selectHTML = '<select name="mobileNav" id="mobileNav" style="display:none">',
currentHref = window.location.href,
checkSize = function () {
@mbjordan
mbjordan / slugify.js
Created August 28, 2013 21:59
Create a URL-friendly string on multiple string, as a list. Returns an Array.
var Return;
function slugify(){
var O = Array.prototype.slice.call(arguments),
t = [],
x = 0,
i;
for (i in O){
if (O.hasOwnProperty(i) && typeof O[i] === "string"){
function listOrArray(Arr) {
var List = Array.prototype.slice.call(arguments, 1),
i;
// If `List` is not empty, assume there are more module objects sent as List Arguments
if (List.length > 0) {
List.unshift(Arr);
Arr = List;
} else {
// No List args in sight, treat the first arg `Arr` as an array and loop through it.
@mbjordan
mbjordan / read-hash.js
Created July 17, 2013 22:13
Simply read the hash both on page load and for every hash change.
window.onhashchange = doChange;
window.onload = doChange;
function doChange() {
var _hash = window.location.hash.replace("#!", "");
console.log(_hash);
}
@mbjordan
mbjordan / sprint-tests.js
Last active December 18, 2015 15:49
SPrint.js - s[tring]print
// ------------ Tests
var s0,
s1;
// Ordered Array mode
s0 = sprint("This is %s %s call, using an %s in order", "a", "function", "array");
@mbjordan
mbjordan / no-class.js
Created December 6, 2012 17:10
no-class.js
var MyLib = {
vars: {
var1: 'value1',
var2: 'value2'
},
func1: function () {
return this.vars.var1;
},
func2: function () {
alert("This is func2");
@mbjordan
mbjordan / broncos-blue.txt
Last active October 13, 2015 06:37
Broncos Web Colors
#001F52
@mbjordan
mbjordan / ref-mask.php
Created November 19, 2012 13:06
HTTP Referral Masking
<?php
session_start();
/**
Setp 1. Get the query string variable and set it in a session, then remove it from the URL.
*/
if (isset($_GET['to']) && !isset($_SESSION['to'])) {
$_SESSION['to'] = urldecode($_GET['to']);
header('Location: http://yoursite.com/path/to/ref-mask.php');// Must be THIS script
exit();
@mbjordan
mbjordan / styleNumber.js
Created November 13, 2012 19:42
Style a number
function styleNumber(number, precision) {
if (number.toString().length >= 4) {
var place = 1;
if (precision !== undefined && precision === 1) {
place = 10;
} else if (precision === 2) {
place = 100;
}
number = ((number / 100) / 10) * place;
number = Math.round(number) / place + ' k';