dash_class.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. define([
  2. 'lodash',
  3. 'jquery',
  4. '../core_module',
  5. ],
  6. function (_, $, coreModule) {
  7. 'use strict';
  8. coreModule.default.directive('dashClass', function() {
  9. return {
  10. link: function($scope, elem) {
  11. var lastHideControlsVal;
  12. $scope.onAppEvent('panel-fullscreen-enter', function() {
  13. elem.toggleClass('panel-in-fullscreen', true);
  14. });
  15. $scope.onAppEvent('panel-fullscreen-exit', function() {
  16. elem.toggleClass('panel-in-fullscreen', false);
  17. });
  18. $scope.$watch('dashboard.hideControls', function() {
  19. if (!$scope.dashboard) {
  20. return;
  21. }
  22. var hideControls = $scope.dashboard.hideControls || $scope.playlist_active;
  23. if (lastHideControlsVal !== hideControls) {
  24. elem.toggleClass('hide-controls', hideControls);
  25. lastHideControlsVal = hideControls;
  26. }
  27. });
  28. $scope.$watch('playlistSrv', function(newValue) {
  29. elem.toggleClass('playlist-active', _.isObject(newValue));
  30. });
  31. }
  32. };
  33. });
  34. });