Skip to content
Snippets Groups Projects
Commit 06d37c9a authored by Philipp Nowinski's avatar Philipp Nowinski
Browse files

[TASK] add code docs

parent fd45db23
No related branches found
Tags 3.7.1
No related merge requests found
......@@ -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
*/
......
'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');
......
......@@ -6,7 +6,7 @@
"license": [
"GPL-2.0+"
],
"version": "3.7.0",
"version": "3.7.1",
"support": {
},
"repositories": [
......
......@@ -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',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment