<div class="page-margin">
	<div class="row">
		<div class="col-md-2 leftcol"><?php echo Wo_LoadPage("sidebar/left-sidebar"); ?></div>
		<div class="col-md-7 middlecol wo-create-forms">
            <div class="wo_settings_page">
				<div class="sun_head_onboard shortpwidth">
					<img class="sho_img" src="<?php echo $wo['config']['theme_url'];?>/img/cads/status.svg" alt="<?php echo $wo['lang']['status'] ?>" />
					<div class="sun_head_onboard_innr">
						<h2><?php echo $wo['lang']['create_new_status'];?></h2>
					</div>
				</div>
				
				<form class="create-user-story form-horizontal" method="post">
					<div class="publisher-hidden-option">
						<div id="progress">
							<span id="percent">0%</span>
							<div class="progress">
								<div id="bar" class="progress-bar progress-bar-striped active"></div> 
							</div>
							<div class="clear"></div>
						</div>
					</div>
					<div class="setting-panel row">
						<div class="form-group col-lg-12">
							<label class="col-md-12" for="about"><?php echo $wo['lang']['whats_going'];?></label>  
							<div class="col-md-12">
								<textarea name="description" id="" rows="3" class="form-control input-md"></textarea>
							</div>
						</div>
						<div class="form-group col-lg-12">
							<label class="col-md-12" for="group_name"><?php echo $wo['lang']['select'];?> *</label>
      						<div class="col-md-12" title="Select media">
      							<div id="select-status-media">
      								<p class="img">			
      									<span>
											<span style="display:block">
											<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-image"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><circle cx="8.5" cy="8.5" r="1.5"></circle><polyline points="21 15 16 10 5 21"></polyline></svg>
											</span>
											<?php echo $wo['lang']['select']; ?>
											<?php echo $wo['lang']['photos']; ?> &amp; <?php echo $wo['lang']['videos']; ?>
										</span>
      									
      								</p>
      							</div>
      						</div>
						</div>
						<div class="form-group hidden col-lg-12" id="user-story-total">
							<label class="col-md-12"></label>  
							<div class="col-md-12">
								<input type="text" class="form-control input-md bg_read_input" readonly>
							</div>
						</div>
						<div class="form-group col-lg-12" id="custom_thumbnail" style="display: none;">
							<label class="col-md-12" for="group_name"><?php echo $wo['lang']['custom_thumbnail'];?></label>
      						<div class="col-md-12" title="Select media">
      							<div id="select-status-media-2">
      								<p class="img">			
      									<span>
											<span style="display:block">
											<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-image"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><circle cx="8.5" cy="8.5" r="1.5"></circle><polyline points="21 15 16 10 5 21"></polyline></svg>
											</span>
											<?php echo $wo['lang']['select']; ?>
											<?php echo $wo['lang']['photos']; ?>
										</span>
      									
      								</p>
      							</div>
      						</div>
      						<div class="form-group hidden col-lg-12" id="user-story-total-2">
								<label class="col-md-12"></label>  
								<div class="col-md-12">
									<input type="text" class="form-control input-md bg_read_input" readonly>
								</div>
							</div>
						</div>
						
					</div>
					 
					<div class="create-status-alert hidden">
						<div class="alert alert-danger">
                           <p><?php echo $wo['lang']['max_number_status'] ?></p>
                        </div>
					</div>
					
					<div class="form-group last-sett-btn modal-footer">
                        <div class="ball-pulse"><div></div><div></div><div></div></div>
						<button type="submit" class="btn btn-main setting-panel-mdbtn"><?php echo $wo['lang']['create'];?></button>
					</div>

					<input type="file" name="statusMedia[]" class="hidden" id="user-storymedia">
					<input type="file" name="cover" class="hidden" id="user-storymedia-2">
				</form>
			</div>
		</div>
		<!-- .col-md-8 -->
		<?php echo Wo_LoadPage('sidebar/content');?>
	</div>
	<!-- .row -->
</div>

<script>
	function getExtension(filename) {
	  var parts = filename.split('.');
	  return parts[parts.length - 1];
	}
   jQuery(document).ready(function($) {
      $("#user-storymedia").change(function () {
        var numFiles = this.files.length;

        if (numFiles > 20) {
         $("#user-storymedia").val('');
         $(".create-status-alert").removeClass('hidden');
        }
        else{
            $("#user-story-total input").val(numFiles + ' file(s) selected');
            $("#user-story-total").removeClass('hidden').slideDown(200);
        }
        var ext = getExtension(this.files[0].name);
	    switch (ext.toLowerCase()) {
		    case 'm4v':
		    case 'avi':
		    case 'mpg':
		    case 'mp4':
		    return $('#custom_thumbnail').slideDown();
	    }
	    $('#custom_thumbnail').slideUp();

      });
      $("#user-storymedia-2").change(function () {
        var numFiles = this.files.length;
        if (numFiles > 20) {
         $("#user-storymedia-2").val('');
         $(".create-status-alert").removeClass('hidden');
        }
        else{
            $("#user-story-total-2 input").val(numFiles + ' file(s) selected');
            $("#user-story-total-2").removeClass('hidden').slideDown(200);
        }

      });

      $("#select-status-media").click(function(event) {
         $("#user-storymedia").click();
      });

      $("#select-status-media-2").click(function(event) {
         $("#user-storymedia-2").click();
      });
      var bar = $('#bar');
	  var percent = $('#percent');

      $('.create-user-story').ajaxForm({
       url: Wo_Ajax_Requests_File() + '?f=status&s=new',
       type:"POST",
       beforeSend: function() {
       	var percentVal = '0%';
        bar.width(percentVal);
        percent.html(percentVal);
        $('.wo_settings_page').find('.last-sett-btn .ball-pulse').fadeIn(100);
       },
       uploadProgress: function (event, position, total, percentComplete) {
           var percentVal = percentComplete + '%';
           bar.width(percentVal);
           $('#progress').slideDown(200);
           if(percentComplete > 50) {
             percent.addClass('white');
           }
           percent.html(percentVal);
      },
       success: function(data) {
        scrollToTop();
        if (data['status'] == 200) {
          $(".create-status-alert").removeClass('hidden').html('<div class="alert alert-success">'+ data['message'] +'</div>');
          window.location = '<?php echo $wo['config']['site_url']; ?>';
        } 

        else if (data['message']) {
          $(".create-status-alert").removeClass('hidden').html('<div class="alert alert-danger">' + data['message'] + '</div>');
        } 
        else{
        	if(data.invalid_file == 3){
	          $("#adult_image_file").modal('show');
	          Wo_Delay(function(){
	            $("#adult_image_file").modal('hide');
	          },3000);
	        }
        }

        $('.wo_settings_page').find('.last-sett-btn .ball-pulse').fadeOut(100);
      }});

   });
</script>