mirror of
				https://github.com/pierre42100/ComunicWeb
				synced 2025-11-04 12:14:12 +00:00 
			
		
		
		
	Created createFormGroup functoin
This commit is contained in:
		@@ -60,4 +60,36 @@ function emptyElem(container){
 | 
			
		||||
 */
 | 
			
		||||
function checkMail(emailAddress){
 | 
			
		||||
	return (emailAddress.match(/^[a-zA-Z0-9_.]+@[a-zA-Z0-9-]{1,}[.][a-zA-Z]{2,5}$/) === null ? false : true);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Create a formgroup element
 | 
			
		||||
 * 
 | 
			
		||||
 * @param {HTMLElement} target The target of the field
 | 
			
		||||
 * @param {String} label The label of the field
 | 
			
		||||
 * @param {String} placeholder The placeholder of the field
 | 
			
		||||
 * @param {String} type The type of the field
 | 
			
		||||
 * @return {HTMLElement} The input 
 | 
			
		||||
 */
 | 
			
		||||
function createFormGroup(target, label, placeholder, type){
 | 
			
		||||
	//Create formgroup
 | 
			
		||||
	var formGroup = createElem("div", target);
 | 
			
		||||
	formGroup.className = "form-group";
 | 
			
		||||
 | 
			
		||||
	//Add label
 | 
			
		||||
	var labelElem = createElem("label", formGroup);
 | 
			
		||||
	labelElem.innerHTML = label;
 | 
			
		||||
 | 
			
		||||
	//Create input group
 | 
			
		||||
	var inputGroup = createElem("div", formGroup);
 | 
			
		||||
	inputGroup.className = "input-group";
 | 
			
		||||
 | 
			
		||||
	//Create input
 | 
			
		||||
	var input = createElem("input", inputGroup);
 | 
			
		||||
	input.type = type;
 | 
			
		||||
	input.placeholder = placeholder;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	//Return input
 | 
			
		||||
	return input;
 | 
			
		||||
}
 | 
			
		||||
@@ -25,7 +25,53 @@ ComunicWeb.components.discussions.list = {
 | 
			
		||||
		//Remove footer
 | 
			
		||||
		listBox.boxFooter.remove();
 | 
			
		||||
 | 
			
		||||
		//Add the create button
 | 
			
		||||
		var createButton = createElem("button");
 | 
			
		||||
		listBox.boxTools.insertBefore(createButton, listBox.boxTools.children[0]);
 | 
			
		||||
		createButton.className = "btn btn-box-tool";
 | 
			
		||||
		createButton.onclick = function(){
 | 
			
		||||
			ComunicWeb.components.discussions.list.displayCreateForm(listBox);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
			//Button icon
 | 
			
		||||
			var createButtonIcon = createElem("i", createButton);
 | 
			
		||||
			createButtonIcon.className = "fa fa-pencil";
 | 
			
		||||
 | 
			
		||||
		//Display conversations list
 | 
			
		||||
		listBox.boxBody.innerHTML = "<p>Hello world</p>";
 | 
			
		||||
 | 
			
		||||
		//Success
 | 
			
		||||
		return true;
 | 
			
		||||
	},
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Display the form to create a new discussion
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @param {Object} listBox Informations about the listbox target
 | 
			
		||||
	 * @return {Boolean} True for a success
 | 
			
		||||
	 */
 | 
			
		||||
	displayCreateForm: function(listBox){
 | 
			
		||||
 | 
			
		||||
		//Log action
 | 
			
		||||
		ComunicWeb.debug.logMessage("INFO : initialize create discussion form");
 | 
			
		||||
 | 
			
		||||
		//Hide boxy body contents
 | 
			
		||||
		var boxBodyElem = listBox.boxBody.children;
 | 
			
		||||
		for(i in boxBodyElem){
 | 
			
		||||
			if(boxBodyElem[i].style)
 | 
			
		||||
				boxBodyElem[i].style.display = "none";
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		//Change box title
 | 
			
		||||
		listBox.boxTitle.innerHTML = "New discussion";
 | 
			
		||||
 | 
			
		||||
		//Create and display discussion creation form
 | 
			
		||||
		var createForm = createElem("div", listBox.boxBody);
 | 
			
		||||
 | 
			
		||||
		//Discussion name
 | 
			
		||||
		var discussionNameInput = createFormGroup()
 | 
			
		||||
 | 
			
		||||
		//Success
 | 
			
		||||
		return true;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user