From 0c73b725f4740635fe7aad75fd7fd1ca945d73a7 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 17 Nov 2015 21:19:05 +0530 Subject: [PATCH] Modal wrapper for ajax_send --- src/pyj/modals.pyj | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/pyj/modals.pyj b/src/pyj/modals.pyj index c9a90e1346..7de1f0bd73 100644 --- a/src/pyj/modals.pyj +++ b/src/pyj/modals.pyj @@ -1,7 +1,7 @@ # vim:fileencoding=utf-8 # License: GPL v3 Copyright: 2015, Kovid Goyal -from ajax import ajax +from ajax import ajax, ajax_send from elementmaker import E from dom import set_css, clear, build_rule from gettext import gettext as _ @@ -224,3 +224,16 @@ def ajax_progress_dialog(path, on_complete, msg, **kw): xhr = ajax(path, on_complete_callback, on_progress=on_progress_callback, **kw) pd = progress_dialog(msg, xhr.abort) return xhr, pd + +def ajax_send_progress_dialog(path, data, on_complete, msg, **kw): + pd = None + def on_complete_callback(event_type, xhr, ev): + nonlocal pd + pd.close() + pd = undefined + return on_complete(event_type, xhr, ev) + def on_progress_callback(loaded, total, xhr): + pd.update_progress(loaded, total) + xhr = ajax_send(path, data, on_complete_callback, on_progress=on_progress_callback, **kw) + pd = progress_dialog(msg, xhr.abort) + return xhr, pd