'wcf.like.reaction.more': '{lang}wcf.like.reaction.more{/lang}'
});
- new UiReactionProfileLoader({@$userID}, {@$firstReactionTypeID});
+ new UiReactionProfileLoader({@$userID});
});
</script>
<ul class="buttonGroup" id="reactionType">
{foreach from=$__wcf->getReactionHandler()->getReactionTypes() item=reactionType name=reactionTypeLoop}
- <li><a class="button small jsTooltip{if $tpl.foreach.reactionTypeLoop.first} active{/if}" data-reaction-type-id="{$reactionType->reactionTypeID}" title="{$reactionType->getTitle()}">{@$reactionType->renderIcon()} <span class="invisible">{$reactionType->getTitle()}</span></a></li>
+ <li><a class="button small jsTooltip" data-reaction-type-id="{$reactionType->reactionTypeID}" title="{$reactionType->getTitle()}">{@$reactionType->renderIcon()} <span class="invisible">{$reactionType->getTitle()}</span></a></li>
{/foreach}
</ul>
</li>
/**
* @constructor
*/
- function UiReactionProfileLoader(userID, firstReactionTypeID) { this.init(userID, firstReactionTypeID); }
+ function UiReactionProfileLoader(userID) { this.init(userID); }
UiReactionProfileLoader.prototype = {
/**
* Initializes a new ReactionListLoader object.
*
* @param integer userID
*/
- init: function(userID, firstReactionTypeID) {
+ init: function(userID) {
this._container = elById('likeList');
this._userID = userID;
- this._reactionTypeID = firstReactionTypeID;
+ this._reactionTypeID = null;
this._targetType = 'received';
this._options = {
parameters: []
throw new Error("[WoltLabSuite/Core/Ui/Reaction/Profile/Loader] Invalid parameter 'userID' given.");
}
- if (!this._reactionTypeID) {
- throw new Error("[WoltLabSuite/Core/Ui/Reaction/Profile/Loader] Invalid parameter 'firstReactionTypeID' given.");
- }
-
var loadButtonList = elCreate('li');
loadButtonList.className = 'likeListMore showMore';
this._noMoreEntries = elCreate('small');
* @param {int} reactionTypeID
*/
_changeReactionTypeValue: function(reactionTypeID) {
+ // remove old active state
+ var activeButton = elBySel('#reactionType .button.active');
+ if (activeButton) {
+ activeButton.classList.remove('active');
+ }
+
if (this._reactionTypeID !== reactionTypeID) {
- // remove old active state
- elBySel('#reactionType .button.active').classList.remove('active');
-
// add active status to new button
elBySel('#reactionType .button[data-reaction-type-id="'+ reactionTypeID +'"]').classList.add('active');
this._reactionTypeID = reactionTypeID;
- this._reload();
}
+ else {
+ this._reactionTypeID = null;
+ }
+
+ this._reload();
},
/**
$this->readInteger('lastLikeTime', true);
$this->readInteger('userID');
- $this->readInteger('reactionTypeID');
+ $this->readInteger('reactionTypeID', true);
$this->readString('targetType');
$user = UserProfileRuntimeCache::getInstance()->getObject($this->parameters['userID']);
else {
$likeList->getConditionBuilder()->add("like_table.userID = ?", [$this->parameters['userID']]);
}
- $likeList->getConditionBuilder()->add("like_table.reactionTypeID = ?", [$this->parameters['reactionTypeID']]);
+ if ($this->parameters['reactionTypeID']) {
+ $likeList->getConditionBuilder()->add("like_table.reactionTypeID = ?", [$this->parameters['reactionTypeID']]);
+ }
$likeList->readObjects();
if (empty($likeList)) {
<?php
namespace wcf\system\menu\user\profile\content;
use wcf\data\like\ViewableLikeList;
-use wcf\system\reaction\ReactionHandler;
use wcf\system\SingletonFactory;
use wcf\system\WCF;
* @inheritDoc
*/
public function getContent($userID) {
- $reactionTypes = ReactionHandler::getInstance()->getReactionTypes();
- $firstReactionType = reset($reactionTypes);
-
$likeList = new ViewableLikeList();
$likeList->getConditionBuilder()->add("like_table.objectUserID = ?", [$userID]);
- $likeList->getConditionBuilder()->add("like_table.reactionTypeID = ?", [$firstReactionType->reactionTypeID]);
$likeList->readObjects();
WCF::getTPL()->assign([
'likeList' => $likeList,
'userID' => $userID,
- 'lastLikeTime' => $likeList->getLastLikeTime(),
- 'firstReactionTypeID' => $firstReactionType->reactionTypeID
+ 'lastLikeTime' => $likeList->getLastLikeTime()
]);
return WCF::getTPL()->fetch('userProfileLikes');