From f0a163ed6d8ef2a65968c12f7b01ad73ff050d93 Mon Sep 17 00:00:00 2001 From: Andrew Robert Nicols Date: Thu, 16 Feb 2012 11:39:44 +0000 Subject: [PATCH] MDL-31656 Open files in a new window when downloading with the filemanager We need to open files in a new window rather than the existing window to prevent warning messages when files are uploaded and then downloaded without the form being saved first. --- lib/form/filemanager.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/form/filemanager.js b/lib/form/filemanager.js index de89ff33ff8..cd3b3ec66ae 100644 --- a/lib/form/filemanager.js +++ b/lib/form/filemanager.js @@ -450,7 +450,7 @@ M.form_filemanager.init = function(Y, options) { var scope = this; var menuitems = [ - {text: M.str.moodle.download, url:file.url} + {text: M.str.moodle.download, onclick:{fn:open_file_in_new_window, obj:file, scope:this}} ]; function setmainfile(type, ev, obj) { var file = obj[node.get('id')]; @@ -467,6 +467,11 @@ M.form_filemanager.init = function(Y, options) { } }); } + function open_file_in_new_window(type, ev, obj) { + // We open in a new window rather than changing the current windows URL as we don't + // want to navigate away from the page + window.open(obj.url, 'fm-download-file'); + } if (this.enablemainfile && (file.sortorder != 1)) { var mainid = '#id_'+this.enablemainfile; var menu = {text: M.str.repository.setmainfile, onclick:{fn: setmainfile, obj:data, scope:this}}; -- 2.43.0