|
@@ -1,17 +1,5 @@
|
|
|
-/* eslint-disable
|
|
|
|
|
- max-len,
|
|
|
|
|
- no-return-assign,
|
|
|
|
|
- no-undef,
|
|
|
|
|
-*/
|
|
|
|
|
-// TODO: This file was created by bulk-decaffeinate.
|
|
|
|
|
-// Fix any style issues and re-enable lint.
|
|
|
|
|
-/*
|
|
|
|
|
- * decaffeinate suggestions:
|
|
|
|
|
- * DS102: Remove unnecessary code created because of implicit returns
|
|
|
|
|
- * DS207: Consider shorter variations of null checks
|
|
|
|
|
- * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
|
|
|
|
- */
|
|
|
|
|
-define(['base'], App =>
|
|
|
|
|
|
|
+define(['base'], App => {
|
|
|
|
|
+ let content = ''
|
|
|
App.directive('addCommentEntry', () => ({
|
|
App.directive('addCommentEntry', () => ({
|
|
|
restrict: 'E',
|
|
restrict: 'E',
|
|
|
templateUrl: 'addCommentEntryTemplate',
|
|
templateUrl: 'addCommentEntryTemplate',
|
|
@@ -23,48 +11,41 @@ define(['base'], App =>
|
|
|
link(scope, element, attrs) {
|
|
link(scope, element, attrs) {
|
|
|
scope.state = {
|
|
scope.state = {
|
|
|
isAdding: false,
|
|
isAdding: false,
|
|
|
- content: ''
|
|
|
|
|
|
|
+ content: content
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
scope.$on('comment:start_adding', () => scope.startNewComment())
|
|
scope.$on('comment:start_adding', () => scope.startNewComment())
|
|
|
|
|
+ scope.$on('$destroy', function() {
|
|
|
|
|
+ content = scope.state.content
|
|
|
|
|
+ })
|
|
|
|
|
|
|
|
scope.startNewComment = function() {
|
|
scope.startNewComment = function() {
|
|
|
scope.state.isAdding = true
|
|
scope.state.isAdding = true
|
|
|
scope.onStartNew()
|
|
scope.onStartNew()
|
|
|
- return setTimeout(() => scope.$broadcast('comment:new:open'))
|
|
|
|
|
|
|
+ setTimeout(() => scope.$broadcast('comment:new:open'))
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
scope.cancelNewComment = function() {
|
|
scope.cancelNewComment = function() {
|
|
|
scope.state.isAdding = false
|
|
scope.state.isAdding = false
|
|
|
- return scope.onCancel()
|
|
|
|
|
|
|
+ scope.state.content = ''
|
|
|
|
|
+ scope.onCancel()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
scope.handleCommentKeyPress = function(ev) {
|
|
scope.handleCommentKeyPress = function(ev) {
|
|
|
if (ev.keyCode === 13 && !ev.shiftKey && !ev.ctrlKey && !ev.metaKey) {
|
|
if (ev.keyCode === 13 && !ev.shiftKey && !ev.ctrlKey && !ev.metaKey) {
|
|
|
ev.preventDefault()
|
|
ev.preventDefault()
|
|
|
if (scope.state.content.length > 0) {
|
|
if (scope.state.content.length > 0) {
|
|
|
- return scope.submitNewComment()
|
|
|
|
|
|
|
+ scope.submitNewComment()
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- return (scope.submitNewComment = function(event) {
|
|
|
|
|
- // If this is from a blur event from clicking on cancel, ignore it.
|
|
|
|
|
- if (event != null && event.type === 'blur') {
|
|
|
|
|
- if (
|
|
|
|
|
- // Includes relatedTarget workaround for Firefox
|
|
|
|
|
- $(event.relatedTarget).hasClass('rp-entry-button-cancel') ||
|
|
|
|
|
- $(event.originalEvent.explicitOriginalTarget).hasClass(
|
|
|
|
|
- 'rp-entry-button-cancel'
|
|
|
|
|
- )
|
|
|
|
|
- ) {
|
|
|
|
|
- return true
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
|
|
+ scope.submitNewComment = function(event) {
|
|
|
scope.onSubmit({ content: scope.state.content })
|
|
scope.onSubmit({ content: scope.state.content })
|
|
|
|
|
+ content = scope.state.content
|
|
|
scope.state.isAdding = false
|
|
scope.state.isAdding = false
|
|
|
- return (scope.state.content = '')
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ scope.state.content = ''
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- })))
|
|
|
|
|
|
|
+ }))
|
|
|
|
|
+})
|