Skip to content

Instantly share code, notes, and snippets.

View brianweiner's full-sized avatar

Brian Weiner brianweiner

  • Fixt
  • Baltimore, MD
View GitHub Profile
@brianweiner
brianweiner / keybase.md
Created November 28, 2016 17:52
Keybase declaration

Keybase proof

I hereby claim:

  • I am brianweiner on github.
  • I am brianweiner (https://keybase.io/brianweiner) on keybase.
  • I have a public key ASAX9LrQjmZZftaSPZnI6FHbiJKG_ZjxlxxVGI5Ej3xCdwo

To claim this, I am signing this object:

@brianweiner
brianweiner / search-filter.js
Created January 30, 2013 14:52
Search filter javascript
$(document).ready(function() {
$("#search-filter").bind("submit", function(event){
event.preventDefault();
$.ajax({
url: '/ajax/search',
data: $(this).getForm().serialize(),
success: function(data){$('#product-list').html(data)},
dataType: 'html'
});
});
@brianweiner
brianweiner / search-filter-category-subsection.html
Last active December 11, 2015 11:38
subsection of search-filter-partial for category behavior
<!-- FIND CATEGORY -->
{% if selected_categories is defined %}
{% set current_category = method('Extensions320ny_Shop_Category', 'create').find_by_id(selected_categories[0]) %}
{% else %}
{% set current_category = category ? category : product.list_categories[0] %}
{% endif %}
<form id="search-filter" method="get" action="/search">
<input type="hidden" name="query" value="{{ query ? query: '' }}">
<!-- CATEGORIES -->
{% set categories = method('Shop_Category', 'create').list_root_children('front_end_sort_order') %}
@brianweiner
brianweiner / shop;search_filter_form.html
Last active December 11, 2015 11:39
Lemonstand ajax search filter example
<section class="search-filter pull-left clearfix">
<!-- FIND CATEGORY -->
{% if selected_categories is not defined %}
{% set my_cat = category ? method('Extensions320ny_Shop_Category', 'create').find_by_id(category.id) : ''%}
{% set selected_categories = category ? [category.id] : [] %}
{% endif %}
<form id="search-filter" method="get" action="/search">
<input type="hidden" name="query" value="{{ query ? query: '' }}">
@brianweiner
brianweiner / stripe_conditional_response_handler.js
Created January 11, 2013 23:12
Stripe response handler with conditional assignment
$(document).ready(function() {
$("#payment-form").submit(function(event) {
// disable the submit button to prevent repeated clicks
$('.submit-button').attr("disabled", "disabled");
Stripe.createToken({
number: $('.card-number').val(),
cvc: $('.card-cvc').val(),
exp_month: $('.card-expiry-month').val() || "0",
exp_year: $('.card-expiry-year').val() || "0"
@brianweiner
brianweiner / stripe_response_handler.js
Last active December 11, 2015 00:09
stripe response handler
function stripeResponseHandler(status, response) {
if (response.error) {
...
// show the errors on the form
$(".payment-errors").text(response.error.message);
$(".submit-button").removeAttr("disabled");
} else {
var form$ = $("#payment-form");
// token contains id, last4, and card type
var token = response['id'];
@brianweiner
brianweiner / stripe-payment-submit.js
Created January 11, 2013 22:58
stripe basic payment form on submit token creation
$(document).ready(function() {
$("#payment-form").submit(function(event) {
// disable the submit button to prevent repeated clicks
$('.submit-button').attr("disabled", "disabled");
Stripe.createToken({
number: $('.card-number').val(),
cvc: $('.card-cvc').val(),
exp_month: $('.card-expiry-month').val(),
exp_year: $('.card-expiry-year').val()
@brianweiner
brianweiner / search_filter_partial_size_only.html
Last active December 11, 2015 00:09
search_filter_partial - size only
<h4>Size</h4>
{% set option_values = category ? my_cat.list_unique_product_option_values('Size') : method('Shop_CustomAttribute','list_unique_values','Size') %}
{% set selected_size = selected_options['Size'] ? selected_options['Size'] : [] %}
<input type="hidden" name="option_names[]" value="Size"/>
<select style="display:none" id="size-select" class="search-filter-select" name="option_values[]">
<option value=""><strong>Choose Size</strong></option>
{% for value in option_values %}
<option
{{ option_state(value, attribute(selected_options, 'Size')) }}