dash_class.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import _ from 'lodash';
  2. import coreModule from '../core_module';
  3. coreModule.directive('dashClass', function($timeout) {
  4. return {
  5. link: function($scope, elem) {
  6. $scope.ctrl.dashboard.events.on('view-mode-changed', function(panel) {
  7. if (panel.fullscreen) {
  8. elem.addClass('panel-in-fullscreen');
  9. } else {
  10. $timeout(() => {
  11. elem.removeClass('panel-in-fullscreen');
  12. });
  13. }
  14. });
  15. elem.toggleClass('panel-in-fullscreen', $scope.ctrl.dashboard.meta.fullscreen === true);
  16. $scope.$watch('ctrl.playlistSrv.isPlaying', function(newValue) {
  17. elem.toggleClass('playlist-active', newValue === true);
  18. });
  19. $scope.$watch('ctrl.dashboardViewState.state.editview', function(newValue) {
  20. if (newValue) {
  21. elem.toggleClass('dashboard-page--settings-opening', _.isString(newValue));
  22. setTimeout(function() {
  23. elem.toggleClass('dashboard-page--settings-open', _.isString(newValue));
  24. }, 10);
  25. } else {
  26. elem.removeClass('dashboard-page--settings-opening');
  27. elem.removeClass('dashboard-page--settings-open');
  28. }
  29. });
  30. },
  31. };
  32. });