Sha256: 82e6f25d2f5da9f68c6264c03b24ce054fbd31aa983b90da2a84d263e7f917a4

Contents?: true

Size: 1.47 KB

Versions: 2

Compression:

Stored size: 1.47 KB

Contents

app.controller("MenuCtrl", function($scope, $state, Documentation) {

  $scope.versions = [];
  $scope.links = {};
  $scope.selectedVersion = '';
  $scope.currentType = '';

  Documentation.getIndex().success(function(index) {

    _.forEach(index, function(items, version) {
      $scope.versions.push(version);
      var links = $scope.links[version] = [];

      _.forEach(items, function(item, name) {
        var link = { name: name, stateRef: '' };

        if (item.controller) {
          link.stateRef = $state.href('root.controller', { version: version, controller: item.controller });
          link.typeName = item.controller;
        }
        else if (item.media_type) {
          link.stateRef = $state.href('root.type', { version: version, type: item.media_type });
          link.typeName = item.media_type;
        }
        else if (item.kind) {
          link.stateRef = $state.href('root.type', { version: version, type: item.kind });
          link.typeName = item.kind;
        }

        links.push(link);
      });
    });
    $scope.selectedVersion = $state.params.version || $scope.versions[0];

  });

  $scope.select = function(version) {
    $scope.selectedVersion = version;
  };

  $scope.availableLinks = function() {
    return $scope.links[$scope.selectedVersion];
  }

  $scope.$on('$stateChangeSuccess', function(e, state, params) {
    if (params.version) $scope.selectedVersion = params.version;
    $scope.currentType = params.controller || params.type;
  });
});

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
praxis-0.13.0 lib/api_browser/app/js/controllers/menu.js
praxis-0.11.2 lib/api_browser/app/js/controllers/menu.js