2016-11-16 10:12:58 -05:00
|
|
|
define [
|
|
|
|
"base"
|
|
|
|
], (App) ->
|
2017-01-12 06:25:36 -05:00
|
|
|
App.directive "commentEntry", ($timeout) ->
|
2016-11-16 10:12:58 -05:00
|
|
|
restrict: "E"
|
|
|
|
templateUrl: "commentEntryTemplate"
|
|
|
|
scope:
|
|
|
|
entry: "="
|
2016-12-16 11:42:41 -05:00
|
|
|
threads: "="
|
2017-01-12 05:52:39 -05:00
|
|
|
permissions: "="
|
2016-11-16 10:12:58 -05:00
|
|
|
onResolve: "&"
|
|
|
|
onReply: "&"
|
2016-11-16 11:13:39 -05:00
|
|
|
onIndicatorClick: "&"
|
2016-11-16 10:12:58 -05:00
|
|
|
link: (scope, element, attrs) ->
|
2017-01-12 06:25:36 -05:00
|
|
|
scope.state =
|
|
|
|
animating: false
|
|
|
|
|
2016-11-16 10:12:58 -05:00
|
|
|
scope.handleCommentReplyKeyPress = (ev) ->
|
|
|
|
if ev.keyCode == 13 and !ev.shiftKey and !ev.ctrlKey and !ev.metaKey
|
|
|
|
ev.preventDefault()
|
|
|
|
ev.target.blur()
|
|
|
|
scope.onReply()
|
2017-01-12 06:25:36 -05:00
|
|
|
|
|
|
|
scope.animateAndCallOnResolve = () ->
|
|
|
|
scope.state.animating = true
|
|
|
|
element.find(".rp-entry").css("top", 0)
|
2017-01-12 06:56:04 -05:00
|
|
|
$timeout((() -> scope.onResolve()), 350)
|
2017-01-12 06:25:36 -05:00
|
|
|
return true
|