Skip to content

Instantly share code, notes, and snippets.

View adamculpepper's full-sized avatar

Adam Culpepper adamculpepper

View GitHub Profile
@adamculpepper
adamculpepper / ajax-form-submit.js
Last active August 29, 2015 14:08
AJAX form submission (using FormKeep & requires jQuery)
//Simple form
$("form").submit(function(e) {
e.preventDefault();
$.ajax({
type: 'POST',
url: 'https://formkeep.com/f/7212a0cb4563',
data: $(this).serialize(),
success: function() {
//window.location = "http://google.com";
@adamculpepper
adamculpepper / search-page-body-class.js
Created October 20, 2014 21:44
Body class added on Search results page (Business Catalyst, requires jQuery)
if (url.search("Default.aspx?A=Search")) {
$("body").addClass("search");
}
@adamculpepper
adamculpepper / business-catalyst-secure-redirect.js
Created October 20, 2014 21:42
Redirect if protocol is secure, but not coming from the store (Business Catalyst, requires jQuery)
// Coming from secure protocol and user is NOT inside the store, redirect to a non-secure connection
if (location.protocol == "https:") {
if (url.search("worldsecuresystems.com") < 0) {
location.protocol = "http:";
}
}
@adamculpepper
adamculpepper / url-body-classes.js
Created October 20, 2014 21:37
Split Up URL slugs, add as body classes
var loc = window.location;
var url = (location.href);
loc.origin || (loc.origin = loc.protocol + '//' + loc.host);
url = url.split('?')[0];
var slugs = $.trim((url.replace(loc.origin, '')).split("/").join(" "));
if (slugs == "") {
slugs = "home";
}
@adamculpepper
adamculpepper / current-year.js
Created October 20, 2014 17:52
Current Year
var year = new Date().getFullYear();
@adamculpepper
adamculpepper / break-iframes.js
Created October 20, 2014 13:36
Break out of iframes
// Break out of iframes
if (window != window.top) {
top.location.href = location.href
}
@adamculpepper
adamculpepper / center.target.js
Last active August 29, 2015 14:07
Center an element to another element
// demo: http://jsfiddle.net/adamculpepper/9bf2r9uj
centerElement($(".center-it.me"), $(".center-it.to"));
function centerElement(me, to) {
var toWidth = to.outerWidth();
var meWidth = me.outerWidth();
var meCenter = Math.abs(meWidth / 2) - (toWidth / 2);
me.css({
@adamculpepper
adamculpepper / ee-body-classes.html
Last active August 29, 2015 14:07
ExpressionEngine Body Class Clean-up (cleans up all the tabs and break lines so the classes are all on one line)
<!--
Stash: http://devot-ee.com/add-ons/stash
Strip Line Breaks: http://devot-ee.com/add-ons/strip-line-breaks
Low Replace: http://devot-ee.com/add-ons/low-replace
-->
{exp:stash:set parse_tags="yes" parse_conditionals="yes" parse_depth="5" type="snippet"}
{exp:strip_line_breaks}
{stash:body_classes}
{exp:low_replace find="\t" replace="" regex="yes"}
// Slightly modified version of Angular's method of checking for Internet Explorer (IE), including checking for IE11
function detectIE() {
// check 6-10
msie = parseInt((/msie (\d+)/.exec((navigator.userAgent).toLowerCase()) || [])[1]);
if (isNaN(msie)) {
// not 6-10, check 11
msie = parseInt((/trident\/.*; rv:(\d+)/.exec((navigator.userAgent).toLowerCase()) || [])[1]);
}
@adamculpepper
adamculpepper / stylish-css.css
Last active August 29, 2015 14:06
Stylish CSS Outlines
/* Formatted for GitHub */
a {outline:1px dotted #D68A85!important;}
h1, h2, h3, h4, h5, h6 {outline:1px dotted #E7912D!important;}
li {outline:1px dotted #CECC33!important;}
span {outline:1px dotted #F0F!important;}
div {outline:1px dotted #3AB6F1!important;}
ul, ol {outline:1px dotted #8684D8!important;}
li {outline:1px dotted #DD67AE!important;}
table td {outline:1px dotted lightblue!important;}
i {outline:1px dotted gray!important;}