Commit e53d499c authored by Sean Hammond's avatar Sean Hammond

Move feature() into AnnotationController

Move scope.feature() from the annotation directive to vm.feature() 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 e8284aba
......@@ -152,7 +152,8 @@ function errorMessage(reason) {
// @ngInject
function AnnotationController(
$document, $q, $rootScope, $scope, $timeout, $window, annotationUI,
annotationMapper, drafts, flash, groups, permissions, session, tags, time) {
annotationMapper, drafts, flash, features, groups, permissions, session,
tags, time) {
var vm = this;
......@@ -162,6 +163,8 @@ function AnnotationController(
vm.action = 'view';
vm.document = null;
// Give the template access to the feature flags.
vm.feature = features.flagEnabled;
// Copy isSidebar from $scope onto vm for consistency (we want this
// directive's templates to always access variables from vm rather than
// directly from scope).
......@@ -652,7 +655,7 @@ function AnnotationController(
*
*/
// @ngInject
function annotation($document, features) {
function annotation($document) {
function linkFn(scope, elem, attrs, controllers) {
var ctrl = controllers[0];
var thread = controllers[1];
......@@ -661,9 +664,6 @@ function annotation($document, features) {
elem.on('keydown', ctrl.onKeydown);
// Give template access to feature flags.
scope.feature = features.flagEnabled;
// FIXME: Replace this counting code with something more sane, and
// something that doesn't involve so much untested logic in the link
// function (as opposed to unit-tested methods on the AnnotationController,
......
......@@ -57,7 +57,7 @@
<section class="annotation-quote-list"
ng-repeat="target in vm.annotation.target track by $index"
ng-if="vm.hasQuotes()">
<excerpt enabled="feature('truncate_annotations')">
<excerpt enabled="vm.feature('truncate_annotations')">
<blockquote class="annotation-quote"
ng-bind-html="selector.exact"
ng-repeat="selector in target.selector
......@@ -70,7 +70,7 @@
<!-- Body -->
<section name="text" class="annotation-body">
<excerpt enabled="feature('truncate_annotations') && !vm.editing()">
<excerpt enabled="vm.feature('truncate_annotations') && !vm.editing()">
<markdown ng-model="vm.annotation.text"
read-only="!vm.editing()"
></markdown>
......
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