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
) {
16 * @exports WoltLabSuite/Core/Conversation/Ui/Subject/Editor
20 * Shows the edit dialog for the selected conversation's subject.
22 * @param {int} objectId
24 beginEdit: function (objectId
) {
31 * Validates and saves the new subject.
33 * @param {Event} event
36 _saveEdit: function (event
) {
37 event
.preventDefault();
39 var innerError
= _subject
.nextElementSibling
;
40 if (innerError
&& innerError
.classList
.contains('innerError')) {
44 var value
= _subject
.value
.trim();
46 innerError
= elCreate('small');
47 innerError
.className
= 'innerError';
48 innerError
.textContent
= Language
.get('wcf.global.form.error.empty');
49 _subject
.parentNode
.insertBefore(innerError
, _subject
.nextElementSibling
);
56 objectIDs
: [_objectId
]
62 * Retrieves the current conversation subject.
67 _getCurrentValue: function () {
69 elBySelAll('.jsConversationSubject[data-conversation-id="' + _objectId
+ '"], .conversationLink[data-object-id="' + _objectId
+ '"]', undefined, function (subject
) {
70 value
= subject
.textContent
;
76 _ajaxSuccess: function (data
) {
79 elBySelAll('.jsConversationSubject[data-conversation-id="' + _objectId
+ '"], .conversationLink[data-object-id="' + _objectId
+ '"]', undefined, function (subject
) {
80 subject
.textContent
= data
.returnValues
.subject
;
83 UiNotification
.show();
86 _dialogSetup: function () {
88 id
: 'dialogConversationSubjectEditor',
90 onSetup
: (function (content
) {
91 _subject
= elById('jsConversationSubject');
92 _subject
.addEventListener('keyup', (function (event
) {
93 if (EventKey
.Enter(event
)) {
94 this._saveEdit(event
);
98 elBySel('.jsButtonSave', content
).addEventListener('click', this._saveEdit
.bind(this));
100 onShow
: (function () {
101 _subject
.value
= this._getCurrentValue();
103 title
: Language
.get('wcf.conversation.edit.subject')
106 + '<dt><label for="jsConversationSubject">' + Language
.get('wcf.global.subject') + '</label></dt>'
107 + '<dd><input type="text" id="jsConversationSubject" class="long" maxlength="255"></dd>'
109 + '<div class="formSubmit"><button class="buttonPrimary jsButtonSave">' + Language
.get('wcf.global.button.save') + '</button></div>'
113 _ajaxSetup: function () {
116 actionName
: 'editSubject',
117 className
: 'wcf\\data\\conversation\\ConversationAction'