Skip to content
Browse files

MDL-31656 Open files in a new window when downloading with the filema…

…nager

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.
  • Loading branch information...
1 parent 0dde394 commit f0a163ed6d8ef2a65968c12f7b01ad73ff050d93 @andrewnicols andrewnicols committed Feb 16, 2012
Showing with 6 additions and 1 deletion.
  1. +6 −1 lib/form/filemanager.js
View
7 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}};

0 comments on commit f0a163e

Please sign in to comment.
Something went wrong with that request. Please try again.