ips.templates.set('club.request.approve',"	<span class='cClubRequestCover_icon i-background_positive'>		<i class='fa-solid fa-check'></i>	</span>	<br>	<span class='ipsBadge ipsBadge--large ipsBadge--positive'>{{#lang}}clubRequestApproved{{/lang}}</span>");ips.templates.set('club.request.decline',"	<span class='cClubRequestCover_icon i-background_negative'>		<i class='fa-solid fa-xmark'></i>	</span>	<br>	<span class='ipsBadge ipsBadge--large ipsBadge--negative'>{{#lang}}clubRequestDenied{{/lang}}</span>");ips.templates.set('club.menu.dragHandle',"	<span data-role='clubMenuDrag' style='display: none'><i class='fa-solid fa-bars'></i> &nbsp;</span>");;
;(function($){"use strict";ips.controller.register('core.front.clubs.navbar',{_interval:null,_sortableElem:null,initialize:function(){this.on(document,'click','[data-action="reorderClubmenu"]',this.startReorder);this.on(document,'click','[data-action="saveClubmenu"]',this.saveOrder);this.setup();},setup:function(){this._sortableElem=this.scope.find('[data-club-menu]');},startReorder:function(e){e.preventDefault();$('[data-action="saveClubmenu"]').removeClass('ipsHide');$('[data-action="reorderClubmenu"]').parent().addClass('ipsHide');var self=this;this._sortableElem.find('a').addClass('i-cursor_move').prepend(ips.templates.render('club.menu.dragHandle'));ips.loader.get(['core/interface/jquery/jquery-ui.js']).then(function(){self._sortableElem.sortable({items:'>',forcePlaceholderSize:true,update:function(){self._orderChanged=true;}});self._reordering=true;self._orderChanged=false;self._sortableElem.find('a [data-role="clubMenuDrag"]').fadeIn();});},_finishReorder:function(){this._sortableElem.find('a').removeClass('i-cursor_move').find('[data-role="clubMenuDrag"]').remove();$('[data-action="saveClubmenu"]').addClass('ipsHide');$('[data-action="reorderClubmenu"]').parent().removeClass('ipsHide');this._sortableElem.sortable('destroy');this._reordering=false;},saveOrder:function(e){e.preventDefault();var self=this;var tabOrder=this._sortableElem.sortable('toArray',{attribute:'data-tab'});if(this._orderChanged){ips.getAjax()(ips.getSetting('baseURL')+'index.php?app=core&module=clubs&controller=view&do=saveMenu',{data:{tabOrder:tabOrder,id:this.scope.attr('data-clubID')},dataType:'json',type:'post'}).done(function(response){ips.ui.flashMsg.show(ips.getString('tab_order_saved'));}).fail(function(){ips.ui.alert.show({type:'alert',icon:'warning',message:ips.getString('tab_order_not_saved'),callbacks:{ok:function(){}}});}).always(function(){self._finishReorder();});}else{this._finishReorder();}}});}(jQuery));;
;(function($){"use strict";ips.controller.register('core.front.clubs.requests',{_interval:null,initialize:function(){this.on('click','[data-action="requestApprove"], [data-action="requestDecline"]',this.handleRequest);this.on(document,'menuItemSelected',this.handleRequest);this.on(window,'resize',this.resizeCovers);this.setup();},setup:function(){},resizeCovers:function(e){var self=this;var cards=this.scope.find('[data-ips-js=memberCard][data-hasCover]');if(cards.length){$.each(cards,function(){var id=$(this).identify().attr('id');var cover=$('body').find('.cClubRequestCover[data-cardId="'+id+'"]');self._positionCover($(this),cover);});}},handleRequest:function(e,data=e.detail){var self=this;if(e.type=='menuItemSelected'){if($(data.menuElem).attr('data-role')!='acceptMenu'){return;}
data.originalEvent.preventDefault();var url=$(data.originalEvent.target).attr('href');var card=$(e.target).closest('[data-ips-js=memberCard]');}else{e.preventDefault();var url=$(e.currentTarget).attr('href');var card=$(e.currentTarget).closest('[data-ips-js=memberCard]');}
var id=card.identify().attr('id');card.find('[data-action]').addClass('ipsButton--disabled');ips.getAjax()(url,{showLoading:true}).done(function(response){card.attr('data-hasCover',true);card.animate({opacity:"0.2"});var cover=$('<div/>').addClass('cClubRequestCover').attr('data-cardId',id);$('body').append(cover);self._positionCover(card,cover);cover.append(ips.templates.render(response.status=='approved'?'club.request.approve':'club.request.decline')).fadeIn();ips.ui.flashMsg.show(response.status=='approved'?ips.getString('clubMemberApproved'):ips.getString('clubMemberDeclined'),{escape:false});if(!self._interval){self._interval=window.setInterval(self._checkCardsExist.bind(self),200);}}).fail(function(){window.location=url;});},_checkCardsExist:function(){var self=this;var covers=$('body').find('.cClubRequestCover');var cards=this.scope.find('[data-ips-js=memberCard][data-hasCover]');if(cards.length==covers.length){return;}
if(covers.length){$.each(covers,function(){var cardId=$(this).attr('data-cardId');var card=self.scope.find('#'+cardId);if(!card.length){$(this).remove();}});}},_positionCover:function(card,cover){var elemPosition=ips.utils.position.getElemPosition(card);var dims=ips.utils.position.getElemDims(card);cover.css({position:'absolute',top:elemPosition.absPos.top+'px',left:elemPosition.absPos.left+'px',width:dims.outerWidth+'px',height:dims.outerHeight+'px'});}});}(jQuery));;