1 define([], function () {
4 angular.module('app.yangman').directive('heightWatcher', heightWatcherDirective);
6 function heightWatcherDirective() {
9 link: function (scope, element, attrs) {
10 scope.$watch(function () {
11 return element.css(attrs['watchAttribute']);
12 }, heightChangedCallBack,
15 scope.heightTotal = null;
17 function heightChangedCallBack(newHeight, oldHeight) {
18 var heightReceivedData, heightSentData;
20 if (newHeight !== oldHeight) {
21 // set total available height
22 scope.heightTotal = angular.element('#jsonSection')[0].offsetHeight;
24 // set full height of ReceiveData (if there will be no sent data)
25 angular.element('#ReceiveData').css('height', scope.heightTotal + 'px');
27 heightSentData = angular.element('#sentData')[0].offsetHeight;
28 heightReceivedData = angular.element('#ReceiveData')[0].offsetHeight;
30 // set ReceiveData height to fill up bottom
31 if ((heightSentData + heightReceivedData) < scope.heightTotal) {
32 angular.element('#ReceiveData').css('height', scope.heightTotal - heightSentData + 'px');