harbor/static/resources/js/components/element-height/element-height.inspector.js

44 lines
1.2 KiB
JavaScript
Raw Normal View History

2016-06-25 21:12:17 +02:00
(function() {
'use strict';
angular
.module('harbor.layout.element.height')
.directive('elementHeight', elementHeight);
function elementHeight($window) {
var directive = {
'restrict': 'A',
'link': link
};
return directive;
function link(scope, element, attrs) {
2016-06-25 21:12:17 +02:00
var w = angular.element($window);
2016-06-25 21:12:17 +02:00
scope.getDimension = function() {
return {'h' : w.height()};
};
2016-06-25 21:12:17 +02:00
if(!angular.isDefined(scope.subsHeight)) scope.subsHeight = 110;
if(!angular.isDefined(scope.subsSection)) scope.subsSection = 32;
if(!angular.isDefined(scope.subsSubPane)) scope.subsSubPane = 226;
2016-06-26 06:56:58 +02:00
2016-06-25 21:12:17 +02:00
scope.$watch(scope.getDimension, function(current) {
if(current) {
var h = current.h;
2016-06-26 06:56:58 +02:00
element.find('.section').css({'height': (h - scope.subsHeight - scope.subsSection) + 'px'});
2016-06-25 21:12:17 +02:00
element.find('.sub-pane').css({'height': (h - scope.subsHeight - scope.subsSubPane) + 'px'});
element.find('.tab-pane').css({'height': (h - scope.subsHeight - scope.subsSubPane) + 'px'});
2016-06-25 21:12:17 +02:00
}
}, true);
w.on('pageshow, resize', function() {
2016-06-25 21:12:17 +02:00
scope.$apply();
});
}
}
})();