{"version":3,"sources":["src/js/club/sticky-container.js","src/js/club/login.js"],"names":["stickyContainer","$container","$spacer","$","$seoContent","$window","window","$col","parent","scrollHandler","throttle","is","width","css","outerHeight","containerLeft","offset","left","colWidth","colLeft","currentScrollPosition","Math","ceil","scrollTop","stickyPosition","top","parseInt","seoTopPos","containerTallerThanWindow","containerMaxPosition","up","scrollStart","position","scroll","trigger","_location$search","_this","arguments","length","undefined","$form","find","$stickyContent","$fieldContainer","mobileBreakpoint","useAjax","hasClass","isLoginPage","setContainerHeight","contentHeight","height","validator","Validator","showErrors","showValidationErrors","showAlert","alert","on","validateField","this","inputFilteringEvents","$input","removeClass","closest","remove","errors","filter","error","rule","emit","e","passwordField","siblings","attr","text","toggleForms","toggleClass","debounce","click","preventDefault","containerDown","leftColumnDown","overFooter","scrollBody","animate","setTimeout","location","hash","search","includes","loginForm","document","querySelector","resetAnchor","classList","add","showPasswordResetStep","submitAjaxForm","data","serialize","loader","utils","addFormLoader","getToken","then","token","Promise","resolve","ajax","method","url","tap","res","success","alreadyJoined","addClass","always","serializeObject","Array","isArray","email","each","key","val","indexOf","replace","kplussa_number","plussaPrefix","String","validate","definition","fields","slideUp","message","type","persistent","pass","localStorage","removeItem","submit","catch","showErrorMessage"],"mappings":"qLAIe,SAASA,EAAgBC,GACvC,IAAMC,EAAUC,IAAE,mBACZC,EAAcD,IAAE,gBAChBE,EAAUF,IAAEG,QACZC,EAAON,EAAWO,SAElBC,EAAgBC,KAYtB,WACC,IAAKT,EAAWU,GAAG,YAClB,OAED,GAAIN,EAAQO,QAjBY,IAqBvB,YAHAT,IAAEF,GAAYY,IAAI,CACjB,SAAY,YAKdV,IAAE,gBAAgBU,IAAI,SAAUV,IAAE,iBAAiBW,eACnD,IAAMC,EAAgBd,EAAWe,SAASC,KACpCC,EAAWX,EAAKK,QAChBO,EAAUZ,EAAKS,SAASC,KACxBG,EAAwBC,KAAKC,KAAKjB,EAAQkB,aAE1CC,EADiBH,KAAKC,KAAKpB,EAAQc,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EAAW2D,EAAI/C,QACfV,EAAU,CAAE8E,QAAS,6BAA8BC,KAAM,SAAUC,YAAY,IAAQ/B,MAAM,WACxFzD,GACH5C,IAAE,aAAaiF,QAAQ,CAAE7D,UAAWiB,EAAMxB,SAASS,IAAM,KAE1DuB,YAEK,GAAIgE,EAAIwB,KACd,GAAI3F,EACH4F,aAAaC,WAAW,WACxBzC,EAAezD,OACT,CACN,IAAMqB,EAAS1D,IAAEiC,GAAMK,KAAK,8BAC5B,GAAIoB,EAAOvB,QAAUuB,EAAO8D,MAAO,CAClC,IAAMI,EAAeC,OAAOnE,EAAOqC,KAAK,kBACxCrC,EAAO8D,IAAII,EAAelE,EAAO8D,OAElCnF,EAAMmG,aAIRC,OAAM,SAAA5B,GACN,IAAMqB,EAAUrB,EAAIqB,SAAW,iEAC/BQ,YAAiBR","file":"hashed/22.d5898d61.chunk.js","sourcesContent":["'use strict';\nimport $ from 'jquery';\nimport throttle from 'lodash/throttle';\n\nexport default function stickyContainer($container) {\n\tconst $spacer = $('.spacer.desktop');\n\tconst $seoContent = $('.seo-content');\n\tconst $window = $(window);\n\tconst $col = $container.parent();\n\tconst stickyBreakpoint = 990;\n\tconst scrollHandler = throttle(sticky, 50);\n\tlet scrollStart = 0;\n\t\n\t$col.parent().css({\n\t\tposition: 'relative'\n\t});\n\n\t$(window).scroll(scrollHandler).trigger('scroll');\n\n\t/**\n * This is called on scroll events.\n */\n\tfunction sticky() {\n\t\tif (!$container.is(':visible')) {\n\t\t\treturn;\n\t\t}\n\t\tif ($window.width() < stickyBreakpoint) {\n\t\t\t$($container).css({\n\t\t\t\t'position': 'initial',\n\t\t\t});\n\t\t\treturn\n\t\t}\n\n\t\t$('.left-column').css('height', $('.right-column').outerHeight()); // for setting the container to bottom when scroll position over seoContent\n\t\tconst containerLeft = $container.offset().left;\n\t\tconst colWidth = $col.width();\n\t\tconst colLeft = $col.offset().left;\n\t\tconst currentScrollPosition = Math.ceil($window.scrollTop());\n\t\tconst spacerPosition = Math.ceil($spacer.offset().top);\n\t\tconst stickyPosition = spacerPosition + parseInt($col.css('padding-top'))\n\t\tconst seoTopPos = Math.ceil($seoContent.offset().top);\n\t\tconst containerTallerThanWindow = Math.ceil($window.outerHeight()) < Math.ceil($container.outerHeight());\n\t\tconst containerMaxPosition = seoTopPos - $container.outerHeight();\n\t\tconst up = currentScrollPosition <= scrollStart;\n\n\t\tscrollStart = currentScrollPosition;\n\n\t\tif (up) {\n\t\t\tif (currentScrollPosition > stickyPosition) {\n\t\t\t\tif (currentScrollPosition < containerMaxPosition) { // Container bottom doesn't hit seoContent\n\t\t\t\t\t$container.css({\n\t\t\t\t\t\t'position': 'fixed',\n\t\t\t\t\t\t'left': containerLeft,\n\t\t\t\t\t\t'bottom': 'auto',\n\t\t\t\t\t\t'top': 0,\n\t\t\t\t\t\t'padding-top': '20px',\n\t\t\t\t\t\t'width': colWidth + 'px'\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t$($container).css({\n\t\t\t\t\t'position': 'relative',\n\t\t\t\t\t'padding-top': '',\n\t\t\t\t\t'top': 0,\n\t\t\t\t\t'left': 'auto',\n\t\t\t\t});\n\t\t\t}\n\n\t\t} else { // Scrolling down\n\n\t\t\tif (currentScrollPosition > stickyPosition) {\n\t\t\t\tif (currentScrollPosition < containerMaxPosition) { // Container bottom won't hit seoContent\n\t\t\t\t\tif (containerTallerThanWindow) {\n\t\t\t\t\t\t$container.css({\n\t\t\t\t\t\t\t'position': 'fixed',\n\t\t\t\t\t\t\t'top': 0,\n\t\t\t\t\t\t\t'padding-top': '20px',\n\t\t\t\t\t\t\t'overflow-y': 'auto',\n\t\t\t\t\t\t\t'overflow-x': 'hidden',\n\t\t\t\t\t\t\t'cursor': 'default',\n\t\t\t\t\t\t\t'left': containerLeft,\n\t\t\t\t\t\t\t'bottom': 0\n\t\t\t\t\t\t});\n\t\t\t\t\t} else {\n\t\t\t\t\t\t$container.css({\n\t\t\t\t\t\t\t'position': 'fixed',\n\t\t\t\t\t\t\t'top': 0,\n\t\t\t\t\t\t\t'padding-top': '20px',\n\t\t\t\t\t\t\t'left': containerLeft,\n\t\t\t\t\t\t\t'width': colWidth + 'px'\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t$container.css({\n\t\t\t\t\t\t'position': 'absolute',\n\t\t\t\t\t\t'left': containerLeft - colLeft,\n\t\t\t\t\t\t'bottom': 0,\n\t\t\t\t\t\t'top': 'auto'\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n","'use strict';\n\nimport $ from 'jquery';\nimport Validator from '../checkout/validator';\nimport validate from '../api/validation';\nimport alert from '../ui/alert'\nimport stickyContainer from './sticky-container';\nimport debounce from 'lodash/debounce';\nimport { showValidationErrors, showErrorMessage, inputFilteringEvents } from '../util/form';\nimport getToken from '../api/token';\nimport utils from '../util';\nimport { showPasswordResetStep } from './user-login';\n\nexport default function($container = $('.club-login-page')) {\n\tif(!$container.length) return;\n\n\tconst $form = $container.find('.club-registration');\n\tconst $stickyContent = $container.find('.left-column .slot-container');\n\tconst $fieldContainer = $container.find('.field-container');\n\tconst mobileBreakpoint = 990;\n\tconst useAjax = $form.hasClass('use-ajax');\n\n\tconst isLoginPage = $('body').hasClass('club-login-page');\n\tif (isLoginPage) {\n\t\tstickyContainer($stickyContent);\n\t}\n\n\t//Set slot-container height based on what content is shown (for login and registration form transition)\n\tconst setContainerHeight = function() {\n\t\tif ($(window).width() < mobileBreakpoint) {\n\t\t\t$('.left-column').css('height', '');\n\t\t}\n\t\tconst contentHeight = $('.is-shown').height();\n\t\t$('.left-column .slot-container .slot-height').css('height', contentHeight);\n\t}\n\n\t//Validation\n\tconst validator = new Validator($form);\n\tconst showErrors = showValidationErrors($form);\n\tconst showAlert = alert($fieldContainer);\n\n\t// validate fields on input change\n\t$form.find('input').on('change focusout', function() {\n\t\tvalidator.validateField($(this));\n\t});\n\n\tinputFilteringEvents($form);\n\n\t// validation success callback\n\tvalidator.on('success', $input => {\n\t\t$input\n\t\t\t.removeClass('validation-error')\n\t\t\t.closest('.field')\n\t\t\t.find('.validation-error-msg')\n\t\t\t.remove();\n\t\tsetContainerHeight();\n\t});\n\n\t// validation error callback\n\tvalidator.on('fail', ($input, errors) => {\n\t\terrors = errors.filter(error => error.rule !== 'username');\n\t\tif (!errors.length) {\n\t\t\tvalidator.emit('success', $input);\n\t\t}\n\t\tshowErrors(errors);\n\t\tsetContainerHeight();\n\t});\n\n\t$form.find('.show-password').on('click', function(e) {\n\t\tconst passwordField = $(this).siblings('input');\n\t\tconst passwordFieldType = passwordField.attr('type');\n\t\tif (passwordFieldType === 'password') {\n\t\t\tpasswordField.attr('type', 'text');\n\t\t\t$(this).text('Piilota');\n\t\t} else {\n\t\t\tpasswordField.attr('type', 'password');\n\t\t\t$(this).text('Näytä');\n\t\t}\n\t});\n\n\t//Toggle login and registration forms\n\tconst toggleForms = () => {\n\t\t$('.side-2').toggleClass('flip-side-1 is-shown');\n\t\t$('.side-1').toggleClass('flip-side-2 is-shown');\n\t}\n\n\t$('.side-1').toggleClass('is-shown'); //set class for club login on page load\n\n\tif (isLoginPage) {\n\t\t$form.css({'position': 'fixed', 'visibility': 'hidden', 'pointer-events': 'none'}); //for very low screens (login scroll event)\n\t\tsetContainerHeight();\n\n\t\t//set correct container height automatically on window resize\n\t\t$(window).on('resize', debounce(() => {\n\t\t\tif ($(window).width() < mobileBreakpoint) {\n\t\t\t\t$('.left-column').css('height', 'auto');\n\t\t\t}\n\t\t\tsetContainerHeight();\n\t\t}, 100))\n\t}\n\n\t//Toggle login and registration form\n\t$container.find('#signup').click(e => {\n\t\te.preventDefault();\n\t\t$form.css({'position': '', 'visibility': '', 'pointer-events': ''});\n\t\ttoggleForms();\n\t\tsetContainerHeight();\n\t\tconst containerDown = $form.offset().top + $form.outerHeight();\n\t\tconst leftColumnDown = $('.left-column').offset().top + $('.left-column').outerHeight()\n\t\tconst overFooter = leftColumnDown - containerDown;\n\n\t\tif($(window).width() >= mobileBreakpoint) {\n\t\t\tif(overFooter < 0) {\n\t\t\t\tconst scrollBody = leftColumnDown - $form.outerHeight();\n\t\t\t\t$('html,body').animate({ scrollTop: scrollBody}, 'fast');\n\t\t\t}\n\t\t} else {\n\t\t\t$('html,body').animate({ scrollTop: 0}, 'fast');\n\t\t}\n\t});\n\n\t$container.find('#login').click( e => {\n\t\te.preventDefault();\n\t\ttoggleForms();\n\t\tsetContainerHeight();\n\t\tif ($(window).width() < mobileBreakpoint) {\n\t\t\t$('html,body').animate({ scrollTop: 0 }, 'fast');\n\t\t} else if (isLoginPage) {\n\t\t\tsetTimeout(() => {\n\t\t\t\t$form.css({'position': 'fixed', 'visibility': 'hidden', 'pointer-events': 'none'});\n\t\t\t}, 1000);\n\t\t}\n\t});\n\n\t//Show registration with '../#liity' or /?liity=1\n\tif((location.hash === '#liity' || location.search?.includes('liity=1')) && isLoginPage ) {\n\t\t$form.css({'position': '', 'visibility': '', 'pointer-events': ''});\n\t\ttoggleForms();\n\t\tsetContainerHeight();\n\t} else if (location.hash && isLoginPage) {\n\t\tif ((location.hash).includes('#uusi-salasana')) {\n\t\t\tlet loginForm = document.querySelector('.login-form'),\n\t\t\t\tresetAnchor = document.querySelector('.reset-password');\n\t\t\tif (loginForm && resetAnchor) {\n\t\t\t\tloginForm.classList.add('hidden');\n\t\t\t\tresetAnchor.classList.remove('hidden');\n\t\t\t}\n\t\t}\n\t}\n\n\t//Set correct height when alert is closed\n\t$fieldContainer.on('closeAlert', e => {\n\t\tsetContainerHeight();\n\t})\n\n\t$form.find('.reset-password-link, .back-to-login').click(e => {\n\t\te.preventDefault();\n\t\tsetContainerHeight();\n\t})\n\n\t$('.back-to-request-otp').click(e => {\n\t\te.preventDefault();\n\t\tshowPasswordResetStep(1);\n\t})\n\n\tconst submitAjaxForm = ($form) => {\n\t\tlet data = $form.serialize();\n\t\tdata += '&campaign=1';\n\n\t\tconst loader = utils.addFormLoader($container.find('.club-registration'));\n\t\treturn getToken()\n\t\t\t.then(token => {\n\t\t\t\tdata += '&token=' + token;\n\t\t\t\treturn Promise.resolve($.ajax({\n\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\turl: $form.attr('action'),\n\t\t\t\t\tdata\n\t\t\t\t}));\n\t\t\t})\n\t\t\t.tap(res => {\n\t\t\t\tif (res && res.success === 1) {\n\t\t\t\t\tif( res.alreadyJoined ) {\n\t\t\t\t\t\t$('.club-registration').addClass('hidden');\n\t\t\t\t\t\t$('.lottery-contact').addClass('hidden');\n\t\t\t\t\t\t$('.already-participated').css('display', 'inline-block');\n\t\t\t\t\t} else {\n\t\t\t\t\t\t$('.club-registration').addClass('hidden');\n\t\t\t\t\t\t$('.registration-success').removeClass('hidden u-hidden');\n\t\t\t\t\t\t$('.lottery-contact').addClass('hidden');\n\t\t\t\t\t\t$('.thanks').css('display', 'inline-block');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn res;\n\t\t\t})\n\t\t\t.always(() => loader.remove());\n\t}\n\n\t//Validate and submit registration form\n\t$form.find('.send-registration').click(e => {\n\t\te.preventDefault();\n\t\tconst data = $form.serializeObject();\n\n\t\tif (Array.isArray(data.email)) {\n\t\t\tdata.email = data.email[0];\n\t\t}\n\n\t\t$.each(data, (key, val) => {\n\t\t\tif (key.indexOf('[]') > -1) {\n\t\t\t\tdata[key.replace('[]', '')] = val;\n\t\t\t\tdelete data[key];\n\t\t\t}\n\t\t});\n\n\t\tif (data.kplussa_number) {\n\t\t\tconst plussaPrefix = String($form.find('input[name=\"kplussa_number\"]').data('plussa-prefix'));\n\t\t\tif (data.kplussa_number.indexOf(plussaPrefix) !== 0) {\n\t\t\t\tdata.kplussa_number = plussaPrefix + data.kplussa_number\n\t\t\t}\n\t\t}\n\n\t\tconst definition = 'registration';\n\n\t\t// validate registration\n\t\treturn validate({ definition, fields: data })\n\t\t\t.then(res => {\n\t\t\t\t$form.find('.validation-alert').slideUp('fast', function() {\n\t\t\t\t\t$(this).remove();\n\t\t\t\t});\n\n\t\t\t\tif (res.errors && res.errors.length) {\n\t\t\t\t\tshowErrors(res.errors);\n\t\t\t\t\tshowAlert({ message: 'Tarkista lomakkeen tiedot!', type: 'danger', persistent: true }).then( () => {\n\t\t\t\t\t\tif (isLoginPage) {\n\t\t\t\t\t\t\t$('html,body').animate({ scrollTop: $form.offset().top - 40 });\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsetContainerHeight()\n\t\t\t\t\t})\n\t\t\t\t} else if (res.pass) {\n\t\t\t\t\tif (useAjax) {\n\t\t\t\t\t\tlocalStorage.removeItem('myJoker');\n\t\t\t\t\t\tsubmitAjaxForm($form);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst $input = $(this).find('input[name=kplussa_number]');\n\t\t\t\t\t\tif ($input.length && $input.val()) {\n\t\t\t\t\t\t\tconst plussaPrefix = String($input.data('plussa-prefix'));\n\t\t\t\t\t\t\t$input.val(plussaPrefix + $input.val());\n\t\t\t\t\t\t}\n\t\t\t\t\t\t$form.submit();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t})\n\t\t\t.catch(res => {\n\t\t\t\tconst message = res.message || 'Hups! Jotain meni pieleen. Yritä hetken kuluttua uudestaan.';\n\t\t\t\tshowErrorMessage(message);\n\t\t\t})\n\t})\n\n}\n\n"],"sourceRoot":""}