Apply suggestions from code review
[GitHub/WoltLab/com.woltlab.wcf.conversation.git] / templates / conversationList.tpl
index d2f4f7b377a2c302fa7491c1dfc1f1274d9ce710..8a3d928c7c446eb726b41ccd5f350a35da53d5f7 100644 (file)
                        <nav class="contentHeaderNavigation">
                                <ul>
                                        {content}
-                                               {if $__wcf->session->getPermission('user.conversation.canStartConversation')}<li><a href="{link controller='ConversationAdd'}{/link}" title="{lang}wcf.conversation.add{/lang}" class="button"><span class="icon icon16 fa-plus"></span> <span>{lang}wcf.conversation.button.add{/lang}</span></a></li>{/if}
+                                               {if $__wcf->session->getPermission('user.conversation.canStartConversation')}
+                                                       <li>
+                                                               <a href="{link controller='ConversationAdd'}{/link}" title="{lang}wcf.conversation.add{/lang}" class="button buttonPrimary">
+                                                                       {icon name='plus'}
+                                                                       <span>{lang}wcf.conversation.button.add{/lang}</span>
+                                                               </a>
+                                                       </li>
+                                               {/if}
                                                {event name='contentHeaderNavigation'}
                                        {/content}
                                </ul>
@@ -59,7 +66,7 @@
                                
                                <div class="formSubmit">
                                        <input type="submit" value="{lang}wcf.global.button.submit{/lang}" accesskey="s">
-                                       {@SECURITY_TOKEN_INPUT_TAG}
+                                       {csrfToken}
                                </div>
                        </form>
                </div>
@@ -74,7 +81,7 @@
                                        {if $labelID}
                                                {foreach from=$labelList item=label}
                                                        {if $label->labelID == $labelID}
-                                                               <span class="badge label{if $label->cssClassName} {@$label->cssClassName}{/if}">{$label->label}</span>
+                                                               <span class="badge label{if $label->cssClassName} {$label->cssClassName}{/if}">{$label->label}</span>
                                                        {/if}
                                                {/foreach}
                                        {else}
@@ -85,7 +92,7 @@
                                <div class="dropdownMenu">
                                        <ul class="scrollableDropdownMenu">
                                                {foreach from=$labelList item=label}
-                                                       <li><a href="{link controller='ConversationList'}{if $filter}filter={@$filter}&{/if}{if !$participants|empty}participants={implode from=$participants item=participant}{$participant|rawurlencode}{/implode}&{/if}sortField={$sortField}&sortOrder={$sortOrder}&pageNo={@$pageNo}&labelID={@$label->labelID}{/link}"><span class="badge label{if $label->cssClassName} {@$label->cssClassName}{/if}" data-css-class-name="{if $label->cssClassName}{@$label->cssClassName}{/if}" data-label-id="{@$label->labelID}">{$label->label}</span></a></li>
+                                                       <li><a href="{link controller='ConversationList'}{if $filter}filter={@$filter}&{/if}{if !$participants|empty}participants={implode from=$participants item=participant}{$participant|rawurlencode}{/implode}&{/if}sortField={$sortField}&sortOrder={$sortOrder}&pageNo={@$pageNo}&labelID={@$label->labelID}{/link}"><span class="badge label{if $label->cssClassName} {@$label->cssClassName}{/if}" data-css-class-name="{if $label->cssClassName}{@$label->cssClassName}{/if}" data-label-id="{$label->labelID}">{$label->label}</span></a></li>
                                                {/foreach}
                                        </ul>
                                        <ul>
                </div>
                
                <div class="boxContent">
-                       <button id="manageLabel">{lang}wcf.conversation.label.management{/lang}</button>
+                       <button type="button" id="manageLabel" class="button">{lang}wcf.conversation.label.management{/lang}</button>
                </div>
        </section>
        
                <div class="boxContent">
                        {assign var='conversationCount' value=$__wcf->getConversationHandler()->getConversationCount()}
                        {assign var='maxConversationCount' value=$__wcf->session->getPermission('user.conversation.maxConversations')}
