diff --git a/.jshintrc b/.jshintrc index d7798813..08f27c77 100644 --- a/.jshintrc +++ b/.jshintrc @@ -26,6 +26,7 @@ "MainView": false, "Docs": false, "SwaggerClient": false, - "Handlebars": false + "Handlebars": false, + "ApiKeyAuthorization": false } } \ No newline at end of file diff --git a/src/main/coffeescript/view/ApiKeyButton.coffee b/src/main/coffeescript/view/ApiKeyButton.coffee deleted file mode 100644 index 0b316692..00000000 --- a/src/main/coffeescript/view/ApiKeyButton.coffee +++ /dev/null @@ -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 - diff --git a/src/main/coffeescript/view/ApiKeyButton.js b/src/main/coffeescript/view/ApiKeyButton.js new file mode 100644 index 00000000..06bc3d90 --- /dev/null +++ b/src/main/coffeescript/view/ApiKeyButton.js @@ -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; + } + +}); \ No newline at end of file