');
},
- render: function () {
- this.collection.each(function (auth) {
- this.renderOneAuth(auth);
- }, this);
-
- this.$el.html(this.$innerEl.html() ? this.$innerEl : '');
-
- return this;
- },
-
- renderOneAuth: function (authModel) {
- var authEl;
- var type = authModel.get('type');
-
- //todo refactor move view name into var and call new with it.
- if (type === 'apiKey') {
- authEl = new SwaggerUi.Views.ApiKeyAuthView({model: authModel, router: this.router}).render().el;
- } else if (type === 'basic' && this.$innerEl.find('.basic_auth_container').length === 0) {
- authEl = new SwaggerUi.Views.BasicAuthView({model: authModel, router: this.router}).render().el;
- } else if (type === 'oauth2') {
- authEl = new SwaggerUi.Views.Oauth2View({model: authModel, router: this.router}).render().el;
- }
-
- this.$innerEl.append(authEl);
- },
-
- //todo move into collection
- parseData: function (data) {
+ parse: function (data) {
var authz = Object.assign({}, window.swaggerUi.api.clientAuthorizations.authz);
return _.map(data, function (auth, name) {
@@ -19449,6 +19415,49 @@ SwaggerUi.Views.AuthsCollectionView = Backbone.View.extend({
return auth;
});
}
+});
+'use strict';
+
+SwaggerUi.Views.AuthsCollectionView = Backbone.View.extend({
+
+ initialize: function(opts) {
+ this.options = opts || {};
+ this.options.data = this.options.data || {};
+ this.router = this.options.router;
+
+ this.collection = new SwaggerUi.Collections.AuthsCollection(opts.data);
+
+ this.$innerEl = $('
');
+ },
+
+ render: function () {
+ this.collection.each(function (auth) {
+ this.renderOneAuth(auth);
+ }, this);
+
+ this.$el.html(this.$innerEl.html() ? this.$innerEl : '');
+
+ return this;
+ },
+
+ renderOneAuth: function (authModel) {
+ var authEl, authView;
+ var type = authModel.get('type');
+
+ if (type === 'apiKey') {
+ authView = 'ApiKeyAuthView';
+ } else if (type === 'basic' && this.$innerEl.find('.basic_auth_container').length === 0) {
+ authView = 'BasicAuthView';
+ } else if (type === 'oauth2') {
+ authView = 'Oauth2View';
+ }
+
+ if (authView) {
+ authEl = new SwaggerUi.Views[authView]({model: authModel, router: this.router}).render().el;
+ }
+
+ this.$innerEl.append(authEl);
+ }
});
@@ -21963,27 +21972,13 @@ SwaggerUi.Views.PopupView = Backbone.View.extend({
main : '#swagger-ui-container'
},
- initialize: function(){},
+ initialize: function(){
+ this.$el.html(this.template(this.model));
+ },
render: function () {
- var $win, dw, dh, st, dlgWd, dlgHt, top, left;
- $win = $(window);
- dw = $win.width();
- dh = $win.height();
- st = $win.scrollTop();
- this.$el.html(this.template(this.model));
this.$(this.selectors.content).append(this.model.content);
$(this.selectors.main).first().append(this.el);
- dlgWd = this.$el.outerWidth();
- dlgHt = this.$el.outerHeight();
- top = (dh -dlgHt)/2 + st;
-
- left = (dw - dlgWd)/2;
-
- this.$el.css({
- top: (top < 0? 0 : top) + 'px',
- left: (left < 0? 0 : left) + 'px'
- });
this.showPopup();
return this;
diff --git a/dist/swagger-ui.min.js b/dist/swagger-ui.min.js
index da9ec589..ca1f12d9 100644
--- a/dist/swagger-ui.min.js
+++ b/dist/swagger-ui.min.js
@@ -1,9 +1,9 @@
(function(){function e(){e.history=e.history||[],e.history.push(arguments),this.console&&console.log(Array.prototype.slice.call(arguments)[0])}this.Handlebars=this.Handlebars||{},this.Handlebars.templates=this.Handlebars.templates||{},this.Handlebars.templates.apikey_auth=Handlebars.template({1:function(e,t,n,i){var r,a="function",o=t.helperMissing,s=this.escapeExpression;return'
'+s((r=null!=(r=t.value||(null!=e?e.value:e))?r:o,typeof r===a?r.call(e,{name:"value",hash:{},data:i}):r))+"\n"},3:function(e,t,n,i){return'
\n'},compiler:[6,">= 2.0.0-beta.1"],main:function(e,t,n,i){var r,a,o="function",s=t.helperMissing,l=this.escapeExpression,u='
\n"},useData:!0}),this.Handlebars.templates.auth_button_operation=Handlebars.template({1:function(e,t,n,i){return" authorize__btn_operation_login\n"},3:function(e,t,n,i){return" authorize__btn_operation_logout\n"},compiler:[6,">= 2.0.0-beta.1"],main:function(e,t,n,i){var r,a='
\n
\n'},useData:!0}),this.Handlebars.templates.auth_button=Handlebars.template({compiler:[6,">= 2.0.0-beta.1"],main:function(e,t,n,i){return"
Authorize\n"},useData:!0}),this.Handlebars.templates.auth_view=Handlebars.template({1:function(e,t,n,i){return'
\n'},3:function(e,t,n,i){return'
\n'},compiler:[6,">= 2.0.0-beta.1"],main:function(e,t,n,i){var r,a='
\n\n
\n
\n';return r=t.unless.call(e,null!=e?e.isLogout:e,{name:"unless",hash:{},fn:this.program(1,i),inverse:this.noop,data:i}),null!=r&&(a+=r),r=t["if"].call(e,null!=e?e.isAuthorized:e,{name:"if",hash:{},fn:this.program(3,i),inverse:this.noop,data:i}),null!=r&&(a+=r),a+"
\n\n
\n"},useData:!0}),this.Handlebars.templates.basic_auth=Handlebars.template({1:function(e,t,n,i){return" - authorized"},3:function(e,t,n,i){var r,a="function",o=t.helperMissing,s=this.escapeExpression;return'
'+s((r=null!=(r=t.username||(null!=e?e.username:e))?r:o,typeof r===a?r.call(e,{name:"username",hash:{},data:i}):r))+"\n"},5:function(e,t,n,i){return'
\n'},7:function(e,t,n,i){return'
\n password:\n \n
\n'},compiler:[6,">= 2.0.0-beta.1"],main:function(e,t,n,i){var r,a,o="function",s=t.helperMissing,l=this.escapeExpression,u="
\n
Basic authentication";return r=t["if"].call(e,null!=e?e.isLogout:e,{name:"if",hash:{},fn:this.program(1,i),inverse:this.noop,data:i}),null!=r&&(u+=r),u+='
\n
\n
\n"},useData:!0}),this.Handlebars.templates.content_type=Handlebars.template({1:function(e,t,n,i){var r,a="";return r=t.each.call(e,null!=e?e.produces:e,{name:"each",hash:{},fn:this.program(2,i),inverse:this.noop,data:i}),null!=r&&(a+=r),a},2:function(e,t,n,i){var r=this.lambda,a=this.escapeExpression;return'
\n"},4:function(e,t,n,i){return'
\n'},compiler:[6,">= 2.0.0-beta.1"],main:function(e,t,n,i){var r,a,o="function",s=t.helperMissing,l=this.escapeExpression,u='
\n
\n"},useData:!0}),$(function(){$.fn.vAlign=function(){return this.each(function(){var e=$(this).height(),t=$(this).parent().height(),n=(t-e)/2;$(this).css("margin-top",n)})},$.fn.stretchFormtasticInputWidthToParent=function(){return this.each(function(){var e=$(this).closest("form").innerWidth(),t=parseInt($(this).closest("form").css("padding-left"),10)+parseInt($(this).closest("form").css("padding-right"),10),n=parseInt($(this).css("padding-left"),10)+parseInt($(this).css("padding-right"),10);$(this).css("width",e-t-n)})},$("form.formtastic li.string input, form.formtastic textarea").stretchFormtasticInputWidthToParent(),$("ul.downplayed li div.content p").vAlign(),$("form.sandbox").submit(function(){var e=!0;return $(this).find("input.required").each(function(){$(this).removeClass("error"),""===$(this).val()&&($(this).addClass("error"),$(this).wiggle(),e=!1)}),e})}),Function.prototype.bind&&console&&"object"==typeof console.log&&["log","info","warn","error","assert","dir","clear","profile","profileEnd"].forEach(function(e){console[e]=this.bind(console[e],console)},Function.prototype.call),window.Docs={shebang:function(){var e=$.param.fragment().split("/");switch(e.shift(),e.length){case 1:if(e[0].length>0){var t="resource_"+e[0];Docs.expandEndpointListForResource(e[0]),$("#"+t).slideto({highlight:!1})}break;case 2:Docs.expandEndpointListForResource(e[0]),$("#"+t).slideto({highlight:!1});var n=e.join("_"),i=n+"_content";Docs.expandOperation($("#"+i)),$("#"+n).slideto({highlight:!1})}},toggleEndpointListForResource:function(e){var t=$("li#resource_"+Docs.escapeResourceName(e)+" ul.endpoints");t.is(":visible")?($.bbq.pushState("#/",2),Docs.collapseEndpointListForResource(e)):($.bbq.pushState("#/"+e,2),Docs.expandEndpointListForResource(e))},expandEndpointListForResource:function(e){var e=Docs.escapeResourceName(e);if(""==e)return void $(".resource ul.endpoints").slideDown();$("li#resource_"+e).addClass("active");var t=$("li#resource_"+e+" ul.endpoints");t.slideDown()},collapseEndpointListForResource:function(e){var e=Docs.escapeResourceName(e);if(""==e)return void $(".resource ul.endpoints").slideUp();$("li#resource_"+e).removeClass("active");var t=$("li#resource_"+e+" ul.endpoints");t.slideUp()},expandOperationsForResource:function(e){return Docs.expandEndpointListForResource(e),""==e?void $(".resource ul.endpoints li.operation div.content").slideDown():void $("li#resource_"+Docs.escapeResourceName(e)+" li.operation div.content").each(function(){Docs.expandOperation($(this))})},collapseOperationsForResource:function(e){return Docs.expandEndpointListForResource(e),""==e?void $(".resource ul.endpoints li.operation div.content").slideUp():void $("li#resource_"+Docs.escapeResourceName(e)+" li.operation div.content").each(function(){Docs.collapseOperation($(this))})},escapeResourceName:function(e){return e.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]\^`{|}~]/g,"\\$&")},expandOperation:function(e){e.slideDown()},collapseOperation:function(e){e.slideUp()}},Handlebars.registerHelper("sanitize",function(e){return e=e.replace(/