{include file="left.tpl"}

<link rel="stylesheet" href="../templates/admin/css/timepicker.css">

<script src="../modules/editors/tinymce/tinymce.min.js"></script>
<script>
	jQuery(document).ready(function($)
	{
		init_tinymce('text', 'forum', '{file_manager_theme}', '{file_manager}', '<? echo md5($conf->code); ?>');

		$('#msgsmile').popover({html: true, animation: true, trigger: 'click'});
		$('#msgsmile').on('show.bs.popover', function()
		{
			$(document).mouseup(function(e)
			{
				var container = $('.popover-content');

				if(container.has(e.target).length === 0)
				{
					$('#msgsmile').popover('hide');

					selected = 'gcms_smiles';
				}
			});
		});

		get_smiles('#msgsmile', 1);

		$('#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();
		});

		load_forums_list('{forum_id}');
	});

	function set_smile(elem)
	{
		var smile = '<img src="'+$(elem).attr('src')+'" class="g_smile" height="20px" width="20px"> ';

		tinymce.activeEditor.insertContent(smile);

		selected = 'gcms_smiles';
	}
</script>

<div class="content float-right">
	<div class="block">
		<div class="header">Редактирование темы</div>
		<div class="block-content">
			<div class="form-input">
				<label for="forums">Форум</label>
				<div id="forums_list"></div>
				<div class="btn float-left m-t-5" onclick="edit_topic_forum('{id}')">Изменить</div>

				<div class="clear"></div>
			</div>
			<div class="form-input">
				<label for="status">Статус</label>
				<select id="status">
					<option value="1" <? if('{status}'=='1') echo 'selected'; ?>>Открыта</option>
					<option value="2" <? if('{status}'=='2') echo 'selected'; ?>>Закрыта</option>
					<option value="3" <? if('{status}'=='3') echo 'selected'; ?>>Закреплена</option>
					<option value="4" <? if('{status}'=='4') echo 'selected'; ?>>Закреплена и закрыта</option>
				</select>
				<div class="btn float-left m-t-5" onclick="edit_topic_status('{id}')">Изменить</div>

				<div class="clear"></div>
			</div>

			<div class="space"></div>

			<div class="upload-image">
				<img id="pic" src="../{img}" class="float-left">
				<form enctype="multipart/form-data" action="ajax/actions_a.php" method="post" id="add_img_form" class="float-right">
					<input type="hidden" id="token" name="token" value="{token}">
					<input type="hidden" id="add_topic_img" name="add_topic_img" value="1">
					<input type="hidden" id="phpaction" name="phpaction" value="1">
					<input class="imginput" type="file" id="img" accept="image/*" name="img">
					<div class="space"></div>
					<div class="btn float-left" onclick="$('#add_img_form').submit()">Загрузить</div>
					<div id="img_result"></div>
				</form>
			</div>
			<div class="clear"></div>
			<div class="form-input">
				<label for="name">Название</label>
				<input type="text" id="name" maxlength="250" autocomplete="off" value="{name}">
			</div>
			<div class="form-input">
				<label for="input_keywords">Текст темы</label>
				<textarea id="text" rows="10">{text}</textarea>
			</div>
			<div class="message-send">
				<i class="fa fa-smile-o" data-container="body" data-content="empty" data-placement="top" data-toggle="popover" id="msgsmile"></i>

				<div class="btn float-right" onclick="edit_topic('{id}')">Сохранить</div>
			</div>
		</div>
	</div>
</div>