Skip to content
This repository was archived by the owner on Aug 30, 2018. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
d7d5ad5
Setup drawer skeleton
cshold Feb 12, 2015
8df785e
Remove unneeded ajax cart toggle methods
cshold Feb 12, 2015
6da3b03
Fully removed flip method. New mobile-nav snippet. Updated mobile header
cshold Feb 12, 2015
283ea6a
Remove modal support. Add function to run when drawer opens
cshold Feb 12, 2015
ed6ddca
Stripped more ajax js away. Returned to familiar timber header layout
cshold Feb 12, 2015
bb2224d
Removed more unneeded settings/js vars
cshold Feb 12, 2015
10c4594
More deletions. Less complexity
cshold Feb 12, 2015
35ad2c8
Drawer header styles
cshold Feb 13, 2015
e53e348
Drawer header style updates
cshold Feb 13, 2015
12c890a
Mobile nav styles
cshold Feb 13, 2015
25fe36a
Mobile nav toggle JS
cshold Feb 13, 2015
637048d
Minor drawer styling updates
cshold Feb 13, 2015
3e124a1
Removed more unused code. New ajax cart layout.
cshold Feb 13, 2015
d5ee3a6
Nicer hit areas on mobile nav with new styles
cshold Feb 13, 2015
929a0d1
External callback for opening cart drawer. Removed unused label
cshold Feb 17, 2015
d640009
Move search bar to header above nav
cshold Feb 17, 2015
ed90880
Login/logout/search moved to mobile nav
cshold Feb 17, 2015
fa183de
Mobile subnav and cart css animations
cshold Feb 17, 2015
cb98772
Unified thickness of some icons
cshold Feb 17, 2015
11ef9b8
Minor Windows style fixes
cshold Feb 18, 2015
e19aba8
Drawer cart grid spacing
cshold Feb 18, 2015
93924c4
Big clean of drawer styles, flexible by color. Merged ajax cart style…
cshold Feb 19, 2015
8bf2bb5
Fix drawer page scroll issue
cshold Feb 19, 2015
8f6759b
Minor link and cart page style updates
cshold Feb 19, 2015
b3099c2
New mobile subnav animation
cshold Feb 19, 2015
2563945
Remove item from cart animation
cshold Feb 19, 2015
d0be940
Minor style updates
cshold Feb 19, 2015
7fea2b5
Revert changed unecessary to this PR
cshold Feb 19, 2015
4a670fd
Fixed qty/price alignment in cart drawer
cshold Feb 19, 2015
9617533
Remove is-added and is-adding class on button if errors occur
cshold Feb 19, 2015
c10280e
Updated form submission syntax
cshold Feb 19, 2015
a2a68c5
Syntax fix on last commit
cshold Feb 19, 2015
bee9aea
Comment for source of drawer JS
cshold Feb 23, 2015
d505bc8
Version bump
cshold Feb 23, 2015
81fde43
Fix input border colours in drawer
cshold Feb 23, 2015
e68f285
Removed unused strings
cshold Feb 23, 2015
8f41624
Organize z-index in variables
cshold Feb 24, 2015
94add3b
Removed data attributes no longer needed on cart template
cshold Feb 24, 2015
255178c
Organized afterCartLoad placement
cshold Feb 24, 2015
828ea54
Switch to custom events for after cart callback
cshold Feb 25, 2015
82d8d73
Added translation to drawer elements
cshold Feb 26, 2015
920a43e
Proper event delegation
cshold Mar 3, 2015
38afcd9
Wrap additional checkout buttons in div, not p
cshold Mar 3, 2015
98087f6
Add cart note to ajax cart drawer
cshold Mar 5, 2015
cf666d3
Added optional vendor to ajax cart
cshold Mar 5, 2015
457451e
Renamed product meta class
cshold Mar 5, 2015
1e91951
Max image width fix
cshold Mar 6, 2015
398e5ab
Actual logo max width fix
cshold Mar 6, 2015
d0343f3
Specific class on logo for max-width fixe in FF
cshold Mar 6, 2015
7b897f9
Another minor icon font update
cshold Mar 6, 2015
6d059f5
Added dropdown arrow in nav
cshold Mar 6, 2015
98eca1f
Removed logo margins
cshold Mar 6, 2015
30e0e1d
Remove side padding on Paypal input buttons
cshold Mar 9, 2015
bfdb1b9
Using mixin for user-select
cshold Mar 10, 2015
ad0e856
New down arrow icon font (for sizing)
cshold Mar 11, 2015
7f3cd11
Sized down arrow in menu
cshold Mar 11, 2015
75d9dc0
Less specific drawer styles. Sidebar default list styles
cshold Mar 12, 2015
d23bd7f
Combined list styles properly
cshold Mar 12, 2015
d11cafa
Removed unneeded styles
cshold Mar 12, 2015
6881ee5
Allow html in handlebar prices
cshold Mar 12, 2015
1aa1721
Remove unused ajax cart helpers
cshold Mar 13, 2015
9eb509b
Remove conditional cart classes. Drawer transition var.
cshold Mar 13, 2015
bd70f85
Descriptive css comments
cshold Mar 13, 2015
1c63024
Temporarily revert to ajaxify.js.liquid
cshold Mar 16, 2015
286aa2d
Git renamed ajax-cart.js.liquid
cshold Mar 16, 2015
f9c046f
Proper git rename of ajax-cart with updates
cshold Mar 16, 2015
8cde711
Move formatMoney to always-present timber.js
cshold Mar 16, 2015
4c91d5c
Update drawer js comment
cshold Mar 17, 2015
6fa6f14
Rename ajax cart api functions
cshold Mar 13, 2015
abc2b76
Minor comment update about addItemFromForm method
cshold Mar 16, 2015
c2e7c1b
Removed formatMoney from ajax js. Lives in timber.js
cshold Mar 17, 2015
afad035
Make sure Shopify namespace exists in timber.js
cshold Mar 17, 2015
9ea7381
Merge pull request #3 from cshold/ajax-cart-api
cshold Mar 17, 2015
9af35c8
Slight update to api comments
cshold Mar 17, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
519 changes: 519 additions & 0 deletions assets/ajax-cart.js.liquid

