feat(core):rewrite userInfo directive

This commit is contained in:
OldHawk
2017-07-18 16:28:08 +08:00
parent 936de8f73d
commit 61d8209d4b
6 changed files with 30 additions and 23 deletions

View File

@@ -59,7 +59,7 @@
<p><span class="moderators-title">{{'FORUMS.FIELDS.MODERATORS' | translate}}:</span>
<span class="moderators-list">
<span class="moderators-item" ng-repeat="m in f.moderators">
<span user-info="m">{{m.displayName}}</span>
<span user-info="m" info-name></span>
<span message-to="m" to-class="message-to-icon"></span>
</span>
</span>
@@ -76,7 +76,7 @@
</div>
<div class="small reply-by">
<span translate="FORUMS.FIELDS.REPLY_BY_1"></span>
<span user-info="f.lastTopic.lastUser">{{f.lastTopic.lastUser.displayName}}</span>
<span user-info="f.lastTopic.lastUser" info-name></span>
<span message-to="f.lastTopic.lastUser" to-class="message-to-icon"></span>
</div>
<div class="small reply-by"
@@ -90,7 +90,7 @@
</div>
<div class="small reply-by">
<span translate="FORUMS.FIELDS.REPLY_BY_1"></span>
<span user-info="f.lastTopic.user">{{f.lastTopic.user.displayName}}</span>
<span user-info="f.lastTopic.user" info-name></span>
<span message-to="f.lastTopic.user" to-class="message-to-icon"></span>
</div>
<div class="small reply-by"

View File

@@ -86,14 +86,12 @@
<div class="reply-item">
<!-- topic content -->
<div class="reply-wrapper">
<span user-info="vm.topic.user" info-class="reply-avatar">
<img ng-src="/{{vm.topic.user.profileImageURL}}">
</span>
<span user-info="vm.topic.user" info-class="reply-avatar" info-avatar></span>
<div class="reply-comment">
<div class="reply-comment-header">
<div class="reply-comment-header-text">
<span user-info="vm.topic.user">{{vm.topic.user.displayName}}</span>
<span user-info="vm.topic.user" info-name></span>
<span score-level="vm.getUserScoreLevel(vm.topic.user);"></span>
<span message-to="vm.topic.user" to-class="message-to-icon"></span>
<span class="user-ud-text">
@@ -160,14 +158,12 @@
<!-- topic replies -->
<div class="reply-wrapper" ng-repeat="rep in vm.topic._replies">
<span user-info="rep.user" info-class="reply-avatar">
<img ng-src="/{{rep.user.profileImageURL}}">
</span>
<span user-info="rep.user" info-class="reply-avatar" info-avatar></span>
<div class="reply-comment">
<div class="reply-comment-header">
<div class="reply-comment-header-text">
<span user-info="rep.user">{{rep.user.displayName}}</span>
<span user-info="rep.user" info-name></span>
<span score-level="vm.getUserScoreLevel(vm.topic.user);"></span>
<span message-to="vm.topic.user" to-class="message-to-icon"></span>
<span class="user-ud-text">

View File

