ComunicWeb/assets/js/components/textarea.js

58 lines
1.3 KiB
JavaScript
Raw Normal View History

2017-06-21 10:10:22 +00:00
/**
* Modern textarea handler
*
* @author Pierre HUBERT
*/
/**
* Create a modern textarea element object
*/
var textArea2 = function(infos){
//Nothing now
};
/**
* Initializate textarea 2.0 element
*
* @param {Object} infos Informations about the textarea to enable
* @info {HTMLElement} element The element to make modern
2017-06-21 14:17:45 +00:00
* @info {Integer} minHeight The minimal height for the textarea
* @info {Integer} maxHeight The maximal height for the textarea
* @return {Boolean} True for a success
2017-06-21 10:10:22 +00:00
*/
textArea2.prototype.init = function(infos){
//Save Textarea element
this.element = infos.element;
//Adapt textarea style
this.element.style.overflow = "hidden";
2017-06-21 14:17:45 +00:00
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;
2017-06-21 10:10:22 +00:00
//Initializate textarea auto-size
$(this.element).textareaAutoSize();
2017-06-21 14:17:45 +00:00
//Success
return true;
2017-06-21 10:10:22 +00:00
};
/**
* Get the textarea value
*
* @return {String} Textarea value
*/
textArea2.prototype.getValue = function(){
return this.element.innerText;
};
//Save the function in the system
ComunicWeb.components.textarea = textArea2;