ComunicWeb/assets/js/pages/home/home.js

71 lines
2.1 KiB
JavaScript
Raw Normal View History

/**
* Common homes functions
2017-02-18 17:37:36 +00:00
*
* @author Pierre HUBERT
*/
ComunicWeb.pages.home.home = {
/**
* Open home page
2017-02-18 17:37:36 +00:00
*
* @param {Object} additionnalData Additionnal data passed in the method
* @param {element} targetElement Where the template will be applied
* @returns {Boolean} False if it fails
*/
openHomePage: function(additionnalData, targetElement){
//Check wether if user is logged in or not
var userLoggedIn = ComunicWeb.user.userLogin.getUserLoginState();
2017-05-22 16:12:50 +00:00
//Check if user is in or not
if(userLoggedIn){
2017-05-22 16:12:50 +00:00
//Dev feature : Show result
targetElement.appendChild(ComunicWeb.common.messages.createCalloutElem("", "User logged in !", "info"));
2017-03-01 14:37:55 +00:00
//Create logout button
var loginButton = document.createElement("button");
loginButton.onclick = (function(){
ComunicWeb.common.page.openPage("logout");
});
loginButton.innerHTML="Logout";
targetElement.appendChild(loginButton);
2017-06-05 14:03:14 +00:00
2017-06-21 10:10:22 +00:00
2017-06-20 11:29:15 +00:00
//Dev feature emojies
var emojiesArea = createElem2({
appendTo: targetElement,
type: "p",
innerHTML: "Emoji test : :) 🇬🇫 🎅🏻 :( (movie) (cool)"
2017-06-20 11:29:15 +00:00
});
//Parse emojies
ComunicWeb.components.emoji.parser.parse({
element: emojiesArea,
});
2017-06-21 10:10:22 +00:00
//Create textarea element
var textarea = createFormGroup({
target: targetElement,
type: "textarea",
label: "Textarea",
placeholder: "New message",
});
textarea.style.width = "200px";
//Initializate textarea
var textarea2 = new ComunicWeb.components.textarea();
textarea2.init({
element: textarea
});
console.log(textarea2);
}
else{
2017-05-22 16:12:50 +00:00
//Display landing page
ComunicWeb.pages.home.landingPage.display(targetElement);
}
//Everything seems to be OK
return true;
}
};