Improved textarea

This commit is contained in:
Pierre 2017-06-21 16:17:45 +02:00
parent 836127d08f
commit b2924cb14e
2 changed files with 17 additions and 1 deletions

View File

@ -16,6 +16,9 @@ var textArea2 = function(infos){
* *
* @param {Object} infos Informations about the textarea to enable * @param {Object} infos Informations about the textarea to enable
* @info {HTMLElement} element The element to make modern * @info {HTMLElement} element The element to make modern
* @info {Integer} minHeight The minimal height for the textarea
* @info {Integer} maxHeight The maximal height for the textarea
* @return {Boolean} True for a success
*/ */
textArea2.prototype.init = function(infos){ textArea2.prototype.init = function(infos){
@ -24,10 +27,21 @@ textArea2.prototype.init = function(infos){
//Adapt textarea style //Adapt textarea style
this.element.style.overflow = "hidden"; this.element.style.overflow = "hidden";
this.element.style.resize = "none";
//Check for minimal and maximal height
if(infos.minHeight){
this.element.style.height = infos.minHeight;
this.element.style.minHeight = infos.minHeight;
}
if(infos.maxHeight)
this.element.style.maxHeight = infos.maxHeight;
//Initializate textarea auto-size //Initializate textarea auto-size
$(this.element).textareaAutoSize(); $(this.element).textareaAutoSize();
//Success
return true;
}; };
/** /**

View File

@ -55,7 +55,9 @@ ComunicWeb.pages.home.home = {
//Initializate textarea //Initializate textarea
var textarea2 = new ComunicWeb.components.textarea(); var textarea2 = new ComunicWeb.components.textarea();
textarea2.init({ textarea2.init({
element: textarea element: textarea,
minHeight: "32px",
maxHeight: "70px",
}); });
console.log(textarea2); console.log(textarea2);