Large diffs are not rendered by default.

1,151 changes: 0 additions & 1,151 deletions assets/ajaxify.js.liquid

This file was deleted.

690 changes: 0 additions & 690 deletions assets/ajaxify.scss.liquid

This file was deleted.

23 changes: 8 additions & 15 deletions assets/ico-select.svg.liquid
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 17.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Layer_1" x="0px" y="0px" width="8px" height="13px" viewBox="0 0 8 13" enable-background="new 0 0 8 13" xml:space="preserve">
<g>
<g>
<polygon fill="{{settings.color_borders}}" points="0,8 4,13 8,8 "/>
</g>
</g>
<g>
<g>
<polygon fill="{{settings.color_borders}}" points="4,0 0,5 8,5 "/>
</g>
</g>
</svg>
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 18.1.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
width="8px" height="5px" viewBox="0 0 8 5" enable-background="new 0 0 8 5" xml:space="preserve">
<path fill="{{settings.color_borders}}" d="M0,0c0,0,3.4,4.4,3.5,4.4C3.7,4.4,7.1,0,7.1,0H0z"/>
</svg>

Binary file modified assets/icons.eot
Binary file not shown.
515 changes: 295 additions & 220 deletions assets/icons.json

Large diffs are not rendered by default.

93 changes: 38 additions & 55 deletions assets/icons.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/icons.ttf
Binary file not shown.
Binary file modified assets/icons.woff
Binary file not shown.
201 changes: 190 additions & 11 deletions assets/timber.js.liquid
Original file line number Diff line number Diff line change
@@ -1,13 +1,64 @@
// Helper functions
function replaceUrlParam(url, paramName, paramValue) {
var pattern = new RegExp('('+paramName+'=).*?(&|$)'),
newUrl = url;
if (url.search(pattern) >= 0) {
newUrl = url.replace(pattern,'$1' + paramValue + '$2');
} else {
newUrl = newUrl + (newUrl.indexOf('?')>0 ? '&' : '?') + paramName + '=' + paramValue;
}
return newUrl;
/* Jonathan Snook - MIT License - https://github.com/snookca/prepareTransition */
(function(a){a.fn.prepareTransition=function(){return this.each(function(){var b=a(this);b.one("TransitionEnd webkitTransitionEnd transitionend oTransitionEnd",function(){b.removeClass("is-transitioning")});var c=["transition-duration","-moz-transition-duration","-webkit-transition-duration","-o-transition-duration"];var d=0;a.each(c,function(a,c){d=parseFloat(b.css(c))||d});if(d!=0){b.addClass("is-transitioning");b[0].offsetWidth}})}})(jQuery);

/* replaceUrlParam - http://stackoverflow.com/questions/7171099/how-to-replace-url-parameter-with-javascript-jquery */
function replaceUrlParam(e,r,a){var n=new RegExp("("+r+"=).*?(&|$)"),c=e;return c=e.search(n)>=0?e.replace(n,"$1"+a+"$2"):c+(c.indexOf("?")>0?"&":"?")+r+"="+a};

/*============================================================================
Money Format
- Shopify.format money is defined in option_selection.js.
If that file is not included, it is redefined here.
==============================================================================*/
if ((typeof Shopify) === 'undefined') { Shopify = {}; }
if (!Shopify.formatMoney) {
Shopify.formatMoney = function(cents, format) {
var value = '',
placeholderRegex = /\{\{\s*(\w+)\s*\}\}/,
formatString = (format || this.money_format);

if (typeof cents == 'string') {
cents = cents.replace('.','');
}

function defaultOption(opt, def) {
return (typeof opt == 'undefined' ? def : opt);
}

function formatWithDelimiters(number, precision, thousands, decimal) {
precision = defaultOption(precision, 2);
thousands = defaultOption(thousands, ',');
decimal = defaultOption(decimal, '.');

if (isNaN(number) || number == null) {
return 0;
}

number = (number/100.0).toFixed(precision);

var parts = number.split('.'),
dollars = parts[0].replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1' + thousands),
cents = parts[1] ? (decimal + parts[1]) : '';

return dollars + cents;
}

switch(formatString.match(placeholderRegex)[1]) {
case 'amount':
value = formatWithDelimiters(cents, 2);
break;
case 'amount_no_decimals':
value = formatWithDelimiters(cents, 0);
break;
case 'amount_with_comma_separator':
value = formatWithDelimiters(cents, 2, '.', ',');
break;
case 'amount_no_decimals_with_comma_separator':
value = formatWithDelimiters(cents, 0, '.', ',');
break;
}

return formatString.replace(placeholderRegex, value);
};
}

// Timber functions
Expand All @@ -21,6 +72,7 @@ timber.cacheSelectors = function () {

// Navigation
$navigation : $('#AccessibleNav'),
$mobileSubNavToggle : $('.mobile-nav__toggle'),

// Collection Pages
$changeView : $('.change-view'),
Expand All @@ -35,13 +87,15 @@ timber.cacheSelectors = function () {
$recoverPasswordForm : $('#RecoverPasswordForm'),
$customerLoginForm : $('#CustomerLoginForm'),
$passwordResetSuccess : $('#ResetSuccess')
}
};
};

