diff --git a/.jshintrc b/.jshintrc index 08f27c77..2c347ba0 100644 --- a/.jshintrc +++ b/.jshintrc @@ -27,6 +27,7 @@ "Docs": false, "SwaggerClient": false, "Handlebars": false, - "ApiKeyAuthorization": false + "ApiKeyAuthorization": false, + "PasswordAuthorization": false } } \ No newline at end of file diff --git a/src/main/coffeescript/view/ApiKeyButton.js b/src/main/coffeescript/view/ApiKeyButton.js index 06bc3d90..2a85a5e5 100644 --- a/src/main/coffeescript/view/ApiKeyButton.js +++ b/src/main/coffeescript/view/ApiKeyButton.js @@ -18,8 +18,12 @@ var ApiKeyButton = Backbone.View.extend({ // TODO: append this to global Swagger applyApiKey: function(){ - var authorizations = new ApiKeyAuthorization(this.model.name, $('#input_apiKey_entry').val(), this.model.in); - window.authorizations.add(this.model.name, authorizations); + 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(); }, diff --git a/src/main/coffeescript/view/BasicAuthButton.coffee b/src/main/coffeescript/view/BasicAuthButton.coffee deleted file mode 100644 index 54c96a55..00000000 --- a/src/main/coffeescript/view/BasicAuthButton.coffee +++ /dev/null @@ -1,34 +0,0 @@ -class BasicAuthButton extends Backbone.View - initialize: -> - - render: -> - template = @template() - $(@el).html(template(@model)) - - @ - - events: - "click #basic_auth_button" : "togglePasswordContainer" - "click #apply_basic_auth" : "applyPassword" - - applyPassword: -> - username = $(".input_username").val() - password = $(".input_password").val() - window.authorizations.add(@model.type, new PasswordAuthorization("basic", username, password)) - window.swaggerUi.load() - elem = $('#basic_auth_container').hide() - - - togglePasswordContainer: -> - if $('#basic_auth_container').length > 0 - elem = $('#basic_auth_container').show() - if elem.is ':visible' - elem.slideUp() - else - # hide others - $('.auth_container').hide() - elem.show() - - template: -> - Handlebars.templates.basic_auth_button_view - diff --git a/src/main/coffeescript/view/BasicAuthButton.js b/src/main/coffeescript/view/BasicAuthButton.js new file mode 100644 index 00000000..a7da3992 --- /dev/null +++ b/src/main/coffeescript/view/BasicAuthButton.js @@ -0,0 +1,46 @@ +'use strict'; + +var BasicAuthButton = Backbone.View.extend({ + + + initialize: function () {}, + + render: function(){ + var template = this.template(); + $(this.el).html(template(this.model)); + + return this; + }, + + events: { + 'click #basic_auth_button' : 'togglePasswordContainer', + 'click #apply_basic_auth' : 'applyPassword' + }, + + applyPassword: function(){ + var username = $('.input_username').val(); + var password = $('.input_password').val(); + var basicAuth = new PasswordAuthorization('basic', username, password); + window.authorizations.add(this.model.type, basicAuth); + window.swaggerUi.load(); + $('#basic_auth_container').hide(); + }, + + togglePasswordContainer: function(){ + if ($('#basic_auth_container').length > 0) { + var elem = $('#basic_auth_container').show(); + if (elem.is(':visible')){ + elem.slideUp(); + } else { + // hide others + $('.auth_container').hide(); + elem.show(); + } + } + }, + + template: function(){ + return Handlebars.templates.basic_auth_button_view; + } + +}); \ No newline at end of file