ie8 fixes

This commit is contained in:
Tony Tam
2014-02-27 19:55:56 -08:00
parent 2a642f5a5f
commit 7b77ffd079
5 changed files with 222 additions and 194 deletions

15
dist/lib/swagger.js vendored
View File

@@ -1,5 +1,5 @@
// swagger.js // swagger.js
// version 2.0.21 // version 2.0.22
var __bind = function(fn, me){ var __bind = function(fn, me){
return function(){ return function(){
@@ -15,6 +15,15 @@ log = function(){
} }
}; };
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function(obj, start) {
for (var i = (start || 0), j = this.length; i < j; i++) {
if (this[i] === obj) { return i; }
}
return -1;
}
}
var SwaggerApi = function(url, options) { var SwaggerApi = function(url, options) {
this.url = null; this.url = null;
this.debug = false; this.debug = false;
@@ -949,7 +958,7 @@ var SwaggerRequest = function(type, url, params, opts, successCallback, errorCal
} }
} }
responseContentType = null; var responseContentType = null;
if (this.opts.responseContentType) { if (this.opts.responseContentType) {
responseContentType = this.opts.responseContentType; responseContentType = this.opts.responseContentType;
} else { } else {
@@ -1116,7 +1125,7 @@ JQueryHttpClient.prototype.execute = function(obj) {
headers: headers headers: headers
}; };
var contentType = (response._headers["content-type"]||response._headers["Content-Type"]||null) var contentType = (headers["content-type"]||headers["Content-Type"]||null)
if(contentType != null) { if(contentType != null) {
if(contentType.indexOf("application/json") == 0 || contentType.indexOf("+json") > 0) { if(contentType.indexOf("application/json") == 0 || contentType.indexOf("+json") > 0) {

373
dist/swagger-ui.js vendored
View File

@@ -1,187 +1,192 @@
$(function() { $(function() {
// Helper function for vertically aligning DOM elements // Helper function for vertically aligning DOM elements
// http://www.seodenver.com/simple-vertical-align-plugin-for-jquery/ // http://www.seodenver.com/simple-vertical-align-plugin-for-jquery/
$.fn.vAlign = function() { $.fn.vAlign = function() {
return this.each(function(i){ return this.each(function(i){
var ah = $(this).height(); var ah = $(this).height();
var ph = $(this).parent().height(); var ph = $(this).parent().height();
var mh = (ph - ah) / 2; var mh = (ph - ah) / 2;
$(this).css('margin-top', mh); $(this).css('margin-top', mh);
}); });
}; };
$.fn.stretchFormtasticInputWidthToParent = function() { $.fn.stretchFormtasticInputWidthToParent = function() {
return this.each(function(i){ return this.each(function(i){
var p_width = $(this).closest("form").innerWidth(); var p_width = $(this).closest("form").innerWidth();
var p_padding = parseInt($(this).closest("form").css('padding-left') ,10) + parseInt($(this).closest("form").css('padding-right'), 10); var p_padding = parseInt($(this).closest("form").css('padding-left') ,10) + parseInt($(this).closest("form").css('padding-right'), 10);
var this_padding = parseInt($(this).css('padding-left'), 10) + parseInt($(this).css('padding-right'), 10); var this_padding = parseInt($(this).css('padding-left'), 10) + parseInt($(this).css('padding-right'), 10);
$(this).css('width', p_width - p_padding - this_padding); $(this).css('width', p_width - p_padding - this_padding);
}); });
}; };
$('form.formtastic li.string input, form.formtastic textarea').stretchFormtasticInputWidthToParent(); $('form.formtastic li.string input, form.formtastic textarea').stretchFormtasticInputWidthToParent();
// Vertically center these paragraphs // Vertically center these paragraphs
// Parent may need a min-height for this to work.. // Parent may need a min-height for this to work..
$('ul.downplayed li div.content p').vAlign(); $('ul.downplayed li div.content p').vAlign();
// When a sandbox form is submitted.. // When a sandbox form is submitted..
$("form.sandbox").submit(function(){ $("form.sandbox").submit(function(){
var error_free = true; var error_free = true;
// Cycle through the forms required inputs // Cycle through the forms required inputs
$(this).find("input.required").each(function() { $(this).find("input.required").each(function() {
// Remove any existing error styles from the input // Remove any existing error styles from the input
$(this).removeClass('error'); $(this).removeClass('error');
// Tack the error style on if the input is empty.. // Tack the error style on if the input is empty..
if ($(this).val() == '') { if ($(this).val() == '') {
$(this).addClass('error'); $(this).addClass('error');
$(this).wiggle(); $(this).wiggle();
error_free = false; error_free = false;
} }
}); });
return error_free; return error_free;
}); });
}); });
function clippyCopiedCallback(a) { function clippyCopiedCallback(a) {
$('#api_key_copied').fadeIn().delay(1000).fadeOut(); $('#api_key_copied').fadeIn().delay(1000).fadeOut();
// var b = $("#clippy_tooltip_" + a); // var b = $("#clippy_tooltip_" + a);
// b.length != 0 && (b.attr("title", "copied!").trigger("tipsy.reload"), setTimeout(function() { // b.length != 0 && (b.attr("title", "copied!").trigger("tipsy.reload"), setTimeout(function() {
// b.attr("title", "copy to clipboard") // b.attr("title", "copy to clipboard")
// }, // },
// 500)) // 500))
} }
// Logging function that accounts for browsers that don't have window.console // Logging function that accounts for browsers that don't have window.console
function log() { log = function(){
if (window.console) console.log.apply(console,arguments); log.history = log.history || [];
} log.history.push(arguments);
// Handle browsers that do console incorrectly (IE9 and below, see http://stackoverflow.com/a/5539378/7913) if(this.console){
if (Function.prototype.bind && console && typeof console.log == "object") { console.log( Array.prototype.slice.call(arguments) );
[ }
"log","info","warn","error","assert","dir","clear","profile","profileEnd" };
].forEach(function (method) {
console[method] = this.bind(console[method], console); // Handle browsers that do console incorrectly (IE9 and below, see http://stackoverflow.com/a/5539378/7913)
}, Function.prototype.call); if (Function.prototype.bind && console && typeof console.log == "object") {
} [
"log","info","warn","error","assert","dir","clear","profile","profileEnd"
var Docs = { ].forEach(function (method) {
console[method] = this.bind(console[method], console);
shebang: function() { }, Function.prototype.call);
}
// If shebang has an operation nickname in it..
// e.g. /docs/#!/words/get_search var Docs = {
var fragments = $.param.fragment().split('/');
fragments.shift(); // get rid of the bang shebang: function() {
switch (fragments.length) { // If shebang has an operation nickname in it..
case 1: // e.g. /docs/#!/words/get_search
// Expand all operations for the resource and scroll to it var fragments = $.param.fragment().split('/');
// log('shebang resource:' + fragments[0]); fragments.shift(); // get rid of the bang
var dom_id = 'resource_' + fragments[0];
switch (fragments.length) {
Docs.expandEndpointListForResource(fragments[0]); case 1:
$("#"+dom_id).slideto({highlight: false}); // Expand all operations for the resource and scroll to it
break; // log('shebang resource:' + fragments[0]);
case 2: var dom_id = 'resource_' + fragments[0];
// Refer to the endpoint DOM element, e.g. #words_get_search
// log('shebang endpoint: ' + fragments.join('_')); Docs.expandEndpointListForResource(fragments[0]);
$("#"+dom_id).slideto({highlight: false});
// Expand Resource break;
Docs.expandEndpointListForResource(fragments[0]); case 2:
$("#"+dom_id).slideto({highlight: false}); // Refer to the endpoint DOM element, e.g. #words_get_search
// log('shebang endpoint: ' + fragments.join('_'));
// Expand operation
var li_dom_id = fragments.join('_'); // Expand Resource
var li_content_dom_id = li_dom_id + "_content"; Docs.expandEndpointListForResource(fragments[0]);
$("#"+dom_id).slideto({highlight: false});
// log("li_dom_id " + li_dom_id);
// log("li_content_dom_id " + li_content_dom_id); // Expand operation
var li_dom_id = fragments.join('_');
Docs.expandOperation($('#'+li_content_dom_id)); var li_content_dom_id = li_dom_id + "_content";
$('#'+li_dom_id).slideto({highlight: false});
break; // log("li_dom_id " + li_dom_id);
} // log("li_content_dom_id " + li_content_dom_id);
}, Docs.expandOperation($('#'+li_content_dom_id));
$('#'+li_dom_id).slideto({highlight: false});
toggleEndpointListForResource: function(resource) { break;
var elem = $('li#resource_' + Docs.escapeResourceName(resource) + ' ul.endpoints'); }
if (elem.is(':visible')) {
Docs.collapseEndpointListForResource(resource); },
} else {
Docs.expandEndpointListForResource(resource); toggleEndpointListForResource: function(resource) {
} var elem = $('li#resource_' + Docs.escapeResourceName(resource) + ' ul.endpoints');
}, if (elem.is(':visible')) {
Docs.collapseEndpointListForResource(resource);
// Expand resource } else {
expandEndpointListForResource: function(resource) { Docs.expandEndpointListForResource(resource);
var resource = Docs.escapeResourceName(resource); }
if (resource == '') { },
$('.resource ul.endpoints').slideDown();
return; // Expand resource
} expandEndpointListForResource: function(resource) {
var resource = Docs.escapeResourceName(resource);
$('li#resource_' + resource).addClass('active'); if (resource == '') {
$('.resource ul.endpoints').slideDown();
var elem = $('li#resource_' + resource + ' ul.endpoints'); return;
elem.slideDown(); }
},
$('li#resource_' + resource).addClass('active');
// Collapse resource and mark as explicitly closed
collapseEndpointListForResource: function(resource) { var elem = $('li#resource_' + resource + ' ul.endpoints');
var resource = Docs.escapeResourceName(resource); elem.slideDown();
$('li#resource_' + resource).removeClass('active'); },
var elem = $('li#resource_' + resource + ' ul.endpoints'); // Collapse resource and mark as explicitly closed
elem.slideUp(); collapseEndpointListForResource: function(resource) {
}, var resource = Docs.escapeResourceName(resource);
$('li#resource_' + resource).removeClass('active');
expandOperationsForResource: function(resource) {
// Make sure the resource container is open.. var elem = $('li#resource_' + resource + ' ul.endpoints');
Docs.expandEndpointListForResource(resource); elem.slideUp();
},
if (resource == '') {
$('.resource ul.endpoints li.operation div.content').slideDown(); expandOperationsForResource: function(resource) {
return; // Make sure the resource container is open..
} Docs.expandEndpointListForResource(resource);
$('li#resource_' + Docs.escapeResourceName(resource) + ' li.operation div.content').each(function() { if (resource == '') {
Docs.expandOperation($(this)); $('.resource ul.endpoints li.operation div.content').slideDown();
}); return;
}, }
collapseOperationsForResource: function(resource) { $('li#resource_' + Docs.escapeResourceName(resource) + ' li.operation div.content').each(function() {
// Make sure the resource container is open.. Docs.expandOperation($(this));
Docs.expandEndpointListForResource(resource); });
},
$('li#resource_' + Docs.escapeResourceName(resource) + ' li.operation div.content').each(function() {
Docs.collapseOperation($(this)); collapseOperationsForResource: function(resource) {
}); // Make sure the resource container is open..
}, Docs.expandEndpointListForResource(resource);
escapeResourceName: function(resource) { $('li#resource_' + Docs.escapeResourceName(resource) + ' li.operation div.content').each(function() {
return resource.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]\^`{|}~]/g, "\\$&"); Docs.collapseOperation($(this));
}, });
},
expandOperation: function(elem) {
elem.slideDown(); escapeResourceName: function(resource) {
}, return resource.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]\^`{|}~]/g, "\\$&");
},
collapseOperation: function(elem) {
elem.slideUp(); expandOperation: function(elem) {
} elem.slideDown();
},
};
collapseOperation: function(elem) {
elem.slideUp();
}
};
(function() { (function() {
var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {}; var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
templates['content_type'] = template(function (Handlebars,depth0,helpers,partials,data) { templates['content_type'] = template(function (Handlebars,depth0,helpers,partials,data) {

View File

@@ -1,5 +1,5 @@
// swagger.js // swagger.js
// version 2.0.21 // version 2.0.22
var __bind = function(fn, me){ var __bind = function(fn, me){
return function(){ return function(){
@@ -15,6 +15,15 @@ log = function(){
} }
}; };
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function(obj, start) {
for (var i = (start || 0), j = this.length; i < j; i++) {
if (this[i] === obj) { return i; }
}
return -1;
}
}
var SwaggerApi = function(url, options) { var SwaggerApi = function(url, options) {
this.url = null; this.url = null;
this.debug = false; this.debug = false;
@@ -949,7 +958,7 @@ var SwaggerRequest = function(type, url, params, opts, successCallback, errorCal
} }
} }
responseContentType = null; var responseContentType = null;
if (this.opts.responseContentType) { if (this.opts.responseContentType) {
responseContentType = this.opts.responseContentType; responseContentType = this.opts.responseContentType;
} else { } else {
@@ -1116,7 +1125,7 @@ JQueryHttpClient.prototype.execute = function(obj) {
headers: headers headers: headers
}; };
var contentType = (response._headers["content-type"]||response._headers["Content-Type"]||null) var contentType = (headers["content-type"]||headers["Content-Type"]||null)
if(contentType != null) { if(contentType != null) {
if(contentType.indexOf("application/json") == 0 || contentType.indexOf("+json") > 0) { if(contentType.indexOf("application/json") == 0 || contentType.indexOf("+json") > 0) {

View File

@@ -19,7 +19,7 @@
"readmeFilename": "README.md", "readmeFilename": "README.md",
"dependencies": { "dependencies": {
"coffee-script": "~1.5.0", "coffee-script": "~1.5.0",
"swagger-client": "2.0.21", "swagger-client": "2.0.22",
"handlebars": "~1.0.10", "handlebars": "~1.0.10",
"less": "~1.4.2" "less": "~1.4.2"
} }

View File

@@ -62,9 +62,14 @@ function clippyCopiedCallback(a) {
} }
// Logging function that accounts for browsers that don't have window.console // Logging function that accounts for browsers that don't have window.console
function log() { log = function(){
if (window.console) console.log.apply(console,arguments); log.history = log.history || [];
} log.history.push(arguments);
if(this.console){
console.log( Array.prototype.slice.call(arguments) );
}
};
// Handle browsers that do console incorrectly (IE9 and below, see http://stackoverflow.com/a/5539378/7913) // Handle browsers that do console incorrectly (IE9 and below, see http://stackoverflow.com/a/5539378/7913)
if (Function.prototype.bind && console && typeof console.log == "object") { if (Function.prototype.bind && console && typeof console.log == "object") {
[ [