{include file="left.tpl"}

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

<script src="../modules/editors/tinymce/tinymce.min.js"></script>
<script src="../templates/admin/js/timepicker/timepicker.js"></script>
<script src="../templates/admin/js/timepicker/jquery-ui-timepicker-addon.js"></script>
<script src="../templates/admin/js/timepicker/jquery-ui-timepicker-addon-i18n.min.js"></script>
<script>
	jQuery(document).ready(function($)
	{
		init_tinymce('text', 'full', '{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_b.php',
				data: data,
				contentType: false,
				processData: false,
			}).done(function (html){
				$('#img_result').empty();
				$('#img_result').append(html);
				$('#add_img_form')[0].reset();
			});

			NProgress.done();
		});

		$('#publish_date').datetimepicker(
		{
			timeInput: true,
			dateFormat: 'dd.mm.yy',
			timeFormat: 'HH:mm'
		});
	});

	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="upload-image">
				<img id="img" 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_new_img" name="add_new_img" value="1">
					<input type="hidden" id="phpaction" name="phpaction" value="1">
					<input class="imginput" type="file" id="new_img" accept="image/*" name="new_img">
					<div class="space"></div>
					<div class="btn float-left" onclick="$('#add_img_form').submit()">Загрузить</div>
					<div class="btn float-left m-l-25" onclick="change_new('{id}')">Сохранить</div>
					<div id="img_result"><input value="{img}" type="hidden" id="input_img" maxlength="255" autocomplete="off"></div>
				</form>
			</div>
			<div class="clear"></div>
			<div class="form-input">
				<label for="class">Категория</label>
				<select id="class">{classes}</select>
			</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="short_text">Краткое описание</label>
				<textarea id="short_text" rows="3" maxlength="250">{short_text}</textarea>
			</div>
			<div class="form-input">
				<label for="input_keywords">Текст новости</label>
				<textarea id="text" rows="10">{text}</textarea>
			</div>
			<div class="form-input">
				<label for="publish_date">Когда опубликовать</label>
				<input type="text" id="publish_date" value="{date}">
			</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="change_new('{id}')">Сохранить</div>
			</div>
		</div>
	</div>
</div>