Merge branch 'MDL-31499-master-iframe' of git://github.com/FMCorz/moodle
authorAparup Banerjee <aparup@moodle.com>
Thu, 14 Jun 2012 09:08:18 +0000 (17:08 +0800)
committerAparup Banerjee <aparup@moodle.com>
Thu, 14 Jun 2012 09:08:18 +0000 (17:08 +0800)
1  2 
lib/form/filemanager.js

diff --combined lib/form/filemanager.js
@@@ -100,8 -100,9 +100,8 @@@ M.form_filemanager.init = function(Y, o
                  this.pathbar.removeChild(this.pathnode);
              }
              // initialize 'select file' panel
 -            this.selectnode = Y.Node.create(M.form_filemanager.templates.fileselectlayout);
 +            this.selectnode = Y.Node.createWithFilesSkin(M.form_filemanager.templates.fileselectlayout);
              this.selectnode.generateID();
 -            Y.one(document.body).appendChild(this.selectnode);
              this.selectui = new Y.Panel({
                  srcNode      : this.selectnode,
                  zIndex       : 600000,
                  header = M.str.moodle.info;
              }
              if (!this.msg_dlg) {
 -                var node = Y.Node.create(M.form_filemanager.templates.message);
 -                this.filemanager.appendChild(node);
 +                this.msg_dlg_node = Y.Node.createWithFilesSkin(M.form_filemanager.templates.message);
 +                var nodeid = this.msg_dlg_node.generateID();
  
                  this.msg_dlg = new Y.Panel({
 -                    srcNode      : node,
 +                    srcNode      : this.msg_dlg_node,
                      zIndex       : 800000,
                      centered     : true,
                      modal        : true,
                      visible      : false,
                      render       : true
                  });
 -                this.msg_dlg.plug(Y.Plugin.Drag,{handles:['.yui3-widget-hd']});
 -                node.one('.fp-msg-butok').on('click', function(e) {
 +                this.msg_dlg.plug(Y.Plugin.Drag,{handles:['#'+nodeid+' .yui3-widget-hd']});
 +                this.msg_dlg_node.one('.fp-msg-butok').on('click', function(e) {
                      e.preventDefault();
                      this.msg_dlg.hide();
                  }, this);
              }
  
              this.msg_dlg.set('headerContent', header);
 -            this.filemanager.one('.fp-msg').removeClass('fp-msg-info').removeClass('fp-msg-error').addClass('fp-msg-'+type)
 -            this.filemanager.one('.fp-msg .fp-msg-text').setContent(msg);
 +            this.msg_dlg_node.removeClass('fp-msg-info').removeClass('fp-msg-error').addClass('fp-msg-'+type)
 +            this.msg_dlg_node.one('.fp-msg-text').setContent(msg);
              this.msg_dlg.show();
          },
          setup_buttons: function() {
                          });
                      }
                      if (!this.mkdir_dialog) {
 -                        var node = Y.Node.create(M.form_filemanager.templates.mkdir);
 -                        this.filemanager.appendChild(node);
 +                        var node = Y.Node.createWithFilesSkin(M.form_filemanager.templates.mkdir);
                          this.mkdir_dialog = new Y.Panel({
                              srcNode      : node,
                              zIndex       : 800000,
                      callback: function(id, obj, args) {
                          if (obj) {
                              scope.refresh(obj.filepath);
-                             var win = window.open(obj.fileurl, 'fm-download-folder');
-                             if (!win) {
-                                 scope.print_msg(M.str.repository.popupblockeddownload, 'error');
-                             }
+                             node = Y.Node.create('<iframe></iframe>').setStyles({
+                                 visibility : 'hidden',
+                                 width : '1px',
+                                 height : '1px'
+                             });
+                             node.set('src', obj.fileurl);
+                             Y.one('body').appendChild(node);
                          } else {
                              scope.print_msg(M.str.repository.draftareanofiles, 'error');
                          }
                          }
                          e.currentTarget.addClass('checked')
                          this.render();
 -                        //Y.Cookie.set('recentviewmode', this.viewmode);
                      }
                  }, this);
          },
                      if (node.refcount) {
                          classname = classname + ' fp-hasreferences';
                      }
 +                    if (node.originalmissing) {
 +                        classname = classname + ' fp-originalmissing';
 +                    }
                      if (node.sortorder == 1) { classname = classname + ' fp-mainfile';}
                      return Y.Lang.trim(classname);
                  }
          show_confirm_dialog: function(dialog_options) {
              // instead of M.util.show_confirm_dialog(e, dialog_options);
              if (!this.confirm_dlg) {
 -                this.confirm_dlg_node = Y.Node.create(M.form_filemanager.templates.confirmdialog);
 +                this.confirm_dlg_node = Y.Node.createWithFilesSkin(M.form_filemanager.templates.confirmdialog);
                  var node = this.confirm_dlg_node;
                  node.generateID();
 -                Y.one(document.body).appendChild(node);
                  this.confirm_dlg = new Y.Panel({
                      srcNode      : node,
                      zIndex       : 800000,
              this.selectui.fileinfo = node;
              selectnode.one('.fp-saveas input').set('value', node.fullname);
              var foldername = this.get_parent_folder_name(node);
 -            selectnode.all('.fp-author input').set('value', node.author);
 +            selectnode.all('.fp-author input').set('value', node.author ? node.author : '');
              selectnode.all('.fp-license select option[selected]').set('selected', false);
              selectnode.all('.fp-license select option[value='+node.license+']').set('selected', true);
              selectnode.all('.fp-path select option[selected]').set('selected', false);