[
'Ajax', 'Core', 'Dictionary', 'Language',
'ObjectMap', 'StringUtil', 'Dom/ChangeListener', 'Dom/Util',
- 'Ui/Dialog', 'WoltLabSuite/Core/Ui/User/List', 'User', 'WoltLabSuite/Core/Ui/Reaction/CountButtons',
+ 'Ui/Dialog', 'WoltLabSuite/Core/Ui/User/List', 'User', 'WoltLabSuite/Core/Ui/Reaction/CountButtons',
'Ui/Alignment', 'Ui/CloseOverlay', 'Ui/Screen'
],
function(
Ajax, Core, Dictionary, Language,
ObjectMap, StringUtil, DomChangeListener, DomUtil,
- UiDialog, UiUserList, User, CountButtons,
+ UiDialog, UiUserList, User, CountButtons,
UiAlignment, UiCloseOverlay, UiScreen
)
{
UiReactionHandler.prototype = {
/**
* Initializes the reaction handler.
- *
+ *
* @param {string} objectType object type
* @param {object} options initialization options
*/
this._popoverCurrentObjectId = 0;
- this._popover = null;
+ this._popover = null;
this._options = Core.extend({
// selectors
- buttonSelector: '.reactButton',
+ buttonSelector: '.reactButton',
containerSelector: '',
isButtonGroupNavigation: false,
isSingleItem: false,
elementData = {
reactButton: null,
- objectId: ~~elData(element, 'object-id'),
+ objectId: ~~elData(element, 'object-id'),
element: element
};
if (elementData.reactButton === null || elementData.reactButton.length === 0) {
// the element may have no react button
- return;
+ return;
+ }
+
+ if (Object.keys(REACTION_TYPES).length === 1) {
+ var reaction = REACTION_TYPES[Object.keys(REACTION_TYPES)[0]];
+ elementData.reactButton.title = reaction.title;
+ var textSpan = elBySel('.invisible', elementData.reactButton);
+ textSpan.innerText = reaction.title;
}
if (elementData.reactButton.closest('.messageFooterGroup > .jsMobileNavigation')) {
/**
* Disables the mobile view for the reaction button.
- *
+ *
* @param {Element} element
*/
_disableMobileView: function(element) {
/**
* Setup the mobile view for the reaction button.
- *
+ *
* @param {Element} element
* @param {int} objectID
*/
},
/**
- * Toggle the visibility of the react popover.
+ * Toggle the visibility of the react popover.
*
* @param {int} objectId
* @param {Element} element
event.stopPropagation();
}
- if (this._popoverCurrentObjectId === 0 || this._popoverCurrentObjectId !== objectId) {
- this._openReactPopover(objectId, element);
+ if (Object.keys(REACTION_TYPES).length === 1) {
+ var reaction = REACTION_TYPES[Object.keys(REACTION_TYPES)[0]];
+ this._popoverCurrentObjectId = objectId;
+
+ this._react(reaction.reactionTypeID);
}
else {
- this._closePopover(objectId, element);
+ if (this._popoverCurrentObjectId === 0 || this._popoverCurrentObjectId !== objectId) {
+ this._openReactPopover(objectId, element);
+ }
+ else {
+ this._closePopover(objectId, element);
+ }
}
},
},
/**
- * Returns the react popover element.
+ * Returns the react popover element.
*
* @returns {Element}
*/
DomChangeListener.trigger();
}
- return this._popover;
+ return this._popover;
},
/**
- * Sort the reaction types by the showOrder field.
+ * Sort the reaction types by the showOrder field.
*
* @returns {Array} the reaction types sorted by showOrder
*/
}
// sort the array
- sortedReactionTypes.sort(function (a, b) {
+ sortedReactionTypes.sort(function (a, b) {
if (a.showOrder > b.showOrder) {
return 1;
}
},
/**
- * Closes the react popover.
+ * Closes the react popover.
*/
_closePopover: function() {
if (this._popoverCurrentObjectId !== 0) {
// update react button status
this._updateReactButton(data.returnValues.objectID, data.returnValues.reactionTypeID);
},
-
+
_ajaxSetup: function() {
return {
data: {