diff options
author | Jonas Kohl | 2024-09-14 17:59:13 +0200 |
---|---|---|
committer | Jonas Kohl | 2024-09-14 17:59:13 +0200 |
commit | d8b74761c6cefdd83360d3f2add0e9ccdc6064c7 (patch) | |
tree | 5e2c947b4a90ae475a7e75897077246e5ea0a948 /src/application/views/view_topic_start.php | |
parent | 948cead0f11d33adbcf0d08773c716e1b6ebb101 (diff) |
Even more changes (devel commit messages are useless)
Diffstat (limited to 'src/application/views/view_topic_start.php')
-rw-r--r-- | src/application/views/view_topic_start.php | 96 |
1 files changed, 67 insertions, 29 deletions
diff --git a/src/application/views/view_topic_start.php b/src/application/views/view_topic_start.php index 4006982..37e8cf8 100644 --- a/src/application/views/view_topic_start.php +++ b/src/application/views/view_topic_start.php @@ -9,30 +9,63 @@ $canEdit = ($GLOBALS["currentUser"]?->id === $topicAuthor->id && $topicAuthor->h $canDelete = ($GLOBALS["currentUser"]?->id === $topicAuthor->id && $topicAuthor->hasPermission(UserPermissions::DELETE_OWN_TOPIC)) || ($GLOBALS["currentUser"]?->hasPermission(UserPermissions::DELETE_OTHER_TOPIC)); ?> +<?php if ($canEdit): ?> + <div class="modal fade" tabindex="-1" role="dialog" id="diag-edit-post"> + <form class="modal-dialog" role="document" action="?_action=updatepost" method="post"> + <input type="hidden" id="i_edit_post" name="post"> + <div class="modal-content"> + <div class="modal-header"> + <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> + <h4 class="modal-title">Edit post</h4> + </div> + <div class="modal-body"> + <div class="form-group"> + <label class="sr-only" for="i_edit_message">Message:</label> + <textarea class="form-control" name="message" id="i_edit_message" rows="12" style="resize: vertical; max-height: 500px"></textarea> + </div> + </div> + <div class="modal-footer"> + <button type="button" class="btn btn-default" data-dismiss="modal"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span> Cancel</button> + <button type="submit" class="btn btn-success"><span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span> Save changes</button> + </div> + </div> + </form> + </div> +<?php endif; ?> + <div class="page-header margin-top-0 clearfix"> - <div role="heading" class="h1 margin-top-0" id="displayHeading"> - <?= htmlentities($topic->title) ?> - <div class="pull-right"> - <?php if ($canEdit): ?> - <button id="btn-edit-title" class="btn btn-default js-only"><span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Edit title</button> - <?php endif; ?> - <?php if ($canReply): ?> - <button id="btn-reply" class="btn btn-default js-only"><span class="glyphicon glyphicon-share-alt" aria-hidden="true"></span> Reply</button> - <?php endif; ?> - <?php if ($canDelete): ?> - <form action="?_action=deletetopic" method="post" class="seamless-inline"> - <input type="hidden" name="topic" value="<?= htmlentities($topic->id) ?>"> - <button type="submit" class="btn btn-danger"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Delete topic</button> - </form> - <?php endif; ?> - </div> + <div id="displayHeading"> + <div role="heading" class="h1 seamless-inline"> + <?= htmlentities($topic->title) ?> + <div class="pull-right text-normal"> + <?php if ($canEdit): ?> + <button id="btn-edit-title" class="btn btn-default js-only"><span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Edit title</button> + <?php endif; ?> + <?php if ($canReply): ?> + <button id="btn-reply" class="btn btn-default js-only"><span class="glyphicon glyphicon-share-alt" aria-hidden="true"></span> Reply</button> + <?php endif; ?> + <?php if ($canDelete): ?> + <form action="?_action=deletetopic" method="post" class="seamless-inline"> + <input type="hidden" name="topic" value="<?= htmlentities($topic->id) ?>"> + <button type="submit" class="btn btn-danger"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Delete topic</button> + </form> + <?php endif; ?> + </div> + </div><br> + Started by + <?php if ($topicAuthor !== null): ?> + <a href="?_action=viewuser&user=<?= htmlentities(urlencode($topicAuthor->id)) ?>"><?= htmlentities($topicAuthor->displayName) ?></a> + <?php else: ?> + <em>(deleted)</em> + <?php endif; ?> + on <span class="_time"><?= htmlentities($topic->creationDate->format("c")) ?></span> </div> <?php if ($canEdit): ?> <form action="?_action=updatetopic" method="post" id="editHeading" style="display: none;" class="form-inline seamless-inline" style="display: block"> <input type="hidden" name="topic" value="<?= htmlentities(urlencode($topic->id)) ?>"> <div class="row"> <div class="col-md-8"> - <input type="text" class="form-control" name="title" id="i_edit_title" value="<?= htmlentities($topic->title) ?>" style="box-sizing: border-box; width: 100%"> + <input type="text" class="form-control" name="title" id="i_edit_title" data-original-value="<?= htmlentities($topic->title) ?>" value="<?= htmlentities($topic->title) ?>" style="box-sizing: border-box; width: 100%; font-size: 36px; height: 56px"> </div> <div class="col-md-4 text-right"> <button type="button" id="topicTitleEditCancel" class="btn btn-default"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span> Cancel</button> @@ -42,22 +75,13 @@ $canDelete = ($GLOBALS["currentUser"]?->id === $topicAuthor->id && $topicAuthor- </form> <?php endif; ?> </div> -<p> -Started by -<?php if ($topicAuthor !== null): ?> -<a href="?_action=viewuser&user=<?= htmlentities(urlencode($topicAuthor->id)) ?>"><?= htmlentities($topicAuthor->displayName) ?></a> -<?php else: ?> -<em>(deleted)</em> -<?php endif; ?> -on <span class="_time"><?= htmlentities($topic->creationDate->format("c")) ?></span> -</p> <script> <?php if ($canEdit): ?> $(function() { $("#btn-edit-title").click(function() { $("#displayHeading").hide(); $("#editHeading").show(); - $("#i_edit_title").focus(); + $("#i_edit_title").val($("#i_edit_title").attr("data-original-value")).focus(); }); $("#topicTitleEditCancel").click(function() { $("#displayHeading").show(); @@ -76,7 +100,7 @@ $(function() { focusReplyBox(); }); $("._reply-post").click(function() { - var text = $(this).attr("data-text"); + var text = $("#post-" + $(this).attr("data-post-id")).attr("data-text"); var val = $("#i_message").val(); var lines = text.split("\n"); for (var i = 0; i < lines.length; ++i) @@ -86,5 +110,19 @@ $(function() { focusReplyBox(); }); }); -</script> <?php endif; ?> +<?php if ($canEdit): ?> +$(function() { + $("._edit-post").click(function() { + var $post = $("#post-" + $(this).attr("data-post-id")); + var $postContent = $post.find(".post-content"); + $("#i_edit_message").css("height", "").val($post.attr("data-text")); + $("#i_edit_post").val($(this).attr("data-post-id")); + $("#diag-edit-post").modal(); + }); + $("#diag-edit-post").on("shown.bs.modal", function() { + $("#i_edit_message").focus(); + }); +}); +<?php endif; ?> +</script> |