body_class.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. define([
  2. 'lodash',
  3. 'jquery',
  4. '../core_module',
  5. ],
  6. function (_, $, coreModule) {
  7. 'use strict';
  8. coreModule.directive('bodyClass', function() {
  9. return {
  10. link: function($scope, elem) {
  11. var lastHideControlsVal;
  12. // tooltip removal fix
  13. $scope.$on("$routeChangeSuccess", function() {
  14. $("#tooltip, .tooltip").remove();
  15. });
  16. $scope.$watch('submenuEnabled', function() {
  17. if (!$scope.dashboard) {
  18. return;
  19. }
  20. elem.toggleClass('submenu-controls-visible', $scope.submenuEnabled);
  21. });
  22. $scope.$watch('dashboard.hideControls', function() {
  23. if (!$scope.dashboard) {
  24. return;
  25. }
  26. var hideControls = $scope.dashboard.hideControls || $scope.playlist_active;
  27. if (lastHideControlsVal !== hideControls) {
  28. elem.toggleClass('hide-controls', hideControls);
  29. lastHideControlsVal = hideControls;
  30. }
  31. });
  32. $scope.$watch('playlistSrv', function(newValue) {
  33. elem.toggleClass('playlist-active', _.isObject(newValue));
  34. });
  35. }
  36. };
  37. });
  38. });