mirror of
				https://github.com/pierre42100/ComunicWeb
				synced 2025-10-31 10:14:51 +00:00 
			
		
		
		
	Can reload single post
This commit is contained in:
		
							
								
								
									
										42
									
								
								assets/js/components/posts/actions.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								assets/js/components/posts/actions.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,42 @@ | |||||||
|  | /** | ||||||
|  |  * Post actions | ||||||
|  |  *  | ||||||
|  |  * @author Pierre HUBERT | ||||||
|  |  */ | ||||||
|  |  | ||||||
|  | ComunicWeb.components.posts.actions = { | ||||||
|  |  | ||||||
|  | 	/** | ||||||
|  | 	 * Reload a single post | ||||||
|  | 	 *  | ||||||
|  | 	 * @param {int} postID The ID of the post to reload | ||||||
|  | 	 * @param {HTMLElement} container The current container of the post | ||||||
|  | 	 */ | ||||||
|  | 	reload_post: function(postID, container){ | ||||||
|  |  | ||||||
|  | 		//Lock the post | ||||||
|  | 		container.style.visibility = "hidden"; | ||||||
|  |  | ||||||
|  | 		//Perform a request through the interface | ||||||
|  | 		ComunicWeb.components.posts.interface.get_single(postID, function(infos){ | ||||||
|  |  | ||||||
|  | 			//Make the post visible | ||||||
|  | 			container.style.visibility = "visible"; | ||||||
|  |  | ||||||
|  | 			//Check for errors | ||||||
|  | 			if(infos.error){ | ||||||
|  | 				ComunicWeb.common.notificationSystem.showNotification("An error occured while getting informations about the post !", "danger"); | ||||||
|  | 				return; | ||||||
|  | 			} | ||||||
|  |  | ||||||
|  | 			//Empty the post container | ||||||
|  | 			emptyElem(container); | ||||||
|  |  | ||||||
|  | 			//Display post | ||||||
|  | 			ComunicWeb.components.posts.ui.display_post(infos, container); | ||||||
|  | 			 | ||||||
|  | 		}); | ||||||
|  |  | ||||||
|  | 	}, | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -14,12 +14,17 @@ ComunicWeb.components.posts.ui = { | |||||||
| 	 */ | 	 */ | ||||||
| 	display_post: function(infos, target){ | 	display_post: function(infos, target){ | ||||||
|  |  | ||||||
| 		//Create post root element | 		//Check if it is required to create a post root element or not | ||||||
| 		var postRoot = createElem2({ | 		if(target.className.includes("post")) | ||||||
| 			appendTo: target, | 			postRoot = target; | ||||||
| 			type: "div", |  | ||||||
| 			class: "post" | 		else | ||||||
| 		}); | 			//Create post root element | ||||||
|  | 			var postRoot = createElem2({ | ||||||
|  | 				appendTo: target, | ||||||
|  | 				type: "div", | ||||||
|  | 				class: "post" | ||||||
|  | 			}); | ||||||
|  |  | ||||||
| 		//Display user block | 		//Display user block | ||||||
| 		var userBlock = createElem2({ | 		var userBlock = createElem2({ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Pierre
					Pierre