Merge branch 'MDL-31656-master-3' of git://git.luns.net.uk/moodle
authorSam Hemelryk <sam@moodle.com>
Sun, 4 Mar 2012 22:09:29 +0000 (11:09 +1300)
committerSam Hemelryk <sam@moodle.com>
Sun, 4 Mar 2012 22:09:29 +0000 (11:09 +1300)
1  2 
lib/form/filemanager.js

diff --combined lib/form/filemanager.js
@@@ -144,9 -144,7 +144,9 @@@ M.form_filemanager.init = function(Y, o
              this.filecount++;
              this.check_buttons();
              this.refresh(this.currentpath);
 -            M.util.set_form_changed();
 +            if (typeof M.core_formchangechecker != 'undefined') {
 +                M.core_formchangechecker.set_form_changed();
 +            }
          },
          check_buttons: function() {
              var button_addfile  = Y.one("#btnadd-"+this.client_id);
                                  scope.mkdir_dialog.hide();
                                  scope.refresh(filepath);
                                  Y.one('#fm-newname').set('value', '');
 -                                M.util.set_form_changed();
 +                                if (typeof M.core_formchangechecker != 'undefined') {
 +                                    M.core_formchangechecker.set_form_changed();
 +                                }
                              }
                          });
                      }
              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')];
                      }
                  });
              }
+             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}};
                          callback: function(id, obj, args) {
                              scope.filecount--;
                              scope.refresh(obj.filepath);
 -                            M.util.set_form_changed();
 +                            if (typeof M.core_formchangechecker != 'undefined') {
 +                                M.core_formchangechecker.set_form_changed();
 +                            }
                              if (scope.filecount < scope.maxfiles && scope.maxfiles!=-1) {
                                  var button_addfile  = Y.one("#btnadd-"+scope.client_id);
                                  button_addfile.setStyle('display', 'inline');
                                  alert(M.str.repository.fileexists);
                              } else {
                                  scope.refresh(obj.filepath);
 -                                M.util.set_form_changed();
 +                                if (typeof M.core_formchangechecker != 'undefined') {
 +                                    M.core_formchangechecker.set_form_changed();
 +                                }
                              }
                              Y.one('#fm-rename-input').set('value', '');
                              scope.rename_dialog.hide();
                              }
                              dialog.cancel();
                              scope.refresh(p);
 -                            M.util.set_form_changed();
 +                            if (typeof M.core_formchangechecker != 'undefined') {
 +                                M.core_formchangechecker.set_form_changed();
 +                            }
                          }
                      });
                  }