{"version":3,"file":"application.js","mappings":"CAAA,WAIE,SAASA,IACP,IAAIC,EAAWC,SAASC,iBAAiB,0BAGzCC,MAAMC,UAAUC,QAAQC,KAAKN,GAAU,SAAUO,GACtC,IAAIC,cAAcC,OACzBF,EACA,uBACA,KACA,CACEG,eAAgB,CACdC,SAAU,OAOTC,GAAG,iBAAiB,SAAUC,EAAaC,GAChD,IAAIC,EAAeF,EAAYG,MAAM,MAErCT,EAAeU,MAAQF,EAAaG,KAAK,QACzCX,EAAeY,KAAOJ,EAAaK,MACrC,IAIA,IAAIC,EAAmBd,EAAeU,MAAMD,MAAM,KAAKI,OACvDb,EAAeY,KAAOE,CACxB,GACF,CAeApB,SAASqB,iBAAiB,oBAAoB,WAC5C,IAXmCC,EAC/BC,EAUgBvB,SAASwB,uBAAuB,iBAElCL,OAAS,IAbQG,EAcLxB,GAb1ByB,EAASvB,SAASyB,cAAc,WAC7BC,IAAM,mDACbH,EAAOI,OAAQ,EACfJ,EAAOK,OAASN,EAChBtB,SAAS6B,KAAKC,YAAYP,GAW5B,GACD,CAxDD","sources":["webpack:///./app/javascript/addressfinder.js"],"sourcesContent":["(function () {\n var widget = null;\n\n // Binds a new Addressfinder widget to any textarea element with a class named 'addressfinder'\n function initialiseAddressfinder() {\n var elements = document.querySelectorAll('textarea.addressfinder')\n\n // IE compatibility enabled\n Array.prototype.forEach.call(elements, function (addressElement) {\n widget = new AddressFinder.Widget(\n addressElement,\n \"PKWQ7XJH3GBUCLFMV49Y\",\n 'NZ',\n {\n address_params: {\n post_box: '0'\n }\n }\n );\n\n // When an address is selected, put each portion of the address on a new\n // line. This matches existing behaviour. \n widget.on('result:select', function (fullAddress, metaData) {\n var addressLines = fullAddress.split(', ');\n\n addressElement.value = addressLines.join(', \\n');\n addressElement.rows = addressLines.length;\n });\n\n // Make the number of rows in the textarea element just the right\n // size for the current address (if any).\n var initialLineCount = addressElement.value.split(',').length;\n addressElement.rows = initialLineCount;\n });\n }\n\n // Downloads the Addressfinder widget, and calls the initialisation\n // function when loaded. This avoids Addressfinder from blocking any\n // other actions or assets that may need to be loaded. \n function downloadAddressfinderWidget(initialisationFunction) {\n var script = document.createElement('script');\n script.src = 'https://api.addressfinder.io/assets/v3/widget.js';\n script.async = true;\n script.onload = initialisationFunction;\n document.body.appendChild(script);\n };\n\n // Only activate Addressfinder if there are elements with an 'addressfinder'\n // class present. Otherwise, do nothing. \n document.addEventListener('DOMContentLoaded', function () {\n var addressFields = document.getElementsByClassName('addressfinder');\n\n if (addressFields.length > 0) {\n downloadAddressfinderWidget(initialiseAddressfinder);\n }\n });\n})();\n"],"names":["initialiseAddressfinder","elements","document","querySelectorAll","Array","prototype","forEach","call","addressElement","AddressFinder","Widget","address_params","post_box","on","fullAddress","metaData","addressLines","split","value","join","rows","length","initialLineCount","addEventListener","initialisationFunction","script","getElementsByClassName","createElement","src","async","onload","body","appendChild"],"sourceRoot":""}