Convert view/ApiKeyButton.coffee
This commit is contained in:
@@ -26,6 +26,7 @@
|
|||||||
"MainView": false,
|
"MainView": false,
|
||||||
"Docs": false,
|
"Docs": false,
|
||||||
"SwaggerClient": false,
|
"SwaggerClient": false,
|
||||||
"Handlebars": false
|
"Handlebars": false,
|
||||||
|
"ApiKeyAuthorization": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
class ApiKeyButton extends Backbone.View
|
|
||||||
initialize: ->
|
|
||||||
|
|
||||||
render: ->
|
|
||||||
template = @template()
|
|
||||||
$(@el).html(template(@model))
|
|
||||||
|
|
||||||
@
|
|
||||||
|
|
||||||
events:
|
|
||||||
"click #apikey_button" : "toggleApiKeyContainer"
|
|
||||||
"click #apply_api_key" : "applyApiKey"
|
|
||||||
|
|
||||||
applyApiKey: ->
|
|
||||||
window.authorizations.add(@model.name, new ApiKeyAuthorization(@model.name, $("#input_apiKey_entry").val(), @model.in))
|
|
||||||
window.swaggerUi.load()
|
|
||||||
elem = $('#apikey_container').show()
|
|
||||||
|
|
||||||
toggleApiKeyContainer: ->
|
|
||||||
if $('#apikey_container').length > 0
|
|
||||||
elem = $('#apikey_container').first()
|
|
||||||
if elem.is ':visible'
|
|
||||||
elem.hide()
|
|
||||||
else
|
|
||||||
# hide others
|
|
||||||
$('.auth_container').hide()
|
|
||||||
elem.show()
|
|
||||||
|
|
||||||
template: ->
|
|
||||||
Handlebars.templates.apikey_button_view
|
|
||||||
|
|
||||||
47
src/main/coffeescript/view/ApiKeyButton.js
Normal file
47
src/main/coffeescript/view/ApiKeyButton.js
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var ApiKeyButton = Backbone.View.extend({ // TODO: append this to global SwaggerUi
|
||||||
|
|
||||||
|
events:{
|
||||||
|
'click #apikey_button' : 'toggleApiKeyContainer',
|
||||||
|
'click #apply_api_key' : 'applyApiKey'
|
||||||
|
},
|
||||||
|
|
||||||
|
initialize: function(){},
|
||||||
|
|
||||||
|
render: function(){
|
||||||
|
var template = this.template();
|
||||||
|
$(this.el).html(template(this.model));
|
||||||
|
|
||||||
|
return this;
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
applyApiKey: function(){
|
||||||
|
var authorizations = new ApiKeyAuthorization(this.model.name, $('#input_apiKey_entry').val(), this.model.in);
|
||||||
|
window.authorizations.add(this.model.name, authorizations);
|
||||||
|
window.swaggerUi.load();
|
||||||
|
$('#apikey_container').show();
|
||||||
|
},
|
||||||
|
|
||||||
|
toggleApiKeyContainer: function(){
|
||||||
|
if ($('#apikey_container').length > 0) {
|
||||||
|
|
||||||
|
var elem = $('#apikey_container').first();
|
||||||
|
|
||||||
|
if (elem.is(':visible')){
|
||||||
|
elem.hide();
|
||||||
|
} else {
|
||||||
|
|
||||||
|
// hide others
|
||||||
|
$('.auth_container').hide();
|
||||||
|
elem.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
template: function(){
|
||||||
|
return Handlebars.templates.apikey_button_view;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user