<? global $vis_language;?>
<div class="modal-dialog modal-md">
    <div class="modal-content">
		<div class="modal-header " style="border-bottom:none !important; height:5px">
		  <button type="button" class="close" data-dismiss="modal">&times;</button>
		  <h4 class="modal-title"><? echo $vis_language['TXTTOPICFOLLOWERS']; ?></h4>
		</div>
		<div class="wrapper">
		<div class="form-group" id="shareWith">
			<label class="col-sm-2 control-label"></label>
			<div class="col-sm-10">
					<input class="form-control" type="text" placeholder="<? echo $vis_language['TXTSEARCHSTAFF'];?>" id="share_with" value="<? if(isset($staff)) echo $staff['first_name']; ?>" data-resize="no">
				<script type="text/javascript">
					$(document).ready(function() {
						$("#share_with").tokenInput(
							"index.php?vis_module=staff&vis_operation=staff_listing&vis_topic_id=<?=$forumTopicFollowers[0]['topic_id']; ?>",
							{
								theme: "facebook",
								searchDelay: 300,
								minChars: 1,
								queryParam: "vis_data",
								preventDuplicates: true,
								propertyToSearch: "full_name",
								tokenValue: "full_name",
								searchingText: "<? echo $vis_language['MSGSEARCHING']."..."; ?>",
								noResultsText: "<? echo $vis_language['TXTNOMATCHFOUND']; ?>",
								resultsFormatter: function(item){ 
								if(item.type=="heading"){
									return "<b>" + "<div style='cursor:pointer;display: inline-block; padding-left: 10px;'><div class='full_name'>" + item.full_name + "</div></div></b>"
								}
								else{ return "<li>" + "<div style='display: inline-block; padding-left: 10px;margin-left:30px;'><div class='full_name'>" + item.full_name + "</div></div></li>"	} },
								tokenFormatter: function(item) { if(item.group_id){$('#vis_blab_grp_share').val($('#vis_blab_grp_share').val()+item.group_id+',');}
									
									else{$('#vis_blab_share').val($('#vis_blab_share').val()+item.id+',');$('#vis_staff').val($('#vis_staff').val()+item.id+',');}return "<li><p>" + item.full_name + "</p></li>" },
								onDelete: function(item){
								if(item.group_id)
								{										
									var staffs = $('#vis_blab_grp_share').val();
									var newStaffs = staffs.replace(item.group_id+',', ''); 
									$('#vis_blab_grp_share').val(newStaffs);
								}
								else
								{
									var staffs = $('#vis_blab_share').val();
									var staffIds = $('#vis_staff').val();	
									var newStaffs = staffs.replace(item.id+',', ''); 
									$('#vis_blab_share').val(newStaffs);
									$('#vis_staff').val(newStaffs);								
								}
								},
								onAdd: function(item)
								{
								
								
									if(item.type == "heading")
									{	
										$("#share_with").tokenInput("remove", {full_name: item.full_name});
									}
									$(this).visExecution('load_operations',{'vis_module':'forums', 'vis_operation':'add_followers','topic_id': '<?php echo $operation['vis_topic_id']; ?>','parent_id':item.id,'vis_topic':'Announcement Forum'});
									$('#vis_workpanel_div').visExecution('load_operations',{'vis_module':'forums', 'vis_operation':'topic_details','vis_topic_id':'<?=$topicId?>','vis_action':'#/forums/topic_details/<?=$topicTitle?>/<?=$topicId?>'});  
								}
							}
						);	
						<?if(isset($operation['vis_home']) && $operation['vis_home']==1){?>
						$("#share_with").tokenInput("add", {id: "<?= $operation['vis_staff_id']; ?>", full_name: "<?= $operation['vis_first_name']." ".$operation['vis_last_name']; ?>"});<? } ?>
						//$("div.token-input-dropdown-facebook").css('width',$(".token-input-list-facebook").width()+2+'px');
					});
				</script>
				<input type="hidden" id="vis_blab_grp_share" name="vis_blab_grp_share"/>
				<input type="hidden" id="vis_blab_share" name="vis_blab_share"/>
				<input type="hidden" id="vis_staff" name="vis_staff" value=""/>
				<input type="hidden" id="vis_attachment_count" name="vis_attachment_count" value="0">
			</div>
		</div>
		<input type="hidden" name="parent_type" value="3">	
		<textarea name="vis_blab_post_hidden" id="vis_blab_post_hidden" class="form-control"  data-minwords="6" rows="2" style="display:none;"></textarea>
		</div>
		<div class="modal-body  wrapper">
			<div class="wrapper-sm m-b-sm" id="follower_list">
				<ul id="vis_recent_activities" class="list-group no-radius m-b-none  list-group no-border">
					<?php if($forumTopicFollowers != -1) for($i=0; $i< count($forumTopicFollowers); $i++) { ?>
						<li class="list-group-item wrapper" id="<?=$forumTopicFollowers[$i]['follow_id']; ?>">
      <a href="#" >
      <? if($forumTopicFollowers[$i]['follower_image']=='' || $forumTopicFollowers[$i]['follower_image']=='default.jpg'){?>
<div class="l-avatar pull-left m-r-sm m-t-n-sm ">
<? if($staff[0]['first_name']!=''){
	$firstname=preg_split('//u', $staff[0]['first_name'], -1, PREG_SPLIT_NO_EMPTY);
$lastname=preg_split('//u', $staff[0]['last_name'], -1, PREG_SPLIT_NO_EMPTY);
	?>
<div class="sm"><? echo ucfirst($firstname[0]).ucfirst($lastname[0]);?></div>
    <? }else{ ?>
    <img class="sm" src="<?= VIS_PATH_PROFILE.'default.jpg';?>">
    <? }?>

</div>
<? }else{ ?>
<div class="l-avatar pull-left m-r-sm m-t-n-sm ">
<img src="<? echo VIS_PATH_PROFILE.$forumTopicFollowers[$i]['follower_image']; ?>" class="sm">
</div>
<? }?>
</a>
							<!--<a href="#" class="thumb-sm pull-left  m-r-sm m-t-n-sm  avatar"><img src="<? //echo VIS_PATH_PROFILE.($forumTopicFollowers[$i]['follower_image']==''?'default.jpg':$forumTopicFollowers[$i]['follower_image']); ?>" /></a>-->
							<a class="clear" href="#/ticket/ticket_details/ZHCJ-016910/150">
							<div class="block m-t-n-xs"><strong class="text-default"><?=$forumTopicFollowers[$i]['follower_name'] ;?></strong> <?=$forumTopicFollowers[$i]['follower_email'];?></div>
							</a>
							<div class="pull-right m-t-n" style="display: none;" id="followerAction<?=$forumTopicFollowers[$i]['follow_id']; ?>">
                                       <span><a class="text-muted" href="javascript:void(0);" onclick="$(this).visExecution('load_operations',{'vis_module':'forums', 'vis_operation':'delete_followers','follow_id': '<?php echo $forumTopicFollowers[$i]['follow_id']; ?>','vis_topic_id':'<?=$topicId?>'});" title="Delete"><i class="vh vh-delete-round"></i></a></span>
                            </div>
						</li>
					<?php } ?>
				</ul>
				
			</div>
		</div>
    </div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
<script type="text/javascript">
$("li").hover(
     function () {
     var id=this.id;
     	
     	$("#followerAction"+id).css("display","block");
     	
     	
     });
     $("li").mouseleave(
     function () {
     var id=this.id;
        $("#followerAction"+id).css("display","none");
		
   });
</script>
