Skip to content

Instantly share code, notes, and snippets.

View Patrick64's full-sized avatar
🦆
All good!

Patrick Woodcock Patrick64

🦆
All good!
View GitHub Profile
@Patrick64
Patrick64 / submit_form_to_new_window.js
Created June 27, 2011 15:47
JQuery: Include this javascript in your page so when the user submits a form their browser opens a new window with the form contents in the querystring.
//open a new window with form fields put in querystring, rather than submit form
$('document').ready(function() {
$('form').submit(function() {
var url = $(this).attr('action') + '?' + $(this).serialize();
window.open(url);
return false; // dont submit form
});
});
@Patrick64
Patrick64 / reefine_tree_groups_example.html
Created September 28, 2015 08:10
Example of tree groups in reefine taken from shop theme
{tree_groups}
<div class="reefine_tree">
<h3 class="group_{group_name}">{label}</h3>
<ul>
{filters}
<li class="{filter_active_class} filter-id-{filter_id} {has_active_subfilters_class}">
<a href="{url}" aria-selected="{filter_active_boolean}" rel="nofollow">{filter_title} ({filter_quantity})</a>
{subfilters_1}
<ul>
{filters_1}
@Patrick64
Patrick64 / reefine-filter-events-by-month.html
Last active December 30, 2015 22:09
Reefine filter events by month
{exp:reefine
channel="event"
filter:type:category_group="1"
filter:type:join="none"
filter:month:type="month_list"
filter:month:fields="event_from|event_to"
filter:month:join="none"
filter:month:where_after="{current_time}"
parse="inward"
url="/{segment_1}/{type}/{month}"
@Patrick64
Patrick64 / Reefine-hello-world.html
Created December 10, 2013 15:56
Clothes shop example for Reefine
{exp:reefine channel="clothes" parse="inward" theme="shop"
filter:fields="title|product_type|size|colour|price"
filter:price:type="number_range"
url="/{segment_1}/{segment_2}/{product_type}/{size}/{colour}/{price}/{title}"}
{entries}
{if entry_ids=='-1'} <p>No matching products found.</p> {/if}
{exp:channel:entries entry_id="{entry_ids}"
disable="categories|category_fields|member_data" dynamic="no"
orderby="title" sort="asc" status="not closed" limit="8"
paginate="yes"}
@Patrick64
Patrick64 / reefine-number-range-links
Created January 24, 2014 15:26
Example of using a list of links instead of textboxes for the number range
@Patrick64
Patrick64 / image_bg_css.html
Last active November 28, 2018 15:29
Tempalte snippet for making a response image background to minimise download size using CE Image. #eecms
{!--
Template snippet image_bg_css.html
This tempalte snippet is for making a response image background to minimise download size using CE Image.
Usage:
{embed="include/image_bg_css" class="div-class" src="{image_url}" max="800"}
^ ^ ^ ^
| | | |
location of this template Class of div URL of image Max image size
@Patrick64
Patrick64 / response_image.html
Created December 11, 2018 09:33
response_image.html #eecms ce_image
{!--
Template snippet
This tempalte snippet is for making a response image to minimise download size using CE Image.
Usage:
{embed="include/responsive_image" class="div-class" src="{image_url}"}
^ ^ ^
| | |
/**
* Set font size so the text fits the width of the container
*/
function setupTitleTextFill(container, textElement) {
// make element inline block and wrap a div so it still does a line break
$(container + " " + textElement).css("display","inline-block").wrap('<div class="title-text-fill-wrapper"></div>');
resizeTitleTextFill(container, textElement);
$(window).resize(function() {
resizeTitleTextFill(container, textElement);
function resizeVideos() {
var $allVideos = $("iframe[src^='https://player.vimeo.com'], iframe[src^='https://www.youtube.com'], object, embed");
$allVideos.each(function() {
$(this)
// jQuery .data does not work on object/embed elements
.attr('data-aspectRatio', this.height / this.width)
.removeAttr('height')
.removeAttr('width');
function smoothAnchorScroll() {
// https://www.abeautifulsite.net/smoothly-scroll-to-an-element-without-a-jquery-plugin-2
$('a[href*="#"]').on('click', function(event) {
if (this.getAttribute('href') == "#") return;
var target = $(this.getAttribute('href'));
if( target.length ) {
// event.preventDefault();
$('html, body').stop().animate({
scrollTop: target.offset().top
}, 1000);