;(function($){"use strict";ips.controller.register('core.admin.support.contact',{initialize:function(){this.on('change','#elCheckbox_support_request_extra_admin',this.acpAccountCheckboxChange);this.on(document,'refreshSupportSummary',this.embedSummary);this.embedSummary();},acpAccountCheckboxChange:function(e){if(!$('#elCheckbox_support_request_extra_admin').is(':checked')){ips.ui.alert.show({type:'confirm',message:ips.getString('supportAcpAccountHead'),subText:ips.getString('supportAcpAccountDisableBlurb'),icon:'warn',buttons:{ok:ips.getString('supportAcpAccountDisableYes'),cancel:ips.getString('supportAcpAccountDisableNo')},callbacks:{ok:function(){$('#elCheckbox_support_request_extra_admin').prop('checked',true);}}});}},embedSummary:function(){var summary=$(document).find('[data-controller="core.admin.support.dashboard"] [data-role="summary"]');if(summary.length){var html=$('<div>').append(summary.clone());html.find('.i-float_end').remove();html.find('[data-role="summary"]').addClass('i-margin-bottom_3');html.find('[data-role="summaryText"]').append(ips.templates.render('support.ticket.supportSummary'));html=html.html();this.scope.find('ul.ipsForm').prepend('<li>'+html+'</li>');}}});}(jQuery));;
;(function($){"use strict";ips.controller.register('core.admin.support.dashboard',{blocksToLoad:0,blocksLoaded:0,criticalIssuesCount:0,recommendedIssuesCount:0,results:{},_ajax:{},_timers:{},_lastValue:'',_input:null,initialize:function(){this.on('click','[data-role="checkAgain"]',this.checkAgain);this.on('click','[data-role="disableCustomizations"]',this.disableCustomizations);this.on('click','[data-role="enableCustomizations"]',this.enableCustomizations);this.on('click','[data-action="enableThirdPartyPart"]',this.enableSingleCustomizations);this._input=$('#elInput_support_advice_search');this.on('focus','#elInput_support_advice_search',this.fieldFocus);this.on('blur','#elInput_support_advice_search',this.fieldBlur);this.on('submit','#guidesForm form',this.guideFormSubmit);this.initializeBlocks();},guideFormSubmit:function(e){e.preventDefault();},fieldFocus:function(e){this._timers.focus=setInterval(this.guideSearch.bind(this),700);},fieldBlur:function(e){clearInterval(this._timers);},guideSearch:function(e){var searchTerm=this._input.val().trim();if(searchTerm==this._lastValue){return;}
if(searchTerm.length<3){if(!$('#featuredGuides').is(':visible')&&searchTerm.length==0){ips.utils.anim.go('fadeIn fast',$('#featuredGuides'));ips.utils.anim.go('fadeOut fast',$('#guideSearchResults'));}
return;}
this._lastValue=searchTerm;$('#guideSearchResults > ul').html('').parent().addClass('ipsLoading');if($('#featuredGuides').is(':visible')){ips.utils.anim.go('fadeOut fast',$('#featuredGuides'));ips.utils.anim.go('fadeIn fast',$('#guideSearchResults'));}
var self=this;if(this._ajax&&Object.keys(this._ajax).length){Object.values(this._ajax).forEach(function(ajax){try{if((typeof ajax.abort==="function")){ajax.abort();Debug.log('aborted ajax');}}catch(err){}});}
if(this.results[searchTerm]!==undefined){this.showResults(this.results[searchTerm]);return;}
ips.getAjax()('?app=core&module=support&controller=support&do=guideSearch',{dataType:'json',data:{search_term:encodeURIComponent(searchTerm)}}).done(function(response){self.results[searchTerm]=response;self.showResults(response);}).fail(function(err){});},showResults:function(results){$('#guideSearchResults').removeClass('ipsLoading');var html='';if(results.length){for(const result of results){html+=ips.templates.render('support.guideSearch',result);}}
else
{html=ips.templates.render('support.guideSearch.noResults');}
if(html){$('#guideSearchResults > ul').html(html);}else{}},initializeBlocks:function(){var self=this;self.blocksToLoad=0;self.blocksLoaded=0;self.criticalIssuesCount=0;self.recommendedIssuesCount=0;for(const elem of $(this.scope).find('[data-role="patchworkItem"]').toArray()){$(elem).find('[data-role="supportBlock"]').html('').addClass('ipsLoading');$(elem).find('[data-iconType]').hide();$(elem).removeClass('elCritical');self.loadBlock($(elem).attr('data-blockid'));self.blocksToLoad++;};},checkAgain:function(){this.blocksToLoad=0;this.blocksLoaded=0;this.scope.find('[data-role="summary"]').hide();this.initializeBlocks();},disableCustomizations:function(e){e.preventDefault();$(e.target).prop('disabled',true).attr('data-oldText',$(e.target).text()).text(ips.getString('supportDisablingCustomizations'));var self=this;ips.getAjax()($(e.target).attr('href')).done(function(response){self.scope.find('[data-role="customizationsWrapper"]').html(response);self.scope.find('[data-role="disableCustomizations"]').text($(e.target).attr('data-oldText')).prop('disabled',false).hide();self.scope.find('[data-role="enableCustomizations"]').show();$(document).trigger('contentChange',[self.scope]);});},enableCustomizations:function(e){e.preventDefault();$(e.target).prop('disabled',true).attr('data-oldText',$(e.target).text()).text(ips.getString('supportEnablingCustomizations'));var self=this;ips.getAjax()($(e.target).attr('href')).done(function(response){self.scope.find('[data-role="disableCustomizations"]').show();self.scope.find('[data-role="enableCustomizations"]').prop('disabled',false).text($(e.target).attr('data-oldText')).hide();var container=self.scope.find('[data-role="disabledInformation"]');container.find('.i-color_warning').removeClass('i-color_warning').addClass('i-color_soft');container.find('.fa-exclamation-triangle').removeClass('fa-exclamation-triangle').addClass('fa-info-circle');container.find('.ipsButton--negative').removeClass('ipsButton--negative').addClass('ipsButton--inherit');container.find('[data-role="disabledMessage"]').hide();container.find('[data-role="enabledMessage"]').show();container.find('[data-action="enableThirdPartyPart"]').remove();$(document).trigger('contentChange',[self.scope]);});},enableSingleCustomizations:function(e){e.preventDefault();$(e.target).prop('disabled',true).text(ips.getString('supportEnablingCustomizations'));var self=this;ips.getAjax()($(e.target).attr('href')+'&enable=1&type='+$(e.target).attr('data-type')).done(function(response){var container=$(e.target).closest('li');container.find('.i-color_warning').removeClass('i-color_warning').addClass('i-color_soft');container.find('.fa-exclamation-triangle').removeClass('fa-exclamation-triangle').addClass('fa-info-circle');container.find('.ipsButton--negative').removeClass('ipsButton--negative').addClass('ipsButton--inherit');container.find('[data-role="disabledMessage"]').hide();container.find('[data-role="enabledMessage"]').show();if(self.scope.find('.ipsButton--negative').length<1){self.scope.find('[data-role="disableCustomizations"]').show();self.scope.find('[data-role="enableCustomizations"]').hide();$(document).trigger('customizationsEnabled');}
$(e.target).remove();$(document).trigger('contentChange',[self.scope]);});},loadBlock:function(blockid){var loadBlockUrl='?app=core&module=support&controller=support&do=getBlock&block='+blockid;var self=this;ips.getAjax()(loadBlockUrl).done(function(response){self.scope.find('[data-blockid="'+blockid+'"] [data-role="supportBlock"]').html(response.html).removeClass('ipsLoading');$(document).trigger('contentChange',[self.scope.find('[data-blockid="'+blockid+'"]')]);self.blocksLoaded++;self.criticalIssuesCount=self.criticalIssuesCount+parseInt(response.criticalIssues);self.recommendedIssuesCount=self.recommendedIssuesCount+parseInt(response.recommendedIssues);self.scope.find('[data-blockid="'+blockid+'"] [data-iconType]').hide();if(parseInt(response.criticalIssues)){ips.utils.anim.go('fadeIn slow',self.scope.find('[data-blockid="'+blockid+'"] [data-iconType="critical"]'));self.scope.find('[data-blockid="'+blockid+'"]').addClass('elCritical');}
else if(parseInt(response.recommendedIssues)){ips.utils.anim.go('fadeIn slow',self.scope.find('[data-blockid="'+blockid+'"] [data-iconType="recommended"]'));}
if(self.blocksLoaded==self.blocksToLoad){self.finishSetup();}}).fail(function(response){self.scope.find('[data-blockid="'+blockid+'"] [data-role="supportBlock"]').removeClass("ipsLoading");self.scope.find('[data-blockid="'+blockid+'"]').addClass('elCritical');$(document).trigger('contentChange',[self.scope.find('[data-blockid="'+blockid+'"]')]);self.blocksLoaded++;});},finishSetup:function(){this.scope.find('[data-role="summaryText"]').html(ips.pluralize(ips.getString('health_check_summary'),[this.criticalIssuesCount,this.recommendedIssuesCount]));ips.utils.anim.go('fadeIn slow',this.scope.find('[data-role="summary"]'));$(document).trigger('refreshSupportSummary');}});}(jQuery));;