overleaf/services/web/public/coffee/ide/review-panel/directives/aggregateChangeEntry.coffee

40 lines
1.3 KiB
CoffeeScript
Raw Normal View History

2017-05-31 09:47:25 -04:00
define [
"base"
], (App) ->
App.directive "aggregateChangeEntry", ($timeout) ->
restrict: "E"
templateUrl: "aggregateChangeEntryTemplate"
scope:
entry: "="
user: "="
permissions: "="
onAccept: "&"
onReject: "&"
onIndicatorClick: "&"
onBodyClick: "&"
link: (scope, element, attrs) ->
scope.contentLimit = 17
scope.isDeletionCollapsed = true
scope.isInsertionCollapsed = true
scope.deletionNeedsCollapsing = false
scope.insertionNeedsCollapsing = false
2017-05-31 09:47:25 -04:00
element.on "click", (e) ->
if $(e.target).is('.rp-entry, .rp-entry-description, .rp-entry-body, .rp-entry-action-icon i')
scope.onBodyClick()
scope.toggleDeletionCollapse = () ->
scope.isDeletionCollapsed = !scope.isDeletionCollapsed
2017-05-31 09:47:25 -04:00
$timeout () ->
scope.$emit "review-panel:layout"
scope.toggleInsertionCollapse = () ->
scope.isInsertionCollapsed = !scope.isInsertionCollapsed
$timeout () ->
scope.$emit "review-panel:layout"
scope.$watch "entry.metadata.replaced_content.length", (deletionContentLength) ->
scope.deletionNeedsCollapsing = deletionContentLength > scope.contentLimit
scope.$watch "entry.content.length", (insertionContentLength) ->
scope.insertionNeedsCollapsing = insertionContentLength > scope.contentLimit