mirror of
https://github.com/cwinfo/powerdns-admin.git
synced 2025-01-08 03:15:40 +00:00
6 lines
2.6 KiB
JavaScript
6 lines
2.6 KiB
JavaScript
/*!
|
|
Autosize 3.0.0
|
|
license: MIT
|
|
http://www.jacklmoore.com/autosize
|
|
*/
|
|
!function(e,t){if("function"==typeof define&&define.amd)define(["exports","module"],t);else if("undefined"!=typeof exports&&"undefined"!=typeof module)t(exports,module);else{var o={exports:{}};t(o.exports,o),e.autosize=o.exports}}(this,function(e,t){"use strict";function o(e){function t(){var t=window.getComputedStyle(e,null);"vertical"===t.resize?e.style.resize="none":"both"===t.resize&&(e.style.resize="horizontal");var r=e.style.width;e.style.width="0px",e.offsetWidth,e.style.width=r,n="none"!==t.maxHeight?parseFloat(t.maxHeight):!1,i="content-box"===t.boxSizing?-(parseFloat(t.paddingTop)+parseFloat(t.paddingBottom)):parseFloat(t.borderTopWidth)+parseFloat(t.borderBottomWidth),o()}function o(){var t=e.style.height,o=document.documentElement.scrollTop,r=document.body.scrollTop;e.style.height="auto";var d=e.scrollHeight+i;if(n!==!1&&d>n?(d=n,"scroll"!==e.style.overflowY&&(e.style.overflowY="scroll")):"hidden"!==e.style.overflowY&&(e.style.overflowY="hidden"),e.style.height=d+"px",document.documentElement.scrollTop=o,document.body.scrollTop=r,t!==e.style.height){var s=document.createEvent("Event");s.initEvent("autosize:resized",!0,!1),e.dispatchEvent(s)}}if(e&&e.nodeName&&"TEXTAREA"===e.nodeName&&!e.hasAttribute("data-autosize-on")){var n,i;e.addEventListener("autosize:destroy",function(t){window.removeEventListener("resize",o),e.removeEventListener("input",o),e.removeEventListener("keyup",o),e.removeAttribute("data-autosize-on"),e.removeEventListener("autosize:destroy"),Object.keys(t).forEach(function(o){e.style[o]=t[o]})}.bind(e,{height:e.style.height,overflowY:e.style.overflowY,resize:e.style.resize})),"onpropertychange"in e&&"oninput"in e&&e.addEventListener("keyup",o),window.addEventListener("resize",o),e.addEventListener("input",o),e.addEventListener("autosize:update",o),e.setAttribute("data-autosize-on",!0),e.style.overflowY="hidden",t()}}function n(e){if(e&&e.nodeName&&"TEXTAREA"===e.nodeName){var t=document.createEvent("Event");t.initEvent("autosize:destroy",!0,!1),e.dispatchEvent(t)}}function i(e){if(e&&e.nodeName&&"TEXTAREA"===e.nodeName){var t=document.createEvent("Event");t.initEvent("autosize:update",!0,!1),e.dispatchEvent(t)}}var r;"function"!=typeof window.getComputedStyle?(r=function(e){return e},r.destroy=function(e){return e},r.update=function(e){return e}):(r=function(e){return e&&e.length?Array.prototype.forEach.call(e,o):e&&e.nodeName&&o(e),e},r.destroy=function(e){return e&&e.length?Array.prototype.forEach.call(e,n):e&&e.nodeName&&n(e),e},r.update=function(e){return e&&e.length?Array.prototype.forEach.call(e,i):e&&e.nodeName&&i(e),e}),t.exports=r}); |