﻿;(function($,_,undefined){"use strict";ips.controller.register('bim.friends.btn',{initialize:function(){this.on('click','[data-action="doAction"]',this.doAction);},doAction:function(e){e.preventDefault();var self=this;var url=$(e.currentTarget).attr('href');var type=$(e.currentTarget).attr('data-type');if(type=='delRequest'||type=='unfriend'){if(!confirm(ips.getString('friends_confirm_'+type))){return false;}}
ips.getAjax()(url,{data:{updateBtn:1,},}).done(function(response){if(response.type=='error'){ips.ui.alert.show({message:response.message});}
else{self.scope.html(response.btn);$(document).trigger('contentChange',[self.scope]);ips.ui.flashMsg.show(response.message);}});return false;},});}(jQuery,_));;
﻿;(function($,_,undefined){"use strict";ips.controller.register('bim.friends.main',{_timer:null,_ajax:null,_value:'',_area:'',initialize:function(){this.on('focus','[data-role="quickSearch"]',this.focusSearch);this.on('blur','[data-role="quickSearch"]',this.blurFriendSearch);this.on('paginationClicked paginationJump',this.paginationClicked);this.on('click','[data-action="findFriends"]',this.findFriends);this.on('click','[data-action="doAction"]',this.doAction);this.on('click','[data-action="confFriends"]',this.confFriends);this._area=this.scope.attr('data-area');},focusSearch:function(){this._timer=setInterval(_.bind(this._checkValue,this),700);},blurFriendSearch:function(){clearInterval(this._timer);},_checkValue:function(){var tab=this.scope.find('.ipsTabs_activeItem').attr('data-tabID');var container=this.scope.find('#ipsTabs_elFriendsBoxTabs_'+this._area+'_elFriendsBoxTab_'+this._area+'_'+tab+'_panel');var value=container.find('[data-role="quickSearch"]').val();if(value==this._value){return;}
this._value=value;this._loadResults();},_loadResults:function(){var self=this;var url=this.scope.attr('data-url');var tab=this.scope.find('.ipsTabs_activeItem').attr('data-tabID');var container=this.scope.find('#ipsTabs_elFriendsBoxTabs_'+this._area+'_elFriendsBoxTab_'+this._area+'_'+tab+'_panel');if(self._value.length>0&&self._value.length<3){return false;}
if(self._ajax&&self._ajax.abort){self._ajax.abort();}
container.find('[data-role="quickSearch"]').addClass('ipsField_loading');self._ajax=ips.getAjax()(url,{data:{fname:self._value,ftab:tab,search:1,},type:'post',}).done(function(response){var results=container.find('[data-role="results"]');if(response.html){results.replaceWith(response.html);}
else{results.html(ips.templates.render('friends.search_no_result'));}
$(document).trigger('contentChange',[results]);}).always(function(){container.find('[data-role="quickSearch"]').removeClass('ipsField_loading');});},paginationClicked:function(e,data){var self=this;var url=data.href;var tab=this.scope.find('.ipsTabs_activeItem').attr('data-tabID');var container=this.scope.find('#ipsTabs_elFriendsBoxTabs_'+this._area+'_elFriendsBoxTab_'+this._area+'_'+tab+'_panel').find('[data-role="results"]');data.originalEvent.preventDefault();if(url=='#'){url=data.paginationElem.find('[data-role="pageJump"]').attr('action')+'&friendspage='+data.pageNo;}
this._ajax=ips.getAjax()(url,{showLoading:true,data:{fname:this._value,browsePage:1,}}).done(function(response){container.html(response.html);$(document).trigger('contentChange',[container]);});},findFriends:function(e){e.preventDefault();var self=this;var url=$(e.currentTarget).attr('href');if($(e.currentTarget).closest('.friendsGrid').length>0){var dialogRef=ips.ui.dialog.create({url:$(e.currentTarget).attr('href'),size:'narrow',title:$(e.currentTarget).attr('title'),forceReload:true,destructOnClose:true,callback:function(e){$(e).find('form').on('submit',function(e){e.preventDefault();ips.getAjax()($(e.currentTarget).attr('action'),{data:$(e.currentTarget).serialize(),type:'post',bypassRedirect:true}).done(function(response){if(response.type=='error'){ips.ui.alert.show({message:response.message,});}
else{dialogRef.hide();ips.ui.flashMsg.show(response.message);self.scope.find('#ipsTabs_elFriendsBoxTabs_'+self._area+'_elFriendsBoxTab_'+self._area+'_mReqs_panel').remove();}});return false;});}});dialogRef.show();}
else{if(self.scope.find('.friendsFind').length>0){return false;}
var container=self.scope.find('.contentWrapper');ips.getAjax()(url).done(function(response){if(response.type=='error'){ips.ui.alert.show({message:response.message});}
else{container.hide()
container.before(response.html);$(document).trigger('contentChange',[self.scope]);self.scope.find('form').on('submit',function(e){e.preventDefault();ips.getAjax()($(e.currentTarget).attr('action'),{data:$(e.currentTarget).serialize(),type:'post',bypassRedirect:true}).done(function(response){if(response.type=='error'){ips.ui.alert.show({message:response.message});}
else{$(e.currentTarget).remove();container.show();ips.ui.flashMsg.show(response.message);self.scope.find('#ipsTabs_elFriendsBoxTabs_'+self._area+'_elFriendsBoxTab_'+self._area+'_mReqs_panel').remove();}});return false;});self.scope.find('form .formCancel').on('click',function(e){$(e.currentTarget).closest('form').remove();container.show();return false;});}});}
return false;},doAction:function(e){e.preventDefault();var self=this;var url=$(e.currentTarget).attr('href');var row=$(e.currentTarget).closest('.friendRow');var type=$(e.currentTarget).attr('data-type');if(type=='delRequest'||type=='unfriend'){if(!confirm(ips.getString('friends_confirm_'+type))){return false;}}
ips.getAjax()(url).done(function(response){if(response.type=='error'){ips.ui.alert.show({message:response.message});}
else{row.remove();if(response.reqCount==0){$('#elFriendsIcon .ipsNotificationCount').hide();$('#elFriendsIconMobile .ipsNotificationCount').hide();self.scope.find('.friendRequestsCount').hide();}
else{$('#elFriendsIcon .ipsNotificationCount').html(response.reqCount).show();$('#elFriendsIconMobile .ipsNotificationCount').html(response.reqCount).show();self.scope.find('.friendRequestsCount').html(response.reqCount).show();}
if(type=='accept'){self.scope.find('#ipsTabs_elFriendsBoxTabs_'+self._area+'_elFriendsBoxTab_'+self._area+'_friends_panel').remove();}
ips.ui.flashMsg.show(response.message);}});return false;},confFriends:function(e){e.preventDefault();var self=this;var url=$(e.currentTarget).attr('href');ips.getAjax()(url).done(function(response){if(response.type=='error'){ips.ui.alert.show({message:response.message});}
else{if(self.scope.find('.friendsConf').length>0){return false;}
var mainContent=self.scope.find('.listContent');mainContent.hide();self.scope.prepend(response);$(document).trigger('contentChange',[self.scope.find('.friendsConf')]);self.scope.find('.friendsConf').on('submit',function(e){e.preventDefault();ips.getAjax()($(e.currentTarget).attr('action'),{data:$(e.currentTarget).serialize(),type:'post',bypassRedirect:true}).done(function(response){if(response.type=='error'){ips.ui.alert.show({message:response.message});}
else{$(e.currentTarget).remove();mainContent.show();ips.ui.flashMsg.show(response.message);}});return false;});self.scope.find('.friendsConf .formCancel').on('click',function(e){$(e.currentTarget).closest('form').remove();mainContent.show();return false;});}});return false;},});}(jQuery,_));;
ips.controller.mixin('friends.menu','core.front.core.userbar',true,function(){this.before('menuOpened',function(e,data){if(data.elemID=='elFriendsIcon'){this._loadMenu('friends',ips.getSetting('baseURL')+'index.php?app=friends&module=friends&controller=friends&_fromMenu=1','friends');}
else if(data.elemID=='elFriendsIconMobile'){this._loadMenu('friendsMobile',ips.getSetting('baseURL')+'index.php?app=friends&module=friends&controller=friends&_fromMenu=2','friendsMobile');}});});;
﻿;(function($,_,undefined){"use strict";ips.controller.mixin('bim.friends.stream','core.front.streams.form',true,function(){this.after('_updateFilterOverview',function(e){var ownership=$('#elStreamOwnership_menu').find('.ipsMenu_itemChecked').data('ipsmenuvalue');if(ownership=='friends'){$('#elStreamFilterForm [data-filter="stream_ownership"] .cStreamFilter_blurb em').text(ips.getString('streamFilter_stream_ownership_friends'));}});});}(jQuery,_));;
﻿ips.templates.set('friends.memberItem'," 	<li class='ipsAutocompleteMenu_item ipsClearfix' data-value=\"{{value}}\" role='option' role='listitem'>		<div class='ipsPhotoPanel ipsPhotoPanel_tiny'>			<span class='ipsUserPhoto ipsUserPhoto_tiny'><img src='{{{photo}}}'></span>			<div>				<strong>{{{name}}}</strong><br>				<span class='ipsType_light'>{{{extra}}}</span>			</div>		</div>	</li>");ips.templates.set('friends.search_no_result'," 	<div class='ipsPad ipsType_center ipsType_large ipsType_light'>		{{#lang}}friends_search_no_result{{/lang}}	</div>");ips.templates.set('friends.home_btn'," 	<a class='ipsButton ipsButton_verySmall ipsButton_veryLight' href='#!' data-action='home'>		{{#lang}}friends_home_btn{{/lang}}	</a>");;