{"version":3,"file":"global.min.js","names":["$","initDirtyForm","applyMasks","setupSearch","setupRecentListings","initCancelButtonConfirmMessage","initDeleteButtonConfirmMessage","initConcurrencyHub","initFeedbackForm","submit","this","valid","prop","deleteRecordType","click","e","isDirty","isFormDirty","cancelUrl","attr","SmartMessageBox","title","content","buttons","buttonPressed","isDirtyOverridden","window","location","document","on","deleteUrl","preventDefault","post","extendDataTablesSettings","settings","extend","sDom","oLanguage","sLengthMenu","sSearch","sInfo","sInfoEmpty","sWrapper","validate","extendValidationSettings","rules","FeedbackName","required","FeedbackEmail","FeedbackBody","messages","errorContainer","errorLabelContainer","submitHandler","form","JSON","stringify","serializeObject","postJson","result","success","trigger","modal","alert","remove","ready","select2"],"sources":["global/global.js"],"sourcesContent":["// Leave this at the top of the file. There should only be one of these. If you need to add other document ready calls then wrap them in a function that is called here\n$(function () {\n initDirtyForm();\n\n applyMasks();\n\n setupSearch();\n\n setupRecentListings();\n\n initCancelButtonConfirmMessage();\n\n initDeleteButtonConfirmMessage();\n\n if (typeof initConcurrencyHub === \"function\") {\n initConcurrencyHub();\n }\n\n initFeedbackForm();\n\n //Prevents a double click on form submits\n $(\"form\").submit(function () {\n if ($(this).valid()) {\n $(\":submit\").prop(\"disabled\", true);\n }\n });\n});\n\n//#region Global variables\n\n// This controls the message that is displayed by the global delete handler\nvar deleteRecordType = \"\";\n\n//#endregion\n\n//#region Cancel Button Comfirm Message\n\nfunction initCancelButtonConfirmMessage() {\n $(\".cancelBtn\").click(function (e) {\n var isDirty = isFormDirty();\n var cancelUrl = $(this).attr(\"data-cancel-url\");\n\n if (isDirty) {\n $.SmartMessageBox(\n {\n title:\n ' Are you sure you want to cancel your changes?',\n content:\n \"You haven't saved your changes yet. Do you want to cancel without saving?\",\n buttons: \"[Yes][No]\",\n },\n function (buttonPressed) {\n if (buttonPressed == \"Yes\") {\n this.isDirtyOverridden = true;\n window.location = cancelUrl;\n }\n }\n );\n } else {\n window.location = cancelUrl;\n }\n });\n}\n\n//#endregion\n\n//#region Delete Buttons Confirm Message\n\nfunction initDeleteButtonConfirmMessage() {\n $(document).on(\"click\", \".deleteButton\", function (e) {\n var deleteUrl = $(this).attr(\"data-delete-url\");\n\n e.preventDefault();\n\n $.SmartMessageBox(\n {\n title: ' Confirm Delete',\n content:\n \"Are you sure you want to delete the \" + deleteRecordType + \"?\",\n buttons: \"[Yes, Delete][No]\",\n },\n function (buttonPressed) {\n if (buttonPressed == \"Yes, Delete\") {\n post(deleteUrl);\n }\n }\n );\n });\n}\n\n//#endregion\n\n//#region Data Tables\nfunction extendDataTablesSettings(settings) {\n var extended = $.extend(\n {},\n {\n //Smart Admin styles\n sDom:\n \"<'dt-toolbar'<'col-xs-12 col-sm-6'f><'col-xs-12 col-sm-6'l>r>\" +\n \"t\" +\n \"<'dt-toolbar-footer'<'col-xs-12 col-sm-6'i><'col-xs-12 col-sm-6'p>>\",\n oLanguage: {\n sLengthMenu: \"_MENU_\",\n sSearch: \"\",\n sInfo:\n \"Showing _START_ to _END_ of _TOTAL_ entries\",\n sInfoEmpty:\n \"Showing 0 to 0 of 0 entries\",\n sSearch:\n \" \",\n },\n sWrapper: \"dataTables_wrapper form-inline\",\n //End Smart Admin styling\n },\n settings\n );\n\n return extended;\n}\n\n//#endregion\n\n//#region FeedbackForm\n\nfunction initFeedbackForm() {\n $(\"#feedbackForm\").validate(\n extendValidationSettings({\n rules: {\n FeedbackName: {\n required: true,\n },\n FeedbackEmail: {\n required: true,\n },\n FeedbackBody: {\n required: true,\n },\n },\n messages: {\n FeedbackName: {\n required: \"Name is required.\",\n },\n FeedbackEmail: {\n required: \"Email is required.\",\n },\n FeedbackBody: {\n required: \"Feedback is required.\",\n },\n },\n errorContainer: \"#feedbackErrorMessageBox\",\n errorLabelContainer: \"#feedbackErrorList\",\n submitHandler: function () {\n var form = JSON.stringify($(\"#feedbackForm\").serializeObject());\n\n $.postJson(\"/api/ReportIssue\", form, function (result) {\n if (result.success) {\n $(\"#feedbackForm\").trigger(\"reset\");\n $(\"#feedbackModal\").modal(\"hide\");\n } else {\n alert(\"Feedback wasn't successfull\");\n }\n });\n },\n })\n );\n}\n\n//#endregion\n\n//#region Recent Listings\n\nfunction setupRecentListings() {\n $(\"#ClearRecentListings\").click(function () {\n $.postJson(\n \"/api/DeleteUserAccountRecentListings\",\n null,\n function (success) {\n if (success) {\n $(\"#recentListings > .recentListing\").remove();\n }\n }\n );\n });\n}\n\n//#endregion\n\n$(document).ready(function () {\n $(\".select2\").select2();\n});\n"],"mappings":"AACAA,GAAE,WACAC,gBAEAC,aAEAC,cAEAC,sBAEAC,iCAEAC,iCAEkC,mBAAvBC,oBACTA,qBAGFC,mBAGAR,EAAE,QAAQS,QAAO,WACXT,EAAEU,MAAMC,SACVX,EAAE,WAAWY,KAAK,YAAY,SAQpC,IAAIC,iBAAmB,GAMvB,SAASR,iCACPL,EAAE,cAAcc,OAAM,SAAUC,GAC9B,IAAIC,EAAUC,cACVC,EAAYlB,EAAEU,MAAMS,KAAK,mBAEzBH,EACFhB,EAAEoB,gBACA,CACEC,MACE,6GACFC,QACE,4EACFC,QAAS,cAEX,SAAUC,GACa,OAAjBA,IACFd,KAAKe,mBAAoB,EACzBC,OAAOC,SAAWT,MAKxBQ,OAAOC,SAAWT,KASxB,SAASZ,iCACPN,EAAE4B,UAAUC,GAAG,QAAS,iBAAiB,SAAUd,GACjD,IAAIe,EAAY9B,EAAEU,MAAMS,KAAK,mBAE7BJ,EAAEgB,iBAEF/B,EAAEoB,gBACA,CACEC,MAAO,8DACPC,QACE,uCAAyCT,iBAAmB,IAC9DU,QAAS,sBAEX,SAAUC,GACa,eAAjBA,GACFQ,KAAKF,SAUf,SAASG,yBAAyBC,GAyBhC,OAxBelC,EAAEmC,OACf,GACA,CAEEC,KACE,oIAGFC,UAAW,CACTC,YAAa,SACbC,QAAS,GACTC,MACE,4JACFC,WACE,+DACFF,QACE,wEAEJG,SAAU,kCAGZR,GAUJ,SAAS1B,mBACPR,EAAE,iBAAiB2C,SACjBC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