<div class="container-home">
	<h3 class="recent-articles heading_all_sections_top">
		<span>
			<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path d="M16.6256 3.12837L9.29145 10.4625L9.29886 14.7097L13.537 14.7022L20.8682 7.37102C21.5912 8.75426 22 10.3277 22 11.9966C22 17.5194 17.5228 21.9966 12 21.9966C6.47715 21.9966 2 17.5194 2 11.9966C2 6.47373 6.47715 1.99658 12 1.99658C13.6689 1.99658 15.2423 2.40541 16.6256 3.12837ZM20.4853 2.09709L21.8995 3.5113L12.7071 12.7037L11.2954 12.7062L11.2929 11.2895L20.4853 2.09709Z" fill="currentColor"></path></svg>
			{{LANG edit_article}}: {{TITLE}}
		</span>
	</h3>
	
	
	<div class="row">
		<div class="col-md-8" id="edit-form">
			<div class="upload_video_bg_color">
			<div id="video-success" class="alert alert-success"></div>
			<div class="errors alert alert-danger"></div>
			<form action="" class="step_2_form" method="POST">
				<div class="form-group">
					<label for="title">{{LANG title}}</label>  
						<input id="title" name="title" type="text" value="{{TITLE}}" class="form-control input-md">
				</div>
				<div class="form-group">
					<label for="description">{{LANG descritpion}}</label>  
						<textarea name="description" id="description" cols="30" rows="10" class="form-control">{{DESC}}</textarea>
				</div>
				<div class="form-group">
						<label for="text">{{LANG the_article}}</label>  
							<textarea name="text" id="text" class="form-control">{{TEXT}}</textarea>
					</div>
				<div class="form-group">
					<label for="category_id">{{LANG category}}</label>  
						<select name="category" id="category_id" class="form-control">
							<?php foreach($pt->categories as $key => $category) { $selected = ($pt->article->category == $key) ? 'selected' : '';?>
							<option value="<?php echo $key?>" <?php echo $selected?>><?php echo $category?></option>
							<?php } ?>
						</select>
				</div>
				<div class="form-group">
					<label for="tags">{{LANG tags}}</label>  
						<input id="mySingleFieldTags" name="tags" type="text" value="{{TAGS}}" placeholder="" class="form-control input-md">
				</div>
				<span class="help-block">{{LANG tags_help}}</span>
				<div class="form-group hidden">
					<label for="thumbnail">{{LANG thumbnail}}</label>  
						<input id="thumbnail" name="image" type="file" accept="image/*">
						<span class="help-block">jpg, png, gif</span>
				</div>
				<div class="">
					<button type="submit" id="submit-btn" class="btn btn-main upload_custom_new">{{LANG publish}}</button>&nbsp;&nbsp;
					<button type="button" class="btn btn-delete upload_custom_new" onclick="PT_DeleteArticle({{ID}});">{{LANG delete}}</button>
				</div>
				<input type="hidden" name="id" class="id" value="{{ID}}">
			</form>
			</div>
		</div>
		<div class="col-md-4">
			<div class="upload_video_bg_color">
				<div class="pt_upload_vdo_preview">
					<div class="pt_upload_vdo_thumb">
						<div class="thumbnail-preview edit-thumb thumbnail-preview-renderer">
							<img src="{{IMAGE}}" alt="{{TITLE}}">
						</div>
					</div>
					
					<div class="video-title">
						<p>{{TITLE}}</p>
					</div>
					<div class="video-description">
						<p></p>
					</div>
				</div>
			</div>
		</div>
		<div class="clear"></div>
	<div class="clear"></div>
</div>
</div>

<script src="{{CONFIG theme_url}}/js/tinymce/js/tinymce/tinymce.min.js"></script>
<script>
	tinymce.init({
          selector: '#text',  // change this value according to your HTML
          auto_focus: 'element1',
          relative_urls: false,
          remove_script_host: false,
          height:500,
          toolbar: 'insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image  uploadImages |  preview media fullpage | forecolor backcolor emoticons',
          plugins: [
              'advlist autolink link image  lists charmap  preview hr anchor pagebreak spellchecker',
              'searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking',
              'save table contextmenu directionality emoticons template paste textcolor'
          ]
        });
function PT_DeleteArticle(id) {
	  if (!id) {
	    return false;
	  }
	  if (!confirm("{{LANG delete_article_text}}")) {
	    return false;
	  }
	  $.post('{{LINK aj/articles/delete-article}}', {id: id}, function(data, textStatus, xhr) {
	    if (data.status == 200) {
	        window.location.href = '{{LINK my_articles}}';
	    }
	  });
	}

$(function () {
	$('.edit-thumb').on('click', function(event) {
		$('#thumbnail').trigger('click');
	});
	$('#thumbnail').on('change', function(event) {
		readURL(this);
	});
   $('#title').keyup(function(event) {
      $('.video-title p').html($(this).val());
   });
	$("#mySingleFieldTags").tagit({
		allowSpaces: true
	});
	$('#edit-form form').ajaxForm({
	    url: '{{LINK aj/articles/update-article}}?hash=' + $('.main_session').val(),
	    beforeSend: function() {
	    	$('#submit-btn').attr('disabled', true);
	    	$('#submit-btn').text("{{LANG please_wait}}");
	    },
	    success: function(data) {
	    	if (data.status == 200) {
	    		$('#video-success').html("{{LANG reviewed_article}}");
                window.location.href = data.url;
	    	} else {
	    		$('#submit-btn').attr('disabled', false);
	    	    $('#submit-btn').html('<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-check-circle"><path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"></path><polyline points="22 4 12 14.01 9 11.01"></polyline></svg> {{LANG publish}}');
	    		$('.errors').removeClass('hidden').html(data.message);
	    	}
	    }
	});
});
</script>