/*! * ui-grid - v4.6.6 - 2018-11-16 * Copyright (c) 2018 ; License: MIT */ (function () { 'use strict'; /** * @ngdoc overview * @name ui.grid.emptyBaseLayer * @description * * # ui.grid.emptyBaseLayer * *
* ** Or you can enable/disable it dynamically by passing in true or false. It doesn't * the value, so it would only be set on initial render. *
* **/ module.directive('uiGridEmptyBaseLayer', ['gridUtil', 'uiGridBaseLayerService', '$parse', function (gridUtil, uiGridBaseLayerService, $parse) { return { require: '^uiGrid', scope: false, compile: function () { return { pre: function ($scope, $elm, $attrs, uiGridCtrl) { var disableEmptyBaseLayer = $parse($attrs.uiGridEmptyBaseLayer)($scope) === false; uiGridBaseLayerService.initializeGrid(uiGridCtrl.grid, disableEmptyBaseLayer); }, post: function ($scope, $elm, $attrs, uiGridCtrl) { if (!uiGridCtrl.grid.options.enableEmptyGridBaseLayer) { return; } var renderBodyContainer = uiGridCtrl.grid.renderContainers.body, viewportHeight = renderBodyContainer.getViewportHeight(); function heightHasChanged() { var newViewPortHeight = renderBodyContainer.getViewportHeight(); if (newViewPortHeight !== viewportHeight) { viewportHeight = newViewPortHeight; return true; } return false; } function getEmptyBaseLayerCss(viewportHeight) { // Set ui-grid-empty-base-layer height return '.grid' + uiGridCtrl.grid.id + ' .ui-grid-render-container ' + '.ui-grid-empty-base-layer-container.ui-grid-canvas ' + '{ height: ' + viewportHeight + 'px; }'; } uiGridCtrl.grid.registerStyleComputation({ func: function() { if (heightHasChanged()) { uiGridBaseLayerService.setNumberOfEmptyRows(viewportHeight, uiGridCtrl.grid); } return getEmptyBaseLayerCss(viewportHeight); } }); } }; } }; }]); /** * @ngdoc directive * @name ui.grid.emptyBaseLayer.directive:uiGridViewport * @description stacks on the uiGridViewport directive to append the empty grid base layer html elements to the * default gridRow template */ module.directive('uiGridViewport', ['$compile', 'gridUtil', '$templateCache', function ($compile, gridUtil, $templateCache) { return { priority: -200, scope: false, compile: function ($elm) { var emptyBaseLayerContainer = $templateCache.get('ui-grid/emptyBaseLayerContainer'); $elm.prepend(emptyBaseLayerContainer); return { pre: function ($scope, $elm, $attrs, controllers) { }, post: function ($scope, $elm, $attrs, controllers) { } }; } }; }]); })();