<?php echo Wo_LoadPage('forum/headers/header'); ?>
<div role="tabpanel" class="tab-pane active" id="showthread">
	<div class="thraed-header-content wow_thread_head">
		<div class="col-md-9 no-padding-right no-padding-left">
			<h4 class="forum_title"><?php echo ($wo['thread']['headline']); ?></h4>
			<div class="clear"></div>
			<div>
				<span><?php echo $wo['lang']['started_by']; ?> <?php echo ($wo['thread']['user_data']['name']); ?></span>
				<span class="middot">·</span>
				<span><?php echo($wo['thread']['replies']); ?>  <?php echo $wo['lang']['replies']; ?></span>
			</div>
		</div>
		<div class="col-md-3 no-padding-right no-padding-left">
			<span class="btn-glossy">
				<a class="btn btn-main btn-mat btn-mat-raised <?php echo Wo_RightToLeft('pull-right') ?>" href="<?php echo Wo_SeoLink('index.php?link1=threadreply&tid='.$wo['thread']['id']);?>" data-ajax="?link1=threadreply&tid=<?php echo $wo['thread']['id'];?>"><?php echo $wo['lang']['reply_to_topic']; ?></a>
			</span>
		</div>
		<div class="clear"></div>
	</div>
	<div>
		<div class="thread-replies wow_thread_main_reply">
			<div class="t-left_prt text-center">
				<div>
					<a href="<?php echo ($wo['thread']['user_data']['url']); ?>" data-ajax="?link1=timeline&u=<?php echo $wo['thread']['user_data']['username']; ?>"><img src="<?php echo $wo['thread']['user_data']['avatar']; ?>" alt="Avatar" class="avatar"></a>
				</div>
				<a href="<?php echo ($wo['thread']['user_data']['url']); ?>" data-ajax="?link1=timeline&u=<?php echo $wo['thread']['user_data']['username']; ?>">
					<h4 class="user-title-thread"><?php echo ($wo['thread']['user_data']['name']); ?></h4>
				</a>
				<hr>
				<p class="small mb0" title="<?php echo $wo['lang']['joined']; ?>"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M19,19H5V8H19M16,1V3H8V1H6V3H5C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5C21,3.89 20.1,3 19,3H18V1M17,12H12V17H17V12Z" /></svg> <?php echo Wo_Time_Elapsed_String($wo['thread']['user_data']['joined']); ?></p>
			</div>
			<div class="t-right_prt">
				<div>
					<h5 class="time"><?php echo $wo['lang']['posted']; ?>: <i class="fa fa-clock-o" aria-hidden="true"></i> <?php echo Wo_Time_Elapsed_String($wo['thread']['posted']); ?></h5>
				</div>
				<div class="small">
					<?php echo Wo_BbcodeToHtml($wo['thread']['post']); ?>
				</div>
			</div>
			<div class="clear"></div>
			<span class="btn-glossy pull-right btn btn-default">
				<a class="btn btn-default pull-right" href="javascript:void(0)" onclick="ThreadShare(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']; ?></a>

			</span>
		</div>
		<div class="wow_thread_replies" id="thread-reply-list">
			<?php 
				if (count($wo['thread']['threadreplies']) > 0) {
					foreach ($wo['thread']['threadreplies'] as $wo['threadreply']) {
						echo Wo_LoadPage("forum/includes/threadreply-list");
					}
				}
			?>
			<div class="clear"></div>
		</div>
	</div>
	<div class="">
	    <div class="posts_load">
	        <?php if (count($wo['thread']['threadreplies']) >= 1): ?>
	        <div class="load-more">
	            <button class="btn btn-default text-center wo_load_more" id="load-thread-replies" >
					<span><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M7.41,8.58L12,13.17L16.59,8.58L18,10L12,16L6,10L7.41,8.58Z"></path></svg></span> <?php echo $wo['lang']['load_more_posts'] ?>
				</button>
	        </div>
	        <?php endif ?>
	    </div>  
	</div>
</div>
<div class="clear"></div>
<?php echo Wo_LoadPage('forum/includes/delete-reply'); ?>
<?php echo Wo_LoadPage('forum/headers/footer'); ?>
<div class="modal fade in" id="thread-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']['thread_shared']; ?>
        </p>
      </div>
      
    </div>
</div>
<script>
	function ThreadShare(self) {
		$("#thread-shared").modal('show');
		$(self).attr('disabled', 'true');
		$.post(Wo_Ajax_Requests_File() + '?f=thread_share&hash_id=' + $('.main_session').val(), {id: <?php echo $wo['thread']['id']; ?>}, function(data, textStatus, xhr) {
			setTimeout(function (argument) {
				$(self).removeAttr('disabled');
				$("#thread-shared").modal('hide');
			},2000);
		});
	}


	$('#forum-messages-search').submit(function(event) {

		if (true) {}
		event.preventDefault()
	    $.ajax({
          url: Wo_Ajax_Requests_File()  +  '?f=forum-messages-search&tid=<?php echo $wo['thread']['id']; ?>',
          data:$(this).serialize(),
          type: 'GET',
          dataType: 'json',
          beforeSend: function() {
            Wo_progressIconLoader($('#forum-messages-search').find('button'));
          },
          success: function(data) {
            $(".posts_load").remove()
            if (data['status'] == 200) {
  	
                $("#thread-reply-list").html(data['html']);
               
              
            } else {
                
                $("#thread-reply-list").html('<h5 class="search-filter-center-text">' + data['html'] + '</h5>');
            } 
            Wo_progressIconLoader($('#quotereply').find('button'));
          }
        });
    });


      $("#load-thread-replies").click(function () {
        $.ajax({
             url: Wo_Ajax_Requests_File(),
             type: 'GET',
             dataType: 'json',
             data: {
                f:"load-thread-replies",
                tid:<?php echo $wo['thread']['id']; ?>,
                offset:($(".thread-replies").length > 0) ? $(".thread-replies:last").attr('data-thread-reply') : 0

             },
             success:function(data){
                
                if (data['status'] == 200) {
                	
                    $("#thread-reply-list").append(data['html'])
                 }
                 else{

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

             }
          });
      });

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

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

      delay(function(){
      if ($("#forum-messages-search").val().trim()) {
	      $.ajax({
	        url: Wo_Ajax_Requests_File(),
	        type: 'GET',
	        data: {	f:"forum-messages-search",
	        		keyword:$("#forum-messages-search").val(),
	        		tid:<?php echo $wo['thread']['id']; ?>
	        	},
	        dataType: "json",
	        success: function(data){
	          if (data['status'] == 200) {
	          	$("#thread-reply-list").html(data['html']);
	          	$(".posts_load").remove()
	          }
	          else if(data['status'] == 404){
	         	$("#thread-reply-list").html('<h5 class="search-filter-center-text">' + data['html'] + '</h5>');
	         	$(".posts_load").remove()
	          }
	        }
	      })}

      }, 1000 );
  	});

</script>

