Skip to content

Commit e82cf9c

Browse files
author
yakudza
committed
[WIP] issue 1650
1 parent 8812348 commit e82cf9c

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

root/static/js/github.js

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,23 @@
77

88
function GithubUrl(item) {
99
this.item = $(item);
10-
this.href = this.item.attr('href');
10+
var href = this.item.attr('href').replace('Perl-Email-Project', 'rjbs');
11+
this.href = href; //this.item.attr('href');
12+
}
13+
14+
// Callback to handle Github JSONP redirects
15+
16+
function getGithubApiJSONP_cb(success_cb) {
17+
return function (res) {
18+
if (res.meta.status >= 300 && res.meta.status < 400) {
19+
var location = res.meta.Location;
20+
var redirect_url = location.replace(/(callback=).*?(&)/, '$1?$2');
21+
$.getJSON(redirect_url, success_cb);
22+
}
23+
else {
24+
success_cb.apply(this, arguments);
25+
}
26+
};
1127
}
1228

1329
GithubUrl.match = function(a){
@@ -27,12 +43,12 @@
2743
prepareData: function(data, cb) {
2844
// we need additionally the repo info
2945
var url = this.url.replace('/issues', '');
30-
$.getJSON(url, function(repo) {
46+
$.getJSON(url, getGithubApiJSONP_cb(function(repo) {
3147
cb({
3248
issues: data,
3349
repo: repo.data
3450
});
35-
});
51+
}));
3652
},
3753
render: function(data) {
3854
if (data.issues.length === 0) {
@@ -146,15 +162,14 @@
146162
}
147163

148164
var self = this;
149-
150-
this.item.qtip({
165+
var qtip;
166+
var tooltip = this.item.qtip({
151167
content: {
152168
ajax: {
153169
dataType: 'json',
154170
type: 'GET',
155171
url: this.url,
156-
success: function(res) {
157-
172+
success: getGithubApiJSONP_cb(function(res) {
158173
var error;
159174
try {
160175
// If there was an error data will likely
@@ -164,11 +179,10 @@
164179
}
165180
} catch(ignore){ }
166181
if( error ){
167-
this.set('content.text', '<i>' + error + '</i>');
182+
qtip.set('content.text', '<i>' + error + '</i>');
168183
return;
169184
}
170185

171-
var qtip = this;
172186
self.prepareData(res.data, function(data) {
173187
var html = self.render(data);
174188
qtip.set('content.text', html);
@@ -179,7 +193,7 @@
179193
}
180194
});
181195
});
182-
}
196+
})
183197
},
184198
text: '<i class="fa fa-spinner fa-spin"></i>',
185199
title: 'Github Info'
@@ -196,6 +210,7 @@
196210
classes: 'qtip-shadow qtip-rounded qtip-light qtip-github',
197211
}
198212
});
213+
qtip = tooltip.qtip('api');
199214
},
200215

201216
// This loops over the keys/values found in this.config and

0 commit comments

Comments
 (0)