mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-03 14:43:59 -05:00
36 lines
No EOL
882 B
CoffeeScript
36 lines
No EOL
882 B
CoffeeScript
define [
|
|
"base"
|
|
], (App) ->
|
|
App.directive "addCommentEntry", () ->
|
|
restrict: "E"
|
|
templateUrl: "addCommentEntryTemplate"
|
|
scope:
|
|
onStartNew: "&"
|
|
onSubmit: "&"
|
|
onCancel: "&"
|
|
onIndicatorClick: "&"
|
|
link: (scope, element, attrs) ->
|
|
scope.state =
|
|
isAdding: false
|
|
content: ""
|
|
|
|
scope.startNewComment = () ->
|
|
scope.state.isAdding = true
|
|
scope.onStartNew()
|
|
setTimeout () ->
|
|
scope.$broadcast "comment:new:open"
|
|
|
|
scope.cancelNewComment = () ->
|
|
scope.state.isAdding = false
|
|
scope.onCancel()
|
|
|
|
scope.handleCommentKeyPress = (ev) ->
|
|
if ev.keyCode == 13 and !ev.shiftKey and !ev.ctrlKey and !ev.metaKey
|
|
ev.preventDefault()
|
|
ev.target.blur()
|
|
scope.submitNewComment()
|
|
|
|
scope.submitNewComment = () ->
|
|
scope.onSubmit { content: scope.state.content }
|
|
scope.state.isAdding = false
|
|
scope.state.content = "" |