2016-07-07 18:03:32 +02:00
|
|
|
/*
|
|
|
|
Copyright (c) 2016 VMware, Inc. All Rights Reserved.
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
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-28 07:12:25 +02:00
|
|
|
|
2016-06-25 21:12:17 +02:00
|
|
|
var w = angular.element($window);
|
2016-06-28 07:12:25 +02:00
|
|
|
|
2016-06-25 21:12:17 +02:00
|
|
|
scope.getDimension = function() {
|
|
|
|
return {'h' : w.height()};
|
|
|
|
};
|
2016-06-28 07:12:25 +02:00
|
|
|
|
2016-06-25 21:12:17 +02:00
|
|
|
if(!angular.isDefined(scope.subsHeight)) scope.subsHeight = 110;
|
2016-06-29 06:04:33 +02:00
|
|
|
if(!angular.isDefined(scope.subsSection)) scope.subsSection = 32;
|
2016-06-25 21:12:17 +02:00
|
|
|
if(!angular.isDefined(scope.subsSubPane)) scope.subsSubPane = 226;
|
2016-06-29 06:04:33 +02:00
|
|
|
if(!angular.isDefined(scope.subsTblBody)) scope.subsTblBody = 40;
|
|
|
|
|
2016-06-25 21:12:17 +02:00
|
|
|
scope.$watch(scope.getDimension, function(current) {
|
|
|
|
if(current) {
|
2016-06-28 07:12:25 +02:00
|
|
|
var h = current.h;
|
2016-07-06 19:12:20 +02:00
|
|
|
element.css({'height': (h - scope.subsHeight) + 'px'});
|
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'});
|
2016-07-06 19:12:20 +02:00
|
|
|
element.find('.tab-pane').css({'height': (h - scope.subsHeight - scope.subsSubPane - scope.subsSection -100) + 'px'});
|
2016-06-30 09:57:00 +02:00
|
|
|
// var subPaneHeight = element.find('.sub-pane').height();
|
|
|
|
// element.find('.table-body-container').css({'height': (subPaneHeight - scope.subsTblBody) + 'px'});
|
2016-06-25 21:12:17 +02:00
|
|
|
}
|
|
|
|
}, true);
|
2016-06-28 07:12:25 +02:00
|
|
|
|
|
|
|
w.on('pageshow, resize', function() {
|
2016-06-25 21:12:17 +02:00
|
|
|
scope.$apply();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
})();
|