Skip to content

Instantly share code, notes, and snippets.

View mdcpepper's full-sized avatar

Mike Pepper mdcpepper

View GitHub Profile
@mdcpepper
mdcpepper / jquery.ul_to_select.js
Created July 6, 2009 13:47
jQuery function for converting an unordered list of links to a select element 'jumpbox'
jQuery.fn.ul_to_select = function(){
return this.each(function(){
var select_box = document.createElement('select');
select_box.id = this.id + '_select'
this.parentNode.insertBefore(select_box, this);
$('<option></option>').html('Choose...').appendTo('#'+select_box.id);
$(this).find('li a').each(function(link){
$('<option></option>').html(this.innerHTML).attr('value', this.href).appendTo('#'+select_box.id);
});
this.parentNode.removeChild(this);
@mdcpepper
mdcpepper / bacs.php
Created June 23, 2011 07:48
A simple BACS payment gateway for Jigoshop. Just drop in to the gateways directory in the plugin.
<?php
/*
Provides a BACS Payment Gateway.
Created by Mike Pepper ([email protected])
Based on the cheque gateway created by Andrew Benbow ([email protected])
*/
class jigoshop_bacs extends jigoshop_payment_gateway {
public function __construct() {
$query = craft()->elements->buildElementsQuery();
$query->andWhere(DbHelper::parseDateParam("content.field_eventStart", '>='.$startDate, $query->params));
$query->andWhere(DbHelper::parseDateParam("content.field_eventEnd", '<='.$endDate, $query->params));
$results = $query->queryAll();
{% set excludedIds = [] %}
{% set allProducts = craft.entries.section('products') %}
{% for product in allProducts %}
{% if product.productCategories|length %}
{% set excludedIds = excludedIds|merge(['not '~product.id]) %}
{% endif %}
{% endfor %}
{% set products = craft.entries.section('products').id(excludedIds).limit(null) %}
{# news/_entry.twig #}
{% block breadcrumbs %}
{{ macro.breadcrumbs(entry, { parent: craft.entries.id(45).first() }) }}
{% endblock %}
{% macro datesBetween(startDate, endDate, currentDate = null) %}
{% import _self as self %}
{# initialize the currentDate from the startDate #}
{% if currentDate is null %}
{% set currentDate = startDate %}
{% endif %}
{# echo the current date, or the startDate if it's the first run #}
<li>{{ currentDate }}</li>
{% set searchTerm = craft.request.getParam('search') %}
{% set entries = craft.entries.hideFromSearchResults([0]).search(searchTerm).limit(25) %}
{% if searchTerm and entries|length %}
{% paginate entries as page %}
{% for entry in page %}
{% include [ entry.section.handle~"/_excerpt-search",
"pages/_excerpt-search",
"_errors/template-missing-search" ] %}
{% endfor %}
{% set navElements = { 1: 'section', 2: 'article' } %}
{% nav entry in entries %}
{# fetch the HTML element matching the entry level #}
<{{ navElements[entry.level]|default('div') }}>
{{ entry.content }}
{% ifchildren %}
{%- if currentUser.admin
or (
( entry.authorId == currentUser.id and currentUser.can('editEntries:' ~ entry.section.id) )
or ( entry.authorId != currentUser.id and currentUser.can('editPeerEntries:' ~ entry.section.id) )
or (
entry.section.type == 'Single' and
( entry.authorId == currentUser.id and currentUser.can('editEntries:' ~ entry.section.id) )
or ( entry.authorId != currentUser.id and currentUser.can('editPeerEntryDrafts:' ~ entry.section.id) )
)
)
@mdcpepper
mdcpepper / designer.html
Last active August 29, 2015 14:06
designer
<link rel="import" href="../google-map/google-map.html">
<link rel="import" href="../paper-tabs/paper-tabs.html">
<link rel="import" href="../paper-tabs/paper-tab.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;