<?php echo Wo_LoadPage('forum/headers/header'); 
$section = Wo_GetForumSec(array('id' => $wo['forum_data']['forum']['sections']));
?>
<div role="tabpanel" class="tab-pane active" id="forumdisplay">
	<div class="w-100 text-center sun_forum_dis_head">
		<h4><?php echo($wo['forum_data']['forum']['name']) ?></h4>
		<a href="<?php echo Wo_SeoLink('index.php?link1=forumsadd&fid=' . $wo['forum_data']['forum']['id']) ?>" data-ajax="?link1=forumaddthred&fid=<?php echo $wo['forum_data']['forum']['id'];?>" class="btn btn-main"><?php echo $wo['lang']['create_new_topic']; ?></a>
		<p><?php echo($wo['forum_data']['forum']['description']) ?></p>
	</div>
	<div class="w-100">
		<?php if (count($wo['forum_data']['threads']) > 0): ?>
			<table class="table threads-table">
				<thead class="sun_forum_dis_thead">
					<tr>
				        <th><?php echo $wo['lang']['topic']; ?></th>
						<th><?php echo $wo['lang']['last_post']; ?></th>
				        <th class="text-center"><?php echo $wo['lang']['replies']; ?></th>
						<th class="text-center"><?php echo $wo['lang']['views']; ?></th>
					</tr>
				</thead>
				<tbody id="forum-threads">
				    <?php foreach ($wo['forum_data']['threads'] as $wo['thread']): ?>
				    	<?php echo Wo_LoadPage("forum/includes/post-list"); ?>
				    <?php endforeach; ?>
				</tbody>
			</table>
		<?php else: ?>
			<?php echo '<h5 class="search-filter-center-text empty_state"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-git-merge"><circle cx="18" cy="18" r="3"></circle><circle cx="6" cy="6" r="3"></circle><path d="M6 21V9a9 9 0 0 0 9 9"></path></svg>' . $wo['lang']['no_threads_found'] .  '</h5>'; ?>
		<?php endif; ?>
	</div>
	<div class="posts_load">
		<?php if (count($wo['forum_data']['threads']) >= 10): ?>
	        <div class="load-more">
	            <button class="btn btn-default text-center pointer forum-posts-load"  >
	            <i class="fa fa-arrow-down progress-icon" data-icon="arrow-down"></i> <?php echo $wo['lang']['load_more_posts'] ?></button>
	        </div>
		<?php endif ?>
	</div>  
	<hr><br>
	<div>
		<a href="<?php echo Wo_SeoLink('index.php?link1=forumsadd&fid=' . $wo['forum_data']['forum']['id']) ?>" data-ajax="?link1=forumaddthred&fid=<?php echo $wo['forum_data']['forum']['id'];?>" class="btn btn-main"><?php echo $wo['lang']['create_new_topic']; ?></a>
		<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" onclick="FroumShare(this)">
            <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"> <path fill="currentColor" d="M18,16.08C17.24,16.08 16.56,16.38 16.04,16.85L8.91,12.7C8.96,12.47 9,12.24 9,12C9,11.76 8.96,11.53 8.91,11.3L15.96,7.19C16.5,7.69 17.21,8 18,8A3,3 0 0,0 21,5A3,3 0 0,0 18,2A3,3 0 0,0 15,5C15,5.24 15.04,5.47 15.09,5.7L8.04,9.81C7.5,9.31 6.79,9 6,9A3,3 0 0,0 3,12A3,3 0 0,0 6,15C6.79,15 7.5,14.69 8.04,14.19L15.16,18.34C15.11,18.55 15.08,18.77 15.08,19C15.08,20.61 16.39,21.91 18,21.91C19.61,21.91 20.92,20.61 20.92,19A2.92,2.92 0 0,0 18,16.08Z"></path> </svg>
            <?php echo $wo['lang']['share_on_timeline']; ?>
		</button>
		<div class="btn-group dropup">
			<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
	            <i class="fa fa-sort-amount-desc" aria-hidden="true"></i> &nbsp; <span class="caret"></span>
			</button>
			<ul class="dropdown-menu" role="menu">
	            <li><a href="<?php echo Wo_SeoLink('index.php?link1=mythreads'); ?>"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-book" style="margin-top: -2px;"><path d="M4 19.5A2.5 2.5 0 0 1 6.5 17H20"></path><path d="M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z"></path></svg> <?php echo $wo['lang']['my_threads']; ?></a></li>
	            <li><a href="<?php echo Wo_SeoLink('index.php?link1=mymessages'); ?>"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-message-circle" style="margin-top: -2px;"><path d="M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z"></path></svg> <?php echo $wo['lang']['my_messages']; ?></a></li>
			</ul>
		</div>
		<?php if ($wo['forum_data']['forums'] && count($wo['forum_data']['forums']) > 0): ?>
			<div class="btn-group dropup">
				<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
	            <?php echo $wo['lang']['jump_to']; ?> &nbsp; <span class="caret"></span>
				</button>
				<ul class="dropdown-menu" role="menu">
	          	<?php foreach ($wo['forum_data']['forums'] as $jump): ?>
	            	<li>
						<a 
						href="<?php echo Wo_SeoLink('index.php?link1=forums&fid='.$jump['id']);?>"
						class="main <?php if ($jump['name'] == $wo['forum_data']['forum']['name']) echo 'bold'; ?>">

				        <?php echo $jump['name']; ?>
				        </a>
	            	</li>
	            <?php endforeach ?>
				</ul>
	        </div>
		<?php endif ?>
	</div>
