mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-22 20:19:21 +00:00
Added no post on page notice
This commit is contained in:
parent
57599bc47f
commit
a697d044db
@ -25,9 +25,17 @@ ComunicWeb.pages.userPage.posts = {
|
|||||||
var postsBody = createElem2({
|
var postsBody = createElem2({
|
||||||
appendTo: postsBlock,
|
appendTo: postsBlock,
|
||||||
type: "div",
|
type: "div",
|
||||||
class: "box-body"
|
class: "box-body",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//Display loading message
|
||||||
|
var loadingMsg = createElem2({
|
||||||
|
appendTo: postsBody,
|
||||||
|
type: "p",
|
||||||
|
innerHTML: "Loading posts..."
|
||||||
|
});
|
||||||
|
loadingMsg.style.textAlign = "center";
|
||||||
|
|
||||||
//Get the posts from the API
|
//Get the posts from the API
|
||||||
ComunicWeb.components.posts.interface.get_user(userInfos.userID, function(result){
|
ComunicWeb.components.posts.interface.get_user(userInfos.userID, function(result){
|
||||||
|
|
||||||
@ -38,6 +46,9 @@ ComunicWeb.pages.userPage.posts = {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
|
//Empty the target
|
||||||
|
emptyElem(postsBody);
|
||||||
|
|
||||||
//Show the posts
|
//Show the posts
|
||||||
ComunicWeb.pages.userPage.posts._show(result, postsBody);
|
ComunicWeb.pages.userPage.posts._show(result, postsBody);
|
||||||
|
|
||||||
@ -50,10 +61,10 @@ ComunicWeb.pages.userPage.posts = {
|
|||||||
* Show user posts
|
* Show user posts
|
||||||
*
|
*
|
||||||
* @param {Object} posts The list of posts to display
|
* @param {Object} posts The list of posts to display
|
||||||
* @param {HMTLElement} target The rendering target
|
* @param {HTMLElement} target The rendering target
|
||||||
*/
|
*/
|
||||||
_show: function(posts, target){
|
_show: function(posts, target){
|
||||||
|
|
||||||
//Process each post
|
//Process each post
|
||||||
var i;
|
var i;
|
||||||
for(i in posts){
|
for(i in posts){
|
||||||
@ -63,8 +74,40 @@ ComunicWeb.pages.userPage.posts = {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Check if there is not any posts
|
||||||
|
if(target.children.length == 0){
|
||||||
|
this._no_posts_msg(target);
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a message to inform user that there is not any post
|
||||||
|
* on the page he is visiting
|
||||||
|
*
|
||||||
|
* @param {HTMLElement} target The target for the message
|
||||||
|
*/
|
||||||
|
_no_posts_msg(target){
|
||||||
|
|
||||||
|
var msgContener = createElem2({
|
||||||
|
appendTo: target,
|
||||||
|
type: "div"
|
||||||
|
});
|
||||||
|
|
||||||
|
var msgTitle = createElem2({
|
||||||
|
appendTo: msgContener,
|
||||||
|
type: "h2",
|
||||||
|
innerHTML: "No post yet"
|
||||||
|
});
|
||||||
|
msgTitle.style.textAlign = "center";
|
||||||
|
|
||||||
|
var msgContent = createElem2({
|
||||||
|
appendTo: msgContener,
|
||||||
|
type: "p",
|
||||||
|
innerHTML: "Nobody has posted a message on this page yet."
|
||||||
|
}).style.textAlign = "center";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
Loading…
Reference in New Issue
Block a user