From 65d75243ec2412a7163d09028b0c355469eb89d9 Mon Sep 17 00:00:00 2001 From: Pierre Date: Sat, 3 Feb 2018 15:58:28 +0100 Subject: [PATCH] Display latest posts. --- assets/css/pages/latestPosts/main.css | 9 +++++ assets/js/pages/latestPosts/main.js | 48 ++++++++++++++++++++++++++- 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/assets/css/pages/latestPosts/main.css b/assets/css/pages/latestPosts/main.css index a9f86b77..ae68eccd 100644 --- a/assets/css/pages/latestPosts/main.css +++ b/assets/css/pages/latestPosts/main.css @@ -12,4 +12,13 @@ max-width: 500px; margin: auto; margin-top: 30px; +} + +.latest-posts-row { + padding-top: 15px; +} + +.latest-posts-row .col-md-6 { + margin: auto; + float: none; } \ No newline at end of file diff --git a/assets/js/pages/latestPosts/main.js b/assets/js/pages/latestPosts/main.js index b1b07f1b..cbc5ca22 100644 --- a/assets/js/pages/latestPosts/main.js +++ b/assets/js/pages/latestPosts/main.js @@ -29,8 +29,54 @@ ComunicWeb.pages.latestPosts.main = { } //Display the list of posts - + ComunicWeb.pages.latestPosts.main._display_list(response, target); }); }, + + /** + * Display the list of latest post + * + * @param {Object} list The list of posts to display + * @param {HTMLElement} target The target for the posts + */ + _display_list: function(list, target){ + + //Create post list box + //Create row + var pageRow = createElem2({ + appendTo: target, + type: "div", + class: "row latest-posts-row" + }); + + //Post column + var column = createElem2({ + appendTo: pageRow, + type: "div", + class: "col-md-6" + }); + + //Create post box + var postBox = createElem2({ + appendTo: column, + type: "div", + class: "box box-primary" + }); + + //Create box body + var boxBody = createElem2({ + appendTo: postBox, + type: "div", + class: "box-body" + }); + + //Process the list of posts + for (let index = 0; index < list.length; index++) { + + //Display the post + ComunicWeb.components.posts.ui.display_post(list[index], boxBody); + + } + } } \ No newline at end of file