return false;
}
-function browseThreads(attachfunc) {
+function browseThreads(attachfunc, closefunc) {
$('#attachThreadList').find('option').remove();
$('#attachThreadMessageId').val('');
+ $('#attachModal').off('hidden.bs.modal');
+ $('#attachModal').on('hidden.bs.modal', function(e) {
+ if (closefunc) closefunc();
+ });
$('#attachModal').modal();
findLatestThreads();
}
-function attachThread(cfid, patchid) {
+function attachThread(cfid, patchid, closefunc) {
browseThreads(function(msgid) {
- doAttachThread(cfid, patchid, msgid);
+ doAttachThread(cfid, patchid, msgid, !closefunc);
+ if (closefunc) {
+ /* We don't really care about closing it, we just reload immediately */
+ closefunc();
+ }
+ },
+ function() {
+ if (closefunc) closefunc();
});
}
}
}
-function doAttachThread(cfid, patchid, msgid) {
+function doAttachThread(cfid, patchid, msgid, reloadonsuccess) {
$.post('/ajax/attachThread/', {
'cf': cfid,
'p': patchid,
'msg': msgid,
}).success(function(data) {
- location.reload();
+ if (reloadonsuccess)
+ location.reload();
return true;
}).fail(function(data) {
if (data.status == 404) {
{%if user.is_authenticated%}
<div style="float:right"><button class="btn btn-default" onclick="attachThread({{cf.id}},{{patch.id}})">Attach thread</button></div>
{%else%}
- <div style="float:right"><button class="btn btn-default" onclick="location.href='/login_and_redirect_back'">Attach thread</button></div>
+ <div style="float:right"><button class="btn btn-default" onclick="location.href='/account/login/?next=/{{cf.id}}/{{patch.id}}/%3Fattachthreadnow'">Attach thread</button></div>
{%endif%}
<dl>
{%for t in patch.mailthread_set.all%}
$(o).tooltip();
});
});
+{%if attachnow%}
+$(document).ready(function() {
+ attachThread({{cf.id}},{{patch.id}}, function() {
+ document.location.replace('/{{cf.id}}/{{patch.id}}/');
+ });
+});
+{%endif%}
</script>
{%endblock%}
'is_this_committer': is_this_committer,
'is_reviewer': is_reviewer,
'committers': committers,
+ 'attachnow': request.GET.has_key('attachthreadnow'),
'title': patch.name,
'breadcrumbs': [{'title': cf.title, 'href': '/%s/' % cf.pk},],
}, context_instance=RequestContext(request))