diff --git a/script/directives.js b/script/directives.js index baef5e0def..3d557f4aef 100644 --- a/script/directives.js +++ b/script/directives.js @@ -85,7 +85,7 @@ }; }(); - habitrpg.directive('markdown', ['$timeout', function($timeout) { + habitrpg.directive('markdown', ['$timeout','MOBILE_APP', function($timeout, MOBILE_APP) { return { restrict: 'E', link: function(scope, element, attrs) { @@ -107,6 +107,21 @@ html = html.replace(' href',' target="'+linktarget+'" href'); element.html(html); + if(MOBILE_APP) { + var elements = element.find("a"); + _.forEach(elements, function(link){ + if(link.href) { + + link.onclick = function (e) { + scope.externalLink(this.href); + + e.preventDefault(); + e.stopPropagation(); + }; + } + }); + } + if(removeWatch) { doRemoveWatch();