e892e530ac715eab9652aa8a540cd006d6e6290a
2 * Provides the editor for conversation subjects.
4 * @author Alexander Ebert
5 * @copyright 2001-2019 WoltLab GmbH
6 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
7 * @module WoltLabSuite/Core/Conversation/Ui/Subject/Editor
9 define(['Ajax', 'EventKey', 'Language', 'Ui/Dialog', 'Ui/Notification'], function (Ajax
, EventKey
, Language
, UiDialog
, UiNotification
) {
14 * @exports WoltLabSuite/Core/Conversation/Ui/Subject/Editor
18 * Shows the edit dialog for the selected conversation's subject.
20 * @param {int} objectId
22 beginEdit: function (objectId
) {
27 * Validates and saves the new subject.
29 * @param {Event} event
32 _saveEdit: function (event
) {
33 event
.preventDefault();
34 var innerError
= _subject
.nextElementSibling
;
35 if (innerError
&& innerError
.classList
.contains('innerError')) {
38 var value
= _subject
.value
.trim();
40 innerError
= elCreate('small');
41 innerError
.className
= 'innerError';
42 innerError
.textContent
= Language
.get('wcf.global.form.error.empty');
43 _subject
.parentNode
.insertBefore(innerError
, _subject
.nextElementSibling
);
50 objectIDs
: [_objectId
]
55 * Retrieves the current conversation subject.
60 _getCurrentValue: function () {
62 elBySelAll('.jsConversationSubject[data-conversation-id="' + _objectId
+ '"], .conversationLink[data-object-id="' + _objectId
+ '"]', undefined, function (subject
) {
63 value
= subject
.textContent
;
67 _ajaxSuccess: function (data
) {
69 elBySelAll('.jsConversationSubject[data-conversation-id="' + _objectId
+ '"], .conversationLink[data-object-id="' + _objectId
+ '"]', undefined, function (subject
) {
70 subject
.textContent
= data
.returnValues
.subject
;
72 UiNotification
.show();
74 _dialogSetup: function () {
76 id
: 'dialogConversationSubjectEditor',
78 onSetup
: (function (content
) {
79 _subject
= elById('jsConversationSubject');
80 _subject
.addEventListener('keyup', (function (event
) {
81 if (EventKey
.Enter(event
)) {
82 this._saveEdit(event
);
85 elBySel('.jsButtonSave', content
).addEventListener('click', this._saveEdit
.bind(this));
87 onShow
: (function () {
88 _subject
.value
= this._getCurrentValue();
90 title
: Language
.get('wcf.conversation.edit.subject')
93 + '<dt><label for="jsConversationSubject">' + Language
.get('wcf.global.subject') + '</label></dt>'
94 + '<dd><input type="text" id="jsConversationSubject" class="long" maxlength="255"></dd>'
96 + '<div class="formSubmit"><button class="buttonPrimary jsButtonSave">' + Language
.get('wcf.global.button.save') + '</button></div>'
99 _ajaxSetup: function () {
102 actionName
: 'editSubject',
103 className
: 'wcf\\data\\conversation\\ConversationAction'