AutorÃa | Ultima modificación | Ver Log |
/**
* Enhance a textarea with auto growing rows to fit the content.
*
* @module core/auto_rows
* @copyright 2016 Ryan Wyllie <ryan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @since 3.2
*/
define("core/auto_rows",["jquery"],(function($){var SELECTORS_ELEMENT="[data-auto-rows]",EVENTS={ROW_CHANGE:"autorows:rowchange"},changeListener=function(e){var element=$(e.target),minRows=element.data("min-rows"),currentRows=element.attr("rows");void 0===minRows&&element.data("min-rows",currentRows),element.attr("rows",1);var rows=function(element){var currentRows=element.attr("rows"),minRows=element.data("min-rows"),maxRows=element.attr("data-max-rows"),height=element.height(),padding=element.innerHeight()-height,rows=(element[0].scrollHeight-padding)/(height/currentRows);return element.css("height",""),rows<minRows?minRows:maxRows&&rows>=maxRows?maxRows:rows}(element);element.attr("rows",rows),rows!=currentRows&&element.trigger(EVENTS.ROW_CHANGE)};return{init:function(root){$(root).data("auto-rows")?$(root).on("input propertychange",changeListener.bind(this)):$(root).on("input propertychange",SELECTORS_ELEMENT,changeListener.bind(this))},events:EVENTS}}));
//# sourceMappingURL=auto_rows.min.js.map