{"version":3,"file":"uppsala.clearable-inputfield.min.js","names":["define","$","init","each","$container","this","$inputfield","find","$clearbutton","toggleClass","val","on","value","e","preventDefault","trigger","focus"],"sources":["uppsala.clearable-inputfield.js"],"mappings":"AAAAA,OAAO,CAAC,WAAW,SAAUC,GAyBzB,MAxB2B,CACvBC,KAAM,WACFD,EAAE,4BAA4BE,MAAK,WAC/B,IAAIC,EAAaH,EAAEI,MACfC,EAAcF,EAAWG,KAAK,uBAC9BC,EAAeJ,EAAWG,KAAK,6BAGnCH,EAAWK,YAAY,8CAA+CH,EAAYI,OAGlFJ,EAAYK,GAAG,SAAS,WACpBP,EAAWK,YAAY,8CAA+CJ,KAAKO,MAC/E,IAEAJ,EAAaG,GAAG,oBAAoB,SAAUE,GAC1CA,EAAEC,iBACFR,EAAYI,IAAI,IAAIK,QAAQ,SAC5BT,EAAYU,OAChB,GACJ,GACJ,EAIR","ignoreList":[],"sourcesContent":["define([\"jquery\"], function ($) {\n var clearableSearchfield = {\n init: function () {\n $(\".js-clearable-inputfield\").each(function () {\n var $container = $(this);\n var $inputfield = $container.find(\".js-clearable-input\");\n var $clearbutton = $container.find(\".js-clearable-clearbutton\");\n\n //on load, toggle clear button to visible if field has value\n $container.toggleClass(\"clearable-inputfield--clearbutton-visible\", !!$inputfield.val());\n\n //on input change, toggle clear button to visible if field has value\n $inputfield.on(\"input\", function () {\n $container.toggleClass(\"clearable-inputfield--clearbutton-visible\", !!this.value);\n });\n\n $clearbutton.on(\"touchstart click\", function (e) {\n e.preventDefault();\n $inputfield.val(\"\").trigger(\"input\");\n $inputfield.focus();\n });\n });\n }\n };\n\n return clearableSearchfield;\n});"]}