;(function($){"use strict";ips.controller.register('core.front.modcp.approveQueue',{initialize:function(){this.on('click','[data-action="approvalQueueAction"]',this.doConfirm);},doConfirm:function(e,data){e.preventDefault();var self=this;var action=$(e.currentTarget).attr('data-type');if(action!=='delete'){self.doAction(e,data);return;}
var alert={type:'confirm',icon:'warn',message:ips.getString('generic_confirm'),subText:'',callbacks:{ok:function(){self.doAction(e,data);},no:function(){return;}}};ips.ui.alert.show(alert);},doAction:function(e,data){e.preventDefault();var element=$(e.target).closest('a');ips.getAjax()($(element).attr('href')+'&_fromApproval=1',{bypassRedirect:true}).done(function(){ips.getAjax()(ips.getSetting('baseURL')+'?app=core&module=modcp&controller=modcp&tab=approval&action=getCount').done(function(response){$('#elModCPApprovalCount').html(response.total);$(element).parents('[data-role="approvalItem"]').slideUp("slow",function(){$(this).remove();});}).fail(function(failresponse){window.location=ips.getSetting('baseURL')+'?app=core&module=modcp&controller=modcp&tab=approval';});}).fail(function(){window.location=$(e.currentTarget).attr('href');});}});}(jQuery));;
;(function($){"use strict";ips.controller.register('core.front.modcp.report',{initialize:function(){this.on(document,'submitDialog','[data-role="warnUserDialog"]',this.dialogSubmitted);this.on('menuItemSelected',this.menuItemSelected);},menuItemSelected:function(e,data=e.detail){data.originalEvent.preventDefault();var link=$(data.menuElem).find('[data-ipsMenuValue="'+data.selectedItemID+'"]');var langString=(data.selectedItemID=='spamFlagButton')?ips.getString('confirmFlagAsSpammer'):ips.getString('confirmUnFlagAsSpammer');var descString=(data.selectedItemID=='spamUnFlagButton')?ips.getString('confirmUnFlagAsSpammerDesc'):'';var self=this;if(data.selectedItemID=='spamFlagButton'||data.selectedItemID=='spamUnFlagButton'){ips.ui.alert.show({type:'confirm',message:langString,subText:descString,callbacks:{ok:function(){self._startLoading();ips.getAjax()(link.attr('href'),{bypassRedirect:true}).done(function(response){self._refreshPanel();});},}});}},dialogSubmitted:function(e,data){this._startLoading();this._refreshPanel();},_startLoading:function(){this.scope.find('[data-role="authorPanel"]').css('height',this.scope.find('[data-role="authorPanel"]').height()+'px').addClass('ipsLoading').find('*').hide();},_refreshPanel:function(){var self=this;ips.getAjax()(window.location,{bypassRedirect:true}).done(function(response){self.scope.find('[data-role="authorPanel"]').css('height','auto').removeClass('ipsLoading').html(response);});}});}(jQuery));;
;(function($){"use strict";ips.controller.register('core.front.modcp.announcementForm',{_lastValue:'',_textField:null,_timer:0,initialize:function(){this._textField=$('#elInput_announce_url');this.on('blur','#elInput_announce_url',this.fieldKeyUp);},fieldKeyUp:function(){clearTimeout(this._timer);this._timer=setTimeout(this._checkPermissions.bind(this),700);},_checkPermissions:function(){var value=this._textField.val().trim();if(value.length<3){return;}
ips.getAjax()('?app=core&module=system&controller=announcement&do=permissionCheck',{dataType:'json',data:{url:value}}).done(function(response){if(response.html===undefined&&$('#elAnnouncementGroupWarning').length){$('#elAnnouncementGroupWarning').remove();}
if($('#elAnnouncementGroupWarning').length){$('#elAnnouncementGroupWarning').replaceWith(response.html);}
else
{$(response.html).insertAfter('#elInput_announce_url');}}).fail(function(err){});}});}(jQuery));;
;(function($){"use strict";ips.controller.register('core.front.modcp.reportToggle',{initialize:function(){this.on('click','[data-action="_ipsMenu_ping"]',this.reportToggleClicked);},reportToggleClicked:function(e){e.preventDefault();var elem=$(e.currentTarget);var reportId=this.scope.find('[data-reportId]').attr('data-reportId');var newStatus=$(elem).closest('[data-ipsMenuValue]').attr('data-ipsMenuValue');var newStatusText=$(elem).find('[data-role="ipsMenu_selectedText"]').text();if($(elem).attr('data-showconfirm')!==undefined){if($(elem).attr('data-hasNotifications')>0){var dialogRef=ips.ui.dialog.create({title:ips.getString('report_status_change_confirm',{newstatus:newStatusText}),size:'narrow',url:'?app=core&module=modcp&controller=modcp&tab=reports&action=reportCenterConfirmModal&id='+reportId+'&status='+newStatus,forceReload:true});dialogRef.show();}else{ips.ui.alert.show({type:'confirm',title:ips.getString('report_status_change_confirm',{newstatus:newStatusText}),icon:'fa fa-question-circle',buttons:{ok:ips.getString('ok'),cancel:ips.getString('cancel')},callbacks:{ok:function(){$(elem).attr('data-action','ipsMenu_ping');$(elem)[0].dispatchEvent(new Event("click",{bubbles:true}));},}});}}else{$(elem).attr('data-action','ipsMenu_ping');$(elem)[0].dispatchEvent(new Event("click",{bubbles:true}));}}});}(jQuery));;
;(function($){"use strict";ips.controller.register('core.front.modcp.warnForm',{pointsEdited:false,expirationEdited:false,editorSetTo:'',initialize(){this.on('change','[name="warn_reason"]',this.changeReason);this.on('change','[name="warn_points"]',this.changePoints);this.on('change','[name="warn_remove"],[name="warn_remove_time"]',e=>{this.expirationEdited=true;});this.on('editorWidgetInitialized',this.editorInitialized);},editorInitialized(e,data){if(data.id==='warn_member_note'){$('[name="warn_reason"]').trigger('change');const editor=ips.ui.editorv5.getObj($('textarea[name="warn_member_note"]').closest('[data-ipsEditorv5]'));this.editorSetTo=editor.getInstanceHTML();}},async changeReason(e){const response=await ips.fetch(ips.getSetting('baseURL')+'index.php?app=core&module=system&controller=warnings&do=reasonAjax&id='+$(e.target).val())
if(!this.pointsEdited||!response.points_override){const pointsNow=parseInt(this.scope.find('[name="warn_points"]').val());this.scope.find('[name="warn_points"]').val(response.points).prop('disabled',parseInt(response.points_override)===0);if(pointsNow!==response.points){this.scope.find('[name="warn_points"]').trigger('change');}
this.pointsEdited=false;}
const removePointsUnlimited=this.scope.find('[name="warn_remove_unlimited"]');if(response.remove.unlimited){if(!this.expirationEdited||!response.remove_override){if(!removePointsUnlimited.prop('checked')){if(removePointsUnlimited.prop('disabled')){removePointsUnlimited.prop('disabled',false).trigger('click').prop('disabled',true);}else{removePointsUnlimited.trigger('click');}}}}else if(!this.expirationEdited||!response.remove_override){removePointsUnlimited.prop('checked',false);this.scope.find('[name="warn_remove"]').val(response.remove.date).prop('disabled',!response.remove_override);this.scope.find('[name="warn_remove_time"]').val(response.remove.time).prop('disabled',!response.remove_override);}
removePointsUnlimited.prop('disabled',!response.remove_override);const cheevPoints=this.scope.find('[name="warn_cheeve_point_reduction"]');if(!response.cheev_override){cheevPoints.prop('disabled',true);}else{cheevPoints.prop('disabled',false);}
cheevPoints.val(response.cheev_point_reduction);const editor=ips.ui.editorv5.getObj($('textarea[name="warn_member_note"]').closest('[data-ipsEditorv5]'));if(response.notes&&editor){const currentContents=editor.getInstanceHTML();const previousContents=this.editorSetTo;editor.unminimize(()=>{if(currentContents===previousContents){editor.reset();}else{editor.insertHtml('<p></p>');}
editor.insertHtml(response.notes);this.editorSetTo=editor.getInstanceHTML();});}},async changePoints(e){this.pointsEdited=true;const response=await ips.fetch(ips.getSetting('baseURL')+'index.php?app=core&module=system&controller=warnings&do=actionAjax&points='+$(e.target).val()+'&member='+this.elem.dataset.member);const types=['mq','rpa','suspend'];this.elem.querySelectorAll('ul#elWarningPenalties').forEach(e=>e.remove());if(response.override){this.elem.querySelectorAll('li#form_warn_punishment .ipsFieldRow__content').ipsShow();}else{this.elem.querySelectorAll('li#form_warn_punishment .ipsFieldRow__content').ipsHide();const enforcedPenalties=[];types.forEach(type=>{if(response.actions[type].unlimited&&(typeof response.actions[type].unlimited!=='string'||parseInt(response.actions[type].unlimited))){enforcedPenalties.push(ips.getString('warningPunishmentIndefinitely',{type:ips.getString('warningPunishment_'+type)}));}
else if(response.actions[type].date!==""&&response.actions[type].date!==null){const date=new Date(response.actions[type].date+' '+response.actions[type].time);enforcedPenalties.push(ips.getString('warningPunishmentDate',{type:ips.getString('warningPunishment_'+type),date:date.toLocaleDateString(document.documentElement.lang||undefined)}));}});this.scope.find('li#form_warn_punishment').append(ips.templates.render('system.warningpenalty.nomodify',{penalties:enforcedPenalties}));}
this.scope.find('#form_warn_punishment [data-action="checkboxsetNone"]').trigger('click');types.forEach(type=>{if(parseInt(response.override)){this.scope.find('[name="warn_punishment['+type+']"]').prop('checked',(response.actions[type].date||response.actions[type].unlimited));}
if(response.actions[type].unlimited){this.scope.find('[name="warn_'+type+'_unlimited"]').prop('checked',true).prop('disabled',!parseInt(response.override)).trigger('change');}else if(response.actions[type].date){this.scope.find('[name="warn_'+type+'_unlimited"]').prop('checked',false).prop('disabled',!parseInt(response.override)).trigger('change');this.scope.find('[name="warn_'+type+'"]').val(response.actions[type].date).prop('disabled',!parseInt(response.override));this.scope.find('[name="warn_'+type+'_time"]').val(response.actions[type].time).prop('disabled',!parseInt(response.override));}});}});}(jQuery));;
;(function($){"use strict";ips.controller.register('core.front.modcp.warnPopup',{initialize:function(){this.on('click','[data-action="revoke"]',this.revokeWarning);},revokeWarning:function(e){e.preventDefault();var url=$(e.currentTarget).attr('href');ips.ui.alert.show({type:'verify',icon:'question',message:ips.getString('revokeWarning'),buttons:{yes:ips.getString('reverseAndDelete'),no:ips.getString('justDelete'),cancel:ips.getString('cancel')},callbacks:{yes:function(){window.location=url+'&undo=1';},no:function(){window.location=url+'&undo=0';}}});}});}(jQuery));;
;(function($){"use strict";ips.controller.register('core.front.modcp.reportList',{initialize:function(){this.on('menuItemSelected','[data-action="changeStatus"]',this.changeReportStatus);this.on('menuItemSelected','[data-role="filterButton"]',this.filterList);},changeReportStatus:function(e,data=e.detail){if(data.originalEvent){data.originalEvent.preventDefault();}
var row=$(e.currentTarget).closest('.ipsData__item');row.removeClass('ipsData__item--warning');switch(data.selectedItemID){case'1':break;case'2':row.addClass('ipsData__item--warning');break;}},filterList:function(e,data=e.detail){if(data.originalEvent){data.originalEvent.preventDefault();}
var filter=data.selectedItemID||'';var container=$(this.scope).find('[data-baseUrl]');ips.getAjax()($(container).data('baseUrl'),{data:{filter:filter}}).done(function(response){$(container).replaceWith(response);$(document).trigger('contentChange',[container]);});}});}(jQuery));;