wikipoints/views/tracks/edit.php

57 lines
2.1 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<a href="/tracks/" class="btn btn-success pull-right">
<span class="glyphicon glyphicon-home" aria-hidden="true"></span>
Выйти из редактора
</a>
<h3>Редактор треков</h3>
<form onfocusout="saveChangesTrip()">
<div class="form-group">
<label for="tripName">Название трека</label>
<input type="text" class="form-control" id="tripName" placeholder="Великолепное путешествие <?= date('Y') ?>" value="<?= $trip->name ?>">
</div>
<div class="form-group">
<label for="tripDescription">Описание Трека</label>
<input type="text" class="form-control" id="tripDescription" placeholder="Это было незабываемое путешествие!..." value="<?= $trip->description ?>">
</div>
<a href="/edittrack/delete/id/<?= $trip->id ?>" class="btn btn-danger pull-right" onclick="return confirm('Вы уверены, что хотите удалить трек?')">
<span class="glyphicon glyphicon-trash" aria-hidden="true"></span>
Удалить трек
</a>
<div class="checkbox">
<label>
<input type="checkbox" id="tripIsPublic" <?= ($trip->status == Trips::STATUS_PUBLIC) ? 'checked="checked"' : '' ?>> Публичный трек (его могут видеть другие пользователи)
</label>
</div>
<span id="tripSavedOK" style="color: #999; display: none;">изменения сохранены...</span>
<span id="tripSavedError" style="color: #900; display: none;">при сохранении возникла ошибка!</span>
</form>
<script lang="javascript">
function saveChangesTrip()
{
$('#tripSavedOK').hide();
$('#tripSavedError').hide();
$.ajax({
url: "/edittrack/trip/id/<?= $trip->id ?>",
method: "POST",
data: {
name: $('#tripName').val(),
description: $('#tripDescription').val(),
isPublic: $('#tripIsPublic').prop('checked')
},
success: function (data) {
$('#tripSavedOK').show();
setTimeout(function () {
$('#tripSavedOK').fadeOut(300);
}, 2000);
},
error: function (data) {
$('#tripSavedError').show();
}
});
}
</script>