|
7 | 7 |
|
8 | 8 | function GithubUrl(item) { |
9 | 9 | 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 | + }; |
11 | 27 | } |
12 | 28 |
|
13 | 29 | GithubUrl.match = function(a){ |
|
27 | 43 | prepareData: function(data, cb) { |
28 | 44 | // we need additionally the repo info |
29 | 45 | var url = this.url.replace('/issues', ''); |
30 | | - $.getJSON(url, function(repo) { |
| 46 | + $.getJSON(url, getGithubApiJSONP_cb(function(repo) { |
31 | 47 | cb({ |
32 | 48 | issues: data, |
33 | 49 | repo: repo.data |
34 | 50 | }); |
35 | | - }); |
| 51 | + })); |
36 | 52 | }, |
37 | 53 | render: function(data) { |
38 | 54 | if (data.issues.length === 0) { |
|
146 | 162 | } |
147 | 163 |
|
148 | 164 | var self = this; |
149 | | - |
150 | | - this.item.qtip({ |
| 165 | + var qtip; |
| 166 | + var tooltip = this.item.qtip({ |
151 | 167 | content: { |
152 | 168 | ajax: { |
153 | 169 | dataType: 'json', |
154 | 170 | type: 'GET', |
155 | 171 | url: this.url, |
156 | | - success: function(res) { |
157 | | - |
| 172 | + success: getGithubApiJSONP_cb(function(res) { |
158 | 173 | var error; |
159 | 174 | try { |
160 | 175 | // If there was an error data will likely |
|
164 | 179 | } |
165 | 180 | } catch(ignore){ } |
166 | 181 | if( error ){ |
167 | | - this.set('content.text', '<i>' + error + '</i>'); |
| 182 | + qtip.set('content.text', '<i>' + error + '</i>'); |
168 | 183 | return; |
169 | 184 | } |
170 | 185 |
|
171 | | - var qtip = this; |
172 | 186 | self.prepareData(res.data, function(data) { |
173 | 187 | var html = self.render(data); |
174 | 188 | qtip.set('content.text', html); |
|
179 | 193 | } |
180 | 194 | }); |
181 | 195 | }); |
182 | | - } |
| 196 | + }) |
183 | 197 | }, |
184 | 198 | text: '<i class="fa fa-spinner fa-spin"></i>', |
185 | 199 | title: 'Github Info' |
|
196 | 210 | classes: 'qtip-shadow qtip-rounded qtip-light qtip-github', |
197 | 211 | } |
198 | 212 | }); |
| 213 | + qtip = tooltip.qtip('api'); |
199 | 214 | }, |
200 | 215 |
|
201 | 216 | // This loops over the keys/values found in this.config and |
|
0 commit comments