timber.init = function () {
FastClick.attach(document.body);
timber.cacheSelectors();
timber.accessibleNav();
timber.drawersInit();
timber.mobileNavToggle();
timber.productImageSwitch();
timber.responsiveVideos();
timber.collectionViews();
Expand Down Expand Up @@ -127,6 +181,19 @@ timber.accessibleNav = function () {
}
};

timber.drawersInit = function () {
timber.LeftDrawer = new timber.Drawers('NavDrawer', 'left');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

open question, is the mobile drawer a pattern we'd like to encourage for all mobile-ready themes?
cc @pauldpritchard

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Encourage, but not make mandatory. It's better than most of the mobile nav solutions we've created so far, but wouldn't fit into every theme's style from my point of view.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we document requirements vs encouragements?

timber.RightDrawer = new timber.Drawers('CartDrawer', 'right', {
'onDrawerOpen': ajaxCart.load
});
};

timber.mobileNavToggle = function () {
timber.cache.$mobileSubNavToggle.on('click', function() {
$(this).parent().toggleClass('mobile-nav--expanded');
});
};

timber.getHash = function () {
return window.location.hash;
};
Expand Down Expand Up @@ -264,5 +331,117 @@ timber.resetPasswordSuccess = function() {
timber.cache.$passwordResetSuccess.show();
};

