{"version":3,"names":[],"mappings":"","sources":["app.js"],"sourcesContent":["(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require==\"function\"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error(\"Cannot find module '\"+o+\"'\");throw f.code=\"MODULE_NOT_FOUND\",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require==\"function\"&&require;for(var o=0;o= charsLimit && controlKeys.indexOf(e.which.toString()) < 0) {\n e.preventDefault();\n }\n })\n .on('change keyup mouseup', 'textarea[data-character-limit]', function () {\n var text = $.trim($(this).val()),\n charsLimit = $(this).data('character-limit'),\n charsUsed = text.length,\n charsRemain = charsLimit - charsUsed;\n\n if (charsRemain < 0) {\n $(this).val(text.slice(0, charsRemain));\n charsRemain = 0;\n }\n\n $(this).parent().parent().find('label').find('div.char-count').find('.char-remain-count').html(charsUsed);\n })\n .on('mouseover mouseout', 'li:has(.has-sub-menu)', function (e) {\n !is_touch_device() && document.documentElement.clientWidth > 1024 && $('#wrapper')[e.type == 'mouseover' ? 'addClass' : 'removeClass']('menu-active');\n })\n // add touch class to body\n .addClass(is_touch_device() ? 'touch' : 'no-touch')\n .addClass(!!navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform) ? 'ios' : '');\n\n /**\n * initialize search suggestions, pending the value of the site preference(enhancedSearchSuggestions)\n * this will either init the legacy(false) or the beta versions(true) of the the search suggest feature.\n * */\n var $searchContainer = $('.header-search').filter(function () {\n return $(this).css('display') != 'none';\n });\n searchsuggestbeta.init($searchContainer, Resources.SIMPLE_SEARCH);\n\n // add show/hide navigation elements\n $('.secondary-navigation .toggle').click(function () {\n $(this).toggleClass('expanded').next('ul').toggle();\n });\n\n // add generic toggle functionality\n $('.toggle').next('.toggle-content').hide();\n $('.toggle').click(function () {\n $(this).toggleClass('expanded').next('.toggle-content').toggle();\n });\n\n // add specific toggle functionality\n $('.toggle-direct').click(function () {\n var toggle = $(this).data('direct');\n var inputs = $(toggle).find(':input');\n\n // toggle view\n $(toggle).toggleClass('toggle-content');\n\n // clear inputs inside of directly toggle item on toggle\n $(inputs).each(function (index) {\n $($inputs[index]).val('');\n });\n });\n\n if ($('button[name=\"dwfrm_giftregistry_search_search\"]').length > 0) {\n var inputs = $('.gift-registry-advanced').find(':input');\n\n $('.registry-search').submit(function () {\n // clear any non viewable inputs\n if ($('.gift-registry-advanced-form').hasClass('toggle-content')) {\n $(inputs).each(function (index) {\n $(inputs[index]).val('');\n });\n }\n });\n }\n\n // subscribe email box\n var $subscribeEmail = $('.subscribe-email');\n if ($subscribeEmail.length > 0) {\n $subscribeEmail\n .focus(function () {\n var val = $(this.val());\n if (val.length > 0 && val !== Resources.SUBSCRIBE_EMAIL_DEFAULT) {\n return; // do not animate when contains non-default value\n }\n\n $(this).animate({ color: '#999999' }, 500, 'linear', function () {\n $(this).val('').css('color', '#333333');\n });\n })\n .blur(function () {\n var val = $.trim($(this.val()));\n if (val.length > 0) {\n return; // do not animate when contains value\n }\n $(this).val(Resources.SUBSCRIBE_EMAIL_DEFAULT).css('color', '#999999').animate({ color: '#333333' }, 500, 'linear');\n });\n }\n\n $('.about-security').on('click', function (e) {\n e.preventDefault();\n dialog.open({\n url: $(e.target).attr('href'),\n options: {\n height: 600\n }\n });\n });\n\n $('.privacy-policy').on('click', function (e) {\n e.preventDefault();\n dialog.open({\n url: $(e.target).attr('href'),\n options: {\n height: 600,\n title: Resources.PRIVACY_POLICY,\n open: function () {\n $('.ui-dialog').addClass('privacy-policy-popup');\n }\n }\n });\n });\n\n // Promo Carousel\n var promoCarousel = $('.promo-carousel');\n if (promoCarousel.find('div').length > 1) {\n $('.promo-carousel').slick({\n autoplay: true,\n autoplaySpeed: 5000\n });\n }\n\n // main menu toggle\n $('.menu-toggle').on('click', function (e) {\n e.preventDefault();\n $('#navigation li.active .menu-item-toggle').trigger('click');\n $('#wrapper').toggleClass('menu-active');\n $('#wrapper').removeClass('submenu-active');\n if ($(this).attr('aria-expanded') == 'false') {\n $(this).attr('aria-expanded', 'true');\n } else {\n $(this).attr('aria-expanded', 'false');\n }\n\n $('#navigation').css('max-height', function () {\n if (document.documentElement.clientWidth >= 768) return 'none';\n var headerH = $('.header-banner').height() + $('.top-banner').height();\n return 'calc(100vh - ' + headerH + 'px)';\n });\n });\n\n $('#navigation .menu-category li.has-sub-menu').on('click', function (e) {\n var $parentLi = $(e.target).closest('li');\n var isMobile = window.matchMedia('only screen and (max-width: 1024px)').matches;\n if ($parentLi.hasClass('has-sub-menu') && isMobile) {\n e.preventDefault();\n }\n $parentLi.toggleClass('active');\n\n var $grandParentLi = $(e.target).parents('.active');\n $('#navigation li').not($grandParentLi).removeClass('active');\n if ($('#navigation li.active').length > 0) {\n $('#wrapper').addClass('submenu-active');\n $grandParentLi.addClass('active');\n } else {\n $('#wrapper').removeClass('submenu-active');\n }\n });\n\n // Collections DOM Changes\n $('li.hasThumbnail').wrapAll('');\n $('ul.subCatThumbnails').siblings('li').wrapAll('');\n $('ul.subCatThumbnails, ul.subCatLeft').wrap('
  • ');\n $('ul.subCatLeft').prepend('
  • Features
  • ');\n $('ul.subCatThumbnails').closest('ul.menu-vertical').addClass('subCatWrapper');\n\n // navigation active overlay\n $('
    ', { class: 'overlay' })\n .insertAfter('#wrapper')\n .on('click', function () {\n $('#wrapper').removeClass('menu-active').removeClass('submenu-active');\n });\n\n // check cate-banner\n $('#cat-banner')\n .filter(function () {\n return $(this).find('.slot-grid-header').height() > 1;\n })\n .addClass('has-banner');\n\n // menu scroll bar\n var useCompactHeader = SitePreferences.USECOMPACTHEADER;\n $(window).scroll(function () {\n if (document.documentElement.clientWidth > 1024) {\n $('body')[$(window).scrollTop() > ($('.header-banner').height() || 1) ? 'addClass' : 'removeClass']('navbar-fixed-top')[$('.fixTop, .sticky.animated').length ? 'addClass' : 'removeClass']('sub-fixed-top');\n if (useCompactHeader == false) {\n \t$('body').addClass('fullStickyHeader');\n }\n }\n });\n\n // Scroll button element\n $('.hero-banner_arrow').click(function () {\n var heightelement = $('.home-intro-message').height() + $('.top-banner').height() + $('.header-banner').height();\n $('html, body').animate(\n {\n scrollTop: $('.home-intro-message').offset().top - heightelement - 40\n },\n 1000\n );\n });\n\n // footer accordion\n $(document).on('click', '.footer-container .accordion-toggle', function (e) {\n e.preventDefault();\n });\n $('.footer-item h2')\n .not('.footer-item-4 h2')\n .click(function (e) {\n var $currentItem = $(this).closest('.footer-item');\n var isMobile = window.matchMedia('only screen and (max-width: 767px)').matches;\n if (isMobile) {\n $('.footer-item.active').not($currentItem).removeClass('active');\n $currentItem.toggleClass('active');\n }\n });\n //navigation flyout\n var navAlign = function () {\n var vpw = document.documentElement.clientWidth;\n $('.level-1 > li')\n .off('mouseenter')\n .on('mouseenter', function () {\n if (vpw > 1024) {\n var $subNav = $(this).find('.level-2').removeClass('r');\n if ($subNav.length < 1) return !1;\n var l = $subNav.data('left') || $subNav.offset().left,\n w = $subNav.outerWidth();\n $subNav.data('left', l);\n l + w > vpw && $subNav.addClass('r');\n }\n });\n };\n navAlign();\n $(window).on('load delayed-resize', function () {\n navAlign();\n $('#navigation').css('max-height', function () {\n if (document.documentElement.clientWidth >= 768) return 'none';\n var headerH = $('.header-banner').height() + $('.top-banner').height();\n return 'calc(100vh - ' + headerH + 'px)';\n });\n });\n\n\n var gtm = require('./gtm');\n $('.thumb-link')\n .on({\n click: gtm.eccViewItemOnClick\n });\n\n $('.view-full-details')\n .on({\n click: gtm.eccViewItemOnClick\n });\n\n}\n\n\n/**\n * @private\n * @function\n * @description Adds class ('js') to html for css targeting and loads js specific styles.\n */\nfunction initializeDom() {\n // add class to html for css targeting\n $('html').addClass('js');\n if (SitePreferences.LISTING_INFINITE_SCROLL) {\n $('html').addClass('infinite-scroll');\n }\n // load js specific styles\n util.limitCharacters();\n}\n\n/**\n * @private\n * @function\n * @description Detect touch device\n */\nfunction is_touch_device() {\n return 'ontouchstart' in window || navigator.MaxTouchPoints > 0 || navigator.msMaxTouchPoints > 0;\n}\n\nvar pages = {\n account: require('./pages/account'),\n cart: require('./pages/cart'),\n checkout: require('./pages/checkout'),\n compare: require('./pages/compare'),\n product: require('./pages/product'),\n registry: require('./pages/registry'),\n search: require('./pages/search'),\n storefront: require('./pages/storefront'),\n wishlist: require('./pages/wishlist'),\n storelocator: require('./pages/storelocator'),\n orderconfirmation: require('./pages/checkout/orderconfirmation')\n};\n\nvar app = {\n init: function () {\n if (document.cookie.length === 0) {\n $('
    ').addClass('browser-compatibility-alert').append($('

    ').addClass('browser-error').html(Resources.COOKIES_DISABLED)).appendTo('#browser-check');\n }\n initializeDom();\n initializeEvents();\n\n // init specific global components\n countries.init();\n tooltip.init();\n minicart.init();\n validator.init();\n rating.init();\n searchplaceholder.init();\n cq.init();\n multishipaddressAction.init();\n giftregistry.init();\n // execute page specific initializations\n $.extend(page, window.pageContext);\n var ns = page.ns;\n if (ns && pages[ns] && pages[ns].init) {\n pages[ns].init();\n }\n }\n};\n\n// general extension functions\n(function () {\n String.format = function () {\n var s = arguments[0];\n var i,\n len = arguments.length - 1;\n for (i = 0; i < len; i++) {\n var reg = new RegExp('\\\\{' + i + '\\\\}', 'gm');\n s = s.replace(reg, arguments[i + 1]);\n }\n return s;\n };\n})();\n\n// initialize app\n$(function () {\n app.init();\n //js for search feature\n var simpleSearchT;\n var buttonSearchTitle = $('span.search-title');\n\n buttonSearchTitle.on('click', function (e) {\n e.preventDefault();\n });\n\n $('.inputSimpleSeach').on('focus', function () {\n buttonSearchTitle.fadeOut(400);\n $(this).addClass('simpleSeachFocus');\n simpleSearchT = setTimeout(function () {\n $('.iconSeach').show();\n }, 500);\n });\n $('.iconSeach').on('blur', function () {\n simpleSearchT && clearTimeout(simpleSearchT);\n $('.inputSimpleSeach').removeClass('simpleSeachFocus').val('');\n $('.iconSeach').hide();\n searchsuggestbeta.clearResults();\n });\n $(document).on('click', function (e) {\n if (!$('.inputSimpleSeach').is(e.target)) {\n simpleSearchT && clearTimeout(simpleSearchT);\n setTimeout(function () {\n buttonSearchTitle.fadeIn(400);\n $('.inputSimpleSeach').removeClass('simpleSeachFocus').val('');\n }, 500);\n $('.iconSeach').hide();\n searchsuggestbeta.clearResults();\n }\n });\n $('.address').on('keydown', function (e) {\n var code = e.keyCode || e.which;\n if (code == '9') {\n setTimeout(function () {\n $('input.error').first().focus();\n if ($('.error:first')) {\n $('.adaError').remove();\n $('input.error')\n .closest('.form-row')\n .find('label')\n .append('');\n }\n }, 10);\n $('.adaError').remove();\n }\n });\n $('.address').on('touchstart', function (e) {\n setTimeout(function () {\n $('input.error').first().focus();\n if ($('.error:first')) {\n $('.adaError').remove();\n $('input.error')\n .closest('.form-row')\n .find('label')\n .append('

    ' + Resources.VALIDATE_REQUIRED + '
    ');\n }\n }, 100);\n $('.adaError').remove();\n });\n $(document).on('touchstart', '#edit-address-form', function (e) {\n setTimeout(function () {\n $('input.error').first().focus();\n if ($('.error:first')) {\n $('.adaError').remove();\n $('input.error')\n .closest('.form-row')\n .find('label')\n .append('
    ' + Resources.VALIDATE_REQUIRED + '
    ');\n }\n }, 100);\n $('.adaError').remove();\n });\n $(document).on('keydown', '#edit-address-form', function (e) {\n var code = e.keyCode || e.which;\n if (code == '9') {\n setTimeout(function () {\n $('input.error').first().focus();\n if ($('.error:first')) {\n $('.adaError').remove();\n $('input.error')\n .closest('.form-row')\n .find('label')\n .append('');\n }\n }, 10);\n $('.adaError').remove();\n }\n });\n function subscribeEmail($signupForm, emailId) {\n $signUpForm.find('.signup-msg').remove();\n\n if (!$signUpForm.validate().form()) {\n return !1;\n }\n\n var signUpUrl = util.appendParamsToUrl(Urls.sendEmailSignUp, {\n email: emailId\n });\n\n if (SitePreferences.LISTRAK_TEST_MODE) {\n signUpUrl = util.appendParamsToUrl(signUpUrl, {\n ltkjstestmode: '1',\n ltkprefcentertestmode: '1'\n });\n }\n\n page.redirect(signUpUrl);\n }\n\n //send email address to listrak\n var $signUpForm = $('form[id$=\"email-alert-signup\"]');\n\n $signUpForm.on('submit', function (e) {\n e.preventDefault();\n\n var emailId = $signUpForm.find('[name$=\"email\"]').val();\n var loyaltyUrl = util.appendParamsToUrl(Urls.loyaltyProgram, {\n emailId: emailId\n });\n\n $.ajax(loyaltyUrl).always(subscribeEmail.bind(this, $signUpForm, emailId));\n });\n\n if ($('.top-banner').length) {\n var headeroffset = $('.top-banner').offset().top + $('.top-banner').height();\n $('body')[$(this).scrollTop() > headeroffset ? 'addClass' : 'removeClass']('navbar-fixed-top');\n }\n\n // Leaving commented here for reference in case we need to put it back!\n /*$('.header-promotion')\n .find('a')\n .on('click', function (e) {\n e.preventDefault();\n dialog.open({\n url: this.href,\n options: {\n dialogClass: 'header-promodion-dialog'\n }\n });\n });*/\n\n $(document).on('click', '.product-primary-image .image-nav', function () {\n var act = $(this).data('action'),\n $thumbs = $('#thumbnails li.thumb'),\n $cur = $thumbs.filter('.selected');\n if ($cur.length < 1) return !1;\n var $target = $cur[act]().length ? $cur[act]() : $thumbs[act == 'next' ? 'first' : 'last']();\n $target.find('.productthumbnail').trigger('click');\n //scroll to current thumb\n $('#thumbnails').jcarousel && $('#thumbnails').jcarousel('scroll', $target);\n });\n\n //Add effect while scroll to Store details\n $('.store-cta').on('click', function () {\n $('html, body').animate(\n {\n scrollTop: $($(this).attr('href')).offset().top\n },\n 500\n );\n });\n //hide next and previous button\n var isMobile = window.matchMedia('only screen and (max-width: 1024px)').matches;\n var tileCount = $('.recently-viewed-content li.grid-tile').length;\n var minTiles = isMobile ? 3 : 4;\n if (tileCount < minTiles) {\n $('.recently-viewed-content .jcarousel-mc-prev').hide();\n $('.recently-viewed-content .jcarousel-mc-next').hide();\n }\n\n if ($('.wrap-product-thumbnails ul li').length <= 1) {\n $('.wrap-product-thumbnails .jcarousel-control-prev').hide();\n $('.wrap-product-thumbnails .jcarousel-control-next').hide();\n }\n\n var giftScroll = function (selector, target) {\n var formOffset = $(selector).offset().top - 90;\n $('html, body').animate({ scrollTop: formOffset }, 800);\n };\n\n $('.Find').on('click', function (e) {\n giftScroll('#find-registry');\n });\n\n $('.pt_gift-registry.client .Create').on('click', function (e) {\n giftScroll('#dwfrm_giftregistry');\n });\n\n $('.pt_gift-registry.client .Manage').on('click', function (e) {\n giftScroll('#your-registries');\n });\n\n $('.pt_gift-registry.guest .Create, .pt_gift-registry.guest .Manage').on('click', function (e) {\n giftScroll('#registry-login');\n });\n});\n\n$('.thumb-link').on('keydown', function (e) {\n var code = e.keyCode || e.which;\n if (code == '13') {\n $(this).click();\n }\n});\n\n$('.store-inner').on('keydown', function (e) {\n var code = e.keyCode || e.which;\n if (code == '13') {\n var elementFocus = $(this).find('a').attr('href');\n $(this).find('a').click();\n $(elementFocus).focus();\n }\n});\n\n$('.flyout-menu').on('keydown', function (e) {\n var code = e.keyCode || e.which;\n if (code == '13' || (code == '13' && code.shiftKey)) {\n $(this).toggleClass('open');\n if ($(this).hasClass('open')) {\n this.setAttribute('aria-expanded', 'true');\n } else {\n this.setAttribute('aria-expanded', 'false');\n }\n }\n});\n\nvar menuItems = document.querySelectorAll('.has-sub-menu');\nArray.prototype.forEach.call(menuItems, function (el) {\n //this redundancy is used to initialize the sub-menus to prevent the need to hit enter twice\n $('.has-sub-menu').attr('class', 'has-sub-menu');\n el.querySelector('a').addEventListener('keydown', function (event) {\n var key = event.which || event.keyCode;\n if (key === 13) {\n $('.menu-horizontal li .ada-top-link').remove();\n if (this.parentNode.className == 'has-sub-menu') {\n if ($('.has-sub-menu .open')) {\n $('.has-sub-menu').attr('class', 'has-sub-menu');\n $('.has-sub-menu a').attr('aria-expanded', 'false');\n }\n this.parentNode.className = 'has-sub-menu open';\n this.setAttribute('aria-expanded', 'true');\n } else {\n this.parentNode.className = 'has-sub-menu';\n this.setAttribute('aria-expanded', 'false');\n }\n event.preventDefault();\n return false;\n }\n if (key === 13 && key.shiftKey) {\n $(this).click();\n }\n });\n});\n\n$('.menu-category > li:not(.has-sub-menu)').find('a').removeAttr('aria-expanded');\n\n$(document).on('keydown', '.zoom-trigger', function (e) {\n var key = event.which || event.keyCode;\n if (key === 13) {\n $(this).click();\n }\n});\n\nfunction changeAdaAddToCartRegion() {\n setTimeout(function () {\n $('#adaAddCart').html(Resources.ADDED_TO_CART);\n $('#adaAddCart').attr('tabindex', '0');\n $(this).trigger({ type: 'keypress', which: 9 });\n $('#adaAddCart').focus();\n }, 500);\n setTimeout(function () {\n $('#adaAddCart').html('');\n $('#adaAddCart').attr('tabindex', '-1');\n $('.add-to-cart').focus();\n }, 1500);\n}\n\n$('body').on('click', '.add-to-cart', function (e) {\n setTimeout(function () {\n $('#adaAddCart').html(Resources.ADDED_TO_CART);\n $('#adaAddCart').attr('tabindex', '0');\n $(this).trigger({ type: 'keypress', which: 9 });\n $('#adaAddCart').focus();\n }, 500);\n setTimeout(function () {\n $('#adaAddCart').html('');\n $('#adaAddCart').attr('tabindex', '-1');\n $('.add-to-cart').focus();\n }, 1500);\n});\n\n$('body').on('keydown', '.add-to-cart', function (e) {\n var key = event.which || event.keyCode;\n if (key === 13) {\n changeAdaAddToCartRegion();\n }\n});\n\n$('.name-link').on('focus', function () {\n $('#quickviewbutton').remove();\n});\n\n$('.image-nav').on('click', function () {\n setTimeout(function () {\n var selected = $('#thumbnails').find('.selected');\n var mainImage = $('.product-primary-image').find('.primary-image');\n var mainTitle = $('.product-image');\n selected = selected.find('.productthumbnail');\n selected = selected.attr('alt');\n mainImage.attr('alt', selected);\n mainTitle.attr('title', selected);\n }, 100);\n});\n\n$(function () {\n var selected = $('#thumbnails').find('.selected');\n var mainImage = $('.product-primary-image').find('.primary-image');\n selected = selected.find('.productthumbnail');\n var mainTitle = $('.product-image');\n selected = selected.attr('alt');\n mainImage.attr('alt', selected);\n mainTitle.attr('title', selected);\n});\n\n// hides info if gift registry selected as shipping address, adds boolean to gift registry button based on option selected\n$('.pt-checkout-content #dwfrm_singleshipping_addressList').on('change', function (e) {\n if ($(e.currentTarget).find(':selected').attr('isgiftregistry') == 'true') {\n $('#dwfrm_singleshipping_shippingAddress .form-row:not(.select-address, .form-row-button)').addClass('hidden');\n $('#useGRAddress').prop('checked', true);\n } else {\n $('#dwfrm_singleshipping_shippingAddress .form-row:not(.select-address, .form-row-button)').removeClass('hidden');\n $('#useGRAddress').prop('checked', false);\n }\n});\n\n},{\"./cookieprivacy\":7,\"./countries\":8,\"./cq\":9,\"./dialog\":10,\"./giftregistry\":13,\"./gtm\":14,\"./jquery-ext\":16,\"./minicart\":18,\"./multishipaddressAction\":19,\"./page\":20,\"./pages/account\":21,\"./pages/cart\":22,\"./pages/checkout\":26,\"./pages/checkout/orderconfirmation\":28,\"./pages/compare\":30,\"./pages/product\":35,\"./pages/registry\":40,\"./pages/search\":41,\"./pages/storefront\":42,\"./pages/storelocator\":43,\"./pages/wishlist\":44,\"./rating\":48,\"./searchplaceholder\":49,\"./searchsuggest\":51,\"./searchsuggest-beta\":50,\"./tooltip\":55,\"./util\":56,\"./validator\":57}],3:[function(require,module,exports){\n'use strict';\n\nvar dialog = require('./dialog'),\n\tpage = require('./page'),\n\tutil = require('./util');\n\nvar selectedList = [];\nvar maxItems = 1;\nvar bliUUID = '';\n\n/**\n * @private\n * @function\n * description Gets a list of bonus products related to a promoted product\n */\nfunction getBonusProducts() {\n\tvar o = {};\n\to.bonusproducts = [];\n\n\tvar i, len;\n\tfor (i = 0, len = selectedList.length; i < len; i++) {\n\t\tvar p = {\n\t\t\tpid: selectedList[i].pid,\n\t\t\tqty: selectedList[i].qty,\n\t\t\toptions: {}\n\t\t};\n\t\tvar a, alen, bp = selectedList[i];\n\t\tif (bp.options) {\n\t\t\tfor (a = 0, alen = bp.options.length; a < alen; a++) {\n\t\t\t\tvar opt = bp.options[a];\n\t\t\t\tp.options = {optionName:opt.name, optionValue:opt.value};\n\t\t\t}\n\t\t}\n\t\to.bonusproducts.push({product:p});\n\t}\n\treturn o;\n}\n\nvar selectedItemTemplate = function (data) {\n\tvar attributes = '';\n\tfor (var attrID in data.attributes) {\n\t\tvar attr = data.attributes[attrID];\n\t\tattributes += '
  • \\n';\n\t\tattributes += '' + attr.displayName + ': ';\n\t\tattributes += '' + attr.displayValue + '\\n';\n\t\tattributes += '
  • ';\n\t}\n\tattributes += '
  • \\n';\n\tattributes += 'Qty: ';\n\tattributes += '' + data.qty + '';\n\treturn [\n\t\t'
  • ',\n\t\t'',\n\t\t'
    ' + data.name + '
    ',\n\t\t'
      ',\n\t\tattributes,\n\t\t'
        ',\n\t\t'
      • '\n\t].join('\\n');\n};\n\n// hide swatches that are not selected or not part of a Product Variation Group\nvar hideSwatches = function () {\n\t$('.bonus-product-item .swatches li').not('.selected').not('.variation-group-value').hide();\n\t// prevent unselecting the selected variant\n\t$('.bonus-product-item .swatches .selected').on('click', function () {\n\t\treturn false;\n\t});\n};\n\n/**\n * @private\n * @function\n * @description Updates the summary page with the selected bonus product\n */\nfunction updateSummary() {\n\tvar $bonusProductList = $('#bonus-product-list');\n\tif (selectedList.length === 0) {\n\t\t$bonusProductList.find('li.selected-bonus-item').remove();\n\t} else {\n\t\tvar ulList = $bonusProductList.find('ul.selected-bonus-items').first();\n\t\tvar i, len;\n\t\tfor (i = 0, len = selectedList.length; i < len; i++) {\n\t\t\tvar item = selectedList[i];\n\t\t\tvar li = selectedItemTemplate(item);\n\t\t\t$(li).appendTo(ulList);\n\t\t}\n\t}\n\n\t// get remaining item count\n\tvar remain = maxItems - selectedList.length;\n\t$bonusProductList.find('.bonus-items-available').text(remain);\n\tif (remain <= 0) {\n\t\t$bonusProductList.find('.select-bonus-item').attr('disabled', 'disabled');\n\t} else {\n\t\t$bonusProductList.find('.select-bonus-item').removeAttr('disabled');\n\t}\n}\n\nfunction initializeGrid () {\n\tvar $bonusProduct = $('#bonus-product-dialog'),\n\t\t$bonusProductList = $('#bonus-product-list'),\n\tbliData = $bonusProductList.data('line-item-detail');\n\tmaxItems = bliData.maxItems;\n\tbliUUID = bliData.uuid;\n\n\tif (bliData.itemCount >= maxItems) {\n\t\t$bonusProductList.find('.select-bonus-item').attr('disabled', 'disabled');\n\t}\n\n\tvar cartItems = $bonusProductList.find('.selected-bonus-item');\n\tcartItems.each(function () {\n\t\tvar ci = $(this);\n\t\tvar product = {\n\t\t\tuuid: ci.data('uuid'),\n\t\t\tpid: ci.data('pid'),\n\t\t\tqty: ci.find('.item-qty').text(),\n\t\t\tname: ci.find('.item-name').html(),\n\t\t\tattributes: {}\n\t\t};\n\t\tvar attributes = ci.find('ul.item-attributes li');\n\t\tattributes.each(function () {\n\t\t\tvar li = $(this);\n\t\t\tproduct.attributes[li.data('attributeId')] = {\n\t\t\t\tdisplayName:li.children('.display-name').html(),\n\t\t\t\tdisplayValue:li.children('.display-value').html()\n\t\t\t};\n\t\t});\n\t\tselectedList.push(product);\n\t});\n\n\t$bonusProductList.on('click', '.bonus-product-item a[href].swatchanchor', function (e) {\n\t\te.preventDefault();\n\t\tvar url = this.href,\n\t\t\t$this = $(this);\n\t\turl = util.appendParamsToUrl(url, {\n\t\t\t'source': 'bonus',\n\t\t\t'format': 'ajax'\n\t\t});\n\t\t$.ajax({\n\t\t\turl: url,\n\t\t\tsuccess: function (response) {\n\t\t\t\t$this.closest('.bonus-product-item').empty().html(response);\n\t\t\t\thideSwatches();\n\t\t\t}\n\t\t});\n\t})\n\t.on('change', '.input-text', function () {\n\t\t$bonusProductList.find('.select-bonus-item').removeAttr('disabled');\n\t\t$(this).closest('.bonus-product-form').find('.quantity-error').text('');\n\t})\n\t.on('click', '.select-bonus-item', function (e) {\n\t\te.preventDefault();\n\t\tif (selectedList.length >= maxItems) {\n\t\t\t$bonusProductList.find('.select-bonus-item').attr('disabled', 'disabled');\n\t\t\t$bonusProductList.find('.bonus-items-available').text('0');\n\t\t\treturn;\n\t\t}\n\n\t\tvar form = $(this).closest('.bonus-product-form'),\n\t\t\tdetail = $(this).closest('.product-detail'),\n\t\t\tuuid = form.find('input[name=\"productUUID\"]').val(),\n\t\t\tqtyVal = form.find('input[name=\"Quantity\"]').val(),\n\t\t\tqty = (isNaN(qtyVal)) ? 1 : (+qtyVal);\n\n\t\tif (qty > maxItems) {\n\t\t\t$bonusProductList.find('.select-bonus-item').attr('disabled', 'disabled');\n\t\t\tform.find('.quantity-error').text(Resources.BONUS_PRODUCT_TOOMANY);\n\t\t\treturn;\n\t\t}\n\n\t\tvar product = {\n\t\t\tuuid: uuid,\n\t\t\tpid: form.find('input[name=\"pid\"]').val(),\n\t\t\tqty: qty,\n\t\t\tname: detail.find('.product-name').text(),\n\t\t\tattributes: detail.find('.product-variations').data('attributes'),\n\t\t\toptions: []\n\t\t};\n\n\t\tvar optionSelects = form.find('.product-option');\n\n\t\toptionSelects.each(function () {\n\t\t\tproduct.options.push({\n\t\t\t\tname: this.name,\n\t\t\t\tvalue: $(this).val(),\n\t\t\t\tdisplay: $(this).children(':selected').first().html()\n\t\t\t});\n\t\t});\n\t\tselectedList.push(product);\n\t\tupdateSummary();\n\t})\n\t.on('click', '.remove-link', function (e) {\n\t\te.preventDefault();\n\t\tvar container = $(this).closest('.selected-bonus-item');\n\t\tif (!container.data('uuid')) { return; }\n\n\t\tvar uuid = container.data('uuid');\n\t\tvar i, len = selectedList.length;\n\t\tfor (i = 0; i < len; i++) {\n\t\t\tif (selectedList[i].uuid === uuid) {\n\t\t\t\tselectedList.splice(i, 1);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tupdateSummary();\n\t})\n\t.on('click', '.add-to-cart-bonus', function (e) {\n\t\te.preventDefault();\n\t\tvar url = util.appendParamsToUrl(Urls.addBonusProduct, {bonusDiscountLineItemUUID: bliUUID});\n\t\tvar bonusProducts = getBonusProducts();\n\t\tif (bonusProducts.bonusproducts[0].product.qty > maxItems) {\n\t\t\tbonusProducts.bonusproducts[0].product.qty = maxItems;\n\t\t}\n\t\t// make the server call\n\t\t$.ajax({\n\t\t\ttype: 'POST',\n\t\t\tdataType: 'json',\n\t\t\tcache: false,\n\t\t\tcontentType: 'application/json',\n\t\t\turl: url,\n\t\t\tdata: JSON.stringify(bonusProducts)\n\t\t})\n\t\t.done(function () {\n\t\t\t// success\n\t\t\tpage.refresh();\n\t\t})\n\t\t.fail(function (xhr, textStatus) {\n\t\t\t// failed\n\t\t\tif (textStatus === 'parsererror') {\n\t\t\t\twindow.alert(Resources.BAD_RESPONSE);\n\t\t\t} else {\n\t\t\t\twindow.alert(Resources.SERVER_CONNECTION_ERROR);\n\t\t\t}\n\t\t})\n\t\t.always(function () {\n\t\t\t$bonusProduct.dialog('close');\n\t\t});\n\t});\n}\n\nvar bonusProductsView = {\n\t/**\n\t * @function\n\t * @description Open the list of bonus products selection dialog\n\t */\n\tshow: function (url) {\n\t\tvar $bonusProduct = $('#bonus-product-dialog');\n\t\t// create the dialog\n\t\tdialog.open({\n\t\t\ttarget: $bonusProduct,\n\t\t\turl: url,\n\t\t\toptions: {\n\t\t\t\twidth: 795,\n\t\t\t\ttitle: Resources.BONUS_PRODUCTS\n\t\t\t},\n\t\t\tcallback: function () {\n\t\t\t\tinitializeGrid();\n\t\t\t\thideSwatches();\n\t\t\t}\n\t\t});\n\t},\n\t/**\n\t * @function\n\t * @description Open bonus product promo prompt dialog\n\t */\n\tloadBonusOption: function () {\n\t\tvar\tself = this,\n\t\t\tbonusDiscountContainer = document.querySelector('.bonus-discount-container');\n\t\tif (!bonusDiscountContainer) { return; }\n\n\t\t// get the html from minicart, then trash it\n\t\tvar bonusDiscountContainerHtml = bonusDiscountContainer.outerHTML;\n\t\tbonusDiscountContainer.parentNode.removeChild(bonusDiscountContainer);\n\n\t\tdialog.open({\n\t\t\thtml: bonusDiscountContainerHtml,\n\t\t\toptions: {\n\t\t\t\twidth: 400,\n\t\t\t\ttitle: Resources.BONUS_PRODUCT,\n\t\t\t\tbuttons: [{\n\t\t\t\t\ttext: Resources.SELECT_BONUS_PRODUCTS,\n\t\t\t\t\tclick: function () {\n\t\t\t\t\t\tvar uuid = $('.bonus-product-promo').data('lineitemid'),\n\t\t\t\t\t\t\turl = util.appendParamsToUrl(Urls.getBonusProducts, {\n\t\t\t\t\t\t\t\tbonusDiscountLineItemUUID: uuid,\n\t\t\t\t\t\t\t\tsource: 'bonus'\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t$(this).dialog('close');\n\t\t\t\t\t\tself.show(url);\n\t\t\t\t\t}\n\t\t\t\t}, {\n\t\t\t\t\ttext: Resources.NO_THANKS,\n\t\t\t\t\tclick: function () {\n\t\t\t\t\t\t$(this).dialog('close');\n\t\t\t\t\t}\n\t\t\t\t}]\n\t\t\t},\n\t\t\tcallback: function () {\n\t\t\t\t// show hide promo details\n\t\t\t\t$('.show-promo-details').on('click', function () {\n\t\t\t\t\t$('.promo-details').toggleClass('visible');\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t}\n};\n\nmodule.exports = bonusProductsView;\n\n},{\"./dialog\":10,\"./page\":20,\"./util\":56}],4:[function(require,module,exports){\n'use strict';\n\nfunction initializeEvents() {\n\tvar quickview = require('./quickview');\n\tvar options = {\n\t\tmouseEnterSelector: '#shop-the-collection .product-image',\n\t\tfocusSelector: '#shop-the-collection .product-image .thumb-link',\n\t\tkeydownSelector: '#shop-the-collection .product-image'\n\t}\n\tquickview.initializeButtons(options);\n}\n\nvar carouselShopTheCollection = {\n\tinit: function () {\n\t\tinitializeEvents();\n\t}\n};\n\nmodule.exports = carouselShopTheCollection;\n},{\"./quickview\":47}],5:[function(require,module,exports){\n'use strict';\n\nfunction initializeEvents() {\n\tvar gtm = require('./gtm');\n\tvar quickview = require('./quickview');\n\tvar options = {\n\t\tmouseEnterSelector: '#you-may-also-like .product-image',\n\t\tfocusSelector: '#you-may-also-like .product-image .thumb-link',\n\t\tkeydownSelector: '#you-may-also-like .product-image'\n\t}\n\n\tvar options_abtest = {\n\t\tmouseEnterSelector: '#you-may-also-like-abtest .product-image',\n\t\tfocusSelector: '#you-may-also-like-abtest .product-image .thumb-link',\n\t\tkeydownSelector: '#you-may-also-like-abtest .product-image'\n\t}\n\n\t// There is a delay here for recommender because it is not always loaded immediately when the page loads, which could\n\t// prevent the button from showing\n\tvar pollCounter = 0;\n\tvar recommenders = $('[id^=\"cq_recomm_slot-\"]');\n\tvar poller = setInterval(function() {\n\t\tfor (var i = 0; i < recommenders.length; i++) {\n\t\t\tif (recommenders[i].children.length > 0) {\n\t\t\t\tpollCounter += 1;\n\t\t\t}\n\t\t}\n\n\t\tif (pollCounter === recommenders.length) {\n\t\t\tclearInterval(poller);\n\t\t\tquickview.initializeButtons(options);\n\t\t\tquickview.initializeButtons(options_abtest);\n\n\t\t\t$('[data-gtmsrc=Einstein]','[data-gtmsrc=\"PDP Entry: Einstein\"]')\n\t\t\t\t.on({\n\t\t\t\t\tclick: gtm.eccViewItemOnClick\n\t\t\t\t});\n\t\t} else {\n\t\t\tpollCounter = 0;\n\t\t}\n\n\t}, 500);\n\n}\n\nvar carouselYouMayAlsoLike = {\n\tinit: function () {\n\t\tinitializeEvents();\n\t}\n};\n\nmodule.exports = carouselYouMayAlsoLike;\n\n},{\"./gtm\":14,\"./quickview\":47}],6:[function(require,module,exports){\n'use strict';\n\nvar page = require('./page'),\n\tutil = require('./util'),\n\tTPromise = require('promise');\n\nvar _currentCategory = '',\n\tMAX_ACTIVE = 6;\n\n/**\n * @private\n * @function\n * @description Verifies the number of elements in the compare container and updates it with sequential classes for ui targeting\n */\nfunction refreshContainer() {\n\tvar $compareContainer = $('.compare-items');\n\tvar $compareItems = $compareContainer.find('.compare-item');\n\tvar numActive = $compareItems.filter('.active').length;\n\n\tif (numActive < 2) {\n\t\t$('#compare-items-button').attr('disabled', 'disabled');\n\t} else {\n\t\t$('#compare-items-button').removeAttr('disabled');\n\t}\n\n\t$compareContainer.toggle(numActive > 0);\n}\n/**\n * @private\n * @function\n * @description Adds an item to the compare container and refreshes it\n */\nfunction addToList(data) {\n\t// get the first compare-item not currently active\n\tvar $item = $('.compare-items .compare-item').not('.active').first(),\n\t\t$productTile = $('#' + data.uuid);\n\n\tif ($item.length === 0) {\n\t\tif ($productTile.length > 0) {\n\t\t\t$productTile.find('.compare-check')[0].checked = false;\n\t\t}\n\t\twindow.alert(Resources.COMPARE_ADD_FAIL);\n\t\treturn;\n\t}\n\n\t// if already added somehow, return\n\tif ($('[data-uuid=\"' + data.uuid + '\"]').length > 0) {\n\t\treturn;\n\t}\n\t// set as active item\n\t$item.addClass('active')\n\t\t.attr('data-uuid', data.uuid)\n\t\t.attr('data-itemid', data.itemid)\n\t\t.data('uuid', data.uuid)\n\t\t.data('itemid', data.itemid)\n\t\t.append($(data.img).clone().addClass('compare-item-image'));\n}\n/**\n * @private\n * @function\n * description Removes an item from the compare container and refreshes it\n */\nfunction removeFromList($item) {\n\tif ($item.length === 0) { return; }\n\t// remove class, data and id from item\n\t$item.removeClass('active')\n\t\t.removeAttr('data-uuid')\n\t\t.removeAttr('data-itemid')\n\t\t.data('uuid', '')\n\t\t.data('itemid', '')\n\t\t// remove the image\n\t\t.find('.compare-item-image').remove();\n}\n\nfunction addProductAjax(args) {\n\tvar promise = new TPromise(function (resolve, reject) {\n\t\t$.ajax({\n\t\t\turl: Urls.compareAdd,\n\t\t\tdata: {\n\t\t\t\tpid: args.itemid,\n\t\t\t\tcategory: _currentCategory\n\t\t\t},\n\t\t\tdataType: 'json'\n\t\t}).done(function (response) {\n\t\t\tif (!response || !response.success) {\n\t\t\t\treject(new Error(Resources.COMPARE_ADD_FAIL));\n\t\t\t} else {\n\t\t\t\tresolve(response);\n\t\t\t}\n\t\t}).fail(function (jqxhr, status, err) {\n\t\t\treject(new Error(err));\n\t\t});\n\t});\n\treturn promise;\n}\n\nfunction removeProductAjax(args) {\n\tvar promise = new TPromise(function (resolve, reject) {\n\t\t$.ajax({\n\t\t\turl: Urls.compareRemove,\n\t\t\tdata: {\n\t\t\t\tpid: args.itemid,\n\t\t\t\tcategory: _currentCategory\n\t\t\t},\n\t\t\tdataType: 'json'\n\t\t}).done(function (response) {\n\t\t\tif (!response || !response.success) {\n\t\t\t\treject(new Error(Resources.COMPARE_REMOVE_FAIL));\n\t\t\t} else {\n\t\t\t\tresolve(response);\n\t\t\t}\n\t\t}).fail(function (jqxhr, status, err) {\n\t\t\treject(new Error(err));\n\t\t});\n\t});\n\treturn promise;\n}\n\nfunction shiftImages() {\n\treturn new TPromise(function (resolve) {\n\t\tvar $items = $('.compare-items .compare-item');\n\t\t$items.each(function (i, item) {\n\t\t\tvar $item = $(item);\n\t\t\t// last item\n\t\t\tif (i === $items.length - 1) {\n\t\t\t\treturn removeFromList($item);\n\t\t\t}\n\t\t\tvar $next = $items.eq(i + 1);\n\t\t\tif ($next.hasClass('active')) {\n\t\t\t\t// remove its own image\n\t\t\t\t$next.find('.compare-item-image').detach().appendTo($item);\n\t\t\t\t$item.addClass('active')\n\t\t\t\t\t.attr('data-uuid', $next.data('uuid'))\n\t\t\t\t\t.attr('data-itemid', $next.data('itemid'))\n\t\t\t\t\t.data('uuid', $next.data('uuid'))\n\t\t\t\t\t.data('itemid', $next.data('itemid'));\n\t\t\t}\n\t\t});\n\t\tresolve();\n\t});\n}\n\n/**\n * @function\n * @description Adds product to the compare table\n */\nfunction addProduct(args) {\n\tvar promise;\n\tvar $items = $('.compare-items .compare-item');\n\tvar $cb = $(args.cb);\n\tvar numActive = $items.filter('.active').length;\n\tif (numActive === MAX_ACTIVE) {\n\t\tif (!window.confirm(Resources.COMPARE_CONFIRMATION)) {\n\t\t\t$cb[0].checked = false;\n\t\t\treturn;\n\t\t}\n\n\t\t// remove product using id\n\t\tvar $firstItem = $items.first();\n\t\tpromise = removeItem($firstItem).then(function () {\n\t\t\treturn shiftImages();\n\t\t});\n\t} else {\n\t\tpromise = TPromise.resolve(0);\n\t}\n\treturn promise.then(function () {\n\t\treturn addProductAjax(args).then(function () {\n\t\t\taddToList(args);\n\t\t\tif ($cb && $cb.length > 0) { $cb[0].checked = true; }\n\t\t\trefreshContainer();\n\t\t});\n\t}).then(null, function () {\n\t\tif ($cb && $cb.length > 0) { $cb[0].checked = false; }\n\t});\n}\n\n/**\n * @function\n * @description Removes product from the compare table\n * @param {object} args - the arguments object should have the following properties: itemid, uuid and cb (checkbox)\n */\nfunction removeProduct(args) {\n\tvar $cb = args.cb ? $(args.cb) : null;\n\treturn removeProductAjax(args).then(function () {\n\t\tvar $item = $('[data-uuid=\"' + args.uuid + '\"]');\n\t\tremoveFromList($item);\n\t\tif ($cb && $cb.length > 0) { $cb[0].checked = false; }\n\t\trefreshContainer();\n\t}, function () {\n\t\tif ($cb && $cb.length > 0) { $cb[0].checked = true; }\n\t});\n}\n\nfunction removeItem($item) {\n\tvar uuid = $item.data('uuid'),\n\t\t$productTile = $('#' + uuid);\n\treturn removeProduct({\n\t\titemid: $item.data('itemid'),\n\t\tuuid: uuid,\n\t\tcb: ($productTile.length === 0) ? null : $productTile.find('.compare-check')\n\t});\n}\n\n/**\n * @private\n * @function\n * @description Initializes the DOM-Object of the compare container\n */\nfunction initializeDom() {\n\tvar $compareContainer = $('.compare-items');\n\t_currentCategory = $compareContainer.data('category') || '';\n\tvar $active = $compareContainer.find('.compare-item').filter('.active');\n\t$active.each(function () {\n\t\tvar $productTile = $('#' + $(this).data('uuid'));\n\t\tif ($productTile.length === 0) {return;}\n\t\t$productTile.find('.compare-check')[0].checked = true;\n\t});\n\t// set container state\n\trefreshContainer();\n}\n\n/**\n * @private\n * @function\n * @description Initializes the events on the compare container\n */\nfunction initializeEvents() {\n\t// add event to buttons to remove products\n\t$('.compare-item').on('click', '.compare-item-remove', function () {\n\t\tremoveItem($(this).closest('.compare-item'));\n\t});\n\n\t// Button to go to compare page\n\t$('#compare-items-button').on('click', function () {\n\t\tpage.redirect(util.appendParamToURL(Urls.compareShow, 'category', _currentCategory));\n\t});\n\n\t// Button to clear all compared items\n\t// rely on refreshContainer to take care of hiding the container\n\t$('#clear-compared-items').on('click', function () {\n\t\t$('.compare-items .active').each(function () {\n\t\t\tremoveItem($(this));\n\t\t});\n\t});\n}\n\nexports.init = function () {\n\tinitializeDom();\n\tinitializeEvents();\n};\n\nexports.addProduct = addProduct;\nexports.removeProduct = removeProduct;\n\n},{\"./page\":20,\"./util\":56,\"promise\":63}],7:[function(require,module,exports){\n'use strict';\n\nvar dialog = require('./dialog');\n\n/**\n * @function cookieprivacy\tUsed to display/control the scrim containing the cookie privacy code\n **/\nmodule.exports = function () {\n\t/**\n\t * If we have not accepted cookies AND we're not on the Privacy Policy page, then show the notification\n\t * NOTE: You will probably want to adjust the Privacy Page test to match your site's specific privacy / cookie page\n\t */\n\tif (SitePreferences.COOKIE_HINT === true && document.cookie.indexOf('dw_cookies_accepted') < 0) {\n\t\t// check for privacy policy page\n\t\tif ($('.privacy-policy').length === 0) {\n\t\t\tdialog.open({\n\t\t\t\turl: Urls.cookieHint,\n\t\t\t\toptions: {\n\t\t\t\t\tcloseOnEscape: false,\n\t\t\t\t\tdialogClass: 'no-close',\n\t\t\t\t\tbuttons: [{\n\t\t\t\t\t\ttext: Resources.I_AGREE,\n\t\t\t\t\t\tclick: function () {\n\t\t\t\t\t\t\t$(this).dialog('close');\n\t\t\t\t\t\t\tenableCookies();\n\t\t\t\t\t\t}\n\t\t\t\t\t}]\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t} else {\n\t\t// Otherwise, we don't need to show the asset, just enable the cookies\n\t\tenableCookies();\n\t}\n\n\tfunction enableCookies() {\n\t\tif (document.cookie.indexOf('dw=1') < 0) {\n\t\t\tdocument.cookie = 'dw=1; path=/';\n\t\t}\n\t\tif (document.cookie.indexOf('dw_cookies_accepted') < 0) {\n\t\t\tdocument.cookie = 'dw_cookies_accepted=1; path=/';\n\t\t}\n\t}\n};\n\n},{\"./dialog\":10}],8:[function(require,module,exports){\n'use strict';\n\nexports.init = function init () {\n\t$('.country-selector .current-country').on('click', function () {\n\t\t$('.country-selector .selector').toggleClass('active');\n\t\t$(this).toggleClass('selector-active');\n\t});\n\t// set currency first before reload\n\t$('.country-selector .selector .locale').on('click', function (e) {\n\t\te.preventDefault();\n\t\tvar url = this.href;\n\t\tvar currency = this.getAttribute('data-currency');\n\t\t$.ajax({\n\t\t\tdataType: 'json',\n\t\t\turl: Urls.setSessionCurrency,\n\t\t\tdata: {\n\t\t\t\tformat: 'ajax',\n\t\t\t\tcurrencyMnemonic: currency\n\t\t\t}\n\t\t})\n\t\t.done(function (response) {\n\t\t\tif (!response.success) {\n\t\t\t\tthrow new Error('Unable to set currency');\n\t\t\t}\n\t\t\twindow.location.href = url;\n\t\t});\n\t});\n};\n\n},{}],9:[function(require,module,exports){\n'use strict';\n/* global CQuotient */\n\nfunction clickThruAfter() {\n\tvar recommenderName = localStorage.getItem('cq.recommenderName');\n\tvar currentProductId = $('[itemprop=\"productID\"]').data('masterid') || '';\n\tif (!recommenderName) {return;}\n\tvar anchors;\n\tif (localStorage.getItem('cq.anchors')) {\n\t\tanchors = localStorage.getItem('cq.anchors');\n\t\tlocalStorage.removeItem('cq.anchors');\n\t}\n\tlocalStorage.removeItem('cq.recommenderName');\n\tif (window.CQuotient) {\n\t\tCQuotient.activities.push({\n\t\t\tactivityType: 'clickReco',\n\t\t\tparameters: {\n\t\t\t\tcookieId: CQuotient.getCQCookieId(),\n\t\t\t\tuserId: CQuotient.getCQUserId(),\n\t\t\t\trecommenderName: recommenderName,\n\t\t\t\tanchors: anchors || '',\n\t\t\t\tproducts: {\n\t\t\t\t\tid: currentProductId\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n}\n\nexports.init = function () {\n\t// set cookie before click through from product tile\n\t$('body').on('click', '.product-tile[data-recommendername] a', function () {\n\t\t// if currently on a product page, send its productId as the anchor\n\t\tif (window.pageContext.type === 'product') {\n\t\t\tlocalStorage.setItem('cq.anchors', $('[itemprop=\"productID\"]').data('masterid') || '');\n\t\t}\n\t\tvar recommenderName = $(this).parents('.product-tile').data('recommendername');\n\t\tlocalStorage.setItem('cq.recommenderName', recommenderName);\n\t});\n\n\tclickThruAfter();\n};\n\n},{}],10:[function(require,module,exports){\n'use strict';\n\nvar ajax = require('./ajax'),\n\tutil = require('./util'),\n\t_ = require('lodash'),\n\timagesLoaded = require('imagesloaded');\n\nvar dialog = {\n\t/**\n\t * @function\n\t * @description Appends a dialog to a given container (target)\n\t * @param {Object} params params.target can be an id selector or an jquery object\n\t */\n\tcreate: function (params) {\n\t\tvar $target, id;\n\n\t\tif (_.isString(params.target)) {\n\t\t\tif (params.target.charAt(0) === '#') {\n\t\t\t\t$target = $(params.target);\n\t\t\t} else {\n\t\t\t\t$target = $('#' + params.target);\n\t\t\t}\n\t\t} else if (params.target instanceof jQuery) {\n\t\t\t$target = params.target;\n\t\t} else {\n\t\t\t$target = $('#dialog-container');\n\t\t}\n\n\t\t// if no element found, create one\n\t\tif ($target.length === 0) {\n\t\t\tif ($target.selector && $target.selector.charAt(0) === '#') {\n\t\t\t\tid = $target.selector.substr(1);\n\t\t\t\t$target = $('
        ').attr('id', id).addClass('dialog-content').appendTo('body');\n\t\t\t}\n\t\t\t// Added due to changes in jQuery 3.0\n\t\t\tif (!$target.selector) {\n\t\t\t\tid = 'dialog-container';\n\t\t\t\t$target = $('
        ').attr('id', id).addClass('dialog-content').appendTo('body');\n\t\t\t}\n\t\t}\n\n\t\t// create the dialog\n\t\tthis.$container = $target;\n\t\tthis.$container.dialog(_.merge({}, this.settings, params.options || {}));\n\t},\n\t/**\n\t * @function\n\t * @description Opens a dialog using the given url (params.url) or html (params.html)\n\t * @param {Object} params\n\t * @param {Object} params.url should contain the url\n\t * @param {String} params.html contains the html of the dialog content\n\t */\n\topen: function (params) {\n\t\t// close any open dialog\n\t\tthis.close();\n\t\tthis.create(params);\n\t\tthis.replace(params);\n\t},\n\t/**\n\t * @description populate the dialog with html content, then open it\n\t **/\n\topenWithContent: function (params) {\n\t\tvar content, position, callback;\n\n\t\tif (!this.$container) { return; }\n\t\tcontent = params.content || params.html;\n\t\tif (!content) { return; }\n\t\tthis.$container.empty().html(content);\n\t\tif (!this.$container.dialog('isOpen')) {\n\t\t\tthis.$container.dialog('open');\n\t\t}\n\n\t\tif (params.options) {\n\t\t\tposition = params.options.position;\n\t\t}\n\t\tif (!position) {\n\t\t\tposition = this.settings.position;\n\t\t}\n\t\timagesLoaded(this.$container).on('done', function () {\n\t\t\tthis.$container.dialog('option', 'position', position);\n\t\t\t// this.$container.dialog().css(\"top\",\"20px\");\n\t\t\t// window.scrollTop = 0;\n\t\t}.bind(this));\n\n\t\tcallback = (typeof params.callback === 'function') ? params.callback : function () {};\n\t\tcallback();\n\t},\n\t/**\n\t * @description Replace the content of current dialog\n\t * @param {object} params\n\t * @param {string} params.url - If the url property is provided, an ajax call is performed to get the content to replace\n\t * @param {string} params.html - If no url property is provided, use html provided to replace\n\t */\n\treplace: function (params) {\n\t\tif (!this.$container) {\n\t\t\treturn;\n\t\t}\n\t\tif (params.url) {\n\t\t\tparams.url = util.appendParamToURL(params.url, 'format', 'ajax');\n\t\t\tajax.load({\n\t\t\t\turl: params.url,\n\t\t\t\tdata: params.data,\n\t\t\t\tcallback: function (response) {\n\t\t\t\t\tparams.content = response;\n\t\t\t\t\tthis.openWithContent(params);\n\t\t\t\t}.bind(this)\n\t\t\t});\n\t\t} else if (params.html) {\n\t\t\tthis.openWithContent(params);\n\t\t}\n\t},\n\t/**\n\t * @function\n\t * @description Closes the dialog\n\t */\n\tclose: function () {\n\t\tif (!this.$container) {\n\t\t\treturn;\n\t\t}\n\t\tthis.$container.dialog('close');\n\t},\n\t/**\n\t * @function\n\t * @description Submits the dialog form with the given action\n\t * @param {String} The action which will be triggered upon form submit\n\t */\n\tsubmit: function (action) {\n\t\tvar $form = this.$container.find('form:first');\n\t\t// set the action\n\t\t$('').attr({\n\t\t\tname: action,\n\t\t\ttype: 'hidden'\n\t\t}).appendTo($form);\n\t\t// serialize the form and get the post url\n\t\tvar data = $form.serialize();\n\t\tvar url = $form.attr('action');\n\t\t// make sure the server knows this is an ajax request\n\t\tif (data.indexOf('ajax') === -1) {\n\t\t\tdata += '&format=ajax';\n\t\t}\n\t\t// post the data and replace current content with response content\n\t\t$.ajax({\n\t\t\ttype: 'POST',\n\t\t\turl: url,\n\t\t\tdata: data,\n\t\t\tdataType: 'html',\n\t\t\tsuccess: function (html) {\n\t\t\t\tthis.$container.html(html);\n\t\t\t}.bind(this),\n\t\t\tfailure: function () {\n\t\t\t\twindow.alert(Resources.SERVER_ERROR);\n\t\t\t}\n\t\t});\n\t},\n\texists: function () {\n\t\treturn this.$container && (this.$container.length > 0);\n\t},\n\tisActive: function () {\n\t\treturn this.exists() && (this.$container.children.length > 0);\n\t},\n\tsettings: {\n\t\tautoOpen: false,\n\t\theight: 'auto',\n\t\tmodal: true,\n\t\toverlay: {\n\t\t\topacity: 0.5,\n\t\t\tbackground: 'black'\n\t\t},\n\t\tresizable: false,\n\t\ttitle: '',\n\t\twidth: '800',\n\t\tclose: function () {\n\t\t\t$(this).dialog('close');\n\t\t},\n\t\tposition: {\n\t\t\tmy: 'center',\n\t\t\tat: 'center',\n\t\t\tof: window,\n\t\t\tcollision: 'flipfit'\n\t\t}\n\t}\n};\n\nmodule.exports = dialog;\n\n},{\"./ajax\":1,\"./util\":56,\"imagesloaded\":61,\"lodash\":62}],11:[function(require,module,exports){\n'use strict';\n\nvar ajax = require('./ajax'),\n\tutil = require('./util');\n/**\n * @function\n * @description Load details to a given gift certificate\n * @param {String} id The ID of the gift certificate\n * @param {Function} callback A function to called\n */\nexports.checkBalance = function (id, callback) {\n\t// load gift certificate details\n\tvar url = util.appendParamToURL(Urls.giftCardCheckBalance, 'giftCertificateID', id);\n\n\tajax.getJson({\n\t\turl: url,\n\t\tcallback: callback\n\t});\n};\n\n},{\"./ajax\":1,\"./util\":56}],12:[function(require,module,exports){\n'use strict';\n\nvar ajax = require('./ajax'),\n\tminicart = require('./minicart'),\n\tutil = require('./util');\n\nvar setAddToCartHandler = function (e) {\n\te.preventDefault();\n\tvar form = $(this).closest('form');\n\n\tvar options = {\n\t\turl: util.ajaxUrl(form.attr('action')),\n\t\tmethod: 'POST',\n\t\tcache: false,\n\t\tdata: form.serialize()\n\t};\n\t$.ajax(options).done(function (response) {\n\t\tif (response.success) {\n\t\t\tajax.load({\n\t\t\t\turl: Urls.minicartGC,\n\t\t\t\tdata: {lineItemId: response.result.lineItemId},\n\t\t\t\tcallback: function (response) {\n\t\t\t\t\tminicart.show(response);\n\t\t\t\t\tform.find('input,textarea').val('');\n\t\t\t\t}\n\t\t\t});\n\t\t} else {\n\t\t\tform.find('span.error').hide();\n\t\t\tfor (var id in response.errors.FormErrors) {\n\t\t\t\tvar $errorEl = $('#' + id).addClass('error').removeClass('valid').next('.error');\n\t\t\t\tif (!$errorEl || $errorEl.length === 0) {\n\t\t\t\t\t$errorEl = $('');\n\t\t\t\t\t$('#' + id).after($errorEl);\n\t\t\t\t}\n\t\t\t\t$errorEl.text(response.errors.FormErrors[id].replace(/\\\\'/g, '\\'')).show();\n\t\t\t}\n\t\t}\n\t}).fail(function (xhr, textStatus) {\n\t\t// failed\n\t\tif (textStatus === 'parsererror') {\n\t\t\twindow.alert(Resources.BAD_RESPONSE);\n\t\t} else {\n\t\t\twindow.alert(Resources.SERVER_CONNECTION_ERROR);\n\t\t}\n\t});\n};\n\nexports.init = function () {\n\t$('#AddToBasketButton').on('click', setAddToCartHandler);\n};\n\n},{\"./ajax\":1,\"./minicart\":18,\"./util\":56}],13:[function(require,module,exports){\n'use strict';\n\nexports.init = function () {\n\t$('select[id*=\"_giftregistry_search_advanced_eventAddress_country\"]').on('change', function () {\n\t\t$('select[id*=\"_giftregistry_search_advanced_eventAddress_states_state\"]').find('option').prop(\"selected\", false);\n\t\tif($(this).find('option:selected').val()!=='US'){\t\t\t\n\t\t\t$('select[id*=\"_giftregistry_search_advanced_eventAddress_states_state\"]').find('option[value=\"OTHER\"]').prop(\"selected\", true);\n\t\t\t$('select[id*=\"_giftregistry_search_advanced_eventAddress_states_state\"]').find('option[value!=\"OTHER\"]').css(\"display\",\"none\");\n\t\t}else{\n\t\t\t$('select[id*=\"_giftregistry_search_advanced_eventAddress_states_state\"]').find('option[value=\"\"]').prop(\"selected\", true);\n\t\t\t$('select[id*=\"_giftregistry_search_advanced_eventAddress_states_state\"]').find('option').css(\"display\",\"block\");\n\t\t}\n\t});\n\t$('select[id*=\"_giftregistry_event_eventaddress_country\"]').on('change', function () {\n\t\t$('select[id*=\"_giftregistry_event_eventaddress_states_state\"]').find('option').prop(\"selected\", false);\n\t\tif($(this).find('option:selected').val()!=='US'){\t\t\t\n\t\t\t$('select[id*=\"_giftregistry_event_eventaddress_states_state\"]').find('option[value=\"OTHER\"]').prop(\"selected\", true);\n\t\t\t$('select[id*=\"_giftregistry_event_eventaddress_states_state\"]').find('option[value!=\"OTHER\"]').css(\"display\",\"none\");\n\t\t}else{\n\t\t\t$('select[id*=\"_giftregistry_event_eventaddress_states_state\"]').find('option[value=\"\"]').prop(\"selected\", true);\n\t\t\t$('select[id*=\"_giftregistry_event_eventaddress_states_state\"]').find('option').css(\"display\",\"block\");\n\t\t}\n\t});\n\t$('.findregistry').on('click', function (e) {\n\t\te.preventDefault();\n\t\t$( this ).addClass( \"hide\");\n\t\t$(\".content\").removeClass(\"hide\");\n\t});\n\n};\n\n},{}],14:[function(require,module,exports){\n'use strict';\n\nfunction eccViewItemOnClick (e) {\n e.preventDefault();\n\ttry {\n\t\tvar productID = $(this).data('productid');\n\t\tvar itemListProperty = $(this).data('gtmsrc');\n\t\tif (itemListProperty === 'PLP') {\n\t\t\titemListProperty = getListNameFromExisistingTag(productID);\n\t\t}\n\n\t\tvar gtmUrl = $(this).data('gtmurl') + '?productlistattribute=' + itemListProperty + '&productID=' + productID;\n\t\tvar fwdUrl = $(this).attr('href');\n\t\t$.ajax({\n\t\t\turl: gtmUrl,\n\t\t\ttype: 'get',\n\t\t\tsuccess: function (response) {\n\t\t\t\ttry {\n\t\t\t\t\tif (response.success && response.ecc_select_item !== null) {\n\t\t\t\t\t\tdataLayer.push(response.ecc_select_item);\n\t\t\t\t\t}\n\t\t\t\t} catch {\n\t\t\t\t\t// Will be directed via the done function below\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t\t.done(function (e) {\n\t\t\twindow.location.href = fwdUrl;\n\t\t});\n\t} catch {\n\t\twindow.location.href = $(this).attr('href');\n\t}\n}\n\nfunction getListNameFromExisistingTag (productID) {\n\tvar dataLayerItemListArray = dataLayer.filter((arrayItem) => arrayItem.event === \"ecc_view_item_list\").map((x) => x.ecommerce.items);\n\tvar dataLayerItemListArrayCombined = [...new Set(dataLayerItemListArray.flat(Infinity).map(JSON.stringify))].map(JSON.parse);\n\treturn dataLayerItemListArrayCombined.filter((x) => x.item_id === String(productID))[0][\"item_list_name\"];\n}\n\nexports.eccViewItemOnClick = eccViewItemOnClick;\nexports.getListNameFromExisistingTag = getListNameFromExisistingTag;\n\n},{}],15:[function(require,module,exports){\n'use strict';\r\n\r\nvar util = require('./util');\r\n\r\nmodule.exports = {\r\n\tinit: function () {\r\n\t\tvar $carousel = $('.carousel-mc');\r\n\t\tif (!$carousel || $carousel.length === 0 || $carousel.children().length === 0) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\t// $carousel.jcarousel();\r\n\r\n\t\t$carousel.on('jcarousel:reload jcarousel:create', function () {\r\n var carousel = $(this),\r\n width = carousel.innerWidth();\r\n width = width / (document.documentElement.clientWidth < 768 ? 2 : 3);\r\n carousel.jcarousel('items').css('width', Math.floor(width) + 'px');\r\n }).jcarousel({\r\n wrap: 'circular',\r\n scroll: 1\r\n });\r\n\r\n\t\t$('.jcarousel-mc-prev')\r\n\t\t\t.on('jcarouselcontrol:active', function () {\r\n\t\t\t\t$(this).removeClass('inactive');\r\n\t\t\t})\r\n\t\t\t.on('jcarouselcontrol:inactive', function () {\r\n\t\t\t\t$(this).addClass('inactive');\r\n\t\t\t})\r\n\t\t\t.jcarouselControl({\r\n\t\t\t\ttarget: '-=1' \r\n\t\t\t});\r\n\r\n\t\t$('.jcarousel-mc-next')\r\n\t\t\t.on('jcarouselcontrol:active', function () {\r\n\t\t\t\t$(this).removeClass('inactive');\r\n\t\t\t})\r\n\t\t\t.on('jcarouselcontrol:inactive', function () {\r\n\t\t\t\t$(this).addClass('inactive');\r\n\t\t\t})\r\n\t\t\t.jcarouselControl({\r\n\t\t\t\ttarget: '+=1'\r\n\t\t\t});\r\n\r\n\t\t$('.jcarousel-mc-pagination')\r\n\t .on('jcarouselpagination:active', 'a', function() {\r\n\t $(this).addClass('active');\r\n\t })\r\n\t .on('jcarouselpagination:inactive', 'a', function() {\r\n\t $(this).removeClass('active');\r\n\t })\r\n\t .on('click', function(e) {\r\n\t e.preventDefault();\r\n\t })\r\n\t .jcarouselPagination({\r\n\t perPage: 2,\r\n\t item: function(page) {\r\n\t return '' + page + '';\r\n\t }\r\n\t });\r\n\t\tif ($('.jcarousel-mc-pagination a').length == 1 ){\r\n\t\t\t$('.jcarousel-mc-pagination').css (\"display\",\"none\");\r\n\t\t}\r\n\t\tif(util.isMobile()){\r\n\t\t\t$carousel.touchwipe({\r\n\t\t\t\twipeLeft: function() {\r\n\t\t\t\t\t$carousel.jcarousel('next');\r\n\t\t\t\t},\r\n\t\t\t\twipeRight: function() {\r\n\t\t\t\t\t$carousel.jcarousel('prev');\r\n\t\t\t\t},\r\n\t\t\t\tmin_move_x: 20,\r\n\t\t\t\tmin_move_y: 20,\r\n\t\t\t\tpreventDefaultEvents: false\r\n\t\t\t});\r\n\t\t}\r\n\t},\r\n\tdoJCarousel: doJCarousel\r\n};\r\n\r\n\r\n/* Slide Common */\r\n(function($) {\r\n $(function() {\r\n\r\n\t\tdoJCarousel();\r\n \r\n\t\tif($('[id^=\"cq_recomm_slot-\"]').length > 0) {\r\n\r\n\t\t\tconst cqNodes = $('[id^=\"cq_recomm_slot-\"]');\r\n\r\n\t\t\tfor(let i = 0; i < cqNodes.length; i++) {\r\n\r\n\t\t\t\t// Select the node that will be observed for mutations\r\n\t\t\t\tconst targetNode = $('[id^=\"cq_recomm_slot-\"]')[i];\r\n\r\n\t\t\t\t// Options for the observer (which mutations to observe)\r\n\t\t\t\tconst config = { attributes: false, childList: true, subtree: true };\r\n\r\n\t\t\t\t// Callback function to execute when mutations are observed\r\n\t\t\t\tconst callback = function(mutationsList, observer) {\r\n\t\t\t\t\t// Use traditional 'for loops' for IE 11\r\n\t\t\t\t\tfor(let mutation of mutationsList) {\r\n\t\t\t\t\t\tif (mutation.type === 'childList' || mutation.type === 'subtree') {\r\n\t\t\t\t\t\t\t//console.log('callback');\r\n\t\t\t\t\t\t\tdoJCarousel();\r\n\t\t\t\t\t\t\tobserver.disconnect();\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t};\r\n\r\n\t\t\t\t// Create an observer instance linked to the callback function\r\n\t\t\t\tconst observer = new MutationObserver(callback);\r\n\r\n\t\t\t\t// Start observing the target node for configured mutations\r\n\t\t\t\tobserver.observe(targetNode, config);\r\n\r\n\t\t\t}\r\n\r\n\t\t}\r\n\r\n /* Slide About Us Page */\r\n $('.meet-the-team_grid-mobile .jcarousel-pagination')\r\n .on('jcarouselpagination:active', 'a', function() {\r\n $(this).addClass('active');\r\n })\r\n .on('jcarouselpagination:inactive', 'a', function() {\r\n $(this).removeClass('active');\r\n })\r\n .on('click', function(e) {\r\n e.preventDefault();\r\n })\r\n .jcarouselPagination({\r\n perPage: 2,\r\n item: function(page) {\r\n return '' + page + '';\r\n }\r\n });\r\n });\r\n})(jQuery);\r\n\r\nfunction doJCarousel(){\r\n var jcarousel = $('.jcarousel').not('.jcarousel-success');\r\n jcarousel\r\n .on('jcarousel:reload jcarousel:create', function () {\r\n var $this = $(this),\r\n width = $this.innerWidth(),\r\n vp = document.documentElement.clientWidth,\r\n items = 1;\r\n\r\n if ($(window).width() > 767 && $this.hasClass('product-thumbnails')) {\r\n \t// Do nothing so the vertical thumbnails stay vertical.\r\n }else{\r\n\t items = $this.data('items') || items;\r\n\t if (vp <= 1024) { // tablet\r\n\t \titems = $this.data('items-sm') || items;\r\n\t \tif (vp < 768) items = $this.data('items-xs') || items; // mobile\r\n\t }\r\n\t var padding = parseInt($this.find('li:first').css('margin-left')) + parseInt($this.find('li:first').css('margin-right'));\r\n\t var newWidth = parseInt((width / items) - padding);\r\n\t \r\n\t $this.addClass('jcarousel-success')\r\n\t \t.jcarousel('items').css('width', newWidth + 'px');\r\n }\r\n })\r\n .jcarousel({\r\n wrap: 'circular'\r\n });\r\n\r\n $('.jcarousel-control-prev')\r\n .jcarouselControl({\r\n target: '-=1'\r\n });\r\n\r\n $('.jcarousel-control-next')\r\n .jcarouselControl({\r\n target: '+=1'\r\n });\r\n\r\n $('.jcarousel-pagination')\r\n .on('jcarouselpagination:active', 'a', function() {\r\n $(this).addClass('active');\r\n })\r\n .on('jcarouselpagination:inactive', 'a', function() {\r\n $(this).removeClass('active');\r\n })\r\n .on('click', function(e) {\r\n e.preventDefault();\r\n })\r\n .jcarouselPagination({\r\n perPage: 1,\r\n item: function(page) {\r\n return '' + page + '';\r\n }\r\n });\r\n}\n},{\"./util\":56}],16:[function(require,module,exports){\n'use strict';\n// jQuery extensions\n\nmodule.exports = function () {\n\t// params\n\t// toggleClass - required\n\t// triggerSelector - optional. the selector for the element that triggers the event handler. defaults to the child elements of the list.\n\t// eventName - optional. defaults to 'click'\n\t$.fn.toggledList = function (options) {\n\t\tif (!options.toggleClass) { return this; }\n\t\tvar list = this;\n\t\treturn list.on(options.eventName || 'click', options.triggerSelector || list.children(), function (e) {\n\t\t\te.preventDefault();\n\t\t\tvar classTarget = options.triggerSelector ? $(this).parent() : $(this);\n\t\t\tclassTarget.toggleClass(options.toggleClass);\n\t\t\t// execute callback if exists\n\t\t\tif (options.callback) {options.callback();}\n\t\t});\n\t};\n\n\t$.fn.syncHeight = function () {\n\t\tvar arr = $.makeArray(this);\n\t\tarr.sort(function (a, b) {\n\t\t\treturn $(a).height() - $(b).height();\n\t\t});\n\t\treturn this.height($(arr[arr.length - 1]).height());\n\t};\n};\n\n},{}],17:[function(require,module,exports){\n'use strict';\n\n/**\n * light gallery all in one\n */\n\nvar util = require('./util'),\n\tzoomMediaQuery = matchMedia('(max-width: 1280px)'),\n\tthumbMediaQuery = matchMedia('(max-width: 767px)');\n\nmodule.exports = {\n\tinit: function () {\n\t\tvar $el = $('.pt_product-details .product-thumbnails ul, .quickview-dialog .product-thumbnails ul'),\n\t\t\tthumbSize = 100,\n\t\t\tthumbMargin = 4,\n\t\t\tanimateThumb = true;\n\t\tif (!$el || $el.length === 0 || $el.children().length === 0) {\n\t\t\treturn;\n\t\t}\n\t\tif (zoomMediaQuery.matches) {\n\t\t\tthumbSize = 57;\n\t\t\tthumbMargin = 2;\n\t\t}\n\t\tif (thumbMediaQuery.matches) {\n\t\t\tthumbSize = 8;\n\t\t\tthumbMargin = 10;\n\t\t\tanimateThumb= false;\n\t\t}\n\t\t\n\t\t\n\t\t$el.lightGallery({\n\t\t\ttriggerBy : \".zoom-trigger\", \n\t\t\tinitSelector: \".selected\",\n\t\t\tdownload: false,\n\t\t\tcounter: false,\n\t\t\thideBars: true,\n\t\t\ttoggleThumb: false,\n\t\t\tkeyPress: true,\n\t\t\tthumbWidth: thumbSize,\n\t\t\tthumbContHeight: thumbSize,\n\t\t\tthumbMargin: thumbMargin,\n\t\t\tanimateThumb: animateThumb,\n\t\t\tenabeThumbNav: true,\n\t\t\tgetCaptionFromTitleOrAlt: false,\n\t\t\taddClass: \"lg-focus-now\",\n\t\t\tappendSubHtmlTo: ''\n\t\t});\n\t\t\n\t\t$(document).on('onAfterOpen.lg', $el, function(event){\n\t\t\t$('.lg-outer')[$el.data('lightGallery').$items.length <= 5 ? 'addClass' : 'removeClass']('lg-hide-thumb-nav');\n\t\t\t$('.lg-focus-now').attr(\"tabindex\",\"0\");\n\t\t\t$('.lg-focus-now div').attr(\"tabindex\",\"0\");\n\t\t\t$('.lg-focus-now span').attr(\"tabindex\",\"0\");\n\t\t\t$('.lg-focus-now').focus();\n\t\t});\n\t}\n};\n\n},{\"./util\":56}],18:[function(require,module,exports){\n'use strict';\n\nvar util = require('./util'),\n\tbonusProductsView = require('./bonus-products-view');\n\nvar timer = {\n\tid: null,\n\tclear: function () {\n\t\tif (this.id) {\n\t\t\twindow.clearTimeout(this.id);\n\t\t\tdelete this.id;\n\t\t}\n\t},\n\tstart: function (duration, callback) {\n\t\tthis.id = setTimeout(callback, duration);\n\t}\n};\n\nvar eccTimer = {\n\tid: null,\n\tclear: function () {\n\t\tif (this.id) {\n\t\t\twindow.clearTimeout(this.id);\n\t\t\tdelete this.id;\n\t\t}\n\t},\n\tstart: function (duration, callback) {\n\t\tthis.id = setTimeout(callback, duration);\n\t}\n};\n\nvar minicart = {\n\tinit: function () {\n\t\tthis.$el = $('#mini-cart');\n\t\t\n\t\tthis.$el.find('.mini-cart-link-checkout').on('click', function (e) {\n\t\t\te.preventDefault();\t\n\t\t\tlocalStorage.removeItem(\"objReloadShipments\");\n\t\t\twindow.location = $(this).attr('href');\n\t\t});\t\t\n\t\tthis.$content = this.$el.find('.mini-cart-content');\n\n\t\t$('.mini-cart-product').eq(0).find('.mini-cart-toggle').addClass('fa-caret-down');\n\t\t$('.mini-cart-product').not(':first').addClass('collapsed')\n\t\t\t.find('.mini-cart-toggle').addClass('fa-caret-right');\n\n\t\t$('.mini-cart-toggle').on('click', function () {\n\t\t\t$(this).toggleClass('fa-caret-down fa-caret-right');\n\t\t\t$(this).closest('.mini-cart-product').toggleClass('collapsed');\n\t\t});\n\n\t\tthis.$el.find('.mini-cart-close').on('click', function () {\n\t\t\tthis.$content.slideUp();\n\t\t}.bind(this));\n\n\t\t// events\n\t\tif(('ontouchstart' in window)\n\t\t \t|| (navigator.MaxTouchPoints > 0)\n\t\t \t|| (navigator.msMaxTouchPoints > 0)) { // touch device\n\t\t\tthis.$el.find('.mini-cart-total').on('click', function(e){\n\t\t\t\tif( $(window).innerWidth() > 767) {\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\tthis.$content.slideToggle();\n\t\t\t\t}\n\t\t\t}.bind(this));\n\t\t} else {\n\t\t\tthis.$el.find('#miniCartLink').on('mouseenter', function() {\n\t\t\t\teccTimer.clear();\n\t\t\t\teccTimer.start(2000, function() {\n\t\t\t\t\tif ($('#mini-cart .mini-cart-content').is(':visible')) {\n\t\t\t\t\t\tvar miniCartTag = $('#minicartViewDataLayerPush').data('minicart-dl-push');\n\t\t\t\t\t\tdataLayer.push(miniCartTag);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}.bind(this));\n\n\t\t\tthis.$el.find('.mini-cart-total').on('mouseenter', function () {\n\t\t\t\tif (this.$content.not(':visible')) {\n\t\t\t\t\tthis.slide();\n\t\t\t\t}\n\t\t\t}.bind(this));\n\t\t\t\n\t\t\tthis.$content.on('mouseenter', function () {\n\t\t\t\ttimer.clear();\n\t\t\t}).on('mouseleave', function () {\n\t\t\t\ttimer.clear();\n\t\t\t\ttimer.start(30, this.close.bind(this));\n\t\t\t}.bind(this));\n\t\t}\n\t},\n\t/**\n\t * @function\n\t * @description Shows the given content in the mini cart\n\t * @param {String} A HTML string with the content which will be shown\n\t */\n\tshow: function (html) {\n\t\tvar $quickViewDialog = $('#QuickViewDialog').parent('.ui-dialog');\n\n\t\tthis.$el.html(html);\n\t\tif ($quickViewDialog.length === 0) {\n\t\t\tutil.scrollBrowser(0);\n\t\t}\n\t\tthis.init();\n\t\tthis.slide();\n\t\tbonusProductsView.loadBonusOption();\n\t},\n\t/**\n\t * @function\n\t * @description Slides down and show the contents of the mini cart\n\t */\n\tslide: function () {\n\t\tvar $quickViewDialog = $('#QuickViewDialog').parent('.ui-dialog');\n\n\t\ttimer.clear();\n\t\t// show the item\n\t\tthis.$content.slideDown(\n\t\t\t{\n\t\t\t\tduration: 'slow', \n\t\t\t\tstart: function(){\n\t\t\t\t\t$(this).addClass('active');\n\n\t\t\t\t\tif ($quickViewDialog.length !== 0) {\n\t\t\t\t\t\t$quickViewDialog.css('z-index', 100);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tcomplete: function(){\n\t\t\t\t\t$(this).addClass('opened');\n\t\t\t\t}\n\t\t\t});\n\t\t// after a time out automatically close it\n\t\ttimer.start(2500, this.close.bind(this));\n\t},\n\t/**\n\t * @function\n\t * @description Closes the mini cart with given delay\n\t * @param {Number} delay The delay in milliseconds\n\t */\n\tclose: function (delay) {\n\t\tvar $quickViewDialog = $('#QuickViewDialog').parent('.ui-dialog');\n\n\t\ttimer.clear();\n\t\tthis.$content.slideUp(\n\t\t\t{\n\t\t\t\tduration: delay, \n\t\t\t\tstart: function(){\n\t\t\t\t\t$(this).removeClass('opened');\n\t\t\t\t},\n\t\t\t\tcomplete: function(){\n\t\t\t\t\t$(this).removeClass('active');\n\n\t\t\t\t\tif ($quickViewDialog.length !== 0) {\n\t\t\t\t\t\t$quickViewDialog.css('z-index', 101);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t}\n};\n\nmodule.exports = minicart;\n\n},{\"./bonus-products-view\":3,\"./util\":56}],19:[function(require,module,exports){\n'use strict';\n\nvar address = require('./pages/checkout/address'),\n\tformPrepare = require('./pages/checkout/formPrepare'),\n\tajax = require('./ajax'),\n\tdialog = require('./dialog'),\n\tutil = require('./util');\n\n\n\n/**\n * @function\n * @description capture add edit adddress form events\n */\nfunction addEditAddress() {\n\tvar $addressForm = $('form[name$=\"multishipping_editAddress\"]'),\n\t\t$addressDropdown = $addressForm.find('select[name$=_addressList]'),\n\t\t$addressList = $addressForm.find('.address-list'),\n\t\tadd = true,\n\t\tselectedAddressUUID = $('.select-address').val();\n\t\n\tif($addressDropdown.find('option').length === 1){\n\t\t$addressDropdown.parent().siblings('label').hide();\n\t\t$addressDropdown.hide();\t\t\n\t}else{\n\t\t$addressDropdown.parent().siblings('label').show();\n\t\t$addressDropdown.show();\n\t\t\n\t}\n\t\n\t$addressDropdown.on('change', function (e) {\n\t\te.preventDefault();\n\t\tvar selectedAddress = $addressList.find('select').val();\n\t\tif (selectedAddress !== 'newAddress') {\n\t\t\tselectedAddress = $.grep($addressList.data('addresses'), function (add) {\n\t\t\t\treturn add.UUID === selectedAddress;\n\t\t\t})[0];\n\t\t\tadd = false;\n\t\t\t// proceed to fill the form with the selected address\n\t\t\tutil.fillAddressFields(selectedAddress, $addressForm);\n\t\t} else {\n\t\t\tadd = true;\n\t\t\t//reset the form if the value of the option is not a UUID\n\t\t\t$addressForm.find('.input-text, .input-select').val('');\n\t\t}\n\t});\n\t\n\tvar getBtnSubmit;\n\t$(\"button\").click(function () {\n\t\tgetBtnSubmit = $(this).attr(\"name\");\t\n\t});\n\t\n\t$('
        ').attr('id', 'multiShipmentQasDialog').appendTo(document.body);\n\tvar params = {\n\t\t\ttarget : $('#multiShipmentQasDialog'),\n\t\t\tcallback : function(){}\n\t}\n\tdialog.create(params);\n\t\n\t$addressForm.on('submit', function (e) {\n\t\te.preventDefault();\t\t\n\t\tif(getBtnSubmit=='dwfrm_multishipping_editAddress_cancel'){\n\t\t\twindow.location = $('#continueMultiShippingStart').val();\n\t\t}\t\n\t\tvar validateForm = $addressForm.validate();\n\t\tif(validateForm.errorList.length>0){return;}\n\t\t\n\t\tvar submitAddressFn = function (jsonResponse) {\n\t\t\tif (!jsonResponse.success) {\n\t\t\t\t// @TODO: figure out a way to handle error on the form\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvar address = jsonResponse.address;\t\t\t\n\t\t\tvar\t$shippingAddress = $('.shippingaddress'),\n\t\t\t\t$select = $shippingAddress.find('.select-address'),\n\t\t\t\t$selected = $select.find('option:selected'),\n\t\t\t\tnewOption = '';\n\t\t\t\t\n\t\t\tif (add) {\n\t\t\t\t$('.shippingaddress select').removeClass('no-option').append(newOption);\n\t\t\t\t$('.no-address').hide();\t\t\n\t\t\t} else {\n\t\t\t\t$('.shippingaddress select').find('option[value=\"' + address.UUID + '\"]').html(newOption);\t\t\t\t\n\t\t\t}\n\t\t\t// if there's no previously selected option, select it\n\t\t\tif ($selected.length === 0 || $selected.val() === '') {\n\t\t\t\t$select.find('option[value=\"' + address.UUID + '\"]').prop('selected', 'selected').trigger('change');\n\t\t\t}\n\t\t\t\n\t\t\tif(localStorage.getItem(\"objReloadShipments\")!==null && localStorage.getItem(\"objReloadShipments\")!=='undefined'){\n\t\t\t\tvar getStoreShipments = JSON.parse(localStorage.getItem(\"objReloadShipments\"));\t\n\t\t\t\tvar productIDofShippingAddress = $('#currentOptiondynamicKey').val();\n\t\t\t\tvar obj = {};\n\t\t\t\tobj[productIDofShippingAddress] = address.UUID;\t\t\t\t\n\t\t\t\tobj = $.extend( {},getStoreShipments,obj);\n\t\t\t\ttry {\n\t\t\t\t\tlocalStorage.removeItem(\"objReloadShipments\");\n\t\t\t\t\tlocalStorage.setItem(\"objReloadShipments\",JSON.stringify(obj));\t\n\t\t\t\t} catch(e) {}\n\t\t\t}\n\n\t\t\twindow.location = $('#continueMultiShippingStart').val();\n\t\t}\n\t\t\n\t\tfunction bindAddressSuggestion(){\n\t\t\tvar addressSuggestionForm = $(\"#multiShipmentQasDialog\").find(\"form\");\n\t\t\tvar ajaxBtnSubmit;\n\t\t\t$(\"#multiShipmentQasDialog button\").click(function () {\n\t\t\t\tajaxBtnSubmit = $(this).attr(\"name\");\t\n\t\t\t});\n\t\t\taddressSuggestionForm.on(\"submit\",function(event){\n\t\t\t\tevent.preventDefault();\n\t\t\t\t//var buttonClicked = $(document.activeElement).attr(\"name\");\t\n\t\t\t\tif(typeof ajaxBtnSubmit === 'undefined'){\n\t\t\t\t\tajaxBtnSubmit = $(\"#monikerSubmit\").attr(\"name\");\n\t\t\t\t}\t\t\t\t\n\t\t\t\t$.post(util.appendParamToURL(addressSuggestionForm.attr('action'), 'format', 'ajax'), \n\t\t\t\t\t\taddressSuggestionForm.serialize()+\"&\"+ajaxBtnSubmit, \n\t\t\t\t\t\tcheckSubmitFn);\n\t\t\t});\n\t\t}\n\t\t\n\t\tvar checkSubmitFn = function(response){\t\t\n\t\t\tif(typeof response.success !== 'undefined'){\n\t\t\t\tsubmitAddressFn(response);\n\t\t\t}else{\n\t\t\t\tparams.content = response;\n\t\t\t\tdialog.close();\n\t\t\t\t$(\"#multiShipmentQasDialog\").empty();\n\t\t\t\tdialog.openWithContent(params);\n\t\t\t\tbindAddressSuggestion();\n\t\t\t}\n\t\t}\n\t\t\n\t\tajax.load({\n\t\t\turl: Urls.addEditAddress,\n\t\t\tdata: $addressForm.serialize(),\n\t\t\tcallback: function (response) {\n\t\t\t\ttry{\n\t\t\t\t\tvar jsonData = JSON.parse(response);\n\t\t\t\t\tsubmitAddressFn(jsonData);\n\t\t\t\t}catch(e){\n\t\t\t\t\tparams.content = response;\n\t\t\t\t\tdialog.openWithContent(params);\n\t\t\t\t\t$(\"#multiShipmentQasDialog\").off( \"click\", \".showHide\");\n\t\t\t\t\t$(\"#multiShipmentQasDialog\").on( \"click\", \".showHide\", function(){\n\t\t\t\t\t\t$(\".picklist\").slideToggle(\"slow\");\n\t\t\t\t\t});\n\t\t\t\t\tbindAddressSuggestion();\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\t\n\t});\n\t\n\tvar optionIDEdit = $('#currentOptionIDEdit').val();\n\tif(optionIDEdit!=null){\t\t\t\n\t\t$addressDropdown.find(\"option[value='\"+ optionIDEdit +\"']\").attr('selected','selected');\n\t\t$addressDropdown.trigger(\"change\");\n\t}\t\n\t\t\n}\n\n/**\n * @function\n * @description shows gift message box in multiship, and if the page is the multi shipping address page it will call initmultishipshipaddress() to initialize the form\n */\nexports.init = function () {\t\n\taddEditAddress();\t\n};\n\n},{\"./ajax\":1,\"./dialog\":10,\"./pages/checkout/address\":23,\"./pages/checkout/formPrepare\":25,\"./util\":56}],20:[function(require,module,exports){\n'use strict';\n\nvar util = require('./util');\n\nvar page = {\n\ttitle: '',\n\ttype: '',\n\tparams: util.getQueryStringParams(window.location.search.substr(1)),\n\tredirect: function (newURL) {\n\t\tsetTimeout(function () {\n\t\t\twindow.location.href = newURL;\n\t\t}, 0);\n\t},\n\trefresh: function () {\n\t\tsetTimeout(function () {\n\t\t\twindow.location.assign(window.location.href);\n\t\t}, 500);\n\t}\n};\n\nmodule.exports = page;\n\n},{\"./util\":56}],21:[function(require,module,exports){\n'use strict';\n\nvar giftcert = require('../giftcert'),\n\ttooltip = require('../tooltip'),\n\tutil = require('../util'),\n\tdialog = require('../dialog'),\n\tpage = require('../page'),\n\tvalidator = require('../validator');\n\nvar checkSubmitFn = function(response){\t\t \n\tif(typeof response.success !== 'undefined'){\n\t\tdialog.close();\n\t\tpage.refresh();\n\t}else{\n\t\t$('#dialog-container').html(response);\n\t\tbindAddressSuggestion();\n\t}\n}\n\nfunction bindAddressSuggestion(){\n\tvar addressSuggestionForm = $('#dialog-container').find(\"form\");\n\tvar ajaxBtnSubmit;\n\t$(\"#dialog-container button\").click(function () {\n\t\tajaxBtnSubmit = $(this).attr(\"name\");\t\n\t});\n\taddressSuggestionForm.on(\"submit\",function(event){\n\t\tevent.preventDefault();\n\t\t//var buttonClicked = $(document.activeElement).attr(\"name\");\t\n\t\tif(typeof ajaxBtnSubmit === 'undefined'){\n\t\t\tajaxBtnSubmit = $(\"#monikerSubmit\").attr(\"name\");\n\t\t}\n\t\t$.post(util.appendParamToURL(addressSuggestionForm.attr('action'), 'format', 'ajax'), addressSuggestionForm.serialize()+\"&\"+ajaxBtnSubmit, checkSubmitFn);\n\t});\n}\n\n/**\n * @function\n * @description Initializes the events on the address form (apply, cancel, delete)\n * @param {Element} form The form which will be initialized\n */\nfunction initializeAddressForm() {\n\tvar $form = $('#edit-address-form');\n\n\t$form.find('input[name=\"format\"]').remove();\n\ttooltip.init();\n\t//$(\"\").attr({type:\"hidden\", name:\"format\", value:\"ajax\"}).appendTo(form);\n\n\t$form.on('click', '.apply-button', function (e) {\n\t\te.preventDefault();\n\t\tif (!$form.valid()) {\n\t\t\treturn false;\n\t\t}\n\t\tvar url = util.appendParamToURL($form.attr('action'), 'format', 'ajax');\n\t\tvar applyName = $form.find('.apply-button').attr('name');\n\t\tvar options = {\n\t\t\turl: url,\n\t\t\tdata: $form.serialize() + '&' + applyName + '=x',\n\t\t\ttype: 'POST'\n\t\t};\n\t\t$.ajax(options).done(function (data) {\n\t\t\tif (typeof(data) !== 'string') {\n\t\t\t\tif (data.success) {\n\t\t\t\t\tdialog.close(); \n\t\t\t\t\tpage.refresh();\n\t\t\t\t} else {\n\t\t\t\t\twindow.alert(data.message);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tvar QASchecked = $($.parseHTML(data)).filter('#QASchecked').val();\t\t\t\t \n\t\t\t\tif(QASchecked==='true'){\n\t\t\t\t\tvar screenHeight = window.screen.height;\n\t\t\t\t\t$('#dialog-container').html(data);\n\t\t\t\t\t$(\"#dialog-container\").off( \"click\", \".showHide\");\n\t\t\t\t\t$(\"#dialog-container\").on( \"click\", \".showHide\", function(){\n\t\t\t\t\t\t$(\".picklist\").slideToggle(\"slow\");\n\t\t\t\t\t});\n\t\t\t\t\tvar dialogHeight = $('#dialog-container').outerHeight();\n\t\t\t\t\tvar alignTop = (screenHeight - dialogHeight)/2;\n\t\t\t\t\t$('.ui-dialog').css('top',alignTop > 0 ? alignTop : 0);\n\t\t\t\t\tbindAddressSuggestion();\n\t\t\t\t}else{\n\t\t\t\t\taccount.init();\n\t\t\t\t\ttooltip.init();\n\t\t\t\t\tdialog.close();\t\n\t\t\t\t\tpage.refresh();\n\t\t\t\t}\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t}\n\t\t});\n\t})\n\t.on('click', '.close-button', function (e) {\n\t\t//.cancel-button\n\t\te.preventDefault();\n\t\tdialog.close();\n\t})\n\t.on('click', '.delete-button', function (e) {\n\t\te.preventDefault();\n\t\tif (window.confirm(String.format(Resources.CONFIRM_DELETE, Resources.TITLE_ADDRESS))) {\n\t\t\tvar url = util.appendParamsToUrl(Urls.deleteAddress, {\n\t\t\t\tAddressID: $form.find('#addressid').val(),\n\t\t\t\tformat: 'ajax'\n\t\t\t});\n\t\t\t$.ajax({\n\t\t\t\turl: url,\n\t\t\t\tmethod: 'POST',\n\t\t\t\tdataType: 'json'\n\t\t\t}).done(function (data) {\n\t\t\t\tif (data.status.toLowerCase() === 'ok') {\n\t\t\t\t\tdialog.close();\n\t\t\t\t\tpage.refresh();\n\t\t\t\t} else if (data.message.length > 0) {\n\t\t\t\t\twindow.alert(data.message);\n\t\t\t\t\treturn false;\n\t\t\t\t} else {\n\t\t\t\t\tdialog.close();\n\t\t\t\t\tpage.refresh();\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t});\n\n\tvalidator.init();\n}\n/**\n * @private\n * @function\n * @description Toggles the list of Orders\n */\nfunction toggleFullOrder () {\n\t$('.order-items')\n\t\t.find('li.hidden:first')\n\t\t.prev('li')\n\t\t.append('View All')\n\t\t.children('.toggle')\n\t\t.click(function () {\n\t\t\t$(this).parent().siblings('li.hidden').show();\n\t\t\t$(this).remove();\n\t\t});\n}\n/**\n * @private\n * @function\n * @description Binds the events on the address form (edit, create, delete)\n */\nfunction initAddressEvents() {\n\tvar addresses = $('#addresses');\n\tif (addresses.length === 0) { return; }\n\n\taddresses.on('click', '.address-edit, .address-create', function (e) {\n\t\te.preventDefault();\n\t\tdialog.open({\n\t\t\turl: this.href,\n\t\t\toptions: {\n\t\t\t\topen: initializeAddressForm,\n\n\t\t\t}\n\t\t});\n\t}).on('click', '.delete', function (e) {\n\t\te.preventDefault();\n\t\tif (window.confirm(String.format(Resources.CONFIRM_DELETE, Resources.TITLE_ADDRESS))) {\n\t\t\t$.ajax({\n\t\t\t\turl: util.appendParamToURL($(this).attr('href'), 'format', 'ajax'),\n\t\t\t\tdataType: 'json'\n\t\t\t}).done(function (data) {\n\t\t\t\tif (data.status.toLowerCase() === 'ok') {\n\t\t\t\t\tpage.redirect(Urls.addressesList);\n\t\t\t\t} else if (data.message.length > 0) {\n\t\t\t\t\twindow.alert(data.message);\n\t\t\t\t} else {\n\t\t\t\t\tpage.refresh();\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t});\n}\n/**\n * @private\n * @function\n * @description Binds the events of the payment methods list (delete card)\n */\nfunction initPaymentEvents() {\n\t$('.add-card').on('click', function (e) {\n\t\te.preventDefault();\n\t\tdialog.open({\n\t\t\turl: $(e.target).attr('href')\n\t\t});\n\t});\n\n\tvar paymentList = $('.payment-list');\n\tif (paymentList.length === 0) { return; }\n\n\tutil.setDeleteConfirmation(paymentList, String.format(Resources.CONFIRM_DELETE, Resources.TITLE_CREDITCARD));\n\n\t$('form[name=\"payment-remove\"]').on('submit', function (e) {\n\t\te.preventDefault();\n\t\t// override form submission in order to prevent refresh issues\n\t\tvar button = $(this).find('.delete');\n\t\t$('').attr({\n\t\t\ttype: 'hidden',\n\t\t\tname: button.attr('name'),\n\t\t\tvalue: button.attr('value') || 'delete card'\n\t\t}).appendTo($(this));\n\t\tvar data = $(this).serialize();\n\t\t$.ajax({\n\t\t\ttype: 'POST',\n\t\t\turl: $(this).attr('action'),\n\t\t\tdata: data\n\t\t})\n\t\t.done(function () {\n\t\t\tpage.redirect(Urls.paymentsList);\n\t\t});\n\t});\n}\n/**\n * @private\n * @function\n * @description init events for the loginPage\n */\nfunction initLoginPage() {\n\t//o-auth binding for which icon is clicked\n\t$('.oAuthIcon').bind('click', function () {\n\t\t$('#OAuthProvider').val(this.id);\n\t});\n\n\t//toggle the value of the rememberme checkbox\n\t$('#dwfrm_login_rememberme').bind('change', function () {\n\t\tif ($('#dwfrm_login_rememberme').attr('checked')) {\n\t\t\t$('#rememberme').val('true');\n\t\t} else {\n\t\t\t$('#rememberme').val('false');\n\t\t}\n\t});\n\t$('#password-reset').on('click', function (e) {\n\t\te.preventDefault();\n\t\tdialog.open({\n\t\t\turl: $(e.target).attr('href'),\n\t\t\toptions: {\n\t\t\t\topen: function () {\n\t\t\t\t\tvalidator.init();\n\t\t\t\t\tvar $requestPasswordForm = $('[name$=\"_requestpassword\"]'),\n\t\t\t\t\t\t$submit = $requestPasswordForm.find('[name$=\"_requestpassword_send\"]');\n\t\t\t\t\t$($submit).on('click', function (e) {\n\t\t\t\t\t\tif (!$requestPasswordForm.valid()) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\tdialog.submit($submit.attr('name'));\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t});\n}\n/**\n * @private\n * @function\n * @description Binds the events of the order, address and payment pages\n */\n\nfunction birthdayDisplay(option) {\n\n\tif (option == \"show\") {\n\t\t$('.birthday-field').removeClass('hidden');\n\t\t$('.Auroraloyaltybirthday input, .Aurorabirthday input, .Auroraloyaltytermaccepted input').addClass('required');\n\t} else {\n\t\t$('.birthday-field').addClass('hidden');\n\t\t$('.Auroraloyaltybirthday input, .Aurorabirthday input, .Auroraloyaltytermaccepted input').removeClass('required')\n\t}\n\n}\n\nfunction checkBirthdayEnrollment() {\n\t$(function () {\n\t\tif ($('.login-rememberme.Auroraoptinloyaltyprogram input[type=\"checkbox\"]:checked').index(0) > -1) {\n\t\t\tbirthdayDisplay(\"show\");\n\t\t}\n\t});\n\t$('.login-rememberme.Auroraoptinloyaltyprogram').on('click', function (e) {\n\t\tif ($(e.currentTarget).find('input[type=\"checkbox\"]:checked').index(0) > -1) {\n\t\t\tbirthdayDisplay(\"show\");\n\t\t} else {\n\t\t\tbirthdayDisplay(\"hide\");\n\t\t}\n\t});\n}\n\nfunction checkoutRedirect() {\n\tif(window.location.search.substring(0) == \"?redirect=checkout\") {\n\t\tvar formValue = $('#RegistrationForm').attr('action') + '&' + window.location.search.substring(1)\n\t\t$('#RegistrationForm').attr('action', formValue)\n\t}\n}\n\nfunction contactUsFormEvents() {\n\tvar _commentField = $('#dwfrm_contactus_comment');\n\tvar _commentCharCount = $('#commentCharCount');\n\n\t// Make sure the dom element exists on the page\n\tif ( _commentField.length > 0 && _commentCharCount.length > 0) {\n\n\t\t// Initialize the character count, messaging, and style\n\t\tvar max_length = 250;\n\t\tvar warning_length = max_length * .8; // Warn at 80% of max length\n\t\tvar total_characters_entered = _commentField.val().length;\n\t\tvar _charRemainingStart = 'You have ';\n\t\tvar _charRemainingEnd = ' characters remaining';\n\t\tvar _charRemainingMessage = _charRemainingStart + max_length + '/' + max_length + _charRemainingEnd;\n\n\t\t_commentCharCount.css('color','#A0A0A0');\n\t\t_commentCharCount.css('fontWeight', 'bold');\n\t\t_commentCharCount.html(_charRemainingMessage);\n\n\t\t// On Key Press (every time a character is entered)\n\t\t_commentField.on('input', function() {\n\t\t\t// Grab the number of characters entered\n\t\t\ttotal_characters_entered = _commentField.val().length;\n\n\t\t\tif(total_characters_entered < max_length) {\n\t\t\t\t// Update the character count content\n\t\t\t\t_charRemainingMessage = _charRemainingStart + (max_length - total_characters_entered) + '/' + max_length + _charRemainingEnd;\n\t\t\t\t_commentCharCount.html(_charRemainingMessage);\n\t\t\t\tif (total_characters_entered < warning_length) {\n\t\t\t\t\t// $gray-200: #515d68; variable value from our style guide scss data\n\t\t\t\t\t_commentCharCount.css('color','#515d68');\n\t\t\t\t} else {\n\t\t\t\t\t// \"border-success\" variable value from our style guide scss data\n\t\t\t\t\t_commentCharCount.css('color', '#deab26');\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t_charRemainingMessage = _charRemainingStart + '0/' + max_length + _charRemainingEnd;\n\t\t\t\t_commentField.attr('maxlength', max_length);\n\t\t\t\t_commentField.val(_commentField.val().substring(0, max_length));\n\t\t\t\t_commentCharCount.html(_charRemainingMessage);\n\n\t\t\t\t// \"warning\" variable value from our style guide scss data\n\t\t\t\t_commentCharCount.css('color', '#c40000');\n\t\t\t}\n\t\t});\n\t}\n}\n\nfunction initializeEvents() {\n\ttoggleFullOrder();\n\tinitAddressEvents();\n\tinitPaymentEvents();\n\tinitLoginPage();\n\tcheckBirthdayEnrollment();\n\tcheckoutRedirect();\n\tcontactUsFormEvents();\n}\n\nvar account = {\n\tinit: function () {\n\t\tinitializeEvents();\n\t\tgiftcert.init();\n\t},\n\tinitCartLogin: function () {\n\t\tinitLoginPage();\n\t}\n};\n\nmodule.exports = account;\n\n},{\"../dialog\":10,\"../giftcert\":12,\"../page\":20,\"../tooltip\":55,\"../util\":56,\"../validator\":57}],22:[function(require,module,exports){\n'use strict';\n\nvar account = require('./account'),\n\tbonusProductsView = require('../bonus-products-view'),\n\tquickview = require('../quickview'),\n\tcartStoreInventory = require('../storeinventory/cart'),\n\tvalidator = require('../validator'),\n jcarouselMc = require('../jcarousel-mc'),\n\tcarouselYouMayAlsoLike = require('../carousel-you-may-also-like');\n\nfunction initializeGiftOptions(){\n\n\t$(\"#gift-options-gift-message-text\").keyup(function() {\n\t\tvar txt = $(this).val();\n\t\tvar text_length = $(this).val().length;\n\t\tvar text_max = parseInt($(this).attr(\"maxlength\"));\n\n\t\t$('.char-max-alert').html(text_length + '/' + text_max + ' characters');\n\n\t\t// backspace last non ascii char.\n\t\tif(!validator.regex.ascii.test( txt )) {\n\t\t\ttxt = txt.substr(0, txt.length - 1);\n\t\t\t$(this).val(txt);\n\t\t}\n\t});\n\n\t$(\"#gift-options-gift-message-text\").keypress(function(e) {\n\t\tvar txt = $(this).val();\n\n\t\t// prevent users to enter non ascii char\n\t\tif(!validator.regex.ascii.test( txt )) {\n\t\t\te.preventDefault();\n\t\t\te.stopPropagation();\n\t\t}\n\t});\n\n\t$(\"#gift-options-gift-message\").click(function(){\n\t\tif($(\"#gift-options-gift-message\").is(\":checked\")){\n\t\t\t$(\"#gift-options-gift-message-text\").prop('readonly', false);\n\t\t\t$(\"#gift-options-gift-message-text\").css(\"background-color\", \"\");\n\t\t}else{\n\t\t\t$(\"#gift-options-gift-message-text\").prop('readonly', true);\n\t\t\t$(\"#gift-options-gift-message-text\").css(\"background-color\", \"#FFFFFF\");\n\t\t}\n\t});\n\n\t$(\".button-gift-options\").click(function(e){\n\n\t\tvar productLineItemAction = $(this).closest(\".item-user-actions\");\n\t\tvar form = $(this).closest(\"form\");\n\n\t\t$(\"#gift-options-gift-message-text\").val(productLineItemAction.find(\".gift-wrap-msg-text-line-item\").val());\n\n\t\tif(productLineItemAction.find(\".gift-wrap-line-item\").val() == 'true'){\n\t\t\t$(\"#gift-options-gift-wrap\").prop( \"checked\", true );\n\t\t} else {\n\t\t\t$(\"#gift-options-gift-wrap\").prop( \"checked\", false );\n\t\t}\n\n\t\tif(productLineItemAction.find(\".gift-wrap-msg-line-item\").val() == 'true'){\n\t\t\t$(\"#gift-options-gift-message\").prop( \"checked\", true );\n\t\t\t$(\"#gift-options-gift-message-text\").prop('readonly', false);\n\t\t\t$(\"#gift-options-gift-message-text\").css(\"background-color\", \"\");\n\t\t} else {\n\t\t\t$(\"#gift-options-gift-message\").prop( \"checked\", false );\n\t\t\t$(\"#gift-options-gift-message-text\").prop('readonly', true);\n\t\t\t$(\"#gift-options-gift-message-text\").css(\"background-color\", \"#FFFFFF\");\n\t\t}\n\n\t\tif(productLineItemAction.find(\".gift-wrappable-line-item\").attr(\"value\") == 'true'){\n\t\t\t$(\"#gift-options-gift-wrap-label\").show();\n\t\t\t$(\"#gift-options-unwrappable-msg\").hide();\n\t\t\t$(\"#gift-options-gift-wrap-img\").show();\n\t\t}else{\n\t\t\t$(\"#gift-options-gift-wrap-label\").hide();\n\t\t\t$(\"#gift-options-unwrappable-msg\").show();\n\t\t\t$(\"#gift-options-gift-wrap-img\").hide();\n\t\t}\n\n\t\tvar popup = $(\".gift-options-dialog\").dialog({\n\t\t autoOpen: false,\n\t\t width: 775,\n height: 435,\n dialogClass: 'gift-cart',\n\t\t modal: true,\n\t\t buttons : {\n\t \"Apply\" : function() {\n\t \t if(validator.regex.ascii.test( $('#gift-options-gift-message-text').val())) {\n\t\t \t productLineItemAction.find(\".gift-wrap-line-item\").val($(\"#gift-options-gift-wrap\").is(\":checked\"));\n\t\t \t productLineItemAction.find(\".gift-wrap-msg-line-item\").val($(\"#gift-options-gift-message\").is(\":checked\"));\n\t\t \t productLineItemAction.find(\".gift-wrap-msg-text-line-item\").val($(\"#gift-options-gift-message-text\").val());\n\t\t \t form.submit();\n\t \t } else {\n\t \t\t alert(Resources.VALIDATE_ASCII);\n\t \t }\n\t },\n\t \"Cancel\" : function() {\n\t $(this).dialog('destroy');\n\t }\n\t },\n\t open: function() {\n\t \t $('.ui-dialog-buttonpane').find('button:contains(\"Apply\")').addClass('applyButton');\n\t $('.ui-dialog-buttonpane').find('button:contains(\"Cancel\")').addClass('cancelButton');\n\t },\n\t close : function(){\n\t \t$(this).dialog('destroy');\n\t }\n\t });\n\t\t$(\".gift-options-dialog\").find('.close').click(function(e){\n\t\t\tpopup.dialog('destroy');\n\t\t });\n\t\t$(\"#gift-options-gift-message-text\").keyup();\n\t\tpopup.dialog(\"open\");\n\n\t});\n\n}\n\nfunction initializeCartGiftOption(){\n try {\n $(\"#dwfrm_cart_giftMessage\").keyup(function() {\n \t\tvar txt = $(this).val();\n \t\tvar text_length = $(this).val().length;\n \t\tvar text_max = parseInt($(this).attr(\"maxlength\"));\n\n \t\t$('.cart-giftMessage .char-max-alert').html(text_length + '/' + text_max + ' characters');\n\n \t\t// backspace last non ascii char.\n \t\tif(!validator.regex.ascii.test( txt )) {\n \t\t\ttxt = txt.substr(0, txt.length - 1);\n \t\t\t$(this).val(txt);\n \t\t}\n \t}); \n\n \tvar text_length = $(\"#dwfrm_cart_giftMessage\").val().length;\n \tvar text_max = parseInt($(\"#dwfrm_cart_giftMessage\").attr(\"maxlength\"));\n\n \t$('.cart-giftMessage .char-max-alert').html(text_length + '/' + text_max + ' characters');\n } catch (e) {}\n}\n\n/**\n * @private\n * @function\n * @description Binds events to the cart page (edit item's details, bonus item's actions, coupon code entry)\n */\n\nfunction birthdayDisplay(option) {\n\n\tif (option == \"show\") {\n\t\t$('.birthday-field').removeClass('hidden');\n\t\t$('.Auroraloyaltybirthday input, .Aurorabirthday input, .Auroraloyaltytermaccepted input').addClass('required');\n\t} else {\n\t\t$('.birthday-field').addClass('hidden');\n\t\t$('.Auroraloyaltybirthday input, .Aurorabirthday input, .Auroraloyaltytermaccepted input').removeClass('required')\n\t}\n\n}\n\nfunction checkBirthdayEnrollment() {\n\t$(function () {\n\t\tif ($('.login-rememberme.Auroraoptinloyaltyprogram input[type=\"checkbox\"]:checked').index(0) > -1) {\n\t\t\tbirthdayDisplay(\"show\");\n\t\t}\n\t});\n\t$('.login-rememberme.Auroraoptinloyaltyprogram').on('click', function (e) {\n\t\tif ($(e.currentTarget).find('input[type=\"checkbox\"]:checked').index(0) > -1) {\n\t\t\tbirthdayDisplay(\"show\");\n\t\t} else {\n\t\t\tbirthdayDisplay(\"hide\");\n\t\t}\n\t});\n}\nfunction initializeEvents() {\n\t\n\tcheckBirthdayEnrollment();\n\n\tcarouselYouMayAlsoLike.init(); // Initialize Quick Add buttons on Recommender Carousel\n\n\t$( window ).on( \"load\", function() { \n\t\tvar cardInCartEl = $('#gift-card-in-cart-loyalty');\n\t\tvar emptyBagTriggerLoyalty = $('#empty-bag-trigger-loyalty');\n\t\tvar removeButton = $('button.yotpo-remove-tag-button');\n\t\tif (((emptyBagTriggerLoyalty.length !== 0) || (cardInCartEl.length !== 0)) && removeButton.length !== 0) {\n\t\t\tremoveButton.trigger('click');\n\t\t}\n\t} );\n\n\t$('#cart-table').on('click', '.item-edit-details a', function (e) {\n\t\te.preventDefault();\n\t\tquickview.show({\n\t\t\turl: e.target.href,\n\t\t\tsource: 'cart'\n\t\t});\n\t})\n\t.on('click', '.bonus-item-actions a, .item-details .bonusproducts a', function (e) {\n\t\te.preventDefault();\n\t\tbonusProductsView.show(this.href);\n\t})\n\t.on('click', '.remove-item-btn', function(){\n\t\t$(this).closest('.cart-row').find('.item-quantity input').val(0);\n\t});\n\n\t// override enter key for coupon code entry\n\t$('form input[name$=\"_couponCode\"]').on('keydown', function (e) {\n\t\tif (e.which === 13 && $(this).val().length === 0) { return false; }\n\t});\n\n\tif($('.you-may-also-like .ltk-recommendations').length>0 && document.documentElement.clientWidth >= 768){\n\t\t$('.ltk-recommendations').addClass('jcarousel');\n\t\t$('.ltk-recommendations').jcarousel();\n\t\t$('.ltk-recommendations').append('prev');\n\t\t$('.ltk-recommendations').append('next');\n\t\t$('.ltk-recommendations').attr('data-items',\"3\");\n\t\tjcarouselMc.doJCarousel();\n\t}\n\n\tlocalStorage.removeItem(\"objReloadShipments\");\n\tinitializeGiftOptions();\n\tinitializeCartGiftOption();\n\n\t// Promotion toggle\n\t$(document).on('click', '.js-cart-coupon__toggle', function () {\n\t\t$(this).toggleClass('active');\n\t\t$('.js-cart-coupon-code__input-wrapper').toggleClass('active');\n\t})\n\t\n\t// Gift Message toggle\n\t$(document).on('click', '.js-cart-giftMessage__toggle', function () {\n\t\t$(this).toggleClass('active');\n\t\t$('.js-cart-giftMessage__input-wrapper').toggleClass('active');\n\t})\n\n\t// Plus qty\n\t$(document).on('click', '.cart-row .js-qty-plus', function() {\n\t\tvar $input = $(this).siblings('input');\n\t\tvar $submit = $('#cart-form-submit');\n\t\t$input.val($input[0].valueAsNumber + 1).trigger('change');\n\t\t$submit.trigger('click');\n\t});\n\n\t// Minus qty\n\t$(document).on('click', '.cart-row .js-qty-minus', function() {\n\t\tvar $input = $(this).siblings('input');\n\t\tvar $submit = $('#cart-form-submit');\n\n\t\tif ($input[0].valueAsNumber !== 1) {\n\t\t\t$input.val($input[0].valueAsNumber - 1).trigger('change');\n\t\t\t$submit.trigger('click');\n\t\t}\n\t});\n\n\t// Disable buttons and inputs on ALL items in cart so customer can't click multiple times\n\t$('#cart-items-form').on('submit', function() {\n\t\t$('.js-qty-plus').prop('disabled', true);\n\t\t$('.js-qty-minus').prop('disabled', true);\n\t\t$(this).siblings('input').prop('disabled', true);\n\t});\n}\n\n/**\n * @description Swipe detection\n */\nfunction swipedetect(el, callback) {\n\tvar touchsurface = el,\n\tswipedir,\n\tstartX,\n\tstartY,\n\tdistX,\n\tdistY,\n\tthreshold = 50, //required min distance traveled to be considered swipe\n\trestraint = 100, // maximum distance allowed at the same time in perpendicular direction\n\tallowedTime = 300, // maximum time allowed to travel that distance\n\telapsedTime,\n\tstartTime,\n\thandleswipe = callback || function (swipedir) {};\n\t\n\tif (touchsurface) {\n\t\ttouchsurface.addEventListener('touchstart', function (e) {\n\t\t\tvar touchobj = e.changedTouches[0];\n\t\t\tswipedir = 'none';\n\t\t\t//dist = 0\n\t\t\tstartX = touchobj.pageX;\n\t\t\tstartY = touchobj.pageY;\n\t\t\tstartTime = new Date().getTime(); // record time when finger first makes contact with surface\n\t\t}, false);\n\t\ttouchsurface.addEventListener('touchmove', function (e) {\n\t\t\te.preventDefault(); // prevent scrolling when inside DIV\n\t\t}, false);\n\t\ttouchsurface.addEventListener('touchend', function (e) {\n\t\t\tvar touchobj = e.changedTouches[0];\n\t\t\tdistX = touchobj.pageX - startX; // get horizontal dist traveled by finger while in contact with surface\n\t\t\tdistY = touchobj.pageY - startY; // get vertical dist traveled by finger while in contact with surface\n\t\t\telapsedTime = new Date().getTime() - startTime; // get time elapsed\n\t\t\tif (elapsedTime <= allowedTime) { // first condition for awipe met\n\t\t\t\tif (Math.abs(distX) >= threshold && Math.abs(distY) <= restraint) { // 2nd condition for horizontal swipe met\n\t\t\t\t\tswipedir = (distX < 0) ? 'left' : 'right'; // if dist traveled is negative, it indicates left swipe\n\t\t\t\t} else if (Math.abs(distY) >= threshold && Math.abs(distX) <= restraint) { // 2nd condition for vertical swipe met\n\t\t\t\t\tswipedir = (distY < 0) ? 'up' : 'down'; // if dist traveled is negative, it indicates up swipe\n\t\t\t\t}\n\t\t\t}\n\t\t\thandleswipe(swipedir);\n\t\t}, false);\n\t}\n}\n\nexports.init = function () {\n\tinitializeEvents();\n\tif (SitePreferences.STORE_PICKUP) {\n\t\tcartStoreInventory.init();\n\t}\n\taccount.initCartLogin();\n\t\n\tvar el = document.getElementById('shop-the-collection');\n\tswipedetect(el, function (swipedir) {\n\t\t//swipedir contains either \"none\", \"left\", \"right\", \"top\", or \"down\"\n\t\tif (swipedir === 'right') {\n\t\t\t$('#shop-the-collection').parent().find('a.carousel-left').trigger('click');\n\t\t}\n\t\tif (swipedir === 'left') {\n\t\t\t$('#shop-the-collection').parent().find('a.carousel-right').trigger('click');\n\t\t}\n\t});\n\tsetTimeout(function(){\n\t\tvar elt = document.getElementById('you-may-also-like');\n\t\tswipedetect(elt, function (swipedir) {\n\t\t\t//swipedir contains either \"none\", \"left\", \"right\", \"top\", or \"down\"\n\t\t\tif (swipedir === 'right') {\n\t\t\t\t$('#you-may-also-like').parent().find('a.carousel-left').trigger('click');\n\t\t\t}\n\t\t\tif (swipedir === 'left') {\n\t\t\t\t$('#you-may-also-like').parent().find('a.carousel-right').trigger('click');\n\t\t\t}\n\t\t});\n\t}, 3000);\n};\n\n},{\"../bonus-products-view\":3,\"../carousel-you-may-also-like\":5,\"../jcarousel-mc\":15,\"../quickview\":47,\"../storeinventory/cart\":52,\"../validator\":57,\"./account\":21}],23:[function(require,module,exports){\n'use strict';\n\nvar util = require('../../util');\nvar shipping = require('./shipping');\n\n/**\n * @function\n * @description Selects the first address from the list of addresses\n */\nexports.init = function () {\n\tvar $form = $('.address');\n\t// select address from list\n\t$('select[name$=\"_addressList\"]', $form).on('change', function () {\n\t\tvar selected = $(this).children(':selected').first();\n\t\tvar selectedAddress = $(selected).data('address');\n\t\tif (!selectedAddress) { return; }\n\t\tutil.fillAddressFields(selectedAddress, $form);\n\t\tshipping.updateShippingMethodList();\n\t\t// re-validate the form\n\t\t$form.validate().form();\n\t});\n};\n\n},{\"../../util\":56,\"./shipping\":29}],24:[function(require,module,exports){\n'use strict';\n\nvar ajax = require('../../ajax'),\n\tformPrepare = require('./formPrepare'),\n\tgiftcard = require('../../giftcard'),\n\tutil = require('../../util');\n\n/**\n * @function\n * @description Fills the Credit Card form with the passed data-parameter and clears the former cvn input\n * @param {Object} data The Credit Card data (holder, type, masked number, expiration month/year)\n */\nfunction setCCFields(data) {\n\tvar $creditCard = $('[data-method=\"CREDIT_CARD\"]');\n\t$creditCard.find('input[name$=\"creditCard_owner\"]').val(data.holder).trigger('change');\n\t$creditCard.find('select[name$=\"_type\"]').val(data.type).trigger('change');\n\t$creditCard.find('input[name*=\"_creditCard_number\"]').val(data.maskedNumber).trigger('change');\n\t$creditCard.find('[name$=\"_month\"]').val(data.expirationMonth).trigger('change');\n\t$creditCard.find('[name$=\"_year\"]').val(data.expirationYear).trigger('change');\n\t$creditCard.find('input[name$=\"_cvn\"]').val('').trigger('change');\n}\n\n/**\n * @function\n * @description Updates the credit card form with the attributes of a given card\n * @param {String} cardID the credit card ID of a given card\n */\nfunction populateCreditCardForm(cardID) {\n\t// load card details\n\tvar url = util.appendParamToURL(Urls.billingSelectCC, 'creditCardUUID', cardID);\n\tajax.getJson({\n\t\turl: url,\n\t\tcallback: function (data) {\n\t\t\tif (!data) {\n\t\t\t\twindow.alert(Resources.CC_LOAD_ERROR);\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsetCCFields(data);\n\t\t}\n\t});\n}\n\n/**\n * @function\n * @description Changes the payment method form depending on the passed paymentMethodID\n * @param {String} paymentMethodID the ID of the payment method, to which the payment method form should be changed to\n */\nfunction updatePaymentMethod(paymentMethodID) {\n\tvar $paymentMethods = $('.payment-method');\n\t$paymentMethods.removeClass('payment-method-expanded');\n\n\tvar $selectedPaymentMethod = $paymentMethods.filter('[data-method=\"' + paymentMethodID + '\"]');\n\tif ($selectedPaymentMethod.length === 0) {\n\t\t$selectedPaymentMethod = $('[data-method=\"Custom\"]');\n\t}\n\t$selectedPaymentMethod.addClass('payment-method-expanded');\n\n\t// ensure checkbox of payment method is checked\n\t$('input[name$=\"_selectedPaymentMethodID\"]').removeAttr('checked');\n\t$('input[value=' + paymentMethodID + ']').prop('checked', 'checked');\n\tif(paymentMethodID === 'AFTERPAY_PBI') {\n\t\t$('.standardpayment').css('display','none');\n\t\t$('.afterpaysubmit').css('display','block');\n\t} else {\n\t\t$('.standardpayment').css('display','block');\n\t\t$('.afterpaysubmit').css('display','none');\n\t}\n\tformPrepare.validateForm();\n}\n\nfunction updateProgressIndicator() {\n\t$( document ).ready(function() {\n\t\t$('.primary-header').append($('.checkout-progress-indicator'));\n\t\t$('.checkout-progress-indicator').css(\"visibility\", \"visible\");\n\t\tif($(window).width() < 768) {\n\t\t\tif($('.checkout-progress-indicator div').length < 4) {\n\t\t\t\t$('.checkout-progress-indicator div').each(function (index, value) { \n\t\t\t\t\tif(!$(this).hasClass(\"placeorder\")) {\n\t\t\t\t\t var $this = ( $(this).find('a').length ) ? $(this).find('a') : $(this);\n\t\t\t\t\t var step = $this.text();\n\t\t\t\t\t var lastIndexOfSpace = step.lastIndexOf(\" \");\n\t\t\t\n\t\t\t\t\t step = step.substring(0, lastIndexOfSpace);\n\t\t\t\t\t $this.text(step);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t\telse {\n\t\t\t\t//$('.checkout-progress-indicator div').css('width','50%');\n\t\t\t\t// Remove last word of step3 element\n\t\t\t\tvar step3 = $('.checkout-progress-indicator div.step-3');\n\t\t\t\tvar $step3 = (step3.find('a').length) ? step3.find('a') : step3;\n\t\t\t\tvar step = $step3.text();\n\t\t\t\tvar lastIndexOfSpace = step.lastIndexOf(\" \");\n\t\n\t\t\t\tstep = step.substring(0, lastIndexOfSpace);\n\t\t\t\t$step3.text(step);\n\t\t\t}\n\t\t}\n\t\tif($('.checkout-progress-indicator')){\n\t\t\tvar $acitveTab = $('.checkout-progress-indicator').find('div.active');\n\t\t\t$('.primary-header-subline').html($acitveTab.text());\n\t\t\tif($('.checkout-progress-indicator').hasClass('multishipprogress')){\n\t\t\t\t$('.pt-checkout-content').addClass('multiship');\n\t\t\t}\n\t\t}\n\t});\n\t\n}\n\n/**\n * @function\n * @description load label to placeholder for Gift and Coupon Code\n */\nfunction moveLabeltoPlaceholder() {\n\t$('.input-placeholder').each(function( index ) {\n\t var label = $(this).find('label span');\n\t var placeholder = label.text();\n\t var input = $(this).find('.input-text');\n\t label.css(\"display\",\"none\");\n\t input.attr(\"placeholder\", placeholder);\n\t});\n\t\n\t$('.select-placeholder').each(function( index ) {\n\t var label = $(this).find('label span');\n\t var labelText = label.text();\n\t labelText = labelText.replace('*','');\n\t var select = $(this).find('.input-select');\n\t var selected = select.find('option:selected');\n\t \n\t if(selected.val() == \"\"){\n\t\t select.addClass('hasPlaceholder');\n\t\t label.css(\"display\",\"none\");\n\t\t selected.text(labelText);\n\t\t selected.attr('label',labelText);\n\t }\n\t});\n\t\n\t$('select').each(function() {\n\t var selectedValue = $(this).find('option:selected').val();\n\t if(typeof selectedValue == 'undefined' ) return;\n\t if(selectedValue.length == 0){\n\t\t $(this).addClass('hasPlaceholder');\n\t }else{\n\t\t $(this).removeClass('hasPlaceholder');\n\t }\n\t});\n\t\n\t$('select').focus(function() {\n\t\t$(this).removeClass('hasPlaceholder');\n\t});\n\t\n\t$('select').change(function() {\n\t var selectedValue = $(this).find('option:selected').val();\n\t if(typeof selectedValue == 'undefined' ) return;\n\t if(selectedValue.length == 0){\n\t\t $(this).addClass('hasPlaceholder');\n\t }else{\n\t\t $(this).removeClass('hasPlaceholder');\n\t }\n\t});\n}\n\n/**\n * @function\n * @description loads billing address, Gift Certificates, Coupon and Payment methods\n */\nexports.init = function () {\n\tvar $checkoutForm = $('.checkout-billing');\n\tvar $addGiftCert = $('#add-giftcert');\n\tvar $giftCertCode = $('input[name$=\"_giftCertCode\"]');\n\tvar $addCoupon = $('#add-coupon');\n\tvar $couponCode = $('input[name$=\"_couponCode\"]');\n\tvar $selectPaymentMethod = $('.payment-method-options');\n\tvar selectedPaymentMethod = $selectPaymentMethod.find(':checked').val();\n\tvar $email = $('input[name$=\"_email_emailAddress\"]');\n\tvar $emailConfirm = $('input[name$=\"_email_confirmEmailAddress\"]');\n\tvar $useAsBillingAddress = $('input[name=\"useAsBillingAddress\"]');\n\tif($useAsBillingAddress.val()==='true'){\n\t\tif($email.val()===''){\n\t\t\t$email.addClass(\"emailhightlight\");\n\t\t}\n\t\tif($emailConfirm.val()===''){\n\t\t\t$emailConfirm.addClass(\"emailhightlight\");\n\t\t}\t\t\n\t}\n\t\n\t$email.keyup(function() {\n\t\tif($useAsBillingAddress.val()==='true'){\n\t\t\tif($email.val()===''){\n\t\t\t\t$email.addClass(\"emailhightlight\");\n\t\t\t}else{\n\t\t\t\t$email.removeClass(\"emailhightlight\");\n\t\t\t}\n\t\t\t\n\n\t\t}\n\t});\n\t$emailConfirm.keyup(function() {\n\t\tif($useAsBillingAddress.val()==='true'){\n\t\t\tif($emailConfirm.val()===''){\n\t\t\t\t$emailConfirm.addClass(\"emailhightlight\");\n\t\t\t}else{\n\t\t\t\t$emailConfirm.removeClass(\"emailhightlight\");\n\t\t\t}\n\t\t\t\n\t\t}\t\t\n\t});\n\tformPrepare.init({\n\t\tformSelector: 'form[id$=\"billing\"]',\n\t\tcontinueSelector: '[name$=\"billing_save\"]'\n\t});\n\t\n\t// default payment method to 'CREDIT_CARD'\n\tupdatePaymentMethod((selectedPaymentMethod) ? selectedPaymentMethod : 'PayPal');\n\t$selectPaymentMethod.on('click', 'input[type=\"radio\"]', function () {\n\t\tupdatePaymentMethod($(this).val());\n\t});\n\n\t// select credit card from list\n\t$('#creditCardList').on('change', function () {\n\t\tvar cardUUID = $(this).val();\n\t\tif (!cardUUID) {return;}\n\t\tpopulateCreditCardForm(cardUUID);\n\n\t\t// remove server side error\n\t\t$('.required.error').removeClass('error');\n\t\t$('.error-message').remove();\n\t});\n\n\t$('#check-giftcert').on('click', function (e) {\n\t\te.preventDefault();\n\t\tvar $balance = $('.balance');\n\t\tif ($giftCertCode.length === 0 || $giftCertCode.val().length === 0) {\n\t\t\tvar error = $balance.find('span.error');\n\t\t\tif (error.length === 0) {\n\t\t\t\terror = $('').addClass('error').appendTo($balance);\n\t\t\t}\n\t\t\terror.html(Resources.GIFT_CERT_MISSING);\n\t\t\treturn;\n\t\t}\n\n\t\tgiftcard.checkBalance($giftCertCode.val(), function (data) {\n\t\t\tif (!data || !data.giftCertificate) {\n\t\t\t\t$balance.html(Resources.GIFT_CERT_INVALID).removeClass('success').addClass('error');\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t$balance.html(Resources.GIFT_CERT_BALANCE + ' ' + data.giftCertificate.balance).removeClass('error').addClass('success');\n\t\t});\n\t});\n\n\t$addGiftCert.on('click', function (e) {\n\t\te.preventDefault();\n\t\tvar code = $giftCertCode.val(),\n\t\t\t$error = $checkoutForm.find('.giftcert-error');\n\t\tif (code.length === 0) {\n\t\t\t$error.html(Resources.GIFT_CERT_MISSING);\n\t\t\treturn;\n\t\t}\n\n\t\tvar url = util.appendParamsToUrl(Urls.redeemGiftCert, {giftCertCode: code, format: 'ajax'});\n\t\t$.getJSON(url, function (data) {\n\t\t\tvar fail = false;\n\t\t\tvar msg = '';\n\t\t\tif (!data) {\n\t\t\t\tmsg = Resources.BAD_RESPONSE;\n\t\t\t\tfail = true;\n\t\t\t} else if (!data.success) {\n\t\t\t\tif(data.apiError!=null){\n\t\t\t\t\tmsg = data.apiError;\n\t\t\t\t}else{\n\t\t\t\t\tmsg = data.message.split('<').join('<').split('>').join('>');\n\t\t\t\t}\t\t\t\t\t\n\t\t\t\tfail = true;\n\t\t\t}\n\t\t\tif (fail) {\n\t\t\t\t$error.html(msg);\n\t\t\t\treturn;\n\t\t\t} else {\n\t\t\t\twindow.location.assign(Urls.billing);\n\t\t\t}\n\t\t});\n\t});\n\n\t$addCoupon.on('click', function (e) {\n\t\te.preventDefault();\n\t\tvar $error = $checkoutForm.find('.coupon-error'),\n\t\t\tcode = $couponCode.val();\n\t\tif (code.length === 0) {\n\t\t\t$error.html(Resources.COUPON_CODE_MISSING);\n\t\t\treturn;\n\t\t}\n\n\t\tvar url = util.appendParamsToUrl(Urls.addCoupon, {couponCode: code, format: 'ajax'});\n\t\t$.getJSON(url, function (data) {\n\t\t\tvar fail = false;\n\t\t\tvar msg = '';\n\t\t\tif (!data) {\n\t\t\t\tmsg = Resources.BAD_RESPONSE;\n\t\t\t\tfail = true;\n\t\t\t} else if (!data.success) {\n\t\t\t\tmsg = data.message.split('<').join('<').split('>').join('>');\n\t\t\t\tfail = true;\n\t\t\t}\n\t\t\tif (fail) {\n\t\t\t\t$error.html(msg);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\t// success message\n\t\t\tif (data.success) {\n\t\t\t\tmsg = data.message.split('<').join('<').split('>').join('>');\n\t\t\t\t$checkoutForm.find('.redemption.coupon').append(''+msg+'');\n\t\t\t}\n\n\t\t\t//basket check for displaying the payment section, if the adjusted total of the basket is 0 after applying the coupon\n\t\t\t//this will force a page refresh to display the coupon message based on a parameter message\n\t\t\tif (data.success && data.baskettotal === 0) {\n\t\t\t\twindow.location.assign(Urls.billing);\n\t\t\t}\n\t\t});\n\t});\n\n\t// trigger events on enter\n\t$couponCode.on('keydown', function (e) {\n\t\tif (e.which === 13) {\n\t\t\te.preventDefault();\n\t\t\t$addCoupon.click();\n\t\t}\n\t});\n\t$giftCertCode.on('keydown', function (e) {\n\t\tif (e.which === 13) {\n\t\t\te.preventDefault();\n\t\t\t$addGiftCert.click();\n\t\t}\n\t});\n\t\n\tupdateProgressIndicator();\n\tmoveLabeltoPlaceholder();\n\t$('input[id$=\"_email_confirmEmailAddress\"]')\n\t$('input[id$=\"_email_confirmEmailAddress\"]').on('blur', function () {\n\t\t\n\t\tvar idOfInput = $(this).id;\n\t\tvar idForSpanError = idOfInput+'-error';\n\t\tvar emailvalue = $('input[id$=\"_email_emailAddress\"]');\n\t\tvar emailToConfirm = $('input[id$=\"_email_confirmEmailAddress\"]');\n\t\t\n\t\tif((emailToConfirm.val()!= \"\") && (emailToConfirm.val() != emailvalue.val())) {\n\t\t\temailToConfirm.addClass('error');\n\t\t\tif($('span[id$=\"_email_confirmEmailAddress-error\"]').length) {\n\t\t\t\t$('span[id$=\"_email_confirmEmailAddress-error\"]').text('Please confirm email address.');\n\t\t\t\t$('span[id$=\"_email_confirmEmailAddress-error\"]').css('display','inline');\n\t\t\t\t$('button[name$=\"_billing_save\"]').attr('disabled','disabled');\n\t\t\t}else {\n\t\t\t\tvar messageError = 'Please confirm email address.';\n\t\t\t\temailToConfirm.parent().append(messageError);\n\t\t\t\t$('button[name$=\"_billing_save\"]').attr('disabled','disabled');\n\t\t\t}\n\t\t}\n\t});\n\t\n\tfunction billingFeildChecker() {\n\t\tif($('#is-CREDIT_CARD:checked').length > 0) {\n\t\t\t\t$('.incomplete-error-message').show();\n\t\t\t\tif ($(\".payment-method.payment-method-expanded input\").filter(function () { return $.trim($(this).val()).length == 0 }).length == 0) {\n\t\t\t\t\t$('.incomplete-error-message').hide();\n\t\t\t\t}\n\t\t} else {\n\t\t\t$('.incomplete-error-message').hide();\n\t\t}\n\t}\n\t$('.payment-method.payment-method-expanded input, .payment-method.payment-method-expanded select, .payment-method-options input').on('change', function () {\n\t\tbillingFeildChecker();\n\t})\n\tbillingFeildChecker();\n\t\n};\n\n},{\"../../ajax\":1,\"../../giftcard\":11,\"../../util\":56,\"./formPrepare\":25}],25:[function(require,module,exports){\n'use strict';\n\nvar _ = require('lodash');\n\nvar $form, $continue, $requiredInputs, validator, $errorMsg;\n\nvar hasEmptyRequired = function () {\n\t// filter out only the visible fields\n\tvar requiredValues = $requiredInputs.filter(':visible').map(function () {\n\t\treturn $(this).val();\n\t});\n\treturn _(requiredValues).contains('');\n};\n\nvar validateForm = function () {\n\t// only validate form when all required fields are filled to avoid\n\t// throwing errors on empty form\n\tif (!validator) {\n\t\treturn;\n\t}\n\tif (!hasEmptyRequired()) {\n\t\tif (validator.form()) {\n\t\t\t$continue.removeAttr('disabled');\n\t\t}\n\t} else {\n\t\t$continue.attr('disabled', 'disabled');\n\t}\n};\n\nvar validateEl = function () {\n\tif ($(this).val() === '') {\n\t\t$continue.attr('disabled', 'disabled');\n\t\t$errorMsg.show();\n\t} else {\n\t\t// enable continue button on last required field that is valid\n\t\t// only validate single field\n\t\tif (validator.element(this) && !hasEmptyRequired()) {\n\t\t\t$continue.removeAttr('disabled');\n\t\t\t$errorMsg.hide();\n\t\t} else {\n\t\t\t$continue.attr('disabled', 'disabled');\n\t\t\t$errorMsg.show();\n\t\t}\n\t}\n};\n\nvar init = function (opts) {\n\tif (!opts.formSelector || !opts.continueSelector) {\n\t\tthrow new Error('Missing form and continue action selectors.');\n\t}\n\t$form = $(opts.formSelector);\n\t$continue = $(opts.continueSelector);\n\tvalidator = $form.validate();\n\t$requiredInputs = $('.required', $form).find(':input');\n\t$errorMsg = $('.incomplete-error-message', $form);\n\tvalidateForm();\n\t// start listening\n\t$requiredInputs.on('change', validateEl);\n\t$requiredInputs.filter('input').on('keyup', _.debounce(validateEl, 200));\n};\n\nexports.init = init;\nexports.validateForm = validateForm;\nexports.validateEl = validateEl;\n\n},{\"lodash\":62}],26:[function(require,module,exports){\n'use strict';\n\nvar address = require('./address'),\n\tbilling = require('./billing'),\n\tmultiship = require('./multiship'),\n\tshipping = require('./shipping');\n\n/**\n * @function Initializes the page events depending on the checkout stage (shipping/billing)\n */\nexports.init = function () {\n\taddress.init();\n\tif ($('.checkout-shipping').length > 0) {\n\t\tshipping.init();\n\t} else if ($('.checkout-multi-shipping').length > 0) {\n\t\tmultiship.init();\n\t} else {\n\t\tbilling.init();\n\t}\n\n\t//if on the order review page and there are products that are not available diable the submit order button\n\tif ($('.order-summary-footer').length > 0) {\n\t\tif ($('.notavailable').length > 0) {\n\t\t\t$('.order-summary-footer .submit-order .button-fancy-large').attr('disabled', 'disabled');\n\t\t}\n\t}\n};\n\n},{\"./address\":23,\"./billing\":24,\"./multiship\":27,\"./shipping\":29}],27:[function(require,module,exports){\n'use strict';\n\nvar address = require('./address'),\n\tformPrepare = require('./formPrepare'),\n\tdialog = require('../../dialog'),\n\tutil = require('../../util');\n\n/**\n * @function\n * @description Initializes gift message box for multiship shipping, the message box starts off as hidden and this will display it if the radio button is checked to yes, also added event handler to listen for when a radio button is pressed to display the message box\n */\nfunction initMultiGiftMessageBox() {\n\t$.each($('.item-list'), function () {\n\t\tvar $this = $(this);\n\t\tvar $giftMessage = $this.find('.gift-message-text');\n\n\t\t//handle initial load\n\t\t$giftMessage.toggleClass('hidden', $('input[name$=\"_isGift\"]:checked', this).val() !== 'true');\n\n\t\t//set event listeners\n\t\t$this.on('change', function () {\n\t\t\t$giftMessage.toggleClass('hidden', $('input[name$=\"_isGift\"]:checked', this).val() !== 'true');\n\t\t});\n\t});\n}\n\n\n/**\n * @function\n * @description capture add edit adddress form events\n */\nfunction addEditAddress(target) {\n\tvar $addressForm = $('form[name$=\"multishipping_editAddress\"]'),\n\t\t$addressDropdown = $addressForm.find('select[name$=_addressList]'),\n\t\t$addressList = $addressForm.find('.address-list'),\n\t\tadd = true,\n\t\tselectedAddressUUID = $(target).parent().siblings('.select-address').val();\n\n\t$addressDropdown.on('change', function (e) {\n\t\te.preventDefault();\n\t\tvar selectedAddress = $addressList.find('select').val();\n\t\tif (selectedAddress !== 'newAddress') {\n\t\t\tselectedAddress = $.grep($addressList.data('addresses'), function (add) {\n\t\t\t\treturn add.UUID === selectedAddress;\n\t\t\t})[0];\n\t\t\tadd = false;\n\t\t\t// proceed to fill the form with the selected address\n\t\t\tutil.fillAddressFields(selectedAddress, $addressForm);\n\t\t} else {\n\t\t\t//reset the form if the value of the option is not a UUID\n\t\t\t$addressForm.find('.input-text, .input-select').val('');\n\t\t}\n\t});\n\n\t$addressForm.on('click', '.cancel', function (e) {\n\t\te.preventDefault();\n\t\tdialog.close();\n\t});\n\n\t$addressForm.on('submit', function (e) {\n\t\te.preventDefault();\n\t\t$.getJSON(Urls.addEditAddress, $addressForm.serialize(), function (response) {\n\t\t\tif (!response.success) {\n\t\t\t\t// @TODO: figure out a way to handle error on the form\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvar address = response.address,\n\t\t\t\t$shippingAddress = $(target).closest('.shippingaddress'),\n\t\t\t\t$select = $shippingAddress.find('.select-address'),\n\t\t\t\t$selected = $select.find('option:selected'),\n\t\t\t\tnewOption = '';\n\t\t\tdialog.close();\n\t\t\tif (add) {\n\t\t\t\t$('.shippingaddress select').removeClass('no-option').append(newOption);\n\t\t\t\t$('.no-address').hide();\n\t\t\t} else {\n\t\t\t\t$('.shippingaddress select').find('option[value=\"' + address.UUID + '\"]').html(newOption);\n\t\t\t}\n\t\t\t// if there's no previously selected option, select it\n\t\t\tif ($selected.length === 0 || $selected.val() === '') {\n\t\t\t\t$select.find('option[value=\"' + address.UUID + '\"]').prop('selected', 'selected').trigger('change');\n\t\t\t}\n\t\t});\n\t});\n\n\t//preserve the uuid of the option for the hop up form\n\tif (selectedAddressUUID) {\n\t\t//update the form with selected address\n\t\t$addressList.find('option').each(function () {\n\t\t\t//check the values of the options\n\t\t\tif ($(this).attr('value') === selectedAddressUUID) {\n\t\t\t\t$(this).prop('selected', 'selected');\n\t\t\t\t$addressDropdown.trigger('change');\n\t\t\t}\n\t\t});\n\t}\n}\n\nfunction updateProgressIndicator() {\n\t$( document ).ready(function() {\n\t\t$('.primary-header').append($('.checkout-progress-indicator'));\n\t\t$('.checkout-progress-indicator').css(\"visibility\", \"visible\");\n\t\tif($(window).width() < 768) {\n\t\t\tif($('.checkout-progress-indicator div').length < 4) {\n\t\t\t\t$('.checkout-progress-indicator div').each(function (index, value) { \n\t\t\t\t\tif(!$(this).hasClass(\"placeorder\")) {\n\t\t\t\t\t var $this = ( $(this).find('a').length ) ? $(this).find('a') : $(this);\n\t\t\t\t\t var step = $this.text();\n\t\t\t\t\t var lastIndexOfSpace = step.lastIndexOf(\" \");\n\t\t\t\n\t\t\t\t\t step = step.substring(0, lastIndexOfSpace);\n\t\t\t\t\t $this.text(step);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t\telse {\n\t\t\t\t//$('.checkout-progress-indicator div').css('width','50%');\n\t\t\t\t// Remove last word of step3 element\n\t\t\t\tvar step3 = $('.checkout-progress-indicator div.step-3');\n\t\t\t\tvar $step3 = (step3.find('a').length) ? step3.find('a') : step3;\n\t\t\t\tvar step = $step3.text();\n\t\t\t\tvar lastIndexOfSpace = step.lastIndexOf(\" \");\n\t\n\t\t\t\tstep = step.substring(0, lastIndexOfSpace);\n\t\t\t\t$step3.text(step);\n\t\t\t}\n\t\t}\n\t\tif($('.checkout-progress-indicator')){\n\t\t\tvar $acitveTab = $('.checkout-progress-indicator').find('div.active');\n\t\t\t$('.primary-header-subline').html($acitveTab.text());\n\t\t\tif($('.checkout-progress-indicator').hasClass('multishipprogress')){\n\t\t\t\t$('.pt-checkout-content').addClass('multiship');\n\t\t\t}\n\t\t}\n\t});\n\t\n}\n\nfunction reSetURLAddEditAddress(optionID,objLink){\n\tvar $currentLinkAddEditAddress = objLink.siblings('.edit-address').find('a');\n\tvar currentURL = $currentLinkAddEditAddress.attr('href');\t\n\tif(typeof currentURL != 'undefined' || currentURL != null ){\n\t\tcurrentURL = currentURL.split('&')[0];\t\n\t\tif(optionID!=''){\t\t\t\n\t\t\t$currentLinkAddEditAddress.attr(\"href\",currentURL + '&addressID=' + optionID);\t\t\t\n\t\t}else{\n\t\t\t$currentLinkAddEditAddress.attr(\"href\",currentURL);\n\t\t}\n\t}\n}\n/**\n * @function\n * @description shows gift message box in multiship, and if the page is the multi shipping address page it will call initmultishipshipaddress() to initialize the form\n */\nexports.init = function () {\n\tinitMultiGiftMessageBox();\n\tupdateProgressIndicator(); \n\t\n\tif ($('.cart-row .shippingaddress .select-address').length > 0) {\n\t\tformPrepare.init({\n\t\t\tcontinueSelector: '[name$=\"addressSelection_save\"]',\n\t\t\tformSelector: '[id$=\"multishipping_addressSelection\"]'\n\t\t});\n\t}\n\t\n\t/*\n\t$('.edit-address').on('click', 'a', function (e) {\n\t\te.preventDefault();\n\t\tdialog.open({url: this.href, options: {open: function () {\n\t\t\taddress.init();\n\t\t\taddEditAddress(e.target);\n\t\t}}});\n\t});\n\t*/\n\n\t//Reload shipments\n\t\n\tvar objStoreShipments = {};\n\tif(localStorage.getItem(\"objReloadShipments\")===null || localStorage.getItem(\"objReloadShipments\")==='undefined'){\n\t\t$.each($('.list-items_body_row'), function () {\n\t\t\tvar pdID = $(this).find('.attribute').find('#dynamicKey').val();\n\t\t\tvar optionSelected = $(this).find('.select-address').find('option:selected').val();\n\t\t\tobjStoreShipments[pdID] = optionSelected;\t\t\n\t\t\t$(this).find('.select-address').removeClass('error');\t\n\t\t\t$(this).find('.select-address').siblings('span').hide();\n\t\t});\n\t\tif(Object.keys(objStoreShipments).length>0){\n\t\t\ttry {\n\t\t\t\tlocalStorage.setItem(\"objReloadShipments\",JSON.stringify(objStoreShipments));\n\t\t\t} catch(e){}\t\n\t\t}\n\t}else{\n\t\tvar getStoreShipments = JSON.parse(localStorage.getItem(\"objReloadShipments\"));\t\t\n\t\t$.each($('.list-items_body_row'), function (index) {\n\t\t\tvar pdID = $(this).find('.attribute').find('#dynamicKey').val();\n\t\t\tvar optionID = getStoreShipments[pdID];\n\t\t\t$(this).find('.select-address').find('option[value=\"' + optionID + '\"]').prop('selected', 'selected');\t\t\n\t\t\treSetURLAddEditAddress(getStoreShipments[pdID],$(this).find('.select-address'));\t\t\t\t\n\t\t\t$(this).find('.select-address').removeClass('error');\t\n\t\t\t$(this).find('.select-address').siblings('span').hide();\n\t\t\t\n\t\t});\n\t}\n\n\t$('select.select-address').on('change', function (){\t\t\n\t\tvar optionID = $(this).find('option:selected').val();\n\t\treSetURLAddEditAddress(optionID,$(this));\t\t\n\t\tvar currentURL = $(this).siblings('.edit-address').find('a').attr('href');\n\t\tcurrentURL = currentURL.substring(currentURL.indexOf('?')+1).split('&')[0];\t\t\n\t\tvar pdID = currentURL.split('=')[1];\t\t\n\t\tvar getStoreShipments = JSON.parse(localStorage.getItem(\"objReloadShipments\"));\n\t\tgetStoreShipments[pdID] = optionID ;\n\t\tlocalStorage.removeItem(\"objReloadShipments\");\n\t\ttry {\n\t\t\tlocalStorage.setItem(\"objReloadShipments\",JSON.stringify(getStoreShipments));\n\t\t} catch(e){}\t\t\t\n\t});\n\t\n};\n\n},{\"../../dialog\":10,\"../../util\":56,\"./address\":23,\"./formPrepare\":25}],28:[function(require,module,exports){\n'use strict';\n\nfunction initConfirmationRegister(){\n\t$('#dwfrm_profile_customer_email').on('input', function() {\n\t $('#dwfrm_profile_customer_emailconfirm').val($('#dwfrm_profile_customer_email').val());\n\t});\n\t\n\t$('input[id*=\"dwfrm_profile_login_password_\"]').on('input', function() {\n\t\t$('#dwfrm_profile_login_passwordconfirm').val($('input[id*=\"dwfrm_profile_login_password_\"]').val());\n\t});\n}\n\nvar orderconfirmation = {\n\tinit: function () {\n\t\tinitConfirmationRegister();\n\t}\n};\n\nmodule.exports = orderconfirmation;\n},{}],29:[function(require,module,exports){\n'use strict';\n\nvar ajax = require('../../ajax'),\n\tformPrepare = require('./formPrepare'),\n\tprogress = require('../../progress'),\n\ttooltip = require('../../tooltip'),\n\tutil = require('../../util');\n\nvar shippingMethods;\n/**\n * @function\n * @description Initializes gift message box, if shipment is gift\n */\nfunction giftMessageBox() {\n\t// show gift message box, if shipment is gift\n\t$('.gift-message-text').toggleClass('hidden', $('input[name$=\"_shippingAddress_isGift\"]:checked').val() !== 'true');\n}\n\n/**\n * @function\n * @description updates the order summary based on a possibly recalculated basket after a shipping promotion has been applied\n */\nfunction updateSummary() {\n\tvar $summary = $('#secondary.summary');\n\t// indicate progress\n\tprogress.show($summary);\n\n\t// load the updated summary area\n\t$summary.load(Urls.summaryRefreshURL, function () {\n\t\t// hide edit shipping method link\n\t\t$summary.fadeIn('fast');\n\t\t$summary.find('.checkout-mini-cart .minishipment .header a').hide();\n\t\t$summary.find('.order-totals-table .order-shipping .label a').hide();\n\t});\n}\n\n/**\n * @function\n * @description Helper method which constructs a URL for an AJAX request using the\n * entered address information as URL request parameters.\n */\nfunction getShippingMethodURL(url, extraParams) {\n\tvar $form = $('.address');\n\tvar params = {\n\t\taddress1: $form.find('input[name$=\"_address1\"]').val(),\n\t\taddress2: $form.find('input[name$=\"_address2\"]').val(),\n\t\tcountryCode: $form.find('select[id$=\"_country\"]').val(),\n\t\tstateCode: $form.find('select[id$=\"_state\"]').val(),\n\t\tpostalCode: $form.find('input[name$=\"_postal\"]').val(),\n\t\tcity: $form.find('input[name$=\"_city\"]').val()\n\t};\n\treturn util.appendParamsToUrl(url, $.extend(params, extraParams));\n}\n\n/**\n * @function\n * @description selects a shipping method for the default shipment and updates the summary section on the right hand side\n * @param\n */\nfunction selectShippingMethod(shippingMethodID) {\n\t// nothing entered\n\tif (!shippingMethodID) {\n\t\treturn;\n\t}\n\t// attempt to set shipping method\n\tvar url = getShippingMethodURL(Urls.selectShippingMethodsList, {shippingMethodID: shippingMethodID});\n\tajax.getJson({\n\t\turl: url,\n\t\tcallback: function (data) {\n\t\t\tupdateSummary();\n\t\t\tif (!data || !data.shippingMethodID) {\n\t\t\t\twindow.alert('Couldn\\'t select shipping method.');\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\t// display promotion in UI and update the summary section,\n\t\t\t// if some promotions were applied\n\t\t\t$('.shippingpromotions').empty();\n\n\t\t\t// TODO the for loop below isn't doing anything?\n\t\t\t// if (data.shippingPriceAdjustments && data.shippingPriceAdjustments.length > 0) {\n\t\t\t// \tvar len = data.shippingPriceAdjustments.length;\n\t\t\t// \tfor (var i=0; i < len; i++) {\n\t\t\t// \t\tvar spa = data.shippingPriceAdjustments[i];\n\t\t\t// \t}\n\t\t\t// }\n\t\t}\n\t});\n}\n\n/**\n * @function\n * @description Make an AJAX request to the server to retrieve the list of applicable shipping methods\n * based on the merchandise in the cart and the currently entered shipping address\n * (the address may be only partially entered). If the list of applicable shipping methods\n * has changed because new address information has been entered, then issue another AJAX\n * request which updates the currently selected shipping method (if needed) and also updates\n * the UI.\n */\nfunction updateShippingMethodList() {\n\tvar $shippingMethodList = $('#shipping-method-list');\n\tif (!$shippingMethodList || $shippingMethodList.length === 0) { return; }\n\tvar url = getShippingMethodURL(Urls.shippingMethodsJSON);\n\n\tajax.getJson({\n\t\turl: url,\n\t\tcallback: function (data) {\n\t\t\tif (!data) {\n\t\t\t\twindow.alert('Couldn\\'t get list of applicable shipping methods.');\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif (shippingMethods && shippingMethods.toString() === data.toString()) {\n\t\t\t\t// No need to update the UI. The list has not changed.\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\t// We need to update the UI. The list has changed.\n\t\t\t// Cache the array of returned shipping methods.\n\t\t\tshippingMethods = data;\n\t\t\t// indicate progress\n\t\t\tprogress.show($shippingMethodList);\n\n\t\t\t// load the shipping method form\n\t\t\tvar smlUrl = getShippingMethodURL(Urls.shippingMethodsList);\n\t\t\t$shippingMethodList.load(smlUrl, function () {\n\t\t\t\t$shippingMethodList.fadeIn('fast');\n\t\t\t\t// rebind the radio buttons onclick function to a handler.\n\t\t\t\t$shippingMethodList.find('[name$=\"_shippingMethodID\"]').click(function () {\n\t\t\t\t\tselectShippingMethod($(this).val());\n\t\t\t\t});\n\n\t\t\t\t// update the summary\n\t\t\t\tupdateSummary();\n\t\t\t\tprogress.hide();\n\t\t\t\ttooltip.init();\n\t\t\t\t//if nothing is selected in the shipping methods select the first one\n\t\t\t\tif ($shippingMethodList.find('.input-radio:checked').length === 0) {\n\t\t\t\t\t$shippingMethodList.find('.input-radio:first').prop('checked', 'checked');\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t});\n}\n\nfunction updateProgressIndicator() {\n\t$( document ).ready(function() {\n\t\t$('.primary-header').append($('.checkout-progress-indicator'));\n\t\t$('.checkout-progress-indicator').css(\"visibility\", \"visible\");\n\t\tif($(window).width() < 768) {\n\t\t\tif($('.checkout-progress-indicator div').length < 4) {\n\t\t\t\t$('.checkout-progress-indicator div').each(function (index, value) { \n\t\t\t\t\tif(!$(this).hasClass(\"placeorder\")) {\n\t\t\t\t\t var $this = ( $(this).find('a').length ) ? $(this).find('a') : $(this);\n\t\t\t\t\t var step = $this.text();\n\t\t\t\t\t var lastIndexOfSpace = step.lastIndexOf(\" \");\n\t\t\t\n\t\t\t\t\t step = step.substring(0, lastIndexOfSpace);\n\t\t\t\t\t $this.text(step);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t\telse {\n\t\t\t\t//$('.checkout-progress-indicator div').css('width','50%');\n\t\t\t\t// Remove last word of step3 element\n\t\t\t\tvar step3 = $('.checkout-progress-indicator div.step-3');\n\t\t\t\tvar $step3 = (step3.find('a').length) ? step3.find('a') : step3;\n\t\t\t\tvar step = $step3.text();\n\t\t\t\tvar lastIndexOfSpace = step.lastIndexOf(\" \");\n\t\n\t\t\t\tstep = step.substring(0, lastIndexOfSpace);\n\t\t\t\t$step3.text(step);\n\t\t\t}\n\t\t}\n\t\tif($('.checkout-progress-indicator')){\n\t\t\tvar $acitveTab = $('.checkout-progress-indicator').find('div.active');\n\t\t\t$('.primary-header-subline').html($acitveTab.text());\n\t\t\tif($('.checkout-progress-indicator').hasClass('multishipprogress')){\n\t\t\t\t$('.pt-checkout-content').addClass('multiship');\n\t\t\t}\n\t\t}\n\t});\n\t\n}\n\nfunction hideShowZipcode() {\n\n\t$('select[name$=\"_addressFields_country\"]').on('change', function(){\n\t\tvar $this = $(this);\n\t\tvar $zipcode = $('input[name$=\"_addressFields_postal\"]');\n\n\t\tif($this.val() == 'US' || $this.val() == 'CA') {\n\t\t\tif($zipcode.val() == '00000') {\n\t\t\t\t$zipcode.val('');\n\t\t\t}\n\t\t\t$zipcode.parent().parent().removeClass('hide');\n\t\t\t$zipcode.focusout();\n\t\t} else {\n\t\t\t$zipcode.val('00000').change();\n\t\t\t$zipcode.parent().parent().addClass('hide');\n\t\t}\n\t}).change();\n}\n\nexports.init = function () {\n\tformPrepare.init({\n\t\tcontinueSelector: '[name$=\"shippingAddress_save\"]',\n\t\tformSelector:'[id$=\"singleshipping_shippingAddress\"]'\n\t});\n\t$('input[name$=\"_shippingAddress_isGift\"]').on('click', giftMessageBox);\n\n\t$('.address').on('change',\n\t\t'input[name$=\"_addressFields_address1\"], input[name$=\"_addressFields_address2\"], select[name$=\"_addressFields_states_state\"], input[name$=\"_addressFields_city\"], input[name$=\"_addressFields_zip\"]',\n\t\tupdateShippingMethodList\n\t);\n\tgiftMessageBox();\n\tupdateShippingMethodList();\n\tupdateProgressIndicator();\n\tlocalStorage.removeItem(\"objReloadShipments\");\n\thideShowZipcode();\n};\n\nexports.updateShippingMethodList = updateShippingMethodList;\n},{\"../../ajax\":1,\"../../progress\":46,\"../../tooltip\":55,\"../../util\":56,\"./formPrepare\":25}],30:[function(require,module,exports){\n'use strict';\n\nvar addProductToCart = require('./product/addToCart'),\n\tajax = require('../ajax'),\n\tpage = require('../page'),\n\tproductTile = require('../product-tile'),\n\tquickview = require('../quickview');\n\n/**\n * @private\n * @function\n * @description Binds the click events to the remove-link and quick-view button\n */\nfunction initializeEvents() {\n\t$('#compare-table').on('click', '.remove-link', function (e) {\n\t\te.preventDefault();\n\t\tajax.getJson({\n\t\t\turl: this.href,\n\t\t\tcallback: function () {\n\t\t\t\tpage.refresh();\n\t\t\t}\n\t\t});\n\t})\n\t.on('click', '.open-quick-view', function (e) {\n\t\te.preventDefault();\n\t\tvar url = $(this).closest('.product').find('.thumb-link').attr('href');\n\t\tquickview.show({\n\t\t\turl: url,\n\t\t\tsource: 'quickview'\n\t\t});\n\t});\n\n\t$('#compare-category-list').on('change', function () {\n\t\t$(this).closest('form').submit();\n\t});\n}\n\nexports.init = function () {\n\tproductTile.init();\n\tinitializeEvents();\n\taddProductToCart();\n};\n\n},{\"../ajax\":1,\"../page\":20,\"../product-tile\":45,\"../quickview\":47,\"./product/addToCart\":32}],31:[function(require,module,exports){\n'use strict';\n\nvar page = require('../page'),\n\tutil = require('../util');\n\nexports.init = function () {\t\n\tif($('.pt_gift-guide').length) {\n\t\tvar headerBanner = $('.top-banner'), \n\t\t\tstickyNav = $('.gift-guide-nav'),\n\t\t\tstickyNavLinks = stickyNav.find('a'),\n\t\t\tstickyNavHeight\t= stickyNav.outerHeight(true),\n\t\t\tstickyNavScrollTop = stickyNav.offset().top - stickyNavHeight - headerBanner.outerHeight(true);\n\t\t\n\t\t// set nav wrapper height\n\t\tstickyNav.parent().height(stickyNavHeight);\n\t\t\n\t\t$(window).on('load scroll',function(){\n\t\t\t\n\t\t\tvar win = $(window),\n\t\t\twindowPosition = win.scrollTop(),\n\t\t\twindowHeight = win.height();\n\t\t\t\n\t\t\t// remove active class \n\t\t\tstickyNavLinks.removeClass('active');\n\t\t\t\n\t\t\t// add active link based on nav position while scrolling\n\t\t\tstickyNavLinks.each(function(index, el){\n\t\t\t\t\n\t\t\t\tvar $this = $(this),\n\t\t\t\t\t$anchor = $($this.attr('href')),\n\t\t\t\t\t$top = $anchor.offset().top - stickyNav.outerHeight(true) - headerBanner.outerHeight(true),\n\t\t\t\t\t$bottom = $anchor.outerHeight(true) + $top;\n\t\t \n\t\t if ((windowPosition >= $top) && (windowPosition <= $bottom)) {\n\t\t \t$this.addClass('active');\n\t\t }\n\t\t\t});\n\t\t\t\n\t\t\tif (windowPosition >= stickyNavScrollTop) {\n\t\t\t\tstickyNav.removeClass('unsticky').addClass('sticky');\n\t\t\t} else {\n\t\t\t\tstickyNav.removeClass('sticky').addClass('unsticky');\n\t\t\t}\n\t\t});\n\t\t\n\t\tstickyNavLinks.click(function(e){\n\t\t\te.preventDefault();\n\t\t\tvar $this = $(this),\n\t\t\t\t$anchor = $($this.attr('href')),\n\t\t\t\t$index = stickyNavLinks.index($this);\n\t\t\t\n\t\t\t// scroll to target\n\t\t\tif(document.documentElement.clientWidth > 1024) {\n\t\t\t\t$('html, body').animate({\n\t\t\t scrollTop: ($index == 0)? $anchor.offset().top - stickyNav.outerHeight(true) + 1 : $anchor.offset().top - headerBanner.height() - stickyNav.outerHeight(true) + 1\n\t\t\t }, 500, function(){\n\t\t\t \t// to fix scroll position due to headerBanner sticky\n\t\t\t \t$(this).animate({\n\t\t\t \t\tscrollTop: ($index == 0)? $anchor.offset().top - stickyNav.outerHeight(true) + 1 : $anchor.offset().top - headerBanner.height() - stickyNav.outerHeight(true) + 1\n\t\t\t \t}, 500);\t\t \t\n\t\t\t });\n\t\t\t} else {\n\t\t\t\t$('html, body').animate({\n\t\t\t scrollTop: $anchor.offset().top\n\t\t\t }, 500);\n\t\t\t}\n\t\t});\n\t}\n};\n\n},{\"../page\":20,\"../util\":56}],32:[function(require,module,exports){\n'use strict';\n\nvar dialog = require('../../dialog'),\n\tminicart = require('../../minicart'),\n\tpage = require('../../page'),\n\tutil = require('../../util'),\n\tTPromise = require('promise'),\n\t_ = require('lodash');\n\n/**\n * @description Make the AJAX request to add an item to cart\n * @param {Element} form The form element that contains the item quantity and ID data\n * @returns {Promise}\n */\nvar addItemToCart = function (form) {\n\tvar $form = $(form),\n\t\t$qty = $form.find('input[name=\"Quantity\"]');\n\tif ($qty.length === 0 || isNaN($qty.val()) || parseInt($qty.val(), 10) === 0) {\n\t\t$qty.val('1');\n\t}\n\treturn TPromise.resolve($.ajax({\n\t\ttype: 'POST',\n\t\turl: util.ajaxUrl(Urls.addProduct),\n\t\tdata: $form.serialize()\n\t}));\n};\n\n/**\n * @description Handler to handle the add to cart event\n */\nvar addToCart = function (e) {\n\te.preventDefault();\n\tvar $form = $(this).closest('form');\n\n\taddItemToCart($form).then(function (response) {\n\t\tvar $uuid = $form.find('input[name=\"uuid\"]');\n\t\tif ($uuid.length > 0 && $uuid.val().length > 0) {\n\t\t\tpage.refresh();\n\t\t} else {\n\t\t\tminicart.show(response);\n\t\t}\n\t}.bind(this));\n};\n\n/**\n * @description Handler to handle the add all items to cart event\n */\nvar addAllToCart = function (e) {\n\te.preventDefault();\n\tvar $productForms = $('#product-set-list').find('form').toArray();\n\tTPromise.all(_.map($productForms, addItemToCart))\n\t\t.then(function (responses) {\n\t\t\tdialog.close();\n\t\t\t// show the final response only, which would include all the other items\n\t\t\tminicart.show(responses[responses.length - 1]);\n\t\t});\n};\n\n/**\n * @function\n * @description Binds the click event to a given target for the add-to-cart handling\n * @param {Element} target The target on which an add to cart event-handler will be set\n */\nmodule.exports = function (target) {\n\t$('.add-to-cart[disabled]').attr('title', $('.availability-msg').text());\n\n\tif (target) {\n\t\ttarget.on('click', '.add-to-cart', addToCart);\n\t} else {\n\t\t$('.add-to-cart').on('click', addToCart);\n\t}\n\n\t$('#add-all-to-cart').on('click', addAllToCart);\n};\n\n},{\"../../dialog\":10,\"../../minicart\":18,\"../../page\":20,\"../../util\":56,\"lodash\":62,\"promise\":63}],33:[function(require,module,exports){\n'use strict';\n\nvar ajax = require('../../ajax'),\n\tutil = require('../../util');\n\nvar updateContainer = function (data) {\n\tvar $availabilityMsg = $('#pdpMain .availability .availability-msg');\n\tvar message; // this should be lexically scoped, when `let` is supported (ES6)\n\tif (!data) {\n\t\t$availabilityMsg.html(Resources.ITEM_STATUS_NOTAVAILABLE);\n\t\treturn;\n\t}\n\t$availabilityMsg.empty();\n\t// Look through levels ... if msg is not empty, then create span el\n\tif (data.levels.IN_STOCK > 0) {\n\t\tif (data.levels.PREORDER === 0 && data.levels.BACKORDER === 0 && data.levels.NOT_AVAILABLE === 0) {\n\t\t\t// Just in stock\n\t\t\tmessage = Resources.IN_STOCK;\n\t\t} else {\n\t\t\t// In stock with conditions ...\n\t\t\tmessage = data.inStockMsg;\n\t\t}\n\t\t$availabilityMsg.append('

        ' + message + '

        ');\n\t}\n\tif (data.levels.PREORDER > 0) {\n\t\tif (data.levels.IN_STOCK === 0 && data.levels.BACKORDER === 0 && data.levels.NOT_AVAILABLE === 0) {\n\t\t\tmessage = Resources.PREORDER;\n\t\t} else {\n\t\t\tmessage = data.preOrderMsg;\n\t\t}\n\t\t$availabilityMsg.append('

        ' + message + '

        ');\n\t}\n\tif (data.levels.BACKORDER > 0) {\n\t\tif (data.levels.IN_STOCK === 0 && data.levels.PREORDER === 0 && data.levels.NOT_AVAILABLE === 0) {\n\t\t\tmessage = Resources.BACKORDER;\n\t\t} else {\n\t\t\tmessage = data.backOrderMsg;\n\t\t}\n\t\t$availabilityMsg.append('

        ' + message + '

        ');\n\t}\n\tif (data.inStockDate !== '') {\n\t\t$availabilityMsg.append('

        ' + String.format(Resources.IN_STOCK_DATE, data.inStockDate) + '

        ');\n\t}\n\tif (data.levels.NOT_AVAILABLE > 0) {\n\t\tif (data.levels.PREORDER === 0 && data.levels.BACKORDER === 0 && data.levels.IN_STOCK === 0) {\n\t\t\tmessage = Resources.NOT_AVAILABLE;\n\t\t} else {\n\t\t\tmessage = Resources.REMAIN_NOT_AVAILABLE;\n\t\t}\n\t\t$availabilityMsg.append('

        ' + message + '

        ');\n\t}\n};\n\nvar getAvailability = function () {\n\tajax.getJson({\n\t\turl: util.appendParamsToUrl(Urls.getAvailability, {\n\t\t\tpid: $('#pid').val(),\n\t\t\tQuantity: $(this).val()\n\t\t}),\n\t\tcallback: updateContainer\n\t});\n};\n\nmodule.exports = function () {\n\t$('#pdpMain').on('change', '.pdpForm input[name=\"Quantity\"]', getAvailability);\n};\n\n},{\"../../ajax\":1,\"../../util\":56}],34:[function(require,module,exports){\n'use strict';\nvar dialog = require('../../dialog'),\n\tlightgalleryMc = require('../../lightgallery-mc'),\n\tutil = require('../../util');\n\nvar zoomMediaQuery = matchMedia('(min-width: 960px)');\n\n/**\n * @description Enables the zoom viewer on the product detail page\n * @param zmq {Media Query List}\n */\nvar loadZoom = function (zmq) {\n\tvar $imgZoom = $('#pdpMain .main-image'),\n\t\thiresUrl;\n\tif (!zmq) {\n\t\tzmq = zoomMediaQuery;\n\t}\n\tif ($imgZoom.length === 0 || dialog.isActive() || util.isMobile() || !zoomMediaQuery.matches) {\n\t\t// remove zoom\n\t\t$imgZoom.trigger('zoom.destroy');\n\t\treturn;\n\t}\n\thiresUrl = $imgZoom.attr('href');\n\n\tif (hiresUrl && hiresUrl !== 'null' && hiresUrl.indexOf('noimagelarge') === -1 && zoomMediaQuery.matches) {\n\t\t$imgZoom.zoom({\n\t\t\turl: hiresUrl\n\t\t});\n\t}\n};\n\nzoomMediaQuery.addListener(loadZoom);\n\n/**\n * @description Sets the main image attributes and the href for the surrounding tag\n * @param {Object} atts Object with url, alt, title and hires properties\n */\nvar setMainImage = function (atts) {\n\t$('#pdpMain .primary-image').attr({\n\t\tsrc: atts.url\n\t});\n\tif (!dialog.isActive() && !util.isMobile()) {\n\t\t$('#pdpMain .main-image').attr('href', atts.hires);\n\t}\n\tloadZoom();\n};\n\n/**\n * @description Replaces the images in the image container, for eg. when a different color was clicked.\n */\nvar replaceImages = function () {\n\tvar $newImages = $('#update-images'),\n\t\t$imageContainer = $('#pdpMain .product-image-container');\n\tif ($newImages.length === 0) { return; }\n\n\t$imageContainer.html($newImages.html());\n\t$newImages.remove();\n\tloadZoom();\n};\n\n/* @module image\n * @description this module handles the primary image viewer on PDP\n **/\n\n/**\n * @description by default, this function sets up zoom and event handler for thumbnail click\n **/\nmodule.exports = function () {\n\tif (dialog.isActive() || util.isMobile()) {\n\t\t$('#pdpMain .main-image').removeAttr('href');\n\t}\n\tloadZoom();\n\t// handle product thumbnail click event\n\t$('#pdpMain').on('click', '.productthumbnail', function () {\n\t\t// switch indicator\n\t\t$(this).closest('.product-thumbnails').find('.thumb.selected').removeClass('selected');\n\t\t$(this).closest('.thumb').addClass('selected');\n\n\t\tsetMainImage($(this).data('lgimg'));\n\t});\n\tlightgalleryMc.init();\n};\nmodule.exports.loadZoom = loadZoom;\nmodule.exports.setMainImage = setMainImage;\nmodule.exports.replaceImages = replaceImages;\n\n},{\"../../dialog\":10,\"../../lightgallery-mc\":17,\"../../util\":56}],35:[function(require,module,exports){\n'use strict';\n\nvar dialog = require('../../dialog'),\n\tproductStoreInventory = require('../../storeinventory/product'),\n\ttooltip = require('../../tooltip'),\n\tutil = require('../../util'),\n\taddToCart = require('./addToCart'),\n\tavailability = require('./availability'),\n\timage = require('./image'),\n\tproductNav = require('./productNav'),\n\tproductSet = require('./productSet'),\n\trecommendations = require('./recommendations'),\n\tvariant = require('./variant'),\n\tcarouselShopTheCollection = require('../../carousel-shop-the-collection'),\n\tcarouselYouMayAlsoLike = require('../../carousel-you-may-also-like');\n\n/**\n * @description Initialize product detail page with reviews, recommendation and product navigation.\n */\nfunction initializeDom() {\n\tproductNav();\n\trecommendations();\n\ttooltip.init();\n\n}\n\n/**\n * @description Initialize event handlers on product detail page\n */\nfunction initializeEvents() {\n\tvar $pdpMain = $('#pdpMain');\n\n\taddToCart();\n\tavailability();\n\tvariant();\n\timage();\n\tproductSet();\n\tif (SitePreferences.STORE_PICKUP) {\n\t\tproductStoreInventory.init();\n\t}\n\n\t// QuickView on Shop The Collection carousel\n\tcarouselShopTheCollection.init();\n\n\t// QuickView on the You May Also Like Carousel\n\tcarouselYouMayAlsoLike.init();\n\n\t// Add to Wishlist and Add to Gift Registry links behaviors\n\t$pdpMain.on('click', '[data-action=\"wishlist\"], [data-action=\"gift-registry\"]', function () {\n\t\tvar data = util.getQueryStringParams($('.pdpForm').serialize());\n\t\tif (data.cartAction) {\n\t\t\tdelete data.cartAction;\n\t\t}\n\t\tvar url = util.appendParamsToUrl(this.href, data);\n\t\tthis.setAttribute('href', url);\n\t});\n\n\t// product options\n\t$pdpMain.on('change', '.product-options select', function () {\n\t\tvar salesPrice = $pdpMain.find('.product-add-to-cart .price-sales');\n\t\tvar selectedItem = $(this).children().filter(':selected').first();\n\t\tsalesPrice.text(selectedItem.data('combined'));\n\t});\n\n\t// prevent default behavior of thumbnail link and add this Button\n\t$pdpMain.on('click', '.thumbnail-link, .unselectable a', function (e) {\n\t\te.preventDefault();\n\t});\n\n\t$('.size-chart-link a').on('click', function (e) {\n\t\te.preventDefault();\n\t\tdialog.open({\n\t\t\turl: $(e.target).attr('href')\n\t\t});\n\t});\n\t\n\t// PDP Details Accordion\n\t$('.product-col-2.product-detail .accordion-item h4, .pt_product-details.product_sets .product-info .accordion-item h4').click(function(){\n\t\tvar $currentItem = $(this).parent();\n\t\t$currentItem.toggleClass('active');\n\t});\n\t\n\t$('.pt_product-details.product_sets .quantity .more').on('click', function () {\n\t\tvar $qty = $(this).closest('.quantity').find('input');\n var currentVal = parseInt($qty.val());\n if (!isNaN(currentVal)) {\n $qty.val(currentVal + 1);\n }\n\t});\n\t$('.pt_product-details.product_sets .quantity .less').on('click', function () {\n\t\tvar $qty = $(this).closest('.quantity').find('input');\n var currentVal = parseInt($qty.val());\n if (!isNaN(currentVal) && currentVal > 1) {\n $qty.val(currentVal - 1);\n }\n\t});\n\n\tvar rafLink = $('#pdp-refer-a-friend-link');\n\tvar rafModal = $('#raf-modal');\n\tvar rafModalClose = $('.raf-modal-close');\n\trafLink.on('click', function (e) {\n\t\te.preventDefault();\n\t\trafModal.show();\n\t\t/* Add overflow hidden class to body */\n\t\t$(\"body\").addClass('raf-stop-scroll');\n\t});\n\n\t// Close button is clicked\n\trafModalClose.on('click', function(e) {\n\t\t/* Remove the overflow hidden from body */\n\t\t$(\"body\").removeClass('raf-stop-scroll');\n\t\trafModal.hide();\n\t});\n\n\t// Esc key is pressed\n\twindow.addEventListener('keydown', function (e) {\n\t\tif (e.key === 'Escape') {\n\t\t\t/* Remove the overflow hidden from body */\n\t\t\t$(\"body\").removeClass('raf-stop-scroll');\n\t\t\trafModal.hide();\n\t\t}\n\t});\n}\n\n/**\n * @description Swipe detection\n */\nfunction swipedetect(el, callback) {\n\tvar touchsurface = el,\n\tswipedir,\n\tstartX,\n\tstartY,\n\tdistX,\n\tdistY,\n\tthreshold = 50, //required min distance traveled to be considered swipe\n\trestraint = 100, // maximum distance allowed at the same time in perpendicular direction\n\tallowedTime = 300, // maximum time allowed to travel that distance\n\telapsedTime,\n\tstartTime,\n\thandleswipe = callback || function (swipedir) {};\n\t\n\tif (touchsurface) {\n\t\ttouchsurface.addEventListener('touchstart', function (e) {\n\t\t\tvar touchobj = e.changedTouches[0];\n\t\t\tswipedir = 'none';\n\t\t\t//dist = 0\n\t\t\tstartX = touchobj.pageX;\n\t\t\tstartY = touchobj.pageY;\n\t\t\tstartTime = new Date().getTime(); // record time when finger first makes contact with surface\n\t\t}, false);\n\t\ttouchsurface.addEventListener('touchmove', function (e) {\n\t\t\te.preventDefault(); // prevent scrolling when inside DIV\n\t\t}, false);\n\t\ttouchsurface.addEventListener('touchend', function (e) {\n\t\t\tvar touchobj = e.changedTouches[0];\n\t\t\tdistX = touchobj.pageX - startX; // get horizontal dist traveled by finger while in contact with surface\n\t\t\tdistY = touchobj.pageY - startY; // get vertical dist traveled by finger while in contact with surface\n\t\t\telapsedTime = new Date().getTime() - startTime; // get time elapsed\n\t\t\tif (elapsedTime <= allowedTime) { // first condition for awipe met\n\t\t\t\tif (Math.abs(distX) >= threshold && Math.abs(distY) <= restraint) { // 2nd condition for horizontal swipe met\n\t\t\t\t\tswipedir = (distX < 0) ? 'left' : 'right'; // if dist traveled is negative, it indicates left swipe\n\t\t\t\t} else if (Math.abs(distY) >= threshold && Math.abs(distX) <= restraint) { // 2nd condition for vertical swipe met\n\t\t\t\t\tswipedir = (distY < 0) ? 'up' : 'down'; // if dist traveled is negative, it indicates up swipe\n\t\t\t\t}\n\t\t\t}\n\t\t\thandleswipe(swipedir);\n\t\t}, false);\n\t}\n}\n\nvar product = {\n\tinitializeEvents: initializeEvents,\n\tinit: function () {\n\t\tinitializeDom();\n\t\tinitializeEvents();\n\t\t\n\t\tif ($(window).width() > 767) {\n\t\t\t$('.wrap-product-thumbnails .jcarousel').jcarousel({\n\t\t\t\tvertical: true\n\t\t\t});\n\t\t}\n\t\t$('.wrap-product-thumbnails .jcarousel-control-prev')\n\t\t\t.on('jcarouselcontrol:active', function() {\n\t\t\t\t$(this).removeClass('inactive');\n\t\t\t})\n\t\t\t.on('jcarouselcontrol:inactive', function() {\n\t\t\t\t$(this).addClass('inactive');\n\t\t\t})\n\t\t\t.jcarouselControl({\n\t\t\t\ttarget: '-=1'\n\t\t\t});\n\n\t\t$('.wrap-product-thumbnails .jcarousel-control-next')\n\t\t\t.on('jcarouselcontrol:active', function() {\n\t\t\t\t$(this).removeClass('inactive');\n\t\t\t})\n\t\t\t.on('jcarouselcontrol:inactive', function() {\n\t\t\t\t$(this).addClass('inactive');\n\t\t\t})\n\t\t\t.jcarouselControl({\n\t\t\t\ttarget: '+=1'\n\t\t\t});\n\n\t\t$('.wrap-product-thumbnails .jcarousel-pagination')\n\t\t\t.on('jcarouselpagination:active', 'a', function() {\n\t\t\t\t$(this).addClass('active');\n\t\t\t})\n\t\t\t.on('jcarouselpagination:inactive', 'a', function() {\n\t\t\t\t$(this).removeClass('active');\n\t\t\t})\n\t\t\t.jcarouselPagination();\n\t\t\n\t\tvar thumbnails = document.getElementById('thumbnails');\n\t\t\n\t\tswipedetect(thumbnails, function (swipedir) {\n\t\t\t//swipedir contains either \"none\", \"left\", \"right\", \"top\", or \"down\"\n\t\t\tif (swipedir === 'right') {\n\t\t\t\t$('#thumbnails').parent().find('a.jcarousel-control-prev').trigger('click');\n\t\t\t}\n\t\t\tif (swipedir === 'left') {\n\t\t\t\t$('#thumbnails').parent().find('a.jcarousel-control-next').trigger('click');\n\t\t\t}\n\t\t});\n\t\t\n\t\tvar el = document.getElementById('shop-the-collection');\n\t\tswipedetect(el, function (swipedir) {\n\t\t\t//swipedir contains either \"none\", \"left\", \"right\", \"top\", or \"down\"\n\t\t\tif (swipedir === 'right') {\n\t\t\t\t$('#shop-the-collection').parent().find('a.carousel-left').trigger('click');\n\t\t\t}\n\t\t\tif (swipedir === 'left') {\n\t\t\t\t$('#shop-the-collection').parent().find('a.carousel-right').trigger('click');\n\t\t\t}\n\t\t});\n\t\tsetTimeout(function(){\n\t\t\tvar elt = document.getElementById('you-may-also-like');\n\t\t\tswipedetect(elt, function (swipedir) {\n\t\t\t\t//swipedir contains either \"none\", \"left\", \"right\", \"top\", or \"down\"\n\t\t\t\tif (swipedir === 'right') {\n\t\t\t\t\t$('#you-may-also-like').parent().find('a.carousel-left').trigger('click');\n\t\t\t\t\t// mobile\n\t\t\t\t\t$('#you-may-also-like-abtest').parent().find('a.carousel-left').trigger('click');\n\t\t\t\t}\n\t\t\t\tif (swipedir === 'left') {\n\t\t\t\t\t$('#you-may-also-like').parent().find('a.carousel-right').trigger('click');\n\t\t\t\t\t// mobile\n\t\t\t\t\t$('#you-may-also-like-abtest').parent().find('a.carousel-right').trigger('click');\n\t\t\t\t}\n\t\t\t});\n\t\t}, 3000);\n\t}\n};\n\nmodule.exports = product;\n\n},{\"../../carousel-shop-the-collection\":4,\"../../carousel-you-may-also-like\":5,\"../../dialog\":10,\"../../storeinventory/product\":54,\"../../tooltip\":55,\"../../util\":56,\"./addToCart\":32,\"./availability\":33,\"./image\":34,\"./productNav\":36,\"./productSet\":37,\"./recommendations\":38,\"./variant\":39}],36:[function(require,module,exports){\n'use strict';\n\nvar ajax = require('../../ajax'),\n\tutil = require('../../util');\n\n/**\n * @description loads product's navigation\n **/\nmodule.exports = function () {\n\tvar $pidInput = $('.pdpForm input[name=\"pid\"]').last(),\n\t\t$navContainer = $('#product-nav-container');\n\t// if no hash exists, or no pid exists, or nav container does not exist, return\n\tif (window.location.hash.length <= 1 || $pidInput.length === 0 || $navContainer.length === 0) {\n\t\treturn;\n\t}\n\n\tvar pid = $pidInput.val(),\n\t\thash = window.location.hash.substr(1),\n\t\turl = util.appendParamToURL(Urls.productNav + '?' + hash, 'pid', pid);\n\n\tajax.load({\n\t\turl: url,\n\t\ttarget: $navContainer\n\t});\n};\n\n},{\"../../ajax\":1,\"../../util\":56}],37:[function(require,module,exports){\n'use strict';\n\nvar addToCart = require('./addToCart'),\n\tajax = require('../../ajax'),\n\ttooltip = require('../../tooltip'),\n\tutil = require('../../util');\n\nmodule.exports = function () {\n\tvar $addToCart = $('#add-to-cart'),\n\t\t$addAllToCart = $('#add-all-to-cart'),\n\t\t$productSetList = $('#product-set-list');\n\n\tvar updateAddToCartButtons = function () {\n\t\tif ($productSetList.find('.add-to-cart[disabled]').length > 0) {\n\t\t\t$addAllToCart.attr('disabled', 'disabled');\n\t\t\t// product set does not have an add-to-cart button, but product bundle does\n\t\t\t$addToCart.attr('disabled', 'disabled');\n\t\t} else {\n\t\t\t$addAllToCart.removeAttr('disabled');\n\t\t\t$addToCart.removeAttr('disabled');\n\t\t}\n\t};\n\n\tif ($productSetList.length > 0) {\n\t\tupdateAddToCartButtons();\n\t}\n\t\n\t$('form.upperAddAllToBagButton button').on('click', function (e) {\n\t\te.preventDefault();\n\t\t$('form.lowerAddAllToBagButton button').click();\n\t});\n\t// click on swatch for product set\n\t$productSetList.on('click', '.product-set-item .swatchanchor', function (e) {\n\t\te.preventDefault();\n\t\tif ($(this).parents('li').hasClass('unselectable')) { return; }\n\t\tvar url = Urls.getSetItem + this.search;\n\t\tvar $container = $(this).closest('.product-set-item');\n\t\tvar qty = $container.find('form input[name=\"Quantity\"]').first().val();\n\n\t\tajax.load({\n\t\t\turl: util.appendParamToURL(url, 'Quantity', isNaN(qty) ? '1' : qty),\n\t\t\ttarget: $container,\n\t\t\tcallback: function () {\n\t\t\t\tupdateAddToCartButtons();\n\t\t\t\taddToCart($container);\n\t\t\t\ttooltip.init();\n\t\t\t}\n\t\t});\n\t});\n};\n\n},{\"../../ajax\":1,\"../../tooltip\":55,\"../../util\":56,\"./addToCart\":32}],38:[function(require,module,exports){\n'use strict';\n\n/**\n * @description Creates product recommendation carousel using jQuery jcarousel plugin\n **/\nmodule.exports = function () {\n\tvar $carousel = $('#carousel-recommendations');\n\tif (!$carousel || $carousel.length === 0 || $carousel.children().length === 0) {\n\t\treturn;\n\t}\n\t$carousel.jcarousel();\n\t$('#carousel-recommendations .jcarousel-prev')\n\t\t.on('jcarouselcontrol:active', function () {\n\t\t\t$(this).removeClass('inactive');\n\t\t})\n\t\t.on('jcarouselcontrol:inactive', function () {\n\t\t\t$(this).addClass('inactive');\n\t\t})\n\t\t.jcarouselControl({\n\t\t\ttarget: '-=1'\n\t\t});\n\n\t$('#carousel-recommendations .jcarousel-next')\n\t\t.on('jcarouselcontrol:active', function () {\n\t\t\t$(this).removeClass('inactive');\n\t\t})\n\t\t.on('jcarouselcontrol:inactive', function () {\n\t\t\t$(this).addClass('inactive');\n\t\t})\n\t\t.jcarouselControl({\n\t\t\ttarget: '+=1'\n\t\t});\n};\n\n},{}],39:[function(require,module,exports){\n'use strict';\n\nvar addToCart = require('./addToCart'),\n\tajax = require('../../ajax'),\n\timage = require('./image'),\n\tprogress = require('../../progress'),\n\tproductStoreInventory = require('../../storeinventory/product'),\n\ttooltip = require('../../tooltip'),\n\tutil = require('../../util');\n\n\n/**\n * @description update product content with new variant from href, load new content to #product-content panel\n * @param {String} href - url of the new product variant\n **/\nvar updateContent = function (href) {\n\tvar $pdpForm = $('.pdpForm');\n\tvar qty = $pdpForm.find('input[name=\"Quantity\"]').first().val();\n\tvar params = {\n\t\tQuantity: isNaN(qty) ? '1' : qty,\n\t\tformat: 'ajax',\n\t\tproductlistid: $pdpForm.find('input[name=\"productlistid\"]').first().val()\n\t};\n\n\tprogress.show($('#pdpMain'));\n\n\tajax.load({\n\t\turl: util.appendParamsToUrl(href, params),\n\t\ttarget: $('#product-content'),\n\t\tcallback: function () {\n\t\t\taddToCart();\n\t\t\tif (SitePreferences.STORE_PICKUP) {\n\t\t\t\tproductStoreInventory.init();\n\t\t\t}\n\t\t\timage.replaceImages();\n\t\t\ttooltip.init();\n\t\t}\n\t});\n};\n\nmodule.exports = function () {\n\tvar $pdpMain = $('#pdpMain');\n\t// hover on swatch - should update main image with swatch image\n\t$pdpMain.on('mouseenter mouseleave', '.swatchanchor', function () {\n\t\tvar largeImg = $(this).data('lgimg'),\n\t\t\t$imgZoom = $pdpMain.find('.main-image'),\n\t\t\t$mainImage = $pdpMain.find('.primary-image');\n\n\t\tif (!largeImg) { return; }\n\t\t// store the old data from main image for mouseleave handler\n\t\t$(this).data('lgimg', {\n\t\t\thires: $imgZoom.attr('href'),\n\t\t\turl: $mainImage.attr('src'),\n\t\t\talt: $mainImage.attr('alt'),\n\t\t\ttitle: $mainImage.attr('title')\n\t\t});\n\t\t// set the main image\n\t\timage.setMainImage(largeImg);\n\t});\n\n\t// click on swatch - should replace product content with new variant\n\t$pdpMain.on('click', '.product-detail .swatchanchor', function (e) {\n\t\te.preventDefault();\n\t\tif ($(this).parents('li').hasClass('unselectable')) { return; }\n\t\tupdateContent(this.href);\n\t});\n\n\t// change drop down variation attribute - should replace product content with new variant\n\t$pdpMain.on('change', '.variation-select', function () {\n\t\tif ($(this).val().length === 0) { return; }\n\t\tupdateContent($(this).val());\n\t});\n\n\t$('.quantity .more').on('click', function () {\n\t\tvar $qty = $(this).closest('.quantity').find('#Quantity');\n var currentVal = parseInt($qty.val());\n if (!isNaN(currentVal)) {\n $qty.val(currentVal + 1);\n }\n\t});\n\t$('.quantity .less').on('click', function () {\n\t\tvar $qty = $(this).closest('.quantity').find('#Quantity');\n var currentVal = parseInt($qty.val());\n if (!isNaN(currentVal) && currentVal > 1) {\n $qty.val(currentVal - 1);\n }\n\t});\n};\n\n},{\"../../ajax\":1,\"../../progress\":46,\"../../storeinventory/product\":54,\"../../tooltip\":55,\"../../util\":56,\"./addToCart\":32,\"./image\":34}],40:[function(require,module,exports){\n'use strict';\n\nvar addProductToCart = require('./product/addToCart'),\n ajax = require('../ajax'),\n quickview = require('../quickview'),\n util = require('../util');\n\n/**\n * @function\n * @description Loads address details to a given address and fills the address form\n * @param {String} addressID The ID of the address to which data will be loaded\n */\nfunction populateForm(addressID, $form) {\n // load address details\n var url = Urls.giftRegAdd + addressID;\n ajax.getJson({\n url: url,\n callback: function(data) {\n if (!data || !data.address) {\n window.alert(Resources.REG_ADDR_ERROR);\n return false;\n }\n // fill the form\n $form.find('[name$=\"_addressid\"]').val(data.address.ID);\n $form.find('[name$=\"_firstname\"]').val(data.address.firstName);\n $form.find('[name$=\"_lastname\"]').val(data.address.lastName);\n $form.find('[name$=\"_address1\"]').val(data.address.address1);\n $form.find('[name$=\"_address2\"]').val(data.address.address2);\n $form.find('[name$=\"_city\"]').val(data.address.city);\n $form.find('[name$=\"_country\"]').val(data.address.countryCode).trigger('change');\n $form.find('[name$=\"_postal\"]').val(data.address.postalCode);\n $form.find('[name$=\"_state\"]').val(data.address.stateCode);\n $form.find('[name$=\"_phone\"]').val(data.address.phone);\n // $form.parent('form').validate().form();\n }\n });\n}\n\n/**\n * @private\n * @function\n * @description Initializes events for the gift registration\n */\nfunction initializeEvents() {\n var $eventAddressForm = $('form[name$=\"_giftregistry\"]'),\n $beforeAddress = $eventAddressForm.find('fieldset[name=\"address-before\"]'),\n $afterAddress = $eventAddressForm.find('fieldset[name=\"address-after\"]');\n\n $('.usepreevent').on('click', function() {\n // filter out storefront toolkit\n $(':input', $beforeAddress).not('[id^=\"ext\"]').not('select[name$=\"_addressBeforeList\"]').each(function() {\n var fieldName = $(this).attr('name'),\n $afterField = $afterAddress.find('[name=\"' + fieldName.replace('Before', 'After') + '\"]');\n $afterField.val($(this).val()).trigger('change');\n });\n });\n $eventAddressForm.on('change', 'select[name$=\"_addressBeforeList\"]', function() {\n var addressID = $(this).val();\n if (addressID.length === 0) {\n return;\n }\n populateForm(addressID, $beforeAddress);\n })\n .on('change', 'select[name$=\"_addressAfterList\"]', function() {\n var addressID = $(this).val();\n if (addressID.length === 0) {\n return;\n }\n populateForm(addressID, $afterAddress);\n });\n\n $('form[name$=\"_giftregistry_items\"]').on('click', '.item-details a', function(e) {\n e.preventDefault();\n var productListID = $('input[name=productListID]').val();\n quickview.show({\n url: e.target.href,\n source: 'giftregistry',\n productlistid: productListID\n });\n });\n $('#dwfrm_giftregistry_event_date').datepicker({\n dateFormat: 'mm/dd/yy',\n onSelect: function() {\n $(this).trigger('focusout');\n }\n });\n if (document.getElementById('copyButton') != null) {\n document.getElementById('copyButton').addEventListener('click', function() {\n copyToClipboard(document.getElementById('copyTarget'));\n $('.confirmdialog').removeClass('hide');\n });\n }\n}\n\nfunction copyToClipboard(elem) {\n var isInput = elem.tagName;\n if (isInput) {\n elem.focus();\n elem.setSelectionRange(0, elem.value.length);\n var succeed;\n try {\n succeed = document.execCommand('copy');\n } catch (e) {\n succeed = false;\n }\n return succeed;\n }\n}\n\nexports.init = function() {\n initializeEvents();\n addProductToCart();\n\n util.setDeleteConfirmation('.item-list', String.format(Resources.CONFIRM_DELETE, Resources.TITLE_GIFTREGISTRY));\n};\n},{\"../ajax\":1,\"../quickview\":47,\"../util\":56,\"./product/addToCart\":32}],41:[function(require,module,exports){\n'use strict';\n\nvar compareWidget = require('../compare-widget'),\n\tproductTile = require('../product-tile'),\n\tprogress = require('../progress'),\n\tutil = require('../util'),\n\tjcarouselMc = require('../jcarousel-mc'),\n\tgiftGuide = require('./giftguide'),\n\tcarouselYouMayAlsoLike = require('../carousel-you-may-also-like');\n\nfunction infiniteScroll() {\n\t// getting the hidden div, which is the placeholder for the next page\n\tvar loadingPlaceHolder = $('.infinite-scroll-placeholder[data-loading-state=\"unloaded\"]');\n\t// get url hidden in DOM\n\tvar gridUrl = loadingPlaceHolder.attr('data-grid-url');\n\n\tif (loadingPlaceHolder.length === 1 && util.elementInViewport(loadingPlaceHolder.get(0), 250)) {\n\t\t// switch state to 'loading'\n\t\t// - switches state, so the above selector is only matching once\n\t\t// - shows loading indicator\n\t\tloadingPlaceHolder.attr('data-loading-state', 'loading');\n\t\tloadingPlaceHolder.addClass('infinite-scroll-loading');\n\n\t\t/**\n\t\t * named wrapper function, which can either be called, if cache is hit, or ajax repsonse is received\n\t\t */\n\t\tvar fillEndlessScrollChunk = function (html) {\n\t\t\tloadingPlaceHolder.removeClass('infinite-scroll-loading');\n\t\t\tloadingPlaceHolder.attr('data-loading-state', 'loaded');\n\t\t\t$('div.search-result-content').append(html);\n\t\t};\n\n\t\t// old condition for caching was `'sessionStorage' in window && sessionStorage[\"scroll-cache_\" + gridUrl]`\n\t\t// it was removed to temporarily address RAP-2649\n\t\tif (false) {\n\t\t\t// if we hit the cache\n\t\t\tfillEndlessScrollChunk(sessionStorage['scroll-cache_' + gridUrl]);\n\t\t} else {\n\t\t\t// else do query via ajax\n\t\t\t$.ajax({\n\t\t\t\ttype: 'GET',\n\t\t\t\tdataType: 'html',\n\t\t\t\turl: gridUrl,\n\t\t\t\tsuccess: function (response) {\n\t\t\t\t\t// put response into cache\n\t\t\t\t\ttry {\n\t\t\t\t\t\tsessionStorage['scroll-cache_' + gridUrl] = response;\n\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\t// nothing to catch in case of out of memory of session storage\n\t\t\t\t\t\t// it will fall back to load via ajax\n\t\t\t\t\t}\n\t\t\t\t\t// update UI\n\t\t\t\t\tfillEndlessScrollChunk(response);\n\t\t\t\t\tproductTile.init();\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n}\n/**\n * @private\n * @function\n * @description replaces breadcrumbs, lefthand nav and product listing with ajax and puts a loading indicator over the product listing\n */\nfunction updateProductListing() {\n\tvar hash = location.href.split('#')[1];\n\tif (!hash || hash === 'results-content' || hash === 'results-products' || hash.indexOf('lg=1&slide') !== -1) { return; }\n\tvar refineUrl;\n\n\tif (hash && hash.length > 0) {\n\t\trefineUrl = window.location.pathname + '?' + hash;\n\t} else {\n\t\treturn;\n\t}\n\tprogress.show($('.search-result-content'));\n\t$('#main').load(util.appendParamToURL(refineUrl, 'format', 'ajax'), function () {\n\t\tcompareWidget.init();\n\t\tproductTile.init();\n\t\tprogress.hide();\n\t});\n}\n\n/**\n * @private\n * @function\n * @description Initializes events for the following elements:
        \n *

        refinement blocks

        \n *

        updating grid: refinements, pagination, breadcrumb

        \n *

        item click

        \n *

        sorting changes

        \n */\nfunction initializeEvents() {\n\tvar $main = $('#main');\n\tvar $searchResultOptions = $main.find('.search-result-options.cattop');\n\t// compare checked\n\t$main.on('click', 'input[type=\"checkbox\"].compare-check', function () {\n\t\tvar cb = $(this);\n\t\tvar tile = cb.closest('.product-tile');\n\n\t\tvar func = this.checked ? compareWidget.addProduct : compareWidget.removeProduct;\n\t\tvar itemImg = tile.find('.product-image a img').first();\n\t\tfunc({\n\t\t\titemid: tile.data('itemid'),\n\t\t\tuuid: tile[0].id,\n\t\t\timg: itemImg,\n\t\t\tcb: cb\n\t\t});\n\n\t});\n\n\t// handle toggle refinement blocks\n\t$('#secondary, .mobile-filter').on('click', '.refinement h3', function () {\n\t\t$(this).toggleClass('expanded')\n\t\t.siblings('ul').toggle();\n\t});\n\n\tif(util.isMobile()){\n\t\t//handle toggle sort-model block\n\t\t$searchResultOptions.on('click', '.sort-model.m-content .label', function () {\n\t\t\t$(this).parent().toggleClass('expanded')\n\t\t\t.find('.sort-level2').toggle();\n\t\t});\n\t}\n\t\n\t$searchResultOptions.on('click', '.sort-model #closebutton', function () {\n\t\t$searchResultOptions.find('.sort-model').removeClass('expanded');\n\t\t$searchResultOptions.find('.sort-level2').hide();\n\t});\n\t\n\t$searchResultOptions.on('click', '.mobile-filter .closebutton', function () {\n\t\t$searchResultOptions.find('.filter-model').toggleClass('expanded');\n\t\t$searchResultOptions.find('.sort-model').toggle();\n\t\t$(this).parent().toggle();\n\t});\n\t\n\t// handle toggle sort-model block\n\t$searchResultOptions.on('click', '.filter-sort-nav .sort-model', function () {\n\t\t$searchResultOptions.find('.mobile-filter').hide();\n\t\t$searchResultOptions.find('.filter-model').removeClass('expanded');\n\t\t$(this).toggleClass('expanded');\n\t\t$searchResultOptions.find('.sort-level2').toggle();\n\t});\n\t\n\t// handle toggle filter-model block\n\t$searchResultOptions.on('click', '.filter-sort-nav .filter-model', function () {\n\t\t$searchResultOptions.find('.sort-level2').hide();\n\t\t$searchResultOptions.find('.sort-model').toggle();\n\t\t$searchResultOptions.find('.sort-model').removeClass('expanded');\n\t\t$(this).toggleClass('expanded');\n\t\t$searchResultOptions.find('.mobile-filter').toggle();\n\t});\n\n\t// handle events for updating grid\n\t$main.on('click', '.refinements a, .pagination a, .sort-model a', function () {\n\t\tif ($(this).parent().hasClass('unselectable')) { return; }\n\t\t\n\t\t// don't intercept for category and folder refinements, as well as unselectable\n if ($(this).parents('.category-refinement').length > 0 || $(this).parents('.folder-refinement').length > 0 || $(this).parent().hasClass('unselectable')) {\n return;\n }\n updateProductListing(this.href);\n\t});\n\n\t// handle events item click. append params.\n\t$main.on('click', '.product-tile a:not(\"#quickviewbutton\")', function () {\n\t\tvar a = $(this);\n\t\t// get current page refinement values\n\t\tvar wl = window.location;\n\n\t\tvar qsParams = (wl.search.length > 1) ? util.getQueryStringParams(wl.search.substr(1)) : {};\n\t\tvar hashParams = (wl.hash.length > 1) ? util.getQueryStringParams(wl.hash.substr(1)) : {};\n\n\t\t// merge hash params with querystring params\n\t\tvar params = $.extend(hashParams, qsParams);\n\t\tif (!params.start) {\n\t\t\tparams.start = 0;\n\t\t}\n\t\t// get the index of the selected item and save as start parameter\n\t\tvar tile = a.closest('.product-tile');\n\t\tvar idx = tile.data('idx') ? + tile.data('idx') : 0;\n\n\t\t// convert params.start to integer and add index\n\t\tparams.start = (+params.start) + (idx + 1);\n\t\t// set the hash and allow normal action to continue\n\t\t//a[0].hash = $.param(params);\n\t});\n\n\t// handle sorting change\n\t$main.on('change', '.sort-by select', function () {\n\t\tvar refineUrl = $(this).find('option:selected').val();\n\t\tvar queryString = util.getQueryString(refineUrl);\n\t\twindow.location.hash = queryString;\n\t\treturn false;\n\t})\n\t.on('change', '.items-per-page select', function () {\n\t\tvar refineUrl = $(this).find('option:selected').val();\n\t\tvar queryString = util.getQueryString(refineUrl);\n\t\tif (refineUrl === 'INFINITE_SCROLL') {\n\t\t\t$('html').addClass('infinite-scroll').removeClass('disable-infinite-scroll');\n\t\t} else {\n\t\t\t$('html').addClass('disable-infinite-scroll').removeClass('infinite-scroll');\n\t\t\twindow.location.hash = queryString;\n\t\t}\n\t\treturn false;\n\t});\n\n\t// handle hash change\n\twindow.onhashchange = updateProductListing;\n}\n\n/**\n * @description Swipe detection\n */\nfunction swipedetect(el, callback) {\n\tvar touchsurface = el,\n\tswipedir,\n\tstartX,\n\tstartY,\n\tdistX,\n\tdistY,\n\tthreshold = 50, //required min distance traveled to be considered swipe\n\trestraint = 100, // maximum distance allowed at the same time in perpendicular direction\n\tallowedTime = 300, // maximum time allowed to travel that distance\n\telapsedTime,\n\tstartTime,\n\thandleswipe = callback || function (swipedir) {};\n\t\n\tif (touchsurface) {\n\t\ttouchsurface.addEventListener('touchstart', function (e) {\n\t\t\tvar touchobj = e.changedTouches[0];\n\t\t\tswipedir = 'none';\n\t\t\t//dist = 0\n\t\t\tstartX = touchobj.pageX;\n\t\t\tstartY = touchobj.pageY;\n\t\t\tstartTime = new Date().getTime(); // record time when finger first makes contact with surface\n\t\t}, false);\n\t\ttouchsurface.addEventListener('touchmove', function (e) {\n\t\t\te.preventDefault(); // prevent scrolling when inside DIV\n\t\t}, false);\n\t\ttouchsurface.addEventListener('touchend', function (e) {\n\t\t\tvar touchobj = e.changedTouches[0];\n\t\t\tdistX = touchobj.pageX - startX; // get horizontal dist traveled by finger while in contact with surface\n\t\t\tdistY = touchobj.pageY - startY; // get vertical dist traveled by finger while in contact with surface\n\t\t\telapsedTime = new Date().getTime() - startTime; // get time elapsed\n\t\t\tif (elapsedTime <= allowedTime) { // first condition for awipe met\n\t\t\t\tif (Math.abs(distX) >= threshold && Math.abs(distY) <= restraint) { // 2nd condition for horizontal swipe met\n\t\t\t\t\tswipedir = (distX < 0) ? 'left' : 'right'; // if dist traveled is negative, it indicates left swipe\n\t\t\t\t} else if (Math.abs(distY) >= threshold && Math.abs(distX) <= restraint) { // 2nd condition for vertical swipe met\n\t\t\t\t\tswipedir = (distY < 0) ? 'up' : 'down'; // if dist traveled is negative, it indicates up swipe\n\t\t\t\t}\n\t\t\t}\n\t\t\thandleswipe(swipedir);\n\t\t}, false);\n\t}\n}\n\n/**\n * Update refinements state (opened or closed)\n */\n function updateRefinementsState() {\n var $secondary = $('#secondary, .mobile-filter');\n\n\t$secondary.find('.refinement ul').each(function() {\n $(this).find('li').each(function() {\n if ($(this).hasClass('selected')) {\n $(this).parents('.refinement').find('h3').addClass('expanded');\n $(this).parents('.refinement ul').show();\n\n\t\t\t\tif ($(window).width() < 768) {\n\t\t\t\t\t$('.filter-sort-nav .filter-model').addClass('expanded');\n\t\t\t\t\t$('.mobile-filter, .sort-model.mobile-true').show();\n\t\t\t\t}\n }\n });\n });\n}\n\nupdateRefinementsState();\n\nexports.init = function () {\n\tcompareWidget.init();\n\tif (SitePreferences.LISTING_INFINITE_SCROLL) {\n\t\t$(window).on('scroll', infiniteScroll);\n\t}\n\tjcarouselMc.init();\n\tproductTile.init();\n\tgiftGuide.init();\n\n\t// Initialize the einstein recommender carousel quick add button\n\tcarouselYouMayAlsoLike.init();\n\n\tinitializeEvents();\n\t\n\tvar el = document.getElementById('shop-the-collection');\n\tswipedetect(el, function (swipedir) {\n\t\t//swipedir contains either \"none\", \"left\", \"right\", \"top\", or \"down\"\n\t\tif (swipedir === 'right') {\n\t\t\t$('#shop-the-collection').parent().find('a.carousel-left').trigger('click');\n\t\t}\n\t\tif (swipedir === 'left') {\n\t\t\t$('#shop-the-collection').parent().find('a.carousel-right').trigger('click');\n\t\t}\n\t});\n\tsetTimeout(function(){\n\t\tvar elt = document.getElementById('you-may-also-like');\n\t\tswipedetect(elt, function (swipedir) {\n\t\t\t//swipedir contains either \"none\", \"left\", \"right\", \"top\", or \"down\"\n\t\t\tif (swipedir === 'right') {\n\t\t\t\t$('#you-may-also-like').parent().find('a.carousel-left').trigger('click');\n\t\t\t}\n\t\t\tif (swipedir === 'left') {\n\t\t\t\t$('#you-may-also-like').parent().find('a.carousel-right').trigger('click');\n\t\t\t}\n\t\t});\n\t}, 3000);\n\tvar elmt = document.getElementById('recently-viewed-wrapper');\n\tswipedetect(elmt, function (swipedir) {\n\t\t//swipedir contains either \"none\", \"left\", \"right\", \"top\", or \"down\"\n\t\tif (swipedir === 'right') {\n\t\t\t$('#recently-viewed-wrapper').parent().find('a.jcarousel-mc-prev').trigger('click');\n\t\t}\n\t\tif (swipedir === 'left') {\n\t\t\t$('#recently-viewed-wrapper').parent().find('a.jcarousel-mc-next').trigger('click');\n\t\t}\n\t});\n};\n\n},{\"../carousel-you-may-also-like\":5,\"../compare-widget\":6,\"../jcarousel-mc\":15,\"../product-tile\":45,\"../progress\":46,\"../util\":56,\"./giftguide\":31}],42:[function(require,module,exports){\n'use strict';\n\nvar dialog = require('../dialog');\n\nexports.init = function () {\n\t$('#homepage-slider')\n\t\t// responsive slides\n\t\t.on('jcarousel:create jcarousel:reload', function () {\n\t\t\tvar element = $(this),\n\t\t\t\twidth = element.innerWidth();\n\t\t\telement.jcarousel('items').css('width', width + 'px');\n\t\t})\n\t\t.jcarousel({\n\t\t\twrap: 'circular'\n\t\t})\n\t\t.jcarouselAutoscroll({\n\t\t\tinterval: 5000\n\t\t});\n\t$('#homepage-slider .jcarousel-control')\n\t\t.on('jcarouselpagination:active', 'a', function () {\n\t\t\t$(this).addClass('active');\n\t\t})\n\t\t.on('jcarouselpagination:inactive', 'a', function () {\n\t\t\t$(this).removeClass('active');\n\t\t})\n\t\t.jcarouselPagination({\n\t\t\titem: function (page) {\n\t\t\t\treturn '
        ' + page + '';\n\t\t\t}\n\t\t});\n\n\t$('#vertical-carousel')\n\t\t.jcarousel({\n\t\t\tvertical: true\n\t\t})\n\t\t.jcarouselAutoscroll({\n\t\t\tinterval: 5000\n\t\t});\n\t$('#vertical-carousel .jcarousel-prev')\n\t\t.on('jcarouselcontrol:active', function () {\n\t\t\t$(this).removeClass('inactive');\n\t\t})\n\t\t.on('jcarouselcontrol:inactive', function () {\n\t\t\t$(this).addClass('inactive');\n\t\t})\n\t\t.jcarouselControl({\n\t\t\ttarget: '-=1'\n\t\t});\n\n\t$('#vertical-carousel .jcarousel-next')\n\t\t.on('jcarouselcontrol:active', function () {\n\t\t\t$(this).removeClass('inactive');\n\t\t})\n\t\t.on('jcarouselcontrol:inactive', function () {\n\t\t\t$(this).addClass('inactive');\n\t\t})\n\t\t.jcarouselControl({\n\t\t\ttarget: '+=1'\n\t\t});\n\t\n\tif($('#home-more-collections-wrapper').length) {\n\t\tif($(window).width() >= 768){\n\t\t\t$('.home-more-collections__top-right_inner .blockCta').width($('.home-more-collections__bottom-right_inner .blockCta').width());\n\t\t}\n\t\t\n\t\tif($(window).width() >= 768 && $(window).width() <= 1280) {\n\t\t\tvar $homeMoreCollection = $('#home-more-collections-wrapper');\n\t\t\tvar $leftTop = $('.home-more-collections__top-left_inner');\n\t\t\tvar $rightTop = $('.home-more-collections__top-right_inner');\n\t\t\tvar $bottomLeft = $('.home-more-collections__bottom-left');\n\t\t\tvar $bottomRight = $('.home-more-collections__bottom-right_inner');\n\t\t\t\n\t\t\tvar $rightTopBottom = $rightTop.position().top + $rightTop.outerHeight(true);\n\t\t\tvar $bottomRightTop = $bottomRight.position().top;\n\t\t\t\n\t\t\t$bottomRight.css('margin-top', $rightTopBottom-$bottomRightTop+15);\n\t\t\t$bottomLeft.css('margin-top', -($rightTop.outerHeight(true)/2));\n\t\t\t$homeMoreCollection.css('height', $homeMoreCollection.outerHeight(true)-(($bottomRightTop-$rightTopBottom)/4));\n\t\t}\n\t}\n\t\n\t$('.play-icon').on('click', function (e) {\n\t\te.preventDefault();\n\t\t$('#about-us-header').css('visibility','hidden');\n\t\tdialog.open({url: this.href, options: {open: function () {\n\t\t\t$('#dialog-container').css('padding',0);\n\t\t},close: function () {\n\t\t\t\t$('#about-us-header').css('visibility','visible');\n\t\t\t}\n\t\t}});\n\t});\n\t\n\t$('.ctalink').on('click', function (e) {\n\t\te.preventDefault();\n\t\t$('#about-us-header').css('visibility','hidden');\n\t\tif($(window).width() >= 1280){\n\t\t\tdialog.open({url: this.href, options: {width: 1174, open: function () {\n\t\t\t\t\t$('#dialog-container').css('padding',0);\n\t\t\t\t},close: function () {\n\t\t\t\t\t$('#about-us-header').css('visibility','visible');\n\t\t\t\t}\n\t\t\t}});\n\t\t}else {\n\t\t\tdialog.open({url: this.href, options: {open: function () {\n\t\t\t\t$('#dialog-container').css('padding',0);\n\t\t\t},close: function () {\n\t\t\t\t$('#about-us-header').css('visibility','visible');\n\t\t\t}}});\n\t\t}\n\t\t\n\t});\n\t\n\t$(function() {\n\t\t$('#about-us-header, #our-stores-header').stickyNavbar({\n\t\t activeClass: \"active\", // Class to be added to highlight nav elements\n\t\t sectionSelector: \"scrollto\", // Class of the section that is interconnected with nav links\n\t\t animDuration: 250, // Duration of jQuery animation\n\t\t startAt: 0, // Stick the menu at XXXpx from the top of the this() (nav container)\n\t\t easing: \"linear\", // Easing type if jqueryEffects = true, use jQuery Easing plugin to extend easing types - gsgd.co.uk/sandbox/jquery/easing\n\t\t animateCSS: true, // AnimateCSS effect on/off\n\t\t animateCSSRepeat: false, // Repeat animation everytime user scrolls\n\t\t cssAnimation: \"fadeInDown\", // AnimateCSS class that will be added to selector\n\t\t jqueryEffects: false, // jQuery animation on/off\n\t\t jqueryAnim: \"slideDown\", // jQuery animation type: fadeIn, show or slideDown\n\t\t selector: \"a\", // Selector to which activeClass will be added, either \"a\" or \"li\"\n\t\t mobile: false, // If false nav will not stick under 480px width of window\n\t\t mobileWidth: 480, // The viewport width (without scrollbar) under which stickyNavbar will not be applied (due usability on mobile devices)\n\t\t zindex: 100, // The zindex value to apply to the element: default 9999, other option is \"auto\"\n\t\t stickyModeClass: \"sticky\", // Class that will be applied to 'this' in sticky mode\n\t\t unstickyModeClass: \"unsticky\" // Class that will be applied to 'this' in non-sticky mode\n\t\t });\n\t});\n};\n\n\n},{\"../dialog\":10}],43:[function(require,module,exports){\n'use strict';\nvar dialog = require('../dialog');\n\nexports.init = function () {\n\t$('.store-details-link').on('click', function (e) {\n\t\te.preventDefault();\n\t\tdialog.open({\n\t\t\turl: $(e.target).attr('href')\n\t\t});\n\t});\n\t\n\tif($('#store-location-results').length) {\n\t\t$('.store-results-hidden').focus();\n\t}\n};\n\n},{\"../dialog\":10}],44:[function(require,module,exports){\n'use strict';\n\nvar addProductToCart = require('./product/addToCart'),\n\tpage = require('../page'),\n\tutil = require('../util');\n\nexports.init = function () {\n\taddProductToCart();\n\t$('#editAddress').on('change', function () {\n\t\tpage.redirect(util.appendParamToURL(Urls.wishlistAddress, 'AddressID', $(this).val()));\n\t});\n\n\t//add js logic to remove the , from the qty feild to pass regex expression on client side\n\t$('.option-quantity-desired input').on('focusout', function () {\n\t\t$(this).val($(this).val().replace(',', ''));\n\t});\n};\n\n},{\"../page\":20,\"../util\":56,\"./product/addToCart\":32}],45:[function(require,module,exports){\n'use strict';\n\nvar imagesLoaded = require('imagesloaded'),\n\tutil = require('./util'),\n\tquickview = require('./quickview');\n\nfunction initQuickViewButtons() {\n\n\tvar options = {\n\t\tmouseEnterSelector: '.tiles-container .product-image',\n\t\tfocusSelector: '.tiles-container .product-image .thumb-link',\n\t\tkeydownSelector: '.tiles-container .product-image',\n\t\tswitchImages: true,\n\t\tcloseOnAddToCart: false\n\t}\n\tquickview.initializeButtons(options);\n}\n\nfunction gridViewToggle() {\n\t$('.toggle-grid').on('click', function () {\n\t\t$('.search-result-content').toggleClass('wide-tiles');\n\t\t$(this).toggleClass('wide');\n\t});\n}\n\n/**\n * @private\n * @function\n * @description Initializes events on the product-tile for the following elements:\n * - swatches\n * - thumbnails\n */\nfunction initializeEvents() {\n\tinitQuickViewButtons();\n\tgridViewToggle();\n\t$('.swatch-list').on('mouseleave', function () {\n\t\t// Restore current thumb image\n\t\tvar $tile = $(this).closest('.product-tile'),\n\t\t\t$thumb = $tile.find('.product-image .thumb-link img').eq(0),\n\t\t\tdata = $thumb.data('current');\n\n\t\t$thumb.attr({\n\t\t\tsrc: data.src,\n\t\t\talt: data.alt,\n\t\t\ttitle: data.title\n\t\t});\n\t});\n\t$('.swatch-list .swatch').on('click', function (e) {\n\t\te.preventDefault();\n\t\tif ($(this).hasClass('selected')) { return; }\n\n\t\tvar $tile = $(this).closest('.product-tile');\n\t\t$(this).closest('.swatch-list').find('.swatch.selected').removeClass('selected');\n\t\t$(this).addClass('selected');\n\t\t$tile.find('.thumb-link').attr('href', $(this).attr('href'));\n\t\t$tile.find('name-link').attr('href', $(this).attr('href'));\n\n\t\tvar data = $(this).children('img').filter(':first').data('thumb');\n\t\tvar $thumb = $tile.find('.product-image .thumb-link img').eq(0);\n\t\tvar currentAttrs = {\n\t\t\tsrc: data.src,\n\t\t\talt: data.alt,\n\t\t\ttitle: data.title\n\t\t};\n\t\t$thumb.attr(currentAttrs);\n\t\t$thumb.data('current', currentAttrs);\n\t}).on('mouseenter', function () {\n\t\t// get current thumb details\n\t\tvar $tile = $(this).closest('.product-tile'),\n\t\t\t$thumb = $tile.find('.product-image .thumb-link img').eq(0),\n\t\t\tdata = $(this).children('img').filter(':first').data('thumb'),\n\t\t\tcurrent = $thumb.data('current');\n\n\t\t// If this is the first time, then record the current img\n\t\tif (!current) {\n\t\t\t$thumb.data('current', {\n\t\t\t\tsrc: $thumb[0].src,\n\t\t\t\talt: $thumb[0].alt,\n\t\t\t\ttitle: $thumb[0].title\n\t\t\t});\n\t\t}\n\n\t\t// Set the tile image to the values provided on the swatch data attributes\n\t\t$thumb.attr({\n\t\t\tsrc: data.src,\n\t\t\talt: data.alt,\n\t\t\ttitle: data.title\n\t\t});\n\t});\n}\n\nexports.init = function () {\n\tvar $tiles = $('.tiles-container .product-tile');\n\tif ($tiles.length === 0) { return; }\n\timagesLoaded('.tiles-container').on('done', function () {\n\t\t$tiles.syncHeight()\n\t\t\t.each(function (idx) {\n\t\t\t\t$(this).data('idx', idx);\n\t\t\t});\n\t});\n\tinitializeEvents();\n};\n\n},{\"./quickview\":47,\"./util\":56,\"imagesloaded\":61}],46:[function(require,module,exports){\n'use strict';\n\nvar $loader;\n\n/**\n * @function\n * @description Shows an AJAX-loader on top of a given container\n * @param {Element} container The Element on top of which the AJAX-Loader will be shown\n */\nvar show = function (container) {\n\tvar target = (!container || $(container).length === 0) ? $('body') : $(container);\n\t$loader = $loader || $('.loader');\n\n\tif ($loader.length === 0) {\n\t\t$loader = $('
        ').addClass('loader')\n\t\t\t.append($('
        ').addClass('loader-indicator'), $('
        ').addClass('loader-bg'));\n\t}\n\treturn $loader.appendTo(target).show();\n};\n/**\n * @function\n * @description Hides an AJAX-loader\n */\nvar hide = function () {\n\tif ($loader) {\n\t\t$loader.hide();\n\t}\n};\n\nexports.show = show;\nexports.hide = hide;\n\n},{}],47:[function(require,module,exports){\n'use strict';\n\nvar dialog = require('./dialog'),\n\tproduct = require('./pages/product'),\n\tutil = require('./util'),\n\tjcarouselMc = require('./jcarousel-mc');\n\n\nvar makeUrl = function (url, source, productListID, closeOnAddToCart) {\n\tif (source) {\n\t\turl = util.appendParamToURL(url, 'source', source);\n\t}\n\tif (productListID) {\n\t\turl = util.appendParamToURL(url, 'productlistid', productListID);\n\t}\n\tif(closeOnAddToCart !== undefined && closeOnAddToCart !== null) {\n\t\turl = util.appendParamToURL(url, 'closeOnAddToCart', closeOnAddToCart);\n\t} else {\n\t\turl = util.appendParamToURL(url, 'closeOnAddToCart', \"false\");\n\t}\n\treturn url;\n};\n\nvar removeParam = function (url) {\n\tif (url.indexOf('?') !== -1) {\n\t\treturn url.substring(0, url.indexOf('?'));\n\t} else {\n\t\treturn url;\n\t}\n};\n\nvar switchThumb = function($ele){\n\tif(util.isMobile()) return;\n\tvar overThumbUrl = $ele.data(\"overthumburl\"),\n\t\tsrc = $ele.find(\"img\").attr(\"src\");\n\tif(overThumbUrl.length){\n\t\t$ele.data(\"overthumburl\", src);\n\t\t$ele.find(\"img\").attr(\"src\", overThumbUrl);\n\t}\n}\n\nvar quickview = {\n\tinit: function () {\n\t\tif (!this.exists()) {\n\t\t\tthis.$container = $('
        ').attr('id', 'QuickViewDialog').appendTo(document.body);\n\t\t\t\n\t\t}\n\t\tthis.productLinks = $('#search-result-items .thumb-link').map(function (index, thumbLink) {\n\t\t\treturn $(thumbLink).attr('href');\n\t\t});\n\t},\n\n\tsetup: function (qvUrl) {\n\t\tvar $btnNext = $('.quickview-next'),\n\t\t\t$btnPrev = $('.quickview-prev');\n\n\t\tproduct.initializeEvents();\n\n\t\t// hide the buttons on the compare page or when there are no other products\n\t\tif (this.productLinks.length <= 1 || $('.compareremovecell').length > 0) {\n\t\t\t$btnNext.hide();\n\t\t\t$btnPrev.hide();\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.productLinkIndex === this.productLinks.length - 1) {\n\t\t\t$btnNext.attr('disabled', 'disabled');\n\t\t}\n\t\tif (this.productLinkIndex === 0) {\n\t\t\t$btnPrev.attr('disabled', 'disabled');\n\t\t}\n\n\t\t$btnNext.on('click', function (e) {\n\t\t\te.preventDefault();\n\t\t\tthis.navigateQuickview(1);\n\t\t}.bind(this));\n\t\t$btnPrev.on('click', function (e) {\n\t\t\te.preventDefault();\n\t\t\tthis.navigateQuickview(-1);\n\t\t}.bind(this));\n\t\t\n\t\tif ($(window).width() > 767) {\n\t\t\t$('#QuickViewDialog .wrap-product-thumbnails .jcarousel').jcarousel({\n\t\t\t\tvertical: true\n\t\t\t});\n\t\t}\n\n\t\t$('#QuickViewDialog .wrap-product-thumbnails .jcarousel-control-prev')\n\t\t\t.on('jcarouselcontrol:active', function() {\n\t\t\t\t$(this).removeClass('inactive');\n\t\t\t})\n\t\t\t.on('jcarouselcontrol:inactive', function() {\n\t\t\t\t$(this).addClass('inactive');\n\t\t\t})\n\t\t\t.jcarouselControl({\n\t\t\t\ttarget: '-=1'\n\t\t\t});\n\n\t\t$('#QuickViewDialog .wrap-product-thumbnails .jcarousel-control-next')\n\t\t\t.on('jcarouselcontrol:active', function() {\n\t\t\t\t$(this).removeClass('inactive');\n\t\t\t})\n\t\t\t.on('jcarouselcontrol:inactive', function() {\n\t\t\t\t$(this).addClass('inactive');\n\t\t\t})\n\t\t\t.jcarouselControl({\n\t\t\t\ttarget: '+=1'\n\t\t\t});\n\n\t\t$('#QuickViewDialog .wrap-product-thumbnails .jcarousel-pagination')\n\t\t\t.on('jcarouselpagination:active', 'a', function() {\n\t\t\t\t$(this).addClass('active');\n\t\t\t})\n\t\t\t.on('jcarouselpagination:inactive', 'a', function() {\n\t\t\t\t$(this).removeClass('active');\n\t\t\t})\n\t\t\t.jcarouselPagination();\n\n\t\t// If there are less than 5 thumbnails, do not show the carousel controls - only for QuickView\n\t\tif ($(\"#QuickViewDialog .wrap-product-thumbnails ul li\").length <= 4) {\n\t\t\t$(\"#QuickViewDialog .wrap-product-thumbnails .jcarousel-control-prev\").hide();\n\t\t\t$(\"#QuickViewDialog .wrap-product-thumbnails .jcarousel-control-next\").hide();\n\t\t}\n\t},\n\n\t/**\n\t * @param {Number} step - How many products away from current product to navigate to. Negative number means navigate backward\n\t */\n\tnavigateQuickview: function (step) {\n\t\t// default step to 0\n\t\tthis.productLinkIndex += (step ? step : 0);\n\t\tvar url = makeUrl(this.productLinks[this.productLinkIndex], 'quickview');\n\t\tdialog.replace({\n\t\t\turl: url,\n\t\t\tcallback: this.setup.bind(this, url)\n\t\t});\n\t},\n\n\t/**\n\t * @description show quick view dialog\n\t * @param {Object} options\n\t * @param {String} options.url - url of the product details\n\t * @param {String} options.source - source of the dialog to be appended to URL\n\t * @param {String} options.productlistid - to be appended to URL\n\t * @param {Boolean} options.closeOnAddToCart - to be appended to URL\n\t * @param {Function} options.callback - callback once the dialog is opened\n\t */\n\tshow: function (options) {\n\t\tvar url;\n\t\tif (!this.exists()) {\n\t\t\tthis.init();\n\t\t}\n\t\turl = makeUrl(options.url, options.source, options.productlistid, options.closeOnAddToCart);\n\t\t\n\t\tdialog.open({\n\t\t\ttarget: this.$container,\n\t\t\turl: url,\n\t\t\tcallback: function() {\n\t\t\t\t// Add timeout to refresh the sitevibes events after the quickview is opened if the\n\t\t\t\t// sitevibes pixel script is present. It could be disabled in the BM\n\t\t\t\tvar _svTarget = $('#sv-pixel-script');\n\t\t\t\tif (_svTarget.length > 0) {\n\t\t\t\t\t// This snippet was given to us by SiteVibes to re-execute their page scan\n\t\t\t\t\tSiteVibesEvents.pageRefresh();\n\t\t\t\t}\n\t\t\t},\n\t\t\toptions: {\n\t\t\t\twidth: 1174,\n\t\t\t\ttitle: Resources.QUICK_VIEW_POPUP,\n\t\t\t\topen: function () {\n\t\t\t\t\tthis.setup(url);\n\t\t\t\t\tif (typeof options.callback === 'function') { options.callback(); }\n\t\t\t\t\tif (typeof window.MyRegistryIntegrationScriptSnippet === \"function\") {\n\t\t\t\t\t\t// Reinitialize the My Registry \"Add To Registry\" when quickview is opened\n\t\t\t\t\t\twindow.MyRegistryIntegrationScriptSnippet();\n\t\t\t\t\t}\n\t\t\t\t\t$(\".afterpay-info-icon\").on('click', function (e) {\n\t\t\t\t\t\tvar popup = $(\".afterpay-custom-modal\").dialog({\n\t\t\t\t\t\t\tautoOpen: false,\n\t\t\t\t\t\t\twidth: 775,\n\t\t\t\t\t\t\theight: 775,\n\t\t\t\t\t\t\tdialogClass: 'afterpay-custom',\n\t\t\t\t\t\t\tmodal: true,\n\t\t\t\t\t\t\tclose: function () {\n\t\t\t\t\t\t\t\t$(this).dialog('destroy');\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t\tpopup.dialog(\"open\");\n\t\t\t\t\t});\n\t\t\t\t}.bind(this),\n\t\t\t\tposition: {\n\t\t\t\t\tmy: 'center top',\n\t\t\t\t\tat: 'center center',\n\t\t\t\t\tof: window,\n\t\t\t\t\tcollision: 'flipfit'\n\t\t\t\t}\n\n\t\t\t}\n\n\n\t\t});\n\n\t\t$('.ui-dialog').addClass('quickview-dialog');\n\t},\n\texists: function () {\n\t\treturn this.$container && (this.$container.length > 0);\n\t},\n\n\t/**\n\t * @description initialize quickview buttons on elements.\n\t * @param {Object} options\n\t * @param {String} options.mouseEnterSelector - jQuey selector for the mouseEnter event\n\t * @param {String} options.keydownSelector - jQuey selector for the keydown event\n\t * @property {Boolean} options.switchImages - flag to swap images with alts or not, default = true\n\t * @property {Boolean} closeOnAddToCart - flag to close quick add pop up when add to cart clicked set in the ISML, default = false\n\t * @property {Boolean} disableQuickView - flag to disable the quick view capability (not show) set in ISML, default = false\n\t */\n\tinitializeButtons: function( options ) {\n\t\tvar mouseEnterSelector = options.mouseEnterSelector;\n\t\tvar keydownSelector = options.keydownSelector;\n\n\t\t// Check to make sure closeOnAddToCart is defined or not and set a default if not defined or is null\n\t\tvar _closeOnAddToCart = typeof closeOnAddToCart !== 'undefined' && closeOnAddToCart !== null ? closeOnAddToCart : false;\n\n\t\t// Check to make sure disableQuickView is defined or not and set a default if not defined or is null\n\t\tvar _disableQuickView = typeof disableQuickView !== 'undefined' && disableQuickView !== null ? disableQuickView : false;\n\n\t\tvar gtm = require('./gtm');\n\t\t\t$('.view-full-details')\n\t\t\t\t.on({\n\t\t\t\t\tclick: gtm.eccViewItemOnClick\n \t\t });\n\n\t\t// Mouse Enter\n\t\t$(mouseEnterSelector).on('mouseenter focus', function (e) {\n\t\t\t// Grab the link first to get the data-* attributes to use for toggles (i.e. disable, swap images, etc)\n\t\t\tvar $link = $(this).find('.thumb-link');\n\n\t\t\t// Get and Set up the Quick View Button\n\t\t\tvar $qvButton = $('#quickviewbutton');\n\t\t\tif ($qvButton.length === 0 && !_disableQuickView && !Boolean($link.data('disablequickview'))) {\n\t\t\t\t$qvButton = $('' + Resources.QUICK_VIEW + '');\n\t\t\t}\n\t\t\t$qvButton.attr({\n\t\t\t\t'href': $link.attr('href'),\n\t\t\t\t'title': $link.attr('title')\n\t\t\t}).appendTo(this);\n\n\t\t\tvar gtm = require('./gtm');\n\t\t\t$qvButton\n\t\t\t\t.on('click', function (e) {\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\ttry {\n\t\t\t\t\t\tvar productID = $link.data('productid');\n\t\t\t\t\t\tvar itemListProperty = $link.data('gtmsrc');\n\t\t\t\t\t\tif (itemListProperty === 'PLP') {\t\t\t\t\t\n\t\t\t\t\t\t\titemListProperty = gtm.getListNameFromExisistingTag(productID);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tvar gtmUrl = $link.data('gtmurl') + '?productlistattribute=' + itemListProperty + '&productID=' + productID + '&isquickview=true';\n\t\t\t\t\t\t$.ajax({\n\t\t\t\t\t\t\turl: gtmUrl,\n\t\t\t\t\t\t\ttype: 'get',\n\t\t\t\t\t\t\tsuccess: function (response) {\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tif (response.success && response.ecc_select_item !== null) {\n\t\t\t\t\t\t\t\t\t\tdataLayer.push(response.ecc_select_item);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\t\t\t\t// This protects the case that an item does not have a list name already in the dataLayer. For example, when a cutoff is made to the maximum amount of items in the dataLayer the item might not be found to obtain its list name.\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t})\n\t\t\t\t\t} catch(e) {\n\t\t\t\t\t\t// This protects the case that an item does not have a list name already in the dataLayer. For example, when a cutoff is made to the maximum amount of items in the dataLayer the item might not be found to obtain its list name.\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t\t.on('click', function (e) {\n\t\t\t\te.preventDefault();\n\t\t\t\tquickview.show({\n\t\t\t\t\turl: $(this).attr('href'),\n\t\t\t\t\tsource: 'quickview',\n\t\t\t\t\tcloseOnAddToCart: _closeOnAddToCart\n\t\t\t\t});\n\t\t\t});\n\n\t\t\t// Swap images if the data attribute is true\n\t\t\tBoolean($link.data('swapqvimages')) ? switchThumb($link) : null;\n\t\t}).on('mouseleave', function() {\n\t\t\tvar $link = $(this).find('.thumb-link');\n\t\t\tBoolean($link.data('swapqvimages')) ? switchThumb($link) : null;\n\t\t\t$('#quickviewbutton').remove();\n\t\t}).on('focusout', function() {\n\t\t\tvar $link = $(this).find('.thumb-link');\n\t\t\tBoolean($link.data('swapqvimages')) ? switchThumb($link) : null;\n\t\t\t$('#quickviewbutton').remove();\n\t\t});\n\n\t\t// Keydown\n\t\t$(keydownSelector).on('keydown', function(e){\n\t\t\tvar $qvButton = $('#quickviewbutton');\n\t\t\tvar keyCode = e.keyCode || e.which;\n\t\t\tif ($qvButton.length > 0) {\n\t\t\t\tif (keyCode == '13' || keyCode == '32') {\n\t\t\t\t\t$('.quickview').click();\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n};\n\nmodule.exports = quickview;\n\n},{\"./dialog\":10,\"./gtm\":14,\"./jcarousel-mc\":15,\"./pages/product\":35,\"./util\":56}],48:[function(require,module,exports){\n'use strict';\n\n/**\n * copied from https://github.com/darkskyapp/string-hash\n */\nfunction hashFn(str) {\n\tvar hash = 5381,\n\t\ti = str.length;\n\n\twhile (i) {\n\t\thash = (hash * 33) ^ str.charCodeAt(--i);\n\t}\n\t/* JavaScript does bitwise operations (like XOR, above) on 32-bit signed\n\t* integers. Since we want the results to be always positive, convert the\n\t* signed int to an unsigned by doing an unsigned bitshift. */\n\treturn hash >>> 0;\n}\n\n/**\n * Create rating based on hash ranging from 2-5\n * @param pid\n */\nfunction getRating(pid) {\n\treturn hashFn(pid.toString()) % 30 / 10 + 2;\n}\n\nmodule.exports = {\n\tinit: function () {\n\t\t$('.product-review').each(function (index, review) {\n\t\t\tvar pid = $(review).data('pid');\n\t\t\tif (!pid) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// rating range from 2 - 5\n\t\t\tvar rating = getRating(pid);\n\t\t\tvar baseRating = Math.floor(rating);\n\t\t\tvar starsCount = 0;\n\t\t\tfor (var i = 0; i < baseRating; i++) {\n\t\t\t\t$('.rating', review).append('');\n\t\t\t\tstarsCount++;\n\t\t\t}\n\t\t\t// give half star for anything in between\n\t\t\tif (rating > baseRating) {\n\t\t\t\t$('.rating', review).append('');\n\t\t\t\tstarsCount++;\n\t\t\t}\n\t\t\tif (starsCount < 5) {\n\t\t\t\tfor (var j = 0; j < 5 - starsCount; j++) {\n\t\t\t\t\t$('.rating', review).append('');\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n};\n\n},{}],49:[function(require,module,exports){\n'use strict';\n\n/**\n * @private\n * @function\n * @description Binds event to the place holder (.blur)\n */\nfunction initializeEvents() {\n var isMobile = window.matchMedia('only screen and (max-width: 767px)').matches;\n var placeHolder = $('.q').attr('placeholder');\n\n $('.q')\n .focus(function () {\n var input = $(this);\n if (input.val() === input.attr('placeholder')) {\n input.val('');\n input.attr('placeholder', placeHolder);\n }\n })\n .blur(function () {\n var input = $(this);\n if (input.val() === '' || input.val() === input.attr('placeholder')) {\n if (!isMobile) {\n input.attr('placeholder', '');\n }\n }\n })\n .blur();\n}\n\nexports.init = initializeEvents;\n\n},{}],50:[function(require,module,exports){\n'use strict';\n\nvar util = require('./util');\n\nvar currentQuery = null,\n\tlastQuery = null,\n\trunningQuery = null,\n\tlistTotal = -1,\n\tlistCurrent = -1,\n\tdelay = 30,\n\t$resultsContainer;\n/**\n * @function\n * @description Handles keyboard's arrow keys\n * @param keyCode Code of an arrow key to be handled\n */\nfunction handleArrowKeys(keyCode) {\n\tswitch (keyCode) {\n\t\tcase 38:\n\t\t\t// keyUp\n\t\t\tlistCurrent = (listCurrent <= 0) ? (listTotal - 1) : (listCurrent - 1);\n\t\t\tbreak;\n\t\tcase 40:\n\t\t\t// keyDown\n\t\t\tlistCurrent = (listCurrent >= listTotal - 1) ? 0 : listCurrent + 1;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\t// reset\n\t\t\tlistCurrent = -1;\n\t\t\treturn false;\n\t}\n\n\t$resultsContainer.children().removeClass('selected').eq(listCurrent).addClass('selected');\n\t$('input[name=\"q\"]').val($resultsContainer.find('.selected .suggestionterm').first().text());\n\treturn true;\n}\n\nvar searchsuggest = {\n\t/**\n\t * @function\n\t * @description Configures parameters and required object instances\n\t */\n\tinit: function (container, defaultValue) {\n\t\tvar $searchContainer = $(container);\n\t\tvar $searchForm = $searchContainer.find('form[name=\"simpleSearch\"]');\n\t\tvar $searchField = $searchForm.find('input[name=\"q\"]');\n\n\t\t// disable browser auto complete\n\t\t$searchField.attr('autocomplete', 'off');\n\n\t\t// on focus listener (clear default value)\n\t\t$searchField.focus(function () {\n\t\t\tif (!$resultsContainer) {\n\t\t\t\t// create results container if needed\n\t\t\t\t$resultsContainer = $('
        ').attr('id', 'search-suggestions').appendTo($searchContainer);\n\t\t\t}\n\t\t\tif ($searchField.val() === defaultValue) {\n\t\t\t\t$searchField.val('');\n\t\t\t}\n\t\t});\n\t\t// on blur listener\n\t\t$(document).on('click', function (e) {\n\t\t\tif (!$searchContainer.is(e.target) && $searchContainer.has(e.target).length === 0) {\n\t\t\t\tsetTimeout(this.clearResults, 200);\n\t\t\t}\n\t\t}.bind(this));\n\t\t// on key up listener\n\t\t$searchField.keyup(function (e) {\n\n\t\t\t// get keyCode (window.event is for IE)\n\t\t\tvar keyCode = e.keyCode || window.event.keyCode;\n\n\t\t\t// check and treat up and down arrows\n\t\t\tif (handleArrowKeys(keyCode)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// check for an ENTER or ESC\n\t\t\tif (keyCode === 13 || keyCode === 27) {\n\t\t\t\tthis.clearResults();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcurrentQuery = $searchField.val().trim();\n\n\t\t\t// no query currently running, init a update\n\t\t\tif (runningQuery === null) {\n\t\t\t\trunningQuery = currentQuery;\n\t\t\t\tsetTimeout(this.suggest.bind(this), delay);\n\t\t\t}\n\t\t}.bind(this));\n\t},\n\n\t/**\n\t * @function\n\t * @description trigger suggest action\n\t */\n\tsuggest: function () {\n\t\t// check whether query to execute (runningQuery) is still up to date and had not changed in the meanwhile\n\t\t// (we had a little delay)\n\t\tif (runningQuery !== currentQuery) {\n\t\t\t// update running query to the most recent search phrase\n\t\t\trunningQuery = currentQuery;\n\t\t}\n\n\t\t// if it's empty clear the results box and return\n\t\tif (runningQuery.length === 0) {\n\t\t\tthis.clearResults();\n\t\t\trunningQuery = null;\n\t\t\treturn;\n\t\t}\n\n\t\t// if the current search phrase is the same as for the last suggestion call, just return\n\t\t/*if (lastQuery === runningQuery) {\n\t\t\trunningQuery = null;\n\t\t\treturn;\n\t\t}*/\n\n\t\t// build the request url\n\t\tvar reqUrl = util.appendParamToURL(Urls.searchsuggest, 'q', runningQuery);\n\t\treqUrl = util.appendParamToURL(reqUrl, 'legacy', 'false');\n\n\t\t// execute server call\n\t\t$.get(reqUrl, function (data) {\n\t\t\tvar suggestionHTML = data,\n\t\t\t\tansLength = suggestionHTML.trim().length;\n\n\t\t\t// if there are results populate the results div\n\t\t\tif (ansLength === 0) {\n\t\t\t\tthis.clearResults();\n\t\t\t} else {\n\t\t\t\t// update the results div\n\t\t\t\t$resultsContainer.html(suggestionHTML).fadeIn(200);\n\t\t\t}\n\n\t\t\t// record the query that has been executed\n\t\t\tlastQuery = runningQuery;\n\t\t\t// reset currently running query\n\t\t\trunningQuery = null;\n\n\t\t\t// check for another required update (if current search phrase is different from just executed call)\n\t\t\tif (currentQuery !== lastQuery) {\n\t\t\t\t// ... and execute immediately if search has changed while this server call was in transit\n\t\t\t\trunningQuery = currentQuery;\n\t\t\t\tsetTimeout(this.suggest.bind(this), delay);\n\t\t\t}\n\t\t\tthis.hideLeftPanel();\n\t\t}.bind(this));\n\t},\n\t/**\n\t * @function\n\t * @description\n\t */\n\tclearResults: function () {\n\t\tif (!$resultsContainer) { return; }\n\t\t$resultsContainer.fadeOut(200, function () {$resultsContainer.empty();});\n\t},\n\t/**\n\t * @function\n\t * @description\n\t */\n\thideLeftPanel: function () {\n\t\t//hide left panel if there is only a matching suggested custom phrase\n\t\tif ($('.search-suggestion-left-panel-hit').length === 1 && $('.search-phrase-suggestion a').text().replace(/(^[\\s]+|[\\s]+$)/g, '').toUpperCase() === $('.search-suggestion-left-panel-hit a').text().toUpperCase()) {\n\t\t\t$('.search-suggestion-left-panel').css('display', 'none');\n\t\t\t$('.search-suggestion-wrapper-full').addClass('search-suggestion-wrapper');\n\t\t\t$('.search-suggestion-wrapper').removeClass('search-suggestion-wrapper-full');\n\t\t}\n\t}\n};\n\nmodule.exports = searchsuggest;\n\n},{\"./util\":56}],51:[function(require,module,exports){\n'use strict';\n\nvar util = require('./util');\n\nvar qlen = 0,\n\tlistTotal = -1,\n\tlistCurrent = -1,\n\tdelay = 300,\n\tfieldDefault = null,\n\tsuggestionsJson = null,\n\t$searchForm,\n\t$searchField,\n\t$searchContainer,\n\t$resultsContainer;\n/**\n * @function\n * @description Handles keyboard's arrow keys\n * @param keyCode Code of an arrow key to be handled\n */\nfunction handleArrowKeys(keyCode) {\n\tswitch (keyCode) {\n\t\tcase 38:\n\t\t\t// keyUp\n\t\t\tlistCurrent = (listCurrent <= 0) ? (listTotal - 1) : (listCurrent - 1);\n\t\t\tbreak;\n\t\tcase 40:\n\t\t\t// keyDown\n\t\t\tlistCurrent = (listCurrent >= listTotal - 1) ? 0 : listCurrent + 1;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\t// reset\n\t\t\tlistCurrent = -1;\n\t\t\treturn false;\n\t}\n\n\t$resultsContainer.children().removeClass('selected').eq(listCurrent).addClass('selected');\n\t$searchField.val($resultsContainer.find('.selected .suggestionterm').first().text());\n\treturn true;\n}\nvar searchsuggest = {\n\t/**\n\t * @function\n\t * @description Configures parameters and required object instances\n\t */\n\tinit: function (container, defaultValue) {\n\t\t// initialize vars\n\t\t$searchContainer = $(container);\n\t\t$searchForm = $searchContainer.find('form[name=\"simpleSearch\"]');\n\t\t$searchField = $searchForm.find('input[name=\"q\"]');\n\t\tfieldDefault = defaultValue;\n\n\t\t// disable browser auto complete\n\t\t$searchField.attr('autocomplete', 'off');\n\n\t\t// on focus listener (clear default value)\n\t\t$searchField.focus(function () {\n\t\t\tif (!$resultsContainer) {\n\t\t\t\t// create results container if needed\n\t\t\t\t$resultsContainer = $('
        ').attr('id', 'suggestions').appendTo($searchContainer).css({\n\t\t\t\t\t'top': $searchContainer[0].offsetHeight,\n\t\t\t\t\t'left': 0,\n\t\t\t\t\t'width': $searchField[0].offsetWidth\n\t\t\t\t});\n\t\t\t}\n\t\t\tif ($searchField.val() === fieldDefault) {\n\t\t\t\t$searchField.val('');\n\t\t\t}\n\t\t});\n\t\t// on blur listener\n\t\t$searchField.blur(function () {\n\t\t\tsetTimeout(this.clearResults, 200);\n\t\t}.bind(this));\n\t\t// on key up listener\n\t\t$searchField.keyup(function (e) {\n\n\t\t\t// get keyCode (window.event is for IE)\n\t\t\tvar keyCode = e.keyCode || window.event.keyCode;\n\n\t\t\t// check and treat up and down arrows\n\t\t\tif (handleArrowKeys(keyCode)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// check for an ENTER or ESC\n\t\t\tif (keyCode === 13 || keyCode === 27) {\n\t\t\t\tthis.clearResults();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tvar lastVal = $searchField.val();\n\n\t\t\t// if is text, call with delay\n\t\t\tsetTimeout(function () {\n\t\t\t\tthis.suggest(lastVal);\n\t\t\t}.bind(this), delay);\n\t\t}.bind(this));\n\t\t// on submit we do not submit the form, but change the window location\n\t\t// in order to avoid https to http warnings in the browser\n\t\t// only if it's not the default value and it's not empty\n\t\t$searchForm.submit(function (e) {\n\t\t\te.preventDefault();\n\t\t\tvar searchTerm = $searchField.val();\n\t\t\tif (searchTerm === fieldDefault || searchTerm.length === 0) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\twindow.location = util.appendParamToURL($(this).attr('action'), 'q', searchTerm);\n\t\t});\n\t},\n\n\t/**\n\t * @function\n\t * @description trigger suggest action\n\t * @param lastValue\n\t */\n\tsuggest: function (lastValue) {\n\t\t// get the field value\n\t\tvar part = $searchField.val();\n\n\t\t// if it's empty clear the resuts box and return\n\t\tif (part.length === 0) {\n\t\t\tthis.clearResults();\n\t\t\treturn;\n\t\t}\n\n\t\t// if part is not equal to the value from the initiated call,\n\t\t// or there were no results in the last call and the query length\n\t\t// is longer than the last query length, return\n\t\t// #TODO: improve this to look at the query value and length\n\t\tif ((lastValue !== part) || (listTotal === 0 && part.length > qlen)) {\n\t\t\treturn;\n\t\t}\n\t\tqlen = part.length;\n\n\t\t// build the request url\n\t\tvar reqUrl = util.appendParamToURL(Urls.searchsuggest, 'q', part);\n\t\treqUrl = util.appendParamToURL(reqUrl, 'legacy', 'true');\n\n\t\t// get remote data as JSON\n\t\t$.getJSON(reqUrl, function (data) {\n\t\t\t// get the total of results\n\t\t\tvar suggestions = data,\n\t\t\t\tansLength = suggestions.length;\n\n\t\t\t// if there are results populate the results div\n\t\t\tif (ansLength === 0) {\n\t\t\t\tthis.clearResults();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsuggestionsJson = suggestions;\n\t\t\tvar html = '';\n\t\t\tfor (var i = 0; i < ansLength; i++) {\n\t\t\t\thtml += '
        ' + suggestions[i].suggestion + '
        ' + suggestions[i].hits + '
        ';\n\t\t\t}\n\n\t\t\t// update the results div\n\t\t\t$resultsContainer.html(html).show().on('hover', 'div', function () {\n\t\t\t\t$(this).toggleClass = 'selected';\n\t\t\t}).on('click', 'div', function () {\n\t\t\t\t// on click copy suggestion to search field, hide the list and submit the search\n\t\t\t\t$searchField.val($(this).children('.suggestionterm').text());\n\t\t\t\tthis.clearResults();\n\t\t\t\t$searchForm.trigger('submit');\n\t\t\t}.bind(this));\n\t\t}.bind(this));\n\t},\n\t/**\n\t * @function\n\t * @description\n\t */\n\tclearResults: function () {\n\t\tif (!$resultsContainer) { return; }\n\t\t$resultsContainer.empty().hide();\n\t}\n};\n\nmodule.exports = searchsuggest;\n\n},{\"./util\":56}],52:[function(require,module,exports){\n'use strict';\n\nvar inventory = require('./');\n\nvar cartInventory = {\n\tsetSelectedStore: function (storeId) {\n\t\tvar $selectedStore = $('.store-tile.' + storeId),\n\t\t\t$lineItem = $('.cart-row[data-uuid=\"' + this.uuid + '\"]'),\n\t\t\tstoreAddress = $selectedStore.find('.store-address').html(),\n\t\t\tstoreStatus = $selectedStore.find('.store-status').data('status'),\n\t\t\tstoreStatusText = $selectedStore.find('.store-status').text();\n\t\tthis.selectedStore = storeId;\n\n\t\t$lineItem.find('.instore-delivery .selected-store-address')\n\t\t\t.data('storeId', storeId)\n\t\t\t.attr('data-store-id', storeId)\n\t\t\t.html(storeAddress);\n\t\t$lineItem.find('.instore-delivery .selected-store-availability')\n\t\t\t.data('status', storeStatus)\n\t\t\t.attr('data-status', storeStatus)\n\t\t\t.text(storeStatusText);\n\t\t$lineItem.find('.instore-delivery .delivery-option').removeAttr('disabled').trigger('click');\n\t},\n\tcartSelectStore: function (selectedStore) {\n\t\tvar self = this;\n\t\tinventory.getStoresInventory(this.uuid).then(function (stores) {\n\t\t\tinventory.selectStoreDialog({\n\t\t\t\tstores: stores,\n\t\t\t\tselectedStoreId: selectedStore,\n\t\t\t\tselectedStoreText: Resources.SELECTED_STORE,\n\t\t\t\tcontinueCallback: function () {},\n\t\t\t\tselectStoreCallback: self.setSelectedStore.bind(self)\n\t\t\t});\n\t\t}).done();\n\t},\n\tsetDeliveryOption: function (value, storeId) {\n\t\t// set loading state\n\t\t$('.item-delivery-options')\n\t\t\t.addClass('loading')\n\t\t\t.children().hide();\n\n\t\tvar data = {\n\t\t\tplid: this.uuid,\n\t\t\tstorepickup: (value === 'store' ? true : false)\n\t\t};\n\t\tif (value === 'store') {\n\t\t\tdata.storepickup = true;\n\t\t\tdata.storeid = storeId;\n\t\t} else {\n\t\t\tdata.storepickup = false;\n\t\t}\n\t\t$.ajax({\n\t\t\turl: Urls.setStorePickup,\n\t\t\tdata: data,\n\t\t\tsuccess: function () {\n\t\t\t\t// remove loading state\n\t\t\t\t$('.item-delivery-options')\n\t\t\t\t\t.removeClass('loading')\n\t\t\t\t\t.children().show();\n\t\t\t}\n\t\t});\n\t},\n\tinit: function () {\n\t\tvar self = this;\n\t\t$('.item-delivery-options .set-preferred-store').on('click', function (e) {\n\t\t\te.preventDefault();\n\t\t\tself.uuid = $(this).data('uuid');\n\t\t\tvar selectedStore = $(this).closest('.instore-delivery').find('.selected-store-address').data('storeId');\n\t\t\tif (!User.zip) {\n\t\t\t\tinventory.zipPrompt(function () {\n\t\t\t\t\tself.cartSelectStore(selectedStore);\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tself.cartSelectStore(selectedStore);\n\t\t\t}\n\t\t});\n\t\t$('.item-delivery-options .delivery-option').on('click', function () {\n\t\t\t// reset the uuid\n\t\t\tvar selectedStore = $(this).closest('.instore-delivery').find('.selected-store-address').data('storeId');\n\t\t\tself.uuid = $(this).closest('.cart-row').data('uuid');\n\t\t\tself.setDeliveryOption($(this).val(), selectedStore);\n\t\t});\n\t}\n};\n\nmodule.exports = cartInventory;\n\n},{\"./\":53}],53:[function(require,module,exports){\n'use strict';\n\nvar _ = require('lodash'),\n\tdialog = require('../dialog'),\n\tTPromise = require('promise'),\n\tutil = require('../util');\n\nvar newLine = '\\n';\nvar storeTemplate = function (store, selectedStoreId, selectedStoreText) {\n\treturn [\n\t\t'
      • ',\n\t\t'\t

        ',\n\t\t'\t\t' + store.address1 + '
        ',\n\t\t'\t\t' + store.city + ', ' + store.stateCode + ' ' + store.postalCode,\n\t\t'\t

        ',\n\t\t'\t

        ' + store.status + '

        ',\n\t\t'\t',\n\t\t'
      • '\n\t].join(newLine);\n};\n\nvar storeListTemplate = function (stores, selectedStoreId, selectedStoreText) {\n\tif (stores && stores.length) {\n\t\treturn [\n\t\t\t'
        ',\n\t\t\t'
          ',\n\t\t\t_.map(stores, function (store) {\n\t\t\t\treturn storeTemplate(store, selectedStoreId, selectedStoreText);\n\t\t\t}).join(newLine),\n\t\t\t'
        ',\n\t\t\t'
        ',\n\t\t\t'
        ',\n\t\t\t'
        '\n\t\t].join(newLine);\n\t} else {\n\t\treturn '
        ' + Resources.INVALID_ZIP + '
        ';\n\t}\n};\n\nvar zipPromptTemplate = function () {\n\treturn [\n\t\t'
        ',\n\t\t'\t',\n\t\t'
        '\n\t].join(newLine);\n};\n\n/**\n * @description test whether zipcode is valid for either US or Canada\n * @return {Boolean} true if the zipcode is valid for either country, false if it's invalid for both\n **/\nvar validateZipCode = function (zipCode) {\n\tvar regexes = {\n\t\tcanada: /^[ABCEGHJKLMNPRSTVXY]\\d[ABCEGHJKLMNPRSTVWXYZ]( )?\\d[ABCEGHJKLMNPRSTVWXYZ]\\d$/i,\n\t\tusa: /^\\d{5}(-\\d{4})?$/\n\t},\n\t\tvalid = false;\n\tif (!zipCode) { return; }\n\t_.each(regexes, function (re) {\n\t\tvar regexp = new RegExp(re);\n\t\tvalid = regexp.test(zipCode);\n\t});\n\treturn valid;\n};\n\nvar storeinventory = {\n\tzipPrompt: function (callback) {\n\t\tvar self = this;\n\t\tdialog.open({\n\t\t\thtml: zipPromptTemplate(),\n\t\t\toptions: {\n\t\t\t\ttitle: Resources.STORE_NEAR_YOU,\n\t\t\t\twidth: 500,\n\t\t\t\tbuttons: [{\n\t\t\t\t\ttext: Resources.SEARCH,\n\t\t\t\t\tclick: function () {\n\t\t\t\t\t\tvar zipCode = $('#user-zip').val();\n\t\t\t\t\t\tif (validateZipCode(zipCode)) {\n\t\t\t\t\t\t\tself.setUserZip(zipCode);\n\t\t\t\t\t\t\tif (callback) {\n\t\t\t\t\t\t\t\tcallback(zipCode);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}],\n\t\t\t\topen: function () {\n\t\t\t\t\t$('#user-zip').on('keypress', function (e) {\n\t\t\t\t\t\tif (e.which === 13) {\n\t\t\t\t\t\t\t// trigger the search button\n\t\t\t\t\t\t\t$('.ui-dialog-buttonset .ui-button').trigger('click');\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t},\n\tgetStoresInventory: function (pid) {\n\t\treturn TPromise.resolve($.ajax({\n\t\t\turl: util.appendParamsToUrl(Urls.storesInventory, {\n\t\t\t\tpid: pid,\n\t\t\t\tzipCode: User.zip\n\t\t\t}),\n\t\t\tdataType: 'json'\n\t\t}));\n\t},\n\t/**\n\t * @description open the dialog to select store\n\t * @param {Array} options.stores\n\t * @param {String} options.selectedStoreId\n\t * @param {String} options.selectedStoreText\n\t * @param {Function} options.continueCallback\n\t * @param {Function} options.selectStoreCallback\n\t **/\n\tselectStoreDialog: function (options) {\n\t\tvar self = this,\n\t\t\tstores = options.stores,\n\t\t\tselectedStoreId = options.selectedStoreId,\n\t\t\tselectedStoreText = options.selectedStoreText,\n\t\t\tstoreList = storeListTemplate(stores, selectedStoreId, selectedStoreText);\n\t\tdialog.open({\n\t\t\thtml: storeList,\n\t\t\toptions: {\n\t\t\t\ttitle: Resources.SELECT_STORE + ' - ' + User.zip,\n\t\t\t\tbuttons: [{\n\t\t\t\t\t\ttext: Resources.CHANGE_LOCATION,\n\t\t\t\t\tclick: function () {\n\t\t\t\t\t\tself.setUserZip(null);\n\t\t\t\t\t\t// trigger the event to start the process all over again\n\t\t\t\t\t\t$('.set-preferred-store').trigger('click');\n\t\t\t\t\t}.bind(this)\n\t\t\t\t}, {\n\t\t\t\t\ttext: Resources.CONTINUE,\n\t\t\t\t\tclick: function () {\n\t\t\t\t\t\tif (options.continueCallback) {\n\t\t\t\t\t\t\toptions.continueCallback(stores);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdialog.close();\n\t\t\t\t\t}\n\t\t\t\t}],\n\t\t\t\topen: function () {\n\t\t\t\t\t$('.select-store-button').on('click', function (e) {\n\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\tvar storeId = $(this).data('storeId');\n\t\t\t\t\t\t// if the store is already selected, don't select again\n\t\t\t\t\t\tif (storeId === selectedStoreId) { return; }\n\t\t\t\t\t\t$('.store-list .store-tile.selected').removeClass('selected')\n\t\t\t\t\t\t\t.find('.select-store-button').text(Resources.SELECT_STORE);\n\t\t\t\t\t\t$(this).text(selectedStoreText)\n\t\t\t\t\t\t\t.closest('.store-tile').addClass('selected');\n\t\t\t\t\t\tif (options.selectStoreCallback) {\n\t\t\t\t\t\t\toptions.selectStoreCallback(storeId);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t},\n\tsetUserZip: function (zip) {\n\t\tUser.zip = zip;\n\t\t$.ajax({\n\t\t\ttype: 'POST',\n\t\t\turl: Urls.setZipCode,\n\t\t\tdata: {\n\t\t\t\tzipCode: zip\n\t\t\t}\n\t\t});\n\t},\n\tshippingLoad: function () {\n\t\tvar $checkoutForm = $('.address');\n\t\t$checkoutForm.off('click');\n\t\t$checkoutForm.on('click', 'input[name$=\"_shippingAddress_isGift\"]', function () {\n\t\t\t$(this).parent().siblings('.gift-message-text').toggleClass('hidden', $('input[name$=\"_shippingAddress_isGift\"]:checked').val());\n\t\t});\n\t}\n};\n\nmodule.exports = storeinventory;\n\n},{\"../dialog\":10,\"../util\":56,\"lodash\":62,\"promise\":63}],54:[function(require,module,exports){\n'use strict';\n\nvar _ = require('lodash'),\n\tinventory = require('./');\n\nvar newLine = '\\n';\nvar pdpStoreTemplate = function (store) {\n\treturn [\n\t\t'
      • ',\n\t\t'\t
        ' + store.address1 + ', ' + store.city + ' ' + store.stateCode +\n\t\t' ' + store.postalCode + '
        ',\n\t\t'\t
        ' + store.status + '
        ',\n\t\t'
      • '\n\t].join(newLine);\n};\nvar pdpStoresListingTemplate = function (stores) {\n\tif (stores && stores.length) {\n\t\treturn [\n\t\t\t'
        ',\n\t\t\t(stores.length > 1 ? '\t' + Resources.SEE_MORE + '' : ''),\n\t\t\t'\t
          ',\n\t\t\t_.map(stores, pdpStoreTemplate).join(newLine),\n\t\t\t'\t
        ',\n\t\t\t'
        '\n\t\t].join(newLine);\n\t}\n};\n\nvar storesListing = function (stores) {\n\t// list all stores on PDP page\n\tif ($('.store-list-pdp-container').length) {\n\t\t$('.store-list-pdp-container').remove();\n\t}\n\t$('.availability-results').append(pdpStoresListingTemplate(stores));\n};\n\nvar productInventory = {\n\tsetPreferredStore: function (storeId) {\n\t\tUser.storeId = storeId;\n\t\t$.ajax({\n\t\t\turl: Urls.setPreferredStore,\n\t\t\ttype: 'POST',\n\t\t\tdata: {storeId: storeId}\n\t\t});\n\t},\n\tproductSelectStore: function () {\n\t\tvar self = this;\n\t\tinventory.getStoresInventory(this.pid).then(function (stores) {\n\t\t\tinventory.selectStoreDialog({\n\t\t\t\tstores: stores,\n\t\t\t\tselectedStoreId: User.storeId,\n\t\t\t\tselectedStoreText: Resources.PREFERRED_STORE,\n\t\t\t\tcontinueCallback: storesListing,\n\t\t\t\tselectStoreCallback: self.setPreferredStore\n\t\t\t});\n\t\t}).done();\n\t},\n\tinit: function () {\n\t\tvar $availabilityContainer = $('.availability-results'),\n\t\t\tself = this;\n\t\tthis.pid = $('input[name=\"pid\"]').val();\n\n\t\t$('#product-content .set-preferred-store').on('click', function (e) {\n\t\t\te.preventDefault();\n\t\t\tif (!User.zip) {\n\t\t\t\tinventory.zipPrompt(function () {\n\t\t\t\t\tself.productSelectStore();\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tself.productSelectStore();\n\t\t\t}\n\t\t});\n\n\t\tif ($availabilityContainer.length) {\n\t\t\tif (User.storeId) {\n\t\t\t\tinventory.getStoresInventory(this.pid).then(storesListing);\n\t\t\t}\n\n\t\t\t// See more or less stores in the listing\n\t\t\t$availabilityContainer.on('click', '.stores-toggle', function (e) {\n\t\t\t\te.preventDefault();\n\t\t\t\t$('.store-list-pdp .store-list-item').toggleClass('visible');\n\t\t\t\tif ($(this).hasClass('collapsed')) {\n\t\t\t\t\t$(this).text(Resources.SEE_LESS);\n\t\t\t\t} else {\n\t\t\t\t\t$(this).text(Resources.SEE_MORE);\n\t\t\t\t}\n\t\t\t\t$(this).toggleClass('collapsed');\n\t\t\t});\n\t\t}\n\t}\n};\n\nmodule.exports = productInventory;\n\n},{\"./\":53,\"lodash\":62}],55:[function(require,module,exports){\n'use strict';\n\n/**\n * @function\n * @description Initializes the tooltip-content and layout\n */\nexports.init = function () {\n\t$(document).tooltip({\n\t\titems: '.tooltip',\n\t\ttrack: true,\n\t\tcontent: function () {\n\t\t\treturn $(this).find('.tooltip-content').html();\n\t\t}\n\t});\n\n\t$('.share-link').on('click', function (e) {\n\t\te.preventDefault();\n\t\tvar target = $(this).data('target');\n\t\tif (!target) {\n\t\t\treturn;\n\t\t}\n\t\t$(target).toggleClass('active');\n\t});\n};\n\n},{}],56:[function(require,module,exports){\n'use strict';\n\nvar _ = require('lodash');\n\nvar util = {\n\t/**\n\t * @function\n\t * @description appends the parameter with the given name and value to the given url and returns the changed url\n\t * @param {String} url the url to which the parameter will be added\n\t * @param {String} name the name of the parameter\n\t * @param {String} value the value of the parameter\n\t */\n\tappendParamToURL: function (url, name, value) {\n\t\t// quit if the param already exists\n\t\tif (url.indexOf(name + '=') !== -1) {\n\t\t\treturn url;\n\t\t}\n\t\tvar separator = url.indexOf('?') !== -1 ? '&' : '?';\n\t\treturn url + separator + name + '=' + encodeURIComponent(value);\n\t},\n\n\t/**\n\t * @function\n\t * @description remove the parameter and its value from the given url and returns the changed url\n\t * @param {String} url the url from which the parameter will be removed\n\t * @param {String} name the name of parameter that will be removed from url\n\t */\n\tremoveParamFromURL: function (url, name) {\n\t\tif (url.indexOf('?') === -1 || url.indexOf(name + '=') === -1) {\n\t\t\treturn url;\n\t\t}\n\t\tvar hash;\n\t\tvar params;\n\t\tvar domain = url.split('?')[0];\n\t\tvar paramUrl = url.split('?')[1];\n\t\tvar newParams = [];\n\t\t// if there is a hash at the end, store the hash\n\t\tif (paramUrl.indexOf('#') > -1) {\n\t\t\thash = paramUrl.split('#')[1] || '';\n\t\t\tparamUrl = paramUrl.split('#')[0];\n\t\t}\n\t\tparams = paramUrl.split('&');\n\t\tfor (var i = 0; i < params.length; i++) {\n\t\t\t// put back param to newParams array if it is not the one to be removed\n\t\t\tif (params[i].split('=')[0] !== name) {\n\t\t\t\tnewParams.push(params[i]);\n\t\t\t}\n\t\t}\n\t\treturn domain + '?' + newParams.join('&') + (hash ? '#' + hash : '');\n\t},\n\n\t/**\n\t * @function\n\t * @description appends the parameters to the given url and returns the changed url\n\t * @param {String} url the url to which the parameters will be added\n\t * @param {Object} params\n\t */\n\tappendParamsToUrl: function (url, params) {\n\t\tvar _url = url;\n\t\t_.each(params, function (value, name) {\n\t\t\t_url = this.appendParamToURL(_url, name, value);\n\t\t}.bind(this));\n\t\treturn _url;\n\t},\n\t/**\n\t * @function\n\t * @description extract the query string from URL\n\t * @param {String} url the url to extra query string from\n\t **/\n\tgetQueryString: function (url) {\n\t\tvar qs;\n\t\tif (!_.isString(url)) { return; }\n\t\tvar a = document.createElement('a');\n\t\ta.href = url;\n\t\tif (a.search) {\n\t\t\tqs = a.search.substr(1); // remove the leading ?\n\t\t}\n\t\treturn qs;\n\t},\n\t/**\n\t * @function\n\t * @description\n\t * @param {String}\n\t * @param {String}\n\t */\n\telementInViewport: function (el, offsetToTop) {\n\t\tvar top = el.offsetTop,\n\t\t\tleft = el.offsetLeft,\n\t\t\twidth = el.offsetWidth,\n\t\t\theight = el.offsetHeight;\n\n\t\twhile (el.offsetParent) {\n\t\t\tel = el.offsetParent;\n\t\t\ttop += el.offsetTop;\n\t\t\tleft += el.offsetLeft;\n\t\t}\n\n\t\tif (typeof(offsetToTop) !== 'undefined') {\n\t\t\ttop -= offsetToTop;\n\t\t}\n\n\t\tif (window.pageXOffset !== null) {\n\t\t\treturn (\n\t\t\t\ttop < (window.pageYOffset + window.innerHeight) &&\n\t\t\t\tleft < (window.pageXOffset + window.innerWidth) &&\n\t\t\t\t(top + height) > window.pageYOffset &&\n\t\t\t\t(left + width) > window.pageXOffset\n\t\t\t);\n\t\t}\n\n\t\tif (document.compatMode === 'CSS1Compat') {\n\t\t\treturn (\n\t\t\t\ttop < (window.document.documentElement.scrollTop + window.document.documentElement.clientHeight) &&\n\t\t\t\tleft < (window.document.documentElement.scrollLeft + window.document.documentElement.clientWidth) &&\n\t\t\t\t(top + height) > window.document.documentElement.scrollTop &&\n\t\t\t\t(left + width) > window.document.documentElement.scrollLeft\n\t\t\t);\n\t\t}\n\t},\n\n\t/**\n\t * @function\n\t * @description Appends the parameter 'format=ajax' to a given path\n\t * @param {String} path the relative path\n\t */\n\tajaxUrl: function (path) {\n\t\treturn this.appendParamToURL(path, 'format', 'ajax');\n\t},\n\n\t/**\n\t * @function\n\t * @description\n\t * @param {String} url\n\t */\n\ttoAbsoluteUrl: function (url) {\n\t\tif (url.indexOf('http') !== 0 && url.charAt(0) !== '/') {\n\t\t\turl = '/' + url;\n\t\t}\n\t\treturn url;\n\t},\n\t/**\n\t * @function\n\t * @description Loads css dynamically from given urls\n\t * @param {Array} urls Array of urls from which css will be dynamically loaded.\n\t */\n\tloadDynamicCss: function (urls) {\n\t\tvar i, len = urls.length;\n\t\tfor (i = 0; i < len; i++) {\n\t\t\tthis.loadedCssFiles.push(this.loadCssFile(urls[i]));\n\t\t}\n\t},\n\n\t/**\n\t * @function\n\t * @description Loads css file dynamically from given url\n\t * @param {String} url The url from which css file will be dynamically loaded.\n\t */\n\tloadCssFile: function (url) {\n\t\treturn $('').appendTo($('head')).attr({\n\t\t\ttype: 'text/css',\n\t\t\trel: 'stylesheet'\n\t\t}).attr('href', url); // for i.e. <9, href must be added after link has been appended to head\n\t},\n\t// array to keep track of the dynamically loaded CSS files\n\tloadedCssFiles: [],\n\n\t/**\n\t * @function\n\t * @description Removes all css files which were dynamically loaded\n\t */\n\tclearDynamicCss: function () {\n\t\tvar i = this.loadedCssFiles.length;\n\t\twhile (0 > i--) {\n\t\t\t$(this.loadedCssFiles[i]).remove();\n\t\t}\n\t\tthis.loadedCssFiles = [];\n\t},\n\t/**\n\t * @function\n\t * @description Extracts all parameters from a given query string into an object\n\t * @param {String} qs The query string from which the parameters will be extracted\n\t */\n\tgetQueryStringParams: function (qs) {\n\t\tif (!qs || qs.length === 0) { return {}; }\n\t\tvar params = {},\n\t\t\tunescapedQS = decodeURIComponent(qs);\n\t\t// Use the String::replace method to iterate over each\n\t\t// name-value pair in the string.\n\t\tunescapedQS.replace(new RegExp('([^?=&]+)(=([^&]*))?', 'g'),\n\t\t\tfunction ($0, $1, $2, $3) {\n\t\t\t\tparams[$1] = $3;\n\t\t\t}\n\t\t);\n\t\treturn params;\n\t},\n\n\tfillAddressFields: function (address, $form) {\n\t\tfor (var field in address) {\n\t\t\tif (field === 'ID' || field === 'UUID' || field === 'key') {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t// if the key in address object ends with 'Code', remove that suffix\n\t\t\t// keys that ends with 'Code' are postalCode, stateCode and countryCode\n\t\t\t$form.find('[name$=\"' + field.replace('Code', '') + '\"]').val(address[field]);\n\t\t\t// update the state fields\n\t\t\tif (field === 'countryCode') {\n\t\t\t\t$form.find('[name$=\"country\"]').trigger('change');\n\t\t\t\t// retrigger state selection after country has changed\n\t\t\t\t// this results in duplication of the state code, but is a necessary evil\n\t\t\t\t// for now because sometimes countryCode comes after stateCode\n\t\t\t\t$form.find('[name$=\"state\"]').val(address.stateCode);\n\t\t\t}\n\t\t}\n\t},\n\t/**\n\t * @function\n\t * @description Updates the number of the remaining character\n\t * based on the character limit in a text area\n\t */\n\tlimitCharacters: function () {\n\t\t$('form').find('textarea[data-character-limit]').each(function () {\n\t\t\tvar characterFromZero = $(this).val().length;\n\t\t\tvar characterLimit = $(this).data('character-limit');\n\t\t\tvar charCountHtml = String.format(Resources.CHAR_LIMIT_MSG,\n\t\t\t\t'' + characterFromZero + '',\n\t\t\t\t'' + characterLimit + '');\n\t\t\tvar charCountContainer = $(this).parent().parent().find('label').find('div.char-count');\n\t\t\tif (charCountContainer.length === 0) {\n\t\t\t\tcharCountContainer = $('
        ');\n\t\t\t\t$(this).parent().parent().find('label').append(charCountContainer);\n\t\t\t}\n\t\t\tcharCountContainer.html(charCountHtml);\n\t\t\t// trigger the keydown event so that any existing character data is calculated\n\t\t\t$(this).change();\n\t\t});\n\t},\n\t/**\n\t * @function\n\t * @description Binds the onclick-event to a delete button on a given container,\n\t * which opens a confirmation box with a given message\n\t * @param {String} container The name of element to which the function will be bind\n\t * @param {String} message The message the will be shown upon a click\n\t */\n\tsetDeleteConfirmation: function (container, message) {\n\t\t$(container).on('click', '.delete', function () {\n\t\t\treturn window.confirm(message);\n\t\t});\n\t},\n\t/**\n\t * @function\n\t * @description Scrolls a browser window to a given x point\n\t * @param {String} The x coordinate\n\t */\n\tscrollBrowser: function (xLocation) {\n\t\t$('html, body').animate({scrollTop: xLocation}, 500);\n\t},\n\n\tisMobile: function () {\n\t\tvar mobileAgentHash = ['mobile', 'tablet', 'phone', 'ipad', 'ipod', 'android', 'blackberry', 'windows ce', 'opera mini', 'palm'];\n\t\tvar\tidx = 0;\n\t\tvar isMobile = false;\n\t\tvar userAgent = (navigator.userAgent).toLowerCase();\n\n\t\twhile (mobileAgentHash[idx] && !isMobile) {\n\t\t\tisMobile = (userAgent.indexOf(mobileAgentHash[idx]) >= 0);\n\t\t\tidx++;\n\t\t}\n\t\treturn isMobile;\n\t}\n};\n\nmodule.exports = util;\n\n},{\"lodash\":62}],57:[function(require,module,exports){\n'use strict';\n\nvar naPhone = /^\\(?([2-9][0-8][0-9])\\)?[\\- ]?([2-9][0-9]{2})[\\- ]?([0-9]{4})(\\s*x[0-9]+)?$/;\nvar regex = {\n\tphone: {\n\t\tus: naPhone,\n\t\tca: naPhone,\n\t\tfr: /^0[1-6]{1}(([0-9]{2}){4})|((\\s[0-9]{2}){4})|((-[0-9]{2}){4})$/,\n\t\tit: /^(([0-9]{2,4})([-\\s\\/]{0,1})([0-9]{4,8}))?$/,\n\t\tjp: /^(0\\d{1,4}- ?)?\\d{1,4}-\\d{4}$/,\n\t\tcn: /.*/,\n\t\tgb: /^((\\(?0\\d{4}\\)?\\s?\\d{3}\\s?\\d{3})|(\\(?0\\d{3}\\)?\\s?\\d{3}\\s?\\d{4})|(\\(?0\\d{2}\\)?\\s?\\d{4}\\s?\\d{4}))(\\s?\\#(\\d{4}|\\d{3}))?$/\n\t},\n\tpostal: {\n\t\tus: /^\\d{5}(-\\d{4})?$/,\n\t\tca: /^[ABCEGHJKLMNPRSTVXY]{1}\\d{1}[A-Z]{1} *\\d{1}[A-Z]{1}\\d{1}$/,\n\t\tfr: /^(F-)?((2[A|B])|[0-9]{2})[0-9]{3}$/,\n\t\tit: /^([0-9]){5}$/,\n\t\tjp: /^([0-9]){3}[-]([0-9]){4}$/,\n\t\tcn: /^([0-9]){6}$/,\n\t\tgb: /^([A-PR-UWYZ0-9][A-HK-Y0-9][AEHMNPRTVXY0-9]?[ABEHMNPRVWXY0-9]? {1,2}[0-9][ABD-HJLN-UW-Z]{2}|GIR 0AA)$/\n\t},\n\tnotCC: /^(?!(([0-9 -]){13,19})).*$/,\n\tascii: /^[\\u0000-\\u007f]*$/,\n\tnameField: /^(?!\\d)[A-Za-zÀ-ÖØ-öø-ÿ0-9]+(?:(\\s|-)[A-Za-zÀ-ÖØ-öø-ÿ0-9]+)*$/,\n\taddressId: /^[A-Za-zÀ-ÖØ-öø-ÿ0-9]+(?:( |-| - )[A-Za-zÀ-ÖØ-öø-ÿ0-9]+)*$/,\n\taddressText: /^[A-Za-zÀ-ÖØ-öø-ÿ0-9]+(?:( |-| - )[A-Za-zÀ-ÖØ-öø-ÿ0-9]+)*$/,\n};\n// global form validator settings\nvar settings = {\n\terrorClass: 'error',\n\terrorElement: 'span',\n\tonkeyup: false,\n\tonfocusout: function (element) {\n\t\tif ($('#email-alert-signup').length < 1){\n\t\t\tif (!this.checkable(element)) {\n\t\t\t\tthis.element(element);\n\t\t\t}\n\t\t}\n\t},\n\tonsubmit: function (element) {\n\t\tif (!this.checkable(element)) {\n\t\t\tthis.element(element);\n\t\t}\n\t}\n};\n/**\n * @function\n * @description Validates a given phone number against the countries phone regex\n * @param {String} value The phone number which will be validated\n * @param {String} el The input field\n */\nvar validatePhone = function (value, el) {\n\tvar country = $(el).closest('form').find('.country');\n\tif (country.length === 0 || country.val().length === 0 || !regex.phone[country.val().toLowerCase()]) {\n\t\treturn true;\n\t}\n\n\tvar rgx = regex.phone[country.val().toLowerCase()];\n\tvar isOptional = this.optional(el);\n\tvar isValid = rgx.test($.trim(value));\n\n\treturn isOptional || isValid;\n};\n\n/**\n * @function\n * @description Validates input/textarea fields to prevent none ascii text\n * @param {String} value The user input text which will be validated\n * @param {String} el The input field\n */\nvar validateASCII = function(value) {\t\n\tvar rgx = regex.ascii;\n\tvar isValid = rgx.test($.trim(value));\n\t\n\treturn isValid;\n} \n\n/**\n * @function\n * @description Validates that a credit card owner is not a Credit card number\n * @param {String} value The owner field which will be validated\n * @param {String} el The input field\n */\nvar validateOwner = function (value) {\n\tvar isValid = regex.notCC.test($.trim(value));\n\treturn isValid;\n};\n\n\n/**\n * @function\n * @description Validates name input fields to prevent invalid/unwanted text\n * @param {String} value The user input text which will be validated\n */\nvar validateNameField = function(value) {\n\treturn regex.nameField.test($.trim(value));\n}\n\n/**\n * @function\n * @description Validates address id/name fields to prevent invalid/unwanted text\n * @param {String} value The user input text which will be validated\n */\nvar validateAddressId = function(value) {\n\treturn value.length > 0 ? regex.addressId.test($.trim(value)) : true;\n}\n\n/**\n * @function\n * @description Validates address 1 fields to prevent invalid/unwanted text\n * @param {String} value The user input text which will be validated\n */\nvar validateAddress1 = function(value) {\n\treturn value.length > 0 ? regex.addressText.test($.trim(value)) : true;\n}\n\n/**\n * @function\n * @description Validates address line 2 field to prevent invalid/unwanted text\n * @param {String} value The user input text which will be validated\n */\nvar validateAddress2 = function(value) {\n\treturn value.length > 0 ? regex.addressText.test($.trim(value)) : true;\n}\n\n\n/**\n * Add phone validation method to jQuery validation plugin.\n * Text fields must have 'phone' css class to be validated as phone\n */\n$.validator.addMethod('phone', validatePhone, Resources.INVALID_PHONE);\n\n/**\n * Add first/last name validation method to jQuery validation plugin.\n * Text fields must have 'input-name' css class to be validated with this\n */\n$.validator.addMethod('input-name', validateNameField, Resources.VALIDATE_LATIN1);\n\n/**\n * Add address name/id name validation method to jQuery validation plugin.\n * Text fields must have 'input-address' css class to be validated with this\n */\n$.validator.addMethod('input-addressId', validateAddressId, Resources.VALIDATE_LATIN1);\n\n/**\n * Add address line 1 validation method to jQuery validation plugin.\n * Text fields must have 'input-address1' css class to be validated with this\n */\n$.validator.addMethod('input-address1', validateAddress1, Resources.VALIDATE_LATIN1);\n\n/**\n * Add address line 2 validation method to jQuery validation plugin.\n * Text fields must have 'input-address2' css class to be validated with this\n */\n$.validator.addMethod('input-address2', validateAddress2, Resources.VALIDATE_LATIN1);\n\n\n/**\n * Add CCOwner validation method to jQuery validation plugin.\n * Text fields must have 'owner' css class to be validated as not a credit card\n */\n$.validator.addMethod('owner', validateOwner, Resources.INVALID_OWNER);\n\n/**\n * Add gift cert amount validation method to jQuery validation plugin.\n * Text fields must have 'gift-cert-amont' css class to be validated\n */\n$.validator.addMethod('gift-cert-amount', function (value, el) {\n\tvar isOptional = this.optional(el);\n\tvar isValid = (!isNaN(value)) && (parseFloat(value) >= 5) && (parseFloat(value) <= 5000);\n\treturn isOptional || isValid;\n}, Resources.GIFT_CERT_AMOUNT_INVALID);\n\n/**\n * Add positive number validation method to jQuery validation plugin.\n * Text fields must have 'positivenumber' css class to be validated as positivenumber\n */\n$.validator.addMethod('positivenumber', function (value) {\n\tif ($.trim(value).length === 0) { return true; }\n\treturn (!isNaN(value) && Number(value) >= 0);\n}, ''); // '' should be replaced with error message if needed\n\n/**\n * Add ascii text validation method to jQuery validation plugin.\n * Text fields must have 'ascii' css class to be validated as ascii\n */\n$.validator.addMethod('ascii', validateASCII, Resources.VALIDATE_ASCII);\n\n/**\n * Validate all input-text fields for non ascii text\n */\n$.validator.addMethod('input-text', function(value, element){\n\t\n\tif($('.pt_checkout').length > 0) {\n\t\treturn $.validator.methods.ascii.call(this, value, element);\n\t}\n\t\n\treturn true;\n\t\n}, Resources.VALIDATE_ASCII);\n\n$.extend($.validator.messages, {\n\trequired: Resources.VALIDATE_REQUIRED,\n\tremote: Resources.VALIDATE_REMOTE,\n\temail: Resources.VALIDATE_EMAIL,\n\turl: Resources.VALIDATE_URL,\n\tdate: Resources.VALIDATE_DATE,\n\tdateISO: Resources.VALIDATE_DATEISO,\n\tnumber: Resources.VALIDATE_NUMBER,\n\tdigits: Resources.VALIDATE_DIGITS,\n\tcreditcard: Resources.VALIDATE_CREDITCARD,\n\tequalTo: Resources.VALIDATE_EQUALTO,\n\tmaxlength: $.validator.format(Resources.VALIDATE_MAXLENGTH),\n\tminlength: $.validator.format(Resources.VALIDATE_MINLENGTH),\n\trangelength: $.validator.format(Resources.VALIDATE_RANGELENGTH),\n\trange: $.validator.format(Resources.VALIDATE_RANGE),\n\tmax: $.validator.format(Resources.VALIDATE_MAX),\n\tmin: $.validator.format(Resources.VALIDATE_MIN),\n\tascii: $.validator.format(Resources.VALIDATE_ASCII),\n\tlatin1: $.validator.format(Resources.VALIDATE_LATIN1)\n});\n\nvar validator = {\n\tregex: regex,\n\tsettings: settings,\n\tinit: function () {\n\t\tvar self = this;\n\t\t$('form:not(.suppress)').each(function () {\n\t\t\t$(this).validate(self.settings);\n\t\t});\n\t},\n\tinitForm: function (f) {\n\t\t$(f).validate(this.settings);\n\t}\n};\n\nmodule.exports = validator;\n\n},{}],58:[function(require,module,exports){\n\"use strict\";\n\n// rawAsap provides everything we need except exception management.\nvar rawAsap = require(\"./raw\");\n// RawTasks are recycled to reduce GC churn.\nvar freeTasks = [];\n// We queue errors to ensure they are thrown in right order (FIFO).\n// Array-as-queue is good enough here, since we are just dealing with exceptions.\nvar pendingErrors = [];\nvar requestErrorThrow = rawAsap.makeRequestCallFromTimer(throwFirstError);\n\nfunction throwFirstError() {\n if (pendingErrors.length) {\n throw pendingErrors.shift();\n }\n}\n\n/**\n * Calls a task as soon as possible after returning, in its own event, with priority\n * over other events like animation, reflow, and repaint. An error thrown from an\n * event will not interrupt, nor even substantially slow down the processing of\n * other events, but will be rather postponed to a lower priority event.\n * @param {{call}} task A callable object, typically a function that takes no\n * arguments.\n */\nmodule.exports = asap;\nfunction asap(task) {\n var rawTask;\n if (freeTasks.length) {\n rawTask = freeTasks.pop();\n } else {\n rawTask = new RawTask();\n }\n rawTask.task = task;\n rawAsap(rawTask);\n}\n\n// We wrap tasks with recyclable task objects. A task object implements\n// `call`, just like a function.\nfunction RawTask() {\n this.task = null;\n}\n\n// The sole purpose of wrapping the task is to catch the exception and recycle\n// the task object after its single use.\nRawTask.prototype.call = function () {\n try {\n this.task.call();\n } catch (error) {\n if (asap.onerror) {\n // This hook exists purely for testing purposes.\n // Its name will be periodically randomized to break any code that\n // depends on its existence.\n asap.onerror(error);\n } else {\n // In a web browser, exceptions are not fatal. However, to avoid\n // slowing down the queue of pending tasks, we rethrow the error in a\n // lower priority turn.\n pendingErrors.push(error);\n requestErrorThrow();\n }\n } finally {\n this.task = null;\n freeTasks[freeTasks.length] = this;\n }\n};\n\n},{\"./raw\":59}],59:[function(require,module,exports){\n(function (global){\n\"use strict\";\n\n// Use the fastest means possible to execute a task in its own turn, with\n// priority over other events including IO, animation, reflow, and redraw\n// events in browsers.\n//\n// An exception thrown by a task will permanently interrupt the processing of\n// subsequent tasks. The higher level `asap` function ensures that if an\n// exception is thrown by a task, that the task queue will continue flushing as\n// soon as possible, but if you use `rawAsap` directly, you are responsible to\n// either ensure that no exceptions are thrown from your task, or to manually\n// call `rawAsap.requestFlush` if an exception is thrown.\nmodule.exports = rawAsap;\nfunction rawAsap(task) {\n if (!queue.length) {\n requestFlush();\n flushing = true;\n }\n // Equivalent to push, but avoids a function call.\n queue[queue.length] = task;\n}\n\nvar queue = [];\n// Once a flush has been requested, no further calls to `requestFlush` are\n// necessary until the next `flush` completes.\nvar flushing = false;\n// `requestFlush` is an implementation-specific method that attempts to kick\n// off a `flush` event as quickly as possible. `flush` will attempt to exhaust\n// the event queue before yielding to the browser's own event loop.\nvar requestFlush;\n// The position of the next task to execute in the task queue. This is\n// preserved between calls to `flush` so that it can be resumed if\n// a task throws an exception.\nvar index = 0;\n// If a task schedules additional tasks recursively, the task queue can grow\n// unbounded. To prevent memory exhaustion, the task queue will periodically\n// truncate already-completed tasks.\nvar capacity = 1024;\n\n// The flush function processes all tasks that have been scheduled with\n// `rawAsap` unless and until one of those tasks throws an exception.\n// If a task throws an exception, `flush` ensures that its state will remain\n// consistent and will resume where it left off when called again.\n// However, `flush` does not make any arrangements to be called again if an\n// exception is thrown.\nfunction flush() {\n while (index < queue.length) {\n var currentIndex = index;\n // Advance the index before calling the task. This ensures that we will\n // begin flushing on the next task the task throws an error.\n index = index + 1;\n queue[currentIndex].call();\n // Prevent leaking memory for long chains of recursive calls to `asap`.\n // If we call `asap` within tasks scheduled by `asap`, the queue will\n // grow, but to avoid an O(n) walk for every task we execute, we don't\n // shift tasks off the queue after they have been executed.\n // Instead, we periodically shift 1024 tasks off the queue.\n if (index > capacity) {\n // Manually shift all values starting at the index back to the\n // beginning of the queue.\n for (var scan = 0, newLength = queue.length - index; scan < newLength; scan++) {\n queue[scan] = queue[scan + index];\n }\n queue.length -= index;\n index = 0;\n }\n }\n queue.length = 0;\n index = 0;\n flushing = false;\n}\n\n// `requestFlush` is implemented using a strategy based on data collected from\n// every available SauceLabs Selenium web driver worker at time of writing.\n// https://docs.google.com/spreadsheets/d/1mG-5UYGup5qxGdEMWkhP6BWCz053NUb2E1QoUTU16uA/edit#gid=783724593\n\n// Safari 6 and 6.1 for desktop, iPad, and iPhone are the only browsers that\n// have WebKitMutationObserver but not un-prefixed MutationObserver.\n// Must use `global` or `self` instead of `window` to work in both frames and web\n// workers. `global` is a provision of Browserify, Mr, Mrs, or Mop.\n\n/* globals self */\nvar scope = typeof global !== \"undefined\" ? global : self;\nvar BrowserMutationObserver = scope.MutationObserver || scope.WebKitMutationObserver;\n\n// MutationObservers are desirable because they have high priority and work\n// reliably everywhere they are implemented.\n// They are implemented in all modern browsers.\n//\n// - Android 4-4.3\n// - Chrome 26-34\n// - Firefox 14-29\n// - Internet Explorer 11\n// - iPad Safari 6-7.1\n// - iPhone Safari 7-7.1\n// - Safari 6-7\nif (typeof BrowserMutationObserver === \"function\") {\n requestFlush = makeRequestCallFromMutationObserver(flush);\n\n// MessageChannels are desirable because they give direct access to the HTML\n// task queue, are implemented in Internet Explorer 10, Safari 5.0-1, and Opera\n// 11-12, and in web workers in many engines.\n// Although message channels yield to any queued rendering and IO tasks, they\n// would be better than imposing the 4ms delay of timers.\n// However, they do not work reliably in Internet Explorer or Safari.\n\n// Internet Explorer 10 is the only browser that has setImmediate but does\n// not have MutationObservers.\n// Although setImmediate yields to the browser's renderer, it would be\n// preferrable to falling back to setTimeout since it does not have\n// the minimum 4ms penalty.\n// Unfortunately there appears to be a bug in Internet Explorer 10 Mobile (and\n// Desktop to a lesser extent) that renders both setImmediate and\n// MessageChannel useless for the purposes of ASAP.\n// https://github.com/kriskowal/q/issues/396\n\n// Timers are implemented universally.\n// We fall back to timers in workers in most engines, and in foreground\n// contexts in the following browsers.\n// However, note that even this simple case requires nuances to operate in a\n// broad spectrum of browsers.\n//\n// - Firefox 3-13\n// - Internet Explorer 6-9\n// - iPad Safari 4.3\n// - Lynx 2.8.7\n} else {\n requestFlush = makeRequestCallFromTimer(flush);\n}\n\n// `requestFlush` requests that the high priority event queue be flushed as\n// soon as possible.\n// This is useful to prevent an error thrown in a task from stalling the event\n// queue if the exception handled by Node.js’s\n// `process.on(\"uncaughtException\")` or by a domain.\nrawAsap.requestFlush = requestFlush;\n\n// To request a high priority event, we induce a mutation observer by toggling\n// the text of a text node between \"1\" and \"-1\".\nfunction makeRequestCallFromMutationObserver(callback) {\n var toggle = 1;\n var observer = new BrowserMutationObserver(callback);\n var node = document.createTextNode(\"\");\n observer.observe(node, {characterData: true});\n return function requestCall() {\n toggle = -toggle;\n node.data = toggle;\n };\n}\n\n// The message channel technique was discovered by Malte Ubl and was the\n// original foundation for this library.\n// http://www.nonblocking.io/2011/06/windownexttick.html\n\n// Safari 6.0.5 (at least) intermittently fails to create message ports on a\n// page's first load. Thankfully, this version of Safari supports\n// MutationObservers, so we don't need to fall back in that case.\n\n// function makeRequestCallFromMessageChannel(callback) {\n// var channel = new MessageChannel();\n// channel.port1.onmessage = callback;\n// return function requestCall() {\n// channel.port2.postMessage(0);\n// };\n// }\n\n// For reasons explained above, we are also unable to use `setImmediate`\n// under any circumstances.\n// Even if we were, there is another bug in Internet Explorer 10.\n// It is not sufficient to assign `setImmediate` to `requestFlush` because\n// `setImmediate` must be called *by name* and therefore must be wrapped in a\n// closure.\n// Never forget.\n\n// function makeRequestCallFromSetImmediate(callback) {\n// return function requestCall() {\n// setImmediate(callback);\n// };\n// }\n\n// Safari 6.0 has a problem where timers will get lost while the user is\n// scrolling. This problem does not impact ASAP because Safari 6.0 supports\n// mutation observers, so that implementation is used instead.\n// However, if we ever elect to use timers in Safari, the prevalent work-around\n// is to add a scroll event listener that calls for a flush.\n\n// `setTimeout` does not call the passed callback if the delay is less than\n// approximately 7 in web workers in Firefox 8 through 18, and sometimes not\n// even then.\n\nfunction makeRequestCallFromTimer(callback) {\n return function requestCall() {\n // We dispatch a timeout with a specified delay of 0 for engines that\n // can reliably accommodate that request. This will usually be snapped\n // to a 4 milisecond delay, but once we're flushing, there's no delay\n // between events.\n var timeoutHandle = setTimeout(handleTimer, 0);\n // However, since this timer gets frequently dropped in Firefox\n // workers, we enlist an interval handle that will try to fire\n // an event 20 times per second until it succeeds.\n var intervalHandle = setInterval(handleTimer, 50);\n\n function handleTimer() {\n // Whichever timer succeeds will cancel both timers and\n // execute the callback.\n clearTimeout(timeoutHandle);\n clearInterval(intervalHandle);\n callback();\n }\n };\n}\n\n// This is for `asap.js` only.\n// Its name will be periodically randomized to break any code that depends on\n// its existence.\nrawAsap.makeRequestCallFromTimer = makeRequestCallFromTimer;\n\n// ASAP was originally a nextTick shim included in Q. This was factored out\n// into this ASAP package. It was later adapted to RSVP which made further\n// amendments. These decisions, particularly to marginalize MessageChannel and\n// to capture the MutationObserver implementation in a closure, were integrated\n// back into ASAP proper.\n// https://github.com/tildeio/rsvp.js/blob/cddf7232546a9cf858524b75cde6f9edf72620a7/lib/rsvp/asap.js\n\n}).call(this,typeof global !== \"undefined\" ? global : typeof self !== \"undefined\" ? self : typeof window !== \"undefined\" ? window : {})\n},{}],60:[function(require,module,exports){\n/*!\n * eventie v1.0.6\n * event binding helper\n * eventie.bind( elem, 'click', myFn )\n * eventie.unbind( elem, 'click', myFn )\n * MIT license\n */\n\n/*jshint browser: true, undef: true, unused: true */\n/*global define: false, module: false */\n\n( function( window ) {\n\n'use strict';\n\nvar docElem = document.documentElement;\n\nvar bind = function() {};\n\nfunction getIEEvent( obj ) {\n var event = window.event;\n // add event.target\n event.target = event.target || event.srcElement || obj;\n return event;\n}\n\nif ( docElem.addEventListener ) {\n bind = function( obj, type, fn ) {\n obj.addEventListener( type, fn, false );\n };\n} else if ( docElem.attachEvent ) {\n bind = function( obj, type, fn ) {\n obj[ type + fn ] = fn.handleEvent ?\n function() {\n var event = getIEEvent( obj );\n fn.handleEvent.call( fn, event );\n } :\n function() {\n var event = getIEEvent( obj );\n fn.call( obj, event );\n };\n obj.attachEvent( \"on\" + type, obj[ type + fn ] );\n };\n}\n\nvar unbind = function() {};\n\nif ( docElem.removeEventListener ) {\n unbind = function( obj, type, fn ) {\n obj.removeEventListener( type, fn, false );\n };\n} else if ( docElem.detachEvent ) {\n unbind = function( obj, type, fn ) {\n obj.detachEvent( \"on\" + type, obj[ type + fn ] );\n try {\n delete obj[ type + fn ];\n } catch ( err ) {\n // can't delete window object properties\n obj[ type + fn ] = undefined;\n }\n };\n}\n\nvar eventie = {\n bind: bind,\n unbind: unbind\n};\n\n// ----- module definition ----- //\n\nif ( typeof define === 'function' && define.amd ) {\n // AMD\n define( eventie );\n} else if ( typeof exports === 'object' ) {\n // CommonJS\n module.exports = eventie;\n} else {\n // browser global\n window.eventie = eventie;\n}\n\n})( window );\n\n},{}],61:[function(require,module,exports){\n/*!\n * imagesLoaded v3.2.0\n * JavaScript is all like \"You images are done yet or what?\"\n * MIT License\n */\n\n( function( window, factory ) { 'use strict';\n // universal module definition\n\n /*global define: false, module: false, require: false */\n\n if ( typeof define == 'function' && define.amd ) {\n // AMD\n define( [\n 'eventEmitter/EventEmitter',\n 'eventie/eventie'\n ], function( EventEmitter, eventie ) {\n return factory( window, EventEmitter, eventie );\n });\n } else if ( typeof module == 'object' && module.exports ) {\n // CommonJS\n module.exports = factory(\n window,\n require('wolfy87-eventemitter'),\n require('eventie')\n );\n } else {\n // browser global\n window.imagesLoaded = factory(\n window,\n window.EventEmitter,\n window.eventie\n );\n }\n\n})( window,\n\n// -------------------------- factory -------------------------- //\n\nfunction factory( window, EventEmitter, eventie ) {\n\n'use strict';\n\nvar $ = window.jQuery;\nvar console = window.console;\n\n// -------------------------- helpers -------------------------- //\n\n// extend objects\nfunction extend( a, b ) {\n for ( var prop in b ) {\n a[ prop ] = b[ prop ];\n }\n return a;\n}\n\nvar objToString = Object.prototype.toString;\nfunction isArray( obj ) {\n return objToString.call( obj ) == '[object Array]';\n}\n\n// turn element or nodeList into an array\nfunction makeArray( obj ) {\n var ary = [];\n if ( isArray( obj ) ) {\n // use object if already an array\n ary = obj;\n } else if ( typeof obj.length == 'number' ) {\n // convert nodeList to array\n for ( var i=0; i < obj.length; i++ ) {\n ary.push( obj[i] );\n }\n } else {\n // array of single index\n ary.push( obj );\n }\n return ary;\n}\n\n // -------------------------- imagesLoaded -------------------------- //\n\n /**\n * @param {Array, Element, NodeList, String} elem\n * @param {Object or Function} options - if function, use as callback\n * @param {Function} onAlways - callback function\n */\n function ImagesLoaded( elem, options, onAlways ) {\n // coerce ImagesLoaded() without new, to be new ImagesLoaded()\n if ( !( this instanceof ImagesLoaded ) ) {\n return new ImagesLoaded( elem, options, onAlways );\n }\n // use elem as selector string\n if ( typeof elem == 'string' ) {\n elem = document.querySelectorAll( elem );\n }\n\n this.elements = makeArray( elem );\n this.options = extend( {}, this.options );\n\n if ( typeof options == 'function' ) {\n onAlways = options;\n } else {\n extend( this.options, options );\n }\n\n if ( onAlways ) {\n this.on( 'always', onAlways );\n }\n\n this.getImages();\n\n if ( $ ) {\n // add jQuery Deferred object\n this.jqDeferred = new $.Deferred();\n }\n\n // HACK check async to allow time to bind listeners\n var _this = this;\n setTimeout( function() {\n _this.check();\n });\n }\n\n ImagesLoaded.prototype = new EventEmitter();\n\n ImagesLoaded.prototype.options = {};\n\n ImagesLoaded.prototype.getImages = function() {\n this.images = [];\n\n // filter & find items if we have an item selector\n for ( var i=0; i < this.elements.length; i++ ) {\n var elem = this.elements[i];\n this.addElementImages( elem );\n }\n };\n\n /**\n * @param {Node} element\n */\n ImagesLoaded.prototype.addElementImages = function( elem ) {\n // filter siblings\n if ( elem.nodeName == 'IMG' ) {\n this.addImage( elem );\n }\n // get background image on element\n if ( this.options.background === true ) {\n this.addElementBackgroundImages( elem );\n }\n\n // find children\n // no non-element nodes, #143\n var nodeType = elem.nodeType;\n if ( !nodeType || !elementNodeTypes[ nodeType ] ) {\n return;\n }\n var childImgs = elem.querySelectorAll('img');\n // concat childElems to filterFound array\n for ( var i=0; i < childImgs.length; i++ ) {\n var img = childImgs[i];\n this.addImage( img );\n }\n\n // get child background images\n if ( typeof this.options.background == 'string' ) {\n var children = elem.querySelectorAll( this.options.background );\n for ( i=0; i < children.length; i++ ) {\n var child = children[i];\n this.addElementBackgroundImages( child );\n }\n }\n };\n\n var elementNodeTypes = {\n 1: true,\n 9: true,\n 11: true\n };\n\n ImagesLoaded.prototype.addElementBackgroundImages = function( elem ) {\n var style = getStyle( elem );\n // get url inside url(\"...\")\n var reURL = /url\\(['\"]*([^'\"\\)]+)['\"]*\\)/gi;\n var matches = reURL.exec( style.backgroundImage );\n while ( matches !== null ) {\n var url = matches && matches[1];\n if ( url ) {\n this.addBackground( url, elem );\n }\n matches = reURL.exec( style.backgroundImage );\n }\n };\n\n // IE8\n var getStyle = window.getComputedStyle || function( elem ) {\n return elem.currentStyle;\n };\n\n /**\n * @param {Image} img\n */\n ImagesLoaded.prototype.addImage = function( img ) {\n var loadingImage = new LoadingImage( img );\n this.images.push( loadingImage );\n };\n\n ImagesLoaded.prototype.addBackground = function( url, elem ) {\n var background = new Background( url, elem );\n this.images.push( background );\n };\n\n ImagesLoaded.prototype.check = function() {\n var _this = this;\n this.progressedCount = 0;\n this.hasAnyBroken = false;\n // complete if no images\n if ( !this.images.length ) {\n this.complete();\n return;\n }\n\n function onProgress( image, elem, message ) {\n // HACK - Chrome triggers event before object properties have changed. #83\n setTimeout( function() {\n _this.progress( image, elem, message );\n });\n }\n\n for ( var i=0; i < this.images.length; i++ ) {\n var loadingImage = this.images[i];\n loadingImage.once( 'progress', onProgress );\n loadingImage.check();\n }\n };\n\n ImagesLoaded.prototype.progress = function( image, elem, message ) {\n this.progressedCount++;\n this.hasAnyBroken = this.hasAnyBroken || !image.isLoaded;\n // progress event\n this.emit( 'progress', this, image, elem );\n if ( this.jqDeferred && this.jqDeferred.notify ) {\n this.jqDeferred.notify( this, image );\n }\n // check if completed\n if ( this.progressedCount == this.images.length ) {\n this.complete();\n }\n\n if ( this.options.debug && console ) {\n console.log( 'progress: ' + message, image, elem );\n }\n };\n\n ImagesLoaded.prototype.complete = function() {\n var eventName = this.hasAnyBroken ? 'fail' : 'done';\n this.isComplete = true;\n this.emit( eventName, this );\n this.emit( 'always', this );\n if ( this.jqDeferred ) {\n var jqMethod = this.hasAnyBroken ? 'reject' : 'resolve';\n this.jqDeferred[ jqMethod ]( this );\n }\n };\n\n // -------------------------- -------------------------- //\n\n function LoadingImage( img ) {\n this.img = img;\n }\n\n LoadingImage.prototype = new EventEmitter();\n\n LoadingImage.prototype.check = function() {\n // If complete is true and browser supports natural sizes,\n // try to check for image status manually.\n var isComplete = this.getIsImageComplete();\n if ( isComplete ) {\n // report based on naturalWidth\n this.confirm( this.img.naturalWidth !== 0, 'naturalWidth' );\n return;\n }\n\n // If none of the checks above matched, simulate loading on detached element.\n this.proxyImage = new Image();\n eventie.bind( this.proxyImage, 'load', this );\n eventie.bind( this.proxyImage, 'error', this );\n // bind to image as well for Firefox. #191\n eventie.bind( this.img, 'load', this );\n eventie.bind( this.img, 'error', this );\n this.proxyImage.src = this.img.src;\n };\n\n LoadingImage.prototype.getIsImageComplete = function() {\n return this.img.complete && this.img.naturalWidth !== undefined;\n };\n\n LoadingImage.prototype.confirm = function( isLoaded, message ) {\n this.isLoaded = isLoaded;\n this.emit( 'progress', this, this.img, message );\n };\n\n // ----- events ----- //\n\n // trigger specified handler for event type\n LoadingImage.prototype.handleEvent = function( event ) {\n var method = 'on' + event.type;\n if ( this[ method ] ) {\n this[ method ]( event );\n }\n };\n\n LoadingImage.prototype.onload = function() {\n this.confirm( true, 'onload' );\n this.unbindEvents();\n };\n\n LoadingImage.prototype.onerror = function() {\n this.confirm( false, 'onerror' );\n this.unbindEvents();\n };\n\n LoadingImage.prototype.unbindEvents = function() {\n eventie.unbind( this.proxyImage, 'load', this );\n eventie.unbind( this.proxyImage, 'error', this );\n eventie.unbind( this.img, 'load', this );\n eventie.unbind( this.img, 'error', this );\n };\n\n // -------------------------- Background -------------------------- //\n\n function Background( url, element ) {\n this.url = url;\n this.element = element;\n this.img = new Image();\n }\n\n // inherit LoadingImage prototype\n Background.prototype = new LoadingImage();\n\n Background.prototype.check = function() {\n eventie.bind( this.img, 'load', this );\n eventie.bind( this.img, 'error', this );\n this.img.src = this.url;\n // check if image is already complete\n var isComplete = this.getIsImageComplete();\n if ( isComplete ) {\n this.confirm( this.img.naturalWidth !== 0, 'naturalWidth' );\n this.unbindEvents();\n }\n };\n\n Background.prototype.unbindEvents = function() {\n eventie.unbind( this.img, 'load', this );\n eventie.unbind( this.img, 'error', this );\n };\n\n Background.prototype.confirm = function( isLoaded, message ) {\n this.isLoaded = isLoaded;\n this.emit( 'progress', this, this.element, message );\n };\n\n // -------------------------- jQuery -------------------------- //\n\n ImagesLoaded.makeJQueryPlugin = function( jQuery ) {\n jQuery = jQuery || window.jQuery;\n if ( !jQuery ) {\n return;\n }\n // set local variable\n $ = jQuery;\n // $().imagesLoaded()\n $.fn.imagesLoaded = function( options, callback ) {\n var instance = new ImagesLoaded( this, options, callback );\n return instance.jqDeferred.promise( $(this) );\n };\n };\n // try making plugin\n ImagesLoaded.makeJQueryPlugin();\n\n // -------------------------- -------------------------- //\n\n return ImagesLoaded;\n\n});\n\n},{\"eventie\":60,\"wolfy87-eventemitter\":71}],62:[function(require,module,exports){\n(function (global){\n/*!\n * Lo-Dash v0.9.2 \n * (c) 2012 John-David Dalton \n * Based on Underscore.js 1.4.2 \n * (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc.\n * Available under MIT license \n */\n;(function(window, undefined) {\n\n /** Detect free variable `exports` */\n var freeExports = typeof exports == 'object' && exports;\n\n /** Detect free variable `global` and use it as `window` */\n var freeGlobal = typeof global == 'object' && global;\n if (freeGlobal.global === freeGlobal) {\n window = freeGlobal;\n }\n\n /** Used for array and object method references */\n var arrayRef = [],\n // avoid a Closure Compiler bug by creatively creating an object\n objectRef = new function(){};\n\n /** Used to generate unique IDs */\n var idCounter = 0;\n\n /** Used internally to indicate various things */\n var indicatorObject = objectRef;\n\n /** Used by `cachedContains` as the default size when optimizations are enabled for large arrays */\n var largeArraySize = 30;\n\n /** Used to restore the original `_` reference in `noConflict` */\n var oldDash = window._;\n\n /** Used to detect template delimiter values that require a with-statement */\n var reComplexDelimiter = /[-?+=!~*%&^<>|{(\\/]|\\[\\D|\\b(?:delete|in|instanceof|new|typeof|void)\\b/;\n\n /** Used to match HTML entities */\n var reEscapedHtml = /&(?:amp|lt|gt|quot|#x27);/g;\n\n /** Used to match empty string literals in compiled template source */\n var reEmptyStringLeading = /\\b__p \\+= '';/g,\n reEmptyStringMiddle = /\\b(__p \\+=) '' \\+/g,\n reEmptyStringTrailing = /(__e\\(.*?\\)|\\b__t\\)) \\+\\n'';/g;\n\n /** Used to match regexp flags from their coerced string values */\n var reFlags = /\\w*$/;\n\n /** Used to insert the data object variable into compiled template source */\n var reInsertVariable = /(?:__e|__t = )\\(\\s*(?![\\d\\s\"']|this\\.)/g;\n\n /** Used to detect if a method is native */\n var reNative = RegExp('^' +\n (objectRef.valueOf + '')\n .replace(/[.*+?^=!:${}()|[\\]\\/\\\\]/g, '\\\\$&')\n .replace(/valueOf|for [^\\]]+/g, '.+?') + '$'\n );\n\n /**\n * Used to match ES6 template delimiters\n * http://people.mozilla.org/~jorendorff/es6-draft.html#sec-7.8.6\n */\n var reEsTemplate = /\\$\\{((?:(?=\\\\?)\\\\?[\\s\\S])*?)}/g;\n\n /** Used to match \"interpolate\" template delimiters */\n var reInterpolate = /<%=([\\s\\S]+?)%>/g;\n\n /** Used to ensure capturing order of template delimiters */\n var reNoMatch = /($^)/;\n\n /** Used to match HTML characters */\n var reUnescapedHtml = /[&<>\"']/g;\n\n /** Used to match unescaped characters in compiled string literals */\n var reUnescapedString = /['\\n\\r\\t\\u2028\\u2029\\\\]/g;\n\n /** Used to fix the JScript [[DontEnum]] bug */\n var shadowed = [\n 'constructor', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable',\n 'toLocaleString', 'toString', 'valueOf'\n ];\n\n /** Used to make template sourceURLs easier to identify */\n var templateCounter = 0;\n\n /** Native method shortcuts */\n var ceil = Math.ceil,\n concat = arrayRef.concat,\n floor = Math.floor,\n getPrototypeOf = reNative.test(getPrototypeOf = Object.getPrototypeOf) && getPrototypeOf,\n hasOwnProperty = objectRef.hasOwnProperty,\n push = arrayRef.push,\n propertyIsEnumerable = objectRef.propertyIsEnumerable,\n slice = arrayRef.slice,\n toString = objectRef.toString;\n\n /* Native method shortcuts for methods with the same name as other `lodash` methods */\n var nativeBind = reNative.test(nativeBind = slice.bind) && nativeBind,\n nativeIsArray = reNative.test(nativeIsArray = Array.isArray) && nativeIsArray,\n nativeIsFinite = window.isFinite,\n nativeIsNaN = window.isNaN,\n nativeKeys = reNative.test(nativeKeys = Object.keys) && nativeKeys,\n nativeMax = Math.max,\n nativeMin = Math.min,\n nativeRandom = Math.random;\n\n /** `Object#toString` result shortcuts */\n var argsClass = '[object Arguments]',\n arrayClass = '[object Array]',\n boolClass = '[object Boolean]',\n dateClass = '[object Date]',\n funcClass = '[object Function]',\n numberClass = '[object Number]',\n objectClass = '[object Object]',\n regexpClass = '[object RegExp]',\n stringClass = '[object String]';\n\n /**\n * Detect the JScript [[DontEnum]] bug:\n *\n * In IE < 9 an objects own properties, shadowing non-enumerable ones, are\n * made non-enumerable as well.\n */\n var hasDontEnumBug;\n\n /** Detect if own properties are iterated after inherited properties (IE < 9) */\n var iteratesOwnLast;\n\n /**\n * Detect if `Array#shift` and `Array#splice` augment array-like objects\n * incorrectly:\n *\n * Firefox < 10, IE compatibility mode, and IE < 9 have buggy Array `shift()`\n * and `splice()` functions that fail to remove the last element, `value[0]`,\n * of array-like objects even though the `length` property is set to `0`.\n * The `shift()` method is buggy in IE 8 compatibility mode, while `splice()`\n * is buggy regardless of mode in IE < 9 and buggy in compatibility mode in IE 9.\n */\n var hasObjectSpliceBug = (hasObjectSpliceBug = { '0': 1, 'length': 1 },\n arrayRef.splice.call(hasObjectSpliceBug, 0, 1), hasObjectSpliceBug[0]);\n\n /** Detect if an `arguments` object's indexes are non-enumerable (IE < 9) */\n var noArgsEnum = true;\n\n (function() {\n var props = [];\n function ctor() { this.x = 1; }\n ctor.prototype = { 'valueOf': 1, 'y': 1 };\n for (var prop in new ctor) { props.push(prop); }\n for (prop in arguments) { noArgsEnum = !prop; }\n\n hasDontEnumBug = !/valueOf/.test(props);\n iteratesOwnLast = props[0] != 'x';\n }(1));\n\n /** Detect if an `arguments` object's [[Class]] is unresolvable (Firefox < 4, IE < 9) */\n var noArgsClass = !isArguments(arguments);\n\n /** Detect if `Array#slice` cannot be used to convert strings to arrays (Opera < 10.52) */\n var noArraySliceOnStrings = slice.call('x')[0] != 'x';\n\n /**\n * Detect lack of support for accessing string characters by index:\n *\n * IE < 8 can't access characters by index and IE 8 can only access\n * characters by index on string literals.\n */\n var noCharByIndex = ('x'[0] + Object('x')[0]) != 'xx';\n\n /**\n * Detect if a node's [[Class]] is unresolvable (IE < 9)\n * and that the JS engine won't error when attempting to coerce an object to\n * a string without a `toString` property value of `typeof` \"function\".\n */\n try {\n var noNodeClass = ({ 'toString': 0 } + '', toString.call(window.document || 0) == objectClass);\n } catch(e) { }\n\n /* Detect if `Function#bind` exists and is inferred to be fast (all but V8) */\n var isBindFast = nativeBind && /\\n|Opera/.test(nativeBind + toString.call(window.opera));\n\n /* Detect if `Object.keys` exists and is inferred to be fast (IE, Opera, V8) */\n var isKeysFast = nativeKeys && /^.+$|true/.test(nativeKeys + !!window.attachEvent);\n\n /**\n * Detect if sourceURL syntax is usable without erroring:\n *\n * The JS engine in Adobe products, like InDesign, will throw a syntax error\n * when it encounters a single line comment beginning with the `@` symbol.\n *\n * The JS engine in Narwhal will generate the function `function anonymous(){//}`\n * and throw a syntax error.\n *\n * Avoid comments beginning `@` symbols in IE because they are part of its\n * non-standard conditional compilation support.\n * http://msdn.microsoft.com/en-us/library/121hztk3(v=vs.94).aspx\n */\n try {\n var useSourceURL = (Function('//@')(), !window.attachEvent);\n } catch(e) { }\n\n /** Used to identify object classifications that `_.clone` supports */\n var cloneableClasses = {};\n cloneableClasses[argsClass] = cloneableClasses[funcClass] = false;\n cloneableClasses[arrayClass] = cloneableClasses[boolClass] = cloneableClasses[dateClass] =\n cloneableClasses[numberClass] = cloneableClasses[objectClass] = cloneableClasses[regexpClass] =\n cloneableClasses[stringClass] = true;\n\n /** Used to determine if values are of the language type Object */\n var objectTypes = {\n 'boolean': false,\n 'function': true,\n 'object': true,\n 'number': false,\n 'string': false,\n 'undefined': false\n };\n\n /** Used to escape characters for inclusion in compiled string literals */\n var stringEscapes = {\n '\\\\': '\\\\',\n \"'\": \"'\",\n '\\n': 'n',\n '\\r': 'r',\n '\\t': 't',\n '\\u2028': 'u2028',\n '\\u2029': 'u2029'\n };\n\n /*--------------------------------------------------------------------------*/\n\n /**\n * The `lodash` function.\n *\n * @name _\n * @constructor\n * @category Chaining\n * @param {Mixed} value The value to wrap in a `lodash` instance.\n * @returns {Object} Returns a `lodash` instance.\n */\n function lodash(value) {\n // exit early if already wrapped\n if (value && value.__wrapped__) {\n return value;\n }\n // allow invoking `lodash` without the `new` operator\n if (!(this instanceof lodash)) {\n return new lodash(value);\n }\n this.__wrapped__ = value;\n }\n\n /**\n * By default, the template delimiters used by Lo-Dash are similar to those in\n * embedded Ruby (ERB). Change the following template settings to use alternative\n * delimiters.\n *\n * @static\n * @memberOf _\n * @type Object\n */\n lodash.templateSettings = {\n\n /**\n * Used to detect `data` property values to be HTML-escaped.\n *\n * @static\n * @memberOf _.templateSettings\n * @type RegExp\n */\n 'escape': /<%-([\\s\\S]+?)%>/g,\n\n /**\n * Used to detect code to be evaluated.\n *\n * @static\n * @memberOf _.templateSettings\n * @type RegExp\n */\n 'evaluate': /<%([\\s\\S]+?)%>/g,\n\n /**\n * Used to detect `data` property values to inject.\n *\n * @static\n * @memberOf _.templateSettings\n * @type RegExp\n */\n 'interpolate': reInterpolate,\n\n /**\n * Used to reference the data object in the template text.\n *\n * @static\n * @memberOf _.templateSettings\n * @type String\n */\n 'variable': ''\n };\n\n /*--------------------------------------------------------------------------*/\n\n /**\n * The template used to create iterator functions.\n *\n * @private\n * @param {Obect} data The data object used to populate the text.\n * @returns {String} Returns the interpolated text.\n */\n var iteratorTemplate = template(\n // conditional strict mode\n '<% if (obj.useStrict) { %>\\'use strict\\';\\n<% } %>' +\n\n // the `iteratee` may be reassigned by the `top` snippet\n 'var index, value, iteratee = <%= firstArg %>, ' +\n // assign the `result` variable an initial value\n 'result = <%= firstArg %>;\\n' +\n // exit early if the first argument is falsey\n 'if (!<%= firstArg %>) return result;\\n' +\n // add code before the iteration branches\n '<%= top %>;\\n' +\n\n // array-like iteration:\n '<% if (arrayLoop) { %>' +\n 'var length = iteratee.length; index = -1;\\n' +\n 'if (typeof length == \\'number\\') {' +\n\n // add support for accessing string characters by index if needed\n ' <% if (noCharByIndex) { %>\\n' +\n ' if (isString(iteratee)) {\\n' +\n ' iteratee = iteratee.split(\\'\\')\\n' +\n ' }' +\n ' <% } %>\\n' +\n\n // iterate over the array-like value\n ' while (++index < length) {\\n' +\n ' value = iteratee[index];\\n' +\n ' <%= arrayLoop %>\\n' +\n ' }\\n' +\n '}\\n' +\n 'else {' +\n\n // object iteration:\n // add support for iterating over `arguments` objects if needed\n ' <% } else if (noArgsEnum) { %>\\n' +\n ' var length = iteratee.length; index = -1;\\n' +\n ' if (length && isArguments(iteratee)) {\\n' +\n ' while (++index < length) {\\n' +\n ' value = iteratee[index += \\'\\'];\\n' +\n ' <%= objectLoop %>\\n' +\n ' }\\n' +\n ' } else {' +\n ' <% } %>' +\n\n // Firefox < 3.6, Opera > 9.50 - Opera < 11.60, and Safari < 5.1\n // (if the prototype or a property on the prototype has been set)\n // incorrectly sets a function's `prototype` property [[Enumerable]]\n // value to `true`. Because of this Lo-Dash standardizes on skipping\n // the the `prototype` property of functions regardless of its\n // [[Enumerable]] value.\n ' <% if (!hasDontEnumBug) { %>\\n' +\n ' var skipProto = typeof iteratee == \\'function\\' && \\n' +\n ' propertyIsEnumerable.call(iteratee, \\'prototype\\');\\n' +\n ' <% } %>' +\n\n // iterate own properties using `Object.keys` if it's fast\n ' <% if (isKeysFast && useHas) { %>\\n' +\n ' var ownIndex = -1,\\n' +\n ' ownProps = objectTypes[typeof iteratee] ? nativeKeys(iteratee) : [],\\n' +\n ' length = ownProps.length;\\n\\n' +\n ' while (++ownIndex < length) {\\n' +\n ' index = ownProps[ownIndex];\\n' +\n ' <% if (!hasDontEnumBug) { %>if (!(skipProto && index == \\'prototype\\')) {\\n <% } %>' +\n ' value = iteratee[index];\\n' +\n ' <%= objectLoop %>\\n' +\n ' <% if (!hasDontEnumBug) { %>}\\n<% } %>' +\n ' }' +\n\n // else using a for-in loop\n ' <% } else { %>\\n' +\n ' for (index in iteratee) {<%' +\n ' if (!hasDontEnumBug || useHas) { %>\\n if (<%' +\n ' if (!hasDontEnumBug) { %>!(skipProto && index == \\'prototype\\')<% }' +\n ' if (!hasDontEnumBug && useHas) { %> && <% }' +\n ' if (useHas) { %>hasOwnProperty.call(iteratee, index)<% }' +\n ' %>) {' +\n ' <% } %>\\n' +\n ' value = iteratee[index];\\n' +\n ' <%= objectLoop %>;' +\n ' <% if (!hasDontEnumBug || useHas) { %>\\n }<% } %>\\n' +\n ' }' +\n ' <% } %>' +\n\n // Because IE < 9 can't set the `[[Enumerable]]` attribute of an\n // existing property and the `constructor` property of a prototype\n // defaults to non-enumerable, Lo-Dash skips the `constructor`\n // property when it infers it's iterating over a `prototype` object.\n ' <% if (hasDontEnumBug) { %>\\n\\n' +\n ' var ctor = iteratee.constructor;\\n' +\n ' <% for (var k = 0; k < 7; k++) { %>\\n' +\n ' index = \\'<%= shadowed[k] %>\\';\\n' +\n ' if (<%' +\n ' if (shadowed[k] == \\'constructor\\') {' +\n ' %>!(ctor && ctor.prototype === iteratee) && <%' +\n ' } %>hasOwnProperty.call(iteratee, index)) {\\n' +\n ' value = iteratee[index];\\n' +\n ' <%= objectLoop %>\\n' +\n ' }' +\n ' <% } %>' +\n ' <% } %>' +\n ' <% if (arrayLoop || noArgsEnum) { %>\\n}<% } %>\\n' +\n\n // add code to the bottom of the iteration function\n '<%= bottom %>;\\n' +\n // finally, return the `result`\n 'return result'\n );\n\n /**\n * Reusable iterator options shared by `forEach`, `forIn`, and `forOwn`.\n */\n var forEachIteratorOptions = {\n 'args': 'collection, callback, thisArg',\n 'top': 'callback = createCallback(callback, thisArg)',\n 'arrayLoop': 'if (callback(value, index, collection) === false) return result',\n 'objectLoop': 'if (callback(value, index, collection) === false) return result'\n };\n\n /** Reusable iterator options for `defaults`, and `extend` */\n var extendIteratorOptions = {\n 'useHas': false,\n 'args': 'object',\n 'top':\n 'for (var argsIndex = 1, argsLength = arguments.length; argsIndex < argsLength; argsIndex++) {\\n' +\n ' if (iteratee = arguments[argsIndex]) {',\n 'objectLoop': 'result[index] = value',\n 'bottom': ' }\\n}'\n };\n\n /** Reusable iterator options for `forIn` and `forOwn` */\n var forOwnIteratorOptions = {\n 'arrayLoop': null\n };\n\n /*--------------------------------------------------------------------------*/\n\n /**\n * Creates a function optimized to search large arrays for a given `value`,\n * starting at `fromIndex`, using strict equality for comparisons, i.e. `===`.\n *\n * @private\n * @param {Array} array The array to search.\n * @param {Mixed} value The value to search for.\n * @param {Number} [fromIndex=0] The index to search from.\n * @param {Number} [largeSize=30] The length at which an array is considered large.\n * @returns {Boolean} Returns `true` if `value` is found, else `false`.\n */\n function cachedContains(array, fromIndex, largeSize) {\n fromIndex || (fromIndex = 0);\n\n var length = array.length,\n isLarge = (length - fromIndex) >= (largeSize || largeArraySize);\n\n if (isLarge) {\n var cache = {},\n index = fromIndex - 1;\n\n while (++index < length) {\n // manually coerce `value` to a string because `hasOwnProperty`, in some\n // older versions of Firefox, coerces objects incorrectly\n var key = array[index] + '';\n (hasOwnProperty.call(cache, key) ? cache[key] : (cache[key] = [])).push(array[index]);\n }\n }\n return function(value) {\n if (isLarge) {\n var key = value + '';\n return hasOwnProperty.call(cache, key) && indexOf(cache[key], value) > -1;\n }\n return indexOf(array, value, fromIndex) > -1;\n }\n }\n\n /**\n * Used by `_.max` and `_.min` as the default `callback` when a given\n * `collection` is a string value.\n *\n * @private\n * @param {String} value The character to inspect.\n * @returns {Number} Returns the code unit of given character.\n */\n function charAtCallback(value) {\n return value.charCodeAt(0);\n }\n\n /**\n * Used by `sortBy` to compare transformed `collection` values, stable sorting\n * them in ascending order.\n *\n * @private\n * @param {Object} a The object to compare to `b`.\n * @param {Object} b The object to compare to `a`.\n * @returns {Number} Returns the sort order indicator of `1` or `-1`.\n */\n function compareAscending(a, b) {\n var ai = a.index,\n bi = b.index;\n\n a = a.criteria;\n b = b.criteria;\n\n // ensure a stable sort in V8 and other engines\n // http://code.google.com/p/v8/issues/detail?id=90\n if (a !== b) {\n if (a > b || a === undefined) {\n return 1;\n }\n if (a < b || b === undefined) {\n return -1;\n }\n }\n return ai < bi ? -1 : 1;\n }\n\n /**\n * Creates a function that, when called, invokes `func` with the `this`\n * binding of `thisArg` and prepends any `partailArgs` to the arguments passed\n * to the bound function.\n *\n * @private\n * @param {Function|String} func The function to bind or the method name.\n * @param {Mixed} [thisArg] The `this` binding of `func`.\n * @param {Array} partialArgs An array of arguments to be partially applied.\n * @returns {Function} Returns the new bound function.\n */\n function createBound(func, thisArg, partialArgs) {\n var isFunc = isFunction(func),\n isPartial = !partialArgs,\n methodName = func;\n\n // juggle arguments\n if (isPartial) {\n partialArgs = thisArg;\n }\n\n function bound() {\n // `Function#bind` spec\n // http://es5.github.com/#x15.3.4.5\n var args = arguments,\n thisBinding = isPartial ? this : thisArg;\n\n if (!isFunc) {\n func = thisArg[methodName];\n }\n if (partialArgs.length) {\n args = args.length\n ? partialArgs.concat(slice.call(args))\n : partialArgs;\n }\n if (this instanceof bound) {\n // get `func` instance if `bound` is invoked in a `new` expression\n noop.prototype = func.prototype;\n thisBinding = new noop;\n\n // mimic the constructor's `return` behavior\n // http://es5.github.com/#x13.2.2\n var result = func.apply(thisBinding, args);\n return isObject(result)\n ? result\n : thisBinding\n }\n return func.apply(thisBinding, args);\n }\n return bound;\n }\n\n /**\n * Produces an iteration callback bound to an optional `thisArg`. If `func` is\n * a property name, the callback will return the property value for a given element.\n *\n * @private\n * @param {Function|String} [func=identity|property] The function called per\n * iteration or property name to query.\n * @param {Mixed} [thisArg] The `this` binding of `callback`.\n * @returns {Function} Returns a callback function.\n */\n function createCallback(func, thisArg) {\n if (!func) {\n return identity;\n }\n if (typeof func != 'function') {\n return function(object) {\n return object[func];\n };\n }\n if (thisArg !== undefined) {\n return function(value, index, object) {\n return func.call(thisArg, value, index, object);\n };\n }\n return func;\n }\n\n /**\n * Creates compiled iteration functions.\n *\n * @private\n * @param {Object} [options1, options2, ...] The compile options object(s).\n * useHas - A boolean to specify using `hasOwnProperty` checks in the object loop.\n * args - A string of comma separated arguments the iteration function will accept.\n * top - A string of code to execute before the iteration branches.\n * arrayLoop - A string of code to execute in the array loop.\n * objectLoop - A string of code to execute in the object loop.\n * bottom - A string of code to execute after the iteration branches.\n *\n * @returns {Function} Returns the compiled function.\n */\n function createIterator() {\n var data = {\n 'arrayLoop': '',\n 'bottom': '',\n 'hasDontEnumBug': hasDontEnumBug,\n 'isKeysFast': isKeysFast,\n 'objectLoop': '',\n 'noArgsEnum': noArgsEnum,\n 'noCharByIndex': noCharByIndex,\n 'shadowed': shadowed,\n 'top': '',\n 'useHas': true\n };\n\n // merge options into a template data object\n for (var object, index = 0; object = arguments[index]; index++) {\n for (var key in object) {\n data[key] = object[key];\n }\n }\n var args = data.args;\n data.firstArg = /^[^,]+/.exec(args)[0];\n\n // create the function factory\n var factory = Function(\n 'createCallback, hasOwnProperty, isArguments, isString, objectTypes, ' +\n 'nativeKeys, propertyIsEnumerable',\n 'return function(' + args + ') {\\n' + iteratorTemplate(data) + '\\n}'\n );\n // return the compiled function\n return factory(\n createCallback, hasOwnProperty, isArguments, isString, objectTypes,\n nativeKeys, propertyIsEnumerable\n );\n }\n\n /**\n * Used by `template` to escape characters for inclusion in compiled\n * string literals.\n *\n * @private\n * @param {String} match The matched character to escape.\n * @returns {String} Returns the escaped character.\n */\n function escapeStringChar(match) {\n return '\\\\' + stringEscapes[match];\n }\n\n /**\n * Used by `escape` to convert characters to HTML entities.\n *\n * @private\n * @param {String} match The matched character to escape.\n * @returns {String} Returns the escaped character.\n */\n function escapeHtmlChar(match) {\n return htmlEscapes[match];\n }\n\n /**\n * A no-operation function.\n *\n * @private\n */\n function noop() {\n // no operation performed\n }\n\n /**\n * Used by `unescape` to convert HTML entities to characters.\n *\n * @private\n * @param {String} match The matched character to unescape.\n * @returns {String} Returns the unescaped character.\n */\n function unescapeHtmlChar(match) {\n return htmlUnescapes[match];\n }\n\n /*--------------------------------------------------------------------------*/\n\n /**\n * Checks if `value` is an `arguments` object.\n *\n * @static\n * @memberOf _\n * @category Objects\n * @param {Mixed} value The value to check.\n * @returns {Boolean} Returns `true` if the `value` is an `arguments` object, else `false`.\n * @example\n *\n * (function() { return _.isArguments(arguments); })(1, 2, 3);\n * // => true\n *\n * _.isArguments([1, 2, 3]);\n * // => false\n */\n function isArguments(value) {\n return toString.call(value) == argsClass;\n }\n // fallback for browsers that can't detect `arguments` objects by [[Class]]\n if (noArgsClass) {\n isArguments = function(value) {\n return value ? hasOwnProperty.call(value, 'callee') : false;\n };\n }\n\n /**\n * Iterates over `object`'s own and inherited enumerable properties, executing\n * the `callback` for each property. The `callback` is bound to `thisArg` and\n * invoked with three arguments; (value, key, object). Callbacks may exit iteration\n * early by explicitly returning `false`.\n *\n * @static\n * @memberOf _\n * @category Objects\n * @param {Object} object The object to iterate over.\n * @param {Function} callback The function called per iteration.\n * @param {Mixed} [thisArg] The `this` binding of `callback`.\n * @returns {Object} Returns `object`.\n * @example\n *\n * function Dog(name) {\n * this.name = name;\n * }\n *\n * Dog.prototype.bark = function() {\n * alert('Woof, woof!');\n * };\n *\n * _.forIn(new Dog('Dagny'), function(value, key) {\n * alert(key);\n * });\n * // => alerts 'name' and 'bark' (order is not guaranteed)\n */\n var forIn = createIterator(forEachIteratorOptions, forOwnIteratorOptions, {\n 'useHas': false\n });\n\n /**\n * Iterates over `object`'s own enumerable properties, executing the `callback`\n * for each property. The `callback` is bound to `thisArg` and invoked with three\n * arguments; (value, key, object). Callbacks may exit iteration early by explicitly\n * returning `false`.\n *\n * @static\n * @memberOf _\n * @category Objects\n * @param {Object} object The object to iterate over.\n * @param {Function} callback The function called per iteration.\n * @param {Mixed} [thisArg] The `this` binding of `callback`.\n * @returns {Object} Returns `object`.\n * @example\n *\n * _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) {\n * alert(key);\n * });\n * // => alerts '0', '1', and 'length' (order is not guaranteed)\n */\n var forOwn = createIterator(forEachIteratorOptions, forOwnIteratorOptions);\n\n /**\n * A fallback implementation of `isPlainObject` that checks if a given `value`\n * is an object created by the `Object` constructor, assuming objects created\n * by the `Object` constructor have no inherited enumerable properties and that\n * there are no `Object.prototype` extensions.\n *\n * @private\n * @param {Mixed} value The value to check.\n * @returns {Boolean} Returns `true` if `value` is a plain object, else `false`.\n */\n function shimIsPlainObject(value) {\n // avoid non-objects and false positives for `arguments` objects\n var result = false;\n if (!(value && typeof value == 'object') || isArguments(value)) {\n return result;\n }\n // IE < 9 presents DOM nodes as `Object` objects except they have `toString`\n // methods that are `typeof` \"string\" and still can coerce nodes to strings.\n // Also check that the constructor is `Object` (i.e. `Object instanceof Object`)\n var ctor = value.constructor;\n if ((!noNodeClass || !(typeof value.toString != 'function' && typeof (value + '') == 'string')) &&\n (!isFunction(ctor) || ctor instanceof ctor)) {\n // IE < 9 iterates inherited properties before own properties. If the first\n // iterated property is an object's own property then there are no inherited\n // enumerable properties.\n if (iteratesOwnLast) {\n forIn(value, function(value, key, object) {\n result = !hasOwnProperty.call(object, key);\n return false;\n });\n return result === false;\n }\n // In most environments an object's own properties are iterated before\n // its inherited properties. If the last iterated property is an object's\n // own property then there are no inherited enumerable properties.\n forIn(value, function(value, key) {\n result = key;\n });\n return result === false || hasOwnProperty.call(value, result);\n }\n return result;\n }\n\n /**\n * A fallback implementation of `Object.keys` that produces an array of the\n * given object's own enumerable property names.\n *\n * @private\n * @param {Object} object The object to inspect.\n * @returns {Array} Returns a new array of property names.\n */\n function shimKeys(object) {\n var result = [];\n forOwn(object, function(value, key) {\n result.push(key);\n });\n return result;\n }\n\n /**\n * Used to convert characters to HTML entities:\n *\n * Though the `>` character is escaped for symmetry, characters like `>` and `/`\n * don't require escaping in HTML and have no special meaning unless they're part\n * of a tag or an unquoted attribute value.\n * http://mathiasbynens.be/notes/ambiguous-ampersands (under \"semi-related fun fact\")\n */\n var htmlEscapes = {\n '&': '&',\n '<': '<',\n '>': '>',\n '\"': '"',\n \"'\": '''\n };\n\n /** Used to convert HTML entities to characters */\n var htmlUnescapes = invert(htmlEscapes);\n\n /*--------------------------------------------------------------------------*/\n\n /**\n * Creates a clone of `value`. If `deep` is `true`, all nested objects will\n * also be cloned otherwise they will be assigned by reference. Functions, DOM\n * nodes, `arguments` objects, and objects created by constructors other than\n * `Object` are **not** cloned.\n *\n * @static\n * @memberOf _\n * @category Objects\n * @param {Mixed} value The value to clone.\n * @param {Boolean} deep A flag to indicate a deep clone.\n * @param- {Object} [guard] Internally used to allow this method to work with\n * others like `_.map` without using their callback `index` argument for `deep`.\n * @param- {Array} [stackA=[]] Internally used to track traversed source objects.\n * @param- {Array} [stackB=[]] Internally used to associate clones with their\n * source counterparts.\n * @returns {Mixed} Returns the cloned `value`.\n * @example\n *\n * var stooges = [\n * { 'name': 'moe', 'age': 40 },\n * { 'name': 'larry', 'age': 50 },\n * { 'name': 'curly', 'age': 60 }\n * ];\n *\n * _.clone({ 'name': 'moe' });\n * // => { 'name': 'moe' }\n *\n * var shallow = _.clone(stooges);\n * shallow[0] === stooges[0];\n * // => true\n *\n * var deep = _.clone(stooges, true);\n * shallow[0] === stooges[0];\n * // => false\n */\n function clone(value, deep, guard, stackA, stackB) {\n if (value == null) {\n return value;\n }\n if (guard) {\n deep = false;\n }\n // inspect [[Class]]\n var isObj = isObject(value);\n if (isObj) {\n // don't clone `arguments` objects, functions, or non-object Objects\n var className = toString.call(value);\n if (!cloneableClasses[className] || (noArgsClass && isArguments(value))) {\n return value;\n }\n var isArr = className == arrayClass;\n isObj = isArr || (className == objectClass ? isPlainObject(value) : isObj);\n }\n // shallow clone\n if (!isObj || !deep) {\n // don't clone functions\n return isObj\n ? (isArr ? slice.call(value) : extend({}, value))\n : value;\n }\n\n var ctor = value.constructor;\n switch (className) {\n case boolClass:\n case dateClass:\n return new ctor(+value);\n\n case numberClass:\n case stringClass:\n return new ctor(value);\n\n case regexpClass:\n return ctor(value.source, reFlags.exec(value));\n }\n // check for circular references and return corresponding clone\n stackA || (stackA = []);\n stackB || (stackB = []);\n\n var length = stackA.length;\n while (length--) {\n if (stackA[length] == value) {\n return stackB[length];\n }\n }\n // init cloned object\n var result = isArr ? ctor(value.length) : {};\n\n // add the source value to the stack of traversed objects\n // and associate it with its clone\n stackA.push(value);\n stackB.push(result);\n\n // recursively populate clone (susceptible to call stack limits)\n (isArr ? forEach : forOwn)(value, function(objValue, key) {\n result[key] = clone(objValue, deep, null, stackA, stackB);\n });\n\n return result;\n }\n\n /**\n * Assigns enumerable properties of the default object(s) to the `destination`\n * object for all `destination` properties that resolve to `null`/`undefined`.\n * Once a property is set, additional defaults of the same property will be\n * ignored.\n *\n * @static\n * @memberOf _\n * @category Objects\n * @param {Object} object The destination object.\n * @param {Object} [default1, default2, ...] The default objects.\n * @returns {Object} Returns the destination object.\n * @example\n *\n * var iceCream = { 'flavor': 'chocolate' };\n * _.defaults(iceCream, { 'flavor': 'vanilla', 'sprinkles': 'rainbow' });\n * // => { 'flavor': 'chocolate', 'sprinkles': 'rainbow' }\n */\n var defaults = createIterator(extendIteratorOptions, {\n 'objectLoop': 'if (result[index] == null) ' + extendIteratorOptions.objectLoop\n });\n\n /**\n * Assigns enumerable properties of the source object(s) to the `destination`\n * object. Subsequent sources will overwrite propery assignments of previous\n * sources.\n *\n * @static\n * @memberOf _\n * @category Objects\n * @param {Object} object The destination object.\n * @param {Object} [source1, source2, ...] The source objects.\n * @returns {Object} Returns the destination object.\n * @example\n *\n * _.extend({ 'name': 'moe' }, { 'age': 40 });\n * // => { 'name': 'moe', 'age': 40 }\n */\n var extend = createIterator(extendIteratorOptions);\n\n /**\n * Creates a sorted array of all enumerable properties, own and inherited,\n * of `object` that have function values.\n *\n * @static\n * @memberOf _\n * @alias methods\n * @category Objects\n * @param {Object} object The object to inspect.\n * @returns {Array} Returns a new array of property names that have function values.\n * @example\n *\n * _.functions(_);\n * // => ['all', 'any', 'bind', 'bindAll', 'clone', 'compact', 'compose', ...]\n */\n function functions(object) {\n var result = [];\n forIn(object, function(value, key) {\n if (isFunction(value)) {\n result.push(key);\n }\n });\n return result.sort();\n }\n\n /**\n * Checks if the specified object `property` exists and is a direct property,\n * instead of an inherited property.\n *\n * @static\n * @memberOf _\n * @category Objects\n * @param {Object} object The object to check.\n * @param {String} property The property to check for.\n * @returns {Boolean} Returns `true` if key is a direct property, else `false`.\n * @example\n *\n * _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b');\n * // => true\n */\n function has(object, property) {\n return object ? hasOwnProperty.call(object, property) : false;\n }\n\n /**\n * Creates an object composed of the inverted keys and values of the given `object`.\n *\n * @static\n * @memberOf _\n * @category Objects\n * @param {Object} object The object to invert.\n * @returns {Object} Returns the created inverted object.\n * @example\n *\n * _.invert({ 'first': 'Moe', 'second': 'Larry', 'third': 'Curly' });\n * // => { 'Moe': 'first', 'Larry': 'second', 'Curly': 'third' } (order is not guaranteed)\n */\n function invert(object) {\n var result = {};\n forOwn(object, function(value, key) {\n result[value] = key;\n });\n return result;\n }\n\n /**\n * Checks if `value` is an array.\n *\n * @static\n * @memberOf _\n * @category Objects\n * @param {Mixed} value The value to check.\n * @returns {Boolean} Returns `true` if the `value` is an array, else `false`.\n * @example\n *\n * (function() { return _.isArray(arguments); })();\n * // => false\n *\n * _.isArray([1, 2, 3]);\n * // => true\n */\n var isArray = nativeIsArray || function(value) {\n return toString.call(value) == arrayClass;\n };\n\n /**\n * Checks if `value` is a boolean (`true` or `false`) value.\n *\n * @static\n * @memberOf _\n * @category Objects\n * @param {Mixed} value The value to check.\n * @returns {Boolean} Returns `true` if the `value` is a boolean value, else `false`.\n * @example\n *\n * _.isBoolean(null);\n * // => false\n */\n function isBoolean(value) {\n return value === true || value === false || toString.call(value) == boolClass;\n }\n\n /**\n * Checks if `value` is a date.\n *\n * @static\n * @memberOf _\n * @category Objects\n * @param {Mixed} value The value to check.\n * @returns {Boolean} Returns `true` if the `value` is a date, else `false`.\n * @example\n *\n * _.isDate(new Date);\n * // => true\n */\n function isDate(value) {\n return toString.call(value) == dateClass;\n }\n\n /**\n * Checks if `value` is a DOM element.\n *\n * @static\n * @memberOf _\n * @category Objects\n * @param {Mixed} value The value to check.\n * @returns {Boolean} Returns `true` if the `value` is a DOM element, else `false`.\n * @example\n *\n * _.isElement(document.body);\n * // => true\n */\n function isElement(value) {\n return value ? value.nodeType === 1 : false;\n }\n\n /**\n * Checks if `value` is empty. Arrays, strings, or `arguments` objects with a\n * length of `0` and objects with no own enumerable properties are considered\n * \"empty\".\n *\n * @static\n * @memberOf _\n * @category Objects\n * @param {Array|Object|String} value The value to inspect.\n * @returns {Boolean} Returns `true` if the `value` is empty, else `false`.\n * @example\n *\n * _.isEmpty([1, 2, 3]);\n * // => false\n *\n * _.isEmpty({});\n * // => true\n *\n * _.isEmpty('');\n * // => true\n */\n function isEmpty(value) {\n var result = true;\n if (!value) {\n return result;\n }\n var className = toString.call(value),\n length = value.length;\n\n if ((className == arrayClass || className == stringClass ||\n className == argsClass || (noArgsClass && isArguments(value))) ||\n (className == objectClass && typeof length == 'number' && isFunction(value.splice))) {\n return !length;\n }\n forOwn(value, function() {\n return (result = false);\n });\n return result;\n }\n\n /**\n * Performs a deep comparison between two values to determine if they are\n * equivalent to each other.\n *\n * @static\n * @memberOf _\n * @category Objects\n * @param {Mixed} a The value to compare.\n * @param {Mixed} b The other value to compare.\n * @param- {Object} [stackA=[]] Internally used track traversed `a` objects.\n * @param- {Object} [stackB=[]] Internally used track traversed `b` objects.\n * @returns {Boolean} Returns `true` if the values are equvalent, else `false`.\n * @example\n *\n * var moe = { 'name': 'moe', 'luckyNumbers': [13, 27, 34] };\n * var clone = { 'name': 'moe', 'luckyNumbers': [13, 27, 34] };\n *\n * moe == clone;\n * // => false\n *\n * _.isEqual(moe, clone);\n * // => true\n */\n function isEqual(a, b, stackA, stackB) {\n // exit early for identical values\n if (a === b) {\n // treat `+0` vs. `-0` as not equal\n return a !== 0 || (1 / a == 1 / b);\n }\n // a strict comparison is necessary because `null == undefined`\n if (a == null || b == null) {\n return a === b;\n }\n // compare [[Class]] names\n var className = toString.call(a);\n if (className != toString.call(b)) {\n return false;\n }\n switch (className) {\n case boolClass:\n case dateClass:\n // coerce dates and booleans to numbers, dates to milliseconds and booleans\n // to `1` or `0`, treating invalid dates coerced to `NaN` as not equal\n return +a == +b;\n\n case numberClass:\n // treat `NaN` vs. `NaN` as equal\n return a != +a\n ? b != +b\n // but treat `+0` vs. `-0` as not equal\n : (a == 0 ? (1 / a == 1 / b) : a == +b);\n\n case regexpClass:\n case stringClass:\n // coerce regexes to strings (http://es5.github.com/#x15.10.6.4)\n // treat string primitives and their corresponding object instances as equal\n return a == b + '';\n }\n // exit early, in older browsers, if `a` is array-like but not `b`\n var isArr = className == arrayClass || className == argsClass;\n if (noArgsClass && !isArr && (isArr = isArguments(a)) && !isArguments(b)) {\n return false;\n }\n if (!isArr) {\n // unwrap any `lodash` wrapped values\n if (a.__wrapped__ || b.__wrapped__) {\n return isEqual(a.__wrapped__ || a, b.__wrapped__ || b);\n }\n // exit for functions and DOM nodes\n if (className != objectClass || (noNodeClass && (\n (typeof a.toString != 'function' && typeof (a + '') == 'string') ||\n (typeof b.toString != 'function' && typeof (b + '') == 'string')))) {\n return false;\n }\n var ctorA = a.constructor,\n ctorB = b.constructor;\n\n // non `Object` object instances with different constructors are not equal\n if (ctorA != ctorB && !(\n isFunction(ctorA) && ctorA instanceof ctorA &&\n isFunction(ctorB) && ctorB instanceof ctorB\n )) {\n return false;\n }\n }\n // assume cyclic structures are equal\n // the algorithm for detecting cyclic structures is adapted from ES 5.1\n // section 15.12.3, abstract operation `JO` (http://es5.github.com/#x15.12.3)\n stackA || (stackA = []);\n stackB || (stackB = []);\n\n var length = stackA.length;\n while (length--) {\n if (stackA[length] == a) {\n return stackB[length] == b;\n }\n }\n\n var index = -1,\n result = true,\n size = 0;\n\n // add `a` and `b` to the stack of traversed objects\n stackA.push(a);\n stackB.push(b);\n\n // recursively compare objects and arrays (susceptible to call stack limits)\n if (isArr) {\n // compare lengths to determine if a deep comparison is necessary\n size = a.length;\n result = size == b.length;\n\n if (result) {\n // deep compare the contents, ignoring non-numeric properties\n while (size--) {\n if (!(result = isEqual(a[size], b[size], stackA, stackB))) {\n break;\n }\n }\n }\n return result;\n }\n // deep compare objects\n for (var key in a) {\n if (hasOwnProperty.call(a, key)) {\n // count the number of properties.\n size++;\n // deep compare each property value.\n if (!(hasOwnProperty.call(b, key) && isEqual(a[key], b[key], stackA, stackB))) {\n return false;\n }\n }\n }\n // ensure both objects have the same number of properties\n for (key in b) {\n // The JS engine in Adobe products, like InDesign, has a bug that causes\n // `!size--` to throw an error so it must be wrapped in parentheses.\n // https://github.com/documentcloud/underscore/issues/355\n if (hasOwnProperty.call(b, key) && !(size--)) {\n // `size` will be `-1` if `b` has more properties than `a`\n return false;\n }\n }\n // handle JScript [[DontEnum]] bug\n if (hasDontEnumBug) {\n while (++index < 7) {\n key = shadowed[index];\n if (hasOwnProperty.call(a, key) &&\n !(hasOwnProperty.call(b, key) && isEqual(a[key], b[key], stackA, stackB))) {\n return false;\n }\n }\n }\n return true;\n }\n\n /**\n * Checks if `value` is, or can be coerced to, a finite number.\n *\n * Note: This is not the same as native `isFinite`, which will return true for\n * booleans and empty strings. See http://es5.github.com/#x15.1.2.5.\n *\n * @deprecated\n * @static\n * @memberOf _\n * @category Objects\n * @param {Mixed} value The value to check.\n * @returns {Boolean} Returns `true` if the `value` is a finite number, else `false`.\n * @example\n *\n * _.isFinite(-101);\n * // => true\n *\n * _.isFinite('10');\n * // => true\n *\n * _.isFinite(true);\n * // => false\n *\n * _.isFinite('');\n * // => false\n *\n * _.isFinite(Infinity);\n * // => false\n */\n function isFinite(value) {\n return nativeIsFinite(value) && !nativeIsNaN(parseFloat(value));\n }\n\n /**\n * Checks if `value` is a function.\n *\n * @static\n * @memberOf _\n * @category Objects\n * @param {Mixed} value The value to check.\n * @returns {Boolean} Returns `true` if the `value` is a function, else `false`.\n * @example\n *\n * _.isFunction(_);\n * // => true\n */\n function isFunction(value) {\n return typeof value == 'function';\n }\n // fallback for older versions of Chrome and Safari\n if (isFunction(/x/)) {\n isFunction = function(value) {\n return toString.call(value) == funcClass;\n };\n }\n\n /**\n * Checks if `value` is the language type of Object.\n * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)\n *\n * @static\n * @memberOf _\n * @category Objects\n * @param {Mixed} value The value to check.\n * @returns {Boolean} Returns `true` if the `value` is an object, else `false`.\n * @example\n *\n * _.isObject({});\n * // => true\n *\n * _.isObject([1, 2, 3]);\n * // => true\n *\n * _.isObject(1);\n * // => false\n */\n function isObject(value) {\n // check if the value is the ECMAScript language type of Object\n // http://es5.github.com/#x8\n // and avoid a V8 bug\n // http://code.google.com/p/v8/issues/detail?id=2291\n return value ? objectTypes[typeof value] : false;\n }\n\n /**\n * Checks if `value` is `NaN`.\n *\n * Note: This is not the same as native `isNaN`, which will return true for\n * `undefined` and other values. See http://es5.github.com/#x15.1.2.4.\n *\n * @deprecated\n * @static\n * @memberOf _\n * @category Objects\n * @param {Mixed} value The value to check.\n * @returns {Boolean} Returns `true` if the `value` is `NaN`, else `false`.\n * @example\n *\n * _.isNaN(NaN);\n * // => true\n *\n * _.isNaN(new Number(NaN));\n * // => true\n *\n * isNaN(undefined);\n * // => true\n *\n * _.isNaN(undefined);\n * // => false\n */\n function isNaN(value) {\n // `NaN` as a primitive is the only value that is not equal to itself\n // (perform the [[Class]] check first to avoid errors with some host objects in IE)\n return toString.call(value) == numberClass && value != +value\n }\n\n /**\n * Checks if `value` is `null`.\n *\n * @deprecated\n * @static\n * @memberOf _\n * @category Objects\n * @param {Mixed} value The value to check.\n * @returns {Boolean} Returns `true` if the `value` is `null`, else `false`.\n * @example\n *\n * _.isNull(null);\n * // => true\n *\n * _.isNull(undefined);\n * // => false\n */\n function isNull(value) {\n return value === null;\n }\n\n /**\n * Checks if `value` is a number.\n *\n * @static\n * @memberOf _\n * @category Objects\n * @param {Mixed} value The value to check.\n * @returns {Boolean} Returns `true` if the `value` is a number, else `false`.\n * @example\n *\n * _.isNumber(8.4 * 5);\n * // => true\n */\n function isNumber(value) {\n return toString.call(value) == numberClass;\n }\n\n /**\n * Checks if a given `value` is an object created by the `Object` constructor.\n *\n * @static\n * @memberOf _\n * @category Objects\n * @param {Mixed} value The value to check.\n * @returns {Boolean} Returns `true` if `value` is a plain object, else `false`.\n * @example\n *\n * function Stooge(name, age) {\n * this.name = name;\n * this.age = age;\n * }\n *\n * _.isPlainObject(new Stooge('moe', 40));\n * // => false\n *\n * _.isPlainObject([1, 2, 3]);\n * // => false\n *\n * _.isPlainObject({ 'name': 'moe', 'age': 40 });\n * // => true\n */\n var isPlainObject = !getPrototypeOf ? shimIsPlainObject : function(value) {\n if (!(value && typeof value == 'object')) {\n return false;\n }\n var valueOf = value.valueOf,\n objProto = typeof valueOf == 'function' && (objProto = getPrototypeOf(valueOf)) && getPrototypeOf(objProto);\n\n return objProto\n ? value == objProto || (getPrototypeOf(value) == objProto && !isArguments(value))\n : shimIsPlainObject(value);\n };\n\n /**\n * Checks if `value` is a regular expression.\n *\n * @static\n * @memberOf _\n * @category Objects\n * @param {Mixed} value The value to check.\n * @returns {Boolean} Returns `true` if the `value` is a regular expression, else `false`.\n * @example\n *\n * _.isRegExp(/moe/);\n * // => true\n */\n function isRegExp(value) {\n return toString.call(value) == regexpClass;\n }\n\n /**\n * Checks if `value` is a string.\n *\n * @static\n * @memberOf _\n * @category Objects\n * @param {Mixed} value The value to check.\n * @returns {Boolean} Returns `true` if the `value` is a string, else `false`.\n * @example\n *\n * _.isString('moe');\n * // => true\n */\n function isString(value) {\n return toString.call(value) == stringClass;\n }\n\n /**\n * Checks if `value` is `undefined`.\n *\n * @deprecated\n * @static\n * @memberOf _\n * @category Objects\n * @param {Mixed} value The value to check.\n * @returns {Boolean} Returns `true` if the `value` is `undefined`, else `false`.\n * @example\n *\n * _.isUndefined(void 0);\n * // => true\n */\n function isUndefined(value) {\n return value === undefined;\n }\n\n /**\n * Creates an array composed of the own enumerable property names of `object`.\n *\n * @static\n * @memberOf _\n * @category Objects\n * @param {Object} object The object to inspect.\n * @returns {Array} Returns a new array of property names.\n * @example\n *\n * _.keys({ 'one': 1, 'two': 2, 'three': 3 });\n * // => ['one', 'two', 'three'] (order is not guaranteed)\n */\n var keys = !nativeKeys ? shimKeys : function(object) {\n // avoid iterating over the `prototype` property\n return typeof object == 'function' && propertyIsEnumerable.call(object, 'prototype')\n ? shimKeys(object)\n : (isObject(object) ? nativeKeys(object) : []);\n };\n\n /**\n * Merges enumerable properties of the source object(s) into the `destination`\n * object. Subsequent sources will overwrite propery assignments of previous\n * sources.\n *\n * @static\n * @memberOf _\n * @category Objects\n * @param {Object} object The destination object.\n * @param {Object} [source1, source2, ...] The source objects.\n * @param- {Object} [indicator] Internally used to indicate that the `stack`\n * argument is an array of traversed objects instead of another source object.\n * @param- {Array} [stackA=[]] Internally used to track traversed source objects.\n * @param- {Array} [stackB=[]] Internally used to associate values with their\n * source counterparts.\n * @returns {Object} Returns the destination object.\n * @example\n *\n * var stooges = [\n * { 'name': 'moe' },\n * { 'name': 'larry' }\n * ];\n *\n * var ages = [\n * { 'age': 40 },\n * { 'age': 50 }\n * ];\n *\n * _.merge(stooges, ages);\n * // => [{ 'name': 'moe', 'age': 40 }, { 'name': 'larry', 'age': 50 }]\n */\n function merge(object, source, indicator) {\n var args = arguments,\n index = 0,\n length = 2,\n stackA = args[3],\n stackB = args[4];\n\n if (indicator !== objectRef) {\n stackA = [];\n stackB = [];\n length = args.length;\n }\n while (++index < length) {\n forOwn(args[index], function(source, key) {\n var found, isArr, value;\n if (source && ((isArr = isArray(source)) || isPlainObject(source))) {\n // avoid merging previously merged cyclic sources\n var stackLength = stackA.length;\n while (stackLength--) {\n found = stackA[stackLength] == source;\n if (found) {\n break;\n }\n }\n if (found) {\n object[key] = stackB[stackLength];\n }\n else {\n // add `source` and associated `value` to the stack of traversed objects\n stackA.push(source);\n stackB.push(value = (value = object[key], isArr)\n ? (isArray(value) ? value : [])\n : (isPlainObject(value) ? value : {})\n );\n // recursively merge objects and arrays (susceptible to call stack limits)\n object[key] = merge(value, source, objectRef, stackA, stackB);\n }\n } else if (source != null) {\n object[key] = source;\n }\n });\n }\n return object;\n }\n\n /**\n * Creates a shallow clone of `object` excluding the specified properties.\n * Property names may be specified as individual arguments or as arrays of\n * property names. If `callback` is passed, it will be executed for each property\n * in the `object`, omitting the properties `callback` returns truthy for. The\n * `callback` is bound to `thisArg` and invoked with three arguments; (value, key, object).\n *\n * @static\n * @memberOf _\n * @category Objects\n * @param {Object} object The source object.\n * @param {Function|String} callback|[prop1, prop2, ...] The properties to omit\n * or the function called per iteration.\n * @param {Mixed} [thisArg] The `this` binding of `callback`.\n * @returns {Object} Returns an object without the omitted properties.\n * @example\n *\n * _.omit({ 'name': 'moe', 'age': 40, 'userid': 'moe1' }, 'userid');\n * // => { 'name': 'moe', 'age': 40 }\n *\n * _.omit({ 'name': 'moe', '_hint': 'knucklehead', '_seed': '96c4eb' }, function(value, key) {\n * return key.charAt(0) == '_';\n * });\n * // => { 'name': 'moe' }\n */\n function omit(object, callback, thisArg) {\n var isFunc = typeof callback == 'function',\n result = {};\n\n if (isFunc) {\n callback = createCallback(callback, thisArg);\n } else {\n var props = concat.apply(arrayRef, arguments);\n }\n forIn(object, function(value, key, object) {\n if (isFunc\n ? !callback(value, key, object)\n : indexOf(props, key, 1) < 0\n ) {\n result[key] = value;\n }\n });\n return result;\n }\n\n /**\n * Creates a two dimensional array of the given object's key-value pairs,\n * i.e. `[[key1, value1], [key2, value2]]`.\n *\n * @static\n * @memberOf _\n * @category Objects\n * @param {Object} object The object to inspect.\n * @returns {Array} Returns new array of key-value pairs.\n * @example\n *\n * _.pairs({ 'moe': 30, 'larry': 40, 'curly': 50 });\n * // => [['moe', 30], ['larry', 40], ['curly', 50]] (order is not guaranteed)\n */\n function pairs(object) {\n var result = [];\n forOwn(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n }\n\n /**\n * Creates a shallow clone of `object` composed of the specified properties.\n * Property names may be specified as individual arguments or as arrays of\n * property names. If `callback` is passed, it will be executed for each property\n * in the `object`, picking the properties `callback` returns truthy for. The\n * `callback` is bound to `thisArg` and invoked with three arguments; (value, key, object).\n *\n * @static\n * @memberOf _\n * @category Objects\n * @param {Object} object The source object.\n * @param {Function|String} callback|[prop1, prop2, ...] The properties to pick\n * or the function called per iteration.\n * @param {Mixed} [thisArg] The `this` binding of `callback`.\n * @returns {Object} Returns an object composed of the picked properties.\n * @example\n *\n * _.pick({ 'name': 'moe', 'age': 40, 'userid': 'moe1' }, 'name', 'age');\n * // => { 'name': 'moe', 'age': 40 }\n *\n * _.pick({ 'name': 'moe', '_hint': 'knucklehead', '_seed': '96c4eb' }, function(value, key) {\n * return key.charAt(0) != '_';\n * });\n * // => { 'name': 'moe' }\n */\n function pick(object, callback, thisArg) {\n var result = {};\n if (typeof callback != 'function') {\n var index = 0,\n props = concat.apply(arrayRef, arguments),\n length = props.length;\n\n while (++index < length) {\n var key = props[index];\n if (key in object) {\n result[key] = object[key];\n }\n }\n } else {\n callback = createCallback(callback, thisArg);\n forIn(object, function(value, key, object) {\n if (callback(value, key, object)) {\n result[key] = value;\n }\n });\n }\n return result;\n }\n\n /**\n * Creates an array composed of the own enumerable property values of `object`.\n *\n * @static\n * @memberOf _\n * @category Objects\n * @param {Object} object The object to inspect.\n * @returns {Array} Returns a new array of property values.\n * @example\n *\n * _.values({ 'one': 1, 'two': 2, 'three': 3 });\n * // => [1, 2, 3]\n */\n function values(object) {\n var result = [];\n forOwn(object, function(value) {\n result.push(value);\n });\n return result;\n }\n\n /*--------------------------------------------------------------------------*/\n\n /**\n * Checks if a given `target` element is present in a `collection` using strict\n * equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used\n * as the offset from the end of the collection.\n *\n * @static\n * @memberOf _\n * @alias include\n * @category Collections\n * @param {Array|Object|String} collection The collection to iterate over.\n * @param {Mixed} target The value to check for.\n * @param {Number} [fromIndex=0] The index to search from.\n * @returns {Boolean} Returns `true` if the `target` element is found, else `false`.\n * @example\n *\n * _.contains([1, 2, 3], 1);\n * // => true\n *\n * _.contains([1, 2, 3], 1, 2);\n * // => false\n *\n * _.contains({ 'name': 'moe', 'age': 40 }, 'moe');\n * // => true\n *\n * _.contains('curly', 'ur');\n * // => true\n */\n function contains(collection, target, fromIndex) {\n var index = -1,\n length = collection ? collection.length : 0;\n\n fromIndex = (fromIndex < 0 ? nativeMax(0, length + fromIndex) : fromIndex) || 0;\n if (typeof length == 'number') {\n return (isString(collection)\n ? collection.indexOf(target, fromIndex)\n : indexOf(collection, target, fromIndex)\n ) > -1;\n }\n return some(collection, function(value) {\n return ++index >= fromIndex && value === target;\n });\n }\n\n /**\n * Creates an object composed of keys returned from running each element of\n * `collection` through a `callback`. The corresponding value of each key is\n * the number of times the key was returned by `callback`. The `callback` is\n * bound to `thisArg` and invoked with three arguments; (value, index|key, collection).\n * The `callback` argument may also be the name of a property to count by (e.g. 'length').\n *\n * @static\n * @memberOf _\n * @category Collections\n * @param {Array|Object|String} collection The collection to iterate over.\n * @param {Function|String} callback|property The function called per iteration\n * or property name to count by.\n * @param {Mixed} [thisArg] The `this` binding of `callback`.\n * @returns {Object} Returns the composed aggregate object.\n * @example\n *\n * _.countBy([4.3, 6.1, 6.4], function(num) { return Math.floor(num); });\n * // => { '4': 1, '6': 2 }\n *\n * _.countBy([4.3, 6.1, 6.4], function(num) { return this.floor(num); }, Math);\n * // => { '4': 1, '6': 2 }\n *\n * _.countBy(['one', 'two', 'three'], 'length');\n * // => { '3': 2, '5': 1 }\n */\n function countBy(collection, callback, thisArg) {\n var result = {};\n callback = createCallback(callback, thisArg);\n forEach(collection, function(value, key, collection) {\n key = callback(value, key, collection);\n (hasOwnProperty.call(result, key) ? result[key]++ : result[key] = 1);\n });\n return result;\n }\n\n /**\n * Checks if the `callback` returns a truthy value for **all** elements of a\n * `collection`. The `callback` is bound to `thisArg` and invoked with three\n * arguments; (value, index|key, collection).\n *\n * @static\n * @memberOf _\n * @alias all\n * @category Collections\n * @param {Array|Object|String} collection The collection to iterate over.\n * @param {Function} [callback=identity] The function called per iteration.\n * @param {Mixed} [thisArg] The `this` binding of `callback`.\n * @returns {Boolean} Returns `true` if all elements pass the callback check,\n * else `false`.\n * @example\n *\n * _.every([true, 1, null, 'yes'], Boolean);\n * // => false\n */\n function every(collection, callback, thisArg) {\n var result = true;\n callback = createCallback(callback, thisArg);\n\n if (isArray(collection)) {\n var index = -1,\n length = collection.length;\n\n while (++index < length) {\n if (!(result = !!callback(collection[index], index, collection))) {\n break;\n }\n }\n } else {\n forEach(collection, function(value, index, collection) {\n return (result = !!callback(value, index, collection));\n });\n }\n return result;\n }\n\n /**\n * Examines each element in a `collection`, returning an array of all elements\n * the `callback` returns truthy for. The `callback` is bound to `thisArg` and\n * invoked with three arguments; (value, index|key, collection).\n *\n * @static\n * @memberOf _\n * @alias select\n * @category Collections\n * @param {Array|Object|String} collection The collection to iterate over.\n * @param {Function} [callback=identity] The function called per iteration.\n * @param {Mixed} [thisArg] The `this` binding of `callback`.\n * @returns {Array} Returns a new array of elements that passed the callback check.\n * @example\n *\n * var evens = _.filter([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; });\n * // => [2, 4, 6]\n */\n function filter(collection, callback, thisArg) {\n var result = [];\n callback = createCallback(callback, thisArg);\n forEach(collection, function(value, index, collection) {\n if (callback(value, index, collection)) {\n result.push(value);\n }\n });\n return result;\n }\n\n /**\n * Examines each element in a `collection`, returning the first one the `callback`\n * returns truthy for. The function returns as soon as it finds an acceptable\n * element, and does not iterate over the entire `collection`. The `callback` is\n * bound to `thisArg` and invoked with three arguments; (value, index|key, collection).\n *\n * @static\n * @memberOf _\n * @alias detect\n * @category Collections\n * @param {Array|Object|String} collection The collection to iterate over.\n * @param {Function} callback The function called per iteration.\n * @param {Mixed} [thisArg] The `this` binding of `callback`.\n * @returns {Mixed} Returns the element that passed the callback check,\n * else `undefined`.\n * @example\n *\n * var even = _.find([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; });\n * // => 2\n */\n function find(collection, callback, thisArg) {\n var result;\n callback = createCallback(callback, thisArg);\n forEach(collection, function(value, index, collection) {\n if (callback(value, index, collection)) {\n result = value;\n return false;\n }\n });\n return result;\n }\n\n /**\n * Iterates over a `collection`, executing the `callback` for each element in\n * the `collection`. The `callback` is bound to `thisArg` and invoked with three\n * arguments; (value, index|key, collection). Callbacks may exit iteration early\n * by explicitly returning `false`.\n *\n * @static\n * @memberOf _\n * @alias each\n * @category Collections\n * @param {Array|Object|String} collection The collection to iterate over.\n * @param {Function} callback The function called per iteration.\n * @param {Mixed} [thisArg] The `this` binding of `callback`.\n * @returns {Array|Object|String} Returns `collection`.\n * @example\n *\n * _([1, 2, 3]).forEach(alert).join(',');\n * // => alerts each number and returns '1,2,3'\n *\n * _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert);\n * // => alerts each number (order is not guaranteed)\n */\n var forEach = createIterator(forEachIteratorOptions);\n\n /**\n * Creates an object composed of keys returned from running each element of\n * `collection` through a `callback`. The corresponding value of each key is an\n * array of elements passed to `callback` that returned the key. The `callback`\n * is bound to `thisArg` and invoked with three arguments; (value, index|key, collection).\n * The `callback` argument may also be the name of a property to group by (e.g. 'length').\n *\n * @static\n * @memberOf _\n * @category Collections\n * @param {Array|Object|String} collection The collection to iterate over.\n * @param {Function|String} callback|property The function called per iteration\n * or property name to group by.\n * @param {Mixed} [thisArg] The `this` binding of `callback`.\n * @returns {Object} Returns the composed aggregate object.\n * @example\n *\n * _.groupBy([4.2, 6.1, 6.4], function(num) { return Math.floor(num); });\n * // => { '4': [4.2], '6': [6.1, 6.4] }\n *\n * _.groupBy([4.2, 6.1, 6.4], function(num) { return this.floor(num); }, Math);\n * // => { '4': [4.2], '6': [6.1, 6.4] }\n *\n * _.groupBy(['one', 'two', 'three'], 'length');\n * // => { '3': ['one', 'two'], '5': ['three'] }\n */\n function groupBy(collection, callback, thisArg) {\n var result = {};\n callback = createCallback(callback, thisArg);\n forEach(collection, function(value, key, collection) {\n key = callback(value, key, collection);\n (hasOwnProperty.call(result, key) ? result[key] : result[key] = []).push(value);\n });\n return result;\n }\n\n /**\n * Invokes the method named by `methodName` on each element in the `collection`,\n * returning an array of the results of each invoked method. Additional arguments\n * will be passed to each invoked method. If `methodName` is a function it will\n * be invoked for, and `this` bound to, each element in the `collection`.\n *\n * @static\n * @memberOf _\n * @category Collections\n * @param {Array|Object|String} collection The collection to iterate over.\n * @param {Function|String} methodName The name of the method to invoke or\n * the function invoked per iteration.\n * @param {Mixed} [arg1, arg2, ...] Arguments to invoke the method with.\n * @returns {Array} Returns a new array of the results of each invoked method.\n * @example\n *\n * _.invoke([[5, 1, 7], [3, 2, 1]], 'sort');\n * // => [[1, 5, 7], [1, 2, 3]]\n *\n * _.invoke([123, 456], String.prototype.split, '');\n * // => [['1', '2', '3'], ['4', '5', '6']]\n */\n function invoke(collection, methodName) {\n var args = slice.call(arguments, 2),\n isFunc = typeof methodName == 'function',\n result = [];\n\n forEach(collection, function(value) {\n result.push((isFunc ? methodName : value[methodName]).apply(value, args));\n });\n return result;\n }\n\n /**\n * Creates an array of values by running each element in the `collection`\n * through a `callback`. The `callback` is bound to `thisArg` and invoked with\n * three arguments; (value, index|key, collection).\n *\n * @static\n * @memberOf _\n * @alias collect\n * @category Collections\n * @param {Array|Object|String} collection The collection to iterate over.\n * @param {Function} [callback=identity] The function called per iteration.\n * @param {Mixed} [thisArg] The `this` binding of `callback`.\n * @returns {Array} Returns a new array of the results of each `callback` execution.\n * @example\n *\n * _.map([1, 2, 3], function(num) { return num * 3; });\n * // => [3, 6, 9]\n *\n * _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; });\n * // => [3, 6, 9] (order is not guaranteed)\n */\n function map(collection, callback, thisArg) {\n var index = -1,\n length = collection ? collection.length : 0,\n result = Array(typeof length == 'number' ? length : 0);\n\n callback = createCallback(callback, thisArg);\n if (isArray(collection)) {\n while (++index < length) {\n result[index] = callback(collection[index], index, collection);\n }\n } else {\n forEach(collection, function(value, key, collection) {\n result[++index] = callback(value, key, collection);\n });\n }\n return result;\n }\n\n /**\n * Retrieves the maximum value of an `array`. If `callback` is passed,\n * it will be executed for each value in the `array` to generate the\n * criterion by which the value is ranked. The `callback` is bound to\n * `thisArg` and invoked with three arguments; (value, index, collection).\n *\n * @static\n * @memberOf _\n * @category Collections\n * @param {Array|Object|String} collection The collection to iterate over.\n * @param {Function} [callback] The function called per iteration.\n * @param {Mixed} [thisArg] The `this` binding of `callback`.\n * @returns {Mixed} Returns the maximum value.\n * @example\n *\n * var stooges = [\n * { 'name': 'moe', 'age': 40 },\n * { 'name': 'larry', 'age': 50 },\n * { 'name': 'curly', 'age': 60 }\n * ];\n *\n * _.max(stooges, function(stooge) { return stooge.age; });\n * // => { 'name': 'curly', 'age': 60 };\n */\n function max(collection, callback, thisArg) {\n var computed = -Infinity,\n index = -1,\n length = collection ? collection.length : 0,\n result = computed;\n\n if (callback || !isArray(collection)) {\n callback = !callback && isString(collection)\n ? charAtCallback\n : createCallback(callback, thisArg);\n\n forEach(collection, function(value, index, collection) {\n var current = callback(value, index, collection);\n if (current > computed) {\n computed = current;\n result = value;\n }\n });\n } else {\n while (++index < length) {\n if (collection[index] > result) {\n result = collection[index];\n }\n }\n }\n return result;\n }\n\n /**\n * Retrieves the minimum value of an `array`. If `callback` is passed,\n * it will be executed for each value in the `array` to generate the\n * criterion by which the value is ranked. The `callback` is bound to `thisArg`\n * and invoked with three arguments; (value, index, collection).\n *\n * @static\n * @memberOf _\n * @category Collections\n * @param {Array|Object|String} collection The collection to iterate over.\n * @param {Function} [callback] The function called per iteration.\n * @param {Mixed} [thisArg] The `this` binding of `callback`.\n * @returns {Mixed} Returns the minimum value.\n * @example\n *\n * _.min([10, 5, 100, 2, 1000]);\n * // => 2\n */\n function min(collection, callback, thisArg) {\n var computed = Infinity,\n index = -1,\n length = collection ? collection.length : 0,\n result = computed;\n\n if (callback || !isArray(collection)) {\n callback = !callback && isString(collection)\n ? charAtCallback\n : createCallback(callback, thisArg);\n\n forEach(collection, function(value, index, collection) {\n var current = callback(value, index, collection);\n if (current < computed) {\n computed = current;\n result = value;\n }\n });\n } else {\n while (++index < length) {\n if (collection[index] < result) {\n result = collection[index];\n }\n }\n }\n return result;\n }\n\n /**\n * Retrieves the value of a specified property from all elements in\n * the `collection`.\n *\n * @static\n * @memberOf _\n * @category Collections\n * @param {Array|Object|String} collection The collection to iterate over.\n * @param {String} property The property to pluck.\n * @returns {Array} Returns a new array of property values.\n * @example\n *\n * var stooges = [\n * { 'name': 'moe', 'age': 40 },\n * { 'name': 'larry', 'age': 50 },\n * { 'name': 'curly', 'age': 60 }\n * ];\n *\n * _.pluck(stooges, 'name');\n * // => ['moe', 'larry', 'curly']\n */\n function pluck(collection, property) {\n var result = [];\n forEach(collection, function(value) {\n result.push(value[property]);\n });\n return result;\n }\n\n /**\n * Boils down a `collection` to a single value. The initial state of the\n * reduction is `accumulator` and each successive step of it should be returned\n * by the `callback`. The `callback` is bound to `thisArg` and invoked with 4\n * arguments; for arrays they are (accumulator, value, index|key, collection).\n *\n * @static\n * @memberOf _\n * @alias foldl, inject\n * @category Collections\n * @param {Array|Object|String} collection The collection to iterate over.\n * @param {Function} callback The function called per iteration.\n * @param {Mixed} [accumulator] Initial value of the accumulator.\n * @param {Mixed} [thisArg] The `this` binding of `callback`.\n * @returns {Mixed} Returns the accumulated value.\n * @example\n *\n * var sum = _.reduce([1, 2, 3], function(memo, num) { return memo + num; });\n * // => 6\n */\n function reduce(collection, callback, accumulator, thisArg) {\n var noaccum = arguments.length < 3;\n callback = createCallback(callback, thisArg);\n forEach(collection, function(value, index, collection) {\n accumulator = noaccum\n ? (noaccum = false, value)\n : callback(accumulator, value, index, collection)\n });\n return accumulator;\n }\n\n /**\n * The right-associative version of `_.reduce`.\n *\n * @static\n * @memberOf _\n * @alias foldr\n * @category Collections\n * @param {Array|Object|String} collection The collection to iterate over.\n * @param {Function} callback The function called per iteration.\n * @param {Mixed} [accumulator] Initial value of the accumulator.\n * @param {Mixed} [thisArg] The `this` binding of `callback`.\n * @returns {Mixed} Returns the accumulated value.\n * @example\n *\n * var list = [[0, 1], [2, 3], [4, 5]];\n * var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []);\n * // => [4, 5, 2, 3, 0, 1]\n */\n function reduceRight(collection, callback, accumulator, thisArg) {\n var iteratee = collection,\n length = collection ? collection.length : 0,\n noaccum = arguments.length < 3;\n\n if (typeof length != 'number') {\n var props = keys(collection);\n length = props.length;\n } else if (noCharByIndex && isString(collection)) {\n iteratee = collection.split('');\n }\n forEach(collection, function(value, index, collection) {\n index = props ? props[--length] : --length;\n accumulator = noaccum\n ? (noaccum = false, iteratee[index])\n : callback.call(thisArg, accumulator, iteratee[index], index, collection);\n });\n return accumulator;\n }\n\n /**\n * The opposite of `_.filter`, this method returns the values of a\n * `collection` that `callback` does **not** return truthy for.\n *\n * @static\n * @memberOf _\n * @category Collections\n * @param {Array|Object|String} collection The collection to iterate over.\n * @param {Function} [callback=identity] The function called per iteration.\n * @param {Mixed} [thisArg] The `this` binding of `callback`.\n * @returns {Array} Returns a new array of elements that did **not** pass the\n * callback check.\n * @example\n *\n * var odds = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; });\n * // => [1, 3, 5]\n */\n function reject(collection, callback, thisArg) {\n callback = createCallback(callback, thisArg);\n return filter(collection, function(value, index, collection) {\n return !callback(value, index, collection);\n });\n }\n\n /**\n * Creates an array of shuffled `array` values, using a version of the\n * Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle.\n *\n * @static\n * @memberOf _\n * @category Collections\n * @param {Array|Object|String} collection The collection to shuffle.\n * @returns {Array} Returns a new shuffled collection.\n * @example\n *\n * _.shuffle([1, 2, 3, 4, 5, 6]);\n * // => [4, 1, 6, 3, 5, 2]\n */\n function shuffle(collection) {\n var index = -1,\n result = Array(collection ? collection.length : 0);\n\n forEach(collection, function(value) {\n var rand = floor(nativeRandom() * (++index + 1));\n result[index] = result[rand];\n result[rand] = value;\n });\n return result;\n }\n\n /**\n * Gets the size of the `collection` by returning `collection.length` for arrays\n * and array-like objects or the number of own enumerable properties for objects.\n *\n * @static\n * @memberOf _\n * @category Collections\n * @param {Array|Object|String} collection The collection to inspect.\n * @returns {Number} Returns `collection.length` or number of own enumerable properties.\n * @example\n *\n * _.size([1, 2]);\n * // => 2\n *\n * _.size({ 'one': 1, 'two': 2, 'three': 3 });\n * // => 3\n *\n * _.size('curly');\n * // => 5\n */\n function size(collection) {\n var length = collection ? collection.length : 0;\n return typeof length == 'number' ? length : keys(collection).length;\n }\n\n /**\n * Checks if the `callback` returns a truthy value for **any** element of a\n * `collection`. The function returns as soon as it finds passing value, and\n * does not iterate over the entire `collection`. The `callback` is bound to\n * `thisArg` and invoked with three arguments; (value, index|key, collection).\n *\n * @static\n * @memberOf _\n * @alias any\n * @category Collections\n * @param {Array|Object|String} collection The collection to iterate over.\n * @param {Function} [callback=identity] The function called per iteration.\n * @param {Mixed} [thisArg] The `this` binding of `callback`.\n * @returns {Boolean} Returns `true` if any element passes the callback check,\n * else `false`.\n * @example\n *\n * _.some([null, 0, 'yes', false]);\n * // => true\n */\n function some(collection, callback, thisArg) {\n var result;\n callback = createCallback(callback, thisArg);\n\n if (isArray(collection)) {\n var index = -1,\n length = collection.length;\n\n while (++index < length) {\n if (result = callback(collection[index], index, collection)) {\n break;\n }\n }\n } else {\n forEach(collection, function(value, index, collection) {\n return !(result = callback(value, index, collection));\n });\n }\n return !!result;\n }\n\n /**\n * Creates an array, stable sorted in ascending order by the results of\n * running each element of `collection` through a `callback`. The `callback`\n * is bound to `thisArg` and invoked with three arguments; (value, index|key, collection).\n * The `callback` argument may also be the name of a property to sort by (e.g. 'length').\n *\n * @static\n * @memberOf _\n * @category Collections\n * @param {Array|Object|String} collection The collection to iterate over.\n * @param {Function|String} callback|property The function called per iteration\n * or property name to sort by.\n * @param {Mixed} [thisArg] The `this` binding of `callback`.\n * @returns {Array} Returns a new array of sorted elements.\n * @example\n *\n * _.sortBy([1, 2, 3], function(num) { return Math.sin(num); });\n * // => [3, 1, 2]\n *\n * _.sortBy([1, 2, 3], function(num) { return this.sin(num); }, Math);\n * // => [3, 1, 2]\n *\n * _.sortBy(['larry', 'brendan', 'moe'], 'length');\n * // => ['moe', 'larry', 'brendan']\n */\n function sortBy(collection, callback, thisArg) {\n var result = [];\n callback = createCallback(callback, thisArg);\n forEach(collection, function(value, index, collection) {\n result.push({\n 'criteria': callback(value, index, collection),\n 'index': index,\n 'value': value\n });\n });\n\n var length = result.length;\n result.sort(compareAscending);\n while (length--) {\n result[length] = result[length].value;\n }\n return result;\n }\n\n /**\n * Converts the `collection`, to an array.\n *\n * @static\n * @memberOf _\n * @category Collections\n * @param {Array|Object|String} collection The collection to convert.\n * @returns {Array} Returns the new converted array.\n * @example\n *\n * (function() { return _.toArray(arguments).slice(1); })(1, 2, 3, 4);\n * // => [2, 3, 4]\n */\n function toArray(collection) {\n if (collection && typeof collection.length == 'number') {\n return (noArraySliceOnStrings ? isString(collection) : typeof collection == 'string')\n ? collection.split('')\n : slice.call(collection);\n }\n return values(collection);\n }\n\n /**\n * Examines each element in a `collection`, returning an array of all elements\n * that contain the given `properties`.\n *\n * @static\n * @memberOf _\n * @category Collections\n * @param {Array|Object|String} collection The collection to iterate over.\n * @param {Object} properties The object of property values to filter by.\n * @returns {Array} Returns a new array of elements that contain the given `properties`.\n * @example\n *\n * var stooges = [\n * { 'name': 'moe', 'age': 40 },\n * { 'name': 'larry', 'age': 50 },\n * { 'name': 'curly', 'age': 60 }\n * ];\n *\n * _.where(stooges, { 'age': 40 });\n * // => [{ 'name': 'moe', 'age': 40 }]\n */\n function where(collection, properties) {\n var props = [];\n forIn(properties, function(value, prop) {\n props.push(prop);\n });\n return filter(collection, function(object) {\n var length = props.length;\n while (length--) {\n var result = object[props[length]] === properties[props[length]];\n if (!result) {\n break;\n }\n }\n return !!result;\n });\n }\n\n /*--------------------------------------------------------------------------*/\n\n /**\n * Creates an array with all falsey values of `array` removed. The values\n * `false`, `null`, `0`, `\"\"`, `undefined` and `NaN` are all falsey.\n *\n * @static\n * @memberOf _\n * @category Arrays\n * @param {Array} array The array to compact.\n * @returns {Array} Returns a new filtered array.\n * @example\n *\n * _.compact([0, 1, false, 2, '', 3]);\n * // => [1, 2, 3]\n */\n function compact(array) {\n var index = -1,\n length = array ? array.length : 0,\n result = [];\n\n while (++index < length) {\n var value = array[index];\n if (value) {\n result.push(value);\n }\n }\n return result;\n }\n\n /**\n * Creates an array of `array` elements not present in the other arrays\n * using strict equality for comparisons, i.e. `===`.\n *\n * @static\n * @memberOf _\n * @category Arrays\n * @param {Array} array The array to process.\n * @param {Array} [array1, array2, ...] Arrays to check.\n * @returns {Array} Returns a new array of `array` elements not present in the\n * other arrays.\n * @example\n *\n * _.difference([1, 2, 3, 4, 5], [5, 2, 10]);\n * // => [1, 3, 4]\n */\n function difference(array) {\n var index = -1,\n length = array ? array.length : 0,\n flattened = concat.apply(arrayRef, arguments),\n contains = cachedContains(flattened, length),\n result = [];\n\n while (++index < length) {\n var value = array[index];\n if (!contains(value)) {\n result.push(value);\n }\n }\n return result;\n }\n\n /**\n * Gets the first element of the `array`. Pass `n` to return the first `n`\n * elements of the `array`.\n *\n * @static\n * @memberOf _\n * @alias head, take\n * @category Arrays\n * @param {Array} array The array to query.\n * @param {Number} [n] The number of elements to return.\n * @param- {Object} [guard] Internally used to allow this method to work with\n * others like `_.map` without using their callback `index` argument for `n`.\n * @returns {Mixed} Returns the first element or an array of the first `n`\n * elements of `array`.\n * @example\n *\n * _.first([5, 4, 3, 2, 1]);\n * // => 5\n */\n function first(array, n, guard) {\n if (array) {\n return (n == null || guard) ? array[0] : slice.call(array, 0, n);\n }\n }\n\n /**\n * Flattens a nested array (the nesting can be to any depth). If `shallow` is\n * truthy, `array` will only be flattened a single level.\n *\n * @static\n * @memberOf _\n * @category Arrays\n * @param {Array} array The array to compact.\n * @param {Boolean} shallow A flag to indicate only flattening a single level.\n * @returns {Array} Returns a new flattened array.\n * @example\n *\n * _.flatten([1, [2], [3, [[4]]]]);\n * // => [1, 2, 3, 4];\n *\n * _.flatten([1, [2], [3, [[4]]]], true);\n * // => [1, 2, 3, [[4]]];\n */\n function flatten(array, shallow) {\n var index = -1,\n length = array ? array.length : 0,\n result = [];\n\n while (++index < length) {\n var value = array[index];\n\n // recursively flatten arrays (susceptible to call stack limits)\n if (isArray(value)) {\n push.apply(result, shallow ? value : flatten(value));\n } else {\n result.push(value);\n }\n }\n return result;\n }\n\n /**\n * Gets the index at which the first occurrence of `value` is found using\n * strict equality for comparisons, i.e. `===`. If the `array` is already\n * sorted, passing `true` for `fromIndex` will run a faster binary search.\n *\n * @static\n * @memberOf _\n * @category Arrays\n * @param {Array} array The array to search.\n * @param {Mixed} value The value to search for.\n * @param {Boolean|Number} [fromIndex=0] The index to search from or `true` to\n * perform a binary search on a sorted `array`.\n * @returns {Number} Returns the index of the matched value or `-1`.\n * @example\n *\n * _.indexOf([1, 2, 3, 1, 2, 3], 2);\n * // => 1\n *\n * _.indexOf([1, 2, 3, 1, 2, 3], 2, 3);\n * // => 4\n *\n * _.indexOf([1, 1, 2, 2, 3, 3], 2, true);\n * // => 2\n */\n function indexOf(array, value, fromIndex) {\n var index = -1,\n length = array ? array.length : 0;\n\n if (typeof fromIndex == 'number') {\n index = (fromIndex < 0 ? nativeMax(0, length + fromIndex) : fromIndex || 0) - 1;\n } else if (fromIndex) {\n index = sortedIndex(array, value);\n return array[index] === value ? index : -1;\n }\n while (++index < length) {\n if (array[index] === value) {\n return index;\n }\n }\n return -1;\n }\n\n /**\n * Gets all but the last element of `array`. Pass `n` to exclude the last `n`\n * elements from the result.\n *\n * @static\n * @memberOf _\n * @category Arrays\n * @param {Array} array The array to query.\n * @param {Number} [n=1] The number of elements to exclude.\n * @param- {Object} [guard] Internally used to allow this method to work with\n * others like `_.map` without using their callback `index` argument for `n`.\n * @returns {Array} Returns all but the last element or `n` elements of `array`.\n * @example\n *\n * _.initial([3, 2, 1]);\n * // => [3, 2]\n */\n function initial(array, n, guard) {\n return array\n ? slice.call(array, 0, -((n == null || guard) ? 1 : n))\n : [];\n }\n\n /**\n * Computes the intersection of all the passed-in arrays using strict equality\n * for comparisons, i.e. `===`.\n *\n * @static\n * @memberOf _\n * @category Arrays\n * @param {Array} [array1, array2, ...] Arrays to process.\n * @returns {Array} Returns a new array of unique elements, in order, that are\n * present in **all** of the arrays.\n * @example\n *\n * _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]);\n * // => [1, 2]\n */\n function intersection(array) {\n var args = arguments,\n argsLength = args.length,\n cache = {},\n result = [];\n\n forEach(array, function(value) {\n if (indexOf(result, value) < 0) {\n var length = argsLength;\n while (--length) {\n if (!(cache[length] || (cache[length] = cachedContains(args[length])))(value)) {\n return;\n }\n }\n result.push(value);\n }\n });\n return result;\n }\n\n /**\n * Gets the last element of the `array`. Pass `n` to return the last `n`\n * elements of the `array`.\n *\n * @static\n * @memberOf _\n * @category Arrays\n * @param {Array} array The array to query.\n * @param {Number} [n] The number of elements to return.\n * @param- {Object} [guard] Internally used to allow this method to work with\n * others like `_.map` without using their callback `index` argument for `n`.\n * @returns {Mixed} Returns the last element or an array of the last `n`\n * elements of `array`.\n * @example\n *\n * _.last([3, 2, 1]);\n * // => 1\n */\n function last(array, n, guard) {\n if (array) {\n var length = array.length;\n return (n == null || guard) ? array[length - 1] : slice.call(array, -n || length);\n }\n }\n\n /**\n * Gets the index at which the last occurrence of `value` is found using strict\n * equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used\n * as the offset from the end of the collection.\n *\n * @static\n * @memberOf _\n * @category Arrays\n * @param {Array} array The array to search.\n * @param {Mixed} value The value to search for.\n * @param {Number} [fromIndex=array.length-1] The index to search from.\n * @returns {Number} Returns the index of the matched value or `-1`.\n * @example\n *\n * _.lastIndexOf([1, 2, 3, 1, 2, 3], 2);\n * // => 4\n *\n * _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3);\n * // => 1\n */\n function lastIndexOf(array, value, fromIndex) {\n var index = array ? array.length : 0;\n if (typeof fromIndex == 'number') {\n index = (fromIndex < 0 ? nativeMax(0, index + fromIndex) : nativeMin(fromIndex, index - 1)) + 1;\n }\n while (index--) {\n if (array[index] === value) {\n return index;\n }\n }\n return -1;\n }\n\n /**\n * Creates an object composed from arrays of `keys` and `values`. Pass either\n * a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]`, or\n * two arrays, one of `keys` and one of corresponding `values`.\n *\n * @static\n * @memberOf _\n * @category Arrays\n * @param {Array} keys The array of keys.\n * @param {Array} [values=[]] The array of values.\n * @returns {Object} Returns an object composed of the given keys and\n * corresponding values.\n * @example\n *\n * _.object(['moe', 'larry', 'curly'], [30, 40, 50]);\n * // => { 'moe': 30, 'larry': 40, 'curly': 50 }\n */\n function object(keys, values) {\n var index = -1,\n length = keys ? keys.length : 0,\n result = {};\n\n while (++index < length) {\n var key = keys[index];\n if (values) {\n result[key] = values[index];\n } else {\n result[key[0]] = key[1];\n }\n }\n return result;\n }\n\n /**\n * Creates an array of numbers (positive and/or negative) progressing from\n * `start` up to but not including `stop`. This method is a port of Python's\n * `range()` function. See http://docs.python.org/library/functions.html#range.\n *\n * @static\n * @memberOf _\n * @category Arrays\n * @param {Number} [start=0] The start of the range.\n * @param {Number} end The end of the range.\n * @param {Number} [step=1] The value to increment or descrement by.\n * @returns {Array} Returns a new range array.\n * @example\n *\n * _.range(10);\n * // => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n *\n * _.range(1, 11);\n * // => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n *\n * _.range(0, 30, 5);\n * // => [0, 5, 10, 15, 20, 25]\n *\n * _.range(0, -10, -1);\n * // => [0, -1, -2, -3, -4, -5, -6, -7, -8, -9]\n *\n * _.range(0);\n * // => []\n */\n function range(start, end, step) {\n start = +start || 0;\n step = +step || 1;\n\n if (end == null) {\n end = start;\n start = 0;\n }\n // use `Array(length)` so V8 will avoid the slower \"dictionary\" mode\n // http://www.youtube.com/watch?v=XAqIpGU8ZZk#t=16m27s\n var index = -1,\n length = nativeMax(0, ceil((end - start) / step)),\n result = Array(length);\n\n while (++index < length) {\n result[index] = start;\n start += step;\n }\n return result;\n }\n\n /**\n * The opposite of `_.initial`, this method gets all but the first value of\n * `array`. Pass `n` to exclude the first `n` values from the result.\n *\n * @static\n * @memberOf _\n * @alias drop, tail\n * @category Arrays\n * @param {Array} array The array to query.\n * @param {Number} [n=1] The number of elements to exclude.\n * @param- {Object} [guard] Internally used to allow this method to work with\n * others like `_.map` without using their callback `index` argument for `n`.\n * @returns {Array} Returns all but the first value or `n` values of `array`.\n * @example\n *\n * _.rest([3, 2, 1]);\n * // => [2, 1]\n */\n function rest(array, n, guard) {\n return array\n ? slice.call(array, (n == null || guard) ? 1 : n)\n : [];\n }\n\n /**\n * Uses a binary search to determine the smallest index at which the `value`\n * should be inserted into `array` in order to maintain the sort order of the\n * sorted `array`. If `callback` is passed, it will be executed for `value` and\n * each element in `array` to compute their sort ranking. The `callback` is\n * bound to `thisArg` and invoked with one argument; (value). The `callback`\n * argument may also be the name of a property to order by.\n *\n * @static\n * @memberOf _\n * @category Arrays\n * @param {Array} array The array to iterate over.\n * @param {Mixed} value The value to evaluate.\n * @param {Function|String} [callback=identity|property] The function called\n * per iteration or property name to order by.\n * @param {Mixed} [thisArg] The `this` binding of `callback`.\n * @returns {Number} Returns the index at which the value should be inserted\n * into `array`.\n * @example\n *\n * _.sortedIndex([20, 30, 50], 40);\n * // => 2\n *\n * _.sortedIndex([{ 'x': 20 }, { 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x');\n * // => 2\n *\n * var dict = {\n * 'wordToNumber': { 'twenty': 20, 'thirty': 30, 'fourty': 40, 'fifty': 50 }\n * };\n *\n * _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) {\n * return dict.wordToNumber[word];\n * });\n * // => 2\n *\n * _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) {\n * return this.wordToNumber[word];\n * }, dict);\n * // => 2\n */\n function sortedIndex(array, value, callback, thisArg) {\n var low = 0,\n high = array ? array.length : low;\n\n // explicitly reference `identity` for better engine inlining\n callback = callback ? createCallback(callback, thisArg) : identity;\n value = callback(value);\n while (low < high) {\n var mid = (low + high) >>> 1;\n callback(array[mid]) < value\n ? low = mid + 1\n : high = mid;\n }\n return low;\n }\n\n /**\n * Computes the union of the passed-in arrays using strict equality for\n * comparisons, i.e. `===`.\n *\n * @static\n * @memberOf _\n * @category Arrays\n * @param {Array} [array1, array2, ...] Arrays to process.\n * @returns {Array} Returns a new array of unique values, in order, that are\n * present in one or more of the arrays.\n * @example\n *\n * _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]);\n * // => [1, 2, 3, 101, 10]\n */\n function union() {\n return uniq(concat.apply(arrayRef, arguments));\n }\n\n /**\n * Creates a duplicate-value-free version of the `array` using strict equality\n * for comparisons, i.e. `===`. If the `array` is already sorted, passing `true`\n * for `isSorted` will run a faster algorithm. If `callback` is passed, each\n * element of `array` is passed through a callback` before uniqueness is computed.\n * The `callback` is bound to `thisArg` and invoked with three arguments; (value, index, array).\n *\n * @static\n * @memberOf _\n * @alias unique\n * @category Arrays\n * @param {Array} array The array to process.\n * @param {Boolean} [isSorted=false] A flag to indicate that the `array` is already sorted.\n * @param {Function} [callback=identity] The function called per iteration.\n * @param {Mixed} [thisArg] The `this` binding of `callback`.\n * @returns {Array} Returns a duplicate-value-free array.\n * @example\n *\n * _.uniq([1, 2, 1, 3, 1]);\n * // => [1, 2, 3]\n *\n * _.uniq([1, 1, 2, 2, 3], true);\n * // => [1, 2, 3]\n *\n * _.uniq([1, 2, 1.5, 3, 2.5], function(num) { return Math.floor(num); });\n * // => [1, 2, 3]\n *\n * _.uniq([1, 2, 1.5, 3, 2.5], function(num) { return this.floor(num); }, Math);\n * // => [1, 2, 3]\n */\n function uniq(array, isSorted, callback, thisArg) {\n var index = -1,\n length = array ? array.length : 0,\n result = [],\n seen = result;\n\n // juggle arguments\n if (typeof isSorted == 'function') {\n thisArg = callback;\n callback = isSorted;\n isSorted = false;\n }\n // init value cache for large arrays\n var isLarge = !isSorted && length > 74;\n if (isLarge) {\n var cache = {};\n }\n if (callback) {\n seen = [];\n callback = createCallback(callback, thisArg);\n }\n while (++index < length) {\n var value = array[index],\n computed = callback ? callback(value, index, array) : value;\n\n if (isLarge) {\n // manually coerce `computed` to a string because `hasOwnProperty`, in\n // some older versions of Firefox, coerces objects incorrectly\n seen = hasOwnProperty.call(cache, computed + '') ? cache[computed] : (cache[computed] = []);\n }\n if (isSorted\n ? !index || seen[seen.length - 1] !== computed\n : indexOf(seen, computed) < 0\n ) {\n if (callback || isLarge) {\n seen.push(computed);\n }\n result.push(value);\n }\n }\n return result;\n }\n\n /**\n * Creates an array with all occurrences of the passed values removed using\n * strict equality for comparisons, i.e. `===`.\n *\n * @static\n * @memberOf _\n * @category Arrays\n * @param {Array} array The array to filter.\n * @param {Mixed} [value1, value2, ...] Values to remove.\n * @returns {Array} Returns a new filtered array.\n * @example\n *\n * _.without([1, 2, 1, 0, 3, 1, 4], 0, 1);\n * // => [2, 3, 4]\n */\n function without(array) {\n var index = -1,\n length = array ? array.length : 0,\n contains = cachedContains(arguments, 1, 20),\n result = [];\n\n while (++index < length) {\n var value = array[index];\n if (!contains(value)) {\n result.push(value);\n }\n }\n return result;\n }\n\n /**\n * Groups the elements of each array at their corresponding indexes. Useful for\n * separate data sources that are coordinated through matching array indexes.\n * For a matrix of nested arrays, `_.zip.apply(...)` can transpose the matrix\n * in a similar fashion.\n *\n * @static\n * @memberOf _\n * @category Arrays\n * @param {Array} [array1, array2, ...] Arrays to process.\n * @returns {Array} Returns a new array of grouped elements.\n * @example\n *\n * _.zip(['moe', 'larry', 'curly'], [30, 40, 50], [true, false, false]);\n * // => [['moe', 30, true], ['larry', 40, false], ['curly', 50, false]]\n */\n function zip(array) {\n var index = -1,\n length = array ? max(pluck(arguments, 'length')) : 0,\n result = Array(length);\n\n while (++index < length) {\n result[index] = pluck(arguments, index);\n }\n return result;\n }\n\n /*--------------------------------------------------------------------------*/\n\n /**\n * Creates a function that is restricted to executing `func` only after it is\n * called `n` times. The `func` is executed with the `this` binding of the\n * created function.\n *\n * @static\n * @memberOf _\n * @category Functions\n * @param {Number} n The number of times the function must be called before\n * it is executed.\n * @param {Function} func The function to restrict.\n * @returns {Function} Returns the new restricted function.\n * @example\n *\n * var renderNotes = _.after(notes.length, render);\n * _.forEach(notes, function(note) {\n * note.asyncSave({ 'success': renderNotes });\n * });\n * // `renderNotes` is run once, after all notes have saved\n */\n function after(n, func) {\n if (n < 1) {\n return func();\n }\n return function() {\n if (--n < 1) {\n return func.apply(this, arguments);\n }\n };\n }\n\n /**\n * Creates a function that, when called, invokes `func` with the `this`\n * binding of `thisArg` and prepends any additional `bind` arguments to those\n * passed to the bound function.\n *\n * @static\n * @memberOf _\n * @category Functions\n * @param {Function} func The function to bind.\n * @param {Mixed} [thisArg] The `this` binding of `func`.\n * @param {Mixed} [arg1, arg2, ...] Arguments to be partially applied.\n * @returns {Function} Returns the new bound function.\n * @example\n *\n * var func = function(greeting) {\n * return greeting + ' ' + this.name;\n * };\n *\n * func = _.bind(func, { 'name': 'moe' }, 'hi');\n * func();\n * // => 'hi moe'\n */\n function bind(func, thisArg) {\n // use `Function#bind` if it exists and is fast\n // (in V8 `Function#bind` is slower except when partially applied)\n return isBindFast || (nativeBind && arguments.length > 2)\n ? nativeBind.call.apply(nativeBind, arguments)\n : createBound(func, thisArg, slice.call(arguments, 2));\n }\n\n /**\n * Binds methods on `object` to `object`, overwriting the existing method.\n * If no method names are provided, all the function properties of `object`\n * will be bound.\n *\n * @static\n * @memberOf _\n * @category Functions\n * @param {Object} object The object to bind and assign the bound methods to.\n * @param {String} [methodName1, methodName2, ...] Method names on the object to bind.\n * @returns {Object} Returns `object`.\n * @example\n *\n * var buttonView = {\n * 'label': 'lodash',\n * 'onClick': function() { alert('clicked: ' + this.label); }\n * };\n *\n * _.bindAll(buttonView);\n * jQuery('#lodash_button').on('click', buttonView.onClick);\n * // => When the button is clicked, `this.label` will have the correct value\n */\n function bindAll(object) {\n var funcs = arguments,\n index = funcs.length > 1 ? 0 : (funcs = functions(object), -1),\n length = funcs.length;\n\n while (++index < length) {\n var key = funcs[index];\n object[key] = bind(object[key], object);\n }\n return object;\n }\n\n /**\n * Creates a function that is the composition of the passed functions,\n * where each function consumes the return value of the function that follows.\n * In math terms, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`.\n * Each function is executed with the `this` binding of the composed function.\n *\n * @static\n * @memberOf _\n * @category Functions\n * @param {Function} [func1, func2, ...] Functions to compose.\n * @returns {Function} Returns the new composed function.\n * @example\n *\n * var greet = function(name) { return 'hi: ' + name; };\n * var exclaim = function(statement) { return statement + '!'; };\n * var welcome = _.compose(exclaim, greet);\n * welcome('moe');\n * // => 'hi: moe!'\n */\n function compose() {\n var funcs = arguments;\n return function() {\n var args = arguments,\n length = funcs.length;\n\n while (length--) {\n args = [funcs[length].apply(this, args)];\n }\n return args[0];\n };\n }\n\n /**\n * Creates a function that will delay the execution of `func` until after\n * `wait` milliseconds have elapsed since the last time it was invoked. Pass\n * `true` for `immediate` to cause debounce to invoke `func` on the leading,\n * instead of the trailing, edge of the `wait` timeout. Subsequent calls to\n * the debounced function will return the result of the last `func` call.\n *\n * @static\n * @memberOf _\n * @category Functions\n * @param {Function} func The function to debounce.\n * @param {Number} wait The number of milliseconds to delay.\n * @param {Boolean} immediate A flag to indicate execution is on the leading\n * edge of the timeout.\n * @returns {Function} Returns the new debounced function.\n * @example\n *\n * var lazyLayout = _.debounce(calculateLayout, 300);\n * jQuery(window).on('resize', lazyLayout);\n */\n function debounce(func, wait, immediate) {\n var args,\n result,\n thisArg,\n timeoutId;\n\n function delayed() {\n timeoutId = null;\n if (!immediate) {\n result = func.apply(thisArg, args);\n }\n }\n return function() {\n var isImmediate = immediate && !timeoutId;\n args = arguments;\n thisArg = this;\n\n clearTimeout(timeoutId);\n timeoutId = setTimeout(delayed, wait);\n\n if (isImmediate) {\n result = func.apply(thisArg, args);\n }\n return result;\n };\n }\n\n /**\n * Executes the `func` function after `wait` milliseconds. Additional arguments\n * will be passed to `func` when it is invoked.\n *\n * @static\n * @memberOf _\n * @category Functions\n * @param {Function} func The function to delay.\n * @param {Number} wait The number of milliseconds to delay execution.\n * @param {Mixed} [arg1, arg2, ...] Arguments to invoke the function with.\n * @returns {Number} Returns the `setTimeout` timeout id.\n * @example\n *\n * var log = _.bind(console.log, console);\n * _.delay(log, 1000, 'logged later');\n * // => 'logged later' (Appears after one second.)\n */\n function delay(func, wait) {\n var args = slice.call(arguments, 2);\n return setTimeout(function() { func.apply(undefined, args); }, wait);\n }\n\n /**\n * Defers executing the `func` function until the current call stack has cleared.\n * Additional arguments will be passed to `func` when it is invoked.\n *\n * @static\n * @memberOf _\n * @category Functions\n * @param {Function} func The function to defer.\n * @param {Mixed} [arg1, arg2, ...] Arguments to invoke the function with.\n * @returns {Number} Returns the `setTimeout` timeout id.\n * @example\n *\n * _.defer(function() { alert('deferred'); });\n * // returns from the function before `alert` is called\n */\n function defer(func) {\n var args = slice.call(arguments, 1);\n return setTimeout(function() { func.apply(undefined, args); }, 1);\n }\n\n /**\n * Creates a function that, when called, invokes `object[methodName]` and\n * prepends any additional `lateBind` arguments to those passed to the bound\n * function. This method differs from `_.bind` by allowing bound functions to\n * reference methods that will be redefined or don't yet exist.\n *\n * @static\n * @memberOf _\n * @category Functions\n * @param {Object} object The object the method belongs to.\n * @param {String} methodName The method name.\n * @param {Mixed} [arg1, arg2, ...] Arguments to be partially applied.\n * @returns {Function} Returns the new bound function.\n * @example\n *\n * var object = {\n * 'name': 'moe',\n * 'greet': function(greeting) {\n * return greeting + ' ' + this.name;\n * }\n * };\n *\n * var func = _.lateBind(object, 'greet', 'hi');\n * func();\n * // => 'hi moe'\n *\n * object.greet = function(greeting) {\n * return greeting + ', ' + this.name + '!';\n * };\n *\n * func();\n * // => 'hi, moe!'\n */\n function lateBind(object, methodName) {\n return createBound(methodName, object, slice.call(arguments, 2));\n }\n\n /**\n * Creates a function that memoizes the result of `func`. If `resolver` is\n * passed, it will be used to determine the cache key for storing the result\n * based on the arguments passed to the memoized function. By default, the first\n * argument passed to the memoized function is used as the cache key. The `func`\n * is executed with the `this` binding of the memoized function.\n *\n * @static\n * @memberOf _\n * @category Functions\n * @param {Function} func The function to have its output memoized.\n * @param {Function} [resolver] A function used to resolve the cache key.\n * @returns {Function} Returns the new memoizing function.\n * @example\n *\n * var fibonacci = _.memoize(function(n) {\n * return n < 2 ? n : fibonacci(n - 1) + fibonacci(n - 2);\n * });\n */\n function memoize(func, resolver) {\n var cache = {};\n return function() {\n var key = resolver ? resolver.apply(this, arguments) : arguments[0];\n return hasOwnProperty.call(cache, key)\n ? cache[key]\n : (cache[key] = func.apply(this, arguments));\n };\n }\n\n /**\n * Creates a function that is restricted to execute `func` once. Repeat calls to\n * the function will return the value of the first call. The `func` is executed\n * with the `this` binding of the created function.\n *\n * @static\n * @memberOf _\n * @category Functions\n * @param {Function} func The function to restrict.\n * @returns {Function} Returns the new restricted function.\n * @example\n *\n * var initialize = _.once(createApplication);\n * initialize();\n * initialize();\n * // Application is only created once.\n */\n function once(func) {\n var result,\n ran = false;\n\n return function() {\n if (ran) {\n return result;\n }\n ran = true;\n result = func.apply(this, arguments);\n\n // clear the `func` variable so the function may be garbage collected\n func = null;\n return result;\n };\n }\n\n /**\n * Creates a function that, when called, invokes `func` with any additional\n * `partial` arguments prepended to those passed to the new function. This\n * method is similar to `bind`, except it does **not** alter the `this` binding.\n *\n * @static\n * @memberOf _\n * @category Functions\n * @param {Function} func The function to partially apply arguments to.\n * @param {Mixed} [arg1, arg2, ...] Arguments to be partially applied.\n * @returns {Function} Returns the new partially applied function.\n * @example\n *\n * var greet = function(greeting, name) { return greeting + ': ' + name; };\n * var hi = _.partial(greet, 'hi');\n * hi('moe');\n * // => 'hi: moe'\n */\n function partial(func) {\n return createBound(func, slice.call(arguments, 1));\n }\n\n /**\n * Creates a function that, when executed, will only call the `func`\n * function at most once per every `wait` milliseconds. If the throttled\n * function is invoked more than once during the `wait` timeout, `func` will\n * also be called on the trailing edge of the timeout. Subsequent calls to the\n * throttled function will return the result of the last `func` call.\n *\n * @static\n * @memberOf _\n * @category Functions\n * @param {Function} func The function to throttle.\n * @param {Number} wait The number of milliseconds to throttle executions to.\n * @returns {Function} Returns the new throttled function.\n * @example\n *\n * var throttled = _.throttle(updatePosition, 100);\n * jQuery(window).on('scroll', throttled);\n */\n function throttle(func, wait) {\n var args,\n result,\n thisArg,\n timeoutId,\n lastCalled = 0;\n\n function trailingCall() {\n lastCalled = new Date;\n timeoutId = null;\n result = func.apply(thisArg, args);\n }\n return function() {\n var now = new Date,\n remaining = wait - (now - lastCalled);\n\n args = arguments;\n thisArg = this;\n\n if (remaining <= 0) {\n clearTimeout(timeoutId);\n lastCalled = now;\n result = func.apply(thisArg, args);\n }\n else if (!timeoutId) {\n timeoutId = setTimeout(trailingCall, remaining);\n }\n return result;\n };\n }\n\n /**\n * Creates a function that passes `value` to the `wrapper` function as its\n * first argument. Additional arguments passed to the function are appended\n * to those passed to the `wrapper` function. The `wrapper` is executed with\n * the `this` binding of the created function.\n *\n * @static\n * @memberOf _\n * @category Functions\n * @param {Mixed} value The value to wrap.\n * @param {Function} wrapper The wrapper function.\n * @returns {Function} Returns the new function.\n * @example\n *\n * var hello = function(name) { return 'hello ' + name; };\n * hello = _.wrap(hello, function(func) {\n * return 'before, ' + func('moe') + ', after';\n * });\n * hello();\n * // => 'before, hello moe, after'\n */\n function wrap(value, wrapper) {\n return function() {\n var args = [value];\n push.apply(args, arguments);\n return wrapper.apply(this, args);\n };\n }\n\n /*--------------------------------------------------------------------------*/\n\n /**\n * Converts the characters `&`, `<`, `>`, `\"`, and `'` in `string` to their\n * corresponding HTML entities.\n *\n * @static\n * @memberOf _\n * @category Utilities\n * @param {String} string The string to escape.\n * @returns {String} Returns the escaped string.\n * @example\n *\n * _.escape('Moe, Larry & Curly');\n * // => \"Moe, Larry & Curly\"\n */\n function escape(string) {\n return string == null ? '' : (string + '').replace(reUnescapedHtml, escapeHtmlChar);\n }\n\n /**\n * This function returns the first argument passed to it.\n *\n * Note: It is used throughout Lo-Dash as a default callback.\n *\n * @static\n * @memberOf _\n * @category Utilities\n * @param {Mixed} value Any value.\n * @returns {Mixed} Returns `value`.\n * @example\n *\n * var moe = { 'name': 'moe' };\n * moe === _.identity(moe);\n * // => true\n */\n function identity(value) {\n return value;\n }\n\n /**\n * Adds functions properties of `object` to the `lodash` function and chainable\n * wrapper.\n *\n * @static\n * @memberOf _\n * @category Utilities\n * @param {Object} object The object of function properties to add to `lodash`.\n * @example\n *\n * _.mixin({\n * 'capitalize': function(string) {\n * return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase();\n * }\n * });\n *\n * _.capitalize('larry');\n * // => 'Larry'\n *\n * _('curly').capitalize();\n * // => 'Curly'\n */\n function mixin(object) {\n forEach(functions(object), function(methodName) {\n var func = lodash[methodName] = object[methodName];\n\n lodash.prototype[methodName] = function() {\n var args = [this.__wrapped__];\n push.apply(args, arguments);\n\n var result = func.apply(lodash, args);\n if (this.__chain__) {\n result = new lodash(result);\n result.__chain__ = true;\n }\n return result;\n };\n });\n }\n\n /**\n * Reverts the '_' variable to its previous value and returns a reference to\n * the `lodash` function.\n *\n * @static\n * @memberOf _\n * @category Utilities\n * @returns {Function} Returns the `lodash` function.\n * @example\n *\n * var lodash = _.noConflict();\n */\n function noConflict() {\n window._ = oldDash;\n return this;\n }\n\n /**\n * Produces a random number between `min` and `max` (inclusive). If only one\n * argument is passed, a number between `0` and the given number will be returned.\n *\n * @static\n * @memberOf _\n * @category Utilities\n * @param {Number} [min=0] The minimum possible value.\n * @param {Number} [max=1] The maximum possible value.\n * @returns {Number} Returns a random number.\n * @example\n *\n * _.random(0, 5);\n * // => a number between 1 and 5\n *\n * _.random(5);\n * // => also a number between 1 and 5\n */\n function random(min, max) {\n if (min == null && max == null) {\n max = 1;\n }\n min = +min || 0;\n if (max == null) {\n max = min;\n min = 0;\n }\n return min + floor(nativeRandom() * ((+max || 0) - min + 1));\n }\n\n /**\n * Resolves the value of `property` on `object`. If `property` is a function\n * it will be invoked and its result returned, else the property value is\n * returned. If `object` is falsey, then `null` is returned.\n *\n * @deprecated\n * @static\n * @memberOf _\n * @category Utilities\n * @param {Object} object The object to inspect.\n * @param {String} property The property to get the value of.\n * @returns {Mixed} Returns the resolved value.\n * @example\n *\n * var object = {\n * 'cheese': 'crumpets',\n * 'stuff': function() {\n * return 'nonsense';\n * }\n * };\n *\n * _.result(object, 'cheese');\n * // => 'crumpets'\n *\n * _.result(object, 'stuff');\n * // => 'nonsense'\n */\n function result(object, property) {\n // based on Backbone's private `getValue` function\n // https://github.com/documentcloud/backbone/blob/0.9.2/backbone.js#L1419-1424\n var value = object ? object[property] : null;\n return isFunction(value) ? object[property]() : value;\n }\n\n /**\n * A micro-templating method that handles arbitrary delimiters, preserves\n * whitespace, and correctly escapes quotes within interpolated code.\n *\n * Note: In the development build `_.template` utilizes sourceURLs for easier\n * debugging. See http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl\n *\n * Note: Lo-Dash may be used in Chrome extensions by either creating a `lodash csp`\n * build and avoiding `_.template` use, or loading Lo-Dash in a sandboxed page.\n * See http://developer.chrome.com/trunk/extensions/sandboxingEval.html\n *\n * @static\n * @memberOf _\n * @category Utilities\n * @param {String} text The template text.\n * @param {Obect} data The data object used to populate the text.\n * @param {Object} options The options object.\n * escape - The \"escape\" delimiter regexp.\n * evaluate - The \"evaluate\" delimiter regexp.\n * interpolate - The \"interpolate\" delimiter regexp.\n * sourceURL - The sourceURL of the template's compiled source.\n * variable - The data object variable name.\n *\n * @returns {Function|String} Returns a compiled function when no `data` object\n * is given, else it returns the interpolated text.\n * @example\n *\n * // using a compiled template\n * var compiled = _.template('hello <%= name %>');\n * compiled({ 'name': 'moe' });\n * // => 'hello moe'\n *\n * var list = '<% _.forEach(people, function(name) { %>
      • <%= name %>
      • <% }); %>';\n * _.template(list, { 'people': ['moe', 'larry', 'curly'] });\n * // => '
      • moe
      • larry
      • curly
      • '\n *\n * // using the \"escape\" delimiter to escape HTML in data property values\n * _.template('<%- value %>', { 'value': '