Move all files to javascript folder and remove coffeescript folder
This commit is contained in:
51
src/main/javascript/view/ApiKeyButton.js
Normal file
51
src/main/javascript/view/ApiKeyButton.js
Normal file
@@ -0,0 +1,51 @@
|
||||
'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 keyAuth = new ApiKeyAuthorization(
|
||||
this.model.name,
|
||||
$('#input_apiKey_entry').val(),
|
||||
this.model.in
|
||||
);
|
||||
window.authorizations.add(this.model.name, keyAuth);
|
||||
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