@@ -60,7 +60,7 @@
<p class="topic-by small">
<span translate="FORUMS.FIELDS.REPLY_BY_1"></span>
<span user-info="t.user">{{t.user.displayName}}</span>
<span user-info="t.user" info-name></span>
<span message-to="t.user" to-class="message-to-icon"></span>
<span translate="FORUMS.FIELDS.REPLY_BY_3"
translate-values="{createdAt: '{{t.createdAt | date: 'yyyy-MM-dd HH:mm:ss'}}'}">
@@ -74,7 +74,7 @@
<div ng-if="t._replies.length > 0"> <!--reply-->
<div class="small reply-by">
<span translate="FORUMS.FIELDS.REPLY_BY_1"></span>
<span user-info="t.lastUser">{{t.lastUser.displayName}}</span>
<span user-info="t.lastUser" info-name></span>
<span message-to="t.lastUser" to-class="message-to-icon"></span>
</div>
<div class="small reply-by"
@@ -85,7 +85,7 @@
<div ng-if="f.lastTopic._replies.length == 0"> <!--post-->
<div class="small reply-by">
<span translate="FORUMS.FIELDS.REPLY_BY_1"></span>
<span user-info="t.user">{{t.user.displayName}}</span>
<span user-info="t.user" info-name></span>
<span message-to="t.user" to-class="message-to-icon"></span>
</div>
<div class="small reply-by"
@@ -149,7 +149,7 @@
<p class="topic-by small">
<span translate="FORUMS.FIELDS.REPLY_BY_1"></span>
<span user-info="t.user">{{t.user.displayName}}</span>
<span user-info="t.user" info-name></span>
<span message-to="t.user" to-class="message-to-icon"></span>
<span translate="FORUMS.FIELDS.REPLY_BY_3"
translate-values="{createdAt: '{{t.createdAt | date: 'yyyy-MM-dd HH:mm:ss'}}'}">
@@ -163,7 +163,7 @@
<div ng-if="t._replies.length > 0"> <!--reply-->
<div class="small reply-by">
<span translate="FORUMS.FIELDS.REPLY_BY_1"></span>
<span user-info="t.lastUser">{{t.lastUser.displayName}}</span>
<span user-info="t.lastUser" info-name></span>
<span message-to="t.lastUser" to-class="message-to-icon"></span>
</div>
<div class="small reply-by"
@@ -174,7 +174,7 @@
<div ng-if="t._replies.length == 0"> <!--post-->
<div class="small reply-by">
<span translate="FORUMS.FIELDS.REPLY_BY_1"></span>
<span user-info="t.user">{{t.user.displayName}}</span>
<span user-info="t.user" info-name></span>
<span message-to="t.user" to-class="message-to-icon"></span>
</div>
<div class="small reply-by"

View File

@@ -257,7 +257,7 @@
</p>
</td>
<td class="col-md-1 td-v-middle text-center">
<span user-info="item.user">{{item.user.displayName}}</span>
<span user-info="item.user" info-name></span>
<span message-to="item.user" to-class="message-to-icon"></span>
</td>
</tr>

View File

@@ -210,7 +210,7 @@
<div class="timeline-comment">
<div class="timeline-comment-header">
<div class="timeline-comment-header-text">
<span user-info="item.user">{{item.user.displayName}}</span>
<span user-info="item.user" info-name></span>
<span message-to="item.user" to-class="message-to-icon"></span>
<span class="user-ud-text">
(<span class="glyphicon glyphicon-arrow-up torrent-up"></span>{{item.user.uploaded | bytes}}
@@ -328,7 +328,7 @@
<dl class="dl-horizontal" style="margin-bottom: 0;">
<dt class="h-line">{{ 'TABLE_FIELDS.PUBLISHER' | translate}}</dt>
<dd class="h-line">
<span user-info="vm.torrentLocalInfo.user">{{vm.torrentLocalInfo.user.displayName}}</span>
<span user-info="vm.torrentLocalInfo.user" info-name></span>
<span message-to="vm.torrentLocalInfo.user" to-class="message-to-icon"></span>
</dd>

View File

@@ -20,9 +20,20 @@
var user = s;
var title = $translate.instant('USER_INFO_TITLE', {name: user.displayName});
var cls = attrs.infoClass;
var e = angular.element('<a href="#" class="' + (cls ? cls : '') + '" ui-sref="userinfo({userId: \'' + user._id + '\'})" title="' + title + '" ng-click="$event.stopPropagation();">' + element[0].innerHTML + '</a>');
element.html(e[0].outerHTML);
$compile(element.contents())(scope);
var e = undefined;
if (attrs.hasOwnProperty('infoName')) {
e = angular.element('<a href="#" ui-sref="userinfo({userId: \'' + user._id + '\'})" ng-click="$event.stopPropagation();">' + user.displayName + '</a>');
} else if (attrs.hasOwnProperty('infoAvatar')) {
e = angular.element('<a href="#" ui-sref="userinfo({userId: \'' + user._id + '\'})" ng-click="$event.stopPropagation();"><img src="/' + user.profileImageURL + '"></a>');
}
if (e) {
e.addClass(cls ? cls : '');
e.attr('title', title);
element.html(e);
$compile(element.contents())(scope);
}
}
});
}