github.com/qubitproducts/logspray@v0.2.14/server/swagger-ui/src/main/javascript/view/ApiKeyAuthView.js (about) 1 'use strict'; 2 3 SwaggerUi.Views.ApiKeyAuthView = Backbone.View.extend({ // TODO: append this to global SwaggerUi 4 5 events: { 6 'change .input_apiKey_entry': 'apiKeyChange' 7 }, 8 9 selectors: { 10 apikeyInput: '.input_apiKey_entry' 11 }, 12 13 template: Handlebars.templates.apikey_auth, 14 15 initialize: function(opts) { 16 this.options = opts || {}; 17 this.router = this.options.router; 18 }, 19 20 render: function (){ 21 this.$el.html(this.template(this.model.toJSON())); 22 23 return this; 24 }, 25 26 apiKeyChange: function (e) { 27 var val = $(e.target).val(); 28 if (val) { 29 this.$(this.selectors.apikeyInput).removeClass('error'); 30 } 31 32 this.model.set('value', val); 33 }, 34 35 isValid: function () { 36 return this.model.validate(); 37 }, 38 39 highlightInvalid: function () { 40 if (!this.isValid()) { 41 this.$(this.selectors.apikeyInput).addClass('error'); 42 } 43 } 44 45 });