/*============================================================================
Drawer modules
- Docs http://shopify.github.io/Timber/#drawers
==============================================================================*/
timber.Drawers = (function () {
var Drawer = function (id, position, options) {
var defaults = {
close: '.js-drawer-close',
open: '.js-drawer-open-' + position,
openClass: 'js-drawer-open',
dirOpenClass: 'js-drawer-open-' + position
};

this.$nodes = {
parent: $('body, html'),
page: $('#PageContainer'),
moved: $('.is-moved-by-drawer')
};

this.config = $.extend(defaults, options);
this.position = position;

this.$drawer = $('#' + id);

if (!this.$drawer.length) {
return false;
}

this.drawerIsOpen = false;
this.init();
};

Drawer.prototype.init = function () {
$(this.config.open).on('click', $.proxy(this.open, this));
this.$drawer.find(this.config.close).on('click', $.proxy(this.close, this));
};

Drawer.prototype.open = function (evt) {
// Keep track if drawer was opened from a click, or called by another function
var externalCall = false;

// Prevent following href if link is clicked
if (evt) {
evt.preventDefault();
} else {
externalCall = true;
}

// Without this, the drawer opens, the click event bubbles up to $nodes.page
// which closes the drawer.
if (evt && evt.stopPropagation) {
evt.stopPropagation();
// save the source of the click, we'll focus to this on close
this.$activeSource = $(evt.currentTarget);
}

if (this.drawerIsOpen && !externalCall) {
return this.close();
}

// Add is-transitioning class to moved elements on open so drawer can have
// transition for close animation
this.$nodes.moved.addClass('is-transitioning');
this.$drawer.prepareTransition();

this.$nodes.parent.addClass(this.config.openClass + ' ' + this.config.dirOpenClass);
this.drawerIsOpen = true;

// Run function when draw opens if set
if (this.config.onDrawerOpen && typeof(this.config.onDrawerOpen) == 'function') {
if (!externalCall) {
this.config.onDrawerOpen();
}
}

if (this.$activeSource && this.$activeSource.attr('aria-expanded')) {
this.$activeSource.attr('aria-expanded', 'true');
}

// Lock scrolling on mobile
this.$nodes.page.on('touchmove.drawer', function () {
return false;
});

this.$nodes.page.on('click.drawer', $.proxy(function () {
this.close();
return false;
}, this));
};

Drawer.prototype.close = function () {
if (!this.drawerIsOpen) { // don't close a closed drawer
return;
}

// deselect any focused form elements
$(document.activeElement).trigger('blur');

// Ensure closing transition is applied to moved elements, like the nav
this.$nodes.moved.prepareTransition({ disableExisting: true });
this.$drawer.prepareTransition({ disableExisting: true });

this.$nodes.parent.removeClass(this.config.dirOpenClass + ' ' + this.config.openClass);

this.drawerIsOpen = false;

this.$nodes.page.off('.drawer');
};

return Drawer;
})();

// Initialize Timber's JS on docready
$(timber.init);
Loading