Advertisement
Guest User

Untitled

a guest
Dec 6th, 2017
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var MasonryGrid, MasonryVideo,
  2.   extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  3.   hasProp = {}.hasOwnProperty,
  4.   slice = [].slice,
  5.   bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
  6.  
  7. window.ThemeEditor = (function(superClass) {
  8.   extend(ThemeEditor, superClass);
  9.  
  10.   function ThemeEditor() {
  11.     return ThemeEditor.__super__.constructor.apply(this, arguments);
  12.   }
  13.  
  14.   ThemeEditor.prototype.initialize = function() {
  15.     this.instanceHandlers = {};
  16.     this.instances = {};
  17.     return $(document).on('shopify:section:load', (function(_this) {
  18.       return function(event) {
  19.         return _this._onSectionLoad(event);
  20.       };
  21.     })(this)).on('shopify:section:unload', (function(_this) {
  22.       return function(event) {
  23.         return _this._onSectionUnload(event);
  24.       };
  25.     })(this)).on('shopify:section:select', (function(_this) {
  26.       return function(event) {
  27.         return _this._onSectionSelect(event);
  28.       };
  29.     })(this)).on('shopify:section:deselect', (function(_this) {
  30.       return function(event) {
  31.         return _this._onSectionDeselect(event);
  32.       };
  33.     })(this)).on('shopify:section:reorder', (function(_this) {
  34.       return function(event) {
  35.         return _this._onSectionReorder(event);
  36.       };
  37.     })(this)).on('shopify:block:select', (function(_this) {
  38.       return function(event) {
  39.         return _this._onBlockSelect(event);
  40.       };
  41.     })(this)).on('shopify:block:deselect', (function(_this) {
  42.       return function(event) {
  43.         return _this._onBlockDeselect(event);
  44.       };
  45.     })(this));
  46.   };
  47.  
  48.   ThemeEditor.prototype._findInstance = function(event) {
  49.     var $container, instance;
  50.     instance = this.instances[event.originalEvent.detail.sectionId];
  51.     if (instance != null) {
  52.       return instance;
  53.     } else {
  54.       $container = $('[data-section-id]', event.target);
  55.       return this._createInstance($container);
  56.     }
  57.   };
  58.  
  59.   ThemeEditor.prototype._createInstance = function($container, instanceHandler) {
  60.     var instance, sectionId, sectionType;
  61.     sectionType = $container.attr('data-section-type');
  62.     sectionId = $container.attr('data-section-id');
  63.     if (sectionType == null) {
  64.       return;
  65.     }
  66.     instanceHandler = instanceHandler || this.instanceHandlers[sectionType];
  67.     instance = {
  68.       instanceHandler: instanceHandler,
  69.       $container: $container,
  70.       sectionId: sectionId
  71.     };
  72.     this.instances[sectionId] = instance;
  73.     return instance;
  74.   };
  75.  
  76.  
  77.   /*
  78.       Action: A section has been added or re-rendered.
  79.       Expected: Re-execute any JavaScript needed for the section to work and
  80.           display properly (as if the page had just been loaded).
  81.    */
  82.  
  83.   ThemeEditor.prototype._onSectionLoad = function(event) {
  84.     var $container, ref, ref1;
  85.     $container = $('[data-section-id]', event.target);
  86.     if (!$container.length) {
  87.       return;
  88.     }
  89.     return (ref = this._createInstance($container)) != null ? (ref1 = ref.instanceHandler) != null ? typeof ref1.onSectionLoad === "function" ? ref1.onSectionLoad(event) : void 0 : void 0 : void 0;
  90.   };
  91.  
  92.  
  93.   /*
  94.       Action: A section has been deleted or is being re-rendered.
  95.       Expected: Clean up any event listeners, variables, etc., so that
  96.           nothing breaks when the page is interacted with and no memory leaks occur.
  97.    */
  98.  
  99.   ThemeEditor.prototype._onSectionUnload = function(event) {
  100.     var instance, ref;
  101.     instance = this._findInstance(event);
  102.     if (instance != null) {
  103.       if ((ref = instance.instanceHandler) != null) {
  104.         if (typeof ref.onSectionUnload === "function") {
  105.           ref.onSectionUnload(event);
  106.         }
  107.       }
  108.     }
  109.     if (instance) {
  110.       return delete this.instances[instance.sectionId];
  111.     }
  112.   };
  113.  
  114.  
  115.   /*
  116.       Action: User has selected the section in the sidebar.
  117.       Expected: Make sure the section is in view and stays
  118.           in view while selected (scrolling happens automatically).
  119.       Example: Could be used to pause a slideshow
  120.    */
  121.  
  122.   ThemeEditor.prototype._onSectionSelect = function(event) {
  123.     var ref, ref1;
  124.     return (ref = this._findInstance(event)) != null ? (ref1 = ref.instanceHandler) != null ? typeof ref1.onSectionSelect === "function" ? ref1.onSectionSelect(event) : void 0 : void 0 : void 0;
  125.   };
  126.  
  127.  
  128.   /*
  129.       Action: User has deselected the section in the sidebar.
  130.       Expected: (None)
  131.       Example: Could be used to restart slideshows that are no longer being interacted with.
  132.    */
  133.  
  134.   ThemeEditor.prototype._onSectionDeselect = function(event) {
  135.     var ref, ref1;
  136.     return (ref = this._findInstance(event)) != null ? (ref1 = ref.instanceHandler) != null ? typeof ref1.onSectionDeselect === "function" ? ref1.onSectionDeselect(event) : void 0 : void 0 : void 0;
  137.   };
  138.  
  139.  
  140.   /*
  141.       Action: User moves section in the sidebar
  142.       Expected: (None)
  143.       Example: Could be used to used to change high level section classes, or fire JS dependent on first section
  144.    */
  145.  
  146.   ThemeEditor.prototype._onSectionReorder = function(event) {
  147.     var ref, ref1;
  148.     return (ref = this._findInstance(event)) != null ? (ref1 = ref.instanceHandler) != null ? typeof ref1.onSectionReorder === "function" ? ref1.onSectionReorder(event) : void 0 : void 0 : void 0;
  149.   };
  150.  
  151.  
  152.   /*
  153.       Action: User has selected the block in the sidebar.
  154.       Expected: Make sure the block is in view and stays
  155.           in view while selected (scrolling happens automatically).
  156.       Example: Can be used to to trigger a slideshow to bring a slide/block into view
  157.    */
  158.  
  159.   ThemeEditor.prototype._onBlockSelect = function(event) {
  160.     var ref, ref1;
  161.     return (ref = this._findInstance(event)) != null ? (ref1 = ref.instanceHandler) != null ? typeof ref1.onBlockSelect === "function" ? ref1.onBlockSelect(event) : void 0 : void 0 : void 0;
  162.   };
  163.  
  164.  
  165.   /*
  166.       Action: User has deselected the block in the sidebar.
  167.       Expected: (None)
  168.       Example: Resume a slideshow
  169.    */
  170.  
  171.   ThemeEditor.prototype._onBlockDeselect = function(event) {
  172.     var ref, ref1;
  173.     return (ref = this._findInstance(event)) != null ? (ref1 = ref.instanceHandler) != null ? typeof ref1.onBlockDeselect === "function" ? ref1.onBlockDeselect(event) : void 0 : void 0 : void 0;
  174.   };
  175.  
  176.  
  177.   /*
  178.       Auto initialisation of a section for the store front
  179.    */
  180.  
  181.   ThemeEditor.prototype._sectionInit = function(instance) {
  182.     var ref;
  183.     return instance != null ? (ref = instance.instanceHandler) != null ? typeof ref.init === "function" ? ref.init(instance) : void 0 : void 0 : void 0;
  184.   };
  185.  
  186.  
  187.   /*
  188.       Registration of a section
  189.           - Takes a string parameter as the first argument which
  190.             matches to `[data-section-type]`
  191.  
  192.        * Example
  193.           @sections = new Sections()
  194.           @sections.register('some-section-type', @someSectionClass)
  195.    */
  196.  
  197.   ThemeEditor.prototype.register = function(type, instanceHandler) {
  198.  
  199.     /*
  200.         Storage of a instanceHandler based on the sectionType allows _onSectionLoad
  201.            to connect a new section to it's registered instanceHandler
  202.      */
  203.     this.instanceHandlers[type] = instanceHandler;
  204.     return $("[data-section-type=" + type + "]").each((function(_this) {
  205.       return function(index, container) {
  206.         var $container;
  207.         $container = $(container);
  208.         return _this._sectionInit(_this._createInstance($container, instanceHandler));
  209.       };
  210.     })(this));
  211.   };
  212.  
  213.  
  214.   /*
  215.       Public method to retrieve information on an instance based on the
  216.       bubbled `event`
  217.    */
  218.  
  219.   ThemeEditor.prototype.getInstance = function(event) {
  220.     return this._findInstance(event);
  221.   };
  222.  
  223.   return ThemeEditor;
  224.  
  225. })(Backbone.View);
  226.  
  227. window.ThemeUtils = {
  228.   breakpoints: {
  229.     xSmall: 540,
  230.     small: 770,
  231.     medium: 1020,
  232.     large: 1280
  233.   },
  234.   extend: function() {
  235.     var dest, i, k, len, obj, objs, v;
  236.     dest = arguments[0], objs = 2 <= arguments.length ? slice.call(arguments, 1) : [];
  237.     for (i = 0, len = objs.length; i < len; i++) {
  238.       obj = objs[i];
  239.       for (k in obj) {
  240.         v = obj[k];
  241.         dest[k] = v;
  242.       }
  243.     }
  244.     return dest;
  245.   },
  246.   windowWidth: function() {
  247.     return window.innerWidth || this.window.width();
  248.   },
  249.   isSmall: function() {
  250.     return this.windowWidth() <= this.breakpoints.small;
  251.   },
  252.   isMedium: function() {
  253.     return this.windowWidth() <= this.breakpoints.medium;
  254.   },
  255.   debounce: function(func, wait, immediate) {
  256.     var timeout;
  257.     timeout = null;
  258.     return function() {
  259.       var args, callNow, context, later;
  260.       context = this;
  261.       args = arguments;
  262.       later = function() {
  263.         timeout = null;
  264.         if (!immediate) {
  265.           func.apply(context, args);
  266.         }
  267.       };
  268.       callNow = immediate && !timeout;
  269.       clearTimeout(timeout);
  270.       timeout = setTimeout(later, wait);
  271.       if (callNow) {
  272.         func.apply(context, args);
  273.       }
  274.     };
  275.   },
  276.   unique: function(array) {
  277.     var i, key, output, ref, results, value;
  278.     output = {};
  279.     for (key = i = 0, ref = array.length; 0 <= ref ? i < ref : i > ref; key = 0 <= ref ? ++i : --i) {
  280.       output[array[key]] = array[key];
  281.     }
  282.     results = [];
  283.     for (key in output) {
  284.       value = output[key];
  285.       results.push(value);
  286.     }
  287.     return results;
  288.   },
  289.   scrollTarget: function($el) {
  290.     if (!($el instanceof jQuery)) {
  291.       $el = $($el);
  292.     }
  293.     return $('html, body').animate({
  294.       scrollTop: $el.offset().top
  295.     }, 500, 'linear');
  296.   },
  297.   inViewport: function(el, direction) {
  298.     var inViewportH, inViewportV, rect, viewportHeight, viewportWidth;
  299.     if (direction == null) {
  300.       direction = 'both';
  301.     }
  302.     if (typeof jQuery === "function" && el instanceof jQuery) {
  303.       el = el[0];
  304.     }
  305.     rect = el.getBoundingClientRect();
  306.     if (document.documentElement.clientWidth < window.innerWidth) {
  307.       viewportWidth = document.documentElement.clientWidth;
  308.     } else {
  309.       viewportWidth = window.innerHeight;
  310.     }
  311.     if (document.documentElement.clientHeight < window.innerHeight) {
  312.       viewportHeight = document.documentElement.clientHeight;
  313.     } else {
  314.       viewportHeight = window.innerHeight;
  315.     }
  316.     inViewportH = rect.right >= 0 && rect.left <= viewportWidth;
  317.     inViewportV = rect.bottom >= 0 && rect.top <= viewportHeight;
  318.     switch (direction) {
  319.       case 'horizontal':
  320.         return inViewportH;
  321.       case 'vertical':
  322.         return inViewportV;
  323.       case 'both':
  324.         return inViewportV && inViewportH;
  325.     }
  326.   },
  327.  
  328.   /*
  329.       Resize Flickity slider to tallest cell in viewport
  330.    */
  331.   flickityResize: function(flickity) {
  332.     var $viewport, cell, height, heights, i, len, ref;
  333.     $viewport = $(flickity.viewport);
  334.     heights = [];
  335.     ref = flickity.cells;
  336.     for (i = 0, len = ref.length; i < len; i++) {
  337.       cell = ref[i];
  338.       if (this.inViewport(cell.element, 'horizontal')) {
  339.         heights.push($(cell.element).outerHeight(true));
  340.       }
  341.     }
  342.     height = Math.max.apply(null, heights);
  343.     return $viewport.height(height);
  344.   }
  345. };
  346.  
  347. window.CurrencyView = (function(superClass) {
  348.   extend(CurrencyView, superClass);
  349.  
  350.   function CurrencyView() {
  351.     return CurrencyView.__super__.constructor.apply(this, arguments);
  352.   }
  353.  
  354.   CurrencyView.prototype.events = {
  355.     "change [name=currencies]": "switchCurrency",
  356.     "switch-currency": "switchCurrency"
  357.   };
  358.  
  359.   CurrencyView.prototype.initialize = function() {
  360.     var doubleMoney, i, j, len, len1, money, newCurrency, ref, ref1;
  361.     Currency.format = Theme.currencySwitcherFormat;
  362.     Currency.money_with_currency_format = {};
  363.     Currency.money_with_currency_format[Theme.currency] = Theme.moneyFormatCurrency;
  364.     Currency.money_format = {};
  365.     Currency.money_format[Theme.currency] = Theme.moneyFormat;
  366.     newCurrency = Currency.cookie.read();
  367.     if (newCurrency && this.$("[name=currencies] option[value=" + newCurrency + "]")) {
  368.       Currency.currentCurrency = newCurrency;
  369.     } else if (Theme.defaultCurrency) {
  370.       Currency.currentCurrency = Theme.defaultCurrency;
  371.       Currency.cookie.write(Theme.defaultCurrency);
  372.     } else {
  373.       Currency.currentCurrency = Theme.currency;
  374.       Currency.cookie.write(Theme.currency);
  375.     }
  376.     $("[name=currencies]").val(Currency.currentCurrency);
  377.     ref = $("span.money span.money");
  378.     for (i = 0, len = ref.length; i < len; i++) {
  379.       doubleMoney = ref[i];
  380.       $(doubleMoney).parents("span.money").removeClass("money");
  381.     }
  382.     ref1 = $("span.money");
  383.     for (j = 0, len1 = ref1.length; j < len1; j++) {
  384.       money = ref1[j];
  385.       $(money).attr("data-currency-" + Theme.currency, $(money).html());
  386.     }
  387.     this.switchCurrency();
  388.     this.moveCurrencyConverter();
  389.     return $(window).on('resize.currency', window.ThemeUtils.debounce(this.moveCurrencyConverter, 100));
  390.   };
  391.  
  392.   CurrencyView.prototype.unload = function() {
  393.     this.moveCurrencyConverter();
  394.     return $(window).off('resize.currency');
  395.   };
  396.  
  397.   CurrencyView.prototype.switchCurrency = function() {
  398.     var $switcher, i, len, money, newCurrency, ref;
  399.     $switcher = $("[name=currencies]");
  400.     newCurrency = $switcher.val();
  401.     if (newCurrency === null) {
  402.       newCurrency = Theme.currency;
  403.     }
  404.     ref = $("span.money");
  405.     for (i = 0, len = ref.length; i < len; i++) {
  406.       money = ref[i];
  407.       $(money).html($(money).attr("data-currency-" + Theme.currency));
  408.       $(money).attr("data-currency", Theme.currency);
  409.     }
  410.     Currency.convertAll(Theme.currency, newCurrency);
  411.     Currency.currentCurrency = newCurrency;
  412.     Currency.cookie.write(newCurrency);
  413.     return this.$(".selected-currency").text(Currency.currentCurrency);
  414.   };
  415.  
  416.   CurrencyView.prototype.moveCurrencyConverter = function() {
  417.     var $currencyWrapper;
  418.     $currencyWrapper = $('.currency-wrapper');
  419.     if (window.ThemeUtils.isMedium()) {
  420.       return $currencyWrapper.detach().insertAfter('.navigation-menu').addClass('mobile-currency-wrapper');
  421.     } else {
  422.       return $currencyWrapper.detach().removeClass('mobile-currency-wrapper').appendTo('[data-header-currency-switcher]');
  423.     }
  424.   };
  425.  
  426.   return CurrencyView;
  427.  
  428. })(Backbone.View);
  429.  
  430.  
  431. /* Dynamic sections */
  432.  
  433. window.HomeSlideshowView = (function(superClass) {
  434.   extend(HomeSlideshowView, superClass);
  435.  
  436.   function HomeSlideshowView() {
  437.     return HomeSlideshowView.__super__.constructor.apply(this, arguments);
  438.   }
  439.  
  440.   HomeSlideshowView.prototype.initialize = function() {
  441.     this.$slideshow = this.$el;
  442.     this.flickity = null;
  443.     this.slideCount = this.$slideshow.data('slideshow-slides');
  444.     this.autoPlay = false;
  445.     this.autoplayHoverPause = false;
  446.     if (this.$slideshow.is('[data-slideshow-autoplay]')) {
  447.       this.autoPlay = parseInt(this.$slideshow.attr('data-slideshow-autoplay'), 10) * 1000;
  448.       this.autoplayHoverPause = this.$slideshow.is('[data-slideshow-autoplay-hover-pause]');
  449.     }
  450.     return this._setupSlideshow();
  451.   };
  452.  
  453.   HomeSlideshowView.prototype.unload = function() {
  454.     if (this.flickity) {
  455.       this.flickity.destroy();
  456.       return this.flickity = null;
  457.     }
  458.   };
  459.  
  460.   HomeSlideshowView.prototype.onBlockSelect = function(event) {
  461.     var $block, slideIndex;
  462.     if (!this.flickity) {
  463.       return;
  464.     }
  465.     $block = $(event.target);
  466.     slideIndex = parseInt($block.data('slide-index'), 10);
  467.     return this.flickity.select(slideIndex, true);
  468.   };
  469.  
  470.   HomeSlideshowView.prototype._setupSlideshow = function() {
  471.     var slideshowNavigation, slideshowPagination;
  472.     slideshowNavigation = true;
  473.     slideshowPagination = true;
  474.     if (this.slideCount === 1) {
  475.       slideshowNavigation = false;
  476.       slideshowPagination = false;
  477.     }
  478.     return this.flickity = new Flickity(this.$slideshow[0], {
  479.       adaptiveHeight: true,
  480.       autoPlay: this.autoPlay,
  481.       cellSelector: '[data-slideshow-slide]',
  482.       imagesLoaded: true,
  483.       pageDots: slideshowPagination,
  484.       pauseAutoPlayOnHover: this.autoplayHoverPause,
  485.       prevNextButtons: slideshowNavigation,
  486.       resize: true,
  487.       wrapAround: true
  488.     });
  489.   };
  490.  
  491.   return HomeSlideshowView;
  492.  
  493. })(Backbone.View);
  494.  
  495. window.ThemeUtils = {
  496.   breakpoints: {
  497.     xSmall: 540,
  498.     small: 770,
  499.     medium: 1020,
  500.     large: 1280
  501.   },
  502.   extend: function() {
  503.     var dest, i, k, len, obj, objs, v;
  504.     dest = arguments[0], objs = 2 <= arguments.length ? slice.call(arguments, 1) : [];
  505.     for (i = 0, len = objs.length; i < len; i++) {
  506.       obj = objs[i];
  507.       for (k in obj) {
  508.         v = obj[k];
  509.         dest[k] = v;
  510.       }
  511.     }
  512.     return dest;
  513.   },
  514.   windowWidth: function() {
  515.     return window.innerWidth || this.window.width();
  516.   },
  517.   isSmall: function() {
  518.     return this.windowWidth() <= this.breakpoints.small;
  519.   },
  520.   isMedium: function() {
  521.     return this.windowWidth() <= this.breakpoints.medium;
  522.   },
  523.   debounce: function(func, wait, immediate) {
  524.     var timeout;
  525.     timeout = null;
  526.     return function() {
  527.       var args, callNow, context, later;
  528.       context = this;
  529.       args = arguments;
  530.       later = function() {
  531.         timeout = null;
  532.         if (!immediate) {
  533.           func.apply(context, args);
  534.         }
  535.       };
  536.       callNow = immediate && !timeout;
  537.       clearTimeout(timeout);
  538.       timeout = setTimeout(later, wait);
  539.       if (callNow) {
  540.         func.apply(context, args);
  541.       }
  542.     };
  543.   },
  544.   unique: function(array) {
  545.     var i, key, output, ref, results, value;
  546.     output = {};
  547.     for (key = i = 0, ref = array.length; 0 <= ref ? i < ref : i > ref; key = 0 <= ref ? ++i : --i) {
  548.       output[array[key]] = array[key];
  549.     }
  550.     results = [];
  551.     for (key in output) {
  552.       value = output[key];
  553.       results.push(value);
  554.     }
  555.     return results;
  556.   },
  557.   scrollTarget: function($el) {
  558.     if (!($el instanceof jQuery)) {
  559.       $el = $($el);
  560.     }
  561.     return $('html, body').animate({
  562.       scrollTop: $el.offset().top
  563.     }, 500, 'linear');
  564.   },
  565.   inViewport: function(el, direction) {
  566.     var inViewportH, inViewportV, rect, viewportHeight, viewportWidth;
  567.     if (direction == null) {
  568.       direction = 'both';
  569.     }
  570.     if (typeof jQuery === "function" && el instanceof jQuery) {
  571.       el = el[0];
  572.     }
  573.     rect = el.getBoundingClientRect();
  574.     if (document.documentElement.clientWidth < window.innerWidth) {
  575.       viewportWidth = document.documentElement.clientWidth;
  576.     } else {
  577.       viewportWidth = window.innerHeight;
  578.     }
  579.     if (document.documentElement.clientHeight < window.innerHeight) {
  580.       viewportHeight = document.documentElement.clientHeight;
  581.     } else {
  582.       viewportHeight = window.innerHeight;
  583.     }
  584.     inViewportH = rect.right >= 0 && rect.left <= viewportWidth;
  585.     inViewportV = rect.bottom >= 0 && rect.top <= viewportHeight;
  586.     switch (direction) {
  587.       case 'horizontal':
  588.         return inViewportH;
  589.       case 'vertical':
  590.         return inViewportV;
  591.       case 'both':
  592.         return inViewportV && inViewportH;
  593.     }
  594.   },
  595.  
  596.   /*
  597.       Resize Flickity slider to tallest cell in viewport
  598.    */
  599.   flickityResize: function(flickity) {
  600.     var $viewport, cell, height, heights, i, len, ref;
  601.     $viewport = $(flickity.viewport);
  602.     heights = [];
  603.     ref = flickity.cells;
  604.     for (i = 0, len = ref.length; i < len; i++) {
  605.       cell = ref[i];
  606.       if (this.inViewport(cell.element, 'horizontal')) {
  607.         heights.push($(cell.element).outerHeight(true));
  608.       }
  609.     }
  610.     height = Math.max.apply(null, heights);
  611.     return $viewport.height(height);
  612.   }
  613. };
  614.  
  615. window.ModalView = (function(superClass) {
  616.   extend(ModalView, superClass);
  617.  
  618.   function ModalView() {
  619.     return ModalView.__super__.constructor.apply(this, arguments);
  620.   }
  621.  
  622.   ModalView.prototype.events = {
  623.     "click": "close",
  624.     "click [data-modal-close]": "close"
  625.   };
  626.  
  627.   ModalView.prototype.initialize = function(options) {
  628.     var callbacks, defaultCallbacks;
  629.     if (options == null) {
  630.       options = {};
  631.     }
  632.     callbacks = options.callbacks || {};
  633.     this.$body = $(document.body);
  634.     this.$window = $(window);
  635.     this.$modalInner = this.$el.find('[data-modal-inner]');
  636.     this.$contents = this.$el.find('[data-modal-contents]');
  637.     this.mobileFriendly = this.$el.attr('data-modal-mobile-friendly') != null;
  638.     this.selectors = {
  639.       open: 'modal-opened',
  640.       visible: 'modal-visible',
  641.       active: 'modal-active',
  642.       scrollLock: 'scroll-locked'
  643.     };
  644.     defaultCallbacks = {
  645.       onOpen: (function(_this) {
  646.         return function() {
  647.           return {};
  648.         };
  649.       })(this),
  650.       onClose: (function(_this) {
  651.         return function() {
  652.           return {};
  653.         };
  654.       })(this)
  655.     };
  656.     return this.callbacks = $.extend({}, defaultCallbacks, callbacks);
  657.   };
  658.  
  659.  
  660.   /*
  661.       Manually open a modal.
  662.    */
  663.  
  664.   ModalView.prototype.open = function() {
  665.     this.$el.addClass(this.selectors.open);
  666.     this.$window.on('resize.modal', (function(_this) {
  667.       return function() {
  668.         return _this._resize();
  669.       };
  670.     })(this));
  671.     return this.callbacks.onOpen({
  672.       $modal: this.$el,
  673.       $contents: this.$contents
  674.     });
  675.   };
  676.  
  677.  
  678.   /*
  679.       Close modal, and clean up
  680.    */
  681.  
  682.   ModalView.prototype.close = function() {
  683.     this.$el.removeClass(this.selectors.active).removeClass(this.selectors.visible).removeClass(this.selectors.open);
  684.     this.$body.removeClass(this.selectors.scrollLock);
  685.     this.$contents.html('');
  686.     this.callbacks.onClose();
  687.     this.$window.off('resize.modal');
  688.     return this.undelegateEvents();
  689.   };
  690.  
  691.  
  692.   /*
  693.       Make a modal visible after content has been added
  694.    */
  695.  
  696.   ModalView.prototype.showModal = function() {
  697.     this.$body.addClass(this.selectors.scrollLock);
  698.     return this.$contents.imagesLoaded((function(_this) {
  699.       return function() {
  700.         _this._position();
  701.         return _this.$el.addClass(_this.selectors.visible).one('trend', function() {
  702.           return _this.$el.addClass(_this.selectors.active);
  703.         });
  704.       };
  705.     })(this));
  706.   };
  707.  
  708.   ModalView.prototype._resize = function() {
  709.     var windowWidth;
  710.     this._position();
  711.     if (!this.mobileFriendly) {
  712.       windowWidth = window.ThemeUtils.windowWidth();
  713.       if (windowWidth > window.ThemeUtils.breakpoints.small) {
  714.         return;
  715.       }
  716.       return this.close();
  717.     }
  718.   };
  719.  
  720.  
  721.   /*
  722.       Center modal vertically and horizontally
  723.    */
  724.  
  725.   ModalView.prototype._position = function() {
  726.     return this.$modalInner.css({
  727.       marginTop: -(this.$modalInner.outerHeight() / 2),
  728.       marginLeft: -(this.$modalInner.outerWidth() / 2)
  729.     });
  730.   };
  731.  
  732.   return ModalView;
  733.  
  734. })(Backbone.View);
  735.  
  736. MasonryVideo = (function() {
  737.   function MasonryVideo($el, event) {
  738.     var $modal, $target, modalID;
  739.     this.$el = $el;
  740.     this.modal = null;
  741.     $target = $(event.currentTarget);
  742.     modalID = $target.attr('data-masonry-video');
  743.     $modal = this.$el.find("[data-modal-id=" + modalID + "]");
  744.     this.modal = new ModalView({
  745.       el: $modal,
  746.       callbacks: {
  747.         onOpen: (function(_this) {
  748.           return function($els) {
  749.             return _this._open($els);
  750.           };
  751.         })(this),
  752.         onClose: (function(_this) {
  753.           return function() {
  754.             return _this._close();
  755.           };
  756.         })(this)
  757.       }
  758.     });
  759.     this.modal.open();
  760.   }
  761.  
  762.   MasonryVideo.prototype.remove = function() {
  763.     if (this.modal) {
  764.       return this.modal.close();
  765.     }
  766.   };
  767.  
  768.   MasonryVideo.prototype._open = function($els) {
  769.     var $contents, $modal, $videoContents, $videoJson;
  770.     $modal = $els.$modal, $contents = $els.$contents;
  771.     $videoJson = $modal.find('[data-masonry-video]');
  772.     try {
  773.       $videoContents = $(JSON.parse($videoJson.text()));
  774.     } catch (error1) {
  775.       return console.warn('Unable to parse contents of video');
  776.     }
  777.     $contents.html($videoContents).fitVids();
  778.     return this.modal.showModal();
  779.   };
  780.  
  781.   MasonryVideo.prototype._close = function() {
  782.     return this.modal = null;
  783.   };
  784.  
  785.   return MasonryVideo;
  786.  
  787. })();
  788.  
  789. window.HomeMasonryView = (function(superClass) {
  790.   extend(HomeMasonryView, superClass);
  791.  
  792.   function HomeMasonryView() {
  793.     this._masonryVideo = bind(this._masonryVideo, this);
  794.     this._masonryLayout = bind(this._masonryLayout, this);
  795.     return HomeMasonryView.__super__.constructor.apply(this, arguments);
  796.   }
  797.  
  798.   HomeMasonryView.prototype.events = {
  799.     'click [data-masonry-url]': '_redirectMasonryFeatures',
  800.     'click [data-masonry-video]': '_masonryVideo'
  801.   };
  802.  
  803.   HomeMasonryView.prototype.initialize = function() {
  804.     this.masonryVideo = null;
  805.     this.$window = $(window);
  806.     this.initializedClass = 'masonry-initialized';
  807.     return this._validate();
  808.   };
  809.  
  810.   HomeMasonryView.prototype.update = function($el) {
  811.     this.$el = $el;
  812.     return this._validate();
  813.   };
  814.  
  815.   HomeMasonryView.prototype.prepareRemove = function() {
  816.     var ref;
  817.     if ((ref = this.masonryVideo) != null) {
  818.       ref.remove();
  819.     }
  820.     return this.$window.off('resize.home-masonry');
  821.   };
  822.  
  823.   HomeMasonryView.prototype._validate = function() {
  824.     var isInitialized;
  825.     this.$masonry = this.$el;
  826.     isInitialized = this.$el.hasClass(this.initializedClass);
  827.     this._bindEvents(isInitialized);
  828.     return this._masonryLayout();
  829.   };
  830.  
  831.   HomeMasonryView.prototype._bindEvents = function(isInitialized) {
  832.     if (isInitialized) {
  833.       return;
  834.     }
  835.     return this.$window.on('resize.home-masonry', window.ThemeUtils.debounce(this._masonryLayout, 10));
  836.   };
  837.  
  838.   HomeMasonryView.prototype._masonryLayout = function() {
  839.     if (this.$masonry.hasClass('home-masonry-feature-count-4') || this.$masonry.hasClass('home-masonry-feature-count-5') || this.$masonry.hasClass('home-masonry-feature-count-6')) {
  840.       this._positionMasonryFeatures();
  841.     }
  842.     if (!window.ThemeUtils.isMedium() && !this.$masonry.hasClass('home-masonry-feature-count-1')) {
  843.       this._setMasonryFeatureHeight();
  844.     }
  845.     return this._positionMasonryFeatureText();
  846.   };
  847.  
  848.   HomeMasonryView.prototype._positionMasonryFeatures = function() {
  849.     var bumpFeature, containerWidth, offset;
  850.     if (this.$masonry.hasClass('home-masonry-feature-count-4') || this.$masonry.hasClass('home-masonry-feature-count-5')) {
  851.       bumpFeature = this.$masonry.find('.home-masonry-feature-3');
  852.     } else if (this.$masonry.hasClass('home-masonry-feature-count-6')) {
  853.       bumpFeature = this.$masonry.find('.home-masonry-feature-4');
  854.     }
  855.     containerWidth = this.$masonry.outerWidth();
  856.     offset = -(containerWidth * 0.074);
  857.     bumpFeature.css({
  858.       'top': offset
  859.     });
  860.     return this.$masonry.css({
  861.       'marginBottom': offset
  862.     });
  863.   };
  864.  
  865.   HomeMasonryView.prototype._setMasonryFeatureHeight = function() {
  866.     return this.$masonry.imagesLoaded((function(_this) {
  867.       return function() {
  868.         var feature, featureAspect, featureFigure, featureFigureDiff, featureWidth, height, i, image, imageAspect, len, marginBottom, preciseHeight, ref, results, width;
  869.         ref = _this.$masonry.children('.home-masonry-feature');
  870.         results = [];
  871.         for (i = 0, len = ref.length; i < len; i++) {
  872.           feature = ref[i];
  873.           feature = $(feature);
  874.           height = feature.outerHeight(false);
  875.           preciseHeight = feature[0].getBoundingClientRect().height;
  876.           marginBottom = feature.css('marginBottom').replace('px', '');
  877.           width = feature.outerWidth();
  878.           featureFigure = feature.children('figure');
  879.           featureWidth = featureFigure.outerWidth();
  880.           featureFigureDiff = width / featureWidth;
  881.           featureAspect = (height / width) * 100;
  882.           feature.children('figure').css({
  883.             'height': preciseHeight + "px"
  884.           });
  885.           image = feature.find('img, .home-masonry-feature-placeholder');
  886.           image.css({
  887.             'height': 'auto',
  888.             'width': 'auto'
  889.           });
  890.           imageAspect = (image.height() / image.width()) * 100;
  891.           if (imageAspect < featureAspect) {
  892.             results.push(image.height(feature.children('figure').outerHeight()).css({
  893.               'marginLeft': -((image.width() - width) / 2)
  894.             }));
  895.           } else {
  896.             results.push(image.width(feature.children('figure').outerWidth()).css({
  897.               'marginTop': -((image.height() - height) / 2)
  898.             }));
  899.           }
  900.         }
  901.         return results;
  902.       };
  903.     })(this));
  904.   };
  905.  
  906.   HomeMasonryView.prototype._redirectMasonryFeatures = function(e) {
  907.     var $target, url;
  908.     $target = $(e.currentTarget);
  909.     if (!$target.parents(this.$masonry).length) {
  910.       return;
  911.     }
  912.     url = $target.data('masonry-url');
  913.     if (url !== '') {
  914.       return window.location = url;
  915.     }
  916.   };
  917.  
  918.   HomeMasonryView.prototype._positionMasonryFeatureText = function() {
  919.     var feature, i, len, ref, results, textHeight, textWidth;
  920.     ref = $('.home-masonry-feature-text', this.$masonry);
  921.     results = [];
  922.     for (i = 0, len = ref.length; i < len; i++) {
  923.       feature = ref[i];
  924.       feature = $(feature);
  925.       textHeight = feature.height();
  926.       textWidth = feature.outerWidth();
  927.       results.push(feature.css({
  928.         'marginTop': -(textHeight / 2),
  929.         'marginLeft': -(textWidth / 2)
  930.       }));
  931.     }
  932.     return results;
  933.   };
  934.  
  935.   HomeMasonryView.prototype._masonryVideo = function(event) {
  936.     return this.masonryVideo = new MasonryVideo(this.$el, event);
  937.   };
  938.  
  939.   return HomeMasonryView;
  940.  
  941. })(Backbone.View);
  942.  
  943. window.HomeMasonryAlternativeView = (function(superClass) {
  944.   extend(HomeMasonryAlternativeView, superClass);
  945.  
  946.   function HomeMasonryAlternativeView() {
  947.     this._masonryVideo = bind(this._masonryVideo, this);
  948.     this._masonryLayout = bind(this._masonryLayout, this);
  949.     return HomeMasonryAlternativeView.__super__.constructor.apply(this, arguments);
  950.   }
  951.  
  952.   HomeMasonryAlternativeView.prototype.events = {
  953.     'click [data-masonry-url]': '_redirectMasonryFeatures',
  954.     'click [data-masonry-video]': '_masonryVideo'
  955.   };
  956.  
  957.   HomeMasonryAlternativeView.prototype.initialize = function() {
  958.     this.$window = $(window);
  959.     this.masonryVideo = null;
  960.     this.initializedClass = 'masonry-initialized';
  961.     return this._validate();
  962.   };
  963.  
  964.   HomeMasonryAlternativeView.prototype.update = function($el) {
  965.     this.$el = $el;
  966.     return this._validate();
  967.   };
  968.  
  969.   HomeMasonryAlternativeView.prototype.prepareRemove = function() {
  970.     var ref;
  971.     if ((ref = this.masonryVideo) != null) {
  972.       ref.remove();
  973.     }
  974.     return this.$window.off('resize.home-masonry');
  975.   };
  976.  
  977.   HomeMasonryAlternativeView.prototype._validate = function() {
  978.     var isInitialized;
  979.     this.$masonry = this.$el;
  980.     isInitialized = this.$el.hasClass(this.initializedClass);
  981.     this._bindEvents(isInitialized);
  982.     return this._masonryLayout();
  983.   };
  984.  
  985.   HomeMasonryAlternativeView.prototype._bindEvents = function(isInitialized) {
  986.     if (isInitialized) {
  987.       return;
  988.     }
  989.     return this.$window.on('resize.home-masonry', window.ThemeUtils.debounce(this._masonryLayout, 10));
  990.   };
  991.  
  992.   HomeMasonryAlternativeView.prototype._masonryLayout = function() {
  993.     if (!window.ThemeUtils.isMedium()) {
  994.       this.setupAlternativeMasonryFeatures('desktop');
  995.     } else {
  996.       this.setupAlternativeMasonryFeatures('mobile');
  997.     }
  998.     return this._positionMasonryFeatureText();
  999.   };
  1000.  
  1001.   HomeMasonryAlternativeView.prototype._redirectMasonryFeatures = function(e) {
  1002.     var $target, url;
  1003.     $target = $(e.currentTarget);
  1004.     if (!$target.parents(this.$masonry).length) {
  1005.       return;
  1006.     }
  1007.     url = $target.data('masonry-url');
  1008.     if (url !== '') {
  1009.       return window.location = url;
  1010.     }
  1011.   };
  1012.  
  1013.   HomeMasonryAlternativeView.prototype._positionMasonryFeatureText = function() {
  1014.     var feature, i, len, ref, results, textHeight, textWidth;
  1015.     ref = $('.home-masonry-feature-text', this.$masonry);
  1016.     results = [];
  1017.     for (i = 0, len = ref.length; i < len; i++) {
  1018.       feature = ref[i];
  1019.       feature = $(feature);
  1020.       textHeight = feature.height();
  1021.       textWidth = feature.outerWidth();
  1022.       results.push(feature.css({
  1023.         'marginTop': -(textHeight / 2),
  1024.         'marginLeft': -(textWidth / 2)
  1025.       }));
  1026.     }
  1027.     return results;
  1028.   };
  1029.  
  1030.   HomeMasonryAlternativeView.prototype.setupAlternativeMasonryFeatures = function(layout) {
  1031.     var windowHeight;
  1032.     this.masonryFeaturesContainer = this.$masonry;
  1033.     this.masonryFeatures = this.$('.home-masonry-feature');
  1034.     windowHeight = document.documentElement.clientHeight;
  1035.     if (layout === 'desktop') {
  1036.       this.masonryFeaturesContainer.height(windowHeight);
  1037.       this.masonryFeatures.removeClass('mobile natural');
  1038.       if (this.masonryFeaturesContainer.hasClass('home-masonry-feature-count-1') || this.masonryFeaturesContainer.hasClass('home-masonry-feature-count-2') || this.masonryFeaturesContainer.hasClass('home-masonry-feature-count-3')) {
  1039.         this.masonryFeatures.css({
  1040.           'height': '100%'
  1041.         });
  1042.       } else if (this.masonryFeaturesContainer.hasClass('home-masonry-feature-count-4')) {
  1043.         this.$('.home-masonry-feature-1, .home-masonry-feature-4').css({
  1044.           'height': windowHeight * 0.45
  1045.         });
  1046.         this.$('.home-masonry-feature-2, .home-masonry-feature-3').css({
  1047.           'height': windowHeight * 0.55
  1048.         });
  1049.         this.$('.home-masonry-feature-3').css({
  1050.           'marginTop': -windowHeight * 0.1
  1051.         });
  1052.       } else if (this.masonryFeaturesContainer.hasClass('home-masonry-feature-count-5')) {
  1053.         this.$('.home-masonry-feature-1, .home-masonry-feature-4, .home-masonry-feature-5').css({
  1054.           'height': windowHeight * 0.45
  1055.         });
  1056.         this.$('.home-masonry-feature-2, .home-masonry-feature-3').css({
  1057.           'height': windowHeight * 0.55
  1058.         });
  1059.         this.$('.home-masonry-feature-3').css({
  1060.           'marginTop': -windowHeight * 0.1
  1061.         });
  1062.       } else if (this.masonryFeaturesContainer.hasClass('home-masonry-feature-count-6')) {
  1063.         this.$('.home-masonry-feature-1, .home-masonry-feature-5, .home-masonry-feature-6').css({
  1064.           'height': windowHeight * 0.45
  1065.         });
  1066.         this.$('.home-masonry-feature-2, .home-masonry-feature-3, .home-masonry-feature-4').css({
  1067.           'height': windowHeight * 0.55
  1068.         });
  1069.         this.$('.home-masonry-feature-4').css({
  1070.           'marginTop': -windowHeight * 0.1
  1071.         });
  1072.       }
  1073.       return this.positionMasonryFeatures();
  1074.     } else if (layout === 'mobile') {
  1075.       this.masonryFeaturesContainer.css({
  1076.         'height': 'auto'
  1077.       });
  1078.       this.masonryFeatures.addClass('mobile natural');
  1079.       return $(document.body).imagesLoaded((function(_this) {
  1080.         return function() {
  1081.           var containerHeight;
  1082.           containerHeight = _this.masonryFeaturesContainer.height();
  1083.           if (windowHeight > containerHeight) {
  1084.             _this.masonryFeatures.removeClass('natural').css({
  1085.               'height': windowHeight / _this.$('.enable-mobile-true').length
  1086.             });
  1087.             return _this.positionMasonryFeatures();
  1088.           } else {
  1089.             return _this.masonryFeatures.children('figure').css({
  1090.               'marginLeft': 0
  1091.             });
  1092.           }
  1093.         };
  1094.       })(this));
  1095.     }
  1096.   };
  1097.  
  1098.   HomeMasonryAlternativeView.prototype.positionMasonryFeatures = function() {
  1099.     return $(document.body).imagesLoaded((function(_this) {
  1100.       return function() {
  1101.         var feature, featureAspect, figure, figureAspect, height, i, len, preciseHeight, ref, results, width;
  1102.         ref = _this.masonryFeatures;
  1103.         results = [];
  1104.         for (i = 0, len = ref.length; i < len; i++) {
  1105.           feature = ref[i];
  1106.           feature = $(feature);
  1107.           height = feature.outerHeight(false);
  1108.           preciseHeight = feature[0].getBoundingClientRect().height;
  1109.           width = feature.outerWidth();
  1110.           featureAspect = height / width;
  1111.           figure = feature.children('figure');
  1112.           figure.css({
  1113.             'height': 'auto',
  1114.             'width': 'auto',
  1115.             'marginLeft': 0,
  1116.             'marginTop': 0
  1117.           });
  1118.           figureAspect = figure.height() / figure.width();
  1119.           if (figureAspect < featureAspect) {
  1120.             results.push(figure.width(height / figureAspect).css({
  1121.               'marginLeft': -((figure.width() - width) / 2)
  1122.             }));
  1123.           } else {
  1124.             results.push(figure.css({
  1125.               'marginTop': -((figure.height() - height) / 2)
  1126.             }));
  1127.           }
  1128.         }
  1129.         return results;
  1130.       };
  1131.     })(this));
  1132.   };
  1133.  
  1134.   HomeMasonryAlternativeView.prototype._masonryVideo = function(event) {
  1135.     return this.masonryVideo = new MasonryVideo(this.$el, event);
  1136.   };
  1137.  
  1138.   return HomeMasonryAlternativeView;
  1139.  
  1140. })(Backbone.View);
  1141.  
  1142. window.HomeCollectionsView = (function(superClass) {
  1143.   extend(HomeCollectionsView, superClass);
  1144.  
  1145.   function HomeCollectionsView() {
  1146.     return HomeCollectionsView.__super__.constructor.apply(this, arguments);
  1147.   }
  1148.  
  1149.   HomeCollectionsView.prototype.events = {
  1150.     "click .home-collection-overlay-wrapper": "_redirectCollection"
  1151.   };
  1152.  
  1153.   HomeCollectionsView.prototype.initialize = function() {
  1154.     this.initializedClass = 'collection-initialized';
  1155.     this._bindEvents();
  1156.     return this._validate();
  1157.   };
  1158.  
  1159.   HomeCollectionsView.prototype._validate = function() {
  1160.     var isInitialized;
  1161.     this.$collectionsContainer = this.$("[data-collections]", this.$el);
  1162.     isInitialized = this.$el.hasClass(this.initializedClass);
  1163.     return this._setupCollections();
  1164.   };
  1165.  
  1166.   HomeCollectionsView.prototype.update = function($el) {
  1167.     this.$el = $el;
  1168.     return this._validate();
  1169.   };
  1170.  
  1171.   HomeCollectionsView.prototype.remove = function() {
  1172.     HomeCollectionsView.__super__.remove.apply(this, arguments);
  1173.     return $(window).off("resize.blog-view");
  1174.   };
  1175.  
  1176.   HomeCollectionsView.prototype.onBlockSelect = function(event) {
  1177.     return this._validate();
  1178.   };
  1179.  
  1180.   HomeCollectionsView.prototype.onBlockDeselect = function(event) {
  1181.     return this._validate();
  1182.   };
  1183.  
  1184.   HomeCollectionsView.prototype._bindEvents = function() {
  1185.     return $(window).on("resize.collections-view", (function(_this) {
  1186.       return function() {
  1187.         _this._setupCollections();
  1188.         if (!Modernizr.csstransforms) {
  1189.           return _this._centerCollectionText();
  1190.         }
  1191.       };
  1192.     })(this));
  1193.   };
  1194.  
  1195.   HomeCollectionsView.prototype._setupCollections = function() {
  1196.     var collectionHeight, featuredCollectionImage;
  1197.     collectionHeight = 10000;
  1198.     featuredCollectionImage = this.$(".home-collection-image img, .home-collection-image svg");
  1199.     featuredCollectionImage.css({
  1200.       'height': 'auto'
  1201.     });
  1202.     return this.$(".home-collections-content").imagesLoaded().done((function(_this) {
  1203.       return function() {
  1204.         var collectionImage, i, len;
  1205.         for (i = 0, len = featuredCollectionImage.length; i < len; i++) {
  1206.           collectionImage = featuredCollectionImage[i];
  1207.           if (collectionImage.getBoundingClientRect().height < collectionHeight) {
  1208.             collectionHeight = collectionImage.getBoundingClientRect().height;
  1209.           }
  1210.         }
  1211.         featuredCollectionImage.css({
  1212.           'height': ''
  1213.         });
  1214.         return _this.$(".home-collection-image").height(collectionHeight);
  1215.       };
  1216.     })(this));
  1217.   };
  1218.  
  1219.   HomeCollectionsView.prototype._centerCollectionText = function() {
  1220.     var collectionText, i, len, ref, results, textHeight, textWidth;
  1221.     ref = this.$(".home-collection-overlay", this.$collectionsContainer);
  1222.     results = [];
  1223.     for (i = 0, len = ref.length; i < len; i++) {
  1224.       collectionText = ref[i];
  1225.       collectionText = $(collectionText);
  1226.       textHeight = collectionText.height();
  1227.       textWidth = collectionText.outerWidth();
  1228.       results.push(collectionText.css({
  1229.         "marginTop": -(textHeight / 2),
  1230.         "marginLeft": -(textWidth / 2)
  1231.       }));
  1232.     }
  1233.     return results;
  1234.   };
  1235.  
  1236.   HomeCollectionsView.prototype._redirectCollection = function(e) {
  1237.     var url;
  1238.     if (!$(e.target).parents(this.$collectionsContainer).length) {
  1239.  
  1240.     } else {
  1241.       url = $(e.target).data("url");
  1242.       if (url !== "") {
  1243.         return window.location = url;
  1244.       }
  1245.     }
  1246.   };
  1247.  
  1248.   return HomeCollectionsView;
  1249.  
  1250. })(Backbone.View);
  1251.  
  1252. MasonryGrid = (function() {
  1253.   function MasonryGrid(options) {
  1254.     var defaultSettings;
  1255.     this.$el = options.$el;
  1256.     defaultSettings = {
  1257.       itemSelector: '[data-masonry-item]',
  1258.       columnWidth: '[data-masonry-sizer]',
  1259.       gutter: 0,
  1260.       percentPosition: false
  1261.     };
  1262.     this.settings = window.ThemeUtils.extend(defaultSettings, options.settings);
  1263.     this.$masonry = this.$el.masonry(this.settings);
  1264.     this.$masonry.imagesLoaded().progress((function(_this) {
  1265.       return function() {
  1266.         return _this.$masonry.masonry('layout');
  1267.       };
  1268.     })(this));
  1269.   }
  1270.  
  1271.   MasonryGrid.prototype.unload = function() {
  1272.     return this.$masonry.masonry('destroy');
  1273.   };
  1274.  
  1275.   return MasonryGrid;
  1276.  
  1277. })();
  1278.  
  1279. window.ProductMasonryLayoutView = (function(superClass) {
  1280.   extend(ProductMasonryLayoutView, superClass);
  1281.  
  1282.   function ProductMasonryLayoutView() {
  1283.     this._initLayout = bind(this._initLayout, this);
  1284.     return ProductMasonryLayoutView.__super__.constructor.apply(this, arguments);
  1285.   }
  1286.  
  1287.   ProductMasonryLayoutView.prototype.initialize = function() {
  1288.     this.$window = $(window);
  1289.     this.selectors = {
  1290.       gallery: {
  1291.         el: '[data-masonry-gallery]',
  1292.         itemSelector: '.product-image',
  1293.         columnWidth: '[data-masonry-image-sizer]'
  1294.       },
  1295.       relatedProducts: {
  1296.         el: '[data-masonry-products]',
  1297.         itemSelector: '.product-list-item',
  1298.         columnWidth: '[data-masonry-products-sizer]'
  1299.       }
  1300.     };
  1301.     this.masonry = {
  1302.       gallery: null,
  1303.       relatedProducts: null
  1304.     };
  1305.     this.flickity = {
  1306.       gallery: null,
  1307.       relatedProducts: null
  1308.     };
  1309.     this.$gallery = this.$(this.selectors.gallery.el);
  1310.     this.$relatedProducts = $(this.selectors.relatedProducts.el);
  1311.     this.hasGallery = this.$gallery.length;
  1312.     this.hasRelatedProducts = this.$relatedProducts.length;
  1313.     this._initLayout();
  1314.     return this._bindEvents();
  1315.   };
  1316.  
  1317.   ProductMasonryLayoutView.prototype.prepareRemove = function() {
  1318.     this.$window.off('resize.product-masonry-layout');
  1319.     this.$gallery.off('product-masonry-layout');
  1320.     this.$relatedProducts.off('product-masonry-layout');
  1321.     if (this.flickity) {
  1322.       this._destroyFlickity();
  1323.     }
  1324.     if (this.masonry) {
  1325.       return this._destroyMasonry();
  1326.     }
  1327.   };
  1328.  
  1329.   ProductMasonryLayoutView.prototype._bindEvents = function() {
  1330.     return this.$window.on('resize.product-masonry-layout', window.ThemeUtils.debounce(this._initLayout, 100));
  1331.   };
  1332.  
  1333.   ProductMasonryLayoutView.prototype._initLayout = function() {
  1334.     if (window.ThemeUtils.isSmall()) {
  1335.       return this._initMobile();
  1336.     } else {
  1337.       return this._initDesktop();
  1338.     }
  1339.   };
  1340.  
  1341.   ProductMasonryLayoutView.prototype._initMobile = function() {
  1342.     this._destroyMasonry();
  1343.     return this._initFlickity();
  1344.   };
  1345.  
  1346.   ProductMasonryLayoutView.prototype._initDesktop = function() {
  1347.     this._destroyFlickity();
  1348.     return this._initMasonry();
  1349.   };
  1350.  
  1351.   ProductMasonryLayoutView.prototype._initFlickity = function() {
  1352.     if (this.hasGallery && !this.flickity.gallery) {
  1353.       this._galleryReset();
  1354.       this.flickity.gallery = new Flickity(this.$gallery[0], {
  1355.         cellAlign: 'left',
  1356.         cellSelector: this.selectors.gallery.itemSelector,
  1357.         contain: false,
  1358.         percentPosition: false,
  1359.         prevNextButtons: false,
  1360.         pageDots: false,
  1361.         imagesLoaded: true,
  1362.         setGallerySize: false
  1363.       });
  1364.       this._flickityEvents({
  1365.         $el: this.$gallery,
  1366.         flickity: this.flickity.gallery
  1367.       });
  1368.     }
  1369.     if (this.hasRelatedProducts && !this.flickity.relatedProducts) {
  1370.       this._relatedProductsReset();
  1371.       this.flickity.relatedProducts = new Flickity(this.$relatedProducts[0], {
  1372.         cellAlign: 'left',
  1373.         cellSelector: this.selectors.relatedProducts.itemSelector,
  1374.         contain: true,
  1375.         prevNextButtons: false,
  1376.         pageDots: false,
  1377.         imagesLoaded: true,
  1378.         setGallerySize: false
  1379.       });
  1380.       return this._flickityEvents({
  1381.         $el: this.$relatedProducts,
  1382.         flickity: this.flickity.relatedProducts
  1383.       });
  1384.     }
  1385.   };
  1386.  
  1387.   ProductMasonryLayoutView.prototype._destroyFlickity = function() {
  1388.     if (this.flickity.gallery) {
  1389.       this.flickity.gallery.destroy();
  1390.       this.flickity.gallery = null;
  1391.       this.$window.off('resize.product-images-flickity');
  1392.     }
  1393.     if (this.flickity.relatedProducts) {
  1394.       this.flickity.relatedProducts.destroy();
  1395.       return this.flickity.relatedProducts = null;
  1396.     }
  1397.   };
  1398.  
  1399.   ProductMasonryLayoutView.prototype._initMasonry = function() {
  1400.     if (this.hasGallery && !this.masonry.gallery) {
  1401.       this._galleryReset();
  1402.       this.masonry.gallery = new MasonryGrid({
  1403.         $el: this.$gallery,
  1404.         settings: {
  1405.           itemSelector: this.selectors.gallery.itemSelector,
  1406.           columnWidth: this.selectors.gallery.columnWidth
  1407.         }
  1408.       });
  1409.     }
  1410.     if (this.hasRelatedProducts && !this.masonry.relatedProducts) {
  1411.       this._relatedProductsReset();
  1412.       return this.masonry.relatedProducts = new MasonryGrid({
  1413.         $el: this.$relatedProducts,
  1414.         settings: {
  1415.           itemSelector: this.selectors.relatedProducts.itemSelector,
  1416.           columnWidth: this.selectors.relatedProducts.columnWidth
  1417.         }
  1418.       });
  1419.     }
  1420.   };
  1421.  
  1422.   ProductMasonryLayoutView.prototype._destroyMasonry = function() {
  1423.     if (this.masonry.gallery) {
  1424.       this.masonry.gallery.unload();
  1425.       this.masonry.gallery = null;
  1426.     }
  1427.     if (this.masonry.relatedProducts) {
  1428.       this.masonry.relatedProducts.unload();
  1429.       return this.masonry.relatedProducts = null;
  1430.     }
  1431.   };
  1432.  
  1433.   ProductMasonryLayoutView.prototype._galleryReset = function() {
  1434.     return this.$gallery.find(this.selectors.gallery.itemSelector).css('');
  1435.   };
  1436.  
  1437.   ProductMasonryLayoutView.prototype._relatedProductsReset = function() {
  1438.     return this.$relatedProducts.find(this.selectors.relatedProducts.itemSelector).css('');
  1439.   };
  1440.  
  1441.   ProductMasonryLayoutView.prototype._flickityEvents = function(options) {
  1442.     var $el, flickity;
  1443.     $el = options.$el, flickity = options.flickity;
  1444.     flickity.on('cellSelect', (function(_this) {
  1445.       return function() {
  1446.         return $el.trigger('product-masonry-layout');
  1447.       };
  1448.     })(this));
  1449.     flickity.on('settle', (function(_this) {
  1450.       return function() {
  1451.         return $el.trigger('product-masonry-layout');
  1452.       };
  1453.     })(this));
  1454.     $el.on('product-masonry-layout', (function(_this) {
  1455.       return function() {
  1456.         return window.ThemeUtils.flickityResize(flickity);
  1457.       };
  1458.     })(this));
  1459.     $el.trigger('product-masonry-layout');
  1460.     return this.$window.on('resize.product-images-flickity', window.ThemeUtils.debounce((function(_this) {
  1461.       return function() {
  1462.         return $el.trigger('product-masonry-layout');
  1463.       };
  1464.     })(this), 10));
  1465.   };
  1466.  
  1467.   return ProductMasonryLayoutView;
  1468.  
  1469. })(Backbone.View);
  1470.  
  1471. window.LinkedOptions = (function() {
  1472.   function LinkedOptions(options) {
  1473.     this.options = options;
  1474.     this._init();
  1475.   }
  1476.  
  1477.   LinkedOptions.prototype._init = function() {
  1478.     return this._mapVariants(this.options.productJSON);
  1479.   };
  1480.  
  1481.   LinkedOptions.prototype._getCurrent = function(optionIndex) {
  1482.     var key, option1, option2, selector;
  1483.     if (this.options.type === 'select') {
  1484.       switch (optionIndex) {
  1485.         case 0:
  1486.           key = 'root';
  1487.           selector = this.options.$selector.eq(0);
  1488.           break;
  1489.         case 1:
  1490.           key = this.options.$selector.eq(0).val();
  1491.           selector = this.options.$selector.eq(1);
  1492.           break;
  1493.         case 2:
  1494.           key = (this.options.$selector.eq(0).val()) + " / " + (this.options.$selector.eq(1).val());
  1495.           selector = this.options.$selector.eq(2);
  1496.       }
  1497.     }
  1498.     if (this.options.type === 'radio') {
  1499.       switch (optionIndex) {
  1500.         case 0:
  1501.           key = 'root';
  1502.           selector = this.options.$selector.filter('[data-option-index=0]').filter(':checked');
  1503.           break;
  1504.         case 1:
  1505.           key = this.options.$selector.filter('[data-option-index=0]').filter(':checked').val();
  1506.           selector = this.options.$selector.filter('[data-option-index=1]').filter(':checked');
  1507.           break;
  1508.         case 2:
  1509.           option1 = this.options.$selector.filter('[data-option-index=0]').filter(':checked').val();
  1510.           option2 = this.options.$selector.filter('[data-option-index=1]').filter(':checked').val();
  1511.           key = option1 + " / " + option2;
  1512.           selector = this.options.$selector.filter('[data-option-index=2]').filter(':checked');
  1513.       }
  1514.     }
  1515.     return {
  1516.       key: key,
  1517.       selector: selector
  1518.     };
  1519.   };
  1520.  
  1521.   LinkedOptions.prototype._updateOptions = function(optionIndex, optionsMap) {
  1522.     var $nextOption, $option, $selector, $selectorOptions, availableOptions, i, initialValue, j, key, len, len1, nextSelector, option, ref, selector, updateSelected;
  1523.     nextSelector = optionIndex + 1;
  1524.     updateSelected = false;
  1525.     ref = this._getCurrent(optionIndex), key = ref.key, selector = ref.selector;
  1526.     availableOptions = optionsMap[key] || [];
  1527.     if (this.options.type === 'select') {
  1528.       $selector = this.options.$productForm.find(selector);
  1529.       initialValue = $selector.val();
  1530.       $selectorOptions = $selector.find('option');
  1531.       for (i = 0, len = $selectorOptions.length; i < len; i++) {
  1532.         option = $selectorOptions[i];
  1533.         $option = $(option);
  1534.         if (availableOptions.indexOf(option.value) === -1) {
  1535.           if (option.selected) {
  1536.             updateSelected = true;
  1537.           }
  1538.           $option.prop('disabled', true).prop('selected', false);
  1539.         } else {
  1540.           $option.prop('disabled', false);
  1541.         }
  1542.       }
  1543.       if (availableOptions.indexOf(initialValue) !== -1) {
  1544.         $selector.val(initialValue);
  1545.       }
  1546.       if (updateSelected) {
  1547.         $selectorOptions.filter(':not(:disabled)').eq(0).prop('selected', true);
  1548.       }
  1549.     }
  1550.     if (this.options.type === 'radio') {
  1551.       $selector = this.options.$selector.filter("[data-option-index=" + optionIndex + "]");
  1552.       for (j = 0, len1 = $selector.length; j < len1; j++) {
  1553.         option = $selector[j];
  1554.         $option = $(option);
  1555.         if (availableOptions.indexOf(option.value) === -1) {
  1556.           if (option.checked) {
  1557.             updateSelected = true;
  1558.           }
  1559.           $option.prop('disabled', true).prop('checked', false);
  1560.         } else {
  1561.           $option.prop('disabled', false);
  1562.         }
  1563.       }
  1564.       if (updateSelected) {
  1565.         $selector.filter(':not(:disabled)').eq(0).attr('checked', true).trigger('click');
  1566.       }
  1567.     }
  1568.     $selector.trigger('change');
  1569.     $nextOption = this.options.$selector.filter("[data-option-index=" + nextSelector + "]");
  1570.     if ($nextOption.length !== 0) {
  1571.       return this._updateOptions(nextSelector, optionsMap);
  1572.     }
  1573.   };
  1574.  
  1575.   LinkedOptions.prototype._mapVariants = function(product) {
  1576.     var i, key, len, optionsMap, ref, variant;
  1577.     optionsMap = [];
  1578.     optionsMap['root'] = [];
  1579.     ref = product.variants;
  1580.     for (i = 0, len = ref.length; i < len; i++) {
  1581.       variant = ref[i];
  1582.       if (variant.available) {
  1583.         optionsMap['root'].push(variant.option1);
  1584.         optionsMap['root'] = window.ThemeUtils.unique(optionsMap['root']);
  1585.         if (product.options.length > 1) {
  1586.           key = variant.option1;
  1587.           optionsMap[key] = optionsMap[key] || [];
  1588.           optionsMap[key].push(variant.option2);
  1589.           optionsMap[key] = window.ThemeUtils.unique(optionsMap[key]);
  1590.         }
  1591.         if (product.options.length > 2) {
  1592.           key = variant.option1 + " / " + variant.option2;
  1593.           optionsMap[key] = optionsMap[key] || [];
  1594.           optionsMap[key].push(variant.option3);
  1595.           optionsMap[key] = window.ThemeUtils.unique(optionsMap[key]);
  1596.         }
  1597.       }
  1598.     }
  1599.     this._updateOptions(0, optionsMap);
  1600.     return this.options.$selector.on('change', (function(_this) {
  1601.       return function(event) {
  1602.         var index, nextSelector;
  1603.         index = parseInt($(event.currentTarget).attr('data-option-index'), 10);
  1604.         nextSelector = index + 1;
  1605.         return _this._updateOptions(nextSelector, optionsMap);
  1606.       };
  1607.     })(this));
  1608.   };
  1609.  
  1610.   return LinkedOptions;
  1611.  
  1612. })();
  1613.  
  1614. window.VariantHelper = (function() {
  1615.   function VariantHelper(options) {
  1616.     var defaultOptions, isShopify;
  1617.     defaultOptions = {
  1618.       $addToCartButton: null,
  1619.       $priceFields: null,
  1620.       $productForm: null,
  1621.       $productThumbnails: null,
  1622.       $selector: null,
  1623.       type: 'select',
  1624.       productJSON: null,
  1625.       productSettings: null
  1626.     };
  1627.     this.options = window.ThemeUtils.extend(defaultOptions, options);
  1628.     this.$body = $(document.body);
  1629.     this.linkedOptions = null;
  1630.     this.enableHistory = false;
  1631.     this.$masterSelect = this.options.$productForm.find("#product-select-" + this.options.formID);
  1632.     isShopify = window.Shopify && window.Shopify.preview_host;
  1633.     if (window.history && window.history.replaceState && this.options.productSettings.enableHistory && !isShopify) {
  1634.       this.enableHistory = true;
  1635.     }
  1636.     this._init();
  1637.     this._bindEvents();
  1638.   }
  1639.  
  1640.   VariantHelper.prototype._init = function() {
  1641.     var i, len, ref, select;
  1642.     if (this.options.type === 'select') {
  1643.       ref = this.options.$selector;
  1644.       for (i = 0, len = ref.length; i < len; i++) {
  1645.         select = ref[i];
  1646.         this._setSelectLabel(null, $(select));
  1647.       }
  1648.     }
  1649.     if (this.options.productSettings.linkedOptions) {
  1650.       this.linkedOptions = new LinkedOptions(this.options);
  1651.     }
  1652.     return this._updateCurrency();
  1653.   };
  1654.  
  1655.   VariantHelper.prototype._bindEvents = function() {
  1656.     return this.options.$selector.on('change.variant-helper', (function(_this) {
  1657.       return function(event) {
  1658.         return _this._variantChange(event);
  1659.       };
  1660.     })(this));
  1661.   };
  1662.  
  1663.   VariantHelper.prototype.unload = function() {
  1664.     return this.options.$selector.off('.variant-helper');
  1665.   };
  1666.  
  1667.   VariantHelper.prototype._setSelectLabel = function(event, $target) {
  1668.     var selectedOption;
  1669.     if (event == null) {
  1670.       event = null;
  1671.     }
  1672.     if ($target == null) {
  1673.       $target = false;
  1674.     }
  1675.     if (!$target) {
  1676.       $target = $(event.currentTarget);
  1677.     }
  1678.     selectedOption = $target.find('option:selected').val();
  1679.     return $target.prev('[data-select-text]').find('[data-selected-option]').text(selectedOption);
  1680.   };
  1681.  
  1682.   VariantHelper.prototype._getCurrentOptions = function() {
  1683.     var $inputs, productOptions;
  1684.     productOptions = [];
  1685.     $inputs = this.options.$selector;
  1686.     if (this.options.type === 'radio') {
  1687.       $inputs = $inputs.filter(':checked');
  1688.     }
  1689.     $inputs.each(function(index, element) {
  1690.       return productOptions.push($(element).val());
  1691.     });
  1692.     return productOptions;
  1693.   };
  1694.  
  1695.   VariantHelper.prototype._getVariantFromOptions = function(productOptions) {
  1696.     var foundVariant, i, isMatch, len, ref, variant;
  1697.     if (this.options.productJSON.variants == null) {
  1698.       return;
  1699.     }
  1700.     foundVariant = null;
  1701.     ref = this.options.productJSON.variants;
  1702.     for (i = 0, len = ref.length; i < len; i++) {
  1703.       variant = ref[i];
  1704.       isMatch = productOptions.every(function(value) {
  1705.         return variant.options.indexOf(value) !== -1;
  1706.       });
  1707.       if (isMatch) {
  1708.         foundVariant = variant;
  1709.       }
  1710.     }
  1711.     return foundVariant;
  1712.   };
  1713.  
  1714.   VariantHelper.prototype._updateMasterSelect = function(variant) {
  1715.     var ref;
  1716.     if (variant == null) {
  1717.       return;
  1718.     }
  1719.     if ((ref = this.$masterSelect.find("[data-variant-id=" + variant.id + "]")) != null) {
  1720.       ref.prop('selected', true);
  1721.     }
  1722.     return this.$masterSelect.trigger('change');
  1723.   };
  1724.  
  1725.   VariantHelper.prototype._updatePrice = function(variant) {
  1726.     var $addToCartButton, $moneyEl, $priceFields, attribute, i, j, len, len1, priceField, productSettings, ref;
  1727.     $addToCartButton = this.options.$addToCartButton;
  1728.     $priceFields = this.options.$priceFields;
  1729.     productSettings = this.options.productSettings;
  1730.     if (variant) {
  1731.       for (i = 0, len = $priceFields.length; i < len; i++) {
  1732.         priceField = $priceFields[i];
  1733.         $moneyEl = $(priceField).children('.money');
  1734.         ref = $moneyEl[0].attributes;
  1735.         for (j = 0, len1 = ref.length; j < len1; j++) {
  1736.           attribute = ref[j];
  1737.           if (attribute.name.indexOf("data-") > -1) {
  1738.             $moneyEl.attr(attribute.name, "");
  1739.           }
  1740.         }
  1741.       }
  1742.       if (variant.available) {
  1743.         $addToCartButton.val(productSettings.addToCartText).removeClass('disabled').removeAttr('disabled');
  1744.       } else {
  1745.         $addToCartButton.val(productSettings.soldOutText).addClass('disabled').attr('disabled', 'disabled');
  1746.       }
  1747.       if (variant.compare_at_price > variant.price) {
  1748.         $priceFields.find('.money:not(.original)').html(Shopify.formatMoney(variant.price, Theme.moneyFormat)).attr("data-currency-" + Theme.currency, Shopify.formatMoney(variant.price, Theme.moneyFormat)).attr("data-currency", Theme.currency);
  1749.         $priceFields.find('.original').html(Shopify.formatMoney(variant.compare_at_price, Theme.moneyFormat)).addClass('visible').attr("data-currency-" + Theme.currency, Shopify.formatMoney(variant.compare_at_price, Theme.moneyFormat)).attr("data-currency", Theme.currency);
  1750.       } else {
  1751.         $priceFields.find('.money').html(Shopify.formatMoney(variant.price, Theme.moneyFormat)).attr("data-currency-" + Theme.currency, Shopify.formatMoney(variant.price, Theme.moneyFormat)).attr("data-currency", Theme.currency);
  1752.         $priceFields.find('.original').removeClass('visible').attr("data-currency-" + Theme.currency, Shopify.formatMoney(variant.compare_at_price, Theme.moneyFormat)).attr("data-currency", Theme.currency);
  1753.       }
  1754.     } else {
  1755.       $addToCartButton.val(productSettings.unavailableText).addClass('disabled').attr('disabled', 'disabled');
  1756.     }
  1757.     return this._updateCurrency();
  1758.   };
  1759.  
  1760.   VariantHelper.prototype._updateImages = function(variant) {
  1761.     var $thumbById, $thumbByIndex, imageId, imagePosition, ref, ref1;
  1762.     imageId = variant != null ? (ref = variant.featured_image) != null ? ref.id : void 0 : void 0;
  1763.     imagePosition = (variant != null ? (ref1 = variant.featured_image) != null ? ref1.position : void 0 : void 0) - 1;
  1764.     $thumbById = this.options.$productThumbnails.filter("[data-image-id='" + imageId + "']");
  1765.     $thumbByIndex = this.options.$productThumbnails.filter("[data-image-position='" + imagePosition + "']");
  1766.     if ((imageId != null) && $thumbById.length) {
  1767.       $thumbById.trigger('click');
  1768.     }
  1769.     if ((imagePosition != null) && $thumbByIndex.length) {
  1770.       return $thumbByIndex.trigger('click');
  1771.     }
  1772.   };
  1773.  
  1774.   VariantHelper.prototype._updateHistory = function(variant) {
  1775.     var newUrl, variantUrl;
  1776.     if (!(this.enableHistory && (variant != null))) {
  1777.       return;
  1778.     }
  1779.     newUrl = [window.location.protocol, '//', window.location.host, window.location.pathname, '?variant=', variant.id];
  1780.     variantUrl = newUrl.join('');
  1781.     return window.history.replaceState({
  1782.       path: variantUrl
  1783.     }, '', variantUrl);
  1784.   };
  1785.  
  1786.   VariantHelper.prototype._variantChange = function(event) {
  1787.     var productOptions, variant;
  1788.     if (this.options.type === 'select') {
  1789.       this._setSelectLabel(event);
  1790.     }
  1791.     productOptions = this._getCurrentOptions();
  1792.     variant = this._getVariantFromOptions(productOptions);
  1793.     this._updateMasterSelect(variant);
  1794.     this._updatePrice(variant);
  1795.     this._updateImages(variant);
  1796.     return this._updateHistory(variant);
  1797.   };
  1798.  
  1799.   VariantHelper.prototype._updateCurrency = function() {
  1800.     if (Theme.currencySwitcher) {
  1801.       return $(".currency-switcher").trigger('switch-currency');
  1802.     }
  1803.   };
  1804.  
  1805.   return VariantHelper;
  1806.  
  1807. })();
  1808.  
  1809. window.ImageZoomView = (function(superClass) {
  1810.   extend(ImageZoomView, superClass);
  1811.  
  1812.   function ImageZoomView() {
  1813.     return ImageZoomView.__super__.constructor.apply(this, arguments);
  1814.   }
  1815.  
  1816.   ImageZoomView.prototype.events = {
  1817.     "prepare-zoom": "prepareZoom",
  1818.     "click": "toggleZoom",
  1819.     "mouseout .product-zoom": "toggleZoom",
  1820.     "mousemove .product-zoom": "zoomImage"
  1821.   };
  1822.  
  1823.   ImageZoomView.prototype.initialize = function() {
  1824.     this.zoomArea = this.$(".product-zoom");
  1825.     return this.$el.imagesLoaded((function(_this) {
  1826.       return function() {
  1827.         return _this.prepareZoom();
  1828.       };
  1829.     })(this));
  1830.   };
  1831.  
  1832.   ImageZoomView.prototype.prepareZoom = function() {
  1833.     var newImage, photoAreaHeight, photoAreaWidth;
  1834.     photoAreaWidth = this.$el.width();
  1835.     photoAreaHeight = this.$el.height();
  1836.     newImage = new Image();
  1837.     $(newImage).on("load", (function(_this) {
  1838.       return function() {
  1839.         var ratio, ratios;
  1840.         _this.zoomImageWidth = newImage.width;
  1841.         _this.zoomImageHeight = newImage.height;
  1842.         ratios = new Array();
  1843.         ratios[0] = _this.zoomImageWidth / photoAreaWidth;
  1844.         ratios[1] = _this.zoomImageHeight / photoAreaHeight;
  1845.         ratio = Math.max.apply(Math, ratios);
  1846.         if (ratio < 1.4) {
  1847.           _this.$el.removeClass("zoom-enabled");
  1848.         } else {
  1849.           _this.$el.addClass("zoom-enabled");
  1850.           return _this.zoomArea.css({
  1851.             backgroundImage: "url(" + newImage.src + ")"
  1852.           });
  1853.         }
  1854.       };
  1855.     })(this));
  1856.     return newImage.src = this.$("img").attr("src");
  1857.   };
  1858.  
  1859.   ImageZoomView.prototype.toggleZoom = function(e) {
  1860.     if (this.$el.hasClass("zoom-enabled")) {
  1861.       if (e.type === "mouseout") {
  1862.         this.zoomArea.removeClass("active");
  1863.         return;
  1864.       }
  1865.       this.zoomArea.toggleClass("active");
  1866.       return this.zoomImage(e);
  1867.     }
  1868.   };
  1869.  
  1870.   ImageZoomView.prototype.zoomImage = function(e) {
  1871.     var bigImageOffset, bigImageX, bigImageY, mousePositionX, mousePositionY, newBackgroundPosition, ratioX, ratioY, zoomHeight, zoomWidth;
  1872.     zoomWidth = this.zoomArea.width();
  1873.     zoomHeight = this.zoomArea.height();
  1874.     bigImageOffset = this.$el.offset();
  1875.     bigImageX = Math.round(bigImageOffset.left);
  1876.     bigImageY = Math.round(bigImageOffset.top);
  1877.     mousePositionX = e.pageX - bigImageX;
  1878.     mousePositionY = e.pageY - bigImageY;
  1879.     if (mousePositionX < zoomWidth && mousePositionY < zoomHeight && mousePositionX > 0 && mousePositionY > 0) {
  1880.       if (this.zoomArea.hasClass("active")) {
  1881.         ratioX = Math.round(mousePositionX / zoomWidth * this.zoomImageWidth - zoomWidth / 2) * -1;
  1882.         ratioY = Math.round(mousePositionY / zoomHeight * this.zoomImageHeight - zoomHeight / 2) * -1;
  1883.         if (ratioX > 0) {
  1884.           ratioX = 0;
  1885.         }
  1886.         if (ratioY > 0) {
  1887.           ratioY = 0;
  1888.         }
  1889.         if (ratioX < -(this.zoomImageWidth - zoomWidth)) {
  1890.           ratioX = -(this.zoomImageWidth - zoomWidth);
  1891.         }
  1892.         if (ratioY < -(this.zoomImageHeight - zoomHeight)) {
  1893.           ratioY = -(this.zoomImageHeight - zoomHeight);
  1894.         }
  1895.         newBackgroundPosition = ratioX + "px " + ratioY + "px";
  1896.         return this.zoomArea.css({
  1897.           backgroundPosition: newBackgroundPosition
  1898.         });
  1899.       }
  1900.     }
  1901.   };
  1902.  
  1903.   return ImageZoomView;
  1904.  
  1905. })(Backbone.View);
  1906.  
  1907. window.ProductSlideshowView = (function(superClass) {
  1908.   extend(ProductSlideshowView, superClass);
  1909.  
  1910.   function ProductSlideshowView() {
  1911.     return ProductSlideshowView.__super__.constructor.apply(this, arguments);
  1912.   }
  1913.  
  1914.   ProductSlideshowView.prototype.events = {
  1915.     "click .product-thumbnails-navigation-previous, .product-thumbnails-navigation-next": "moveProductThumbnails"
  1916.   };
  1917.  
  1918.   ProductSlideshowView.prototype.initialize = function() {
  1919.     this.isQuickShop = this.$el.parent().hasClass("quick-shop");
  1920.     this.productThumbnailsWrapper = this.$(".product-thumbnails-wrapper");
  1921.     this.productThumbnails = this.$(".product-thumbnails");
  1922.     this.productThumbnail = this.$(".product-thumbnail");
  1923.     if (this.$(".product-thumbnails").hasClass("has-side-scroll")) {
  1924.       this.setupProductSlideshow();
  1925.       return $(window).resize((function(_this) {
  1926.         return function() {
  1927.           _this.setupProductSlideshow();
  1928.           return _this.productThumbnails.css({
  1929.             "left": 0
  1930.           });
  1931.         };
  1932.       })(this));
  1933.     }
  1934.   };
  1935.  
  1936.   ProductSlideshowView.prototype.setupProductSlideshow = function() {
  1937.     var containerWidth, tallestImageHeight;
  1938.     tallestImageHeight = 0;
  1939.     containerWidth = 0;
  1940.     return this.productThumbnails.imagesLoaded((function(_this) {
  1941.       return function() {
  1942.         var currentImageHeight, currentImageWidth, i, image, len, ref;
  1943.         _this.productThumbnailPadding = parseInt(_this.productThumbnail.css("padding-left"), 10) * 2;
  1944.         _this.productThumbnail.width((_this.productThumbnailsWrapper.width() / 4) - _this.productThumbnailPadding);
  1945.         ref = _this.productThumbnail;
  1946.         for (i = 0, len = ref.length; i < len; i++) {
  1947.           image = ref[i];
  1948.           currentImageHeight = image.getBoundingClientRect().height;
  1949.           currentImageWidth = image.getBoundingClientRect().width;
  1950.           if (currentImageHeight > tallestImageHeight) {
  1951.             tallestImageHeight = currentImageHeight;
  1952.           }
  1953.           containerWidth += currentImageWidth;
  1954.         }
  1955.         _this.productThumbnailsWrapper.height(tallestImageHeight);
  1956.         return _this.productThumbnails.width(containerWidth);
  1957.       };
  1958.     })(this));
  1959.   };
  1960.  
  1961.   ProductSlideshowView.prototype.moveProductThumbnails = function(e) {
  1962.     var containerWidth, currentPosition;
  1963.     containerWidth = this.productThumbnailsWrapper.width();
  1964.     currentPosition = this.productThumbnails.position().left;
  1965.     if ($(e.currentTarget).hasClass("product-thumbnails-navigation-next") && (currentPosition - containerWidth) > -(this.$(".product-thumbnails").outerWidth())) {
  1966.       return this.productThumbnails.css({
  1967.         "left": currentPosition - containerWidth
  1968.       });
  1969.     } else if ($(e.target).hasClass("product-thumbnails-navigation-previous") && currentPosition < 0) {
  1970.       return this.productThumbnails.css({
  1971.         "left": currentPosition + containerWidth
  1972.       });
  1973.     }
  1974.   };
  1975.  
  1976.   return ProductSlideshowView;
  1977.  
  1978. })(Backbone.View);
  1979.  
  1980. window.ProductView = (function(superClass) {
  1981.   extend(ProductView, superClass);
  1982.  
  1983.   function ProductView() {
  1984.     this.setupProductDetails = bind(this.setupProductDetails, this);
  1985.     this.scrollFunction = bind(this.scrollFunction, this);
  1986.     return ProductView.__super__.constructor.apply(this, arguments);
  1987.   }
  1988.  
  1989.   ProductView.prototype.events = {
  1990.     'click .product-thumbnails img': 'swapProductImage',
  1991.     'click .add-to-cart input': 'addToCart'
  1992.   };
  1993.  
  1994.   ProductView.prototype.initialize = function() {
  1995.     this.window = $(window);
  1996.     this.zoomView = null;
  1997.     this.variantHelpers = null;
  1998.     this.productSlideshow = null;
  1999.     this.productMasonryLayout = null;
  2000.     this.rteViews = [];
  2001.     this.selectsViews = [];
  2002.     this.useImagesList = this.$el.is('[data-images-list-view]');
  2003.     this.useZoom = this.$el.is('[data-zoom]');
  2004.     this.useLinkedOptions = this.$el.is('[data-linked-options]');
  2005.     this.useAJAX = this.$el.is('[data-ajax]');
  2006.     this.useMasonry = this.$el.is('[data-product-masonry]');
  2007.     Shopify.onError = (function(_this) {
  2008.       return function(XMLHttpRequest) {
  2009.         return _this.handleErrors(XMLHttpRequest);
  2010.       };
  2011.     })(this);
  2012.     return this.render();
  2013.   };
  2014.  
  2015.   ProductView.prototype.onSectionUnload = function() {
  2016.     var i, j, len, len1, ref, ref1, rte, select;
  2017.     if (this.zoomView) {
  2018.       this.zoomView.remove();
  2019.     }
  2020.     if (this.variantHelpers) {
  2021.       this.variantHelpers.unload();
  2022.     }
  2023.     if (this.productSlideshow) {
  2024.       this.productSlideshow.remove();
  2025.     }
  2026.     if (this.productMasonryLayout) {
  2027.       this.productMasonryLayout.prepareRemove();
  2028.       this.productMasonryLayout.remove();
  2029.     }
  2030.     ref = this.rteViews;
  2031.     for (i = 0, len = ref.length; i < len; i++) {
  2032.       rte = ref[i];
  2033.       rte.remove();
  2034.     }
  2035.     ref1 = this.selectsViews;
  2036.     for (j = 0, len1 = ref1.length; j < len1; j++) {
  2037.       select = ref1[j];
  2038.       select.remove();
  2039.     }
  2040.     return this.window.off('.product-images-list');
  2041.   };
  2042.  
  2043.   ProductView.prototype.render = function() {
  2044.     var $productJSON, $productSettings, i, j, len, len1, ref, ref1, rte, select;
  2045.     this.isQuickShop = this.$el.hasClass('quick-shop-wrapper');
  2046.     this.productId = this.$el.data('product-id');
  2047.     this.minimumPriceArea = this.$('.product-price-minimum');
  2048.     this.productImages = this.$('.product-images');
  2049.     this.mainImage = this.$('.product-main-image img');
  2050.     this.productThumbnail = this.$('.product-thumbnail');
  2051.     this.productDetailsWrapper = this.$('.product-details-wrapper');
  2052.     this.productDetails = this.$('.product-details');
  2053.     this.productMessages = this.$('.product-message');
  2054.     this.$productForm = this.$('[data-product-form]');
  2055.     this.formID = parseInt(this.$productForm.attr('data-product-form'), 10);
  2056.     this.productForm = "product-form-" + this.formID;
  2057.     this.$productThumbnails = this.$('.product-thumbnails img');
  2058.     this.$addToCartButton = this.$('.add-to-cart input');
  2059.     this.$priceArea = this.$('.product-price');
  2060.     $productJSON = this.$("[data-product-json-" + this.formID + "]");
  2061.     $productSettings = this.$("[data-product-settings-" + this.formID + "]");
  2062.     if (!$productJSON.length) {
  2063.       return;
  2064.     }
  2065.     this.productJSON = JSON.parse($productJSON.text());
  2066.     this.productSettings = JSON.parse($productSettings.text());
  2067.     this.$variantDropdowns = this.$("[data-option-select=" + this.formID + "]");
  2068.     this.options = this.productJSON.options;
  2069.     this.variants = this.productJSON.variants;
  2070.     this.setupVariants();
  2071.     if (this.useMasonry) {
  2072.       this.productMasonryLayout = new ProductMasonryLayoutView({
  2073.         el: this.$el
  2074.       });
  2075.     } else if (this.useImagesList) {
  2076.       this.window.on('load.product-images-list resize.product-images-list', window.ThemeUtils.debounce(this.setupProductDetails, 100));
  2077.       this.window.on('scroll.product-images-list', window.ThemeUtils.debounce(this.scrollFunction, 10));
  2078.     } else {
  2079.       this.productSlideshow = new ProductSlideshowView({
  2080.         el: this.productImages
  2081.       });
  2082.     }
  2083.     if (this.useZoom && !this.useImagesList) {
  2084.       this.zoomView = new ImageZoomView({
  2085.         el: this.$('.product-main-image')
  2086.       });
  2087.     }
  2088.     ref = this.$('.rte');
  2089.     for (i = 0, len = ref.length; i < len; i++) {
  2090.       rte = ref[i];
  2091.       this.rteViews.push(new RTEView({
  2092.         el: rte
  2093.       }));
  2094.     }
  2095.     ref1 = this.$('select');
  2096.     for (j = 0, len1 = ref1.length; j < len1; j++) {
  2097.       select = ref1[j];
  2098.       if (!select.hasAttribute('data-select-ignore')) {
  2099.         this.selectsViews.push(new SelectView({
  2100.           el: select
  2101.         }));
  2102.       } else {
  2103.         continue;
  2104.       }
  2105.     }
  2106.     if (Theme.currencySwitcher) {
  2107.       return $('.currency-switcher').trigger('switch-currency');
  2108.     }
  2109.   };
  2110.  
  2111.   ProductView.prototype.scrollFunction = function() {
  2112.     if (window.innerWidth > 770 && document.documentElement.getBoundingClientRect().height > this.detailsHeight) {
  2113.       return this.triggerFixedProductInfo(this.stickyNavHeight, this.detailsWrapperOffset, this.detailsHeight);
  2114.     } else {
  2115.       return this.productDetails.css({
  2116.         'position': 'static'
  2117.       });
  2118.     }
  2119.   };
  2120.  
  2121.   ProductView.prototype.setupVariants = function() {
  2122.     var dropdownSettings, variantHelperDefaults;
  2123.     if (!(this.variants.length > 1)) {
  2124.       return;
  2125.     }
  2126.     variantHelperDefaults = {
  2127.       $addToCartButton: this.$addToCartButton,
  2128.       $priceFields: this.$priceArea,
  2129.       $productForm: this.$productForm,
  2130.       $productThumbnails: this.$productThumbnails,
  2131.       formID: this.formID,
  2132.       productSettings: this.productSettings,
  2133.       productJSON: this.productJSON
  2134.     };
  2135.     if (this.$variantDropdowns.length) {
  2136.       dropdownSettings = {
  2137.         $selector: this.$variantDropdowns,
  2138.         type: 'select'
  2139.       };
  2140.       dropdownSettings = window.ThemeUtils.extend(variantHelperDefaults, dropdownSettings);
  2141.       return this.variantHelpers = new VariantHelper(dropdownSettings);
  2142.     }
  2143.   };
  2144.  
  2145.   ProductView.prototype.swapProductImage = function(e, imageSrc) {
  2146.     var newImage;
  2147.     this.productThumbnail.removeClass('active');
  2148.     if (e) {
  2149.       this.$(e.currentTarget).parent().addClass('active');
  2150.       newImage = this.$(e.currentTarget).data('high-res');
  2151.       return this.$(e.currentTarget).closest(this.$el).find('.product-main-image img').attr('src', newImage).trigger('prepare-zoom');
  2152.     } else {
  2153.       newImage = imageSrc;
  2154.       return this.$('.product-main-image img').attr('src', newImage).trigger('prepare-zoom');
  2155.     }
  2156.   };
  2157.  
  2158.   ProductView.prototype.setupProductDetails = function() {
  2159.     if (!this.useImagesList) {
  2160.       return;
  2161.     }
  2162.     this.productDetails.width(this.productDetailsWrapper.width());
  2163.     this.stickyNavHeight = 0;
  2164.     this.detailsWrapperOffset = this.productDetailsWrapper.offset().top;
  2165.     this.detailsHeight = this.productDetails.get(0).getBoundingClientRect().height;
  2166.     return this.scrollFunction();
  2167.   };
  2168.  
  2169.   ProductView.prototype.triggerFixedProductInfo = function(stickyNavHeight, detailsWrapperOffset, detailsHeight) {
  2170.     var detailsOffset, imagesOffset, scrollTop;
  2171.     if (!this.useImagesList) {
  2172.       return;
  2173.     }
  2174.     scrollTop = this.window.scrollTop();
  2175.     detailsOffset = this.productDetails.offset().top + detailsHeight;
  2176.     imagesOffset = this.productImages.offset().top + this.productImages.get(0).getBoundingClientRect().height;
  2177.     if (this.productDetails.get(0).getBoundingClientRect().height < this.productImages.get(0).getBoundingClientRect().height) {
  2178.       if (detailsWrapperOffset - scrollTop < 0) {
  2179.         if ((detailsOffset < imagesOffset) || scrollTop < (imagesOffset - (detailsHeight + stickyNavHeight))) {
  2180.           return this.productDetails.css({
  2181.             'position': 'fixed',
  2182.             'top': stickyNavHeight
  2183.           });
  2184.         } else if (detailsOffset >= imagesOffset) {
  2185.           return this.productDetails.css({
  2186.             'position': 'absolute',
  2187.             'top': this.productImages.get(0).getBoundingClientRect().height - this.detailsHeight
  2188.           });
  2189.         } else {
  2190.           return this.productDetails.css({
  2191.             'position': 'static'
  2192.           });
  2193.         }
  2194.       } else {
  2195.         return this.productDetails.css({
  2196.           'position': 'static'
  2197.         });
  2198.       }
  2199.     }
  2200.   };
  2201.  
  2202.   ProductView.prototype.addToCart = function(e) {
  2203.     var productId;
  2204.     if (!this.useAJAX) {
  2205.       return;
  2206.     }
  2207.     e.preventDefault();
  2208.     this.productMessages.html('');
  2209.     productId = this.$el.data('product-id');
  2210.     return Shopify.addItemFromForm("product-form-" + productId, (function(_this) {
  2211.       return function(item) {
  2212.         var message;
  2213.         message = Theme.addToCartSuccess.replace('**product**', _this.productJSON.title).replace('**cart_link**', "<a href='/cart'>{{ 'products.product.cart_link' | t }}</a>").replace('**continue_link**', "<a href='/collections/all'>{{ 'products.product.continue_link' | t }}</a>").replace('**checkout_link**', "<a href='/checkout'>{{ 'products.product.checkout_link' | t }}</a>");
  2214.         return setTimeout(function() {
  2215.           _this.productMessages.html(message).addClass('success-message').removeClass('error-message');
  2216.           return _this.updateCart(item);
  2217.         }, 500);
  2218.       };
  2219.     })(this));
  2220.   };
  2221.  
  2222.   ProductView.prototype.updateCart = function(newItem) {
  2223.     var miniCartItemWrapper;
  2224.     $('.mini-cart').removeClass('empty');
  2225.     miniCartItemWrapper = $('.mini-cart-item-wrapper');
  2226.     return Shopify.getCart((function(_this) {
  2227.       return function(cart) {
  2228.         var currencySwitcher, currencyValue, i, image, item, len, price, ref;
  2229.         miniCartItemWrapper.empty();
  2230.         $('[data-cart-count]').html("<span class='cart-count-text'>" + Theme.cartText + "</span> (<span class='cart-count-number'>" + cart.item_count + "</span>)");
  2231.         ref = cart.items;
  2232.         for (i = 0, len = ref.length; i < len; i++) {
  2233.           item = ref[i];
  2234.           price = Shopify.formatMoney(item.price, Theme.moneyFormat);
  2235.           image = item.image != null ? item.image : "{{ 'no-image.svg' | asset_url }}";
  2236.           miniCartItemWrapper.append("<article class='mini-cart-item' data-variant='" + item.variant_id + "' data-url='" + item.url + "' data-title='" + item.title + "'>\n    <figure class='mini-cart-item-image'>\n        <a href='" + item.url + "'>\n            <img alt='" + item.title + "' src='" + image + "'>\n        </a>\n    </figure>\n    <div class='mini-cart-item-details'>\n        <p class='mini-cart-item-quantity'>\n            {{ 'layout.mini_cart.quantity' | t }}: <span>" + item.quantity + "</span>\n        </p>\n        <p class='mini-cart-item-title'>\n            <a href='" + item.url + "'>" + item.title + "</a>\n        </p>\n        <p class='mini-cart-item-price'>\n            <span class='money'>" + price + "</span>\n        </p>\n    </div>\n</article>");
  2237.         }
  2238.         currencySwitcher = $('.currency-switcher select');
  2239.         currencyValue = currencySwitcher.val();
  2240.         return currencySwitcher.val(Theme.currency).trigger('reset-currency').val(currencyValue).trigger('reset-currency');
  2241.       };
  2242.     })(this));
  2243.   };
  2244.  
  2245.   ProductView.prototype.handleErrors = function(error) {
  2246.     var max, message, target, variant, variantID;
  2247.     if (error.responseJSON.message === 'Cart Error') {
  2248.       variantID = parseInt(this.$("#product-select-" + this.productId).val(), 10);
  2249.       target = (function() {
  2250.         var i, len, ref, results;
  2251.         ref = this.variants;
  2252.         results = [];
  2253.         for (i = 0, len = ref.length; i < len; i++) {
  2254.           variant = ref[i];
  2255.           if (variant.id === variantID) {
  2256.             results.push(variant);
  2257.           }
  2258.         }
  2259.         return results;
  2260.       }).call(this);
  2261.       max = target[0].inventory_quantity;
  2262.       message = "{{ 'products.product.error_message_stock' | t: stock: '**stock**' | escape }}".replace('**stock**', max);
  2263.     } else {
  2264.       message = "{{ 'products.product.error_message_general' | t | escape }}";
  2265.     }
  2266.     return setTimeout((function(_this) {
  2267.       return function() {
  2268.         return _this.$('.product-message').html(message).addClass('error-message').removeClass('success-message');
  2269.       };
  2270.     })(this), 1000);
  2271.   };
  2272.  
  2273.   return ProductView;
  2274.  
  2275. })(Backbone.View);
  2276.  
  2277. window.SelectView = (function(superClass) {
  2278.   extend(SelectView, superClass);
  2279.  
  2280.   function SelectView() {
  2281.     return SelectView.__super__.constructor.apply(this, arguments);
  2282.   }
  2283.  
  2284.   SelectView.prototype.events = {
  2285.     "change": "updateSelectText"
  2286.   };
  2287.  
  2288.   SelectView.prototype.initialize = function() {
  2289.     if (!(this.$el.parent(".select-wrapper").length || this.$el.hasClass("product-variants") || this.$el.hasClass("select-disable-wrapper"))) {
  2290.       this.$el.wrap("<div class='select-wrapper' />").parent().prepend("<span class='selected-text'></span>");
  2291.     }
  2292.     return this.updateSelectText();
  2293.   };
  2294.  
  2295.   SelectView.prototype.updateSelectText = function() {
  2296.     var newOption;
  2297.     newOption = this.$el.find("option:selected").prop("selected", true).text();
  2298.     return this.$el.siblings(".selected-text").text(newOption);
  2299.   };
  2300.  
  2301.   return SelectView;
  2302.  
  2303. })(Backbone.View);
  2304.  
  2305. window.RTEView = (function(superClass) {
  2306.   extend(RTEView, superClass);
  2307.  
  2308.   function RTEView() {
  2309.     return RTEView.__super__.constructor.apply(this, arguments);
  2310.   }
  2311.  
  2312.   RTEView.prototype.events = {
  2313.     "click .tabs li": "switchTabs"
  2314.   };
  2315.  
  2316.   RTEView.prototype.initialize = function() {
  2317.     this.setupTabs();
  2318.     return this.resizeVideos();
  2319.   };
  2320.  
  2321.   RTEView.prototype.switchTabs = function(e) {
  2322.     var content, position, tab, tabContainer, tabContentContainer;
  2323.     e.preventDefault();
  2324.     tab = $(e.currentTarget);
  2325.     tabContainer = tab.parent();
  2326.     tabContentContainer = tabContainer.next();
  2327.     position = tab.index();
  2328.     content = tabContentContainer.find("> li").eq(position);
  2329.     tabContainer.find("> li").removeClass("active");
  2330.     tabContentContainer.find("> li").removeClass("active");
  2331.     tab.addClass("active");
  2332.     return content.addClass("active");
  2333.   };
  2334.  
  2335.   RTEView.prototype.setupTabs = function() {
  2336.     var tabs;
  2337.     tabs = this.$el.find(".tabs");
  2338.     tabs.find("li:first").addClass("active");
  2339.     return tabs.next().find("li:first").addClass("active");
  2340.   };
  2341.  
  2342.   RTEView.prototype.resizeVideos = function() {
  2343.     var i, len, ref, results, video;
  2344.     this.$el.fitVids({
  2345.       customSelector: "iframe"
  2346.     });
  2347.     ref = this.$("iframe");
  2348.     results = [];
  2349.     for (i = 0, len = ref.length; i < len; i++) {
  2350.       video = ref[i];
  2351.       video = $(video);
  2352.       if (video.hasClass("highlight")) {
  2353.         results.push(video.parent().addClass("highlight"));
  2354.       } else {
  2355.         results.push(void 0);
  2356.       }
  2357.     }
  2358.     return results;
  2359.   };
  2360.  
  2361.   return RTEView;
  2362.  
  2363. })(Backbone.View);
  2364.  
  2365. window.QuickShopView = (function(superClass) {
  2366.   extend(QuickShopView, superClass);
  2367.  
  2368.   function QuickShopView() {
  2369.     return QuickShopView.__super__.constructor.apply(this, arguments);
  2370.   }
  2371.  
  2372.   QuickShopView.prototype.events = {
  2373.     "click": "closeQuickShop"
  2374.   };
  2375.  
  2376.   QuickShopView.prototype.initialize = function() {
  2377.     this.productImages = this.$(".product-images");
  2378.     this.mainImage = this.$(".product-main-image");
  2379.     this.thumbnailsOuterWrapper = this.$(".product-thumbnails-outer-wrapper");
  2380.     this.thumbnailsWrapper = this.thumbnailsOuterWrapper.find(".product-thumbnails-wrapper");
  2381.     this.thumbnails = this.$(".product-thumbnails");
  2382.     this.productDetails = this.$(".product-details");
  2383.     this.quickShop = this.$(".quick-shop");
  2384.     this.productJSON = this.$el.data("product-json");
  2385.     this.productSettingsJSON = this.$el.data("product-settings-json");
  2386.     Shopify.getProduct(this.$el.data("product-handle"), (function(_this) {
  2387.       return function(item) {
  2388.         $(document.body).addClass("scroll-locked");
  2389.         _this.quickShop.data("item", item);
  2390.         _this.$el.addClass("visible");
  2391.         _this.setupProductDetails(item);
  2392.         return new ProductView({
  2393.           el: _this.$el
  2394.         });
  2395.       };
  2396.     })(this));
  2397.     return $(window).resize((function(_this) {
  2398.       return function() {
  2399.         _this.positionQuickShop();
  2400.         if (window.innerWidth <= 1020 && $(document.body).hasClass("quick-shop-open")) {
  2401.           return _this.closeQuickShop();
  2402.         }
  2403.       };
  2404.     })(this));
  2405.   };
  2406.  
  2407.   QuickShopView.prototype.closeQuickShop = function(e) {
  2408.     if (!this.$(e.target).closest(".quick-shop").length || this.$(e.target).parent().hasClass("quick-shop-close")) {
  2409.       return this.$el.removeClass("visible").one("trend", (function(_this) {
  2410.         return function() {
  2411.           $(document.body).removeClass("scroll-locked");
  2412.           _this.$el.add(_this.quickShop).removeClass("active");
  2413.           _this.mainImage.add(_this.thumbnails).add(_this.productDetails).empty();
  2414.           _this.thumbnailsWrapper.add(_this.thumbnails).removeAttr("style");
  2415.           _this.thumbnails.removeClass("has-side-scroll");
  2416.           return _this.$(".product-thumbnails-navigation").remove();
  2417.         };
  2418.       })(this));
  2419.     }
  2420.   };
  2421.  
  2422.   QuickShopView.prototype.setupProductDetails = function(item) {
  2423.     var addToCartButton, compactImage, compare_at_hidden, description, firstVariant, hasFeaturedImage, hasVariantImage, i, image, index, itemCompareAtPrice, itemPrice, j, l, largeImage, len, len1, len2, len3, m, option, ref, ref1, ref2, ref3, stock, value, variant, variantPrice, vendor, vendorURL, zoom;
  2424.     if (item.images.length > 4) {
  2425.       this.thumbnails.addClass("has-side-scroll");
  2426.     }
  2427.     ref = item.images;
  2428.     for (index = i = 0, len = ref.length; i < len; index = ++i) {
  2429.       image = ref[index];
  2430.       largeImage = Shopify.resizeImage(image, "1024x1024");
  2431.       compactImage = Shopify.resizeImage(image, "compact");
  2432.       if (item.images.length > 1) {
  2433.         this.thumbnails.append("<span class=\"product-thumbnail\">\n    <img data-high-res=\"" + largeImage + "\" src=\"" + compactImage + "\" data-image-position=\"" + index + "\">\n</span>");
  2434.       }
  2435.     }
  2436.     if (item.images.length > 4) {
  2437.       this.thumbnailsOuterWrapper.prepend("<span class=\"product-thumbnails-navigation product-thumbnails-navigation-previous\">&#xe601;</span>");
  2438.       this.thumbnailsOuterWrapper.append("<span class=\"product-thumbnails-navigation product-thumbnails-navigation-next\">&#xe600;</span>");
  2439.     }
  2440.     zoom = "";
  2441.     zoom = "<div class='product-zoom'></div>";
  2442.     firstVariant = item.variants[0];
  2443.     hasVariantImage = firstVariant.featured_image != null;
  2444.     hasFeaturedImage = item.featured_image != null;
  2445.     if (hasVariantImage) {
  2446.       largeImage = Shopify.resizeImage(firstVariant.featured_image.src, "1024x1024");
  2447.       this.mainImage.prepend("<img class=\"product-image\" src=\"" + largeImage + "\">\n" + zoom);
  2448.     } else if (hasFeaturedImage) {
  2449.       largeImage = Shopify.resizeImage(item.featured_image, "1024x1024");
  2450.       this.mainImage.prepend("<img class=\"product-image\" src=\"" + largeImage + "\">\n" + zoom);
  2451.     } else {
  2452.       this.mainImage.prepend('{{ "product-1" | placeholder_svg_tag: "placeholder-svg" }}');
  2453.     }
  2454.     vendor = "";
  2455.     vendorURL = this.$el.data("vendor-url");
  2456.     vendor = "<a class='product-vendor' href='" + vendorURL + "'>" + item.vendor + "</a>";
  2457.     itemPrice = Shopify.formatMoney(firstVariant.price, Theme.moneyFormat);
  2458.     itemCompareAtPrice = "";
  2459.     if (firstVariant.compare_at_price > firstVariant.price) {
  2460.       itemCompareAtPrice = Shopify.formatMoney(firstVariant.compare_at_price, Theme.moneyFormat);
  2461.     }
  2462.     stock = "InStock";
  2463.     addToCartButton = "<input type='submit' value='{{ 'products.product.add_to_cart' | t }}' />";
  2464.     if (!item.available) {
  2465.       stock = "OutOfStock";
  2466.       addToCartButton = "<input type='submit' class='disabled' disabled='disabled' value='{{ 'products.product.sold_out' | t }}' />";
  2467.     }
  2468.     description = "";
  2469.     if (item.description !== null) {
  2470.       description = "<div class='product-description rte' itemprop='description'>" + item.description + "</div>";
  2471.     }
  2472.     compare_at_hidden = firstVariant.price < firstVariant.compare_at_price ? "" : "hidden";
  2473.     this.productDetails.append(vendor + "\n\n<h2 class=\"product-title\">" + item.title + "</h2>\n\n<p class=\"product-price\" itemprop=\"offers\" itemscope itemtype=\"http://schema.org/Offer\">\n    <span class=\"product-price-minimum money\">" + itemPrice + "</span>\n    <span class=\"product-price-compare money original " + compare_at_hidden + "\">" + itemCompareAtPrice + "</span>\n    <link itemprop=\"availability\" href=\"http://schema.org/" + stock + "\">\n</p>\n\n<form action=\"/cart/add\" method=\"post\" id=\"product-form-" + item.id + "\" data-product-form=\"" + item.id + "\" data-product-id=\"" + item.id + "\">\n\n    <script type=\"application/json\" data-product-json-" + item.id + ">\n        " + this.productJSON + "\n    </script>\n\n    <script type=\"application/json\" data-product-settings-" + item.id + ">\n        " + this.productSettingsJSON + "\n    </script>\n\n    <div class=\"product-options\">\n    </div>\n\n    <div class=\"product-quantity inline-input-wrapper\">\n        <label>{{ 'general.general.quantity' | t }}</label>\n        <input type=\"text\" name=\"quantity\" value=\"1\" />\n    </div>\n\n    <div class=\"add-to-cart\">\n        " + addToCartButton + "\n    </div>\n\n    <div class=\"product-message\"></div>\n\n</form>\n\n" + description + "\n\n<a class=\"view-product\" href=\"" + item.url + "\">{{ 'products.quick_shop_modal.view_product' | t }}</a>");
  2474.     if (!(item.options.length === 1 && item.options[0].values[0] === 'Default Title')) {
  2475.       ref1 = item.options;
  2476.       for (j = 0, len1 = ref1.length; j < len1; j++) {
  2477.         option = ref1[j];
  2478.         this.$(".product-options").append("<div class=\"inline-field-wrapper js-required\">\n    <div class=\"selector-wrapper\">\n        <label class=\"select-text\" for=\"single-option-" + item.id + "-" + (option.position - 1) + "\" data-select-text=\"\">\n            <strong>" + option.name + ":</strong>\n        </label>\n        <div class=\"select-wrapper\">\n            <span class=\"selected-text\">\n            " + option.values[0] + "\n            </span>\n            <select class=\"single-option-selector\" id=\"single-option-" + item.id + "-" + (option.position - 1) + "\" data-option-select=\"" + item.id + "\" data-option-index=\"" + (option.position - 1) + "\">");
  2479.         ref2 = option.values;
  2480.         for (l = 0, len2 = ref2.length; l < len2; l++) {
  2481.           value = ref2[l];
  2482.           this.$("#single-option-" + item.id + "-" + (option.position - 1)).append("<option value='" + value + "'>" + value + "</option>");
  2483.         }
  2484.         this.$(".product-options").append("            </select>\n        </div>\n    </div>\n</div>");
  2485.       }
  2486.     }
  2487.     this.$(".product-options").append("<div class=\"product-options\">\n    <div class=\"selector-wrapper no-js-required\">\n        <label for=\"product-select-" + item.id + "\"></label>\n        <div class=\"select-wrapper\">\n            <span class=\"selected-text\">\n            </span>\n            <select class=\"product-select\" name=\"id\" id=\"product-select-" + item.id + "\">");
  2488.     ref3 = item.variants;
  2489.     for (m = 0, len3 = ref3.length; m < len3; m++) {
  2490.       variant = ref3[m];
  2491.       variantPrice = Shopify.formatMoney(variant.price, Theme.moneyFormat);
  2492.       if (variant.available) {
  2493.         this.$("#product-select-" + item.id).append("<option value='" + variant.id + "' data-variant-id='" + variant.id + "' data-sku='" + variant.sku + "'>" + variant.title + " - " + variantPrice + "</option>");
  2494.       } else {
  2495.         this.$("#product-select-" + item.id).append("<option value='" + variant.id + "' data-variant-id='" + variant.id + "' data-sku='" + variant.sku + "' disabled='disabled'>" + variant.title + " - " + variantPrice + "</option>");
  2496.       }
  2497.     }
  2498.     this.$(".product-options").append("            </select>\n        </div>\n    </div>\n</div>");
  2499.     return this.productImages.imagesLoaded((function(_this) {
  2500.       return function() {
  2501.         _this.quickShop.addClass("active");
  2502.         return _this.positionQuickShop();
  2503.       };
  2504.     })(this));
  2505.   };
  2506.  
  2507.   QuickShopView.prototype.positionQuickShop = function() {
  2508.     return this.quickShop.css({
  2509.       marginTop: -(this.quickShop.outerHeight() / 2),
  2510.       marginLeft: -(this.quickShop.outerWidth() / 2)
  2511.     });
  2512.   };
  2513.  
  2514.   return QuickShopView;
  2515.  
  2516. })(Backbone.View);
  2517.  
  2518. window.ProductListItemView = (function(superClass) {
  2519.   extend(ProductListItemView, superClass);
  2520.  
  2521.   function ProductListItemView() {
  2522.     return ProductListItemView.__super__.constructor.apply(this, arguments);
  2523.   }
  2524.  
  2525.   ProductListItemView.prototype.events = {
  2526.     "click .product-list-item-thumbnail": "redirectToProduct",
  2527.     "click .quick-shop-modal-trigger": "openQuickShop"
  2528.   };
  2529.  
  2530.   ProductListItemView.prototype.initialize = function() {
  2531.     this.productHover = $('[data-product-hover]').data('product-hover');
  2532.     if (this.productHover === 'quick-shop' || this.productHover === 'stock-level') {
  2533.       return this.centerProductItemOverlay();
  2534.     }
  2535.   };
  2536.  
  2537.   ProductListItemView.prototype.centerProductItemOverlay = function() {
  2538.     var trigger;
  2539.     if (this.productHover === 'quick-shop') {
  2540.       return trigger = this.$(".quick-shop-modal-trigger");
  2541.     } else if (this.productHover === 'stock-level') {
  2542.       return trigger = this.$(".product-list-item-inventory");
  2543.     }
  2544.   };
  2545.  
  2546.   ProductListItemView.prototype.redirectToProduct = function(e) {
  2547.     var $target, isSlider, url;
  2548.     $target = $(e.target);
  2549.     url = !$target.hasClass('quick-shop-modal-trigger') ? $target.data('url') : null;
  2550.     isSlider = $target.closest('.flickity-slider').length;
  2551.     if (isSlider) {
  2552.       return;
  2553.     }
  2554.     if (url) {
  2555.       return window.location = url;
  2556.     }
  2557.   };
  2558.  
  2559.   ProductListItemView.prototype.openQuickShop = function(e) {
  2560.     var quickShopWrapper;
  2561.     quickShopWrapper = $(".quick-shop-wrapper");
  2562.     quickShopWrapper.data("product-handle", $(e.target).data("product-handle")).data("product-id", $(e.target).data("product-id")).data("variant-id", $(e.target).data("variant-id")).data("vendor-url", $(e.target).data("vendor-url")).data("product-json", $(e.target).siblings("[data-product-json]").text()).data("product-settings-json", $(e.target).siblings("[data-product-settings-json]").text());
  2563.     return this.quickshop = new QuickShopView({
  2564.       el: quickShopWrapper
  2565.     });
  2566.   };
  2567.  
  2568.   return ProductListItemView;
  2569.  
  2570. })(Backbone.View);
  2571.  
  2572. window.HomeProductsView = (function(superClass) {
  2573.   extend(HomeProductsView, superClass);
  2574.  
  2575.   function HomeProductsView() {
  2576.     this._flickity = bind(this._flickity, this);
  2577.     return HomeProductsView.__super__.constructor.apply(this, arguments);
  2578.   }
  2579.  
  2580.   HomeProductsView.prototype.initialize = function() {
  2581.     this.$window = $(window);
  2582.     this.productViews = [];
  2583.     this.$container = this.$('[data-products-container]');
  2584.     this.slide = '.product-list-item';
  2585.     this.flickity = null;
  2586.     this._setupProducts();
  2587.     this._bindEvents();
  2588.     return this._flickity();
  2589.   };
  2590.  
  2591.   HomeProductsView.prototype.prepareRemove = function() {
  2592.     var i, len, productView, ref, results;
  2593.     this.$window.off('resize.home-featured-collections');
  2594.     this._destroyFlickity();
  2595.     if (this.productViews.length) {
  2596.       ref = this.productViews;
  2597.       results = [];
  2598.       for (i = 0, len = ref.length; i < len; i++) {
  2599.         productView = ref[i];
  2600.         results.push(productView.remove());
  2601.       }
  2602.       return results;
  2603.     }
  2604.   };
  2605.  
  2606.   HomeProductsView.prototype._bindEvents = function() {
  2607.     return this.$window.on('resize.home-featured-collections', window.ThemeUtils.debounce(this._flickity, 100));
  2608.   };
  2609.  
  2610.   HomeProductsView.prototype._setupProducts = function() {
  2611.     var i, len, productItem, ref, results;
  2612.     ref = $(".product-list-item", this.$el);
  2613.     results = [];
  2614.     for (i = 0, len = ref.length; i < len; i++) {
  2615.       productItem = ref[i];
  2616.       results.push(this.productViews.push(new ProductListItemView({
  2617.         el: productItem
  2618.       })));
  2619.     }
  2620.     return results;
  2621.   };
  2622.  
  2623.   HomeProductsView.prototype._flickity = function() {
  2624.     if (!this.$container.length) {
  2625.       return;
  2626.     }
  2627.     if (!window.ThemeUtils.isSmall()) {
  2628.       return this._destroyFlickity();
  2629.     }
  2630.     if (this.flickity) {
  2631.       return;
  2632.     }
  2633.     this.flickity = new Flickity(this.$container[0], {
  2634.       cellAlign: 'left',
  2635.       cellSelector: this.slide,
  2636.       contain: false,
  2637.       prevNextButtons: false,
  2638.       pageDots: false,
  2639.       imagesLoaded: true,
  2640.       setGallerySize: false
  2641.     });
  2642.     return this._flickityEvents();
  2643.   };
  2644.  
  2645.   HomeProductsView.prototype._destroyFlickity = function() {
  2646.     if (this.flickity) {
  2647.       this.flickity.destroy();
  2648.       this.flickity = null;
  2649.       this.$window.off('resize.home-featured-collections-flickity');
  2650.       return this.$container.off('home-featured-collections-height');
  2651.     }
  2652.   };
  2653.  
  2654.   HomeProductsView.prototype._flickityEvents = function() {
  2655.     this.flickity.on('cellSelect', (function(_this) {
  2656.       return function() {
  2657.         return _this.$container.trigger('home-featured-collections-height');
  2658.       };
  2659.     })(this));
  2660.     this.flickity.on('settle', (function(_this) {
  2661.       return function() {
  2662.         return _this.$container.trigger('home-featured-collections-height');
  2663.       };
  2664.     })(this));
  2665.     this.$container.on('home-featured-collections-height', (function(_this) {
  2666.       return function() {
  2667.         return window.ThemeUtils.flickityResize(_this.flickity);
  2668.       };
  2669.     })(this));
  2670.     this.$container.trigger('home-featured-collections-height');
  2671.     return this.$window.on('resize.home-featured-collections-flickity', window.ThemeUtils.debounce((function(_this) {
  2672.       return function() {
  2673.         return _this.$container.trigger('home-featured-collections-height');
  2674.       };
  2675.     })(this), 10));
  2676.   };
  2677.  
  2678.   return HomeProductsView;
  2679.  
  2680. })(Backbone.View);
  2681.  
  2682.  
  2683. /**
  2684.  * Get URLs to square versions of an Instagram photo.
  2685.  *
  2686.  * @param {*} photo The instagram photo object, as returned by their API.
  2687.  * @return Object An object with `small` and `large` URLs.
  2688.  */
  2689. function instagramSquared(photo) {
  2690.   var response = { small:'', large:'', thumbnail:'' };
  2691.  
  2692.   // At a bare minimum we need the following:
  2693.   if (!photo || !photo.images || !photo.images.standard_resolution) {
  2694.     console.error('Instagram: can not parse photo data.');
  2695.     return response;
  2696.   }
  2697.  
  2698.   // Set fallbacks in case we can't resize
  2699.   response.large = photo.images.standard_resolution.url;
  2700.   response.small = photo.images.low_resolution
  2701.     ? photo.images.low_resolution.url
  2702.     : photo.images.standard_resolution.url;
  2703.   response.thumbnail = photo.images.thumbnail
  2704.     ? photo.images.thumbnail.url
  2705.     : photo.images.standard_resolution.url;
  2706.  
  2707.   // We need the cropping information from the thumbnail URL
  2708.   if (!photo.images.thumbnail) return response;
  2709.  
  2710.   // Crop each size
  2711.   response.large = getSquareUrl(response.large, photo.images.thumbnail.url);
  2712.   response.small = getSquareUrl(response.small, photo.images.thumbnail.url);
  2713.  
  2714.   return response;
  2715. }
  2716.  
  2717. /**
  2718.  * Resize the template URL based off another URL's sizes.
  2719.  *
  2720.  * This pulls the size information from one URL (in a format like `s320x320`)
  2721.  * and and moves it to another URL.
  2722.  *
  2723.  * This lets us use the cropping information from one URL, and the sizing
  2724.  * information from another. Currently, only the thumbnail size has the crop
  2725.  * info, so the templateU
  2726.  *
  2727.  * @param url
  2728.  *        An Instagram photo URL to pull the sizing information from.
  2729.  *
  2730.  * @param templateUrl
  2731.  *        An Instagram photo URL that has cropping information.
  2732.  */
  2733. function getSquareUrl(url, templateUrl) {
  2734.   var sizes = url.match(/\/[ps]([0-9]+)x([0-9]+)\//);
  2735.   if (!sizes || sizes.length < 3) return templateUrl;
  2736.  
  2737.   var size = Math.round(Math.max(
  2738.     parseInt(sizes[1], 10),
  2739.     parseInt(sizes[2], 10)
  2740.   ));
  2741.  
  2742.   return templateUrl.replace(
  2743.     /\/[ps][0-9]+x[0-9]+\//,
  2744.     "/s" + size + "x" + size + "/"
  2745.   );
  2746. }
  2747. ;
  2748.  
  2749. window.HomeInstagramWidgetView = (function(superClass) {
  2750.   extend(HomeInstagramWidgetView, superClass);
  2751.  
  2752.   function HomeInstagramWidgetView() {
  2753.     return HomeInstagramWidgetView.__super__.constructor.apply(this, arguments);
  2754.   }
  2755.  
  2756.   HomeInstagramWidgetView.prototype.initialize = function() {
  2757.     this.initializedClass = 'instagram-initialized';
  2758.     return this._validate();
  2759.   };
  2760.  
  2761.   HomeInstagramWidgetView.prototype._validate = function() {
  2762.     var accessToken, isInitialized, photoCount;
  2763.     this.$photoContainer = $("[data-instagram-photos]", this.$el);
  2764.     accessToken = $('[data-instagram-token]', this.$el).attr('data-instagram-token');
  2765.     photoCount = $('[data-instagram-photo-count]', this.$el).attr('data-instagram-photo-count');
  2766.     isInitialized = this.$el.hasClass(this.initializedClass);
  2767.     return this._getPhotos(accessToken, photoCount, isInitialized);
  2768.   };
  2769.  
  2770.   HomeInstagramWidgetView.prototype._getPhotos = function(accessToken, photoCount, isInitialized) {
  2771.     var url;
  2772.     if (!accessToken.length) {
  2773.       return this._hasError(false);
  2774.     }
  2775.     if (isInitialized) {
  2776.       return;
  2777.     }
  2778.     url = "https://api.instagram.com/v1/users/self/media/recent?access_token=" + accessToken + "&count=" + photoCount + "&callback=";
  2779.     return $.ajax({
  2780.       type: "GET",
  2781.       dataType: "jsonp",
  2782.       url: url,
  2783.       success: (function(_this) {
  2784.         return function(response) {
  2785.           var i, len, photo, ref, results, sizes;
  2786.           if (response.meta.code === 200) {
  2787.             _this.$photoContainer.empty();
  2788.             ref = response.data;
  2789.             results = [];
  2790.             for (i = 0, len = ref.length; i < len; i++) {
  2791.               photo = ref[i];
  2792.               sizes = instagramSquared(photo);
  2793.               results.push(_this.$photoContainer.append("<a class='instagram-photo' target='_blank' href='" + photo.link + "'><img src='" + sizes.small + "'/></a>"));
  2794.             }
  2795.             return results;
  2796.           } else {
  2797.             _this.$photoContainer.append("<div class='instagram-error'>Instagram error: " + response.meta.error_message + "</div>");
  2798.             return console.log("Instagram error: " + response.meta.error_message);
  2799.           }
  2800.         };
  2801.       })(this),
  2802.       error: (function(_this) {
  2803.         return function(response) {
  2804.           _this.$photoContainer.empty();
  2805.           return console.log("Instagram error: " + response.meta.error_message);
  2806.         };
  2807.       })(this)
  2808.     });
  2809.   };
  2810.  
  2811.   HomeInstagramWidgetView.prototype._hasError = function(response) {
  2812.     this.$el.toggleClass(this.initializedClass, false);
  2813.     if (response) {
  2814.       return console.log("Instagram error: " + response.meta.error_message);
  2815.     }
  2816.   };
  2817.  
  2818.   HomeInstagramWidgetView.prototype.update = function($el) {
  2819.     this.$el = $el;
  2820.     return this._validate();
  2821.   };
  2822.  
  2823.   return HomeInstagramWidgetView;
  2824.  
  2825. })(Backbone.View);
  2826.  
  2827. window.HomeTwitterWidgetView = (function(superClass) {
  2828.   extend(HomeTwitterWidgetView, superClass);
  2829.  
  2830.   function HomeTwitterWidgetView() {
  2831.     this._renderTweets = bind(this._renderTweets, this);
  2832.     return HomeTwitterWidgetView.__super__.constructor.apply(this, arguments);
  2833.   }
  2834.  
  2835.   HomeTwitterWidgetView.prototype.initialize = function() {
  2836.     this.initializedClass = 'twitter-initialized';
  2837.     return this._validate();
  2838.   };
  2839.  
  2840.   HomeTwitterWidgetView.prototype._validate = function() {
  2841.     var isInitialized, showImages, showRetweets;
  2842.     this.$tweetContainer = $("[data-twitter-tweets]", this.$el);
  2843.     this.username = $("[data-twitter-username]", this.$el).attr("data-twitter-username");
  2844.     showRetweets = $("[data-twitter-show-retweets]", this.$el).length;
  2845.     showImages = $("[data-twitter-show-images]", this.$el).length;
  2846.     isInitialized = this.$el.hasClass(this.initializedClass) && this.$tweetContainer.length;
  2847.     return this._getTweets(showRetweets, showImages, isInitialized);
  2848.   };
  2849.  
  2850.   HomeTwitterWidgetView.prototype._getTweets = function(showRetweets, showImages, isInitialized) {
  2851.     var config;
  2852.     if (!this.username.length) {
  2853.       return this._hasError(false);
  2854.     }
  2855.     if (isInitialized) {
  2856.       return;
  2857.     }
  2858.     config = {
  2859.       "profile": {
  2860.         "screenName": this.username
  2861.       },
  2862.       "maxTweets": 1,
  2863.       "enableLinks": true,
  2864.       "showUser": true,
  2865.       "showTime": true,
  2866.       "showRetweet": showRetweets,
  2867.       "showImages": showImages,
  2868.       "showInteraction": true,
  2869.       "customCallback": this._renderTweets,
  2870.       "showInteraction": false,
  2871.       "useEmoji": true
  2872.     };
  2873.     return twitterFetcher.fetch(config);
  2874.   };
  2875.  
  2876.   HomeTwitterWidgetView.prototype._renderTweets = function(tweets) {
  2877.     var i, len, media, timestamp, tweet, user;
  2878.     if (tweets.length) {
  2879.       this.$("[data-tweet]", this.$tweetContainer).empty();
  2880.       for (i = 0, len = tweets.length; i < len; i++) {
  2881.         tweet = tweets[i];
  2882.         tweet = $(tweet);
  2883.         this.$("[data-tweet]", this.$tweetContainer).append(tweet);
  2884.       }
  2885.       media = this.$(".media");
  2886.       user = this.$(".user");
  2887.       this.$("[data-tweet]", this.$tweetContainer).prepend(media);
  2888.       this.$("[data-tweet]", this.$tweetContainer).prepend(user);
  2889.       if (("@" + (this.username.toLowerCase())) !== this.$('[data-scribe="element:screen_name"]').text().toLowerCase()) {
  2890.         this.$('[data-scribe="element:user_link"]').prepend('<svg class="retweet-svg" viewBox="0 0 32 32"> <path class="path1" d="M4 10h20v6l8-8-8-8v6h-24v12h4zM28 22h-20v-6l-8 8 8 8v-6h24v-12h-4z"></path> </svg>');
  2891.       }
  2892.       timestamp = this.$(".timePosted").text().split(" ");
  2893.       return this.$(".timePosted").prepend("<span class='twitter-icon'>&#xF12E;</span>");
  2894.     } else {
  2895.       return console.log("No tweets to display. Most probable cause is an incorrectly entered Widget ID.");
  2896.     }
  2897.   };
  2898.  
  2899.   HomeTwitterWidgetView.prototype._hasError = function(response) {
  2900.     this.$el.toggleClass(this.initializedClass, false);
  2901.     this.$tweetContainer.html();
  2902.     if (response) {
  2903.       return console.log("Twitter error: " + response.meta.error_message);
  2904.     }
  2905.   };
  2906.  
  2907.   HomeTwitterWidgetView.prototype.update = function($el) {
  2908.     this.$el = $el;
  2909.     return this._validate();
  2910.   };
  2911.  
  2912.   return HomeTwitterWidgetView;
  2913.  
  2914. })(Backbone.View);
  2915.  
  2916. window.HomeSocialWidgetsView = (function(superClass) {
  2917.   extend(HomeSocialWidgetsView, superClass);
  2918.  
  2919.   function HomeSocialWidgetsView() {
  2920.     return HomeSocialWidgetsView.__super__.constructor.apply(this, arguments);
  2921.   }
  2922.  
  2923.   HomeSocialWidgetsView.prototype.initialize = function() {
  2924.     if ($('[data-instagram]', this.$el).length) {
  2925.       this.instagram = new HomeInstagramWidgetView({
  2926.         el: this.$el
  2927.       });
  2928.     }
  2929.     if ($('[data-twitter]', this.$el).length) {
  2930.       return this.twitter = new HomeTwitterWidgetView({
  2931.         el: this.$el
  2932.       });
  2933.     }
  2934.   };
  2935.  
  2936.   HomeSocialWidgetsView.prototype.update = function($el) {
  2937.     this.$el = $el;
  2938.     if (this.instagram) {
  2939.       this.instagram.update(this.$el);
  2940.     }
  2941.     if (this.twitter) {
  2942.       return this.twitter.update(this.$el);
  2943.     }
  2944.   };
  2945.  
  2946.   HomeSocialWidgetsView.prototype.remove = function() {
  2947.     this.instagram = null;
  2948.     return this.twitter = null;
  2949.   };
  2950.  
  2951.   return HomeSocialWidgetsView;
  2952.  
  2953. })(Backbone.View);
  2954.  
  2955. window.HomeVideoWithTextOverlay = (function(superClass) {
  2956.   extend(HomeVideoWithTextOverlay, superClass);
  2957.  
  2958.   function HomeVideoWithTextOverlay() {
  2959.     return HomeVideoWithTextOverlay.__super__.constructor.apply(this, arguments);
  2960.   }
  2961.  
  2962.   HomeVideoWithTextOverlay.prototype.events = {
  2963.     'click [data-play-video]': 'playVideo'
  2964.   };
  2965.  
  2966.   HomeVideoWithTextOverlay.prototype.playVideo = function() {
  2967.     var $overlay, $video, delimiter, videoSrc, videoSrcNew;
  2968.     $overlay = this.$el.find('[data-video-overlay]');
  2969.     $video = this.$el.find('iframe');
  2970.     if (!$video.length) {
  2971.       return;
  2972.     }
  2973.     videoSrc = $video.attr('src');
  2974.     delimiter = (videoSrc != null ? videoSrc.indexOf('?') : void 0) === -1 ? '?' : '&';
  2975.     videoSrcNew = "" + videoSrc + delimiter + "autoplay=1";
  2976.     return $overlay.addClass('overlay-inactive').one('trend', (function(_this) {
  2977.       return function() {
  2978.         $video.attr('src', videoSrcNew);
  2979.         return $overlay.remove();
  2980.       };
  2981.     })(this));
  2982.   };
  2983.  
  2984.   HomeVideoWithTextOverlay.prototype.prepareRemove = function() {
  2985.     var ref;
  2986.     return (ref = this.video) != null ? ref.remove() : void 0;
  2987.   };
  2988.  
  2989.   return HomeVideoWithTextOverlay;
  2990.  
  2991. })(Backbone.View);
  2992.  
  2993. window.HomeTestimonialsView = (function(superClass) {
  2994.   extend(HomeTestimonialsView, superClass);
  2995.  
  2996.   function HomeTestimonialsView() {
  2997.     this._flickity = bind(this._flickity, this);
  2998.     return HomeTestimonialsView.__super__.constructor.apply(this, arguments);
  2999.   }
  3000.  
  3001.   HomeTestimonialsView.prototype.initialize = function() {
  3002.     this.container = 'data-testimonials-container';
  3003.     this.slide = 'data-testimonial-item';
  3004.     this.$window = $(window);
  3005.     this.$testimonialsContainer = this.$el.find("[" + this.container + "]");
  3006.     this.flickity = null;
  3007.     this._bindEvents();
  3008.     return this._flickity();
  3009.   };
  3010.  
  3011.   HomeTestimonialsView.prototype.prepareRemove = function() {
  3012.     this.$window.off('resize.testimonials');
  3013.     return this._destroyFlickity();
  3014.   };
  3015.  
  3016.   HomeTestimonialsView.prototype._bindEvents = function() {
  3017.     return this.$window.on('resize.testimonials', window.ThemeUtils.debounce(this._flickity, 100));
  3018.   };
  3019.  
  3020.   HomeTestimonialsView.prototype._flickity = function() {
  3021.     if (!this.$testimonialsContainer.length) {
  3022.       return;
  3023.     }
  3024.     if (!window.ThemeUtils.isSmall()) {
  3025.       return this._destroyFlickity();
  3026.     }
  3027.     if (this.flickity) {
  3028.       return;
  3029.     }
  3030.     return this.flickity = new Flickity(this.$testimonialsContainer[0], {
  3031.       cellAlign: 'center',
  3032.       cellSelector: "[" + this.slide + "]",
  3033.       contain: true,
  3034.       prevNextButtons: false,
  3035.       pageDots: false,
  3036.       imagesLoaded: true
  3037.     });
  3038.   };
  3039.  
  3040.   HomeTestimonialsView.prototype._destroyFlickity = function() {
  3041.     if (this.flickity) {
  3042.       this.flickity.destroy();
  3043.       return this.flickity = null;
  3044.     }
  3045.   };
  3046.  
  3047.   HomeTestimonialsView.prototype.onBlockSelect = function(event) {
  3048.     var index;
  3049.     if (!this.flickity) {
  3050.       return;
  3051.     }
  3052.     index = parseInt($(event.target).attr(this.slide), 10) - 1;
  3053.     return this.flickity.select(index, true);
  3054.   };
  3055.  
  3056.   return HomeTestimonialsView;
  3057.  
  3058. })(Backbone.View);
  3059.  
  3060. window.HomePromotionView = (function(superClass) {
  3061.   extend(HomePromotionView, superClass);
  3062.  
  3063.   function HomePromotionView() {
  3064.     this._headerOffset = bind(this._headerOffset, this);
  3065.     this.adjustHeight = bind(this.adjustHeight, this);
  3066.     return HomePromotionView.__super__.constructor.apply(this, arguments);
  3067.   }
  3068.  
  3069.   HomePromotionView.prototype.initialize = function() {
  3070.     this.$window = $(window);
  3071.     this.$body = $('body');
  3072.     this.$header = $('[data-section-type="header"]');
  3073.     this.$parent = this.$el.parent();
  3074.     this.$wrapper = this.$('[data-promotion-wrapper]');
  3075.     this.$content = this.$('[data-promotion-content]');
  3076.     this.$image = this.$('[data-promotion-image]');
  3077.     this.$imageContainer = this.$('[data-promotion-image-container]');
  3078.     this.isFullScreen = this.$el.is('[data-section-full-screen]');
  3079.     this._bindEvents();
  3080.     return this.adjustHeight();
  3081.   };
  3082.  
  3083.   HomePromotionView.prototype.prepareRemove = function() {
  3084.     return this.$window.off('.home-promotion');
  3085.   };
  3086.  
  3087.   HomePromotionView.prototype.onSectionReorder = function() {
  3088.     return this._headerOffset();
  3089.   };
  3090.  
  3091.   HomePromotionView.prototype.adjustHeight = function() {
  3092.     var heights, minHeight;
  3093.     heights = [];
  3094.     if (this.$imageContainer.length) {
  3095.       if (this.$content.length) {
  3096.         heights.push(this.$content.outerHeight(true));
  3097.       }
  3098.       if (this.$image.length) {
  3099.         heights.push(this.$image.outerHeight(true));
  3100.       }
  3101.       minHeight = Math.max.apply(null, heights);
  3102.       this.$imageContainer.css({
  3103.         minHeight: minHeight
  3104.       });
  3105.     }
  3106.     return this._headerOffset();
  3107.   };
  3108.  
  3109.   HomePromotionView.prototype._bindEvents = function() {
  3110.     this.$window.on('resize.home-promotion', window.ThemeUtils.debounce(this.adjustHeight, 100));
  3111.     return this.$window.on('scroll.home-promotion', window.ThemeUtils.debounce(this.adjustHeight, 10));
  3112.   };
  3113.  
  3114.   HomePromotionView.prototype._headerOffset = function() {
  3115.     var headerHeight, headerScrolledHeight, isFirstChild, isStickyEnabled, maxHeight, newHeight;
  3116.     if (!this.isFullScreen) {
  3117.       return;
  3118.     }
  3119.     headerHeight = this.$header.outerHeight(true);
  3120.     headerScrolledHeight = this.$header.find('.navigation').outerHeight(true);
  3121.     isFirstChild = this.$parent.is(':first-child');
  3122.     isStickyEnabled = this.$body.hasClass('sticky-header');
  3123.     maxHeight = this.$window.height();
  3124.     if (window.ThemeUtils.isMedium()) {
  3125.       this.$wrapper.css('height', '');
  3126.     }
  3127.     if (isFirstChild) {
  3128.       newHeight = maxHeight - headerHeight;
  3129.       return this.$wrapper.height(newHeight);
  3130.     } else if (!window.ThemeUtils.isMedium() && isStickyEnabled) {
  3131.       newHeight = maxHeight - headerScrolledHeight;
  3132.       return this.$wrapper.height(newHeight);
  3133.     } else {
  3134.       return this.$wrapper.css('height', '');
  3135.     }
  3136.   };
  3137.  
  3138.   return HomePromotionView;
  3139.  
  3140. })(Backbone.View);
  3141.  
  3142. window.HomeBlogView = (function(superClass) {
  3143.   extend(HomeBlogView, superClass);
  3144.  
  3145.   function HomeBlogView() {
  3146.     this._flickity = bind(this._flickity, this);
  3147.     return HomeBlogView.__super__.constructor.apply(this, arguments);
  3148.   }
  3149.  
  3150.   HomeBlogView.prototype.initialize = function() {
  3151.     this.container = 'data-blog-container';
  3152.     this.slide = '.home-blog-post';
  3153.     this.$window = $(window);
  3154.     this.$container = this.$el.find("[" + this.container + "]");
  3155.     this.flickity = null;
  3156.     this._bindEvents();
  3157.     return this._flickity();
  3158.   };
  3159.  
  3160.   HomeBlogView.prototype.prepareRemove = function() {
  3161.     this.$window.off('resize.home-blog-posts');
  3162.     return this._destroyFlickity();
  3163.   };
  3164.  
  3165.   HomeBlogView.prototype._bindEvents = function() {
  3166.     return this.$window.on('resize.home-blog-posts', window.ThemeUtils.debounce(this._flickity, 100));
  3167.   };
  3168.  
  3169.   HomeBlogView.prototype._flickity = function() {
  3170.     if (!this.$container.length) {
  3171.       return;
  3172.     }
  3173.     if (!window.ThemeUtils.isSmall()) {
  3174.       return this._destroyFlickity();
  3175.     }
  3176.     if (this.flickity) {
  3177.       return;
  3178.     }
  3179.     this.flickity = new Flickity(this.$container[0], {
  3180.       cellAlign: 'left',
  3181.       cellSelector: this.slide,
  3182.       contain: false,
  3183.       prevNextButtons: false,
  3184.       pageDots: false,
  3185.       imagesLoaded: true,
  3186.       setGallerySize: false
  3187.     });
  3188.     return this._flickityEvents();
  3189.   };
  3190.  
  3191.   HomeBlogView.prototype._destroyFlickity = function() {
  3192.     if (this.flickity) {
  3193.       this.flickity.destroy();
  3194.       this.flickity = null;
  3195.       this.$window.off('resize.home-blog-posts-flickity');
  3196.       return this.$container.off('home-blog-posts-height');
  3197.     }
  3198.   };
  3199.  
  3200.   HomeBlogView.prototype._flickityEvents = function() {
  3201.     this.flickity.on('cellSelect', (function(_this) {
  3202.       return function() {
  3203.         return _this.$container.trigger('home-blog-posts-height');
  3204.       };
  3205.     })(this));
  3206.     this.flickity.on('settle', (function(_this) {
  3207.       return function() {
  3208.         return _this.$container.trigger('home-blog-posts-height');
  3209.       };
  3210.     })(this));
  3211.     this.$container.on('home-blog-posts-height', (function(_this) {
  3212.       return function() {
  3213.         return window.ThemeUtils.flickityResize(_this.flickity);
  3214.       };
  3215.     })(this));
  3216.     this.$container.trigger('home-blog-posts-height');
  3217.     return this.$window.on('resize.home-blog-posts-flickity', window.ThemeUtils.debounce((function(_this) {
  3218.       return function() {
  3219.         return _this.$container.trigger('home-blog-posts-height');
  3220.       };
  3221.     })(this), 10));
  3222.   };
  3223.  
  3224.   return HomeBlogView;
  3225.  
  3226. })(Backbone.View);
  3227.  
  3228. window.HomeView = (function(superClass) {
  3229.   extend(HomeView, superClass);
  3230.  
  3231.   function HomeView() {
  3232.     return HomeView.__super__.constructor.apply(this, arguments);
  3233.   }
  3234.  
  3235.   HomeView.prototype.initialize = function() {
  3236.     return this.sectionBinding();
  3237.   };
  3238.  
  3239.   HomeView.prototype.sectionBinding = function() {
  3240.     this.sections = new ThemeEditor();
  3241.     this.sections.register('home-slideshow', this.homeSlideshow(this.sections));
  3242.     this.sections.register('home-masonry', this.homeMasonry(this.sections));
  3243.     this.sections.register('home-masonry-alternative', this.homeMasonryAlternative(this.sections));
  3244.     this.sections.register('home-collection-list', this.collectionList(this.sections));
  3245.     this.sections.register('home-featured-collection', this.featuredCollection(this.sections));
  3246.     this.sections.register('home-social-widgets', this.socialWidgets(this.sections));
  3247.     this.sections.register('home-testimonials', this.testimonials(this.sections));
  3248.     this.sections.register('home-video-with-text-overlay', this.videoWithTextOverlay(this.sections));
  3249.     this.sections.register('home-promotion', this.homePromotion(this.sections));
  3250.     return this.sections.register('home-blog', this.homeBlog(this.sections));
  3251.   };
  3252.  
  3253.   HomeView.prototype.homeSlideshow = function(sections) {
  3254.     return {
  3255.       instances: {},
  3256.       init: function(instance) {
  3257.         return this.instances[instance.sectionId] = new HomeSlideshowView({
  3258.           el: instance.$container
  3259.         });
  3260.       },
  3261.       onSectionLoad: function(event) {
  3262.         var instance;
  3263.         instance = sections.getInstance(event);
  3264.         if (this.instances[instance.sectionId] == null) {
  3265.           return this.init(instance);
  3266.         }
  3267.       },
  3268.       onBlockSelect: function(event) {
  3269.         var instance, ref;
  3270.         instance = sections.getInstance(event);
  3271.         return (ref = this.instances[instance.sectionId]) != null ? ref.onBlockSelect(event) : void 0;
  3272.       },
  3273.       onSectionUnload: function(event) {
  3274.         var instance, ref, ref1;
  3275.         instance = sections.getInstance(event);
  3276.         if ((ref = this.instances[instance.sectionId]) != null) {
  3277.           ref.unload();
  3278.         }
  3279.         if ((ref1 = this.instances[instance.sectionId]) != null) {
  3280.           ref1.remove();
  3281.         }
  3282.         return delete this.instances[instance.sectionId];
  3283.       }
  3284.     };
  3285.   };
  3286.  
  3287.   HomeView.prototype.homeMasonry = function(sections) {
  3288.     return {
  3289.       instances: {},
  3290.       init: function(instance) {
  3291.         return this.instances[instance.sectionId] = new HomeMasonryView({
  3292.           el: instance.$container
  3293.         });
  3294.       },
  3295.       onSectionLoad: function(event) {
  3296.         var instance;
  3297.         instance = sections.getInstance(event);
  3298.         if (this.instances[instance.sectionId] == null) {
  3299.           return this.init(instance);
  3300.         }
  3301.       },
  3302.       onSectionSelect: function(event) {
  3303.         var instance, ref;
  3304.         instance = sections.getInstance(event);
  3305.         return (ref = this.instances[instance.sectionId]) != null ? ref.update(instance.$container) : void 0;
  3306.       },
  3307.       onSectionDeselect: function(event) {
  3308.         return this.onSectionSelect(event);
  3309.       },
  3310.       onSectionUnload: function(event) {
  3311.         var instance;
  3312.         instance = sections.getInstance(event);
  3313.         this.instances[instance.sectionId].prepareRemove();
  3314.         this.instances[instance.sectionId].remove();
  3315.         return delete this.instances[instance.sectionId];
  3316.       }
  3317.     };
  3318.   };
  3319.  
  3320.   HomeView.prototype.homeMasonryAlternative = function(sections) {
  3321.     return {
  3322.       instances: {},
  3323.       init: function(instance) {
  3324.         return this.instances[instance.sectionId] = new HomeMasonryAlternativeView({
  3325.           el: instance.$container
  3326.         });
  3327.       },
  3328.       onSectionLoad: function(event) {
  3329.         var instance;
  3330.         instance = sections.getInstance(event);
  3331.         if (this.instances[instance.sectionId] == null) {
  3332.           return this.init(instance);
  3333.         }
  3334.       },
  3335.       onSectionSelect: function(event) {
  3336.         var instance, ref;
  3337.         instance = sections.getInstance(event);
  3338.         return (ref = this.instances[instance.sectionId]) != null ? ref.update(instance.$container) : void 0;
  3339.       },
  3340.       onSectionDeselect: function(event) {
  3341.         return this.onSectionSelect(event);
  3342.       },
  3343.       onSectionUnload: function(event) {
  3344.         var instance, ref;
  3345.         instance = sections.getInstance(event);
  3346.         if ((ref = this.instances[instance.sectionId]) != null) {
  3347.           ref.remove();
  3348.         }
  3349.         return delete this.instances[instance.sectionId];
  3350.       }
  3351.     };
  3352.   };
  3353.  
  3354.   HomeView.prototype.socialWidgets = function(sections) {
  3355.     return {
  3356.       instances: {},
  3357.       init: function(instance) {
  3358.         return this.instances[instance.sectionId] = new HomeSocialWidgetsView({
  3359.           el: instance.$container
  3360.         });
  3361.       },
  3362.       onSectionLoad: function(event) {
  3363.         var instance;
  3364.         instance = sections.getInstance(event);
  3365.         if (this.instances[instance.sectionId] == null) {
  3366.           return this.init(instance);
  3367.         }
  3368.       },
  3369.       onSectionSelect: function(event) {
  3370.         var instance, ref;
  3371.         instance = sections.getInstance(event);
  3372.         return (ref = this.instances[instance.sectionId]) != null ? ref.update(instance.$container) : void 0;
  3373.       },
  3374.       onSectionDeselect: function(event) {
  3375.         return this.onSectionSelect(event);
  3376.       },
  3377.       onSectionUnload: function(event) {
  3378.         var instance, ref;
  3379.         instance = sections.getInstance(event);
  3380.         if ((ref = this.instances[instance.sectionId]) != null) {
  3381.           ref.remove();
  3382.         }
  3383.         return delete this.instances[instance.sectionId];
  3384.       }
  3385.     };
  3386.   };
  3387.  
  3388.   HomeView.prototype.collectionList = function(sections) {
  3389.     return {
  3390.       instances: {},
  3391.       init: function(instance) {
  3392.         return this.instances[instance.sectionId] = new HomeCollectionsView({
  3393.           el: instance.$container
  3394.         });
  3395.       },
  3396.       onSectionLoad: function(event) {
  3397.         var instance;
  3398.         instance = sections.getInstance(event);
  3399.         if (this.instances[instance.sectionId] == null) {
  3400.           return this.init(instance);
  3401.         }
  3402.       },
  3403.       onSectionSelect: function(event) {
  3404.         var instance, ref;
  3405.         instance = sections.getInstance(event);
  3406.         return (ref = this.instances[instance.sectionId]) != null ? ref.update(instance.$container) : void 0;
  3407.       },
  3408.       onSectionDeselect: function(event) {
  3409.         return this.onSectionSelect(event);
  3410.       },
  3411.       onSectionUnload: function(event) {
  3412.         var instance, ref;
  3413.         instance = sections.getInstance(event);
  3414.         if ((ref = this.instances[instance.sectionId]) != null) {
  3415.           ref.remove();
  3416.         }
  3417.         return delete this.instances[instance.sectionId];
  3418.       },
  3419.       onBlockSelect: function(event) {
  3420.         var instance, ref;
  3421.         instance = sections.getInstance(event);
  3422.         return (ref = this.instances[instance.sectionId]) != null ? ref.onBlockSelect(event) : void 0;
  3423.       },
  3424.       onBlockDeselect: function(event) {
  3425.         var instance, ref;
  3426.         instance = sections.getInstance(event);
  3427.         return (ref = this.instances[instance.sectionId]) != null ? ref.onBlockDeselect(event) : void 0;
  3428.       }
  3429.     };
  3430.   };
  3431.  
  3432.   HomeView.prototype.featuredCollection = function(sections) {
  3433.     return {
  3434.       instances: {},
  3435.       init: function(instance) {
  3436.         return this.instances[instance.sectionId] = new HomeProductsView({
  3437.           el: instance.$container
  3438.         });
  3439.       },
  3440.       onSectionLoad: function(event) {
  3441.         var instance;
  3442.         instance = sections.getInstance(event);
  3443.         if (this.instances[instance.sectionId] == null) {
  3444.           return this.init(instance);
  3445.         }
  3446.       },
  3447.       onSectionUnload: function(event) {
  3448.         var instance, ref, ref1;
  3449.         instance = sections.getInstance(event);
  3450.         if ((ref = this.instances[instance.sectionId]) != null) {
  3451.           ref.prepareRemove();
  3452.         }
  3453.         if ((ref1 = this.instances[instance.sectionId]) != null) {
  3454.           ref1.remove();
  3455.         }
  3456.         return delete this.instances[instance.sectionId];
  3457.       }
  3458.     };
  3459.   };
  3460.  
  3461.   HomeView.prototype.socialWidgets = function(sections) {
  3462.     return {
  3463.       instances: {},
  3464.       init: function(instance) {
  3465.         return this.instances[instance.sectionId] = new HomeSocialWidgetsView({
  3466.           el: instance.$container
  3467.         });
  3468.       },
  3469.       onSectionLoad: function(event) {
  3470.         var instance;
  3471.         instance = sections.getInstance(event);
  3472.         if (this.instances[instance.sectionId] == null) {
  3473.           return this.init(instance);
  3474.         }
  3475.       },
  3476.       onSectionSelect: function(event) {
  3477.         var instance, ref;
  3478.         instance = sections.getInstance(event);
  3479.         return (ref = this.instances[instance.sectionId]) != null ? ref.update(instance.$container) : void 0;
  3480.       },
  3481.       onSectionDeselect: function(event) {
  3482.         return this.onSectionSelect(event);
  3483.       },
  3484.       onSectionUnload: function(event) {
  3485.         var instance, ref;
  3486.         instance = sections.getInstance(event);
  3487.         if ((ref = this.instances[instance.sectionId]) != null) {
  3488.           ref.remove();
  3489.         }
  3490.         return delete this.instances[instance.sectionId];
  3491.       }
  3492.     };
  3493.   };
  3494.  
  3495.   HomeView.prototype.testimonials = function(sections) {
  3496.     return {
  3497.       instances: {},
  3498.       init: function(instance) {
  3499.         return this.instances[instance.sectionId] = new HomeTestimonialsView({
  3500.           el: instance.$container
  3501.         });
  3502.       },
  3503.       onSectionLoad: function(event) {
  3504.         var instance;
  3505.         instance = sections.getInstance(event);
  3506.         if (this.instances[instance.sectionId] == null) {
  3507.           return this.init(instance);
  3508.         }
  3509.       },
  3510.       onSectionSelect: function(event) {
  3511.         return this.onSectionLoad(event);
  3512.       },
  3513.       onSectionUnload: function(event) {
  3514.         var instance;
  3515.         instance = sections.getInstance(event);
  3516.         this.instances[instance.sectionId].prepareRemove();
  3517.         this.instances[instance.sectionId].remove();
  3518.         return delete this.instances[instance.sectionId];
  3519.       },
  3520.       onBlockSelect: function(event) {
  3521.         var instance, ref;
  3522.         instance = sections.getInstance(event);
  3523.         return (ref = this.instances[instance.sectionId]) != null ? ref.onBlockSelect(event) : void 0;
  3524.       }
  3525.     };
  3526.   };
  3527.  
  3528.   HomeView.prototype.videoWithTextOverlay = function(sections) {
  3529.     return {
  3530.       instances: {},
  3531.       init: function(instance) {
  3532.         return this.instances[instance.sectionId] = new HomeVideoWithTextOverlay({
  3533.           el: instance.$container
  3534.         });
  3535.       },
  3536.       onSectionLoad: function(event) {
  3537.         var instance;
  3538.         instance = sections.getInstance(event);
  3539.         if (this.instances[instance.sectionId] == null) {
  3540.           return this.init(instance);
  3541.         }
  3542.       },
  3543.       onSectionSelect: function(event) {
  3544.         return this.onSectionLoad(event);
  3545.       },
  3546.       onSectionUnload: function(event) {
  3547.         var instance;
  3548.         instance = sections.getInstance(event);
  3549.         this.instances[instance.sectionId].prepareRemove();
  3550.         this.instances[instance.sectionId].remove();
  3551.         return delete this.instances[instance.sectionId];
  3552.       }
  3553.     };
  3554.   };
  3555.  
  3556.   HomeView.prototype.homePromotion = function(sections) {
  3557.     return {
  3558.       instances: {},
  3559.       init: function(instance) {
  3560.         return this.instances[instance.sectionId] = new HomePromotionView({
  3561.           el: instance.$container
  3562.         });
  3563.       },
  3564.       onSectionLoad: function(event) {
  3565.         var instance;
  3566.         instance = sections.getInstance(event);
  3567.         if (this.instances[instance.sectionId] == null) {
  3568.           return this.init(instance);
  3569.         }
  3570.       },
  3571.       onSectionSelect: function(event) {
  3572.         var instance;
  3573.         instance = sections.getInstance(event);
  3574.         return this.instances[instance.sectionId].adjustHeight();
  3575.       },
  3576.       onSectionDeSelect: function(event) {
  3577.         return this.onSectionSelect(event);
  3578.       },
  3579.       onSectionReorder: function() {
  3580.         var i, instance, len, ref, results;
  3581.         ref = this.instances;
  3582.         results = [];
  3583.         for (i = 0, len = ref.length; i < len; i++) {
  3584.           instance = ref[i];
  3585.           results.push(instance.onSectionReorder());
  3586.         }
  3587.         return results;
  3588.       },
  3589.       onSectionUnload: function(event) {
  3590.         var instance;
  3591.         instance = sections.getInstance(event);
  3592.         this.instances[instance.sectionId].prepareRemove();
  3593.         this.instances[instance.sectionId].remove();
  3594.         return delete this.instances[instance.sectionId];
  3595.       }
  3596.     };
  3597.   };
  3598.  
  3599.   HomeView.prototype.homeBlog = function(sections) {
  3600.     return {
  3601.       instances: {},
  3602.       init: function(instance) {
  3603.         return this.instances[instance.sectionId] = new HomeBlogView({
  3604.           el: instance.$container
  3605.         });
  3606.       },
  3607.       onSectionLoad: function(event) {
  3608.         var instance;
  3609.         instance = sections.getInstance(event);
  3610.         if (this.instances[instance.sectionId] == null) {
  3611.           return this.init(instance);
  3612.         }
  3613.       },
  3614.       onSectionUnload: function(event) {
  3615.         var instance;
  3616.         instance = sections.getInstance(event);
  3617.         this.instances[instance.sectionId].prepareRemove();
  3618.         this.instances[instance.sectionId].remove();
  3619.         return delete this.instances[instance.sectionId];
  3620.       }
  3621.     };
  3622.   };
  3623.  
  3624.   return HomeView;
  3625.  
  3626. })(Backbone.View);
  3627.  
  3628. window.AccountView = (function(superClass) {
  3629.   extend(AccountView, superClass);
  3630.  
  3631.   function AccountView() {
  3632.     return AccountView.__super__.constructor.apply(this, arguments);
  3633.   }
  3634.  
  3635.   AccountView.prototype.events = {
  3636.     "click .delete-address": "deleteAddress",
  3637.     "click .edit-address": "editAddress",
  3638.     "click .add-new-address": "addNewAddress",
  3639.     "click .toggle-forgetfulness": "recoverPassword",
  3640.     "change .address-country": "updateProvinceSelectText"
  3641.   };
  3642.  
  3643.   AccountView.prototype.initialize = function() {
  3644.     var body;
  3645.     body = $(document.body);
  3646.     if (body.hasClass("template-customers-addresses")) {
  3647.       this.prepareAddresses();
  3648.     }
  3649.     if (body.hasClass("template-customers-login")) {
  3650.       this.checkForReset();
  3651.     }
  3652.     if (window.location.hash === "#recover") {
  3653.       return this.recoverPassword();
  3654.     }
  3655.   };
  3656.  
  3657.   AccountView.prototype.recoverPassword = function() {
  3658.     this.$(".recover-password").toggle();
  3659.     return this.$(".customer-login").toggle();
  3660.   };
  3661.  
  3662.   AccountView.prototype.checkForReset = function() {
  3663.     if (this.$(".reset-check").data("successful-reset") === true) {
  3664.       return this.$(".successful-reset").show();
  3665.     }
  3666.   };
  3667.  
  3668.   AccountView.prototype.prepareAddresses = function() {
  3669.     var address, addressID, addresses, i, len, results;
  3670.     new Shopify.CountryProvinceSelector("address-country", "address-province", {
  3671.       hideElement: "address-province-container"
  3672.     });
  3673.     addresses = this.$(".customer-address");
  3674.     if (addresses.length) {
  3675.       results = [];
  3676.       for (i = 0, len = addresses.length; i < len; i++) {
  3677.         address = addresses[i];
  3678.         addressID = $(address).data("address-id");
  3679.         results.push(new Shopify.CountryProvinceSelector("address-country-" + addressID, "address-province-" + addressID, {
  3680.           hideElement: "address-province-container-" + addressID
  3681.         }));
  3682.       }
  3683.       return results;
  3684.     }
  3685.   };
  3686.  
  3687.   AccountView.prototype.deleteAddress = function(e) {
  3688.     var addressID;
  3689.     addressID = $(e.target).parents("[data-address-id]").data("address-id");
  3690.     return Shopify.CustomerAddress.destroy(addressID);
  3691.   };
  3692.  
  3693.   AccountView.prototype.editAddress = function(e) {
  3694.     var addressID;
  3695.     addressID = $(e.target).parents("[data-address-id]").data("address-id");
  3696.     this.$(".customer-address").removeClass("editing").find(".edit-address").removeClass("disabled");
  3697.     this.$(".customer-address[data-address-id='" + addressID + "']").addClass("editing").find(".edit-address").addClass("disabled");
  3698.     this.$(".customer-address-edit-form, .customer-new-address").addClass("hidden");
  3699.     return this.$(".customer-address-edit-form[data-address-id='" + addressID + "']").removeClass("hidden");
  3700.   };
  3701.  
  3702.   AccountView.prototype.addNewAddress = function() {
  3703.     this.$(".customer-address").removeClass("editing").find(".edit-address").removeClass("disabled");
  3704.     this.$(".customer-address-edit-form").addClass("hidden");
  3705.     return this.$(".customer-new-address").removeClass("hidden");
  3706.   };
  3707.  
  3708.   AccountView.prototype.updateProvinceSelectText = function() {
  3709.     return this.$(".address-province").siblings(".selected-text").text("-- " + Theme.pleaseSelectText + " --");
  3710.   };
  3711.  
  3712.   return AccountView;
  3713.  
  3714. })(Backbone.View);
  3715.  
  3716. window.NotFoundView = (function(superClass) {
  3717.   extend(NotFoundView, superClass);
  3718.  
  3719.   function NotFoundView() {
  3720.     return NotFoundView.__super__.constructor.apply(this, arguments);
  3721.   }
  3722.  
  3723.   NotFoundView.prototype.events = {};
  3724.  
  3725.   NotFoundView.prototype.initialize = function() {};
  3726.  
  3727.   return NotFoundView;
  3728.  
  3729. })(Backbone.View);
  3730.  
  3731. window.PasswordView = (function(superClass) {
  3732.   extend(PasswordView, superClass);
  3733.  
  3734.   function PasswordView() {
  3735.     return PasswordView.__super__.constructor.apply(this, arguments);
  3736.   }
  3737.  
  3738.   PasswordView.prototype.el = document.body;
  3739.  
  3740.   PasswordView.prototype.events = {
  3741.     "click": "closeModal",
  3742.     "click .admin-login-modal": "openModal"
  3743.   };
  3744.  
  3745.   PasswordView.prototype.initialize = function() {
  3746.     this.modalWrapper = $(".password-page-modal-wrapper");
  3747.     this.modalContent = this.modalWrapper.find(".password-page-modal");
  3748.     this.openByDefault = this.modalWrapper.find("[data-open-modal]").length;
  3749.     if (this.openByDefault) {
  3750.       this.openModal();
  3751.     }
  3752.     return $(window).resize((function(_this) {
  3753.       return function() {
  3754.         return _this.positionModal();
  3755.       };
  3756.     })(this));
  3757.   };
  3758.  
  3759.   PasswordView.prototype.closeModal = function(e) {
  3760.     if (this.$(e.target).hasClass("visible")) {
  3761.       return this.modalWrapper.removeClass("visible").one("trend", (function(_this) {
  3762.         return function() {
  3763.           return _this.$el.removeClass("scroll-locked");
  3764.         };
  3765.       })(this));
  3766.     }
  3767.   };
  3768.  
  3769.   PasswordView.prototype.openModal = function() {
  3770.     this.$el.addClass("scroll-locked");
  3771.     this.positionModal();
  3772.     return this.modalWrapper.addClass("visible");
  3773.   };
  3774.  
  3775.   PasswordView.prototype.positionModal = function() {
  3776.     return this.modalContent.css({
  3777.       marginTop: -(this.modalContent.outerHeight() / 2),
  3778.       marginLeft: -(this.modalContent.outerWidth() / 2)
  3779.     });
  3780.   };
  3781.  
  3782.   return PasswordView;
  3783.  
  3784. })(Backbone.View);
  3785.  
  3786. window.GiftCardView = (function(superClass) {
  3787.   extend(GiftCardView, superClass);
  3788.  
  3789.   function GiftCardView() {
  3790.     return GiftCardView.__super__.constructor.apply(this, arguments);
  3791.   }
  3792.  
  3793.   GiftCardView.prototype.initialize = function() {
  3794.     return this.addQrCode();
  3795.   };
  3796.  
  3797.   GiftCardView.prototype.addQrCode = function() {
  3798.     var qrWrapper;
  3799.     qrWrapper = $('[data-qr-code]');
  3800.     return new QRCode(qrWrapper[0], {
  3801.       text: qrWrapper.data('qr-code'),
  3802.       width: 120,
  3803.       height: 120
  3804.     });
  3805.   };
  3806.  
  3807.   return GiftCardView;
  3808.  
  3809. })(Backbone.View);
  3810.  
  3811. window.BlogStaticView = (function(superClass) {
  3812.   extend(BlogStaticView, superClass);
  3813.  
  3814.   function BlogStaticView() {
  3815.     return BlogStaticView.__super__.constructor.apply(this, arguments);
  3816.   }
  3817.  
  3818.   BlogStaticView.prototype.events = {
  3819.     "change .blog-sidebar select": "filterBlog"
  3820.   };
  3821.  
  3822.   BlogStaticView.prototype.initialize = function() {
  3823.     this.initializedClass = 'blog-initialized';
  3824.     return this._validate();
  3825.   };
  3826.  
  3827.   BlogStaticView.prototype.update = function($el) {
  3828.     this.$el = $el;
  3829.     this._validate();
  3830.     if (this.$('.blog-tag-filter select')) {
  3831.       return new SelectView({
  3832.         el: this.$('.blog-tag-filter select')
  3833.       });
  3834.     }
  3835.   };
  3836.  
  3837.   BlogStaticView.prototype.remove = function() {
  3838.     BlogStaticView.__super__.remove.apply(this, arguments);
  3839.     return $(window).off("resize.blog-view");
  3840.   };
  3841.  
  3842.   BlogStaticView.prototype._validate = function() {
  3843.     if (window.innerWidth <= 1020) {
  3844.       this.positionSidebar("below");
  3845.     } else {
  3846.       this.positionSidebar();
  3847.     }
  3848.     this.$el.imagesLoaded((function(_this) {
  3849.       return function() {
  3850.         _this.setupFeaturedImage();
  3851.         return _this.setupFullWidthImages();
  3852.       };
  3853.     })(this));
  3854.     return $(window).on("resize.blog-view", (function(_this) {
  3855.       return function() {
  3856.         _this.setupFullWidthImages();
  3857.         if (window.innerWidth <= 1020) {
  3858.           return _this.positionSidebar("below");
  3859.         } else {
  3860.           _this.positionSidebar();
  3861.           return _this.setupFeaturedImage();
  3862.         }
  3863.       };
  3864.     })(this));
  3865.   };
  3866.  
  3867.   BlogStaticView.prototype.filterBlog = function(e) {
  3868.     var tag, url;
  3869.     if (!this.$el.is('[data-tag-filter]')) {
  3870.       return;
  3871.     }
  3872.     tag = this.$(e.target).val();
  3873.     url = this.$(e.target).data("url");
  3874.     if (tag === "all") {
  3875.       return window.location.href = "/blogs/" + url;
  3876.     } else {
  3877.       return window.location.href = "/blogs/" + url + "/tagged/" + tag;
  3878.     }
  3879.   };
  3880.  
  3881.   BlogStaticView.prototype.setupFeaturedImage = function(setup) {
  3882.     var i, image, len, post, ref, results;
  3883.     ref = this.$(".blog-post");
  3884.     results = [];
  3885.     for (i = 0, len = ref.length; i < len; i++) {
  3886.       post = ref[i];
  3887.       post = $(post);
  3888.       image = post.find("img.highlight").first();
  3889.       if (image.length) {
  3890.         results.push(post.find(".blog-post-inner").css({
  3891.           "paddingTop": image.height() - 60
  3892.         }));
  3893.       } else {
  3894.         results.push(void 0);
  3895.       }
  3896.     }
  3897.     return results;
  3898.   };
  3899.  
  3900.   BlogStaticView.prototype.setupFullWidthImages = function() {
  3901.     var i, image, len, postContent, postContentMargin, postContentWidth, ref, results;
  3902.     postContent = this.$(".post-content");
  3903.     postContentWidth = postContent.outerWidth(true);
  3904.     postContentMargin = postContent.css("marginLeft");
  3905.     ref = this.$("img.full-width");
  3906.     results = [];
  3907.     for (i = 0, len = ref.length; i < len; i++) {
  3908.       image = ref[i];
  3909.       image = $(image);
  3910.       results.push(image.css({
  3911.         "width": postContentWidth,
  3912.         "left": "-" + postContentMargin
  3913.       }));
  3914.     }
  3915.     return results;
  3916.   };
  3917.  
  3918.   BlogStaticView.prototype.positionSidebar = function(position) {
  3919.     var sidebar;
  3920.     sidebar = this.$(".blog-sidebar");
  3921.     if (position === "below") {
  3922.       return sidebar.insertAfter(".blog-posts");
  3923.     } else {
  3924.       return sidebar.insertBefore(".blog-posts");
  3925.     }
  3926.   };
  3927.  
  3928.   return BlogStaticView;
  3929.  
  3930. })(Backbone.View);
  3931.  
  3932. window.BlogMasonryView = (function(superClass) {
  3933.   extend(BlogMasonryView, superClass);
  3934.  
  3935.   function BlogMasonryView() {
  3936.     return BlogMasonryView.__super__.constructor.apply(this, arguments);
  3937.   }
  3938.  
  3939.   BlogMasonryView.prototype.initialize = function() {
  3940.     this.$masonry = this.$el.find('[data-masonry-grid]');
  3941.     return this.masonryGrid = new MasonryGrid({
  3942.       $el: this.$masonry
  3943.     });
  3944.   };
  3945.  
  3946.   BlogMasonryView.prototype.onSectionUnload = function() {
  3947.     return this.masonryGrid.unload();
  3948.   };
  3949.  
  3950.   return BlogMasonryView;
  3951.  
  3952. })(Backbone.View);
  3953.  
  3954. window.BlogViewHandler = (function() {
  3955.   function BlogViewHandler($el) {
  3956.     var hasMasonryBlog, hasStaticBlog, selectors;
  3957.     this.$el = $el;
  3958.     this.sections = new ThemeEditor();
  3959.     selectors = {
  3960.       staticBlog: 'blog-static',
  3961.       masonryBlog: 'blog-masonry'
  3962.     };
  3963.     hasStaticBlog = this.$el.find("[data-section-type='" + selectors.staticBlog + "']").length;
  3964.     hasMasonryBlog = this.$el.find("[data-section-type='" + selectors.masonryBlog + "']").length;
  3965.     if (hasStaticBlog) {
  3966.       this.sections.register(selectors.staticBlog, this.staticBlog(this.sections));
  3967.     }
  3968.     if (hasMasonryBlog) {
  3969.       this.sections.register(selectors.masonryBlog, this.masonryBlog(this.sections));
  3970.     }
  3971.   }
  3972.  
  3973.   BlogViewHandler.prototype.staticBlog = function(sections) {
  3974.     return {
  3975.       instances: {},
  3976.       init: function(instance) {
  3977.         return this.instances[instance.sectionId] = new BlogStaticView({
  3978.           el: instance.$container
  3979.         });
  3980.       },
  3981.       onSectionLoad: function(event) {
  3982.         var instance;
  3983.         instance = sections.getInstance(event);
  3984.         if (this.instances[instance.sectionId] == null) {
  3985.           return this.init(instance);
  3986.         }
  3987.       },
  3988.       onSectionSelect: function(event) {
  3989.         var instance, ref;
  3990.         instance = sections.getInstance(event);
  3991.         return (ref = this.instances[instance.sectionId]) != null ? ref.update(instance.$container) : void 0;
  3992.       },
  3993.       onSectionDeselect: function(event) {
  3994.         return this.onSectionSelect(event);
  3995.       },
  3996.       onSectionUnload: function(event) {
  3997.         var instance, ref;
  3998.         instance = sections.getInstance(event);
  3999.         if ((ref = this.instances[instance.sectionId]) != null) {
  4000.           ref.remove();
  4001.         }
  4002.         return delete this.instances[instance.sectionId];
  4003.       }
  4004.     };
  4005.   };
  4006.  
  4007.   BlogViewHandler.prototype.masonryBlog = function(sections) {
  4008.     return {
  4009.       instances: {},
  4010.       init: function(instance) {
  4011.         return this.instances[instance.sectionId] = new BlogMasonryView({
  4012.           el: instance.$container
  4013.         });
  4014.       },
  4015.       onSectionLoad: function(event) {
  4016.         var instance;
  4017.         instance = sections.getInstance(event);
  4018.         if (this.instances[instance.sectionId] == null) {
  4019.           return this.init(instance);
  4020.         }
  4021.       },
  4022.       onSectionUnload: function(event) {
  4023.         var instance;
  4024.         instance = sections.getInstance(event);
  4025.         this.instances[instance.sectionId].onSectionUnload();
  4026.         return delete this.instances[instance.sectionId];
  4027.       }
  4028.     };
  4029.   };
  4030.  
  4031.   return BlogViewHandler;
  4032.  
  4033. })();
  4034.  
  4035.  
  4036. /* Static sections */
  4037.  
  4038. window.NavigationView = (function(superClass) {
  4039.   extend(NavigationView, superClass);
  4040.  
  4041.   function NavigationView() {
  4042.     return NavigationView.__super__.constructor.apply(this, arguments);
  4043.   }
  4044.  
  4045.   NavigationView.prototype.events = {
  4046.     'mouseover .mega-nav-list a': 'swapMegaNavImages',
  4047.     'click .has-dropdown [data-subnav-toggle]': 'toggleNavTier',
  4048.     'mouseleave .has-mega-nav': 'useDefaultImage',
  4049.     'click [data-header-nav-toggle]': 'handleMobileNavigationToggle'
  4050.   };
  4051.  
  4052.   NavigationView.prototype.initialize = function() {
  4053.     this.$navigationWrapper = this.$('[data-navigation-wrapper]');
  4054.     this.$navigationContent = this.$('[data-navigation-content]');
  4055.     this.$body = $(document.body);
  4056.     this.transitionend = (function(transition) {
  4057.       var transEndEventNames;
  4058.       transEndEventNames = {
  4059.         '-webkit-transition': 'webkitTransitionEnd',
  4060.         '-moz-transition': 'transitionend',
  4061.         '-o-transition': 'oTransitionEnd',
  4062.         transition: 'transitionend'
  4063.       };
  4064.       return transEndEventNames[transition];
  4065.     })(Modernizr.prefixed('transition'));
  4066.     this.setupNavigation();
  4067.     return $(window).on('resize.navigation', (function(_this) {
  4068.       return function() {
  4069.         _this.setupNavigation();
  4070.         if (!window.ThemeUtils.isMedium() && _this.$body.hasClass('mobile-nav-open')) {
  4071.           _this.$navigationWrapper.removeClass('visible');
  4072.           return _this.toggleMobileNavigation('close');
  4073.         }
  4074.       };
  4075.     })(this));
  4076.   };
  4077.  
  4078.   NavigationView.prototype.unload = function() {
  4079.     $(window).off('resize.navigation');
  4080.     return this.toggleMobileNavigation('close');
  4081.   };
  4082.  
  4083.   NavigationView.prototype.setupNavigation = function() {
  4084.     if (!window.ThemeUtils.isMedium()) {
  4085.       this.$navigationWrapper.detach().insertAfter('[data-header-branding]');
  4086.       this.$navigationContent.removeClass('navigation-mobile').addClass('navigation-desktop');
  4087.       return this.$('li[data-mega-nav="true"]').removeClass('has-dropdown').addClass('has-mega-nav');
  4088.     } else {
  4089.       this.$navigationWrapper.detach().insertAfter('[data-header-main]');
  4090.       this.$navigationContent.removeClass('navigation-desktop').addClass('navigation-mobile');
  4091.       return this.$('li[data-mega-nav="true"]').removeClass('has-mega-nav').addClass('has-dropdown');
  4092.     }
  4093.   };
  4094.  
  4095.   NavigationView.prototype.swapMegaNavImages = function(e) {
  4096.     var image, imageAlt;
  4097.     image = this.$(e.target).parent().data('image');
  4098.     imageAlt = this.$(e.target).parent().data('image-alt');
  4099.     return this.$('.mega-nav-image img').attr('src', image).attr('alt', imageAlt);
  4100.   };
  4101.  
  4102.   NavigationView.prototype.handleMobileNavigationToggle = function() {
  4103.     if (this.$body.hasClass('mobile-nav-open')) {
  4104.       return this.toggleMobileNavigation('close');
  4105.     } else {
  4106.       return this.toggleMobileNavigation('open');
  4107.     }
  4108.   };
  4109.  
  4110.   NavigationView.prototype.toggleMobileNavigation = function(direction) {
  4111.     if (direction === 'open') {
  4112.       this.$body.addClass('mobile-nav-open lock-scroll');
  4113.       this.$navigationContent.addClass('visible');
  4114.       this.$navigationWrapper.addClass('visible background');
  4115.       return this.setTierHeight();
  4116.     } else if (direction === 'close') {
  4117.       this.$navigationContent.removeAttr('style');
  4118.       this.$body.removeClass('mobile-nav-open');
  4119.       this.$navigationContent.removeClass('visible');
  4120.       if (Modernizr.csstransitions) {
  4121.         this.$navigationWrapper.removeClass('background').one(this.transitionend, (function(_this) {
  4122.           return function() {
  4123.             _this.$navigationWrapper.removeClass('visible');
  4124.             return _this.$body.removeClass('lock-scroll');
  4125.           };
  4126.         })(this));
  4127.       } else {
  4128.         this.$navigationWrapper.removeClass('visible background');
  4129.         this.$body.removeClass('lock-scroll');
  4130.       }
  4131.       return this.$navigationContent.find('.has-dropdown-open').removeClass('has-dropdown-open').find('.navigation-submenu-visible').removeClass('navigation-submenu-visible');
  4132.     }
  4133.   };
  4134.  
  4135.   NavigationView.prototype.toggleNavTier = function(e) {
  4136.     var $parentEl, $target, $targetLinkList, $trigger;
  4137.     if (this.$navigationContent.hasClass('navigation-mobile')) {
  4138.       e.preventDefault();
  4139.     }
  4140.     $target = $(e.currentTarget);
  4141.     $trigger = $target.closest('a');
  4142.     $parentEl = $trigger.parent('li');
  4143.     $targetLinkList = this.$("ul[data-linklist='" + ($trigger.data('linklist-trigger')) + "']");
  4144.     if ($parentEl.hasClass('has-dropdown-open')) {
  4145.       return this.closeNavTier({
  4146.         $parentEl: $parentEl,
  4147.         $targetLinkList: $targetLinkList
  4148.       });
  4149.     } else {
  4150.       this.closeSiblingTiers($parentEl);
  4151.       return this.openNavTier({
  4152.         $parentEl: $parentEl,
  4153.         $targetLinkList: $targetLinkList
  4154.       });
  4155.     }
  4156.   };
  4157.  
  4158.   NavigationView.prototype.closeSiblingTiers = function($openMenu) {
  4159.     return $openMenu.siblings('.has-dropdown-open').each((function(_this) {
  4160.       return function(index, el) {
  4161.         var $parentEl, $targetLinkList;
  4162.         $parentEl = $(el);
  4163.         $targetLinkList = $parentEl.find('.navigation-submenu-visible');
  4164.         return _this.closeNavTier({
  4165.           $parentEl: $parentEl,
  4166.           $targetLinkList: $targetLinkList
  4167.         });
  4168.       };
  4169.     })(this));
  4170.   };
  4171.  
  4172.   NavigationView.prototype.openNavTier = function(options) {
  4173.     var $parentEl, $targetLinkList;
  4174.     $parentEl = options.$parentEl, $targetLinkList = options.$targetLinkList;
  4175.     $targetLinkList.addClass('navigation-submenu-visible');
  4176.     $parentEl.addClass('has-dropdown-open');
  4177.     return this.setTierHeight();
  4178.   };
  4179.  
  4180.   NavigationView.prototype.closeNavTier = function(options) {
  4181.     var $parentEl, $targetLinkList;
  4182.     $parentEl = options.$parentEl, $targetLinkList = options.$targetLinkList;
  4183.     $targetLinkList.removeClass('navigation-submenu-visible').find('.navigation-submenu-visible').removeClass('navigation-submenu-visible');
  4184.     $parentEl.removeClass('has-dropdown-open').find('.has-dropdown-open').removeClass('has-dropdown-open');
  4185.     return this.setTierHeight();
  4186.   };
  4187.  
  4188.   NavigationView.prototype.setTierHeight = function() {
  4189.     return this.$navigationContent.css({
  4190.       'overflow-y': 'scroll',
  4191.       'height': '100%'
  4192.     });
  4193.   };
  4194.  
  4195.   NavigationView.prototype.useDefaultImage = function() {
  4196.     var megaNavImage;
  4197.     megaNavImage = this.$('.mega-nav-image img');
  4198.     return megaNavImage.attr('src', megaNavImage.data('image')).attr('alt', megaNavImage.data('alt'));
  4199.   };
  4200.  
  4201.   return NavigationView;
  4202.  
  4203. })(Backbone.View);
  4204.  
  4205. window.HeaderView = (function(superClass) {
  4206.   extend(HeaderView, superClass);
  4207.  
  4208.   function HeaderView() {
  4209.     return HeaderView.__super__.constructor.apply(this, arguments);
  4210.   }
  4211.  
  4212.   HeaderView.prototype.initialize = function() {
  4213.     this.$window = $(window);
  4214.     this.$body = $(document.body);
  4215.     this.$header = this.$('[data-section-type="header"]');
  4216.     this.$mainHeader = this.$('[data-header-main]');
  4217.     this.$headerContent = this.$('[data-header-content]');
  4218.     this.$navigationWrapper = this.$('[data-navigation-wrapper]');
  4219.     this.$navigationContent = this.$('[data-navigation-content]');
  4220.     this.$branding = this.$('[data-header-branding]');
  4221.     this.$headerTools = this.$('.header-tools');
  4222.     this.$headerRight = this.$('[data-header-content-right]');
  4223.     this.$headerSearch = this.$('[data-header-search]');
  4224.     this.$headerSearchSubmit = this.$('[data-header-search-button]');
  4225.     this.$headerSearchClose = this.$('[data-header-search-button-close]');
  4226.     this.isStickyHeader = this.$el.is('[data-sticky-header]');
  4227.     this.isCompactCenter = this.$el.is('[data-header-compact-center]');
  4228.     this.navHeight = 0;
  4229.     this.windowWidth = window.ThemeUtils.windowWidth();
  4230.     setTimeout((function(_this) {
  4231.       return function() {
  4232.         return _this.navHeight = _this.$navigationWrapper.height();
  4233.       };
  4234.     })(this), 100);
  4235.     if (this.isStickyHeader && !window.ThemeUtils.isMedium() && !this.$body.hasClass('alternate-index-layout')) {
  4236.       this._toggleStickyHeader(true);
  4237.     } else {
  4238.       this._toggleStickyHeader(false);
  4239.     }
  4240.     this._triggerStickyHeader();
  4241.     this.navigation = new NavigationView({
  4242.       el: this.$el
  4243.     });
  4244.     this._setSearchWidth();
  4245.     this._setupBranding();
  4246.     this._setCompactCenterHeights();
  4247.     return this._bindEvents();
  4248.   };
  4249.  
  4250.   HeaderView.prototype.onSectionDeselect = function() {
  4251.     return this.navigation.toggleMobileNavigation('close');
  4252.   };
  4253.  
  4254.   HeaderView.prototype.unload = function() {
  4255.     this.navigation.unload();
  4256.     this.$window.off('.header');
  4257.     this.$headerSearchSubmit.off('.header-search');
  4258.     this.$headerSearchClose.off('.header-search');
  4259.     return this._triggerStickyHeader();
  4260.   };
  4261.  
  4262.   HeaderView.prototype._bindEvents = function() {
  4263.     this.$window.on('resize.header', (function(_this) {
  4264.       return function() {
  4265.         if (window.ThemeUtils.windowWidth() === _this.windowWidth) {
  4266.           return;
  4267.         }
  4268.         _this.windowWidth = window.ThemeUtils.windowWidth();
  4269.         _this.navHeight = _this.$navigationWrapper.height();
  4270.         _this._triggerStickyHeader();
  4271.         _this._setSearchWidth();
  4272.         _this._setCompactCenterHeights();
  4273.         if (!window.ThemeUtils.isMedium()) {
  4274.           return _this._toggleSearchForm(false);
  4275.         }
  4276.       };
  4277.     })(this));
  4278.     this.$window.on('scroll.header', (function(_this) {
  4279.       return function() {
  4280.         if (!_this.isStickyHeader) {
  4281.           _this._setCompactCenterHeights();
  4282.         }
  4283.         return _this._triggerStickyHeader();
  4284.       };
  4285.     })(this));
  4286.     this.$headerSearchSubmit.on('click.header-search', (function(_this) {
  4287.       return function(event) {
  4288.         var $target;
  4289.         $target = $(event.currentTarget);
  4290.         if (!window.ThemeUtils.isMedium()) {
  4291.           return;
  4292.         }
  4293.         if ($target.data('clicked')) {
  4294.           return;
  4295.         }
  4296.         event.preventDefault();
  4297.         $target.data('clicked', true);
  4298.         _this._bindCloseSearch();
  4299.         return _this._toggleSearchForm(true);
  4300.       };
  4301.     })(this));
  4302.     return this.$headerSearchClose.on('click.header-search', (function(_this) {
  4303.       return function(event) {
  4304.         event.preventDefault();
  4305.         return _this._toggleSearchForm(false);
  4306.       };
  4307.     })(this));
  4308.   };
  4309.  
  4310.  
  4311.   /*
  4312.       When search form is open, and receives click outside of form, close
  4313.    */
  4314.  
  4315.   HeaderView.prototype._bindCloseSearch = function() {
  4316.     return this.$body.on('click.header-search-close', event, (function(_this) {
  4317.       return function() {
  4318.         var $parent;
  4319.         $parent = $(event.target).parents('[data-header-search]');
  4320.         if ($parent.length) {
  4321.           return;
  4322.         }
  4323.         return _this._toggleSearchForm(false);
  4324.       };
  4325.     })(this));
  4326.   };
  4327.  
  4328.   HeaderView.prototype._triggerStickyHeader = function() {
  4329.     var toggleOn;
  4330.     toggleOn = false;
  4331.     if (!this.isStickyHeader) {
  4332.       return this._toggleStickyHeader(false);
  4333.     }
  4334.     if (this.$window.scrollTop() > this.$el.outerHeight()) {
  4335.       toggleOn = true;
  4336.     }
  4337.     if (window.ThemeUtils.isMedium() || this.$body.hasClass('alternate-index-layout')) {
  4338.       toggleOn = false;
  4339.     }
  4340.     return this._toggleStickyHeader(toggleOn);
  4341.   };
  4342.  
  4343.   HeaderView.prototype._toggleStickyHeader = function(toggleOn) {
  4344.     var paddingTop;
  4345.     if (toggleOn == null) {
  4346.       toggleOn = false;
  4347.     }
  4348.     paddingTop = toggleOn ? this.navHeight : 0;
  4349.     this.$body.css({
  4350.       paddingTop: paddingTop
  4351.     }).toggleClass('sticky-header', toggleOn);
  4352.     return this._setCompactCenterHeights(!toggleOn);
  4353.   };
  4354.  
  4355.  
  4356.   /*
  4357.       Expand search form logic
  4358.    */
  4359.  
  4360.   HeaderView.prototype._toggleSearchForm = function(open) {
  4361.     var headerRightWidth, headerSearchWidth, logoCollision, navCollision, ref, searchButtonWidth;
  4362.     if (open == null) {
  4363.       open = false;
  4364.     }
  4365.     headerRightWidth = '';
  4366.     headerSearchWidth = parseInt(this.$headerSearch.data('width'), 10);
  4367.     searchButtonWidth = this.$headerSearchClose.outerWidth(true);
  4368.     logoCollision = false;
  4369.     navCollision = false;
  4370.     if (open) {
  4371.       ref = this._logoSearchCollision(headerSearchWidth), logoCollision = ref.logoCollision, navCollision = ref.navCollision;
  4372.       headerRightWidth = headerSearchWidth + searchButtonWidth;
  4373.       headerSearchWidth = '100%';
  4374.     } else {
  4375.       this.$headerSearchSubmit.data('clicked', false);
  4376.       this.$body.off('.header-search-close');
  4377.     }
  4378.     if (!open && this.$mainHeader.hasClass('header-search-expanded')) {
  4379.       this.$mainHeader.addClass('header-search-expanded-closing', true);
  4380.     }
  4381.     this.$mainHeader.toggleClass('header-search-expanded', open);
  4382.     this.$mainHeader.toggleClass('header-nav-toggle-covered', navCollision);
  4383.     this.$mainHeader.toggleClass('header-logo-covered', logoCollision).one('trend', (function(_this) {
  4384.       return function() {
  4385.         if (!open) {
  4386.           return _this.$mainHeader.removeClass('header-search-expanded-closing');
  4387.         }
  4388.       };
  4389.     })(this));
  4390.     this.$headerRight.css({
  4391.       width: headerRightWidth
  4392.     });
  4393.     return this.$headerSearch.css({
  4394.       width: headerSearchWidth
  4395.     });
  4396.   };
  4397.  
  4398.  
  4399.   /*
  4400.       Detect if Logo or nav toggle will be covered by expanded search form
  4401.    */
  4402.  
  4403.   HeaderView.prototype._logoSearchCollision = function(headerSearchWidth) {
  4404.     var logoCollision, logoRightEdge, navCollision, navRightEdge, searchLeftEdge;
  4405.     logoRightEdge = document.querySelector('[data-header-branding] .logo-link').getBoundingClientRect().right;
  4406.     navRightEdge = document.querySelector('[data-header-content] [data-header-nav-toggle]').getBoundingClientRect().right;
  4407.     searchLeftEdge = document.querySelector('[data-header-search]').getBoundingClientRect().left - headerSearchWidth;
  4408.     logoCollision = logoRightEdge > searchLeftEdge;
  4409.     navCollision = navRightEdge > searchLeftEdge;
  4410.     return {
  4411.       logoCollision: logoCollision,
  4412.       navCollision: navCollision
  4413.     };
  4414.   };
  4415.  
  4416.  
  4417.   /*
  4418.       Match Navigation and Branding heights
  4419.       Center navigation vertically if Branding is taller
  4420.    */
  4421.  
  4422.   HeaderView.prototype._setCompactCenterHeights = function(toggleOn) {
  4423.     var heights, minHeight, navHeight, navOffset;
  4424.     if (toggleOn == null) {
  4425.       toggleOn = true;
  4426.     }
  4427.     if (!this.isCompactCenter) {
  4428.       return;
  4429.     }
  4430.     minHeight = 'auto';
  4431.     navHeight = this.$navigationContent.outerHeight(true);
  4432.     navOffset = 0;
  4433.     if (!window.ThemeUtils.isMedium() && toggleOn) {
  4434.       heights = [];
  4435.       heights.push(navHeight);
  4436.       heights.push(this.$branding.outerHeight(true));
  4437.       minHeight = Math.max.apply(null, heights);
  4438.     }
  4439.     if (navHeight < minHeight) {
  4440.       navOffset = (minHeight - navHeight) / 2;
  4441.     }
  4442.     this.navHeight = this.$navigationWrapper.height();
  4443.     this.$navigationWrapper.css('margin-top', navOffset);
  4444.     return this.$headerContent.css({
  4445.       minHeight: minHeight
  4446.     });
  4447.   };
  4448.  
  4449.   HeaderView.prototype._setupBranding = function() {
  4450.     var $mobileBranding;
  4451.     $mobileBranding = this.$branding.clone();
  4452.     $mobileBranding.removeAttr('data-header-branding').removeClass('header-branding-desktop').addClass('header-branding-mobile');
  4453.     return this.$navigationContent.prepend($mobileBranding);
  4454.   };
  4455.  
  4456.   HeaderView.prototype._setSearchWidth = function() {
  4457.     var searchWidth;
  4458.     searchWidth = this.$mainHeader.find('.mini-cart-wrapper').outerWidth(true) + this.$mainHeader.find('.checkout-link').outerWidth(true);
  4459.     this.$headerSearch.width(searchWidth);
  4460.     return this.$headerSearch.data('width', searchWidth);
  4461.   };
  4462.  
  4463.   return HeaderView;
  4464.  
  4465. })(Backbone.View);
  4466.  
  4467. window.CollectionView = (function(superClass) {
  4468.   extend(CollectionView, superClass);
  4469.  
  4470.   function CollectionView() {
  4471.     return CollectionView.__super__.constructor.apply(this, arguments);
  4472.   }
  4473.  
  4474.   CollectionView.prototype.events = {
  4475.     'change [data-collection-tags]': 'filterCollection',
  4476.     'change [data-collection-sorting]': 'sortCollection'
  4477.   };
  4478.  
  4479.   CollectionView.prototype.initialize = function() {
  4480.     this.$masonry = this.$('[data-masonry-grid]');
  4481.     this.masonryGrid = null;
  4482.     this.$collectionTags = this.$('[data-collection-tags]');
  4483.     this.$collectionSorting = this.$('[data-collection-sorting]');
  4484.     if (this.$collectionTags.length) {
  4485.       new SelectView({
  4486.         el: this.$collectionTags
  4487.       });
  4488.     }
  4489.     if (this.$collectionSorting.length) {
  4490.       new SelectView({
  4491.         el: this.$collectionSorting
  4492.       });
  4493.     }
  4494.     if (this.$masonry.length) {
  4495.       return this.masonryGrid = new MasonryGrid({
  4496.         $el: this.$masonry,
  4497.         settings: {
  4498.           itemSelector: '.product-list-item'
  4499.         }
  4500.       });
  4501.     }
  4502.   };
  4503.  
  4504.   CollectionView.prototype.onSectionUnload = function() {
  4505.     if (this.masonryGrid) {
  4506.       return this.masonryGrid.unload();
  4507.     }
  4508.   };
  4509.  
  4510.   CollectionView.prototype.filterCollection = function(event) {
  4511.     var $target, tag, url;
  4512.     $target = $(event.currentTarget);
  4513.     tag = $target.val();
  4514.     url = $target.data('url');
  4515.     if (tag === "all") {
  4516.       return window.location.href = "/collections/" + url;
  4517.     } else {
  4518.       return window.location.href = "/collections/" + url + "/" + tag;
  4519.     }
  4520.   };
  4521.  
  4522.   CollectionView.prototype.sortCollection = function(event) {
  4523.     var $target, Sorting, currentSearch, i, index, len, part, search, searchParts;
  4524.     $target = $(event.currentTarget);
  4525.     Sorting = {};
  4526.     Sorting.sort_by = $target.val();
  4527.     if ($target.closest('.select-wrapper').hasClass('vendor-collection')) {
  4528.       currentSearch = location.search;
  4529.       searchParts = currentSearch.split('&');
  4530.       for (index = i = 0, len = searchParts.length; i < len; index = ++i) {
  4531.         part = searchParts[index];
  4532.         if (part.indexOf('sort_by') !== -1) {
  4533.           searchParts.splice(index, 1);
  4534.         }
  4535.       }
  4536.       search = searchParts.join('&');
  4537.       return location.search = search + "&" + (jQuery.param(Sorting));
  4538.     } else {
  4539.       return location.search = jQuery.param(Sorting);
  4540.     }
  4541.   };
  4542.  
  4543.   return CollectionView;
  4544.  
  4545. })(Backbone.View);
  4546.  
  4547. window.ArticleView = (function(superClass) {
  4548.   extend(ArticleView, superClass);
  4549.  
  4550.   function ArticleView() {
  4551.     return ArticleView.__super__.constructor.apply(this, arguments);
  4552.   }
  4553.  
  4554.   ArticleView.prototype.initialize = function() {
  4555.     this.initializedClass = 'article-initialized';
  4556.     return this._validate();
  4557.   };
  4558.  
  4559.   ArticleView.prototype.update = function($el) {
  4560.     this.$el = $el;
  4561.     return this._validate();
  4562.   };
  4563.  
  4564.   ArticleView.prototype.remove = function() {
  4565.     ArticleView.__super__.remove.apply(this, arguments);
  4566.     return $(window).off("resize.article-view");
  4567.   };
  4568.  
  4569.   ArticleView.prototype._validate = function() {
  4570.     if (window.innerWidth <= 1020) {
  4571.       this.positionSidebar("below");
  4572.     } else {
  4573.       this.positionSidebar();
  4574.     }
  4575.     this.$el.imagesLoaded((function(_this) {
  4576.       return function() {
  4577.         _this.setupFeaturedImage();
  4578.         return _this.setupFullWidthImages();
  4579.       };
  4580.     })(this));
  4581.     return $(window).on("resize.article-view", (function(_this) {
  4582.       return function() {
  4583.         _this.setupFullWidthImages();
  4584.         if (window.innerWidth <= 1020) {
  4585.           return _this.positionSidebar("below");
  4586.         } else {
  4587.           _this.positionSidebar();
  4588.           return _this.setupFeaturedImage();
  4589.         }
  4590.       };
  4591.     })(this));
  4592.   };
  4593.  
  4594.   ArticleView.prototype.setupFeaturedImage = function(setup) {
  4595.     var i, image, len, post, ref, results;
  4596.     ref = this.$(".blog-post");
  4597.     results = [];
  4598.     for (i = 0, len = ref.length; i < len; i++) {
  4599.       post = ref[i];
  4600.       post = $(post);
  4601.       image = post.find("img.highlight").first();
  4602.       if (image.length) {
  4603.         results.push(post.find(".blog-post-inner").css({
  4604.           "paddingTop": image.height() - 60
  4605.         }));
  4606.       } else {
  4607.         results.push(void 0);
  4608.       }
  4609.     }
  4610.     return results;
  4611.   };
  4612.  
  4613.   ArticleView.prototype.setupFullWidthImages = function() {
  4614.     var i, image, len, postContent, postContentMargin, postContentWidth, ref, results;
  4615.     postContent = this.$(".post-content");
  4616.     postContentWidth = postContent.outerWidth(true);
  4617.     postContentMargin = postContent.css("marginLeft");
  4618.     ref = this.$("img.full-width");
  4619.     results = [];
  4620.     for (i = 0, len = ref.length; i < len; i++) {
  4621.       image = ref[i];
  4622.       image = $(image);
  4623.       results.push(image.css({
  4624.         "width": postContentWidth,
  4625.         "left": "-" + postContentMargin
  4626.       }));
  4627.     }
  4628.     return results;
  4629.   };
  4630.  
  4631.   ArticleView.prototype.positionSidebar = function(position) {
  4632.     var sidebar;
  4633.     sidebar = this.$(".blog-sidebar");
  4634.     if (position === "below") {
  4635.       return sidebar.insertAfter(".blog-post-wrapper");
  4636.     } else {
  4637.       return sidebar.insertBefore(".blog-post-wrapper");
  4638.     }
  4639.   };
  4640.  
  4641.   return ArticleView;
  4642.  
  4643. })(Backbone.View);
  4644.  
  4645. window.CartView = (function(superClass) {
  4646.   extend(CartView, superClass);
  4647.  
  4648.   function CartView() {
  4649.     return CartView.__super__.constructor.apply(this, arguments);
  4650.   }
  4651.  
  4652.   CartView.prototype.events = {
  4653.     "click .get-rates": "getRates",
  4654.     "change .cart-instructions textarea": "saveSpecialInstructions"
  4655.   };
  4656.  
  4657.   CartView.prototype.initialize = function() {
  4658.     this.initializedClass = 'cart-initialized';
  4659.     return this._validate();
  4660.   };
  4661.  
  4662.   CartView.prototype.update = function($el) {
  4663.     this.$el = $el;
  4664.     return this._validate();
  4665.   };
  4666.  
  4667.   CartView.prototype._validate = function() {
  4668.     this.hasShippingCalculator = this.$el.is("[data-shipping-calculator]");
  4669.     if (this.hasShippingCalculator) {
  4670.       this.shippingCalculator();
  4671.       if (Theme.customerLoggedIn && Theme.customerAddress && Theme.customerAddress.country) {
  4672.         this.calculateShipping(true);
  4673.       }
  4674.     }
  4675.     return Shopify.onError = (function(_this) {
  4676.       return function(XMLHttpRequest) {
  4677.         return _this.handleErrors(XMLHttpRequest);
  4678.       };
  4679.     })(this);
  4680.   };
  4681.  
  4682.   CartView.prototype.saveSpecialInstructions = function() {
  4683.     var newNote;
  4684.     newNote = $(".cart-instructions textarea").val();
  4685.     return Shopify.updateCartNote(newNote, function(cart) {});
  4686.   };
  4687.  
  4688.   CartView.prototype.updateShippingLabel = function(select) {
  4689.     var selectedVariant;
  4690.     if (select) {
  4691.       select = $(select);
  4692.       selectedVariant = select.find("option:selected").val();
  4693.       return select.prev(".selected-option").text(selectedVariant);
  4694.     }
  4695.   };
  4696.  
  4697.   CartView.prototype.shippingCalculator = function() {
  4698.     var selectableOptions;
  4699.     Shopify.Cart.ShippingCalculator.show({
  4700.       submitButton: Theme.shippingButton,
  4701.       submitButtonDisabled: Theme.shippingDisabled,
  4702.       customerIsLoggedIn: Theme.customerLoggedIn,
  4703.       moneyFormat: Theme.moneyFormat
  4704.     });
  4705.     selectableOptions = this.$(".cart-shipping-calculator select");
  4706.     setTimeout((function(_this) {
  4707.       return function() {
  4708.         var i, len, results, select;
  4709.         results = [];
  4710.         for (i = 0, len = selectableOptions.length; i < len; i++) {
  4711.           select = selectableOptions[i];
  4712.           results.push(_this.updateShippingLabel(select));
  4713.         }
  4714.         return results;
  4715.       };
  4716.     })(this), 500);
  4717.     return this.$(".cart-shipping-calculator select").change((function(_this) {
  4718.       return function(e) {
  4719.         var i, len, results, select;
  4720.         results = [];
  4721.         for (i = 0, len = selectableOptions.length; i < len; i++) {
  4722.           select = selectableOptions[i];
  4723.           results.push(_this.updateShippingLabel(select));
  4724.         }
  4725.         return results;
  4726.       };
  4727.     })(this));
  4728.   };
  4729.  
  4730.   CartView.prototype.getRates = function() {
  4731.     return this.calculateShipping();
  4732.   };
  4733.  
  4734.   CartView.prototype.calculateShipping = function(auto) {
  4735.     var ratesFeedback, shippingAddress, shippingCalculatorResponse;
  4736.     shippingCalculatorResponse = this.$(".cart-shipping-calculator-response");
  4737.     shippingCalculatorResponse.empty().append("<p class='shipping-calculator-response message'/><ul class='shipping-rates'/>");
  4738.     ratesFeedback = $(".shipping-calculator-response");
  4739.     this.$(".get-rates").val(Theme.shippingDisabled);
  4740.     if (auto) {
  4741.       shippingAddress = Theme.customerAddress;
  4742.     } else {
  4743.       shippingAddress = {};
  4744.       shippingAddress.zip = this.$(".address-zip").val() || "";
  4745.       shippingAddress.country = this.$(".address-country").val() || "";
  4746.       shippingAddress.province = this.$(".address-province").val() || "";
  4747.     }
  4748.     return Shopify.getCartShippingRatesForDestination(shippingAddress, function(rates) {
  4749.       var address, firstRate, i, len, price, rate, rateValues, response;
  4750.       address = shippingAddress.zip + ", " + shippingAddress.province + ", " + shippingAddress.country;
  4751.       if (!shippingAddress.province.length) {
  4752.         address = shippingAddress.zip + ", " + shippingAddress.country;
  4753.       }
  4754.       if (!shippingAddress.zip.length) {
  4755.         address = shippingAddress.province + ", " + shippingAddress.country;
  4756.       }
  4757.       if (!(shippingAddress.province.length && shippingAddress.zip.length)) {
  4758.         address = shippingAddress.country;
  4759.       }
  4760.       if (rates.length > 1) {
  4761.         firstRate = Shopify.Cart.ShippingCalculator.formatRate(rates[0].price);
  4762.         response = Theme.shippingCalcMultiRates.replace("**address**", address).replace("**number_of_rates**", rates.length).replace("**rate**", "<span class='money'>" + firstRate + "</span>");
  4763.         ratesFeedback.html(response);
  4764.       } else if (rates.length === 1) {
  4765.         response = Theme.shippingCalcOneRate.replace("**address**", address);
  4766.         ratesFeedback.html(response);
  4767.       } else {
  4768.         ratesFeedback.html(Theme.shippingCalcNoRates);
  4769.       }
  4770.       for (i = 0, len = rates.length; i < len; i++) {
  4771.         rate = rates[i];
  4772.         price = Shopify.Cart.ShippingCalculator.formatRate(rate.price);
  4773.         rateValues = Theme.shippingCalcRateValues.replace("**rate_title**", rate.name).replace("**rate**", "<span class='money'>" + price + "</span>");
  4774.         this.$(".shipping-rates").append("<li>" + rateValues + "</li>");
  4775.       }
  4776.       return this.$(".get-rates").val(Theme.shippingButton);
  4777.     });
  4778.   };
  4779.  
  4780.   CartView.prototype.handleErrors = function(errors) {
  4781.     var errorMessage;
  4782.     errorMessage = $.parseJSON(errors.responseText);
  4783.     errorMessage = Theme.shippingCalcErrorMessage.replace("**error_message**", errorMessage.zip);
  4784.     this.$(".cart-shipping-calculator-response").html("<p>" + errorMessage + "</p>");
  4785.     return this.$(".get-rates").val(Theme.shippingButton);
  4786.   };
  4787.  
  4788.   return CartView;
  4789.  
  4790. })(Backbone.View);
  4791.  
  4792. window.ListCollections = (function(superClass) {
  4793.   extend(ListCollections, superClass);
  4794.  
  4795.   function ListCollections($el) {
  4796.     this.$masonry = $el.find('[data-masonry-grid]');
  4797.     this.masonryGrid = null;
  4798.     if (this.$masonry.length) {
  4799.       this.masonryGrid = new MasonryGrid({
  4800.         $el: this.$masonry
  4801.       });
  4802.     }
  4803.   }
  4804.  
  4805.   ListCollections.prototype.onSectionUnload = function() {
  4806.     if (this.masonryGrid) {
  4807.       return this.masonryGrid.unload();
  4808.     }
  4809.   };
  4810.  
  4811.   return ListCollections;
  4812.  
  4813. })(Backbone.View);
  4814.  
  4815. window.ThemeView = (function(superClass) {
  4816.   extend(ThemeView, superClass);
  4817.  
  4818.   function ThemeView() {
  4819.     return ThemeView.__super__.constructor.apply(this, arguments);
  4820.   }
  4821.  
  4822.   ThemeView.prototype.el = document.body;
  4823.  
  4824.   ThemeView.prototype.events = {
  4825.     'submit .contact-form': 'spamCheck'
  4826.   };
  4827.  
  4828.   ThemeView.prototype.initialize = function() {
  4829.     var body;
  4830.     body = $(document.body);
  4831.     this.isHome = body.hasClass("template-index");
  4832.     this.isCollection = body.hasClass("template-collection");
  4833.     this.isListCollections = body.hasClass("template-list-collections");
  4834.     this.isProduct = body.hasClass("template-product");
  4835.     this.isCart = body.hasClass("template-cart");
  4836.     this.isPage = body.hasClass("template-page");
  4837.     this.isBlog = body.hasClass("template-blog");
  4838.     this.isArticle = body.hasClass("template-article");
  4839.     this.isAccount = body.attr("class").indexOf("-customers-") > 0;
  4840.     this.is404 = body.hasClass("template-404");
  4841.     this.isSearch = body.hasClass("template-search");
  4842.     this.isPasswordPage = body.hasClass("template-password");
  4843.     this.isGiftCardPage = body.hasClass("gift-card-template");
  4844.     this.sectionBinding();
  4845.     if (navigator.userAgent.indexOf("MSIE 10") !== -1) {
  4846.       this.$el.addClass("ie10");
  4847.     }
  4848.     $(window).load((function(_this) {
  4849.       return function() {
  4850.         return body.removeClass("loading");
  4851.       };
  4852.     })(this));
  4853.     return $(window).on('dragStart', (function(_this) {
  4854.       return function(event) {
  4855.         var $flickityEnabledEl, $target, flickity;
  4856.         $target = $(event.target);
  4857.         $flickityEnabledEl = $target.closest('.flickity-enabled');
  4858.         if (!$flickityEnabledEl.length) {
  4859.           return;
  4860.         }
  4861.         flickity = Flickity.data($flickityEnabledEl[0]);
  4862.         return window.removeEventListener('scroll', flickity);
  4863.       };
  4864.     })(this));
  4865.   };
  4866.  
  4867.   ThemeView.prototype.render = function() {
  4868.     var i, j, l, len, len1, len2, productItem, ref, ref1, ref2, rte, select;
  4869.     if (Theme.currencySwitcher) {
  4870.       this.currencyView = new CurrencyView({
  4871.         el: this.$(".currency-switcher")
  4872.       });
  4873.       this.$(".currency-switcher").trigger('switch-currency');
  4874.     }
  4875.     if (this.isHome) {
  4876.       new HomeView({
  4877.         el: this.$el
  4878.       });
  4879.     }
  4880.     if (this.isAccount) {
  4881.       new AccountView({
  4882.         el: this.$el
  4883.       });
  4884.     }
  4885.     if (this.is404) {
  4886.       new NotFoundView({
  4887.         el: this.$el
  4888.       });
  4889.     }
  4890.     if (this.isSearch && Theme.quickShop) {
  4891.       new QuickShopView({
  4892.         el: this.$(".search-results-products")
  4893.       });
  4894.     }
  4895.     if (this.isPasswordPage) {
  4896.       new PasswordView();
  4897.     }
  4898.     if (this.isGiftCardPage) {
  4899.       new GiftCardView();
  4900.     }
  4901.     if (!this.isProduct) {
  4902.       ref = $(".rte");
  4903.       for (i = 0, len = ref.length; i < len; i++) {
  4904.         rte = ref[i];
  4905.         new RTEView({
  4906.           el: rte
  4907.         });
  4908.       }
  4909.       ref1 = $("select");
  4910.       for (j = 0, len1 = ref1.length; j < len1; j++) {
  4911.         select = ref1[j];
  4912.         new SelectView({
  4913.           el: select
  4914.         });
  4915.       }
  4916.     }
  4917.     if (!this.isHome) {
  4918.       ref2 = $(".product-list-item");
  4919.       for (l = 0, len2 = ref2.length; l < len2; l++) {
  4920.         productItem = ref2[l];
  4921.         new ProductListItemView({
  4922.           el: productItem
  4923.         });
  4924.       }
  4925.     }
  4926.     if ($("html").hasClass("lt-ie10")) {
  4927.       return this.inputPlaceholderFix();
  4928.     }
  4929.   };
  4930.  
  4931.   ThemeView.prototype.sectionBinding = function() {
  4932.     this.sections = new ThemeEditor();
  4933.     this.sections.register('header', this.header(this.sections));
  4934.     if (this.isListCollections) {
  4935.       this.sections.register('collections-list', this.listCollections(this.sections));
  4936.     }
  4937.     if (this.isCollection) {
  4938.       this.sections.register('collection', this.collection(this.sections));
  4939.     }
  4940.     if (this.isBlog) {
  4941.       new BlogViewHandler(this.$el);
  4942.     }
  4943.     if (this.isArticle) {
  4944.       this.sections.register('article', this.article(this.sections));
  4945.     }
  4946.     if (this.isCart) {
  4947.       this.sections.register('cart', this.cart(this.sections));
  4948.     }
  4949.     if (this.isProduct) {
  4950.       this.sections.register('product', this.product(this.sections));
  4951.     }
  4952.     $(document).on('shopify:section:load', (function(_this) {
  4953.       return function() {
  4954.         if (_this.currencyView) {
  4955.           _this.currencyView.unload();
  4956.           _this.currencyView = null;
  4957.         }
  4958.         if (Theme.currencySwitcher) {
  4959.           _this.currencyView = new CurrencyView({
  4960.             el: _this.$(".currency-switcher")
  4961.           });
  4962.           return _this.$(".currency-switcher").trigger('switch-currency');
  4963.         }
  4964.       };
  4965.     })(this));
  4966.     return $(document).on('shopify:section:unload', (function(_this) {
  4967.       return function() {
  4968.         if (_this.currencyView) {
  4969.           _this.currencyView.unload();
  4970.           return _this.currencyView = null;
  4971.         }
  4972.       };
  4973.     })(this));
  4974.   };
  4975.  
  4976.   ThemeView.prototype.header = function(sections) {
  4977.     return {
  4978.       instances: {},
  4979.       init: function(instance) {
  4980.         return this.instances[instance.sectionId] = new HeaderView({
  4981.           el: instance.$container
  4982.         });
  4983.       },
  4984.       onSectionLoad: function(event) {
  4985.         var instance;
  4986.         instance = sections.getInstance(event);
  4987.         if (this.instances[instance.sectionId] == null) {
  4988.           return this.init(instance);
  4989.         }
  4990.       },
  4991.       onSectionDeselect: function(event) {
  4992.         var instance;
  4993.         instance = sections.getInstance(event);
  4994.         return this.instances[instance.sectionId].onSectionDeselect();
  4995.       },
  4996.       onSectionUnload: function(event) {
  4997.         var instance;
  4998.         instance = sections.getInstance(event);
  4999.         this.instances[instance.sectionId].unload();
  5000.         return delete this.instances[instance.sectionId];
  5001.       }
  5002.     };
  5003.   };
  5004.  
  5005.   ThemeView.prototype.listCollections = function(sections) {
  5006.     return {
  5007.       instances: {},
  5008.       init: function(instance) {
  5009.         return this.instances[instance.sectionId] = new ListCollections(instance.$container);
  5010.       },
  5011.       onSectionLoad: function(event) {
  5012.         var instance;
  5013.         instance = sections.getInstance(event);
  5014.         if (this.instances[instance.sectionId] == null) {
  5015.           return this.init(instance);
  5016.         }
  5017.       },
  5018.       onSectionUnload: function(event) {
  5019.         var instance;
  5020.         instance = sections.getInstance(event);
  5021.         this.instances[instance.sectionId].onSectionUnload();
  5022.         return delete this.instances[instance.sectionId];
  5023.       }
  5024.     };
  5025.   };
  5026.  
  5027.   ThemeView.prototype.collection = function(sections) {
  5028.     return {
  5029.       instances: {},
  5030.       init: function(instance) {
  5031.         return this.instances[instance.sectionId] = new CollectionView({
  5032.           el: instance.$container
  5033.         });
  5034.       },
  5035.       onSectionLoad: function(event) {
  5036.         var instance;
  5037.         instance = sections.getInstance(event);
  5038.         if (this.instances[instance.sectionId] == null) {
  5039.           return this.init(instance);
  5040.         }
  5041.       },
  5042.       onSectionUnload: function(event) {
  5043.         var instance, ref;
  5044.         instance = sections.getInstance(event);
  5045.         this.instances[instance.sectionId].onSectionUnload();
  5046.         if ((ref = this.instances[instance.sectionId]) != null) {
  5047.           ref.remove();
  5048.         }
  5049.         return delete this.instances[instance.sectionId];
  5050.       }
  5051.     };
  5052.   };
  5053.  
  5054.   ThemeView.prototype.article = function(sections) {
  5055.     return {
  5056.       instances: {},
  5057.       init: function(instance) {
  5058.         return this.instances[instance.sectionId] = new ArticleView({
  5059.           el: instance.$container
  5060.         });
  5061.       },
  5062.       onSectionLoad: function(event) {
  5063.         var instance;
  5064.         instance = sections.getInstance(event);
  5065.         if (this.instances[instance.sectionId] == null) {
  5066.           return this.init(instance);
  5067.         }
  5068.       },
  5069.       onSectionSelect: function(event) {
  5070.         var instance, ref;
  5071.         instance = sections.getInstance(event);
  5072.         return (ref = this.instances[instance.sectionId]) != null ? ref.update(instance.$container) : void 0;
  5073.       },
  5074.       onSectionDeselect: function(event) {
  5075.         return this.onSectionSelect(event);
  5076.       },
  5077.       onSectionUnload: function(event) {
  5078.         var instance, ref;
  5079.         instance = sections.getInstance(event);
  5080.         if ((ref = this.instances[instance.sectionId]) != null) {
  5081.           ref.remove();
  5082.         }
  5083.         return delete this.instances[instance.sectionId];
  5084.       }
  5085.     };
  5086.   };
  5087.  
  5088.   ThemeView.prototype.cart = function(sections) {
  5089.     return {
  5090.       instances: {},
  5091.       init: function(instance) {
  5092.         return this.instances[instance.sectionId] = new CartView({
  5093.           el: instance.$container
  5094.         });
  5095.       },
  5096.       onSectionLoad: function(event) {
  5097.         var instance;
  5098.         instance = sections.getInstance(event);
  5099.         if (this.instances[instance.sectionId] == null) {
  5100.           return this.init(instance);
  5101.         }
  5102.       },
  5103.       onSectionSelect: function(event) {
  5104.         var instance, ref;
  5105.         instance = sections.getInstance(event);
  5106.         return (ref = this.instances[instance.sectionId]) != null ? ref.update(instance.$container) : void 0;
  5107.       },
  5108.       onSectionDeselect: function(event) {
  5109.         return this.onSectionSelect(event);
  5110.       },
  5111.       onSectionUnload: function(event) {
  5112.         var instance, ref;
  5113.         instance = sections.getInstance(event);
  5114.         if ((ref = this.instances[instance.sectionId]) != null) {
  5115.           ref.remove();
  5116.         }
  5117.         return delete this.instances[instance.sectionId];
  5118.       }
  5119.     };
  5120.   };
  5121.  
  5122.   ThemeView.prototype.product = function(sections) {
  5123.     return {
  5124.       instances: {},
  5125.       init: function(instance) {
  5126.         return this.instances[instance.sectionId] = new ProductView({
  5127.           el: instance.$container
  5128.         });
  5129.       },
  5130.       onSectionLoad: function(event) {
  5131.         var instance;
  5132.         instance = sections.getInstance(event);
  5133.         if (this.instances[instance.sectionId] == null) {
  5134.           return this.init(instance);
  5135.         }
  5136.       },
  5137.       onSectionUnload: function(event) {
  5138.         var instance;
  5139.         instance = sections.getInstance(event);
  5140.         this.instances[instance.sectionId].onSectionUnload();
  5141.         this.instances[instance.sectionId].remove();
  5142.         return delete this.instances[instance.sectionId];
  5143.       }
  5144.     };
  5145.   };
  5146.  
  5147.   ThemeView.prototype.inputPlaceholderFix = function() {
  5148.     var i, input, len, placeholders, text;
  5149.     placeholders = $("[placeholder]");
  5150.     for (i = 0, len = placeholders.length; i < len; i++) {
  5151.       input = placeholders[i];
  5152.       input = $(input);
  5153.       if (!(input.val().length > 0)) {
  5154.         text = input.attr("placeholder");
  5155.         input.attr("value", text);
  5156.         input.data("original-text", text);
  5157.       }
  5158.     }
  5159.     placeholders.focus(function() {
  5160.       input = $(this);
  5161.       if (input.val() === input.data("original-text")) {
  5162.         return input.val('');
  5163.       }
  5164.     });
  5165.     return placeholders.blur(function() {
  5166.       input = $(this);
  5167.       if (input.val().length === 0) {
  5168.         return input.val(input.data("original-text"));
  5169.       }
  5170.     });
  5171.   };
  5172.  
  5173.   ThemeView.prototype.spamCheck = function(e) {
  5174.     if (this.$(e.target).find('.comment-check').val().length > 0) {
  5175.       return e.preventDefault();
  5176.     }
  5177.   };
  5178.  
  5179.   return ThemeView;
  5180.  
  5181. })(Backbone.View);
  5182.  
  5183. $(function() {
  5184.   window.theme = new ThemeView();
  5185.   return theme.render();
  5186. });
  5187.  
  5188.  
  5189. $(document).ready( function() {
  5190. jQuery('a[href^="http"]').not('a[href^="'+$(location).attr('hostname')+'"]').attr('target', '_blank');
  5191. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement