Merge branch 'MDL-31499-master-iframe' of git://github.com/FMCorz/moodle
[moodle.git] / lib / form / filemanager.js
index fe16bed..132cbf7 100644 (file)
@@ -100,9 +100,8 @@ M.form_filemanager.init = function(Y, options) {
                 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,
@@ -234,27 +233,27 @@ M.form_filemanager.init = function(Y, options) {
                 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() {
@@ -302,8 +301,7 @@ M.form_filemanager.init = function(Y, options) {
                         });
                     }
                     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,
@@ -370,7 +368,6 @@ M.form_filemanager.init = function(Y, options) {
                         }
                         e.currentTarget.addClass('checked')
                         this.render();
-                        //Y.Cookie.set('recentviewmode', this.viewmode);
                     }
                 }, this);
         },
@@ -533,6 +530,9 @@ M.form_filemanager.init = function(Y, options) {
                     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);
                 }
@@ -682,10 +682,9 @@ M.form_filemanager.init = function(Y, options) {
         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,
@@ -870,7 +869,7 @@ M.form_filemanager.init = function(Y, options) {
             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);