Skip to content

Instantly share code, notes, and snippets.

@alison-mk
alison-mk / activate-pagination.js
Created December 7, 2016 23:50
Custom script for Coffee Fest. Activates prev/next pagination for each schedule day when more than 6 events exist per day. Visible in action here: https://www.coffeefest.com/venues/details/coffee-fest-nashville-2017#schedule
// Activate pagination when more than 6 events display per day
function pagination() {
var schedulerEvent = $('#events .event');
var prevButton = $('#events .prev');
var nextButton = $('#events .next');
var currentPage = "page_1"; // begin as statically defined, will always start on page_1
// If user is on page 1, add inactive class to Prev link
function disablePrev() {
if (currentPage === "page_1") {
@alison-mk
alison-mk / background-color.scss
Created February 1, 2016 18:50
Sass file that pairs with background-color.js gist, animates background color on scoll. Can be seen live here: http://alisonleemckay.com/
// Basic variables
$header-font: 'Playfair Display', serif;
$body-font: 'Roboto', Arial, sans-serif;
$color1: #A8EBFF;
$color2: #FFE2E5;
$color3: #BAEDC6;
$navy: #334D70;
$link-color: #269196;
@alison-mk
alison-mk / background-color.js
Last active February 1, 2016 18:48
Script to change change background color on scroll. Pairs with scss gist background-color.scss. Can be seen live here: http://alisonleemckay.com/
$(function() {
changeBg();
});
function changeBg() {
window.addEventListener('scroll', function(e){
var distanceY = window.pageYOffset || document.documentElement.scrollTop;
var color2 = 250;
var color3 = 750;
var body = $("body");
@alison-mk
alison-mk / menu-accordion.scss
Last active January 10, 2016 01:48
Menu Accordion: Hide/Show on click for sidebar menu items. Works in tandem with coordinated script, posted to my gist account as menu-accordion.js. Full menu can be seen in action here: http://www.leefoil.com/
.efelle-menu {
margin: 0;
padding: 0;
text-align: center;
font-size: 15px;
li {
display: block;
margin: 0;
width: 100%;
@alison-mk
alison-mk / age-verification.js
Last active June 17, 2023 23:37
Age verification cookie: Check cookie on every page load, display pop up window if no cookie is found. In every instance, set cookie to expire after one day. Live and in action here: http://www.leefoil.com/
ageVerify: function() {
function setCookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000));
var expires = "expires="+d.toUTCString();
document.cookie = cname + "=" + cvalue + "; " + expires;
}
function getCookie(cname) {
var name = cname + "=";
@alison-mk
alison-mk / menu-accordion.js
Last active January 10, 2016 01:46
Menu Accordion: Hide/Show on click for sidebar menu items. Works in tandem with coordinated SCSS, posted to my gist account as menu-accordion.scss. Full menu can be seen in action here: http://www.leefoil.com/
menuAccordion: function() {
var subMenu = $('.main-mnu li.is-parent ul'); // Grab sub-menu element
var parentLi = $('.main-mnu li.is-parent'); // Grab parent list item
var collapsed = true; // Set to true on page load
$(subMenu).addClass('collapsed'); // Hide sub-menu on page load
if (parentLi) {
// Add <button> to parent, attaching expand/collapse icon with CSS
$('.main-mnu li.is-parent>a').append('<button></button>');
@alison-mk
alison-mk / client.js
Last active January 10, 2016 01:25
Access an Endpoint
// Objective: access endpoint on server, created by Express
$(function() {
// On click of button, execute following function
$('button').on('click', function() {
// Use jQuery $.get AJAX request to pull JSON feed
$.get('/dinosaurs', function(data) {
// Write random dinosaur into page within a <span> tag
$('span').html(data.dinosaur);
});
@alison-mk
alison-mk / server.js
Created June 15, 2015 06:11
Create an Endpoint
// Objective: create an endpoint using app.get that sends a JSON object
// Set /dinosaurs as endpoint
app.get("/dinosaurs", function (req, res){
// Assign dinosaur as JSON object, pull a random dinosaur out of array of dinos
res.json({dinosaur: array[randomNumber]});
});
// Array of dinosaurs
var array = [ "Stegosaurus", "Tyrranosaurus", "Velociraptor", "Triceratops"];