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.
This commit is contained in:
Andrew Robert Nicols 2012-02-16 11:39:44 +00:00
parent 0dde394db5
commit f0a163ed6d

View file

@ -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}};