// no need for the event to do anything more.
event.stopPropagation();
event.preventDefault();
+ scope.closeBox();
+ });
+
+ scope.closeBox = function () {
element.remove();
scope.$destroy();
- });
+ };
}
- }
+ };
}]);
ngApp.directive('commentEdit', [function () {
restrict: 'E',
templateUrl: 'comment-reply.html',
scope: {
- comment: '=',
+ comment: '='
},
link: function (scope, element) {
scope.isEdit = true;
event.stopPropagation();
event.preventDefault();
if (commentId === scope.comment.id && !scope.isNew) {
- element.remove();
- scope.$destroy();
+ scope.closeBox();
}
});
+
+ scope.closeBox = function () {
+ element.remove();
+ scope.$destroy();
+ };
}
- }
+ };
}]);
- ngApp.directive('commentReplyLink', ['$document', '$compile', '$http', function ($document, $compile, $http) {
+ ngApp.directive('commentReplyLink', ['$document', '$compile', function ($document, $compile) {
return {
scope: {
comment: '='
scope.$destroy();
});
- element.on('click', function () {
- var $container = element.parents('.comment-box').first();
+ element.on('click', function (e) {
+ e.preventDefault();
+ var $container = element.parents('.comment-actions').first();
if (!$container.length) {
console.error('commentReplyLink directive should be placed inside a container with class comment-box!');
return;
}
function removeDupe() {
- let $existingElement = $document.find('.comments-list comment-reply');
+ let $existingElement = $document.find('.comments-list comment-reply, .comments-list comment-edit');
if (!$existingElement.length) {
return;
}
$existingElement.remove();
}
}]);
+
+ ngApp.directive('commentDeleteLink', ['$window', function ($window) {
+ return {
+ controller: 'CommentDeleteController',
+ scope: {
+ comment: '='
+ },
+ link: function (scope, element, attr, ctrl) {
+
+ element.on('click', function(e) {
+ e.preventDefault();
+ var resp = $window.confirm(trans('entities.comment_delete_confirm'));
+ if (!resp) {
+ return;
+ }
+
+ ctrl.delete(scope.comment);
+ });
+ }
+ };
+ }]);
};