From 20ac7c89d432e6a8f2c5e8c81c2e4bec0b5543ed Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Thu, 18 Dec 2014 22:50:24 +0800 Subject: [PATCH] don't pop window when export file :koala: --- file/exporter.go | 2 +- static/js/tree.js | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/file/exporter.go b/file/exporter.go index 78c0343..ded145f 100644 --- a/file/exporter.go +++ b/file/exporter.go @@ -43,7 +43,7 @@ func GetZip(w http.ResponseWriter, r *http.Request) { filename := filepath.Base(path) w.Header().Set("Content-Disposition", "attachment; filename="+filename) - w.Header().Set("Content-type", "application/zip") + w.Header().Set("Content-Type", "application/zip") http.ServeFile(w, r, path) os.Remove(path) diff --git a/static/js/tree.js b/static/js/tree.js index c13c4de..f7a4607 100644 --- a/static/js/tree.js +++ b/static/js/tree.js @@ -145,10 +145,12 @@ var tree = { $("#dialogRenamePrompt").dialog("open"); }, export: function () { - var request = newWideRequest(); + var request = newWideRequest(), + isSucc = false; request.path = wide.curNode.path; $.ajax({ + async: false, type: 'POST', url: config.context + '/file/zip/new', data: JSON.stringify(request), @@ -160,9 +162,13 @@ var tree = { return false; } - window.open(config.context + '/file/zip?path=' + wide.curNode.path + '.zip'); + isSucc = true; } }); + + if (isSucc) { + window.open(config.context + '/file/zip?path=' + wide.curNode.path + ".zip"); + } }, refresh: function (it) { if (it) {