This commit is contained in:
Tony Tam
2015-07-22 18:05:52 -07:00
5 changed files with 80 additions and 58 deletions

30
dist/css/screen.css vendored
View File

@@ -1155,8 +1155,16 @@
.swagger-section .auth { .swagger-section .auth {
float: right; float: right;
} }
.swagger-section #api_information_panel { .swagger-section .api-ic {
position: absolute; height: 18px;
vertical-align: middle;
display: inline-block;
background: url(../images/explorer_icons.png) no-repeat;
}
.swagger-section .api-ic .api_information_panel {
position: relative;
margin-top: 20px;
margin-left: -5px;
background: #FFF; background: #FFF;
border: 1px solid #ccc; border: 1px solid #ccc;
border-radius: 5px; border-radius: 5px;
@@ -1167,34 +1175,32 @@
color: black; color: black;
padding: 5px; padding: 5px;
} }
.swagger-section #api_information_panel p .api-msg-enabled { .swagger-section .api-ic .api_information_panel p .api-msg-enabled {
color: green; color: green;
} }
.swagger-section #api_information_panel p .api-msg-disabled { .swagger-section .api-ic .api_information_panel p .api-msg-disabled {
color: red; color: red;
} }
.swagger-section .api-ic { .swagger-section .api-ic:hover .api_information_panel {
height: 18px; position: absolute;
vertical-align: middle; display: block;
display: inline-block;
background: url(../images/explorer_icons.png) no-repeat;
} }
.swagger-section .ic-info { .swagger-section .ic-info {
background-position: 0 0; background-position: 0 0;
width: 18px; width: 18px;
margin-top: -7px; margin-top: -6px;
margin-left: 4px; margin-left: 4px;
} }
.swagger-section .ic-warning { .swagger-section .ic-warning {
background-position: -60px 0; background-position: -60px 0;
width: 18px; width: 18px;
margin-top: -7px; margin-top: -6px;
margin-left: 4px; margin-left: 4px;
} }
.swagger-section .ic-error { .swagger-section .ic-error {
background-position: -30px 0; background-position: -30px 0;
width: 18px; width: 18px;
margin-top: -7px; margin-top: -6px;
margin-left: 4px; margin-left: 4px;
} }
.swagger-section .ic-off { .swagger-section .ic-off {

View File

@@ -40,6 +40,7 @@ function handleLogin() {
appName = window.swaggerUi.api.info.title; appName = window.swaggerUi.api.info.title;
} }
$('.api-popup-dialog').remove();
popupDialog = $( popupDialog = $(
[ [
'<div class="api-popup-dialog">', '<div class="api-popup-dialog">',
@@ -240,7 +241,7 @@ window.onOAuthComplete = function onOAuthComplete(token) {
if(b){ if(b){
// if all roles are satisfied // if all roles are satisfied
var o = null; var o = null;
$.each($('.auth #api_information_panel'), function(k, v) { $.each($('.auth .api-ic .api_information_panel'), function(k, v) {
var children = v; var children = v;
if(children && children.childNodes) { if(children && children.childNodes) {
var requiredScopes = []; var requiredScopes = [];
@@ -257,7 +258,7 @@ window.onOAuthComplete = function onOAuthComplete(token) {
} }
} }
if(diff.length > 0){ if(diff.length > 0){
o = v.parentNode; o = v.parentNode.parentNode;
$(o.parentNode).find('.api-ic.ic-on').addClass('ic-off'); $(o.parentNode).find('.api-ic.ic-on').addClass('ic-off');
$(o.parentNode).find('.api-ic.ic-on').removeClass('ic-on'); $(o.parentNode).find('.api-ic.ic-on').removeClass('ic-on');
@@ -266,7 +267,7 @@ window.onOAuthComplete = function onOAuthComplete(token) {
$(o).find('.api-ic').removeClass('ic-error'); $(o).find('.api-ic').removeClass('ic-error');
} }
else { else {
o = v.parentNode; o = v.parentNode.parentNode;
$(o.parentNode).find('.api-ic.ic-off').addClass('ic-on'); $(o.parentNode).find('.api-ic.ic-off').addClass('ic-on');
$(o.parentNode).find('.api-ic.ic-off').removeClass('ic-off'); $(o.parentNode).find('.api-ic.ic-off').removeClass('ic-off');

35
dist/swagger-ui.js vendored
View File

@@ -8,9 +8,9 @@
this["Handlebars"]["templates"] = this["Handlebars"]["templates"] || {}; this["Handlebars"]["templates"] = this["Handlebars"]["templates"] || {};
this["Handlebars"]["templates"]["apikey_button_view"] = Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) { this["Handlebars"]["templates"]["apikey_button_view"] = Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression; var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
return "<!--div class='auth_button' id='apikey_button'><img class='auth_icon' alt='apply api key' src='images/apikey.jpeg'></div-->\n<div class='auth_container' id='apikey_container'>\n <div class='key_input_container'>\n <div class='auth_label'>" return "<!--div class='auth_button' id='apikey_button'><img class='auth_icon' alt='apply api key' src='images/apikey.jpeg'></div-->\n<div class='auth_container' id='apikey_container'>\n <div class='key_input_container'>\n <div class='auth_label'><label for='input_apiKey_entry'>"
+ escapeExpression(((helper = (helper = helpers.keyName || (depth0 != null ? depth0.keyName : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"keyName","hash":{},"data":data}) : helper))) + escapeExpression(((helper = (helper = helpers.keyName || (depth0 != null ? depth0.keyName : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"keyName","hash":{},"data":data}) : helper)))
+ "</div>\n <input placeholder=\"api_key\" class=\"auth_input\" id=\"input_apiKey_entry\" name=\"apiKey\" type=\"text\"/>\n <div class='auth_submit'><a class='auth_submit_button' id=\"apply_api_key\" href=\"#\" data-sw-translate>apply</a></div>\n </div>\n</div>\n\n"; + "</label></div>\n <input placeholder='api_key' class='auth_input' id='input_apiKey_entry' name='apiKey' type='text'/>\n <div class='auth_submit'><a class='auth_submit_button' id='apply_api_key' href='#' data-sw-translate>apply</a></div>\n </div>\n</div>\n";
},"useData":true}); },"useData":true});
this["Handlebars"]["templates"]["basic_auth_button_view"] = Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) { this["Handlebars"]["templates"]["basic_auth_button_view"] = Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
return "<div class='auth_button' id='basic_auth_button'><img class='auth_icon' src='images/password.jpeg'></div>\n<div class='auth_container' id='basic_auth_container'>\n <div class='key_input_container'>\n <div class=\"auth_label\"><label for=\"input_username\" data-sw-translate>Username</label></div>\n <input placeholder=\"username\" class=\"auth_input\" id=\"input_username\" name=\"username\" type=\"text\"/>\n <div class=\"auth_label\"><label for=\"password\" data-sw-translate>Password</label></div>\n <input placeholder=\"password\" class=\"auth_input\" id=\"input_password\" name=\"password\" type=\"password\"/>\n <div class='auth_submit'><a class='auth_submit_button' id=\"apply_basic_auth\" href=\"#\">apply</a></div>\n </div>\n</div>\n\n"; return "<div class='auth_button' id='basic_auth_button'><img class='auth_icon' src='images/password.jpeg'></div>\n<div class='auth_container' id='basic_auth_container'>\n <div class='key_input_container'>\n <div class=\"auth_label\"><label for=\"input_username\" data-sw-translate>Username</label></div>\n <input placeholder=\"username\" class=\"auth_input\" id=\"input_username\" name=\"username\" type=\"text\"/>\n <div class=\"auth_label\"><label for=\"password\" data-sw-translate>Password</label></div>\n <input placeholder=\"password\" class=\"auth_input\" id=\"input_password\" name=\"password\" type=\"password\"/>\n <div class='auth_submit'><a class='auth_submit_button' id=\"apply_basic_auth\" href=\"#\">apply</a></div>\n </div>\n</div>\n\n";
@@ -253,6 +253,14 @@ Handlebars.registerHelper('renderTextParam', function(param) {
var isArray = param.type.toLowerCase() === 'array' || param.allowMultiple; var isArray = param.type.toLowerCase() === 'array' || param.allowMultiple;
var defaultValue = isArray && Array.isArray(param.default) ? param.default.join('\n') : param.default; var defaultValue = isArray && Array.isArray(param.default) ? param.default.join('\n') : param.default;
var dataVendorExtensions = Object.keys(param).filter(function(property) {
// filter X-data- properties
return property.match(/^X-data-/i) !== null;
}).reduce(function(result, property) {
// remove X- from property name, so it results in html attributes like data-foo='bar'
return result += ' ' + property.substring(2, property.length) + '=\'' + param[property] + '\'';
}, '');
if (typeof defaultValue === 'undefined') { if (typeof defaultValue === 'undefined') {
defaultValue = ''; defaultValue = '';
} }
@@ -266,7 +274,7 @@ Handlebars.registerHelper('renderTextParam', function(param) {
} }
if(isArray) { if(isArray) {
result = '<textarea class=\'body-textarea' + (param.required ? ' required' : '') + '\' name=\'' + param.name + '\'' + idAtt; result = '<textarea class=\'body-textarea' + (param.required ? ' required' : '') + '\' name=\'' + param.name + '\'' + idAtt + dataVendorExtensions;
result += ' placeholder=\'Provide multiple values in new lines' + (param.required ? ' (at least one required).' : '.') + '\'>'; result += ' placeholder=\'Provide multiple values in new lines' + (param.required ? ' (at least one required).' : '.') + '\'>';
result += defaultValue + '</textarea>'; result += defaultValue + '</textarea>';
} else { } else {
@@ -275,7 +283,7 @@ Handlebars.registerHelper('renderTextParam', function(param) {
parameterClass += ' required'; parameterClass += ' required';
} }
result = '<input class=\'' + parameterClass + '\' minlength=\'' + (param.required ? 1 : 0) + '\''; result = '<input class=\'' + parameterClass + '\' minlength=\'' + (param.required ? 1 : 0) + '\'';
result += ' name=\'' + param.name +'\' placeholder=\'' + (param.required ? '(required)' : '') + '\'' + idAtt; result += ' name=\'' + param.name +'\' placeholder=\'' + (param.required ? '(required)' : '') + '\'' + idAtt + dataVendorExtensions;
result += ' type=\'' + type + '\' value=\'' + defaultValue + '\'/>'; result += ' type=\'' + type + '\' value=\'' + defaultValue + '\'/>';
} }
return new Handlebars.SafeString(result); return new Handlebars.SafeString(result);
@@ -386,9 +394,9 @@ this["Handlebars"]["templates"]["operation"] = Handlebars.template({"1":function
if (stack1 != null) { buffer += stack1; } if (stack1 != null) { buffer += stack1; }
return buffer + "</div>\n"; return buffer + "</div>\n";
},"7":function(depth0,helpers,partials,data) { },"7":function(depth0,helpers,partials,data) {
return " <div class=\"auth\">\n <span class=\"api-ic ic-error\"></span>"; return " <div class=\"auth\">\n <span class=\"api-ic ic-error\">";
},"9":function(depth0,helpers,partials,data) { },"9":function(depth0,helpers,partials,data) {
var stack1, buffer = " <div id=\"api_information_panel\" style=\"top: 526px; left: 776px; display: none;\">\n"; var stack1, buffer = " <div class=\"api_information_panel\">\n";
stack1 = helpers.each.call(depth0, depth0, {"name":"each","hash":{},"fn":this.program(10, data),"inverse":this.noop,"data":data}); stack1 = helpers.each.call(depth0, depth0, {"name":"each","hash":{},"fn":this.program(10, data),"inverse":this.noop,"data":data});
if (stack1 != null) { buffer += stack1; } if (stack1 != null) { buffer += stack1; }
return buffer + " </div>\n"; return buffer + " </div>\n";
@@ -400,7 +408,7 @@ this["Handlebars"]["templates"]["operation"] = Handlebars.template({"1":function
+ escapeExpression(lambda((depth0 != null ? depth0.scope : depth0), depth0)) + escapeExpression(lambda((depth0 != null ? depth0.scope : depth0), depth0))
+ "</div>\n"; + "</div>\n";
},"12":function(depth0,helpers,partials,data) { },"12":function(depth0,helpers,partials,data) {
return "</div>"; return "</span></div>";
},"14":function(depth0,helpers,partials,data) { },"14":function(depth0,helpers,partials,data) {
return " <div class='access'>\n <span class=\"api-ic ic-off\" title=\"click to authenticate\"></span>\n </div>\n"; return " <div class='access'>\n <span class=\"api-ic ic-off\" title=\"click to authenticate\"></span>\n </div>\n";
},"16":function(depth0,helpers,partials,data) { },"16":function(depth0,helpers,partials,data) {
@@ -31155,7 +31163,6 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
'click .response_hider' : 'hideResponse', 'click .response_hider' : 'hideResponse',
'click .toggleOperation' : 'toggleOperationContent', 'click .toggleOperation' : 'toggleOperationContent',
'mouseenter .api-ic' : 'mouseEnter', 'mouseenter .api-ic' : 'mouseEnter',
'mouseout .api-ic' : 'mouseExit',
'dblclick .curl' : 'selectText', 'dblclick .curl' : 'selectText',
}, },
@@ -31218,11 +31225,6 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
pos.top = y; pos.top = y;
pos.left = x; pos.left = x;
elem.css(pos); elem.css(pos);
$(e.currentTarget.parentNode).find('#api_information_panel').show();
},
mouseExit: function(e) {
$(e.currentTarget.parentNode).find('#api_information_panel').hide();
}, },
// Note: copied from CoffeeScript compiled file // Note: copied from CoffeeScript compiled file
@@ -31241,9 +31243,9 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
for (l = 0, len = modelAuths.length; l < len; l++) { for (l = 0, len = modelAuths.length; l < len; l++) {
auths = modelAuths[l]; auths = modelAuths[l];
for (key in auths) { for (key in auths) {
auth = auths[key];
for (a in this.auths) { for (a in this.auths) {
auth = this.auths[a]; auth = this.auths[a];
if (key === auth.name) {
if (auth.type === 'oauth2') { if (auth.type === 'oauth2') {
this.model.oauth = {}; this.model.oauth = {};
this.model.oauth.scopes = []; this.model.oauth.scopes = [];
@@ -31263,6 +31265,7 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
} }
} }
} }
}
} else { } else {
for (k in modelAuths) { for (k in modelAuths) {
v = modelAuths[k]; v = modelAuths[k];
@@ -32122,7 +32125,9 @@ SwaggerUi.Views.SignatureView = Backbone.View.extend({
if (e) { e.preventDefault(); } if (e) { e.preventDefault(); }
var textArea = $('textarea', $(this.el.parentNode.parentNode.parentNode)); var textArea = $('textarea', $(this.el.parentNode.parentNode.parentNode));
if ($.trim(textArea.val()) === '') {
// Fix for bug in IE 10/11 which causes placeholder text to be copied to "value"
if ($.trim(textArea.val()) === '' || textArea.prop('placeholder') === textArea.val()) {
textArea.val(this.model.sampleJSON); textArea.val(this.model.sampleJSON);
} }
} }

File diff suppressed because one or more lines are too long

View File

@@ -11,6 +11,14 @@ Handlebars.registerHelper('renderTextParam', function(param) {
var isArray = param.type.toLowerCase() === 'array' || param.allowMultiple; var isArray = param.type.toLowerCase() === 'array' || param.allowMultiple;
var defaultValue = isArray && Array.isArray(param.default) ? param.default.join('\n') : param.default; var defaultValue = isArray && Array.isArray(param.default) ? param.default.join('\n') : param.default;
var dataVendorExtensions = Object.keys(param).filter(function(property) {
// filter X-data- properties
return property.match(/^X-data-/i) !== null;
}).reduce(function(result, property) {
// remove X- from property name, so it results in html attributes like data-foo='bar'
return result += ' ' + property.substring(2, property.length) + '=\'' + param[property] + '\'';
}, '');
if (typeof defaultValue === 'undefined') { if (typeof defaultValue === 'undefined') {
defaultValue = ''; defaultValue = '';
} }
@@ -24,7 +32,7 @@ Handlebars.registerHelper('renderTextParam', function(param) {
} }
if(isArray) { if(isArray) {
result = '<textarea class=\'body-textarea' + (param.required ? ' required' : '') + '\' name=\'' + param.name + '\'' + idAtt; result = '<textarea class=\'body-textarea' + (param.required ? ' required' : '') + '\' name=\'' + param.name + '\'' + idAtt + dataVendorExtensions;
result += ' placeholder=\'Provide multiple values in new lines' + (param.required ? ' (at least one required).' : '.') + '\'>'; result += ' placeholder=\'Provide multiple values in new lines' + (param.required ? ' (at least one required).' : '.') + '\'>';
result += defaultValue + '</textarea>'; result += defaultValue + '</textarea>';
} else { } else {
@@ -33,7 +41,7 @@ Handlebars.registerHelper('renderTextParam', function(param) {
parameterClass += ' required'; parameterClass += ' required';
} }
result = '<input class=\'' + parameterClass + '\' minlength=\'' + (param.required ? 1 : 0) + '\''; result = '<input class=\'' + parameterClass + '\' minlength=\'' + (param.required ? 1 : 0) + '\'';
result += ' name=\'' + param.name +'\' placeholder=\'' + (param.required ? '(required)' : '') + '\'' + idAtt; result += ' name=\'' + param.name +'\' placeholder=\'' + (param.required ? '(required)' : '') + '\'' + idAtt + dataVendorExtensions;
result += ' type=\'' + type + '\' value=\'' + defaultValue + '\'/>'; result += ' type=\'' + type + '\' value=\'' + defaultValue + '\'/>';
} }
return new Handlebars.SafeString(result); return new Handlebars.SafeString(result);