{"version":3,"sources":["pages/SuggestAListingPage.js"],"names":["SuggestAListingPage","geocoder","map","infowindow","marker","autocomplete","showGeocodeResults","place","status","address","addr","address_components","formatted_address","length","short_name","join","su","a1a","a1b","a1","st","pc","i","types","long_name","$","val","trim","readonly","show","prop","setAddressEdit","saveLatLng","geometry","location","loadDetails","latlng","content","close","google","maps","InfoWindow","setMap","Marker","position","clickable","setContent","setPosition","open","event","trigger","setCenter","setZoom","markMap","lat","lng","Init","validator","setDefaults","highlight","element","group","closest","addClass","unhighlight","removeClass","errorElement","errorClass","errorPlacement","error","insertAfter","selectize","delimiter","maxItems","create","closeAfterSelect","openOnFocus","plugins","accessibility","Label","DescribedBy","document","on","keyCode","hide","mask","q","orgs","Bloodhound","name","datumTokenizer","tokenizers","obj","whitespace","queryTokenizer","limit","remote","url","replace","query","encodeURIComponent","ajax","beforeSend","ev","settings","data","JSON","stringify","Search","dataType","contentType","type","filter","results","result","DisplayName","OrganisationID","initialize","typeahead","hint","minLength","displayKey","source","ttAdapter","templates","suggestion","d","datum","html","e","preventDefault","valid","submit","first","focus","validate","rules","LocationPhone","ausPhone","require_from_group","LocationEmail","mcdEmail","LocationWebsite","UserPhone","UserMobile","ausMobile","UserEmail","ContactPhone","ContactMobile","ContactEmail","AddressComplete","Suburb","State","Postcode","messages","OrganisationName","Geocoder","input","mapOptions","center","LatLng","zoom","mapTypeId","MapTypeId","ROADMAP","Map","getElementById","places","Autocomplete","componentRestrictions","country","bindTo","addListener","getPlace","viewport","fitBounds","latLng","geocode","GeocoderStatus","OK","alert","initAddress","this","Common","FormatAsAusPhone"],"mappings":"AAAA,IAAIA,qBACJ,WA4MI,IAAIC,EACAC,EACAC,EACAC,EACAC,EA4CJ,SAASC,EAAmBC,EAAOC,EAAQC,GACvC,IAAIC,EAAOD,EACPF,EAAMI,qBAEFD,EADyC,GAAxCH,EAAMK,mBAAqB,IAAIC,OACzBN,EAAMK,kBAGN,CAAEL,EAAMI,mBAAmB,IAAMJ,EAAMI,mB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oBAAoBC,IAAI,IAC1BD,EAAE,aAAaC,IAAI,IACnBD,EAAE,aAAaC,IAAI,IACnBD,EAAE,WAAWC,IAAI,IACjBD,EAAE,UAAUC,IAAI,IAChBD,EAAE,aAAaC,IAAI,OAG3BD,EAAE,aAAayD,GAAG,OAAQ,WAClBzD,EAAE6J,MAAM5J,OAER6J,OAAOC,iBAAiB/J,EAAE6J,MAAO7J,EAAE,UAAUC,YAtMjE","file":"SuggestAListingPage.min.js","sourcesContent":["var SuggestAListingPage;\r\n(function (SuggestAListingPage) {\r\n    function Init() {\r\n        $(function () {\r\n            $.validator.setDefaults({\r\n                highlight: function (element) {\r\n                    var group = $(element).closest('.form-group');\r\n                    if (group.length) {\r\n                        group.addClass('has-error');\r\n                    }\r\n                    else {\r\n                        $(element).addClass('has-error');\r\n                    }\r\n                },\r\n                unhighlight: function (element) {\r\n                    var group = $(element).closest('.form-group');\r\n                    if (group.length) {\r\n                        group.removeClass('has-error');\r\n                    }\r\n                    else {\r\n                        $(element).removeClass('has-error');\r\n                    }\r\n                },\r\n                errorElement: 'span',\r\n                errorClass: 'help-block',\r\n                errorPlacement: function (error, element) {\r\n                    var group = $(element).closest('.form-group');\r\n                    if (group.length) {\r\n                        error.insertAfter(group);\r\n                    }\r\n                    else {\r\n                        error.insertAfter(element);\r\n                    }\r\n                }\r\n            });\r\n            $(\"#Services\").selectize({\r\n                delimiter: '|',\r\n                maxItems: null,\r\n                create: false,\r\n                closeAfterSelect: false,\r\n                openOnFocus: false,\r\n                plugins: { \"accessibility\": { Label: \"Select a Service Category\", DescribedBy: \"servicesDescription\" } }\r\n            });\r\n            // Disable the Enter key from submitting the form (i.e when users press Enter to select address or add a new line in the brief description)\r\n            $(document).on(\"keypress\", \":input:not(textarea)\", function (event) {\r\n                return event.keyCode != 13;\r\n            });\r\n            $(\"#divFormattedAddress\").hide();\r\n            $('#Address1').prop(\"readonly\", true);\r\n            $('#Address2').prop(\"readonly\", true);\r\n            $('#Suburb').prop(\"readonly\", true);\r\n            $('#Postcode').prop(\"readonly\", true);\r\n            $('#State').prop(\"readonly\", true);\r\n            $(\"#ABN\").mask('99 999 999 999');\r\n            var q = \"\";\r\n            var orgs = new Bloodhound({\r\n                name: \"organisations\",\r\n                datumTokenizer: Bloodhound.tokenizers.obj.whitespace(\"DisplayName\"),\r\n                queryTokenizer: Bloodhound.tokenizers.whitespace,\r\n                limit: 20,\r\n                remote: {\r\n                    url: \"/SuggestAListing/FetchOrganisations\",\r\n                    replace: function (url, query) {\r\n                        q = query;\r\n                        // Change the url target url so it triggers\r\n                        url = url + \"#\" + encodeURIComponent(q);\r\n                        return url;\r\n                    },\r\n                    ajax: {\r\n                        beforeSend: function (ev, settings) {\r\n                            settings.data = JSON.stringify({ Search: q });\r\n                        },\r\n                        dataType: \"json\",\r\n                        contentType: \"application/json; charset=utf-8\",\r\n                        type: \"POST\"\r\n                    },\r\n                    filter: function (results) {\r\n                        return $.map(results, function (result) {\r\n                            return {\r\n                                DisplayName: result.DisplayName,\r\n                                OrganisationID: result.OrganisationID\r\n                            };\r\n                        });\r\n                    }\r\n                }\r\n            });\r\n            orgs.initialize();\r\n            $(\"#OrganisationName\").typeahead({\r\n                hint: true,\r\n                minLength: 3,\r\n                highlight: true\r\n            }, {\r\n                name: \"organisations\",\r\n                displayKey: \"DisplayName\",\r\n                source: orgs.ttAdapter(),\r\n                templates: {\r\n                    suggestion: function (d) {\r\n                        return \"<p class='needsclick'>\" + d.DisplayName + \"</p>\";\r\n                    }\r\n                }\r\n            });\r\n            $(\"#OrganisationName\").on(\"typeahead:selected\", function (obj, datum) {\r\n                $(\"#LocationName\").val(\"\");\r\n                $(\".outletPreview\").html(\"\");\r\n                $(\"#LocationName\").removeClass(\"sal-square-right\");\r\n                $(\"#divContactDetails\").show();\r\n                $(\"#divLocationAddress\").show();\r\n                $(\"#OutletID\").val(\"0\");\r\n                $(\"#OrganisationID\").val(datum.OrganisationID);\r\n            });\r\n            $(\"#btnSave\").on(\"click\", function (e) {\r\n                e.preventDefault();\r\n                if ($(\"#suggestAListingForm\").valid()) {\r\n                    $(\"#suggestAListingForm\").submit();\r\n                }\r\n                else {\r\n                    $(\".has-error :input:not([readonly])\").first().focus();\r\n                }\r\n            });\r\n            $(\"#suggestAListingForm\").validate({\r\n                rules: {\r\n                    LocationPhone: {\r\n                        ausPhone: true,\r\n                        require_from_group: [1, \".location-contact\"]\r\n                    },\r\n                    LocationEmail: {\r\n                        mcdEmail: true,\r\n                        require_from_group: [1, \".location-contact\"]\r\n                    },\r\n                    LocationWebsite: {\r\n                        url: true,\r\n                        require_from_group: [1, \".location-contact\"]\r\n                    },\r\n                    UserPhone: {\r\n                        ausPhone: true,\r\n                        require_from_group: [1, \".user-contact\"]\r\n                    },\r\n                    UserMobile: {\r\n                        ausMobile: true,\r\n                        require_from_group: [1, \".user-contact\"]\r\n                    },\r\n                    UserEmail: {\r\n                        mcdEmail: true,\r\n                        require_from_group: [1, \".user-contact\"]\r\n                    },\r\n                    ContactPhone: {\r\n                        ausPhone: true\r\n                    },\r\n                    ContactMobile: {\r\n                        ausMobile: true\r\n                    },\r\n                    ContactEmail: {\r\n                        mcdEmail: true\r\n                    },\r\n                    AddressComplete: {\r\n                        require_from_group: [4, \".location-address\"]\r\n                    },\r\n                    Suburb: {\r\n                        require_from_group: [4, \".location-address\"]\r\n                    },\r\n                    State: {\r\n                        require_from_group: [4, \".location-address\"]\r\n                    },\r\n                    Postcode: {\r\n                        require_from_group: [4, \".location-address\"]\r\n                    }\r\n                },\r\n                messages: {\r\n                    OrganisationName: \"An Organisation Name is required\",\r\n                    LocationPhone: { require_from_group: \"A Phone, Email or Website is required\", ausPhone: \"Please enter a valid Phone number\" },\r\n                    LocationEmail: { require_from_group: \"A Phone, Email or Website is required\", mcdEmail: \"Please enter a valid Email address\" },\r\n                    LocationWebsite: { require_from_group: \"A Phone, Email or Website is required\", url: \"Please enter a valid Website\" },\r\n                    AddressComplete: \"An Address is required\",\r\n                    Suburb: \"A Suburb is required\",\r\n                    State: \"A State is required\",\r\n                    Postcode: \"A Postcode is required\",\r\n                    UserPhone: { require_from_group: \"A Phone, Mobile or Email is required\", ausPhone: \"Please enter a valid Phone number\" },\r\n                    UserMobile: { require_from_group: \"A Phone, Mobile or Email is required\", ausMobile: \"Please enter a valid Mobile number\" },\r\n                    UserEmail: { require_from_group: \"A Phone, Mobile or Email is required\", mcdEmail: \"Please enter a valid Email address\" },\r\n                    ContactPhone: { ausPhone: \"Please enter a valid Phone number\" },\r\n                    ContactMobile: { ausMobile: \"Please enter a valid Mobile number\" },\r\n                    ContactEmail: { mcdEmail: \"Please enter a valid Email address\" }\r\n                }\r\n            });\r\n            initAddress();\r\n            $(\"#AddressComplete\").on(\"blur\", function () {\r\n                if (!$(this).val()) {\r\n                    $(\"#divFormattedAddress\").hide();\r\n                    $(\"#BuildingAddress\").val('');\r\n                    $(\"#Address1\").val('');\r\n                    $(\"#Address2\").val('');\r\n                    $(\"#Suburb\").val('');\r\n                    $(\"#State\").val('');\r\n                    $(\"#Postcode\").val('');\r\n                }\r\n            });\r\n            $(\".ausPhone\").on(\"blur\", function () {\r\n                if ($(this).val()) {\r\n                    // format the number\r\n                    Common.FormatAsAusPhone($(this), $(\"#State\").val());\r\n                }\r\n            });\r\n        });\r\n    }\r\n    SuggestAListingPage.Init = Init;\r\n    var geocoder;\r\n    var map;\r\n    var infowindow;\r\n    var marker;\r\n    var autocomplete;\r\n    function initAddress() {\r\n        geocoder = new google.maps.Geocoder();\r\n        var mapOptions = {\r\n            center: new google.maps.LatLng(-25.049072, 134.35711879999997),\r\n            zoom: 4,\r\n            mapTypeId: google.maps.MapTypeId.ROADMAP\r\n        };\r\n        map = new google.maps.Map(document.getElementById('map'), mapOptions);\r\n        var input;\r\n        input = document.getElementById('AddressComplete');\r\n        autocomplete = new google.maps.places.Autocomplete(input, { componentRestrictions: { country: 'au' } });\r\n        autocomplete.bindTo(\"bounds\", map);\r\n        google.maps.event.addListener(autocomplete, 'place_changed', function () {\r\n            clearMap();\r\n            var place = autocomplete.getPlace();\r\n            if (place.geometry.viewport) {\r\n                map.fitBounds(place.geometry.viewport);\r\n            }\r\n            else {\r\n                map.setCenter(place.geometry.location);\r\n            }\r\n            showGeocodeResults(place, 'AutoComplete failed.', '');\r\n        });\r\n        google.maps.event.addListener(map, 'click', function (event) { geocodeLatLng(event.latLng); });\r\n    }\r\n    function setAddressEdit(readonly) {\r\n        $(\"#divFormattedAddress\").show();\r\n        $('#Address1').prop(\"readonly\", readonly);\r\n        $('#Address2').prop(\"readonly\", readonly);\r\n        $('#Suburb').prop(\"readonly\", readonly);\r\n        $('#Postcode').prop(\"readonly\", readonly);\r\n        $('#State').prop(\"readonly\", readonly);\r\n    }\r\n    function geocodeLatLng(latlng) {\r\n        geocoder.geocode({ 'latLng': latlng }, function (results, status) {\r\n            if (status == google.maps.GeocoderStatus.OK) {\r\n                showGeocodeResults(results[0], status, '');\r\n            }\r\n            else {\r\n                alert('Geocode was not successful for the following reason: ' + status);\r\n            }\r\n        });\r\n    }\r\n    function showGeocodeResults(place, status, address) {\r\n        var addr = address;\r\n        if (place.address_components) {\r\n            if ((place.formatted_address || \"\").length > 0) {\r\n                addr = place.formatted_address;\r\n            }\r\n            else {\r\n                addr = [(place.address_components[0] && place.address_components[0].short_name || ''),\r\n                    (place.address_components[1] && place.address_components[1].short_name || ''),\r\n                    (place.address_components[2] && place.address_components[2].short_name || '')].join(', ');\r\n            }\r\n            loadDetails(place);\r\n            $('#editAddress').show();\r\n        }\r\n        markMap(place.geometry.location, addr);\r\n    }\r\n    function loadDetails(place) {\r\n        var su = '';\r\n        var a1a = '';\r\n        var a1b = '';\r\n        var a1 = '';\r\n        var a2 = '';\r\n        var st = '';\r\n        var pc = '';\r\n        for (var i = 0; i < place.address_components.length; i++) {\r\n            switch (place.address_components[i].types[0]) {\r\n                case \"street_address\":\r\n                    a1 = place.address_components[i].long_name;\r\n                    break;\r\n                case \"street_number\":\r\n                    a1a = place.address_components[i].long_name;\r\n                    break;\r\n                case \"route\":\r\n                    a1b = place.address_components[i].long_name;\r\n                    break;\r\n                case \"locality\":\r\n                    su = place.address_components[i].long_name;\r\n                    break;\r\n                case \"administrative_area_level_1\":\r\n                    st = place.address_components[i].short_name;\r\n                    break;\r\n                case \"postal_code\":\r\n                    pc = place.address_components[i].short_name;\r\n                    break;\r\n                default: break;\r\n            }\r\n        }\r\n        if (a1.length == 0)\r\n            a1 = a1a + ' ' + a1b;\r\n        if (a1.length > 0 || su.length > 0) {\r\n            $(\"#AddressComplete\").val(place.formatted_address);\r\n            $(\"#BuildingAddress\").val(\"\");\r\n            $(\"#Address1\").val($.trim(a1) || \"\");\r\n            $(\"#Address2\").val($.trim(a2) || \"\");\r\n            $(\"#Suburb\").val($.trim(su) || \"\");\r\n            $(\"#State\").val($.trim(st) || \"\");\r\n            $(\"#Postcode\").val($.trim(pc) || \"\");\r\n            setAddressEdit(true);\r\n        }\r\n        saveLatLng(place.geometry.location);\r\n    }\r\n    function saveLatLng(latlng) {\r\n        $(\"#Lat\").val(latlng.lat());\r\n        $(\"#Lng\").val(latlng.lng());\r\n    }\r\n    function clearMap() {\r\n        $(\"#Lat\").val(0);\r\n        $(\"#Lng\").val(0);\r\n        if (infowindow != null)\r\n            infowindow.close();\r\n    }\r\n    function markMap(latlng, content) {\r\n        if (infowindow != null)\r\n            infowindow.close();\r\n        infowindow = new google.maps.InfoWindow();\r\n        if (marker != null)\r\n            marker.setMap(null);\r\n        marker = new google.maps.Marker({\r\n            position: latlng,\r\n            map: map,\r\n            clickable: false\r\n        });\r\n        infowindow.setContent('<div><strong>Your Location</strong></div>' + content);\r\n        infowindow.setPosition(latlng);\r\n        infowindow.open(map);\r\n        google.maps.event.trigger(map, 'resize');\r\n        map.setCenter(latlng);\r\n        saveLatLng(latlng);\r\n        map.setZoom(15);\r\n    }\r\n})(SuggestAListingPage || (SuggestAListingPage = {}));\r\n"]}