quoteCalculator.service("uiService",function(moduleService,instantiateService,ajaxService,apiService){var uiService=this;this.instantiateUiServicesInController=function($scope,$compile){$scope.loading=!0,$scope.ProductSearchTerm="",$scope.CsvFileLineCount="",$scope.StartLoading=function(){$scope.loading=!0,$scope.$digest()},$scope.StopLoading=function(){$scope.loading=!1,$scope.$digest(),setTimeout(setFixedBannerPositions,50)},$scope.ToggleAccordion=function(key){uiService.toggleAccordion(key)},$scope.toggleChildAccordion=function(event){uiService.toggleChildAccordion(event)},$scope.bodyClicked=function(event){uiService.bodyClicked(event),$scope.closeAllPantoneAutofillSuggestions()},$scope.CountOptions=function(fieldName){return uiService.CountOptions(fieldName,$scope)},$scope.CountChildProducts=function(){return uiService.countChildProducts(productCategories)},$scope.ProductSearchInit=function(){uiService.ProductSearchInit($scope,ajaxService)},$scope.InputButtonPressed=function(event,successFunction){13==event.keyCode&&successFunction()},$scope.AllAccordions=function(className,hide){uiService.allAccordions(className,hide)},$scope.CloseAllDropdowns=function(){uiService.closeAllDropdowns()},$scope.ToggleDropdown=function(event){uiService.toggleDropdown(event.target,$scope)},$scope.RefreshProductSelection=function(){$scope.ShowAccordion=!0,$scope.ProductSearchTerm="",$scope.toggleProductSelectorCheckbox(),$scope.toggleProductSelectorCheckbox()},$scope.RefreshInterfaceModules=function(){instantiateService.refreshInterfaceModules($scope,$compile)},$scope.NumFormat=function(number){return uiService.formatNumber(number)},$scope.ReturnDay=function(date){return uiService.returnDay(date)},$scope.ReturnTime=function(date){return uiService.returnTime(date)},$scope.ReturnShortDate=function(date){return uiService.returnShortDate(date)},$scope.LoadingIfEmpty=function(string){return uiService.loadingIfEmpty(string)},$scope.DotsIfEmpty=function(string){return uiService.dotsIfEmpty(string)},$scope.ReturnCompDate=function(date){return uiService.returnCompDate(date)},$scope.OpenQuotationAccordion=function(event){uiService.openQuotationAccordion(event)},$scope.FormatPrice=function(price){return uiService.formatPrice(price)},$scope.FillAdvancedTabStrip=function(){uiService.FillAdvancedTabStrip($scope,$compile)},$scope.tabStripClicked=function(event,specificationId,title){uiService.tabStripClicked(event,specificationId,title,$scope,$compile)},$scope.TempAdvButtonHandle=function(id,event){uiService.TempAdvButtonHandle(id,event,$scope)},$scope.TempButtonHandle=function(id,event){uiService.TempButtonHandle(id,event)},$scope.UnselectAdvButtonsByRef=function(ref){uiService.UnselectAdvButtonsByRef(ref)},$scope.CheckChoicesExist=function(idArea){return uiService.CheckChoicesExist(idArea,$scope)},$scope.AdvancedButtonToggleClicked=function(event){uiService.advancedButtonToggleClicked(event.originalEvent.target)},$scope.IncrementNumberInput=function(questionId,dataObject,dataAttribute,raise,min,max,step){uiService.IncrementNumberInput(questionId,dataObject,dataAttribute,raise,min,max,step,$scope)},$scope.NumberInputChanged=function(questionId,dataObject,dataAttribute,min,max){uiService.NumberInputChanged(questionId,dataObject,dataAttribute,min,max,$scope)},$scope.FileUploaded=function(fileUploadEle,fileSavePath,saveAs,allowedFileTypesArray,purposeData){uiService.FileUploaded($scope,fileUploadEle,fileSavePath,saveAs,allowedFileTypesArray,purposeData)},$scope.LineCountHandle=function(reader){uiService.LineCountHandle(reader,$scope)},$scope.LineCount=function(reader){return uiService.LineCount(reader,$scope)},document.body.addEventListener("click",$scope.bodyClicked),$scope.ToggleOpen=function(index){$scope.IndexedSpecificationInterfaces[index].displayCollapsed?$scope.IndexedSpecificationInterfaces[index].displayCollapsed=!1:$scope.IndexedSpecificationInterfaces[index].displayCollapsed=!0,$scope.$$phase||$scope.$digest()},$scope.AdditionalOptionChecked=!1,$scope.CheckboxClicked=function(){$scope.ApiQuote.productStyleOptionalExtra=!$scope.ApiQuote.productStyleOptionalExtra,$scope.SendQuoteUpdate($scope.ApiQuote.id,"ProductStyleOptionalExtra",null,$scope.ApiQuote.productStyleOptionalExtra,"")},$scope.TotalQuantity=function(){var quant=uiService.totalQuantity($scope.Quantity,$scope);if(quant)return quant;setTimeout(function(){$scope.$$phase||$scope.$digest()},1e3)},$scope.versionCount=function(){let count=0;for(let i=0;i<$scope.Quantity.length;i++)count+=$scope.Quantity[i].versionTypeCount;return 0==count?1:count},$scope.SelectTestFunction=function(){ajaxService.getRequest("Test/FunctionList",{},function(response,httpCode,optionalData){$scope.ShowCustomPopup("testFunction"),$scope.functionList=response,$scope.$digest()})},$scope.functionList=[],$scope.ActiveFunction=!1,$scope.ShowFunction=function(){var targetUrl="Test/"+$scope.ActiveFunction+"/"+$scope.ApiQuote.id;ajaxService.getRequest(targetUrl,{},function(response,httpCode,optionalData){$scope.ShowCustomPopup("showFunction"),document.getElementById("showFunctionPopup").innerHTML=response.value,$scope.$digest()})},$scope.selectTestFunction=function(string){$scope.ActiveFunction=string,$scope.ClosePopup()},$scope.returnFunctionDisplay=function(){for(let i=0;i<$scope.functionList.length;i++)if($scope.functionList[i].functionValue==$scope.ActiveFunction)return $scope.functionList[i].displayName},$scope.SetSizeTabInterface=function(id){$scope.SizeInterfaceTabOpen=id,$scope.RefreshInterface(id,$scope.ApiQuote.id)},$scope.DefaultSizeTabDataArray=[{id:5,openIf:5,label:"Size",description:"Select a size for your standard print size product"},{id:6,openIf:5,label:"Size",description:"Select a size for your standard print size product"},{id:14,openIf:14,label:"Style",description:"Select a pre-made style and custom dimensions for your product"},{id:24,openIf:24,label:"Die-cut",description:"Select a custom die-cut and size for your product"},{id:81,openIf:81,label:"Shape",description:"Select a pre-made die-cut for your product"}],$scope.SizeTabDataArray=[],$scope.OrderTabs=function(array){var newArray;Array.isArray(array)&&(newArray=[],array.forEach(function(inter){$scope.DefaultSizeTabDataArray.forEach(function(tab){inter.specificationInterfaceId==tab.id&&newArray.push(tab)})}),$scope.SizeTabDataArray=newArray)},$scope.returnSizeTabTitle=function(){const tabs=$scope.SizeTabDataArray;let returnString="Please select your ";for(let i=0;i<tabs.length;i++)$scope.IndexedSpecificationInterfaces[tabs[i].id].displayed&&(i==tabs.length-1?returnString+=" or ":0!==i&&(returnString+=", "),returnString+=tabs[i].label.toLowerCase());return returnString+=" options",returnString},$scope.confirmDeleteCallbackFunction=!1,$scope.confirmDeleteCallbackFunctionParameter1=!1,$scope.confirmDeleteCallbackFunctionParameter2=!1,$scope.confirmDeleteCallbackFunctionParameter3=!1,$scope.confirmDelete=function(title,question,confirmCallback,callbackParametersArray){callbackParametersArray?(3==callbackParametersArray.length&&confirmCallback(callbackParametersArray[0],callbackParametersArray[1],callbackParametersArray[2]),2==callbackParametersArray.length&&confirmCallback(callbackParametersArray[0],callbackParametersArray[1]),1==callbackParametersArray.length&&confirmCallback(callbackParametersArray[0])):confirmCallback()},$scope.stylePrice=function(number){if(null==number)return"£0.00";let rounded=Math.round(100*number)/100,string="£"+rounded.toString();return-1==string.indexOf(".")&&(string+=".00"),string.indexOf(".")==string.length-2&&(string+=0),string},$scope.stylePriceWithoutUnit=function(number){if(null==number)return"£0.00";if(number%1==0)return number.toString();let rounded=Math.round(100*number)/100,string=rounded.toString();return-1==string.indexOf(".")&&(string+=".00"),string.indexOf(".")==string.length-2&&(string+=0),string},$scope.stylePercent=function(number){if(!number)return"0%";let rounded=Math.round(100*number)/100;return rounded.toString()+"%"},$scope.reloadQuote=function(quoteId){$scope.inFileMaker?window.top.location=window.top.location.pathname+"?printPriceQuoteId="+quoteId+"&mode=filemaker":window.top.location=window.top.location.pathname+"?printPriceQuoteId="+quoteId},$scope.products=[],$scope.showAccordion=!0,$scope.setNavigationSlider=function(response){response&&response.length&&(console.log(response),$scope.products=response,$scope.$$phase||$scope.$digest())},$scope.searchInitCheck=function(event){13==event.keyCode&&$scope.searchProducts($scope.productSearchTerm)},$scope.searchProducts=function(searchString){ajaxService.getRequest("product/search/"+searchString,null,function(response){$scope.processProductSearchResponse(response)})},$scope.processProductSearchResponse=function(response){$scope.productSearchResults=response,$scope.showAccordion=!1,$scope.$$phase||$scope.$digest()},$scope.countChildProducts=function(){if(0==$scope.products.length)return"...";{let count=0;return $scope.products.forEach(function(parent){count+=parent.productTypes.length}),count}},$scope.showAllAccordions=function(){var accordions=document.getElementsByClassName("accordion-options-wrapper");for(let i=0;i<accordions.length;i++)jQuery(accordions[i]).slideDown(200);let indicators=document.getElementsByClassName("accordion-indicator");for(let i=0;i<indicators.length;i++)indicators[i].innerHTML="-"},$scope.hideAllAccordions=function(){var accordions=document.getElementsByClassName("accordion-options-wrapper");for(let i=0;i<accordions.length;i++)jQuery(accordions[i]).slideUp(200);let indicators=document.getElementsByClassName("accordion-indicator");for(let i=0;i<indicators.length;i++)indicators[i].innerHTML="+"},$scope.toggleAccordion=function(index){let ele=document.getElementById("a-i-"+index);"-"==ele.innerHTML?(ele.innerHTML="+",jQuery("#accordion-option-"+index).slideToggle(200)):($scope.hideAllAccordions(),jQuery("#accordion-option-"+index).slideToggle(200),ele.innerHTML="-")},$scope.toggleChildAccordion=function(event){event.stopPropagation();let ele=event.target,parent=ele.parentElement;event=parent.querySelector(".child-accordion-options");"-"==ele.innerHTML?(ele.innerHTML="+",jQuery(event).slideToggle(200)):(jQuery(event).slideToggle(200),ele.innerHTML="-")},$scope.refreshProductSelection=function(){$scope.productSearchResults=[],$scope.showAccordion=!0},$scope.displayCollapsedCheck=function(intId){if(!$scope.IndexedSpecificationInterfaces)return!1;let displayCollapsed=$scope.IndexedSpecificationInterfaces[intId].displayCollapsed;$scope.IndexedSpecificationInterfaces[intId].moreChoice&&(displayCollapsed=!1);return-1<[5,6,14,24,81].indexOf(intId)&&$scope.SizeAggregation&&(displayCollapsed=!1),displayCollapsed},$scope.displayCollapsedArrowCheck=function(intId){if(!$scope.IndexedSpecificationInterfaces)return!1;let displayCollapsed=!0;return $scope.IndexedSpecificationInterfaces[intId].moreChoice&&(displayCollapsed=!1),displayCollapsed},$scope.capitaliseFirst=function(string){return(string=string.toString()).substring(0,1).toUpperCase()+string.substring(1)},$scope.returnImage=function(option){return option&&option.ChoiceImageFile||null},$scope.setChangedTabs=function(){let tabs=jQuery("#tab-strip-selector").find(".tab-strip-tab").toArray();tabs.forEach(function(tab){if("linear-gradient(rgb(150, 150, 150), rgb(128, 128, 128))"!==jQuery(tab).css("background-image")){var interfaceData=$scope.SpecificationInterfaces.find(function(f){return f.interface===tab.innerHTML});switch(changed=!1,interfaceData.specificationInterfaceId){case 13:$scope.IndexedChoiceData["13-Printing Press"]&&$scope.IndexedChoiceData["13-Printing Press"].selected&&$scope.IndexedChoiceData["13-Printing Press"].selected.ChoiceValueId&&99!=$scope.IndexedChoiceData["13-Printing Press"].selected.ChoiceValueId&&$scope.IndexedChoiceData["13-Printing Press"].selected.ChoiceValueId&&(changed=!0);break;case 22:$scope.IndexedChoiceData["22-Single Double Sided - Print Sides"]&&("1"===$scope.IndexedChoiceData["22-Single Double Sided - Print Sides"].valueDisplay&&1===$scope.IndexedChoiceData["22-Print Colour Front"].selected.ChoiceValueId||(changed=!0));break;case 24:var o=$scope.returnDieCutObject();o&&(o.finishingId||o.largestHeightMm||o.largestWidthMm)&&(changed=!0);break;case 25:$scope.fData&&$scope.fData.scratchLatex&&(changed=!0);break;case 26:$scope.fData&&($scope.fData.lamination||$scope.fData.laminationBack)&&(changed=!0);break;case 27:$scope.fData&&($scope.fData.spotUv||$scope.fData.spotUvBack)&&(changed=!0);break;case 28:$scope.fData&&$scope.fData.perf&&(changed=!0);break;case 29:$scope.fData&&($scope.fData.variableDataNumbering||$scope.fData.variableDataQrCode||$scope.fData.variableDataBarcode||$scope.fData.variableDataMergedData||$scope.fData.variableDataColour)&&(changed=!0);break;case 30:$scope.fData&&$scope.fData.drillHoles&&(changed=!0);break;case 34:$scope.IndexedChoiceData["34-Packaging Category"]&&0<$scope.IndexedChoiceData["34-Packaging Category"].selected.ChoiceValueId&&(changed=!0);break;case 40:$scope.fData&&($scope.fData.embossOne||$scope.fData.embossTwo)&&(changed=!0);break;case 41:$scope.fData&&($scope.fData.foilOne||$scope.fData.foilTwo)&&(changed=!0);break;case 45:$scope.fData&&$scope.fData.corners&&(changed=!0);break;case 46:$scope.fData&&!1!==$scope.fData.assembly&&0<$scope.fData.assembly.length&&(changed=!0);break;case 48:$scope.ApiQuote.priceAdjustment&&0!==$scope.ApiQuote.priceAdjustment&&"0"!==$scope.ApiQuote.priceAdjustment&&(changed=!0);break;case 50:$scope.IndexedChoiceData["50-No Fail"]&&"True"==$scope.IndexedChoiceData["50-No Fail"].valueDisplay&&(changed=!0);break;case 51:$scope.IndexedChoiceData["51-Delivery Adjustment plus and minus"]&&$scope.IndexedChoiceData["51-Delivery Adjustment plus and minus"].specificationData.DeliveryAdjustmentDays&&(changed=!0);break;case 65:$scope.fData&&($scope.fData.debossOne||$scope.fData.debossTwo)&&(changed=!0);break;case 77:$scope.envelope&&(changed=!0);break;case 82:$scope.fData&&$scope.fData.score&&$scope.fData.score.quantity&&(changed=!0)}changed&&jQuery(tab).css("background-image","linear-gradient(darkgreen, green)")}})},$scope.setMenuTriggers=function(){(-1<window.location.host.indexOf("printprice.co.uk")||-1<window.location.host.indexOf("localhost"))&&jQuery(document).ready(function(){for(var menuSlideReady=!0,dropdowns=document.getElementsByClassName("header-item-wrapper"),menuSlideReady=[],i=0;i<dropdowns.length;i++)menuSlideReady.push(!0);jQuery(".header-item-wrapper").hover(function(e){for(var index,i=-0;i<dropdowns.length;i++)dropdowns[i]==this&&(index=i);(menuSlideReady[index]||e.originalEvent.target.classList.contains("header-item"))&&(menuSlideReady[index]=!1,jQuery(this).find(".header-dropdown").slideDown(120),jQuery(this).find(".header-dropdown-icon").attr("src","https://printprice.co.uk/media/icons/dropdown-arrow.png"),jQuery(this).find(".header-item").css("background-color","white").css("color","#1B273D"))},function(){for(var index,i=-0;i<dropdowns.length;i++)dropdowns[i]==this&&(index=i);jQuery(this).find(".header-item").css("background-color","transparent").css("color","white"),jQuery(this).find(".header-dropdown-icon").attr("src","https://printprice.co.uk/media/icons/product-arrow.png"),jQuery(this).find(".header-dropdown").slideUp(120,function(){menuSlideReady[index]=!0})})})},$scope.setStyleDynamicStyling=function(){var parents=document.getElementsByClassName("js-parent-height-equaliser");for(let i=0;i<parents.length;i++)$scope.setIndividualStyleInterfaceStyling(parents[i],"js-child-height-equaliser")},$scope.setIndividualStyleInterfaceStyling=function(parent,childJsClass){parent&&(parent=parent.querySelectorAll("."+childJsClass),childJsClass=$scope.getLargestHeightForDynamicStylingEqualiser(parent),$scope.setLargestHeightForDynamicStylingEqualiser(parent,childJsClass))},$scope.getLargestHeightForDynamicStylingEqualiser=function(children){let largestHeight=0;for(let i=0;i<children.length;i++){var height=children[i].offsetHeight;height>largestHeight&&(largestHeight=height)}return largestHeight},$scope.setLargestHeightForDynamicStylingEqualiser=function(children,largestHeight){for(let i=0;i<children.length;i++){let child=children[i];child.style.height=largestHeight+"px"}},$scope.queryShowStraightEdgeTemplateDownload=function(){return $scope.ProductDefault.hasStraightEdges},$scope.downloadStraightEdgeTemplate=function(){ajaxService.getRequest("svg-template/quote/"+$scope.ApiQuote.id,null,function(svg,httpCode,optionalData){var name=$scope.getProductTypeNameSlug(),svg=(document.getElementById("svg-form-input").value=svg,document.getElementById("svg-form-title").value=name,$scope.getWidthMm()),height=$scope.getHeightMm();document.getElementById("svg-form-filename").value=name+"-W"+svg+"-H"+height,document.getElementById("svg-form").submit()})},$scope.getProductTypeNameSlug=function(){return $scope.ProductDefault.displayName.toLowerCase().replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-").replace(" ","-")+"-template"}},this.toggleDropdown=function(_element,$scope){_element=jQuery(_element).parent();_element.find(".dropdown-arrow").hasClass("dropdown-arrow-dropped")?this.closeDropdown(_element):(this.closeAllDropdowns(),this.openDropdown(_element))},this.closeDropdown=function(dropdownWrapperElement){dropdownWrapperElement.find(".dropdown-arrow").removeClass("dropdown-arrow-dropped"),dropdownWrapperElement.find(".dropdown").slideUp(200),dropdownWrapperElement.find(".dropdown-text").removeClass("js-dropdown-no-shadow")},this.openDropdown=function(dropdownWrapperElement){dropdownWrapperElement.find(".dropdown-arrow").addClass("dropdown-arrow-dropped"),dropdownWrapperElement.find(".dropdown").slideDown(200),dropdownWrapperElement.find(".dropdown-text").addClass("js-dropdown-no-shadow")},this.closeAllDropdowns=function(){for(var dropdowns=document.getElementsByClassName("dropdown-wrapper"),i=0;i<dropdowns.length;i++)this.closeDropdown(jQuery(dropdowns[i]))},this.bodyClicked=function(event){event&&(event.target.classList.contains("dropdown-option-data")||event.target.classList.contains("dropdown-text")||this.closeAllDropdowns())},this.toggleAccordion=function(number){var indicator=document.getElementById("a-i-"+number);if("+"==indicator.innerHTML){if(accordionClosing)for(var accordionIndicators=document.getElementsByClassName("accordion-indicator"),accordionDropdowns=document.getElementsByClassName("accordion-options-wrapper"),i=0;i<accordionIndicators.length;i++)accordionIndicators[i].innerHTML="+",jQuery(accordionDropdowns[i]).slideUp(200);indicator.innerHTML="-"}else indicator.innerHTML="+";jQuery("#accordion-option-"+number).slideToggle(200)},this.increaseQuantity=function(currentValue,raiseValue,minValue,maxValue){var returnValue,currentValue=parseInt(currentValue);return isNaN(currentValue)||(returnValue=maxValue<(returnValue=raiseValue?currentValue<minValue?minValue:currentValue<10?currentValue+1:currentValue<30?currentValue+5:currentValue<100?currentValue+10:currentValue<300?currentValue+50:currentValue<1e3?currentValue+100:currentValue<3e3?currentValue+250:currentValue+1e3:currentValue<=minValue?minValue:currentValue<=10?currentValue-1:currentValue<=30?currentValue-5:currentValue<=100?currentValue-10:currentValue<=300?currentValue-50:currentValue<=1e3?currentValue-100:currentValue<=3e3?currentValue-250:currentValue-1e3)?maxValue:returnValue)<minValue?minValue:returnValue},this.increaseQuantityNoValidation=function(currentValue,raiseValue){var returnValue,currentValue=parseInt(currentValue);return isNaN(currentValue)||(returnValue=raiseValue?currentValue<10?currentValue+1:currentValue<30?currentValue+5:currentValue<100?currentValue+10:currentValue<300?currentValue+50:currentValue<1e3?currentValue+100:currentValue<3e3?currentValue+250:currentValue+1e3:currentValue<=10?currentValue-1:currentValue<=30?currentValue-5:currentValue<=100?currentValue-10:currentValue<=300?currentValue-50:currentValue<=1e3?currentValue-100:currentValue<=3e3?currentValue-250:currentValue-1e3)<1?1:returnValue},this.increaseQuantitySetAmount=function(currentValue,raiseValue,minValue,maxValue,step){return raiseValue?currentValue+=step:currentValue-=step,maxValue<currentValue?maxValue:currentValue<minValue?minValue:currentValue},this.handleButtonClick=function(event,id){if(!event.target.classList.contains("button1-selected")){for(var clearButtons=document.getElementsByClassName("button-"+id),i=0;i<clearButtons.length;i++)clearButtons[i].classList.remove("button1-selected"),jQuery(clearButtons[i]).find(".button1-checkbox").removeClass("button1-checkbox-selected");event.target.classList.add("button1-selected"),jQuery(event.target).find(".button1-checkbox").addClass("button1-checkbox-selected")}},this.formatPrice=function(price){return(price=Math.round(100*price)/100).toLocaleString("en-UK",{style:"currency",currency:"GBP"})},this.tempButtonHandle=function(event,classExtension){for(var buttons=document.getElementsByClassName("button-"+classExtension),i=0;i<buttons.length;i++)buttons[i].classList.remove("button1-selected");event.currentTarget.classList.add("button1-selected")},this.matGroupCustomSelect=function(){for(var buttons=document.getElementsByClassName("button-matGroup"),i=0;i<buttons.length;i++)buttons[i].classList.remove("button1-selected");buttons[4].classList.add("button1-selected")},this.formatNumber=function(int){try{return int.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")}catch(e){return int}},this.formatDate=function(dateString){dateString=new Date(dateString);return["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"][dateString.getDay()]+" "+uiService.returnDateWithSuffix(dateString.getDate())+" "+["January","February","March","April","May","June","July","August","September","October","November","December"][dateString.getMonth()]+" "+dateString.getFullYear()},this.returnDay=function(dateString){return["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"][new Date(dateString).getDay()]},this.returnTime=function(dateString){dateString=new Date(dateString);return dateString.getHours()+":"+dateString.getMinutes()},this.returnCompDate=function(dateString){var dateString=new Date(dateString),numberDay=uiService.stringifyDateNumber(dateString.getDate()),month=uiService.stringifyDateNumber(dateString.getMonth()+1);return dateString.getFullYear()+"-"+month+"-"+numberDay},this.returnShortDate=function(dateString){var dateString=new Date(dateString),numberDay=uiService.stringifyDateNumber(dateString.getDate()),month=uiService.stringifyDateNumber(dateString.getMonth()+1),dateString=dateString.getFullYear();return isNaN(numberDay)||isNaN(month)||isNaN(dateString)?"Loading...":numberDay+"/"+month+"/"+dateString},this.loadingIfEmpty=function(string){return string||"Loading..."},this.dotsIfEmpty=function(string){return string||"..."},this.stringifyDateNumber=function(number){number=number.toString();return number=1==number.length?"0"+number:number},this.returnDateWithSuffix=function(n){return n+(0<n?["th","st","nd","rd"][3<n&&n<21||3<n%10?0:n%10]:"")},this.allAccordions=function(className,displayProperty){for(var eles=document.getElementsByClassName(className),i=0;i<eles.length;i++)"hide"==displayProperty?jQuery(eles[i]).slideUp():jQuery(eles[i]).slideDown();for(var indicators=document.getElementsByClassName("accordion-indicator"),i=0;i<indicators.length;i++)indicators[i].innerHTML="hide"==displayProperty?"+":"-"},this.advancedButtonToggleClicked=function(ele){"matrix(-1, 1.22465e-16, -1.22465e-16, -1, 0, 0)"==jQuery(ele).find("img").css("transform")?(jQuery(ele).parent().find(".advanced-options-wrapper-hidden").slideUp(),jQuery(ele).find("img").css("transform","rotate(0deg)")):(jQuery(ele).parent().find(".advanced-options-wrapper-hidden").slideDown(),jQuery(ele).find("img").css("transform","rotate(180deg)"))},this.selectProductTypeRedirect=function(id,userType){window.location.href="internal"==userType?"quote.php?productTypeId="+id:"quote.php?forceUser="+userType+"&productTypeId="+id},this.countChildProducts=function(array){for(var count=0,i=0;i<array.length;i++)"number"==typeof array[i].ParentId&&count++;return count},this.unselectAdvButtonsByRef=function(ref){for(var buttons=document.getElementsByClassName(ref),i=0;i<buttons.length;i++)buttons[i].classList.remove("button1-selected"),jQuery(buttons[i]).find(".button1-checkbox")[0].classList.remove("button1-checkbox-selected"),0<jQuery(buttons[i]).find(".button-price").length&&jQuery(buttons[i]).find(".button-price")[0].classList.add("button-price-shown")},this.unselectButtonsByRef=function(ref){for(var buttons=document.getElementsByClassName(ref),i=0;i<buttons.length;i++)buttons[i].classList.remove("button1-selected")},this.openQuotationAccordion=function(event){var openOrClose=jQuery(event.originalEvent.target).parent().find(".quotation-manager-indicator")[0],accordionElement=jQuery(event.originalEvent.target).parent().find(".quotation-manager-hidden-wrapper")[0],event=jQuery(event.originalEvent.target).parent().find(".quotation-manager-quote-text")[0];if("+"==openOrClose.innerHTML){if(accordionClosing)for(var dropdowns2=document.getElementsByClassName("quotation-manager-hidden-wrapper"),titles2=document.getElementsByClassName("quotation-manager-quote-text"),indicators2=document.getElementsByClassName("quotation-manager-indicator"),i=0;i<dropdowns2.length;i++)jQuery(dropdowns2[i]).slideUp(200),titles2[i].classList.remove("quotation-manager-selected"),indicators2[i].innerHTML="+";jQuery(accordionElement).slideDown(200),openOrClose.innerHTML="-",event.classList.add("quotation-manager-selected")}else jQuery(accordionElement).slideUp(200),openOrClose.innerHTML="+",event.classList.remove("quotation-manager-selected")},this.totalQuantity=function(quantityArray,$scope){if($scope&&$scope.quoteDataSigns){let signIdToUse=null;if("undefined"!=typeof signId?signIdToUse=signId:-1<window.location.search.toLowerCase().indexOf("signid=")&&(signIdToUse=Number($scope.getUrlParameter("signId"))),signIdToUse){let totalQuantity=0;return $scope.quoteDataSigns.forEach(sign=>{totalQuantity+=sign.quantity}),totalQuantity}}if(void 0===quantityArray)return"Please wait...";for(var count=0,i=0;i<quantityArray.length;i++)"number"==typeof parseInt(quantityArray[i].versionQuantity)&&(count+=parseInt(quantityArray[i].versionQuantity*quantityArray[i].versionTypeCount));return isNaN(count)?null:count},this.CountOptions=function(fieldName,$scope){if(void 0!==$scope.IndexedChoiceData)return void 0!==$scope.IndexedChoiceData[fieldName]?void 0===$scope.IndexedChoiceData[fieldName].displayed||0<$scope.IndexedChoiceData[fieldName].length?$scope.IndexedChoiceData[fieldName].length:1:0},this.ProductSearchInit=function($scope,ajaxService){var targetUrl="product/search/"+document.getElementById("search-input").value;optionalData={url:targetUrl,productId:productId,quoteId:id,userType:$scope.userType},ajaxService.getRequest(targetUrl,optionalData,function(response,httpCode,optionalData){$scope.ProductSearchResults=response,$scope.$digest()}),$scope.ShowAccordion=!1},this.FillAdvancedTabStrip=function($scope,$compile){var wrapperEle=document.getElementById("tab-strip-selector");wrapperEle.innerHTML="";let advancedInterfacesFound=!1;for(var i=0;i<$scope.SpecificationInterfaces.length;i++)if($scope.SpecificationInterfaces[i].displayed&&$scope.SpecificationInterfaces[i].moreChoice){advancedInterfacesFound=!0;for(var specId=$scope.SpecificationInterfaces[i].specificationInterfaceId,name="No data sent in ApiQuoteData for interface ID "+$scope.SpecificationInterfaces[i].specificationInterfaceId,j=0;j<$scope.ApiQuoteData.length;j++)found=!1,$scope.ApiQuoteData[j].specificationInterfaceId==$scope.SpecificationInterfaces[i].specificationInterfaceId&&(name=$scope.ApiQuoteData[j].specificationInterface);if(name=="No data sent in ApiQuoteData for interface ID "+$scope.SpecificationInterfaces[i].specificationInterfaceId)try{name="No data sent in ApiQuoteData for interface "+moduleService.moduleLookup(specId)+", ID: "+$scope.SpecificationInterfaces[i].specificationInterfaceId}catch(e){}specId='<p class="tab-strip-tab" ng-class="(CheckTabChanged('+specId+"))? 'tab-strip-tab-selected':'' \" ng-click=\"tabStripClicked($event, "+specId+", '"+(name=$scope.SpecificationInterfaces[i].interface?$scope.SpecificationInterfaces[i].interface:name)+"')\">"+name+"</p>";angular.element(wrapperEle).append($compile(specId)($scope))}advancedInterfacesFound?uiService.showAdvancedInterface():uiService.hideAdvancedInterface()},this.hideAdvancedInterface=function(){let eles=document.getElementsByClassName("advanced-title-wrapper");for(let i=0;i<eles.length;i++)eles[i].style.display="none"},this.showAdvancedInterface=function(){let eles=document.getElementsByClassName("advanced-title-wrapper");for(let i=0;i<eles.length;i++)eles[i].style.display="block"},this.tabStripClicked=function(event,specificationId,title,$scope,$compile){var htmlToInsert,advWrapperEle,event=event.target;$scope.openAdvancedInterfaceId!==specificationId?((advWrapperEle=document.getElementById("advancedOptionsBuilder")).innerHTML="",jQuery(".tab-strip-tab").css("background-colour","#1B273D"),jQuery(".tab-strip-tab").css("background-image","none"),jQuery(event).css("background-image","linear-gradient(rgb(150, 150, 150), grey"),htmlToInsert='<div id="advanced-'+("template-"+($scope.openAdvancedInterfaceId=specificationId))+'"><div class="question-separator"></div>'+$scope.interfaceHTML.find(function(f){return f.interfaceId==specificationId}).content+"</div>",angular.element(advWrapperEle).prepend($compile(htmlToInsert)($scope))):(jQuery(event).css("background-image","none"),jQuery(event).css("background-colour","#1B273D"),$scope.openAdvancedInterfaceId=null,(advWrapperEle=document.getElementById("advancedOptionsBuilder")).innerHTML=""),this.setChangedTabs($scope)},this.setChangedTabs=function($scope){$scope.setChangedTabs()},this.TempAdvButtonHandle=function(id,event,$scope){event=event.originalEvent.target;uiService.unselectAdvButtonsByRef("button-"+id),event.classList.add("button1-selected"),jQuery(event).find(".button1-checkbox")[0].classList.add("button1-checkbox-selected"),0<jQuery(event).find(".button-price").length&&jQuery(event).find(".button-price")[0].classList.remove("button-price-shown")},this.TempButtonHandle=function(id,event){event=event.originalEvent.target;uiService.unselectButtonsByRef("button-"+id),event.classList.add("button1-selected")},this.UnselectAdvButtonsByRef=function(ref){for(var buttons=document.getElementsByClassName(ref),i=0;i<buttons.length;i++)buttons[i].classList.remove("button1-selected"),jQuery(buttons[i]).find(".button1-checkbox")[0].classList.remove("button1-checkbox-selected"),0<jQuery(buttons[i]).find(".button-price").length&&jQuery(buttons[i]).find(".button-price")[0].classList.add("button-price-shown")},this.CheckChoicesExist=function(idArea,$scope){try{return void 0!==$scope.IndexedChoiceData[idArea].selected.ChoiceDisplayName}catch(e){return!1}},this.IncrementNumberInput=function(questionId,dataObject,dataAttribute,raise,min,max,step,$scope){var newValue,oldValue;raise&&max||!raise&&min?(newValue=step?uiService.increaseQuantitySetAmount(dataObject[dataAttribute],raise,min,max,step):uiService.increaseQuantity(dataObject[dataAttribute],raise,min,max),oldValue=dataObject[dataAttribute],dataObject[dataAttribute]=newValue,$scope.Errors[questionId]?($scope.Errors[questionId].error=!1,$scope.Errors[questionId].errorDescription="",oldValue==newValue&&newValue==max&&($scope.Errors[questionId].error=!0,$scope.Errors[questionId].errorDescription="The maximum value for this input is "+max),oldValue==newValue&&newValue==min&&($scope.Errors[questionId].error=!0,$scope.Errors[questionId].errorDescription="The minimum value for this input is "+min),"HandFinishingRate"==questionId&&$scope.QueueFinishingsUpdate(),$scope.Errors[questionId].error||apiService.NumberInputChanged(questionId,dataObject,dataAttribute)):apiService.NumberInputChanged(questionId,dataObject,dataAttribute),"pagescount"==questionId.toLowerCase()?$scope.pagesCountChanged():"leavescount"==questionId.toLowerCase()&&$scope.leavesCountChanged()):(raise?(dataObject[dataAttribute]=dataObject[dataAttribute]+(step||1),step&&dataObject[dataAttribute]%step!=0&&(dataObject[dataAttribute]=dataObject[dataAttribute]+(step-dataObject[dataAttribute]%step))):(dataObject[dataAttribute]=dataObject[dataAttribute]-(step||1),step&&dataObject[dataAttribute]%step!=0&&(dataObject[dataAttribute]=dataObject[dataAttribute]-dataObject[dataAttribute]%step)),dataObject[dataAttribute]<0&&(dataObject[dataAttribute]=0),"pagescount"==questionId.toLowerCase()?$scope.pagesCountChanged():"leavescount"==questionId.toLowerCase()?$scope.leavesCountChanged():apiService.NumberInputChanged(questionId,dataObject,dataAttribute))},this.validateNumberInput=function($scope,newValue,min,max,questionId,dataObject,dataAttribute){max&&max<newValue&&($scope.Errors[questionId].error=!0,$scope.Errors[questionId].errorDescription="The maximum value for this input is "+max,dataObject[dataAttribute]=max),min&&newValue<min&&($scope.Errors[questionId].error=!0,$scope.Errors[questionId].errorDescription="The minimum value for this input is "+min,dataObject[dataAttribute]=min),"pagescount"==questionId.toLowerCase()?$scope.pagesCountChanged():"leavescount"==questionId.toLowerCase()?$scope.leavesCountChanged():apiService.NumberInputChanged(questionId,dataObject,dataAttribute),$scope.$digest()},this.numberValidationHandle=null,this.NumberInputChanged=function(questionId,dataObject,dataAttribute,min,max,$scope){var newValue;min||max?(newValue=dataObject[dataAttribute],$scope.Errors[questionId]||($scope.Errors[questionId]={}),$scope.Errors[questionId].error=!1,$scope.Errors[questionId].errorDescription="",clearTimeout(uiService.numberValidationHandle),uiService.numberValidationHandle=setTimeout(uiService.validateNumberInput,700,$scope,newValue,min,max,questionId,dataObject,dataAttribute),max&&max<newValue&&($scope.Errors[questionId].error=!0,$scope.Errors[questionId].errorDescription="The maximum value for this input is "+max),min&&newValue<min&&($scope.Errors[questionId].error=!0,$scope.Errors[questionId].errorDescription="The minimum value for this input is "+min),"HandFinishingRate"==questionId&&$scope.QueueFinishingsUpdate(),$scope.Errors[questionId].error||("pagescount"==questionId.toLowerCase()?$scope.pagesCountChanged():"leavescount"==questionId.toLowerCase()?$scope.leavesCountChanged():apiService.NumberInputChanged(questionId,dataObject,dataAttribute))):"pagescount"==questionId.toLowerCase()?$scope.pagesCountChanged():"leavescount"==questionId.toLowerCase()?$scope.leavesCountChanged():apiService.NumberInputChanged(questionId,dataObject,dataAttribute)},this.FileUploaded=function($scope,fileUploadEle,fileSavePath,saveAs,allowedFileTypesArray,purposeData){var fileArray=fileUploadEle.files;for(let i=0;i<fileArray.length;i++)$scope.saveFile(fileSavePath,fileArray[i],saveAs,allowedFileTypesArray,purposeData)},this.LineCountHandle=function(reader,$scope){reader=$scope.LineCount(reader);$scope.CsvFileLineCount="This file has "+reader+" rows.",$scope.$digest()},this.LineCount=function(reader,$scope){for(var rowArray=reader.result.split("\n"),i=0;i<rowArray.length;i++)""==rowArray[i]&&rowArray.splice(i,1);return rowArray.length-1}});