Commit 032a2ee61fb3f1e13233f9f4f4da72b4788ad38f
1 parent
43f48851
Exists in
master
and in
27 other branches
Add loading
Showing
3 changed files
with
36 additions
and
12 deletions
Show diff stats
public/javascripts/application.js
| ... | ... | @@ -1093,4 +1093,12 @@ function notifyMe(title, options) { |
| 1093 | 1093 | // want to be respectful there is no need to bother them any more. |
| 1094 | 1094 | } |
| 1095 | 1095 | |
| 1096 | +function start_fetching(element){ | |
| 1097 | + jQuery(element).append('<div class="fetching-overlay">Loading...</div>'); | |
| 1098 | +} | |
| 1099 | + | |
| 1100 | +function stop_fetching(element){ | |
| 1101 | + jQuery('.fetching-overlay', element).remove(); | |
| 1102 | +} | |
| 1103 | + | |
| 1096 | 1104 | window.isHidden = function isHidden() { return (typeof(document.hidden) != 'undefined') ? document.hidden : !document.hasFocus() }; | ... | ... |
public/javascripts/chat.js
| ... | ... | @@ -596,18 +596,20 @@ jQuery(function($) { |
| 596 | 596 | } |
| 597 | 597 | |
| 598 | 598 | function recent_messages(jid, offset) { |
| 599 | - if(!offset) offset = 0; | |
| 600 | - $.getJSON('/chat/recent_messages', {identifier: getIdentifier(jid), offset: offset}, function(data) { | |
| 601 | - $.each(data, function(i, message) { | |
| 602 | - var body = message['body']; | |
| 603 | - var from = message['from']; | |
| 604 | - var to = message['to']; | |
| 605 | - var date = message['created_at']; | |
| 606 | - var who = from['id']==getCurrentIdentifier() ? 'self' : from['id'] | |
| 607 | - | |
| 608 | - Jabber.show_message(jid, from['name'], body, who, from['id'], date, offset); | |
| 609 | - }); | |
| 610 | - }); | |
| 599 | + if(!offset) offset = 0; | |
| 600 | + start_fetching('.history'); | |
| 601 | + $.getJSON('/chat/recent_messages', {identifier: getIdentifier(jid), offset: offset}, function(data) { | |
| 602 | + $.each(data, function(i, message) { | |
| 603 | + var body = message['body']; | |
| 604 | + var from = message['from']; | |
| 605 | + var to = message['to']; | |
| 606 | + var date = message['created_at']; | |
| 607 | + var who = from['id']==getCurrentIdentifier() ? 'self' : from['id'] | |
| 608 | + | |
| 609 | + Jabber.show_message(jid, from['name'], body, who, from['id'], date, offset); | |
| 610 | + }); | |
| 611 | + stop_fetching('.history'); | |
| 612 | + }); | |
| 611 | 613 | } |
| 612 | 614 | |
| 613 | 615 | function count_unread_messages(jid_id, hide) { | ... | ... |
public/stylesheets/application.css
| ... | ... | @@ -6533,3 +6533,17 @@ li.profile-activity-item.upload_image .activity-gallery-images-count-1 img { |
| 6533 | 6533 | .fetching { |
| 6534 | 6534 | opacity: 0.3; |
| 6535 | 6535 | } |
| 6536 | + | |
| 6537 | +.fetching-overlay { | |
| 6538 | + position: absolute; | |
| 6539 | + top: 0px; | |
| 6540 | + left: 0px; | |
| 6541 | + right: 0px; | |
| 6542 | + bottom: 0px; | |
| 6543 | + background: rgba(0, 0, 0, 0.5); | |
| 6544 | + padding: 10%; | |
| 6545 | + text-align: center; | |
| 6546 | + font-size: 200%; | |
| 6547 | + color: rgb(255, 255, 255); | |
| 6548 | + text-shadow: 0px 0px 10px #FFF; | |
| 6549 | +} | ... | ... |