Skip to content

Instantly share code, notes, and snippets.

View roseg43's full-sized avatar

Gabriel Rose roseg43

View GitHub Profile
<?php
/* When a form is submitted, create two custom posts */
function after_gform_submit($entry, $form) {
$isInteraction = false;
$interaction_type_id;
$supporter_email_id;
foreach($form["fields"] as $field) {
if ( $field["label"] == "Interaction Type" ) {
@roseg43
roseg43 / slicky.js
Created September 3, 2014 22:04
Basic slider designed to be integrated with WordPress Visual Composer.
/**
* @author Gabe Rose (gabe.s.rose@gmail.com)
* Plugin Description:
* This is a simple slider plugin designed to be used in WordPress Visual Composer to make easily customizable sliders.
* @TODO: Reduce specifity so it can actually be used separate builds.
*/
var index = 1,
maxIndex = 3,
newIndex,
@roseg43
roseg43 / navimate.js
Created December 2, 2014 13:15
Animated nav for single-page navigations
$(function() {
var $navItems = $('li');
var $offsets = new Array();
var $widths = new Array();
var $activeOffset,
$activeWidth,
newPos;
$navItems.each(function() {
@roseg43
roseg43 / shoehorn.js
Created April 27, 2015 15:44
Bootstrap Panel Filtering
//TODO: turn into jQuery function
$(function() {
$('.mix').each(function(){$(this).addClass('active');});
$('.filter select').change(function() {
var filter = $(this).val().toLowerCase();
var $filterEls = $('.mix');
$filterEls.each(function() {
var isHidden = false;
var filterVal = $(this).data('filter').toLowerCase();
if (filter == 'all') {
@roseg43
roseg43 / bannerMask.jquery.js
Created February 18, 2016 15:37
Dynamic Slanted SVG-clip Banners
(function($) {
var index = 0;
var window_width = $('body').outerWidth();
$.fn.polygonMask = function(direction) {
var $this = $(this),
height = $this.outerHeight(),
offset_top = $this.offset().top;
@roseg43
roseg43 / jquery.scheduleManager.js
Created August 30, 2016 14:38
Custom calendar schedule manager that manages selection states and passes selected objects as JSON to a PDF generator.
(function ($) {
// An array of presentationTimeslots
var slots = [];
function presentationTimeslot(el) {
// So that we always have a global object scope that can't be tainted by local scopes
var self = this;
this.$el = $(el);
this.$parentTable = this.$el.parents('table');
@roseg43
roseg43 / jquery.anchorNavigation.js
Created December 13, 2016 20:25
A small class that creates a list of page-scrolling anchors based on sections with data-nav-title set.
function anchorNavigation(el) {
var self = this;
this.$el = jq(el);
this.$navigableItems = jq('[data-nav-title]');
this.$el.append('<ul />');
this.$navigationList = this.$el.find('ul');
this.navigationItems = [];
@roseg43
roseg43 / versionStringRemover.py
Last active March 12, 2019 15:29
A small command-line script to remove version strings from filenames and filename references in directories. Useful for parsing wget scrapes.
import os, re, sys
print ("Asset Renamer v1 ::::::::::::::")
def replaceVersionsInFile(file):
#This regex matches all href and src attributes and finds version strings that either use question marks of the unicode string %3
pattern = "(?:href=[\"\']?([^\"\'>]+)[\"\']?|src=[\"\']?([^\"\'>]+)[\"\']?)([\']?(?=.*%3?)[^\"\']*)|(.*(?=.*\?)[^\"\']*)"
fo = open(file, 'r+');
text = fo.readlines()
fo.seek(0)
fo.truncate()
for line in text:
@roseg43
roseg43 / chartist-plugin-htmllabels.js
Created September 17, 2019 16:08
Allows for custom HTML labels in a ChartistJS chart.
// HTML Label plugin
Chartist.plugins = Chartist.plugins || {};
Chartist.plugins.ctHtmlLabels = function(options) {
return function(chart) {
chart.on('draw', function(context) {
if (context.type === 'label') {
// Best to combine with something like sanitize-html
context.element.empty()._node.innerHTML = context.text;
}
});
@roseg43
roseg43 / _flex-grid.scss
Created December 10, 2019 20:30
Basic SCSS Flexbox Grid
/**
* Basic Flex Grid
* ----------------
* This is a simple flex grid I've been using on a lot of projects. It supports both
* flexible grids as well as rigid column grids. While this is currently designed for internal use
* (it uses flexbox mixins because our build pipeline doesn't support autoprefixer yet), it's not too difficult
* to use in your own projects. Simply replace the flexbox mixins with their relevant rules, and you'll be good
* to go.
* @author Gabe Rose <https://gist.github.com/roseg43>
**/