Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

sidebar.controller.js 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /**
  2. * Created by robin on 11/1/15.
  3. */
  4. angular.module('app')
  5. .controller('SideBarController', ['$scope', '$state', 'DataShareBusiness', '$mdDialog',
  6. function($scope, $state, DataShareBusiness, $mdDialog) {
  7. $scope.DataShareBusiness = DataShareBusiness;
  8. $scope.Search = {
  9. value: "",
  10. selected: null
  11. };
  12. $scope.getCurrentGroups = function()
  13. {
  14. if (DataShareBusiness.CurrentGroups.length != 0) {
  15. var e = DataShareBusiness.CurrentGroups[DataShareBusiness.CurrentGroups.length - 1];
  16. if (e.Groups == null || e.Groups.length == 0) {
  17. return e.Parent.Groups;
  18. }
  19. return e.Groups;
  20. }
  21. return DataShareBusiness.Groups;
  22. };
  23. $scope.search = function()
  24. {
  25. var groups = [];
  26. function searchRec(group)
  27. {
  28. if (group.Name.toLowerCase().indexOf($scope.Search.value.toLowerCase()) > -1) {
  29. groups.push(group);
  30. }
  31. if (group.Groups != null) {
  32. group.Groups.forEach(searchRec);
  33. }
  34. }
  35. DataShareBusiness.Groups.forEach(searchRec);
  36. return groups;
  37. };
  38. $scope.goTo = function(group)
  39. {
  40. if (group != null) {
  41. $scope.Search.value = "";
  42. DataShareBusiness.goToGroup(group);
  43. }
  44. };
  45. $scope.goToFirstMatch = function()
  46. {
  47. if ($scope.Search.value.length != 0) {
  48. var groups = $scope.search();
  49. if (groups.length > 0) {
  50. $scope.goTo(groups[0]);
  51. }
  52. }
  53. };
  54. $scope.isInState = function(state)
  55. {
  56. return $state.current.name == state;
  57. };
  58. }]);