/** * Gives auto height while typing on textarea elements * * Usage: *
* * Source: * https://github.com/monospaced/angular-elastic/blob/master/elastic.js * */ angular.module('superdesk.core.ui.autoheight', []).directive('sdAutoHeight', ['$window', function($window) { return { require: 'ngModel', restrict: 'A, C', link: function(scope, element, attrs, ngModel) { // cache a reference to the DOM element var ta = element[0], $ta = element; // ensure the element is a textarea, and browser is capable if (ta.nodeName !== 'TEXTAREA' || !$window.getComputedStyle) { return; } // set these properties before measuring dimensions $ta.css({ overflow: 'hidden', 'overflow-y': 'hidden', 'word-wrap': 'break-word', }); // force text reflow var text = ta.value; ta.value = ''; ta.value = text; var $win = angular.element($window), mirrorStyle, mirrorStyleBasic = 'position: absolute; top: -999px; right: auto; bottom: auto; left: 0 ;' + 'overflow: hidden; -webkit-box-sizing: content-box;' + '-moz-box-sizing: content-box; box-sizing: content-box;' + 'min-height: 0 !important; height: 0 !important; padding: 0;' + 'word-wrap: break-word; border: 0;', $mirror = angular.element('