</div>
<div class="clear"></div>
<?php echo Wo_LoadPage('forum/headers/footer'); ?>
<div class="modal fade in" id="forum-shared" role="dialog">
    <div class="modal-dialog">
    
      <div class="modal-content">
        <p style="text-align: center;padding: 30px 20px;font-family: Hind,Arial;font-size: 16px;">
          <i class="fa fa-check" aria-hidden="true" style="color: green;"></i>      
          <?php echo $wo['lang']['forum_shared']; ?>
        </p>
      </div>
      
    </div>
</div>
<script>

	function FroumShare(self) {
		$("#forum-shared").modal('show');
		$(self).attr('disabled', 'true');
		$.post(Wo_Ajax_Requests_File() + '?f=forum_share&hash_id=' + $('.main_session').val(), {id: <?php echo $_GET['fid']; ?>}, function(data, textStatus, xhr) {
			setTimeout(function (argument) {
				$(self).removeAttr('disabled');
				$("#forum-shared").modal('hide');
			},2000);
		});
	}
	$(".forum-posts-load").click(function () {
		  
	      $.ajax({
	         url: Wo_Ajax_Requests_File(),
	         type: 'GET',
	         dataType: 'json',
	         data: {
	         	f:"forum-posts-load",

	         	forum:<?php echo $_GET['fid']; ?>,

	         	offset:($(".topic-list").length > 0) ? $(".topic-list:last").attr('data-forum') : 0,

	         },
	         success:function(data){
	         	
	            if (data['status'] == 200) {

	                $(".threads-table tbody").append(data['html'])
	             }else{

	               $(".posts_load").remove()
	               
	             }

	         }
	      });
	   	});

	var delay = (function(){
		var timer = 0;
		return function(callback, ms){
		  clearTimeout (timer);
		  timer = setTimeout(callback, ms);
		};
	})();

	$("#search-forum-threads").keyup(function(event) {

      delay(function(){
      if ($("#search-forum-threads").val().trim()) {
	      $.ajax({
	        url: Wo_Ajax_Requests_File(),
	        type: 'GET',
	        data: {	f:"forum-thread-search",
	        		keyword:$("#search-forum-threads").val(),
	        		fid:<?php echo($wo['forum_data']['forum']['id']) ?>
	        	},
	        dataType: "json",
	        success: function(data){
	          if (data['status'] == 200) {
	          	$("#forum-threads").html(data['html']);
	          }
	          else if(data['status'] == 404){
	          	
	         	 $("#forum-threads").html('<tr> <td colspan="5" class="text-center" style="padding:40px 40px;" >' + data['html'] + '</td></tr>');
	          }
	        }
	      })}

      }, 1000 );
  	});
</script>
