Commit 967b3929 authored by Sean Hammond's avatar Sean Hammond

Move share() into AnnotationController

Move scope.share() from the annotation directive to vm.share() in
the AnnotationController. Just trying to move as much as possible out of
the directive's scope and link function into the controller, if we're
gonna use a directive controller here try to just use it instead of
randomly using the link function and scope for some things and the
controller for others.
parent 5de7bf86
...@@ -263,6 +263,19 @@ function AnnotationController( ...@@ -263,6 +263,19 @@ function AnnotationController(
} }
}; };
vm.share = function(event) {
var $container = angular.element(event.currentTarget).parent();
$container.addClass('open').find('input').focus().select();
// We have to stop propagation here otherwise this click event will
// re-close the share dialog immediately.
event.stopPropagation();
$document.one('click', function() {
$container.removeClass('open');
});
};
/** /**
* @ngdoc method * @ngdoc method
* @name annotation.AnnotaitonController#hasContent * @name annotation.AnnotaitonController#hasContent
...@@ -645,19 +658,6 @@ function annotation($document, features) { ...@@ -645,19 +658,6 @@ function annotation($document, features) {
// Give template access to feature flags. // Give template access to feature flags.
scope.feature = features.flagEnabled; scope.feature = features.flagEnabled;
scope.share = function(event) {
var $container = angular.element(event.currentTarget).parent();
$container.addClass('open').find('input').focus().select();
// We have to stop propagation here otherwise this click event will
// re-close the share dialog immediately.
event.stopPropagation();
$document.one('click', function() {
$container.removeClass('open');
});
};
// Keep track of edits going on in the thread. // Keep track of edits going on in the thread.
if (counter !== null) { if (counter !== null) {
// Expand the thread if descendants are editing. // Expand the thread if descendants are editing.
......
...@@ -141,7 +141,7 @@ ...@@ -141,7 +141,7 @@
><i class="h-icon-reply btn-icon"></i> Reply</button> ><i class="h-icon-reply btn-icon"></i> Reply</button>
<span class="share-dialog-wrapper"> <span class="share-dialog-wrapper">
<button class="small btn btn-clean" <button class="small btn btn-clean"
ng-click="share($event)" ng-click="vm.share($event)"
><i class="h-icon-link btn-icon"></i> Link</button> ><i class="h-icon-link btn-icon"></i> Link</button>
<span class="share-dialog" ng-click="$event.stopPropagation()"> <span class="share-dialog" ng-click="$event.stopPropagation()">
<a target="_blank" <a target="_blank"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment