From 06d37c9a4b45cbf896137be8d416dda962a55eae Mon Sep 17 00:00:00 2001 From: Philipp Nowinski <philipp@sgalinski.de> Date: Thu, 18 May 2017 13:26:34 +0200 Subject: [PATCH] [TASK] add code docs --- Classes/Controller/Ajax/LikeController.php | 7 +++++++ Resources/Public/Scripts/Likes.js | 14 +++++++++++++- composer.json | 2 +- ext_emconf.php | 2 +- 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/Classes/Controller/Ajax/LikeController.php b/Classes/Controller/Ajax/LikeController.php index 8f6956e..8373cab 100644 --- a/Classes/Controller/Ajax/LikeController.php +++ b/Classes/Controller/Ajax/LikeController.php @@ -31,9 +31,16 @@ use TYPO3\CMS\Core\Database\DatabaseConnection; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Frontend\Page\PageRepository; +/** + * The LikeController handles the Ajax-Actions related to the like feature + * + * @package SGalinski\SgNews\Controller\Ajax + */ class LikeController extends AbstractAjaxController { /** + * This action increases the tx_sgnews_likes field of a given page ($newsPid) by one + * * @param int $newsPid * @return string */ diff --git a/Resources/Public/Scripts/Likes.js b/Resources/Public/Scripts/Likes.js index 623ee8b..3f896f0 100644 --- a/Resources/Public/Scripts/Likes.js +++ b/Resources/Public/Scripts/Likes.js @@ -1,5 +1,6 @@ 'use strict'; +// We rely on a global jQuery instance here, so don't initialize the module if none is found if (window.hasOwnProperty('$')) { var $likeContainer = $('#tx-sgnews-likes'), $likeButton = $likeContainer.find('.btn'), @@ -7,9 +8,12 @@ if (window.hasOwnProperty('$')) { newsId = $likeContainer.data('uid'); $likeButton.on('click', addLike); - checkButtonStatus(); + /** + * Fires the Ajax-Call to add a new Like + * Won't do anything if the user already committed a like + */ function addLike() { if (!window.localStorage.getItem('sg-news-like-' + newsId)) { $likeButton.addClass('tx-sgnews-loading'); @@ -26,12 +30,20 @@ if (window.hasOwnProperty('$')) { } } + /** + * Checks if the user already committed a like and updates the button accordingly + */ function checkButtonStatus() { if (window.localStorage.getItem('sg-news-like-' + newsId)) { updateButton(false); } } + /** + * Update the like-button status + * + * @param {bool} addedLike If set to true, the like-count will also be increased + */ function updateButton(addedLike) { $likeButton.removeClass('btn-info').addClass('btn-success'); $likeButton.find('.fa-star-o').removeClass('fa-star-o').addClass('fa-star'); diff --git a/composer.json b/composer.json index ed6a7e2..40ac866 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,7 @@ "license": [ "GPL-2.0+" ], - "version": "3.7.0", + "version": "3.7.1", "support": { }, "repositories": [ diff --git a/ext_emconf.php b/ext_emconf.php index c949ff1..fface53 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -19,7 +19,7 @@ $EM_CONF[$_EXTKEY] = [ 'modify_tables' => '', 'clearCacheOnLoad' => 0, 'lockType' => '', - 'version' => '3.7.0', + 'version' => '3.7.1', 'constraints' => [ 'depends' => [ 'typo3' => '7.6.0-7.6.99', -- GitLab