ep_comments_page 1.0.0 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/locales/cs.json +29 -0
- package/locales/kn.json +24 -0
- package/package.json +1 -1
- package/static/js/index.js +3 -8
- package/static/js/newComment.js +26 -23
- package/static/tests/frontend/specs/newComment.js +18 -0
package/locales/cs.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"@metadata": {
|
|
3
|
+
"authors": [
|
|
4
|
+
"Spotter"
|
|
5
|
+
]
|
|
6
|
+
},
|
|
7
|
+
"ep_comments_page.comment": "Komentář",
|
|
8
|
+
"ep_comments_page.comments": "Komentáře",
|
|
9
|
+
"ep_comments_page.add_comment.title": "Přidat nový komentář k výběru",
|
|
10
|
+
"ep_comments_page.add_comment": "Přidat nový komentář k výběru",
|
|
11
|
+
"ep_comments_page.add_comment.hint": "Nejprve vyberte text, který chcete komentovat",
|
|
12
|
+
"ep_comments_page.delete_comment.title": "Smazat tento komentář",
|
|
13
|
+
"ep_comments_page.edit_comment.title": "Upravit tento komentář",
|
|
14
|
+
"ep_comments_page.show_comments": "Zobrazit komentáře",
|
|
15
|
+
"ep_comments_page.comments_template.suggested_change": "Navrhovaná změna",
|
|
16
|
+
"ep_comments_page.comments_template.from": "Od",
|
|
17
|
+
"ep_comments_page.comments_template.accept_change.value": "Přijmout změnu",
|
|
18
|
+
"ep_comments_page.comments_template.revert_change.value": "Vrátit změnu",
|
|
19
|
+
"ep_comments_page.comments_template.to": "Komu",
|
|
20
|
+
"ep_comments_page.comments_template.include_suggestion": "Zahrnout navrhovanou změnu",
|
|
21
|
+
"ep_comments_page.comments_template.comment.value": "Komentář",
|
|
22
|
+
"ep_comments_page.comments_template.cancel.value": "Zrušit",
|
|
23
|
+
"ep_comments_page.comments_template.reply.value": "Odpovědět",
|
|
24
|
+
"ep_comments_page.comments_template.reply.placeholder": "Odpovědět",
|
|
25
|
+
"ep_comments_page.comments_template.edit_comment.save": "Uložit",
|
|
26
|
+
"ep_comments_page.comments_template.edit_comment.cancel": "Zrušit",
|
|
27
|
+
"ep_comments_page.error.edit_unauth": "Komentáře ostatních uživatelů nelze upravovat!",
|
|
28
|
+
"ep_comments_page.error.delete_unauth": "Komentáře ostatních uživatelů nelze mazat!"
|
|
29
|
+
}
|
package/locales/kn.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"@metadata": {
|
|
3
|
+
"authors": [
|
|
4
|
+
"ಮಲ್ನಾಡಾಚ್ ಕೊಂಕ್ಣೊ"
|
|
5
|
+
]
|
|
6
|
+
},
|
|
7
|
+
"ep_comments_page.comment": "ಟಿಪ್ಪಣಿ",
|
|
8
|
+
"ep_comments_page.comments": "ಟಿಪ್ಪಣಿಗಳು",
|
|
9
|
+
"ep_comments_page.delete_comment.title": "ಈ ಟಿಪ್ಪಣಿಯನ್ನು ಅಳಿಸಿ",
|
|
10
|
+
"ep_comments_page.edit_comment.title": "ಈ ಟಿಪ್ಪಣಿಯನ್ನು ಸಂಪಾದಿಸಿ",
|
|
11
|
+
"ep_comments_page.show_comments": "ಟಿಪ್ಪಣಿಗಳನ್ನು ತೋರಿಸಿ",
|
|
12
|
+
"ep_comments_page.comments_template.suggested_change": "ಸೂಚಿಸಲ್ಪಟ್ಟ ಬದಲಾವಣೆ",
|
|
13
|
+
"ep_comments_page.comments_template.from": "ಇಂದ",
|
|
14
|
+
"ep_comments_page.comments_template.accept_change.value": "ಬದಲಾವಣೆ ಸ್ವೀಕರಿಸಿ",
|
|
15
|
+
"ep_comments_page.comments_template.to": "ಗೆ",
|
|
16
|
+
"ep_comments_page.comments_template.comment.value": "ಟಿಪ್ಪಣಿ",
|
|
17
|
+
"ep_comments_page.comments_template.cancel.value": "ರದ್ದುಮಾಡಿ",
|
|
18
|
+
"ep_comments_page.comments_template.reply.value": "ಪ್ರತಿಕ್ರಿಯೆ",
|
|
19
|
+
"ep_comments_page.comments_template.reply.placeholder": "ಪ್ರತಿಕ್ರಿಯೆ",
|
|
20
|
+
"ep_comments_page.comments_template.edit_comment.save": "ಉಳಿಸಿ",
|
|
21
|
+
"ep_comments_page.comments_template.edit_comment.cancel": "ರದ್ದುಮಾಡಿ",
|
|
22
|
+
"ep_comments_page.error.edit_unauth": "ನೀವು ಬೇರೆಯವರ ಟಿಪ್ಪಣಿಗಳನ್ನು ಸಂಪಾದಿಸಲಾಗುವುದಿಲ್ಲ!",
|
|
23
|
+
"ep_comments_page.error.delete_unauth": "ನೀವು ಬೇರೆಯವರ ಟಿಪ್ಪಣಿಗಳನ್ನು ಅಳಿಸಲಾಗುವುದಿಲ್ಲ!"
|
|
24
|
+
}
|
package/package.json
CHANGED
package/static/js/index.js
CHANGED
|
@@ -901,12 +901,6 @@ EpComments.prototype.displayNewCommentForm = function () {
|
|
|
901
901
|
// Write the text to the changeFrom form
|
|
902
902
|
$('#newComment').find('.from-value').text(selectedText);
|
|
903
903
|
|
|
904
|
-
// Display form
|
|
905
|
-
setTimeout(() => {
|
|
906
|
-
const position = getXYOffsetOfRep(rep);
|
|
907
|
-
newComment.showNewCommentPopup(position);
|
|
908
|
-
});
|
|
909
|
-
|
|
910
904
|
// Check if the first element selected is visible in the viewport
|
|
911
905
|
const $firstSelectedElement = this.getFirstElementSelected();
|
|
912
906
|
const firstSelectedElementInViewport = this.isElementInViewport($firstSelectedElement);
|
|
@@ -915,8 +909,9 @@ EpComments.prototype.displayNewCommentForm = function () {
|
|
|
915
909
|
this.scrollViewportIfSelectedTextIsNotVisible($firstSelectedElement);
|
|
916
910
|
}
|
|
917
911
|
|
|
918
|
-
//
|
|
919
|
-
|
|
912
|
+
// Display form
|
|
913
|
+
const position = getXYOffsetOfRep(rep);
|
|
914
|
+
newComment.showNewCommentPopup(position);
|
|
920
915
|
};
|
|
921
916
|
|
|
922
917
|
EpComments.prototype.scrollViewportIfSelectedTextIsNotVisible = function ($firstSelectedElement) {
|
package/static/js/newComment.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
const commentL10n = require('ep_comments_page/static/js/commentL10n');
|
|
4
4
|
|
|
5
|
+
let $newComment = $();
|
|
6
|
+
|
|
5
7
|
// Create a comment object with data filled on the given form
|
|
6
8
|
const buildCommentFrom = (form) => {
|
|
7
9
|
const text = form.find('.comment-content').val();
|
|
@@ -26,15 +28,16 @@ const cancelNewComment = () => {
|
|
|
26
28
|
// Callback for new comment Submit
|
|
27
29
|
const submitNewComment = (callback) => {
|
|
28
30
|
const index = 0;
|
|
29
|
-
const
|
|
30
|
-
const comment = buildCommentFrom(form);
|
|
31
|
+
const comment = buildCommentFrom($newComment);
|
|
31
32
|
if (comment.text.length > 0 || comment.changeTo && comment.changeTo.length > 0) {
|
|
32
|
-
|
|
33
|
+
$newComment.find('.comment-content, .to-value').removeClass('error');
|
|
33
34
|
hideNewCommentPopup();
|
|
34
35
|
callback(comment, index);
|
|
35
36
|
} else {
|
|
36
|
-
if (comment.text.length === 0)
|
|
37
|
-
if (comment.changeTo && comment.changeTo.length === 0)
|
|
37
|
+
if (comment.text.length === 0) $newComment.find('.comment-content').addClass('error');
|
|
38
|
+
if (comment.changeTo && comment.changeTo.length === 0) {
|
|
39
|
+
$newComment.find('.to-value').addClass('error');
|
|
40
|
+
}
|
|
38
41
|
}
|
|
39
42
|
return false;
|
|
40
43
|
};
|
|
@@ -42,36 +45,35 @@ const submitNewComment = (callback) => {
|
|
|
42
45
|
/* ***** Public methods: ***** */
|
|
43
46
|
|
|
44
47
|
const localizenewCommentPopup = () => {
|
|
45
|
-
|
|
46
|
-
if (newCommentPopup.length !== 0) commentL10n.localize(newCommentPopup);
|
|
48
|
+
if ($newComment.length !== 0) commentL10n.localize($newComment);
|
|
47
49
|
};
|
|
48
50
|
|
|
49
51
|
// Insert new Comment Form
|
|
50
52
|
const insertNewCommentPopupIfDontExist = (comment, callback) => {
|
|
51
|
-
$
|
|
53
|
+
$newComment.remove();
|
|
52
54
|
|
|
53
55
|
comment.commentId = '';
|
|
54
|
-
|
|
55
|
-
|
|
56
|
+
$newComment = $('#newCommentTemplate').tmpl(comment);
|
|
57
|
+
$newComment.appendTo($('#editorcontainerbox'));
|
|
56
58
|
|
|
57
59
|
localizenewCommentPopup();
|
|
58
60
|
|
|
59
61
|
// Listen for include suggested change toggle
|
|
60
|
-
$
|
|
61
|
-
$
|
|
62
|
+
$newComment.find('.suggestion-checkbox').change(function () {
|
|
63
|
+
$newComment.find('.suggestion').toggle($(this).is(':checked'));
|
|
62
64
|
});
|
|
63
65
|
|
|
64
66
|
// Cancel btn
|
|
65
|
-
|
|
67
|
+
$newComment.find('#comment-reset').on('click', () => {
|
|
66
68
|
cancelNewComment();
|
|
67
69
|
});
|
|
68
70
|
// Create btn
|
|
69
|
-
$
|
|
71
|
+
$newComment.on('submit', (e) => {
|
|
70
72
|
e.preventDefault();
|
|
71
73
|
return submitNewComment(callback);
|
|
72
74
|
});
|
|
73
75
|
|
|
74
|
-
return
|
|
76
|
+
return $newComment;
|
|
75
77
|
};
|
|
76
78
|
|
|
77
79
|
const showNewCommentPopup = (position) => {
|
|
@@ -82,27 +84,28 @@ const showNewCommentPopup = (position) => {
|
|
|
82
84
|
left = $('.toolbar .addComment').offset().left;
|
|
83
85
|
}
|
|
84
86
|
const top = position[1];
|
|
85
|
-
$
|
|
87
|
+
$newComment.css('left', left);
|
|
86
88
|
if (left === position[0]) {
|
|
87
|
-
$
|
|
89
|
+
$newComment.css('top', top);
|
|
88
90
|
}
|
|
89
91
|
// Reset form to make sure it is all clear
|
|
90
|
-
$
|
|
91
|
-
$
|
|
92
|
-
$
|
|
92
|
+
$newComment.find('.suggestion-checkbox').prop('checked', false).trigger('change');
|
|
93
|
+
$newComment.find('textarea').val('');
|
|
94
|
+
$newComment.find('.comment-content, .to-value').removeClass('error');
|
|
93
95
|
|
|
94
96
|
// Show popup
|
|
95
|
-
$
|
|
97
|
+
$newComment.addClass('popup-show');
|
|
98
|
+
$newComment.find('.comment-content').focus();
|
|
96
99
|
|
|
97
100
|
// mark selected text, so it is clear to user which text range the comment is being applied to
|
|
98
101
|
pad.plugins.ep_comments_page.preCommentMarker.markSelectedText();
|
|
99
102
|
};
|
|
100
103
|
|
|
101
104
|
const hideNewCommentPopup = () => {
|
|
102
|
-
$
|
|
105
|
+
$newComment.removeClass('popup-show');
|
|
103
106
|
|
|
104
107
|
// force focus to be lost, so virtual keyboard is hidden on mobile devices
|
|
105
|
-
$
|
|
108
|
+
$newComment.find(':focus').blur();
|
|
106
109
|
|
|
107
110
|
// unmark selected text, as now there is no text being commented
|
|
108
111
|
pad.plugins.ep_comments_page.preCommentMarker.unmarkSelectedText();
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const utils = require('../utils');
|
|
4
|
+
|
|
5
|
+
before(async function () {
|
|
6
|
+
await utils.aNewPad();
|
|
7
|
+
helper.padInner$('div').first()
|
|
8
|
+
.sendkeys('{selectall}')
|
|
9
|
+
.sendkeys('{del}')
|
|
10
|
+
.text('commented text')
|
|
11
|
+
.sendkeys('{selectall}');
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('new comment button focuses on comment textarea', async function () {
|
|
15
|
+
helper.padChrome$('.addComment').click();
|
|
16
|
+
expect(helper.padChrome$.document.activeElement)
|
|
17
|
+
.to.be(helper.padChrome$('#newComment').find('.comment-content')[0]);
|
|
18
|
+
});
|