2016-11-16 09:56:34 -05:00
|
|
|
define [
|
|
|
|
"base"
|
|
|
|
], (App) ->
|
2017-01-13 10:30:31 -05:00
|
|
|
App.directive "changeEntry", ($timeout) ->
|
2016-11-16 09:56:34 -05:00
|
|
|
restrict: "E"
|
|
|
|
templateUrl: "changeEntryTemplate"
|
|
|
|
scope:
|
|
|
|
entry: "="
|
2016-11-16 10:12:58 -05:00
|
|
|
user: "="
|
2017-01-12 05:52:39 -05:00
|
|
|
permissions: "="
|
2016-11-16 09:56:34 -05:00
|
|
|
onAccept: "&"
|
|
|
|
onReject: "&"
|
2016-11-16 11:13:39 -05:00
|
|
|
onIndicatorClick: "&"
|
2017-01-26 11:11:02 -05:00
|
|
|
onBodyClick: "&"
|
2017-01-13 10:30:31 -05:00
|
|
|
link: (scope, element, attrs) ->
|
|
|
|
scope.contentLimit = 40
|
|
|
|
scope.isCollapsed = true
|
2017-01-18 05:53:59 -05:00
|
|
|
scope.needsCollapsing = false
|
2017-01-13 10:30:31 -05:00
|
|
|
|
2017-01-26 11:11:02 -05:00
|
|
|
element.on "click", (e) ->
|
2017-01-30 10:00:32 -05:00
|
|
|
if $(e.target).is('.rp-entry, .rp-entry-description, .rp-entry-body, .rp-entry-action-icon i')
|
2017-01-26 11:11:02 -05:00
|
|
|
scope.onBodyClick()
|
|
|
|
|
2017-01-13 10:30:31 -05:00
|
|
|
scope.toggleCollapse = () ->
|
|
|
|
scope.isCollapsed = !scope.isCollapsed
|
|
|
|
$timeout () ->
|
2017-01-18 05:53:59 -05:00
|
|
|
scope.$emit "review-panel:layout"
|
|
|
|
|
|
|
|
scope.$watch "entry.content.length", (contentLength) ->
|
|
|
|
scope.needsCollapsing = contentLength > scope.contentLimit
|