github.com/qubitproducts/logspray@v0.2.14/server/swagger-ui/src/main/javascript/view/HeaderView.js (about) 1 'use strict'; 2 3 SwaggerUi.Views.HeaderView = Backbone.View.extend({ 4 events: { 5 'click #show-pet-store-icon' : 'showPetStore', 6 'click #explore' : 'showCustom', 7 'submit #api_selector' : 'showCustom', 8 'keyup #input_baseUrl' : 'showCustomOnKeyup', 9 'keyup #input_apiKey' : 'showCustomOnKeyup' 10 }, 11 12 initialize: function(){}, 13 14 showPetStore: function(){ 15 this.trigger('update-swagger-ui', { 16 url:'http://petstore.swagger.io/v2/swagger.json' 17 }); 18 }, 19 20 showCustomOnKeyup: function(e){ 21 if (e.keyCode === 13) { 22 this.showCustom(); 23 } 24 }, 25 26 showCustom: function(e){ 27 if (e) { 28 e.preventDefault(); 29 } 30 31 this.trigger('update-swagger-ui', { 32 url: $('#input_baseUrl').val() 33 }); 34 }, 35 36 update: function(url, apiKey, trigger){ 37 if (trigger === undefined) { 38 trigger = false; 39 } 40 41 $('#input_baseUrl').val(url); 42 43 if (trigger) { 44 this.trigger('update-swagger-ui', {url:url}); 45 } 46 } 47 });