moodle/lib/amd/build/auto_rows.min.js
2016-10-11 14:39:24 +08:00

1 line
482 B
JavaScript

define(["jquery"],function(a){var b={ELEMENT:"[data-auto-rows]"},c={ROW_CHANGE:"autorows:rowchange"},d=function(a){var b=a.attr("rows"),c=a.attr("data-max-rows"),d=a.height(),e=a.innerHeight(),f=e-d;a.height("1px");var g=a[0].scrollHeight,h=(g-f)/(d/b);return a.css("height",""),c&&h>=c?c:h},e=function(e){a(e).on("input propertychange",b.ELEMENT,function(b){var f=a(b.target),g=f.attr("rows"),h=d(f);h!=g&&(f.attr("rows",h),a(e).trigger(c.ROW_CHANGE))})};return{init:e,events:c}});