diff options
Diffstat (limited to 'src/application/views')
| -rw-r--r-- | src/application/views/form_login.php | 4 | ||||
| -rw-r--r-- | src/application/views/form_newtopic.php | 34 | ||||
| -rw-r--r-- | src/application/views/form_register.php | 40 | ||||
| -rw-r--r-- | src/application/views/nav_logged_in.php | 4 | ||||
| -rw-r--r-- | src/application/views/template_end.php | 25 | ||||
| -rw-r--r-- | src/application/views/template_navigation_start.php | 2 | ||||
| -rw-r--r-- | src/application/views/template_start.php | 14 | ||||
| -rw-r--r-- | src/application/views/view_post.php | 32 | ||||
| -rw-r--r-- | src/application/views/view_topic_start.php | 96 | ||||
| -rw-r--r-- | src/application/views/view_user.php | 29 | 
10 files changed, 206 insertions, 74 deletions
| diff --git a/src/application/views/form_login.php b/src/application/views/form_login.php index 8ddb22e..27924e8 100644 --- a/src/application/views/form_login.php +++ b/src/application/views/form_login.php @@ -9,7 +9,9 @@ if ($lastFormUri !== $_SERVER["REQUEST_URI"]) $lastForm = [];  RequestUtils::clearLastForm();  ?> -<h1>Log in</h1> +<div class="page-header margin-top-0"> +    <h1>Log in</h1> +</div>  <div class="col-md-4"></div>  <div class="well col-md-4">  <?php diff --git a/src/application/views/form_newtopic.php b/src/application/views/form_newtopic.php index d5cbfbd..2e58268 100644 --- a/src/application/views/form_newtopic.php +++ b/src/application/views/form_newtopic.php @@ -3,22 +3,32 @@  use mystic\forum\Messaging;  use mystic\forum\utils\RequestUtils; -if (($_formError = RequestUtils::getAndClearFormError()) !== null) { -    Messaging::error($_formError); -} -  $lastFormUri = "";  $lastForm = RequestUtils::getLastForm($lastFormUri) ?? [];  if ($lastFormUri !== $_SERVER["REQUEST_URI"]) $lastForm = [];  RequestUtils::clearLastForm();  ?> -<form action="<?= htmlentities($_SERVER["REQUEST_URI"]) ?>" method="post"> -<strong>Topic title:</strong><br> -<input type="text" name="title" value="<?= htmlentities($lastForm["title"] ?? "") ?>" required><br> - -<strong>Message:</strong><br> -<textarea name="message" rows="12" cols="60" required></textarea><br> - -<button type="submit">Create topic</button> +<div class="page-header margin-top-0"> +    <h1>New topic</h1> +</div> +<?php +if (($_formError = RequestUtils::getAndClearFormError()) !== null) { +    _view("alert_error", ["message" => $_formError]); +} +?> +<form action="<?= htmlentities($_SERVER["REQUEST_URI"]) ?>#form" method="post" enctype="multipart/form-data"> +<div class="form-group"> +    <label for="i_message">Topic title:</label> +    <input type="text" class="form-control" id="i_title" name="title" value="<?= htmlentities($lastForm["title"] ?? "") ?>" required autofocus> +</div> +<div class="form-group"> +    <label for="i_message">Message:</label> +    <textarea class="form-control" id="i_message" name="message" required rows="12" cols="60" style="resize:vertical;max-height:499px"><?= htmlentities($lastForm["message"] ?? "") ?></textarea> +</div> +<div class="form-group"> +    <label for="i_files">Attachments: <small>(max. <?= htmlentities(MAX_ATTACHMENT_COUNT) ?> files, max. <?= htmlentities(MAX_ATTACHMENT_SIZE >> 20) ?> MiB each)</small></label> +    <input type="file" name="files[]" id="i_files" multiple accept="*/*"> +</div> +<button type="submit" class="btn btn-success">Create topic</button>  </form> diff --git a/src/application/views/form_register.php b/src/application/views/form_register.php index 221f37d..6f62652 100644 --- a/src/application/views/form_register.php +++ b/src/application/views/form_register.php @@ -9,7 +9,9 @@ if ($lastFormUri !== $_SERVER["REQUEST_URI"]) $lastForm = [];  RequestUtils::clearLastForm();  ?> -<h1>Register</h1> +<div class="page-header margin-top-0"> +    <h1>Register</h1> +</div>  <div class="col-md-4"></div>  <div class="well col-md-4">  <?php @@ -18,31 +20,49 @@ if (($_formError = RequestUtils::getAndClearFormError()) !== null) {  }  ?>  <form action="<?= htmlentities($_SERVER["REQUEST_URI"]) ?>" method="post"> -<div class="form-group"> +<div class="form-group" id="group0">      <label for="i_username">Username:</label>      <input class="form-control" id="i_username" type="text" name="username" value="<?= htmlentities($lastForm["username"] ?? "") ?>" required>  </div> -<div class="form-group"> +<div class="form-group" id="group1"> +    <label for="i_username">Username:</label> +    <input class="form-control" id="i_username" type="text" name="df82a9bc21" value="<?= htmlentities($lastForm["username"] ?? "") ?>" required> +</div> + +<div class="form-group" id="group2">      <label for="i_display_name">Display name:</label>      <input class="form-control" id="i_display_name" type="text" name="display_name" value="<?= htmlentities($lastForm["display_name"] ?? "") ?>" required>  </div> -<div class="form-group"> +<div class="form-group" id="group3">      <label for="i_password">Choose password:</label>      <input class="form-control" id="i_password" type="password" name="password" required>  </div> -<div class="form-group"> +<div class="form-group" id="group4">      <label for="i_password_retype">Repeat password:</label>      <input class="form-control" id="i_password_retype" type="password" name="password_retype" required>  </div> -<div class="form-group"> +<div class="form-group" id="group5">      <label for="i_email">Email address:</label>      <input class="form-control" id="i_email" type="email" name="email" value="<?= htmlentities($lastForm["email"] ?? "") ?>" required>  </div> +<div class="form-group" id="group6"> +    <label for="i_email">CAPTCHA:</label> +    <div class="text-center margin-bottom"> +        <img src="?_action=captcha&t=<?= htmlentities(strval(microtime(true) * 1000)) ?>" alt="CAPTCHA" width="192" height="48" id="captcha-img"> +    </div> +    <div class="input-group"> +        <input type="text" name="captcha" id="i_captcha" class="form-control" required> +        <div class="input-group-btn"> +            <button class="btn btn-default" type="button" id="btn-refresh-captcha"><span class="glyphicon glyphicon-refresh" aria-hidden="true"></span><span class="sr-only">New CAPTCHA</span></button> +        </div> +    </div> +</div> +  <div class="form-group">      <button class="btn btn-default" type="submit">Register now</button>  </div> @@ -53,3 +73,11 @@ if (($_formError = RequestUtils::getAndClearFormError()) !== null) {  </form>  </div>  <div class="col-md-4"></div> + +<script> +$(function() { +    $("#btn-refresh-captcha").click(function() { +        $("#captcha-img").attr("src", "?_action=captcha&t=" + new Date().getTime().toString()); +    }); +}); +</script> diff --git a/src/application/views/nav_logged_in.php b/src/application/views/nav_logged_in.php index f899ad8..8ed8d07 100644 --- a/src/application/views/nav_logged_in.php +++ b/src/application/views/nav_logged_in.php @@ -9,6 +9,6 @@ use mystic\forum\orm\User;  <strong><?= htmlentities($user->displayName) ?></strong>!  <?php endif; ?>  </p></li> -<li><a href="?_action=viewuser&user=<?= htmlentities(urlencode($user->id)) ?>"><span class="glyphicon glyphicon-user" aria-hidden="true"><span class="sr-only">View profile</span></a></li> -<li><a href="?_action=logout&next=<?= htmlentities(urlencode($_SERVER["REQUEST_URI"])) ?>"><span class="glyphicon glyphicon-log-out" aria-hidden="true"><span class="sr-only">Log out</span></a></li> +<li><a href="?_action=viewuser&user=<?= htmlentities(urlencode($user->id)) ?>"><span class="glyphicon glyphicon-user" aria-hidden="true"></span><span class="sr-only">View profile</span></a></li> +<li><a href="?_action=logout&next=<?= htmlentities(urlencode($_SERVER["REQUEST_URI"])) ?>"><span class="glyphicon glyphicon-log-out" aria-hidden="true"></span><span class="sr-only">Log out</span></a></li>  </ul> diff --git a/src/application/views/template_end.php b/src/application/views/template_end.php index 27fc3ba..7757780 100644 --- a/src/application/views/template_end.php +++ b/src/application/views/template_end.php @@ -3,7 +3,8 @@  <div class="container">  <div class="panel panel-default">  <div class="panel-body"> -    © <?= date("Y") ?> +    © <?= date("Y") ?> <?= htmlentities(env("MYSTIC_FORUM_COPYRIGHT") ?? env("MYSTIC_FORUM_TITLE") ?? "Forum") ?>. +    Powered by <a href="https://git.jkohl.link/mystic-forum.git/">Mystic Forum</a>  </div>  </div>  </div> @@ -23,6 +24,28 @@ $(function() {          var date = new Date($(e).text());          $(e).text(date.toLocaleTimeString());      }); + +    $("input[type=file]").each(function(i, e) { +        var isMultiple = !!$(e).prop("multiple"); +        var $input = $('<input type="text" readonly class="form-control" />').attr("placeholder", "No file" + (isMultiple ? "s" : "") + " selected"); +        $(e).after($('<div class="input-group file-input-group"></div>').append( +            $input, +            $('<span class="input-group-btn"></span>').append( +                $('<button class="btn btn-default" type="button"></button>').text("Select file" + (isMultiple ? "s" : "") + "...").click(function() { +                    $(e).click(); +                }) +            ) +        )).addClass("sr-only"); +        $(e).on("change", function() { +            var files = $(e)[0].files; +            if (files.length < 1) +                $input.val(""); +            else if (files.length === 1) +                $input.val(files[0].name); +            else +                $input.val(files.length + " files selected"); +        }); +    })  });  </script> diff --git a/src/application/views/template_navigation_start.php b/src/application/views/template_navigation_start.php index 48cdb9a..3c69bf4 100644 --- a/src/application/views/template_navigation_start.php +++ b/src/application/views/template_navigation_start.php @@ -7,6 +7,6 @@                  <span class="icon-bar"></span>                  <span class="icon-bar"></span>              </button> -            <a class="navbar-brand" href=".">Forum</a> +            <a class="navbar-brand" href="."><?= htmlentities(env("MYSTIC_FORUM_TITLE") ?? "Forum") ?></a>          </div>          <div class="collapse navbar-collapse" id="nav-collapse"> diff --git a/src/application/views/template_start.php b/src/application/views/template_start.php index 4cfdb74..56af9bf 100644 --- a/src/application/views/template_start.php +++ b/src/application/views/template_start.php @@ -1,3 +1,11 @@ +<?php + +$pageTitle = ""; +if (isset($_title) && $_title !== null) +    $pageTitle = "$_title | "; +$pageTitle .= env("MYSTIC_FORUM_TITLE") ?? "Forum"; + +?>  <!DOCTYPE html>  <!--[if lt IE 7]>      <html lang="de" class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->  <!--[if IE 7]>         <html lang="de" class="no-js lt-ie9 lt-ie8"> <![endif]--> @@ -5,10 +13,10 @@  <!--[if gt IE 8]><!--> <html lang="de" class="no-js"> <!--<![endif]-->  <head>      <meta charset="utf-8"> -    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> +    <meta http-equiv="X-UA-Compatible" content="IE=edge">      <meta name="viewport" content="width=device-width,initial-scale=1"> -    <title><?= htmlentities($_title ?? "") ?></title> -    <link rel="stylesheet" href="/ui/theme-default.css"> +    <title><?= htmlentities($pageTitle) ?></title> +    <link rel="stylesheet" href="/themes/<?= env("MYSTIC_FORUM_THEME") ?? "default" ?>/theme.css">      <script src="/ui/jquery-1.12.4.min.js"></script>      <script src="/ui/dist/js/bootstrap.min.js"></script>      <script src="/ui/modernizr-2.6.2.min.js"></script> diff --git a/src/application/views/view_post.php b/src/application/views/view_post.php index 5022d4a..26eec62 100644 --- a/src/application/views/view_post.php +++ b/src/application/views/view_post.php @@ -3,11 +3,17 @@  use mystic\forum\orm\UserPermissions;  use mystic\forum\orm\Attachment; +/** @var mystic\forum\orm\Post $post */ +/** @var mystic\forum\orm\User $postAuthor */ +  $fileAttachments = array_filter($attachments, fn(Attachment $a) => !str_starts_with($a->mimeType, "image/"));  $imageAttachments = array_filter($attachments, fn(Attachment $a) => str_starts_with($a->mimeType, "image/"));  $canReply = $GLOBALS["currentUser"]?->hasPermission(UserPermissions::CREATE_OWN_POST) ?? false; +$canEdit = ($GLOBALS["currentUser"]?->id === $postAuthor?->id && $postAuthor?->hasPermission(UserPermissions::EDIT_OWN_POST)) +        || ($GLOBALS["currentUser"]?->hasPermission(UserPermissions::EDIT_OTHER_POST)); +  $canDelete = ($GLOBALS["currentUser"]?->id === $postAuthor?->id && $postAuthor?->hasPermission(UserPermissions::DELETE_OWN_POST))            || ($GLOBALS["currentUser"]?->hasPermission(UserPermissions::DELETE_OTHER_POST)); @@ -30,15 +36,15 @@ $your_are_the_author = $GLOBALS["currentUser"]?->id === $postAuthor?->id;  </div>  </div>  <?php else: ?> -<div class="media" id="post-<?= htmlentities($post->id) ?>"> +<div class="media" id="post-<?= htmlentities($post->id) ?>" data-text="<?= htmlentities($post->content) ?>">  <?php if (!$hide_pfp): ?>      <div class="media-left hidden-sm hidden-xs">          <?php if ($postAuthor): ?>              <?php if ($hide_actions): ?> -                <img class="media-object" alt="Profile picture" src="?_action=profilepicture&user=<?= htmlentities(urlencode($postAuthor->id)) ?>" alt="" width="64" height="64"> +                <img class="media-object" alt="Profile picture" src="?_action=profilepicture&user=<?= htmlentities(urlencode($postAuthor->id)) ?>" width="64" height="64">              <?php else: ?>                  <a href="?_action=viewuser&user=<?= htmlentities(urlencode($postAuthor->id)) ?>"> -                    <img class="media-object" alt="Profile picture" src="?_action=profilepicture&user=<?= htmlentities(urlencode($postAuthor->id)) ?>" alt="" width="64" height="64"> +                    <img class="media-object" alt="Profile picture" src="?_action=profilepicture&user=<?= htmlentities(urlencode($postAuthor->id)) ?>" width="64" height="64">                  </a>              <?php endif; ?>          <?php else: ?> @@ -49,12 +55,15 @@ $your_are_the_author = $GLOBALS["currentUser"]?->id === $postAuthor?->id;      <div class="media-body">          <div class="panel panel-default">              <div class="panel-heading"> -                <h3 class="panel-title"> +                <div class="panel-title h3">                      <?php if (!$hide_actions): ?>                      <div class="pull-right"> -                        <?php if ($canReply): ?>                          <a href="#post-<?= htmlentities(urlencode($post->id)) ?>" class="btn btn-default"><span class="glyphicon glyphicon-link" aria-hidden="true"></span><span class="sr-only">Permalink</span></a> -                        <button data-text="<?= htmlentities($post->content) ?>" class="btn btn-default js-only _reply-post"><span class="glyphicon glyphicon-share-alt" aria-hidden="true"></span><span class="sr-only">Reply to post</span></button> +                        <?php if ($canReply): ?> +                            <button data-post-id="<?= htmlentities($post->id) ?>" class="btn btn-default js-only _reply-post"><span class="glyphicon glyphicon-share-alt" aria-hidden="true"></span><span class="sr-only">Reply to post</span></button> +                        <?php endif; ?> +                        <?php if ($canEdit): ?> +                            <button data-post-id="<?= htmlentities($post->id) ?>" class="btn btn-default js-only _edit-post"><span class="glyphicon glyphicon-pencil" aria-hidden="true"></span><span class="sr-only">Edit post</span></button>                          <?php endif; ?>                          <?php if ($canDelete): ?>                              <form action="?_action=deletepost" method="post" class="seamless-inline"> @@ -76,21 +85,24 @@ $your_are_the_author = $GLOBALS["currentUser"]?->id === $postAuthor?->id;                      <?php else: ?>                          <em class="text-muted">(deleted)</em>                      <?php endif; ?> -                </h3> +                </div>                  <span class="_time"><?= $post->postDate->format("c"); ?></span> +                <?php if ($post->edited): ?> +                    <em class="text-muted">(edited)</em> +                <?php endif; ?>              </div>              <div class="panel-body"> -                <div class="post-content"><?= renderPost($post->content) ?></div> +                <div class="post-content"><?= renderPost(trim($post->content)) ?></div>                  <?php if (count($imageAttachments) > 0): ?>                  <div class="post-images clearfix">                      <?php /** @var Attachment $attachment */ foreach ($imageAttachments as $attachment): ?>                          <?php if ($hide_actions): ?>                              <span class="image-attachment" title="<?= htmlentities($attachment->name) ?>"> -                                <img class="image-attachment-image" src="?_action=thumb&attachment=<?= htmlentities(urlencode($attachment->id)) ?>" alt="" width="110"> +                                <img class="image-attachment-image" src="?_action=thumb&attachment=<?= htmlentities(urlencode($attachment->id)) ?>" alt="" width="100">                              </span>                          <?php else: ?>                              <a class="image-attachment" href="?_action=attachment&attachment=<?= htmlentities(urlencode($attachment->id)) ?>" title="<?= htmlentities($attachment->name) ?>"> -                                <img class="image-attachment-image" src="?_action=thumb&attachment=<?= htmlentities(urlencode($attachment->id)) ?>" alt="" width="110"> +                                <img class="image-attachment-image" src="?_action=thumb&attachment=<?= htmlentities(urlencode($attachment->id)) ?>" alt="" width="100">                              </a>                          <?php endif; ?>                      <?php endforeach; ?> 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> diff --git a/src/application/views/view_user.php b/src/application/views/view_user.php index 23d2b71..79b57d2 100644 --- a/src/application/views/view_user.php +++ b/src/application/views/view_user.php @@ -26,13 +26,13 @@ $dateJoined = DateTime::createFromImmutable($user->created);  $dateJoined->setTime(0, 0, 0, 0);  ?> -<div class="clearfix"> +<div class="clearfix page-header margin-top-0">      <img class="pull-left margin-right" src="?_action=profilepicture&user=<?= htmlentities(urlencode($user->id)) ?>">      <span class="h1"><?= htmlentities($user->displayName) ?></span>      <?php if ($isOwnProfile): ?>          <span class="label label-primary">You</span>      <?php endif; ?><br> -    @<?= htmlentities($user->name) ?> • <span class="text-muted">Member since <span class="_date"><?= htmlentities($dateJoined->format("c")); ?></span> +    @<?= htmlentities($user->name) ?> • <span class="text-muted">Member since <span class="_date"><?= htmlentities($dateJoined->format("c")); ?></span></span>  </div>  <?php if ($canEdit): ?> @@ -97,18 +97,22 @@ if (($_formError = RequestUtils::getAndClearFormError()) !== null) {          <label>Profile picture:</label>  <?php  $_checkbox_disabled = empty($user->profilePicture); -$_checkbox_disabled_class = $_checkbox_disabled ? " disabled" : ""; +$_checkbox_disabled_class = $_checkbox_disabled ? " disabled text-muted" : "";  ?>          <div class="radio margin-top-0 <?= $_checkbox_disabled_class ?>">              <label>                  <input type="radio" name="pfp_action" id="pfp_action_1" value="keep"<?= !empty($user->profilePicture) ? ' checked' : ' disabled' ?>> -                Existing profile picture +                Keep current profile picture              </label>          </div>          <div class="radio">              <label>                  <input type="radio" name="pfp_action" id="pfp_action_2" value="remove"<?= empty($user->profilePicture) ? ' checked' : '' ?>> -                No profile picture +                <?php if (empty($user->profilePicture)): ?> +                    No profile picture +                <?php else: ?> +                    Remove profile picture +                <?php endif; ?>              </label>          </div>          <div class="radio"> @@ -141,12 +145,19 @@ $(function() {  });  <?php if ($canEdit): ?>  $(function() { -    $("#i_pfp").hide().prop("disabled", true).prop("required", false); +    function _hide() { +        $("#i_pfp").hide().prop("disabled", true).prop("required", false); +        $("#i_pfp + .file-input-group").hide().find("button").prop("disabled", true); +    } +    _hide(); +    setTimeout(_hide, 10);      $("[name='pfp_action']").on("change input check click", function() { -        if ($("#pfp_action_3").is(":checked")) +        if ($("#pfp_action_3").is(":checked")) {              $("#i_pfp").show().prop("disabled", false).prop("required", true); -        else -            $("#i_pfp").hide().prop("disabled", true).prop("required", false); +            $("#i_pfp + .file-input-group").show().find("button").prop("disabled", false); +        } else { +            _hide(); +        }      })  });  <?php endif; ?> |