dash_class.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. $scope.onAppEvent('panel-fullscreen-enter', function() {
  12. elem.toggleClass('panel-in-fullscreen', true);
  13. });
  14. $scope.onAppEvent('panel-fullscreen-exit', function() {
  15. elem.toggleClass('panel-in-fullscreen', false);
  16. });
  17. var lastHideControlsVal;
  18. $scope.$watch('ctrl.dashboard.hideControls', function() {
  19. if (!$scope.dashboard) {
  20. return;
  21. }
  22. var hideControls = $scope.dashboard.hideControls;
  23. if (lastHideControlsVal !== hideControls) {
  24. elem.toggleClass('hide-controls', hideControls);
  25. lastHideControlsVal = hideControls;
  26. }
  27. });
  28. $scope.$watch('ctrl.playlistSrv.isPlaying', function(newValue) {
  29. elem.toggleClass('playlist-active', newValue === true);
  30. });
  31. $scope.$watch('ctrl.dashboardViewState.state.editview', function(newValue) {
  32. if (newValue) {
  33. elem.toggleClass('dashboard-page--settings-opening', _.isString(newValue));
  34. setTimeout(function() {
  35. elem.toggleClass('dashboard-page--settings-open', _.isString(newValue));
  36. }, 10);
  37. } else {
  38. elem.removeClass('dashboard-page--settings-opening');
  39. elem.removeClass('dashboard-page--settings-open');
  40. }
  41. });
  42. }
  43. };
  44. });
  45. });