-                       <p class="conversationUsageBar{if $conversationCount/$maxConversationCount >= 1.0} red{elseif $conversationCount/$maxConversationCount > 0.9} yellow{/if}">
-                               <span style="width: {if $conversationCount/$maxConversationCount < 1.0}{@$conversationCount/$maxConversationCount*100|round:0}{else}100{/if}%">{#$conversationCount/$maxConversationCount*100}%</span>
-                       </p>
+                       {assign var='conversationCountValue' value=$conversationCount/$maxConversationCount*100}
+                       <meter class="conversationQuotaMeter" min="0" max="100" low="90" high="99" value="{$conversationCountValue|ceil}" aria-label="{lang}wcf.conversation.quota{/lang}">
+                               {#$conversationCountValue}&nbsp;%
+                       </meter>
                        <p><small>{lang}wcf.conversation.quota.description{/lang}</small></p>
                </div>
        </section>
        {event name='boxes'}
 {/capture}
 
-{capture assign='headerNavigation'}
-       <li><a rel="alternate" href="{link controller='ConversationFeed'}at={@$__wcf->getUser()->userID}-{@$__wcf->getUser()->accessToken}{/link}" title="{lang}wcf.global.button.rss{/lang}" class="jsTooltip"><span class="icon icon16 fa-rss"></span> <span class="invisible">{lang}wcf.global.button.rss{/lang}</span></a></li>
-       <li class="jsOnly"><a href="#" title="{lang}wcf.conversation.markAllAsRead{/lang}" class="markAllAsReadButton jsTooltip"><span class="icon icon16 fa-check"></span> <span class="invisible">{lang}wcf.conversation.markAllAsRead{/lang}</span></a></li>
+{capture assign='contentInteractionPagination'}
+       {assign var='participantsParameter' value=''}
+       {if $participants}{capture assign='participantsParameter'}&participants={implode from=$participants item=participant}{$participant|rawurlencode}{/implode}{/capture}{/if}
+       {assign var='labelIDParameter' value=''}
+       {if $labelID}{assign var='labelIDParameter' value="&labelID=$labelID"}{/if}
+       {pages print=true assign=pagesLinks controller='ConversationList' link="filter=$filter$participantsParameter&pageNo=%d&sortField=$sortField&sortOrder=$sortOrder$labelIDParameter"}
 {/capture}
 
-{include file='header'}
+{capture assign='contentInteractionButtons'}
+       <button type="button" class="markAllAsReadButton contentInteractionButton button small jsOnly">
+               {icon name='check'}
+               <span>{lang}wcf.global.button.markAllAsRead{/lang}</span>
+       </button>
+{/capture}
 
-{hascontent}
-       <div class="paginationTop">
-               {content}
-                       {assign var='participantsParameter' value=''}
-                       {if $participants}{capture assign='participantsParameter'}&participants={implode from=$participants item=participant}{$participant|rawurlencode}{/implode}{/capture}{/if}
-                       {assign var='labelIDParameter' value=''}
-                       {if $labelID}{assign var='labelIDParameter' value="&labelID=$labelID"}{/if}
-                       {pages print=true assign=pagesLinks controller='ConversationList' link="filter=$filter$participantsParameter&pageNo=%d&sortField=$sortField&sortOrder=$sortOrder$labelIDParameter"}
-               {/content}
-       </div>
-{/hascontent}
+{capture assign='contentInteractionDropdownItems'}
+       <li><a rel="alternate" href="{link controller='ConversationFeed'}at={@$__wcf->getUser()->userID}-{@$__wcf->getUser()->accessToken}{/link}">{lang}wcf.global.button.rss{/lang}</a></li>
+{/capture}
+
+{include file='header'}
 
 {if !$items}
        <p class="info" role="status">{lang}wcf.conversation.noConversations{/lang}</p>
                                                <ul class="inlineList">
                                                        <li>
                                                                <a rel="nofollow" href="{link controller='ConversationList'}{if $filter}filter={@$filter}&{/if}{if !$participants|empty}participants={implode from=$participants item=participant}{$participant|rawurlencode}{/implode}&{/if}pageNo={@$pageNo}&sortField={$sortField}&sortOrder={if $sortOrder == 'ASC'}DESC{else}ASC{/if}{if $labelID}&labelID={@$labelID}{/if}{/link}">
-                                                                       <span class="icon icon16 fa-sort-amount-{$sortOrder|strtolower} jsTooltip" title="{lang}wcf.global.sorting{/lang} ({lang}wcf.global.sortOrder.{if $sortOrder === 'ASC'}ascending{else}descending{/if}{/lang})"></span>
+                                                                       {if $sortOrder === 'ASC'}
+                                                                               <span class="jsTooltip" title="{lang}wcf.global.sorting{/lang} ({lang}wcf.global.sortOrder.ascending{/lang})">
+                                                                                       {icon name='arrow-down-wide-short'}
+                                                                               </span>
+                                                                       {else}
+                                                                               <span class="jsTooltip" title="{lang}wcf.global.sorting{/lang} ({lang}wcf.global.sortOrder.descending{/lang})">
+                                                                                       {icon name='arrow-down-short-wide'}
+                                                                               </span>
+                                                                       {/if}
                                                                </a>
                                                        </li>
                                                        <li>
                        
                        {foreach from=$objects item=conversation}
                                <li class="tabularListRow">
-                                       <ol class="tabularListColumns messageGroup conversation jsClipboardObject{if $conversation->isNew()} new{/if}" data-conversation-id="{@$conversation->conversationID}" data-label-ids="[ {implode from=$conversation->getAssignedLabels() item=label}{@$label->labelID}{/implode} ]" data-is-closed="{@$conversation->isClosed}" data-can-close-conversation="{if $conversation->userID == $__wcf->getUser()->userID}1{else}0{/if}" data-can-add-participants="{if $conversation->canAddParticipants()}1{else}0{/if}">
+                                       <ol class="tabularListColumns messageGroup conversation jsClipboardObject{if $conversation->isNew()} new{/if}" data-conversation-id="{$conversation->conversationID}" data-label-ids="[ {implode from=$conversation->getAssignedLabels() item=label}{$label->labelID}{/implode} ]" data-is-closed="{$conversation->isClosed}" data-can-close-conversation="{if $conversation->userID == $__wcf->getUser()->userID}1{else}0{/if}" data-can-add-participants="{if $conversation->canAddParticipants()}1{else}0{/if}">
                                                <li class="columnMark jsOnly">
-                                                       <label><input type="checkbox" class="jsClipboardItem" data-object-id="{@$conversation->conversationID}"></label>
+                                                       <label><input type="checkbox" class="jsClipboardItem" data-object-id="{$conversation->conversationID}"></label>
                                                </li>
                                                <li class="columnIcon columnAvatar">
                                                        {if $conversation->getUserProfile()->getAvatar()}
                                                        {/hascontent}
                                                                
                                                        <h3>
-                                                               <a href="{if $conversation->isNew()}{link controller='Conversation' object=$conversation}action=firstNew{/link}{else}{link controller='Conversation' object=$conversation}{/link}{/if}" class="conversationLink messageGroupLink" data-conversation-id="{@$conversation->conversationID}">{$conversation->subject}</a>
+                                                               <a href="{if $conversation->isNew()}{link controller='Conversation' object=$conversation}action=firstNew{/link}{else}{$conversation->getLink()}{/if}" class="conversationLink messageGroupLink" data-object-id="{$conversation->conversationID}">{$conversation->subject}</a>
                                                                {if $conversation->replies}
                                                                        <span class="badge messageGroupCounterMobile">{@$conversation->replies|shortUnit}</span>
                                                                {/if}
                                                        
                                                        <aside class="statusDisplay" role="presentation">
                                                                <ul class="statusIcons">
-                                                                       {if $conversation->isClosed}<li><span class="icon icon16 fa-lock jsIconLock jsTooltip" title="{lang}wcf.global.state.closed{/lang}"></span></li>{/if}
-                                                                       {if $conversation->attachments}<li><span class="icon icon16 fa-paperclip jsIconAttachment jsTooltip" title="{lang}wcf.conversation.attachments{/lang}"></span></li>{/if}
+                                                                       {if $conversation->isClosed}
+                                                                               <li>
+                                                                                       <span class="jsIconLock jsTooltip" title="{lang}wcf.global.state.closed{/lang}">
+                                                                                               {icon name='lock'}
+                                                                                       </span>
+                                                                               </li>
+                                                                       {/if}
+                                                                       {if $conversation->attachments}
+                                                                               <li>
+                                                                                       <span class="jsIconAttachment jsTooltip" title="{lang}wcf.conversation.attachments{/lang}">
+                                                                                               {icon name='paperclip'}
+                                                                                       </span>
+                                                                               </li>
+                                                                       {/if}
                                                                </ul>
                                                        </aside>
                                                        
                                                        <ul class="inlineList dotSeparated small messageGroupInfo">
-                                                               <li class="messageGroupAuthor">{if $conversation->userID}<a href="{link controller='User' object=$conversation->getUserProfile()->getDecoratedObject()}{/link}" class="userLink" data-user-id="{@$conversation->userID}">{$conversation->username}</a>{else}{$conversation->username}{/if}</li>
-                                                               <li class="messageGroupTime">{@$conversation->time|time}</li>
+                                                               <li class="messageGroupAuthor">{user object=$conversation->getUserProfile()}</li>
+                                                               <li class="messageGroupTime">{time time=$conversation->time}</li>
                                                                <li class="messageGroupEditLink jsOnly"><a href="#" class="jsConversationInlineEditor">{lang}wcf.global.button.edit{/lang}</a></li>
                                                                {event name='messageGroupInfo'}
                                                        </ul>
                                                        
                                                        <ul class="messageGroupInfoMobile">
                                                                <li class="messageGroupAuthorMobile">{$conversation->username}</li>
-                                                               <li class="messageGroupLastPostTimeMobile">{@$conversation->lastPostTime|time}</li>
+                                                               <li class="messageGroupLastPostTimeMobile">{time time=$conversation->lastPostTime}</li>
                                                        </ul>
                                                        
                                                        {if $conversation->getParticipantSummary()|count}
                                                                <small class="conversationParticipantSummary">
                                                                        {assign var='participantSummaryCount' value=$conversation->getParticipantSummary()|count}
-                                                                       {lang}wcf.conversation.participants{/lang}: {implode from=$conversation->getParticipantSummary() item=participant}<a href="{link controller='User' object=$participant}{/link}" class="userLink{if $participant->hideConversation == 2} conversationLeft{/if}" data-user-id="{@$participant->userID}">{$participant->username}</a>{/implode}
+                                                                       {lang}wcf.conversation.participants{/lang}: {implode from=$conversation->getParticipantSummary() item=participant}<a href="{$participant->getLink()}" class="userLink{if $participant->hideConversation == 2} conversationLeft{/if}" data-object-id="{$participant->userID}">{$participant->username}</a>{/implode}
                                                                        {if $participantSummaryCount < $conversation->participants}{lang}wcf.conversation.participants.other{/lang}{/if}
                                                                </small>
                                                        {/if}
                                                                <dd>{@$conversation->participants|shortUnit}</dd>
                                                        </dl>
                                                        
-                                                       <div class="messageGroupListStatsSimple" aria-label="{lang}wcf.conversation.replies{/lang}">{@$conversation->replies|shortUnit}</div>
+                                                       <div class="messageGroupListStatsSimple">
+                                                               {if $conversation->replies}
+                                                                       <span aria-label="{lang}wcf.conversation.replies{/lang}">
+                                                                               {icon name='comment'}
+                                                                       </span>
+                                                                       {@$conversation->replies|shortUnit}
+                                                               {/if}
+                                                       </div>
                                                </li>
                                                <li class="columnLastPost">
                                                        {if $conversation->replies != 0 && $conversation->lastPostTime}
                                                                        
                                                                        <div>
                                                                                <p>
-                                                                                       {if $conversation->lastPosterID}
-                                                                                               <a href="{link controller='User' object=$conversation->getLastPosterProfile()->getDecoratedObject()}{/link}" class="userLink" data-user-id="{@$conversation->getLastPosterProfile()->userID}">{$conversation->lastPoster}</a>
-                                                                                       {else}
-                                                                                               {$conversation->lastPoster}
-                                                                                       {/if}
+                                                                                       {user object=$conversation->getLastPosterProfile()}
                                                                                </p>
-                                                                               <small>{@$conversation->lastPostTime|time}</small>
+                                                                               <small>{time time=$conversation->lastPostTime}</small>
                                                                        </div>
                                                                </div>
                                                        {/if}
                <nav class="contentFooterNavigation">
                        <ul>
                                {content}
-                                       {if $__wcf->session->getPermission('user.conversation.canStartConversation')}<li><a href="{link controller='ConversationAdd'}{/link}" title="{lang}wcf.conversation.add{/lang}" class="button"><span class="icon icon16 fa-plus"></span> <span>{lang}wcf.conversation.button.add{/lang}</span></a></li>{/if}
+                                       {if $__wcf->session->getPermission('user.conversation.canStartConversation')}
+                                               <li>
+                                                       <a href="{link controller='ConversationAdd'}{/link}" title="{lang}wcf.conversation.add{/lang}" class="button buttonPrimary">
+                                                               {icon name='plus'}
+                                                               <span>{lang}wcf.conversation.button.add{/lang}</span>
+                                                       </a>
+                                               </li>
+                                       {/if}
                                        {event name='contentFooterNavigation'}
                                {/content}
                        </ul>
        {/hascontent}
 </footer>
 
-<script data-relocate="true" src="{@$__wcf->getPath()}js/WCF.Conversation{if !ENABLE_DEBUG_MODE}.min{/if}.js?v={@LAST_UPDATE_TIME}"></script>
+<script data-relocate="true" src="{$__wcf->getPath()}js/WCF.Conversation{if !ENABLE_DEBUG_MODE}.min{/if}.js?v={@LAST_UPDATE_TIME}"></script>
 <script data-relocate="true">
-       require(['Language', 'WoltLabSuite/Core/Ui/ItemList/User'], function(Language, UiItemListUser) {
+       require([
+               'WoltLabSuite/Core/Language',
+               'WoltLabSuite/Core/Controller/Popover',
+               'WoltLabSuite/Core/Ui/ItemList/User',
+               'WoltLabSuite/Core/Controller/Clipboard',
+       ], (
+               Language,
+               ControllerPopover,
+               UiItemListUser,
+               ControllerClipboard
+       ) => {
                Language.addObject({
-                       'wcf.conversation.edit.addParticipants': '{lang}wcf.conversation.edit.addParticipants{/lang}',
-                       'wcf.conversation.edit.assignLabel': '{lang}wcf.conversation.edit.assignLabel{/lang}',
-                       'wcf.conversation.edit.close': '{lang}wcf.conversation.edit.close{/lang}',
-                       'wcf.conversation.edit.leave': '{lang}wcf.conversation.edit.leave{/lang}',
-                       'wcf.conversation.edit.open': '{lang}wcf.conversation.edit.open{/lang}',
-                       'wcf.conversation.edit.subject': '{lang}wcf.conversation.edit.subject{/lang}',
-                       'wcf.conversation.label.management': '{lang}wcf.conversation.label.management{/lang}',
-                       'wcf.conversation.label.management.addLabel.success': '{lang}wcf.conversation.label.management.addLabel.success{/lang}',
-                       'wcf.conversation.label.management.deleteLabel.confirmMessage': '{lang}wcf.conversation.label.management.deleteLabel.confirmMessage{/lang}',
-                       'wcf.conversation.label.management.editLabel': '{lang}wcf.conversation.label.management.editLabel{/lang}',
-                       'wcf.conversation.label.placeholder': '{lang}wcf.conversation.label.placeholder{/lang}',
-                       'wcf.conversation.leave.title': '{lang}wcf.conversation.leave.title{/lang}',
-                       'wcf.global.state.closed': '{lang}wcf.global.state.closed{/lang}',
-                       'wcf.global.subject': '{lang}wcf.global.subject{/lang}',
-                       'wcf.conversation.label.assignLabels': '{lang}wcf.conversation.label.assignLabels{/lang}'
+                       'wcf.conversation.edit.addParticipants': '{jslang}wcf.conversation.edit.addParticipants{/jslang}',
+                       'wcf.conversation.edit.assignLabel': '{jslang}wcf.conversation.edit.assignLabel{/jslang}',
+                       'wcf.conversation.edit.close': '{jslang}wcf.conversation.edit.close{/jslang}',
+                       'wcf.conversation.edit.leave': '{jslang}wcf.conversation.edit.leave{/jslang}',
+                       'wcf.conversation.edit.open': '{jslang}wcf.conversation.edit.open{/jslang}',
+                       'wcf.conversation.edit.subject': '{jslang}wcf.conversation.edit.subject{/jslang}',
+                       'wcf.conversation.label.management': '{jslang}wcf.conversation.label.management{/jslang}',
+                       'wcf.conversation.label.management.addLabel.success': '{jslang}wcf.conversation.label.management.addLabel.success{/jslang}',
+                       'wcf.conversation.label.management.deleteLabel.confirmMessage': '{jslang}wcf.conversation.label.management.deleteLabel.confirmMessage{/jslang}',
+                       'wcf.conversation.label.management.editLabel': '{jslang}wcf.conversation.label.management.editLabel{/jslang}',
+                       'wcf.conversation.label.placeholder': '{jslang}wcf.conversation.label.placeholder{/jslang}',
+                       'wcf.conversation.leave.title': '{jslang}wcf.conversation.leave.title{/jslang}',
+                       'wcf.global.state.closed': '{jslang}wcf.global.state.closed{/jslang}',
+                       'wcf.global.subject': '{jslang}wcf.global.subject{/jslang}',
+                       'wcf.conversation.label.assignLabels': '{jslang}wcf.conversation.label.assignLabels{/jslang}'
                });
                
-               WCF.Clipboard.init('wcf\\page\\ConversationListPage', {@$hasMarkedItems}, { });
+               ControllerClipboard.setup({
+                       pageClassName: 'wcf\\page\\ConversationListPage',
+                       hasMarkedItems: {if $hasMarkedItems}true{else}false{/if},
+               });
                
                var $editorHandler = new WCF.Conversation.EditorHandler();
                var $inlineEditor = new WCF.Conversation.InlineEditor('.conversation');
                
                new WCF.Conversation.Clipboard($editorHandler);
                new WCF.Conversation.Label.Manager('{link controller='ConversationList' encode=false}{if $filter}filter={@$filter}&{/if}{if !$participants|empty}participants={implode from=$participants item=participant}{$participant|rawurlencode}{/implode}&{/if}sortField={$sortField}&sortOrder={$sortOrder}&pageNo={@$pageNo}{/link}');
-               new WCF.Conversation.Preview();
-               new WCF.Conversation.MarkAsRead();
-               new WCF.Conversation.MarkAllAsRead();
                
                // mobile safari hover workaround
                if ($(window).width() <= 800) {
                        excludedSearchValues: ['{$__wcf->user->username|encodeJS}'],
                        maxItems: 20
                });
+               
+               ControllerPopover.init({
+                       className: 'conversationLink',
+                       dboAction: 'wcf\\data\\conversation\\ConversationAction',
+                       identifier: 'com.woltlab.wcf.conversation'
+               });
+       });
+</script>
+
+<script data-relocate="true">
+       require(['WoltLabSuite/Core/Conversation/Ui/MarkAsRead'], (MarkAsRead) => {
+               MarkAsRead.setup();
+       });
+       require(['WoltLabSuite/Core/Conversation/Ui/MarkAllAsRead'], (MarkAllAsRead) => {
+               MarkAllAsRead.setup();
        });
 </script>