markdown links in chat will now open in a blank window.

* added `target` attribute for the markdown directive to specify. default behavior is `_self`.
This commit is contained in:
Nick Gordon
2013-11-24 10:32:51 -08:00
parent 6736da36d4
commit f4323ddc24
2 changed files with 5 additions and 3 deletions

View File

@@ -100,7 +100,7 @@ habitrpg.directive('habitrpgSortable', ['User', function(User) {
.replace(/'/g, ''');
};
if (cap[0].charAt(0) !== '!') {
return '<a target="_blank" class="markdown-link" href="'
return '<a class="markdown-link" href="'
+ escape(link.href)
+ '"'
+ (link.title
@@ -114,7 +114,7 @@ habitrpg.directive('habitrpgSortable', ['User', function(User) {
} else {
return '<a class="markdown-img-link" href="'
+ escape(link.href)
+ '" target="_blank"'
+ '"'
+ (link.title
? ' title="'
+ escape(link.title)
@@ -147,7 +147,9 @@ habitrpg.directive('habitrpgSortable', ['User', function(User) {
link: function(scope, element, attrs) {
scope.$watch(attrs.ngModel, function(value, oldValue) {
var markdown = value;
var linktarget = attrs.target || '_self';
var html = md.toHtml(markdown);
html = html.replace(' href','target="'+linktarget+'" href');
element.html(html);
});
}

View File

@@ -3,7 +3,7 @@ li(bindonce='group.chat', ng-repeat='message in group.chat', bo-class='{highligh
a.label.chat-message(class='hidden-label')
span {{message.user}}&nbsp;
| &nbsp;
markdown(ng-model='message.text')
markdown(ng-model='message.text',target='_blank')
| &nbsp;-&nbsp;
span.muted.time(from-now='message.timestamp')
a(bo-show='user.contributor.admin || message.uuid == user.id', ng-click='deleteChatMessage(group, message)')