<form method="POST" action="/article/save"  style="height: 100%;">
	<input type="hidden" name="id" value="<?= $article->id ?>" />
	<input type="hidden" name="allowComments" value="1" />
<!--	<input type="checkbox" name="allowComments" id="articleComments" <?= $article->allowComments ? 'checked' : '' ?> />Разрешить комментарии-->

	<table style="height: 100%; width: 100%" class="<?= (isset($_COOKIE["disableAutoview"]) && $_COOKIE["disableAutoview"] == 'true')?'singleEditor':'doubleEditor' ?>" id="mainEditorTable">
		<tr  style="height: 1%;">
			<td colspan="2">
				<div class="form-group" style="margin-bottom: -1px;">
					<div class="col-md-12 nopaddingx">
						<input type="text" name="title" id="articleTitle" class="form-control" value="<?= $article->title ?>" placeholder="Заголовок..." />
					</div>
				</div>
			</td>
		</tr>
		<tr  style="height: 1%;">
			<td colspan="2" style="padding: 5px 10px 0 10px;">
				<div class="btn-group pull-right" role="group">
					<?php if ($article->id): ?>
						<a href="/article/<?= $article->id ?>" target="_blank" class="btn btn-sm btn-default" title="Просмотр последней сохраненой версии"><span class="glyphicon glyphicon-eye-open" aria-hidden="true"></span> предпросмотр</a>
					<?php endif; ?>
					<a href="/user/" class="btn btn-sm btn-danger" onclick="return confirm('Несохраненные изменения будут утеряны! Выйти?')" title="Выйти без сохранения"><span class="glyphicon glyphicon-floppy-remove" aria-hidden="true"></span> выйти из редактора</a>
				</div>
				<div class="btn-group" role="group">
					<?php if ($article->status == 'draft') : ?>
						<button type="submit" class="btn btn-sm btn-default" name="save" value="published" title="Сохранить"><span class="glyphicon glyphicon-floppy-saved"></span> сохранить и опубликовать</button>
					<?php endif; ?>
					<button type="submit" id="submitButton" class="btn btn-sm btn-default" name="save" value="save" title="Сохранить изменения"><span class="glyphicon glyphicon-floppy-disk"></span> сохранить<?= ($article->status == 'draft') ? ' черновик' : '' ?></button>
				</div>
				<div class="btn-group" role="group">
					<button type="button" class="btn btn-default btn-sm" title="Жирый" onclick="markBold()"><b>Ж</b></button>
					<button type="button" class="btn btn-default btn-sm" title="Курсив" onclick="markItalic()"><i>К</i></button>
					<button type="button" class="btn btn-default btn-sm" title="Подчеркивание" onclick="markUnderline()"><u>П</u></button>
					<button type="button" class="btn btn-default btn-sm" title="Фото или картинка" onclick="togglePhotobank()"><span class="glyphicon glyphicon-camera" aria-hidden="true"></span></button>
					<button type="button" class="btn btn-default btn-sm" title="Ссылка на точку" onclick="insertPoint()"><span class="glyphicon glyphicon-map-marker" aria-hidden="true"></span></button>
					<button type="button" class="btn btn-default btn-sm" title="Подсказка по разметке" onclick="$('#articleInfoModal').modal('show');"><span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> разметка</button>
				</div>
				<div class="btn-group" role="group">
					<button type="button" id="autoviewSwitcher" class="btn btn-default btn-sm <?= (isset($_COOKIE["disableAutoview"]) && $_COOKIE["disableAutoview"] == 'true')?'':'active' ?>" title="Автопросмотр" onclick="toggleAutoview()">Автопросмотр</button>
				</div>
			</td>
		</tr>
		<tr  style="height: 99%;" class="main">
			<td>
				<textarea name="text" id="articleText" class="form-control"  onscroll="monitor.scrollTop=scrollTop" style="height: 100%; min-height: 100px; padding-top: 4px; resize: none;" ><?= $article->text ?></textarea>
			</td>
			<td id="monitorContainer"><div id="monitor" style=""></div></td>
		</tr>
	</table>
</form>

<div id="photobankContainer">
	<span class="glyphicon glyphicon-remove pull-right" style="color: #fff; margin: 5px;font-size: 18px; cursor: pointer;" onclick="togglePhotobank()" aria-hidden="true"></span>
	<div style="margin: 5px 10px;">
		<form enctype="multipart/form-data" id="articlePhotoloader" action="/images/loadPhoto" method="POST" name="loadavatar" target="hiddenframe"  class="form-inline">
			<input type="hidden" name="MAX_FILE_SIZE" value="5242880" />
			<div class="form-group">
				<label style="color: white;">Загрузить новое изображение (MAX 5MB) (jpg, png)</label>
			</div>
			<br/>
			<div class="form-group">
				<input id="photo" name="photo" type="file" class="form-control" accept=".jpg,.png,.jpeg" />
			</div>
			<div class="form-group">
				<input id="caption" name="caption" type="text" class="form-control" placeholder="Описание (по желанию)" />
			</div>
			<div class="form-group">
				<button type="submit" class="btn btn-sm btn-default">Загрузить на сервер</button>
			</div>
		</form>
	</div>
	<div class="col-md-12" id="photobank"></div>
</div>
<iframe id="hiddenframe" name="hiddenframe" style="width:0px; height:0px; border:0px" onload="$(document).ready(function () {
			updatePhotobank()
		})"></iframe>
<?= self::renderPartial('modals/articleInfo.php', array(), true) ?>
