1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-08-02 07:47:32 +00:00

Load events in ajax when myhome is loaded

This commit is contained in:
zhengxie 2013-08-12 15:05:58 +08:00
parent 2745f49893
commit c1eb8eabc2
4 changed files with 11 additions and 25 deletions

View File

@ -92,7 +92,7 @@
<!--mine shared stared -->
{% include "snippets/my_owned_repos.html" %}
{% if events %}
{% if ENABLE_EVENTS %}
{% include "snippets/events.html" %}
{% endif %}
@ -124,7 +124,7 @@
{% include "snippets/repo_create_js.html" %}
{% endwith %}
{% if events %}
{% if ENABLE_EVENTS %}
{% include "snippets/events_js.html" %}
{% endif %}
</script>

View File

@ -5,9 +5,7 @@
{% include "snippets/events_body.html" %}
</div>
<div id="events-loading" class="hide"><img src="{{MEDIA_URL}}img/loading-icon.gif" alt="{% trans 'Loading...' %}" /></div>
{% if events_more %}
<button id="events-more">{% trans 'More' %}</button>
{% endif %}
<button id="events-more" class="hide">{% trans 'More' %}</button>
<p id="events-error" class="error hide"></p>
<form id="repo-decrypt-form" class="simple-input-popup hide">{% csrf_token %}
<h3>{% trans 'Library' %} <span class="op-target"></span> {% trans 'is encrypted' %}</h3>

View File

@ -1,5 +1,6 @@
{% load i18n %}
{% include 'snippets/list_commit_detail.html' %}
function reqEvents(start) {
$('#events-loading').removeClass('hide');
$.ajax({
@ -71,14 +72,12 @@ function showDetailForEncrypRepo(obj) {
}
}
var events_more_offset = {{events_more_offset}};
$('.lsch-encrypted').click(function() {
showDetailForEncrypRepo($(this));
return false;
});
$('#events-more').data('start', events_more_offset).click(function() {
$('#events-more').click(function() {
$(this).addClass('hide');
reqEvents($(this).data('start'));
});
@ -86,3 +85,8 @@ $('.updated-repo').each(function() {
$(this).next().css({'margin-right':$(this).width() + 10});
});
{% include 'snippets/repo_decrypt_js.html' %}
$(function() {
reqEvents(0);
});

View File

@ -870,18 +870,6 @@ def myhome(request):
allow_public_share = False if request.cloud_mode else True
# events
if EVENTS_ENABLED:
events_count = 15
events, events_more_offset = get_user_events(email, 0, events_count)
events_more = True if len(events) == events_count else False
event_groups = group_events_data(events)
else:
events, events_more_offset = None, None
events_more = False
event_groups = None
events_count = 0
starred_files = get_starred_files(request.user.username)
traffic_stat = 0
@ -908,16 +896,12 @@ def myhome(request):
"grpmsg_reply_list": grpmsg_reply_list,
"create_shared_repo": False,
"allow_public_share": allow_public_share,
"events": events,
"events_more_offset": events_more_offset,
"events_more": events_more,
"event_groups": event_groups,
"events_count": events_count,
"starred_files": starred_files,
"TRAFFIC_STATS_ENABLED": TRAFFIC_STATS_ENABLED,
"traffic_stat": traffic_stat,
"ENABLE_PAYMENT": getattr(settings, 'ENABLE_PAYMENT', False),
"ENABLE_SUB_LIBRARY": ENABLE_SUB_LIBRARY,
"ENABLE_EVENTS": EVENTS_ENABLED,
"sub_repos": sub_repos,
}, context_instance=RequestContext(request))