text: var webuycarsApp=angular.module(["webuycarsApp"],["angular-toArrayFilter","ngResource","ngMap","ui.bootstrap"]);$(document).ready(function(){$(".navbar-toggle").on("click",function(){$(this).toggleClass("active")}),$(document).click(function(e){var t=$(e.target);!0!==$(".navbar-collapse:visible").hasClass("in")||t.hasClass("navbar-toggle")||$(".navbar-toggle:visible").click()}),$("#selectedValuationNew").click(function(){$("#selectedValuation").hide(),$(".appointment-funnel").removeClass("hidden")}),$(".btn-career-apply").on("click",function(e){$("#careers-apply").slideDown(),$("html, body").animate({scrollTop:$("#careers-apply").offset().top},2e3)})}),angular.module("webuycarsApp").factory("Appointment",["$resource",function(e){return e("car-valuation-thank-you")}]),angular.module("webuycarsApp").factory("BranchTiming",["$resource",function(e){return e("branches/:branchSlug/timings/:appointmentDay",{},{query:{method:"GET",isArray:!0}})}]),angular.module("webuycarsApp").factory("VehicleModel",["$resource",function(e){return e("vehicles/make/:vehicleMakeId/models",{},{query:{method:"GET",params:{vehicleMakeId:"valuation.vehicleMake.id"},isArray:!0}})}]),angular.module("webuycarsApp").controller("ValuationStepFiveController",["$scope","$filter","$document","NgMap",function(e,t,n,a){var o=this;o.latitude=null,o.longitude=null,o.branchName=null,a.getMap().then(function(e){o.latitude&&o.longitude?(e.setZoom(10),e.setCenter({lat:o.latitude,lng:o.longitude}),new google.maps.Marker({position:{lat:o.latitude,lng:o.longitude},title:o.branchName}).setMap(e)):(e.setZoom(10),e.setCenter({lat:25.206497,lng:55.268743}))})}]),angular.module("webuycarsApp").controller("ValuationStepFourController",["$scope","$filter","$document","$window","$location","$anchorScroll","NgMap","BranchTiming","Appointment",function(e,t,n,a,o,i,l,r,c){var s=this,u=new Date;u.setDate(u.getDate()+30),s.mapHeight="400px",s.branches=[],s.selectedBranch=null,s.appointmentDate=null,s.branchTimings=[],s.selectedBranchTiming=null,s.emailAddress=null,s.markers=[],s.selectedBranchObject={},s.selectedPosition={},s.isTimingSlotsAvailable=!0,s.valuationId=null,s.options={minDate:new Date,maxDate:u,showWeeks:!1,startingDay:7,maxMode:"day"},e.$watch("ctrl.branches",function(){s.branchesChanged()}),e.$watch("ctrl.selectedBranch",function(){s.isTimingSlotsAvailable=!0,s.selectedBranchChanged(),s.fetchBranchTimings()}),e.$watch("ctrl.appointmentDate",function(){s.isTimingSlotsAvailable=!0,s.fetchBranchTimings()}),l.getMap().then(function(e){s.mapHeight=angular.element(n[0].getElementById("book-appointment-form")).height()+188+"px",e.addListener("center_changed",function(){window.setTimeout(function(){e.panTo(e.getCenter())},3e3)}),window.setTimeout(function(){var t=e.getCenter();google.maps.event.trigger(e,"resize"),e.setCenter(t)},500)}),s.addMarker=function(e){l.getMap().then(function(t){var n=new google.maps.LatLng(e.latitude,e.longitude),a=new google.maps.Marker({position:n,title:e.title});a.setMap(t),e.marker=a,s.markers.push(a)})},s.fetchBranchTimings=function(){if(s.selectedBranch&&s.appointmentDate instanceof Date){var e=new Date(s.appointmentDate-6e4*s.appointmentDate.getTimezoneOffset()).toISOString().split("T")[0],t=angular.element(n[0].getElementById("loading-container"));t.show(),s.branchTimings=r.query({branchSlug:s.selectedBranch,appointmentDay:e},function(e){t.hide(),s.isTimingSlotsAvailable=Boolean(e.length)})}},s.branchesChanged=function(){for(var e in s.branches){var t=s.branches[e];t.hasOwnProperty("latitude")&&t.latitude&&t.hasOwnProperty("longitude")&&t.longitude&&s.addMarker(t)}l.getMap().then(function(e){for(var t=new google.maps.LatLngBounds,n=0;n<s.markers.length;n++)t.extend(s.markers[n].getPosition());e.fitBounds(t)})},s.selectedBranchChanged=function(){s.selectedBranchObject=t("filter")(s.branches,{slug:s.selectedBranch})[0],l.getMap().then(function(e){s.selectedBranchObject&&s.selectedBranchObject.marker?(e.setZoom(18),e.setCenter(s.selectedBranchObject.marker.getPosition()),s.selectedPosition=s.selectedBranchObject.marker.getPosition()):(s.selectedPosition={lat:25.206497,lng:55.268743},e.setZoom(10),e.setCenter(s.selectedPosition))})},s.triggerFormSubmit=function(){if(e.valuationStepFourForm.$setSubmitted(),e.valuationStepFourForm.$valid&&"[object Date]"===Object.prototype.toString.call(s.appointmentDate)){var t=s.selectedBranchTiming.split(":"),o=new c,i=s.appointmentDate.getMonth()+1;o.bookedAt=s.appointmentDate.getFullYear()+"-"+i+"-"+s.appointmentDate.getDate()+" "+t[0]+":"+t[1]+":00",o.branch=s.selectedBranch,o.emailAddress=s.emailAddress;var l=angular.element(n[0].getElementById("loading-container"));l.show(),o.$save(null,function(e,t){l.hide(),window.setTimeout(function(){a.location.href=t("Location")},100)},function(e){l.hide(),alert("Error: Unable to create an Appointment")})}else s.scrollTo("pick-a-branch")},s.scrollTo=function(e){o.hash(e),i()}}]),angular.module("webuycarsApp").component("valuationStepOne",{templateUrl:"templates/valuation/valuationStepOne.html",controller:["$document","$window","VehicleModel",function(e,t,n){this.vehicleMakeId=null,this.vehicleModelId=null,this.vehicleYear=null,this.vehicleModels=[],this.changedVehicleMake=function(){var t=angular.element(e[0].getElementById("loading-container"));t.show(),this.vehicleModels=n.query({vehicleMakeId:this.vehicleMakeId},function(){t.hide()})},this.submit=function(e,t){e.$submitted=!0,e.$invalid&&t.preventDefault()}}],controllerAs:"ctrl",bindings:{vehicleMakes:"=",vehicleYears:"=",formButtonText:"@",formGroupClass:"@",formClass:"@",formGroupSubmitClass:"@",formActionUrl:"="}}),angular.module("webuycarsApp").controller("ValuationStepThreeController",["$scope","$document",function(e,t){e.name=null,e.mobileNumber=null,this.submitForm=function(e){e&&valuationStepThreeForm.submit()}}]),angular.module("webuycarsApp").controller("ValuationStepTwoController",["$scope",function(e){e.vehicleModelType=null,e.vehicleMileage=null,e.vehicleOption=null,e.vehicleBodyCondition=null,this.submitForm=function(e){e&&valuationStepTwoForm.submit()}}]),angular.module("webuycarsApp").controller("ContactUsController",["$scope",function(e){this.submitForm=function(e){e&&contactUsForm.submit()}}]),angular.module("webuycarsApp").component("appointmentsMade",{templateUrl:"templates/static/appointmentsMade.html",controller:["$scope",function(e){var t=this;t.appointmentsIndexUrl="",t.totalAppointments=0,t.initialAppointmentsMade=0,t.appointmentsMadeSoFar=0,e.$watch("ctrl.initialAppointmentsMade",function(){t.appointmentsMadeSoFar=t.initialAppointmentsMade+t.totalAppointments}),e.$watch("ctrl.totalAppointments",function(){t.appointmentsMadeSoFar=t.initialAppointmentsMade+t.totalAppointments})}],controllerAs:"ctrl",bindings:{appointmentsIndexUrl:"=",totalAppointments:"=",initialAppointmentsMade:"="}}),angular.module("webuycarsApp").controller("DetailsController",["$scope",function(e){this.submitForm=function(e){e&&candidateForm.submit()}}]);