2015-09-01 21:00:03 +02:00
|
|
|
/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
|
|
|
|
(function () {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
/**
|
2015-09-30 17:28:22 +02:00
|
|
|
* ensureTarget - A filter to set a blank target to all links.
|
|
|
|
* @memberof SOGo.Common
|
2015-09-01 21:00:03 +02:00
|
|
|
* @ngInject
|
2015-09-30 17:28:22 +02:00
|
|
|
* @example:
|
|
|
|
|
|
|
|
<div ng-bind-html="part.content | ensureTarget"><!-- msg --></div>
|
|
|
|
*/
|
|
|
|
ensureTarget.$inject = ['$sce'];
|
|
|
|
function ensureTarget($sce) {
|
2015-09-01 21:00:03 +02:00
|
|
|
return function(element) {
|
|
|
|
var tree = angular.element('<div>' + element + '</div>');
|
|
|
|
tree.find('a').attr('target', '_blank');
|
2015-09-30 17:28:22 +02:00
|
|
|
return $sce.trustAs('html', tree.html());
|
2015-09-01 21:00:03 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
angular.module('SOGo.Common')
|
|
|
|
.filter('ensureTarget', ensureTarget);
|
|
|
|
})();
|