fixes opening url in new tab only in description

This commit is contained in:
bodnia
2016-03-19 10:07:22 +02:00
parent 7a328ba9ad
commit 9c509e5cad
4 changed files with 913 additions and 820 deletions

View File

@@ -14,7 +14,6 @@ SwaggerUi.Views.MainView = Backbone.View.extend({
this.router = opts.router;
document.addEventListener('click', this.onLinkClick, true);
// Sort APIs
if (opts.swaggerOptions.apisSorter) {
sorterOption = opts.swaggerOptions.apisSorter;
@@ -84,6 +83,12 @@ SwaggerUi.Views.MainView = Backbone.View.extend({
render: function () {
$(this.el).html(Handlebars.templates.main(this.model));
this.info = this.$('.info')[0];
if (this.info) {
this.info.addEventListener('click', this.onLinkClick, true);
}
this.model.securityDefinitions = this.model.securityDefinitions || {};
// Render each resource
@@ -136,11 +141,10 @@ SwaggerUi.Views.MainView = Backbone.View.extend({
onLinkClick: function (e) {
var el = e.target;
if (el.tagName === 'A' && el.href) {
if (location.hostname !== el.hostname || location.port !== el.port) {
if (el.tagName === 'A' && el.href && !el.target) {
e.preventDefault();
window.open(el.href, '_blank');
}
}
}
});