<style>

	.left_block {width:100%;}
</style>
<div class="r_block">
	<div class="r_block_head">
		Редактирование темы
	</div> 
	<div class="r_block_c">
		{if(is_worthy("e"))}
		<div class="form-group">
			<label for="input_keywords">
				<h4>
					<span class="glyphicon glyphicon-th"></span> Форум
				</h4>
			</label>
			<div id="forums_list"></div>
			<script>load_forums_list('{forum_id}');</script>
		</div>
		<button id="create_btn2" onclick="edit_topic_forum('{id}');" type="button" class="btn2">Изменить</button><br>
		<hr>
		<div class="form-group">
			<label for="input_keywords">
				<h4>
					<span class="glyphicon glyphicon-tag"></span> Статус
				</h4>
			</label>
			<select id="status" class="form-control">
				<option value="1" {if('{status}'=='1')} selected {/if}>Открыта</option>
				<option value="2" {if('{status}'=='2')} selected {/if}>Закрыта</option>
				<option value="3" {if('{status}'=='3')} selected {/if}>Закреплена</option>
				<option value="4" {if('{status}'=='4')} selected {/if}>Закреплена и закрыта</option>
			</select>
		</div>
		<button id="create_btn3" onclick="edit_topic_status('{id}');" type="button" class="btn2">Изменить</button><br>
		<hr>
		{/if}
		<div class="form-group">
			<label for="img">
				<h4>
					Изображение
				</h4>
			</label>
			<div class="row">
				<div class="col-md-3">
					<img id="pic" src="../{img}" class="wh80x80">
				</div>
				<div class="col-md-9">
					<div class="input-group">
						<form enctype="multipart/form-data" action="ajax/actions_a.php" method="POST" id="add_img_form">
							<input type="hidden" id="token" name="token" value="{token}">
							<input type="hidden" id="id" name="id" value="{id}">
							<input type="hidden" id="add_topic_img" name="add_topic_img" value="1">
							<input type="hidden" id="phpaction" name="phpaction" value="1">
							<input class="input-file w100 mb-5" type="file" id="img" accept="image/*" name="img"/><br>
							<input class="btn2" type="submit" value="Загрузить">
							<button onclick="edit_topic('{id}');" type="button" class="btn2">Сохранить</button>
							<div id="img_result">
								<input value="{img}" type="hidden" id="topic_img" maxlength="255" autocomplete="off">
							</div>
						</form>
					</div>
				</div>
			</div>
			<script>
				$("#add_img_form").submit(function (event){
					NProgress.start();
					event.preventDefault();
					var data = new FormData($('#add_img_form')[0]);
					$.ajax({
						type: "POST",
						url: "../ajax/actions_a.php",
						data: data,
						contentType: false,
						processData: false,
					}).done(function (html) {
						$("#img_result").empty();
						$("#img_result").append(html);
						$('#add_img_form')[0].reset();
					});
					NProgress.done();
				});
			</script>
		</div>
		<div class="form-group">
			<label for="name">
				<h4>
					<span class=" glyphicon glyphicon-italic"></span> Название
				</h4>
			</label>
			<input type="text" class="form-control" id="name" maxlength="250" autocomplete="off" value="{name}">
		</div>
		<div class="form-group">
			<label for="input_keywords">
				<h4>
					<span class="glyphicon glyphicon-pencil"></span> Текст темы
				</h4>
			</label>
			<textarea id="text" class="form-control maxMinW100" rows="10">{text}</textarea>
		</div>
		<div id="topic_result" class="mt-10"></div>
		<div class="smile_input_forum">
			<button id="create_btn" onclick="edit_topic('{id}');" type="button" class="btn2">Изменить</button>
			<div id="smile_btn" class="smile_btn visible-lg-inline-block type2" data-container="body" data-toggle="popover" data-placement="top" data-content="empty"></div>
		</div>
	</div>
</div>
<script>
	$(document).ready(function() {
		init_tinymce("text", "forum", "{file_manager_theme}", "{file_manager}", "{{md5($conf->code)}}");
		get_smiles('#smile_btn', 1);
	});

	$('#smile_btn').popover({ html: true, animation: true, trigger: "click" });
	$('#smile_btn').on('show.bs.popover', function () {
		$(document).mouseup(function (e) {
			var container = $(".popover-content");
			if (container.has(e.target).length === 0){
				$('#smile_btn').popover('hide'); selected = 'gcms_smiles';
			}
		});
	});

	function set_smile(elem){
		var smile =  "<img src=\""+$(elem).attr("src")+"\" class=\"g_smile\" height=\"20px\" width=\"20px\">";
		tinymce.activeEditor.insertContent(smile);
		$('#smile_btn').popover('hide'); selected = 'gcms_smiles';
	}
</script>