From: Matthias Schmidt Date: Thu, 4 Aug 2016 19:31:50 +0000 (+0200) Subject: Move JavaScript modules into WoltLabSuite/Core namespace X-Git-Tag: 3.0.0_Beta_1~33 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=ab10f51ff4a292ec43ec4bb04d92524e30a78a2e;p=GitHub%2FWoltLab%2Fcom.woltlab.wcf.conversation.git Move JavaScript modules into WoltLabSuite/Core namespace --- diff --git a/files/js/WoltLab/Conversation/Ui/Participant/Add.js b/files/js/WoltLab/Conversation/Ui/Participant/Add.js deleted file mode 100644 index c483259..0000000 --- a/files/js/WoltLab/Conversation/Ui/Participant/Add.js +++ /dev/null @@ -1,123 +0,0 @@ -/** - * Adds participants to an existing conversation. - * - * @author Alexander Ebert - * @copyright 2001-2016 WoltLab GmbH - * @license GNU Lesser General Public License - * @module WoltLab/Conversation/Ui/Participant/Add - */ -define(['Ajax', 'Language', 'Ui/Dialog', 'Ui/Notification', 'WoltLab/WCF/Ui/ItemList/User'], function(Ajax, Language, UiDialog, UiNotification, UiItemListUser) { - "use strict"; - - /** - * @constructor - * @param {int} conversationId conversation id - */ - function UiParticipantAdd(conversationId) { this.init(conversationId); } - UiParticipantAdd.prototype = { - /** - * Manages the form to add one or more participants to an existing conversation. - * - * @param {int} conversationId conversation id - */ - init: function(conversationId) { - this._conversationId = conversationId; - - Ajax.api(this, { - actionName: 'getAddParticipantsForm' - }); - }, - - _ajaxSetup: function() { - return { - data: { - className: 'wcf\\data\\conversation\\ConversationAction', - objectIDs: [ this._conversationId ] - } - }; - }, - - /** - * Handles successful Ajax requests. - * - * @param {Object} data response data - */ - _ajaxSuccess: function(data) { - switch (data.actionName) { - case 'addParticipants': - this._handleResponse(data); - break; - - case 'getAddParticipantsForm': - this._render(data); - break; - } - }, - - /** - * Shows the success message and closes the dialog overlay. - * - * @param {Object} data response data - */ - _handleResponse: function(data) { - //noinspection JSUnresolvedVariable - if (data.returnValues.count) { - //noinspection JSUnresolvedVariable - UiNotification.show(data.returnValues.successMessage); - } - - UiDialog.close(this); - }, - - /** - * Renders the dialog to add participants. - * - * @param {object} data response data - */ - _render: function(data) { - //noinspection JSUnresolvedVariable - UiDialog.open(this, data.returnValues.template); - - var buttonSubmit = document.getElementById('addParticipants'); - buttonSubmit.disabled = true; - - //noinspection JSUnresolvedVariable - UiItemListUser.init('participantsInput', { - callbackChange: function(elementId, values) { buttonSubmit.disabled = (values.length === 0); }, - excludedSearchValues: data.returnValues.excludedSearchValues, - maxItems: data.returnValues.maxItems - }); - - buttonSubmit.addEventListener('click', this._submit.bind(this)); - }, - - /** - * Sends a request to add participants. - */ - _submit: function() { - var values = UiItemListUser.getValues('participantsInput'), participants = []; - for (var i = 0, length = values.length; i < length; i++) { - participants.push(values[i].value); - } - - Ajax.api(this, { - actionName: 'addParticipants', - parameters: { - participants: participants - } - }); - }, - - _dialogSetup: function() { - return { - id: 'conversationAddParticipants', - options: { - title: Language.get('wcf.conversation.edit.addParticipants') - }, - source: null - }; - } - }; - - return UiParticipantAdd; -}); diff --git a/files/js/WoltLabSuite/Core/Conversation/Ui/Participant/Add.js b/files/js/WoltLabSuite/Core/Conversation/Ui/Participant/Add.js new file mode 100644 index 0000000..fe5517f --- /dev/null +++ b/files/js/WoltLabSuite/Core/Conversation/Ui/Participant/Add.js @@ -0,0 +1,123 @@ +/** + * Adds participants to an existing conversation. + * + * @author Alexander Ebert + * @copyright 2001-2016 WoltLab GmbH + * @license GNU Lesser General Public License + * @module WoltLabSuite/Core/Conversation/Ui/Participant/Add + */ +define(['Ajax', 'Language', 'Ui/Dialog', 'Ui/Notification', 'WoltLabSuite/Core/Ui/ItemList/User'], function(Ajax, Language, UiDialog, UiNotification, UiItemListUser) { + "use strict"; + + /** + * @constructor + * @param {int} conversationId conversation id + */ + function UiParticipantAdd(conversationId) { this.init(conversationId); } + UiParticipantAdd.prototype = { + /** + * Manages the form to add one or more participants to an existing conversation. + * + * @param {int} conversationId conversation id + */ + init: function(conversationId) { + this._conversationId = conversationId; + + Ajax.api(this, { + actionName: 'getAddParticipantsForm' + }); + }, + + _ajaxSetup: function() { + return { + data: { + className: 'wcf\\data\\conversation\\ConversationAction', + objectIDs: [ this._conversationId ] + } + }; + }, + + /** + * Handles successful Ajax requests. + * + * @param {Object} data response data + */ + _ajaxSuccess: function(data) { + switch (data.actionName) { + case 'addParticipants': + this._handleResponse(data); + break; + + case 'getAddParticipantsForm': + this._render(data); + break; + } + }, + + /** + * Shows the success message and closes the dialog overlay. + * + * @param {Object} data response data + */ + _handleResponse: function(data) { + //noinspection JSUnresolvedVariable + if (data.returnValues.count) { + //noinspection JSUnresolvedVariable + UiNotification.show(data.returnValues.successMessage); + } + + UiDialog.close(this); + }, + + /** + * Renders the dialog to add participants. + * + * @param {object} data response data + */ + _render: function(data) { + //noinspection JSUnresolvedVariable + UiDialog.open(this, data.returnValues.template); + + var buttonSubmit = document.getElementById('addParticipants'); + buttonSubmit.disabled = true; + + //noinspection JSUnresolvedVariable + UiItemListUser.init('participantsInput', { + callbackChange: function(elementId, values) { buttonSubmit.disabled = (values.length === 0); }, + excludedSearchValues: data.returnValues.excludedSearchValues, + maxItems: data.returnValues.maxItems + }); + + buttonSubmit.addEventListener('click', this._submit.bind(this)); + }, + + /** + * Sends a request to add participants. + */ + _submit: function() { + var values = UiItemListUser.getValues('participantsInput'), participants = []; + for (var i = 0, length = values.length; i < length; i++) { + participants.push(values[i].value); + } + + Ajax.api(this, { + actionName: 'addParticipants', + parameters: { + participants: participants + } + }); + }, + + _dialogSetup: function() { + return { + id: 'conversationAddParticipants', + options: { + title: Language.get('wcf.conversation.edit.addParticipants') + }, + source: null + }; + } + }; + + return UiParticipantAdd; +}); diff --git a/templates/conversationAdd.tpl b/templates/conversationAdd.tpl index db9b381..66258ab 100644 --- a/templates/conversationAdd.tpl +++ b/templates/conversationAdd.tpl @@ -131,7 +131,7 @@