mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-26 05:49:22 +00:00
Update like status on the database
This commit is contained in:
parent
e834b06b16
commit
1147ab787e
@ -625,6 +625,13 @@ var ComunicWeb = {
|
||||
//TODO : implement
|
||||
},
|
||||
|
||||
/**
|
||||
* Likes API interface
|
||||
*/
|
||||
interface: {
|
||||
//TODO : implement
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -88,6 +88,7 @@ ComunicWeb.components.like.button = {
|
||||
count = newliking ? count + 1 : count - 1;
|
||||
|
||||
//Update liking status on the API
|
||||
ComunicWeb.components.like.interface.update(kind, id, newliking);
|
||||
|
||||
//Display liking element again
|
||||
ComunicWeb.components.like.button.display(kind, id, count, newliking, target);
|
||||
|
29
assets/js/components/like/interface.js
Normal file
29
assets/js/components/like/interface.js
Normal file
@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Likes API interface
|
||||
*
|
||||
* @author Pierre HUBERT
|
||||
*/
|
||||
|
||||
ComunicWeb.components.like.interface = {
|
||||
|
||||
/**
|
||||
* Update like status
|
||||
*
|
||||
* @param {String} type The type of component
|
||||
* @param {Integer} id The ID of the element
|
||||
* @param {Boolean} like New like status
|
||||
*/
|
||||
update: function(type, id, like){
|
||||
|
||||
//Perform an API request
|
||||
var apiURI = "likes/update";
|
||||
var params = {
|
||||
type: type,
|
||||
id: id,
|
||||
like: like
|
||||
};
|
||||
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true);
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -160,6 +160,7 @@ $config['JSfiles'] = array(
|
||||
|
||||
//Like button
|
||||
"%PATH_ASSETS%js/components/like/button.js",
|
||||
"%PATH_ASSETS%js/components/like/interface.js",
|
||||
|
||||
//Modern textarea handler
|
||||
"%PATH_ASSETS%js/components/textarea.js",
|
||||
|
Loading…
Reference in New Issue
Block a user