Skip to content

Commit

Permalink
Add code to hide the loading icon for the web widget and show origina…
Browse files Browse the repository at this point in the history
…l link if the AJAX call failed
  • Loading branch information
LaurentGoderre committed Oct 30, 2012
1 parent e4278c9 commit 6d398a6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
2 changes: 1 addition & 1 deletion build/js/pe-ap-min.js

Large diffs are not rendered by default.

31 changes: 20 additions & 11 deletions src/js/workers/webwidget.js
Expand Up @@ -91,7 +91,7 @@
}
},
_exec: function (elm, type) {
var $response, feeds, limit, typeObj, entries, i, last, process_entries, parse_entries, _results;
var $loading, $content, feeds, limit, typeObj, entries, i, last, process_entries, parse_entries, _results;
limit = _pe.limit(elm);
feeds = elm.find('a').map(function () {
var a = this.href;
Expand All @@ -106,8 +106,11 @@
}
return a;
});
$response = $('<ul class="widget-content"><li class="widget-state-loading"><img src="' + pe.add.liblocation + 'images/webfeeds/ajax-loader.gif" alt="' + pe.dic.get('%loading') + '" /></li></ul>');
elm.find('.widget-content').replaceWith($response);

$loading = $('<li class="widget-state-loading"><img src="' + pe.add.liblocation + 'images/webfeeds/ajax-loader.gif" alt="' + pe.dic.get('%loading') + '" /></li>');
$content = elm.find('.widget-content');
$content.find('li').hide();
$content.append($loading);

typeObj = _pe.fn.webwidget[type];

Expand All @@ -119,15 +122,21 @@

process_entries = function (data) {
var k, len;
data = typeObj._map_entries(data);
for (k = 0, len = data.length; k < len; k += 1) {
entries.push(data[k]);
}
if (!last) {
parse_entries(entries, limit, $response);
try{
data = typeObj._map_entries(data);
for (k = 0, len = data.length; k < len; k += 1) {
entries.push(data[k]);
}
if (!last) {
parse_entries(entries, limit, $content);
}

last -= 1;
return last;
}finally{
$loading.remove();
$content.find('li').show();
}
last -= 1;
return last;
};

while (i >= 0) {
Expand Down

0 comments on commit 6d398a6

Please sign in to comment.