56 lines
1.2 KiB
JavaScript
56 lines
1.2 KiB
JavaScript
'use strict';
|
|
|
|
SwaggerUi.Views.HeaderView = Backbone.View.extend({
|
|
events: {
|
|
'click #show-pet-store-icon' : 'showPetStore',
|
|
'click #show-wordnik-dev-icon' : 'showWordnikDev',
|
|
'click #explore' : 'showCustom',
|
|
'keyup #input_baseUrl' : 'showCustomOnKeyup',
|
|
'keyup #input_apiKey' : 'showCustomOnKeyup'
|
|
},
|
|
|
|
initialize: function(){},
|
|
|
|
showPetStore: function(){
|
|
this.trigger('update-swagger-ui', {
|
|
url:'http://petstore.swagger.io/v2/swagger.json'
|
|
});
|
|
},
|
|
|
|
showWordnikDev: function(){
|
|
this.trigger('update-swagger-ui', {
|
|
url: 'http://api.wordnik.com/v4/resources.json'
|
|
});
|
|
},
|
|
|
|
showCustomOnKeyup: function(e){
|
|
if (e.keyCode === 13) {
|
|
this.showCustom();
|
|
}
|
|
},
|
|
|
|
showCustom: function(e){
|
|
if (e) {
|
|
e.preventDefault();
|
|
}
|
|
|
|
this.trigger('update-swagger-ui', {
|
|
url: $('#input_baseUrl').val(),
|
|
apiKey: $('#input_apiKey').val()
|
|
});
|
|
},
|
|
|
|
update: function(url, apiKey, trigger){
|
|
if (trigger === undefined) {
|
|
trigger = false;
|
|
}
|
|
|
|
$('#input_baseUrl').val(url);
|
|
|
|
//$('#input_apiKey').val(apiKey);
|
|
if (trigger) {
|
|
this.trigger('update-swagger-ui', {url:url});
|
|
}
|
|
}
|
|
});
|