Convert view/HeaderView.coffee
This commit is contained in:
@@ -1,37 +0,0 @@
|
||||
class HeaderView extends Backbone.View
|
||||
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: ->
|
||||
|
||||
showPetStore: (e) ->
|
||||
@trigger(
|
||||
'update-swagger-ui'
|
||||
{url:"http://petstore.swagger.wordnik.com/api/api-docs"}
|
||||
)
|
||||
|
||||
showWordnikDev: (e) ->
|
||||
@trigger(
|
||||
'update-swagger-ui'
|
||||
{url:"http://api.wordnik.com/v4/resources.json"}
|
||||
)
|
||||
|
||||
showCustomOnKeyup: (e) ->
|
||||
@showCustom() if e.keyCode is 13
|
||||
|
||||
showCustom: (e) ->
|
||||
e?.preventDefault()
|
||||
@trigger(
|
||||
'update-swagger-ui'
|
||||
{url: $('#input_baseUrl').val(), apiKey: $('#input_apiKey').val()}
|
||||
)
|
||||
|
||||
update: (url, apiKey, trigger = false) ->
|
||||
$('#input_baseUrl').val url
|
||||
#$('#input_apiKey').val apiKey
|
||||
@trigger 'update-swagger-ui', {url:url} if trigger
|
||||
51
src/main/coffeescript/view/HeaderView.js
Normal file
51
src/main/coffeescript/view/HeaderView.js
Normal file
@@ -0,0 +1,51 @@
|
||||
'use strict';
|
||||
|
||||
var 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.wordnik.com/api/api-docs'
|
||||
});
|
||||
},
|
||||
|
||||
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 = false){
|
||||
$('#input_baseUrl').val(url);
|
||||
|
||||
//$('#input_apiKey').val(apiKey);
|
||||
if (trigger) {
|
||||
this.trigger('update-swagger-ui', {url:url});
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user