github.com/qubitproducts/logspray@v0.2.14/server/swagger-ui/src/main/javascript/view/AuthsCollectionView.js (about)

     1  'use strict';
     2  
     3  SwaggerUi.Views.AuthsCollectionView = Backbone.View.extend({
     4  
     5      initialize: function(opts) {
     6          this.options = opts || {};
     7          this.options.data = this.options.data || {};
     8          this.router = this.options.router;
     9  
    10          this.collection = new SwaggerUi.Collections.AuthsCollection(opts.data);
    11  
    12          this.$innerEl = $('<div>');
    13          this.authViews = [];
    14      },
    15  
    16      render: function () {
    17          this.collection.each(function (auth) {
    18              this.renderOneAuth(auth);
    19          }, this);
    20  
    21          this.$el.html(this.$innerEl.html() ? this.$innerEl : '');
    22  
    23          return this;
    24      },
    25  
    26      renderOneAuth: function (authModel) {
    27          var authViewEl, authView, authViewName;
    28          var type = authModel.get('type');
    29  
    30          if (type === 'apiKey') {
    31              authViewName = 'ApiKeyAuthView';
    32          } else if (type === 'basic' && this.$innerEl.find('.basic_auth_container').length === 0) {
    33              authViewName = 'BasicAuthView';
    34          } else if (type === 'oauth2') {
    35              authViewName = 'Oauth2View';
    36          }
    37  
    38          if (authViewName) {
    39              authView = new SwaggerUi.Views[authViewName]({model: authModel, router: this.router});
    40              authViewEl = authView.render().el;
    41              this.authViews.push(authView);
    42          }
    43  
    44          this.$innerEl.append(authViewEl);
    45      },
    46  
    47      highlightInvalid: function () {
    48          this.authViews.forEach(function (view) {
    49              view.highlightInvalid();
    50          }, this);
    51      }
    52  
    53  });