diff --git a/root/static/js/github.js b/root/static/js/github.js
index 331551cd6c..fe412ec20a 100644
--- a/root/static/js/github.js
+++ b/root/static/js/github.js
@@ -10,6 +10,21 @@
this.href = this.item.attr('href');
}
+ // Callback to handle Github JSONP redirects
+
+ function getGithubApiJSONP_cb(success_cb) {
+ return function (res) {
+ if (res.meta.status >= 300 && res.meta.status < 400) {
+ var location = res.meta.Location;
+ var redirect_url = location.replace(/(callback=).*?(&)/, '$1?$2');
+ $.getJSON(redirect_url, success_cb);
+ }
+ else {
+ success_cb.apply(this, arguments);
+ }
+ };
+ }
+
GithubUrl.match = function(a){
if ($(a).length == 0) return;
@@ -27,12 +42,12 @@
prepareData: function(data, cb) {
// we need additionally the repo info
var url = this.url.replace('/issues', '');
- $.getJSON(url, function(repo) {
+ $.getJSON(url, getGithubApiJSONP_cb(function(repo) {
cb({
issues: data,
repo: repo.data
});
- });
+ }));
},
render: function(data) {
if (data.issues.length === 0) {
@@ -146,15 +161,14 @@
}
var self = this;
-
- this.item.qtip({
+ var qtip;
+ var tooltip = this.item.qtip({
content: {
ajax: {
dataType: 'json',
type: 'GET',
url: this.url,
- success: function(res) {
-
+ success: getGithubApiJSONP_cb(function(res) {
var error;
try {
// If there was an error data will likely
@@ -164,11 +178,10 @@
}
} catch(ignore){ }
if( error ){
- this.set('content.text', '' + error + '');
+ qtip.set('content.text', '' + error + '');
return;
}
- var qtip = this;
self.prepareData(res.data, function(data) {
var html = self.render(data);
qtip.set('content.text', html);
@@ -179,7 +192,7 @@
}
});
});
- }
+ })
},
text: '',
title: 'Github Info'
@@ -196,6 +209,7 @@
classes: 'qtip-shadow qtip-rounded qtip-light qtip-github',
}
});
+ qtip = tooltip.qtip('api');
},
// This loops over the keys/values found in this.config and