Skip to content

Instantly share code, notes, and snippets.

View AndrewHaine's full-sized avatar
🇬🇧
Building

Andrew Haine AndrewHaine

🇬🇧
Building
View GitHub Profile
@AndrewHaine
AndrewHaine / index.js
Last active February 6, 2024 05:43
Infinite Craft Save/Restore Buttons
/**
* Add save/restore buttons to Infinite Craft
* Works by saving the elements that you have created into localStorage
*
* Remember to hit `Save` before closing your tab, Happy Crafting!
*/
const saveElements = () => {
localStorage.setItem('saved-elements', JSON.stringify(window.$nuxt.$children[2].$children[0].$children[0].$data.elements));
}
<?php
namespace App\Tags;
use Statamic\Tags\Tags;
class ParentCategoryBreadcrumbs extends Tags
{
/**
* The {{ parent_category_breadcrumbs }} tag.
@AndrewHaine
AndrewHaine / slider.js
Created May 3, 2021 15:08
GlideJS AutoHeight functionality
/**
* glideInstance here is the instance of Glide (created via const glideInstance = new Glide(...))
* sliderElement here is the top-level container element, used for searching for glide elements within
*/
glideInstance.on(['mount.after', 'run.after'], () => _glideHandleHeight(sliderElement));
/**
* @param {HTMLElement} slider
*/
@AndrewHaine
AndrewHaine / HappyBreadcrumbsTags.php
Created March 19, 2021 11:05
Statamic breadcrumbs with taxonomy index pages excluded
<?php
namespace App\Tags;
use Statamic\Facades\Data;
use Statamic\Facades\Site;
use Statamic\Facades\URL;
use Statamic\Support\Str;
use Statamic\Tags\Tags;
use ReflectionClass;
@AndrewHaine
AndrewHaine / helpers.js
Created February 27, 2018 22:02
Common helper functions for front end javascript projects
/**
* A collection of good helper/utility functions
* that may be required in a project
*
* Andrew Haine - 2018
*/
/**
* Using CSS transforms in JavaScript? You'll need to stick some vendor prefixes in there
* @param {Object} el The element to transform
@AndrewHaine
AndrewHaine / parallax.js
Last active April 4, 2017 21:11
Smooth background image parallax effect - requires jquery
class Parallax {
constructor(el) {
if(!el.length) {
return;
}
else {
this._doParallax(el);
}
}
@AndrewHaine
AndrewHaine / UserFormsSubmissionExtension.php
Last active April 10, 2017 21:28
Silverstripe UserForms extension for custom submission summary fields
<?php
class UserformsSubmissionExtension extends DataExtension
{
/**
* Update Fields
* @return FieldList
*/
public function updateCMSFields(FieldList $fields)
{