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BAAuBqB,GAAG,SAAS,SAAC7B,GAG/CV,EAAE,kBAAkBQ,SAAS,SACjC,IAEAR,EAAE,kBAAkBuC,GAAG,SAAS,SAAU7B,GACtCA,EAAEC,iBACFX,EAAEa,MAAML,SAAS,UACjBe,EAAUL,KAAK,uBAAuBsB,OAG1C,IAGAjB,EAAUkB,QAAO,SAAC/B,GAEd,GADAA,EAAEC,iBACE+B,OAAOC,qBAAuBD,OAAOC,oBAAoBC,QAAQ,UAAY,EAAG,CAChF,IAAMC,EAAYtB,EAAUL,KAAK,uBAAuBQ,MACxDH,EAAUL,KAAK,uBAAuBJ,KAAK,kBAAmB+B,GAC9DvB,EAAWE,GAAWqB,EACtBjB,aAAakB,QAAQ,cAAehB,KAAKiB,UAAUzB,IACnDtB,EAAE,uBAAuBqC,KAAK,4BAC9BrC,EAAE,8BAA8BgD,IAAI,SAAU,QAC9CC,YAAW,WACPjD,EAAE,uBAAuBqC,KAAK,GAClC,GAAG,KACHd,EAAU2B,OAAO,WACjBZ,GACJ,MACItC,EAAE,uBAAuBqC,KAAK,+BAEtC,IAGA,IAAMc,EAAYnD,EAAE,qBACpB,QAAqC,IAA1BmD,EAAUrC,KAAK,OAAwB,CAC9C,IAAMsC,EAAYD,EAAUrC,KAAK,OAC3BuC,EAAYD,EAAUjB,QAAQ,cAAe,0BAC/CmB,GAAY,EAEhBC,aAAY,YACRD,GAAaA,GAETH,EAAUrC,KAAK,MAAOuC,GAEtBF,EAAUrC,KAAK,MAAOsC,EAE9B,GAAG,IACP,CACJ,CAGQI,EACJ,GAKRxD,EAAEyD,UAAUC,OAAM,WACdxD,OAAOC,aAAaC,MACxB,G","sources":["webpack://soyvay-com/./js/src/pages/single-recipe.js"],"sourcesContent":["/**\n * single recipe js\n * handles behavior and note saving funcitonality for single recipe post\n *\n */\n(function ($) {\n SoyVay.singleRecipe = (function () {\n function privateInit() {\n // detect if iphone or ipad\n if (navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i)) {\n $('body').addClass('iphone-ipad');\n }\n\n $('.db-scroll-link').click(function (e) {\n e.preventDefault();\n const targetId = $(this).attr('href');\n const scrollTo = $(targetId).offset().top - 185;\n $('.db-scroll-link').find('.circle').removeClass('circle-active');\n $(this).find('.circle').addClass('circle-active');\n $('html,body').animate(\n {\n scrollTop: scrollTo,\n },\n 500\n );\n });\n\n const $noteForm = $('#recipe-note-form');\n const $postID = `recipe-${$noteForm.find('[name=post_id]').val()}`;\n let notesArray;\n\n // check Local Storage for previously saved notes\n const recipeStorage = localStorage.getItem('recipeNotes');\n notesArray = recipeStorage ? JSON.parse(recipeStorage) : {};\n if (notesArray[$postID]) {\n $noteForm.find('[name=note_content]').attr('data-last-saved', notesArray[$postID]);\n var entityMap = {\n '&': '&',\n '<': '<',\n '>': '>',\n '\"': '"',\n \"'\": ''',\n '/': '/',\n '`': '`',\n '=': '='\n };\n var sanitizedNote = String(notesArray[$postID]).replace(/[&<>\"'`=\\/]/g, function (s) { return entityMap[s];});\n $noteForm.find('[name=note_content]').html(sanitizedNote);\n }\n\n // Character Count removed as a requirement\n /*\n // Show remaining characters available for user notes.\n // The maximum length is set via the textarea's maxlength attribute.\n var updateCharacterCount = function() {\n var maxLength = $noteForm.find('[name=note_content]').attr('maxlength');\n var currentLength = $noteForm.find('[name=note_content]').val().length;\n var charsRemaining = maxLength - currentLength;\n $noteForm.find('.note-character-count span').text(charsRemaining);\n\n if(charsRemaining <= 10) {\n $noteForm.find('.note-character-count').addClass('near-limit');\n } else {\n $noteForm.find('.note-character-count').removeClass('near-limit');\n }\n }\n */\n\n const updateNoteUI = function () {\n if (\n $noteForm.find('[name=note_content]').attr('data-last-saved') !==\n $noteForm.find('[name=note_content]').val()\n ) {\n $noteForm.find('[type=submit]').attr('disabled', false);\n } else {\n $noteForm.find('[type=submit]').attr('disabled', true);\n }\n // Character Count removed as a requirement\n // updateCharacterCount();\n };\n\n // Character Count removed as a requirement\n // Populate remaining character count on page load\n // updateCharacterCount();\n\n // update note UI to start with disabled state\n updateNoteUI();\n\n // Cache note contents on page load to\n // decide if a save affordance should be\n // shown to the user when content has changed.\n $noteForm.find('[name=note_content]').on('input paste', (e) => {\n updateNoteUI();\n });\n\n $noteForm.find('[name=note_content]').on('focus', (e) => {\n // Character Count removed as a requirement\n // $noteForm.find('.note-character-count').removeClass('hidden');\n $('.js-edit-notes').addClass('hidden');\n });\n\n $('.js-edit-notes').on('click', function (e) {\n e.preventDefault();\n $(this).addClass('hidden');\n $noteForm.find('[name=note_content]').focus();\n // Character Count removed as a requirement\n // $noteForm.find('.note-character-count').removeClass('hidden');\n });\n\n // Handle saving a recipe note\n $noteForm.submit((e) => {\n e.preventDefault();\n if (window.OptanonActiveGroups && window.OptanonActiveGroups.indexOf('C0003') >= 0) {\n const lastSaved = $noteForm.find('[name=note_content]').val();\n $noteForm.find('[name=note_content]').attr('data-last-saved', lastSaved);\n notesArray[$postID] = lastSaved;\n localStorage.setItem('recipeNotes', JSON.stringify(notesArray));\n $('.note-saved-message').html('Your note has been saved');\n $('#recipe-note-form textarea').css('border', 'none');\n setTimeout(() => {\n $('.note-saved-message').html('');\n }, 3000);\n $noteForm.garlic('destroy');\n updateNoteUI();\n } else {\n $('.note-saved-message').html('Your note could not be saved');\n }\n });\n\n // Swap the tip icon with the video icon when it flashes\n const $tipImage = $('.toggle-video img');\n if (typeof $tipImage.attr('src') !== 'undefined') {\n const tipImgSrc = $tipImage.attr('src');\n const vidImgSrc = tipImgSrc.replace('tipicon.svg', 'img/global/vidicon.png');\n let isVidIcon = false;\n\n setInterval(() => {\n isVidIcon = !isVidIcon;\n if (isVidIcon) {\n $tipImage.attr('src', vidImgSrc);\n } else {\n $tipImage.attr('src', tipImgSrc);\n }\n }, 2000);\n }\n }\n return {\n init() {\n privateInit();\n },\n };\n })();\n\n // document ready\n $(document).ready(() => {\n SoyVay.singleRecipe.init();\n });\n})(jQuery);\n"],"names":["$","jQuery","SoyVay","singleRecipe","init","navigator","userAgent","match","addClass","click","e","preventDefault","targetId","this","attr","scrollTo","offset","top","find","removeClass","animate","scrollTop","notesArray","$noteForm","$postID","concat","val","recipeStorage","localStorage","getItem","JSON","parse","entityMap","sanitizedNote","String","replace","s","html","updateNoteUI","on","focus","submit","window","OptanonActiveGroups","indexOf","lastSaved","setItem","stringify","css","setTimeout","garlic","$tipImage","tipImgSrc","vidImgSrc","isVidIcon","setInterval","privateInit","document","ready"],"sourceRoot":""}