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);
});
}